diff options
Diffstat (limited to 'drivers/tty')
55 files changed, 1230 insertions, 1425 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index e53d9a512c6d..2caaf5a2516d 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -32,7 +32,6 @@ #include <linux/delay.h> #undef SERIAL_PARANOIA_CHECK -#define SERIAL_DO_RESTART /* Set of debugging defines */ diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index d4a1331675ed..abbed201dc74 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -292,14 +292,14 @@ static void cyz_rx_restart(unsigned long); static struct timer_list cyz_rx_full_timer[NR_PORTS]; #endif /* CONFIG_CYZ_INTR */ -static inline void cyy_writeb(struct cyclades_port *port, u32 reg, u8 val) +static void cyy_writeb(struct cyclades_port *port, u32 reg, u8 val) { struct cyclades_card *card = port->card; cy_writeb(port->u.cyy.base_addr + (reg << card->bus_index), val); } -static inline u8 cyy_readb(struct cyclades_port *port, u32 reg) +static u8 cyy_readb(struct cyclades_port *port, u32 reg) { struct cyclades_card *card = port->card; @@ -321,7 +321,7 @@ static inline bool cyz_fpga_loaded(struct cyclades_card *card) return __cyz_fpga_loaded(card->ctl_addr.p9060); } -static inline bool cyz_is_loaded(struct cyclades_card *card) +static bool cyz_is_loaded(struct cyclades_card *card) { struct FIRM_ID __iomem *fw_id = card->base_addr + ID_ADDRESS; @@ -329,7 +329,7 @@ static inline bool cyz_is_loaded(struct cyclades_card *card) readl(&fw_id->signature) == ZFIRM_ID; } -static inline int serial_paranoia_check(struct cyclades_port *info, +static int serial_paranoia_check(struct cyclades_port *info, const char *name, const char *routine) { #ifdef SERIAL_PARANOIA_CHECK diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index 2054427992e0..99875949bfb7 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c @@ -220,7 +220,7 @@ static struct isi_port isi_ports[PORT_COUNT]; * it wants to talk. */ -static inline int WaitTillCardIsFree(unsigned long base) +static int WaitTillCardIsFree(unsigned long base) { unsigned int count = 0; unsigned int a = in_atomic(); /* do we run under spinlock? */ @@ -280,7 +280,7 @@ static void raise_dtr(struct isi_port *port) } /* card->lock HAS to be held */ -static inline void drop_dtr(struct isi_port *port) +static void drop_dtr(struct isi_port *port) { struct isi_board *card = port->card; unsigned long base = card->base; diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 14c54e041065..92982d7c0489 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -155,7 +155,6 @@ struct mon_str { #define LOWWAIT 2 #define EMPTYWAIT 3 -#define SERIAL_DO_RESTART #define WAKEUP_CHARS 256 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index ed776149261e..d9a5fc28fef4 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -162,12 +162,23 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x, return put_user(x, ptr); } -static inline int tty_copy_to_user(struct tty_struct *tty, - void __user *to, - const void *from, - unsigned long n) +static int tty_copy_to_user(struct tty_struct *tty, void __user *to, + size_t tail, size_t n) { struct n_tty_data *ldata = tty->disc_data; + size_t size = N_TTY_BUF_SIZE - tail; + const void *from = read_buf_addr(ldata, tail); + int uncopied; + + if (n > size) { + tty_audit_add_data(tty, from, size, ldata->icanon); + uncopied = copy_to_user(to, from, size); + if (uncopied) + return uncopied; + to += size; + n -= size; + from = ldata->read_buf; + } tty_audit_add_data(tty, from, n, ldata->icanon); return copy_to_user(to, from, n); @@ -1201,9 +1212,7 @@ static void n_tty_receive_overrun(struct tty_struct *tty) ldata->num_overrun++; if (time_after(jiffies, ldata->overrun_time + HZ) || time_after(ldata->overrun_time, jiffies)) { - printk(KERN_WARNING "%s: %d input overrun(s)\n", - tty_name(tty), - ldata->num_overrun); + tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun); ldata->overrun_time = jiffies; ldata->num_overrun = 0; } @@ -1486,8 +1495,7 @@ n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) n_tty_receive_overrun(tty); break; default: - printk(KERN_ERR "%s: unknown flag %d\n", - tty_name(tty), flag); + tty_err(tty, "unknown flag %d\n", flag); break; } } @@ -2006,11 +2014,11 @@ static int copy_from_read_buf(struct tty_struct *tty, n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); n = min(*nr, n); if (n) { - retval = copy_to_user(*b, read_buf_addr(ldata, tail), n); + const unsigned char *from = read_buf_addr(ldata, tail); + retval = copy_to_user(*b, from, n); n -= retval; - is_eof = n == 1 && read_buf(ldata, tail) == EOF_CHAR(tty); - tty_audit_add_data(tty, read_buf_addr(ldata, tail), n, - ldata->icanon); + is_eof = n == 1 && *from == EOF_CHAR(tty); + tty_audit_add_data(tty, from, n, ldata->icanon); smp_store_release(&ldata->read_tail, ldata->read_tail + n); /* Turn single EOF into zero-length read */ if (L_EXTPROC(tty) && ldata->icanon && is_eof && @@ -2054,13 +2062,13 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, size_t eol; size_t tail; int ret, found = 0; - bool eof_push = 0; /* N.B. avoid overrun if nr == 0 */ - n = min(*nr, smp_load_acquire(&ldata->canon_head) - ldata->read_tail); - if (!n) + if (!*nr) return 0; + n = min(*nr + 1, smp_load_acquire(&ldata->canon_head) - ldata->read_tail); + tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1); size = min_t(size_t, tail + n, N_TTY_BUF_SIZE); @@ -2072,34 +2080,24 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, if (eol == N_TTY_BUF_SIZE && more) { /* scan wrapped without finding set bit */ eol = find_next_bit(ldata->read_flags, more, 0); - if (eol != more) - found = 1; - } else if (eol != size) - found = 1; + found = eol != more; + } else + found = eol != size; - size = N_TTY_BUF_SIZE - tail; n = eol - tail; if (n > N_TTY_BUF_SIZE) n += N_TTY_BUF_SIZE; - n += found; - c = n; + c = n + found; - if (found && !ldata->push && read_buf(ldata, eol) == __DISABLED_CHAR) { - n--; - eof_push = !n && ldata->read_tail != ldata->line_start; + if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) { + c = min(*nr, c); + n = c; } - n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu size:%zu more:%zu\n", - __func__, eol, found, n, c, size, more); - - if (n > size) { - ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), size); - if (ret) - return -EFAULT; - ret = tty_copy_to_user(tty, *b + size, ldata->read_buf, n - size); - } else - ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), n); + n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu tail:%zu more:%zu\n", + __func__, eol, found, n, c, tail, more); + ret = tty_copy_to_user(tty, *b, tail, n); if (ret) return -EFAULT; *b += n; @@ -2116,7 +2114,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, ldata->push = 0; tty_audit_push(tty); } - return eof_push ? -EAGAIN : 0; + return 0; } extern ssize_t redirected_tty_write(struct file *, const char __user *, @@ -2273,10 +2271,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, if (ldata->icanon && !L_EXTPROC(tty)) { retval = canon_copy_from_read_buf(tty, &b, &nr); - if (retval == -EAGAIN) { - retval = 0; - continue; - } else if (retval) + if (retval) break; } else { int uncopied; diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a45660f62db5..b3110040164a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -788,7 +788,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) if (retval) goto err_release; - tty_debug_hangup(tty, "(tty count=%d)\n", tty->count); + tty_debug_hangup(tty, "opening (count=%d)\n", tty->count); tty_unlock(tty); return 0; diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 0140ba4aacde..0982c1a44187 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c @@ -157,7 +157,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty); #endif -static int m68328_console_initted = 0; +static int m68328_console_initted; static int m68328_console_baud = CONSOLE_BAUD_RATE; static int m68328_console_cbaud = DEFAULT_CBAUD; @@ -274,8 +274,8 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx) #endif ch = GET_FIELD(rx, URX_RXDATA); - if(info->is_cons) { - if(URX_BREAK & rx) { /* whee, break received */ + if (info->is_cons) { + if (URX_BREAK & rx) { /* whee, break received */ return; #ifdef CONFIG_MAGIC_SYSRQ } else if (ch == 0x10) { /* ^P */ @@ -302,7 +302,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx) tty_insert_flip_char(&info->tport, ch, flag); #ifndef CONFIG_XCOPILOT_BUGS - } while((rx = uart->urx.w) & URX_DATA_READY); + } while ((rx = uart->urx.w) & URX_DATA_READY); #endif tty_schedule_flip(&info->tport); @@ -330,7 +330,7 @@ static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty) info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1); info->xmit_cnt--; - if(info->xmit_cnt <= 0) { + if (info->xmit_cnt <= 0) { /* All done for now... TX ints off */ uart->ustcnt &= ~USTCNT_TX_INTR_MASK; goto clear_and_return; @@ -452,45 +452,45 @@ struct { } #ifndef CONFIG_M68VZ328 hw_baud_table[18] = { - {0,0}, /* 0 */ - {0,0}, /* 50 */ - {0,0}, /* 75 */ - {0,0}, /* 110 */ - {0,0}, /* 134 */ - {0,0}, /* 150 */ - {0,0}, /* 200 */ - {7,0x26}, /* 300 */ - {6,0x26}, /* 600 */ - {5,0x26}, /* 1200 */ - {0,0}, /* 1800 */ - {4,0x26}, /* 2400 */ - {3,0x26}, /* 4800 */ - {2,0x26}, /* 9600 */ - {1,0x26}, /* 19200 */ - {0,0x26}, /* 38400 */ - {1,0x38}, /* 57600 */ - {0,0x38}, /* 115200 */ + {0, 0}, /* 0 */ + {0, 0}, /* 50 */ + {0, 0}, /* 75 */ + {0, 0}, /* 110 */ + {0, 0}, /* 134 */ + {0, 0}, /* 150 */ + {0, 0}, /* 200 */ + {7, 0x26}, /* 300 */ + {6, 0x26}, /* 600 */ + {5, 0x26}, /* 1200 */ + {0, 0}, /* 1800 */ + {4, 0x26}, /* 2400 */ + {3, 0x26}, /* 4800 */ + {2, 0x26}, /* 9600 */ + {1, 0x26}, /* 19200 */ + {0, 0x26}, /* 38400 */ + {1, 0x38}, /* 57600 */ + {0, 0x38}, /* 115200 */ }; #else hw_baud_table[18] = { - {0,0}, /* 0 */ - {0,0}, /* 50 */ - {0,0}, /* 75 */ - {0,0}, /* 110 */ - {0,0}, /* 134 */ - {0,0}, /* 150 */ - {0,0}, /* 200 */ - {0,0}, /* 300 */ - {7,0x26}, /* 600 */ - {6,0x26}, /* 1200 */ - {0,0}, /* 1800 */ - {5,0x26}, /* 2400 */ - {4,0x26}, /* 4800 */ - {3,0x26}, /* 9600 */ - {2,0x26}, /* 19200 */ - {1,0x26}, /* 38400 */ - {0,0x26}, /* 57600 */ - {1,0x38}, /* 115200 */ + {0, 0}, /* 0 */ + {0, 0}, /* 50 */ + {0, 0}, /* 75 */ + {0, 0}, /* 110 */ + {0, 0}, /* 134 */ + {0, 0}, /* 150 */ + {0, 0}, /* 200 */ + {0, 0}, /* 300 */ + {7, 0x26}, /* 600 */ + {6, 0x26}, /* 1200 */ + {0, 0}, /* 1800 */ + {5, 0x26}, /* 2400 */ + {4, 0x26}, /* 4800 */ + {3, 0x26}, /* 9600 */ + {2, 0x26}, /* 19200 */ + {1, 0x26}, /* 38400 */ + {0, 0x26}, /* 57600 */ + {1, 0x38}, /* 115200 */ }; #endif /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */ @@ -538,7 +538,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty) #ifdef CONFIG_SERIAL_68328_RTS_CTS if (cflag & CRTSCTS) { - uart->utx.w &= ~ UTX_NOCTS; + uart->utx.w &= ~UTX_NOCTS; } else { uart->utx.w |= UTX_NOCTS; } @@ -591,8 +591,8 @@ void console_print_68328(const char *p) { char c; - while((c=*(p++)) != 0) { - if(c == '\n') + while ((c = *(p++)) != 0) { + if (c == '\n') rs_put_char('\r'); rs_put_char(c); } @@ -624,7 +624,7 @@ static void rs_flush_chars(struct tty_struct *tty) if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) return; #ifndef USE_INTS - for(;;) { + for (;;) { #endif /* Enable transmitter */ @@ -659,9 +659,9 @@ static void rs_flush_chars(struct tty_struct *tty) local_irq_restore(flags); } -extern void console_printn(const char * b, int count); +extern void console_printn(const char *b, int count); -static int rs_write(struct tty_struct * tty, +static int rs_write(struct tty_struct *tty, const unsigned char *buf, int count) { int c, total = 0; @@ -700,7 +700,7 @@ static int rs_write(struct tty_struct * tty, /* Enable transmitter */ local_irq_disable(); #ifndef USE_INTS - while(info->xmit_cnt) { + while (info->xmit_cnt) { #endif uart->ustcnt |= USTCNT_TXEN; @@ -767,7 +767,7 @@ static void rs_flush_buffer(struct tty_struct *tty) * incoming characters should be throttled. * ------------------------------------------------------------ */ -static void rs_throttle(struct tty_struct * tty) +static void rs_throttle(struct tty_struct *tty) { struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; @@ -780,7 +780,7 @@ static void rs_throttle(struct tty_struct * tty) /* Turn off RTS line (do this atomic) */ } -static void rs_unthrottle(struct tty_struct * tty) +static void rs_unthrottle(struct tty_struct *tty) { struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; @@ -803,8 +803,8 @@ static void rs_unthrottle(struct tty_struct * tty) * ------------------------------------------------------------ */ -static int get_serial_info(struct m68k_serial * info, - struct serial_struct * retinfo) +static int get_serial_info(struct m68k_serial *info, + struct serial_struct *retinfo) { struct serial_struct tmp; @@ -827,7 +827,7 @@ static int get_serial_info(struct m68k_serial * info, } static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty, - struct serial_struct * new_info) + struct serial_struct *new_info) { struct tty_port *port = &info->tport; struct serial_struct new_serial; @@ -883,7 +883,7 @@ check_and_exit: * transmit holding register is empty. This functionality * allows an RS485 driver to be written in user space. */ -static int get_lsr_info(struct m68k_serial * info, unsigned int *value) +static int get_lsr_info(struct m68k_serial *info, unsigned int *value) { #ifdef CONFIG_SERIAL_68328_RTS_CTS m68328_uart *uart = &uart_addr[info->line]; @@ -904,7 +904,7 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value) /* * This routine sends a break character out the serial port. */ -static void send_break(struct m68k_serial * info, unsigned int duration) +static void send_break(struct m68k_serial *info, unsigned int duration) { m68328_uart *uart = &uart_addr[info->line]; unsigned long flags; @@ -922,7 +922,7 @@ static void send_break(struct m68k_serial * info, unsigned int duration) static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { - struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; + struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; int retval; if (serial_paranoia_check(info, tty->name, "rs_ioctl")) @@ -992,9 +992,9 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) * that IRQ if nothing is left in the chain. * ------------------------------------------------------------ */ -static void rs_close(struct tty_struct *tty, struct file * filp) +static void rs_close(struct tty_struct *tty, struct file *filp) { - struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; + struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; struct tty_port *port = &info->tport; m68328_uart *uart = &uart_addr[info->line]; unsigned long flags; @@ -1079,7 +1079,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) */ void rs_hangup(struct tty_struct *tty) { - struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; + struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; if (serial_paranoia_check(info, tty->name, "rs_hangup")) return; @@ -1098,7 +1098,7 @@ void rs_hangup(struct tty_struct *tty) * the IRQ chain. It also performs the serial-specific * initialization for the tty structure. */ -int rs_open(struct tty_struct *tty, struct file * filp) +int rs_open(struct tty_struct *tty, struct file *filp) { struct m68k_serial *info; int retval; @@ -1180,7 +1180,7 @@ rs68328_init(void) local_irq_save(flags); - for(i=0;i<NR_PORTS;i++) { + for (i = 0; i < NR_PORTS; i++) { info = &m68k_soft[i]; tty_port_init(&info->tport); @@ -1198,7 +1198,7 @@ rs68328_init(void) printk(" is a builtin MC68328 UART\n"); #ifdef CONFIG_M68VZ328 - if (i > 0 ) + if (i > 0) PJSEL &= 0xCF; /* PSW enable second port output */ #endif @@ -1263,7 +1263,7 @@ int m68328_console_setup(struct console *cp, char *arg) return(-1); if (arg) - n = simple_strtoul(arg,NULL,0); + n = simple_strtoul(arg, NULL, 0); for (i = 0; i < ARRAY_SIZE(baud_table); i++) if (baud_table[i] == n) @@ -1279,7 +1279,7 @@ int m68328_console_setup(struct console *cp, char *arg) } m68328_set_baud(); /* make sure baud rate changes */ - return(0); + return 0; } @@ -1298,7 +1298,7 @@ void m68328_console_write (struct console *co, const char *str, while (count--) { if (*str == '\n') rs_put_char('\r'); - rs_put_char( *str++ ); + rs_put_char(*str++); } } diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 39126460c1f5..c9720a97a977 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -620,7 +620,7 @@ static int univ8250_console_setup(struct console *co, char *options) * @options: ptr to option string from console command line * * Only attempts to match console command lines of the form: - * console=uart[8250],io|mmio|mmio32,<addr>[,<options>] + * console=uart[8250],io|mmio|mmio16|mmio32,<addr>[,<options>] * console=uart[8250],0x<addr>[,<options>] * This form is used to register an initial earlycon boot console and * replace it with the serial8250_console at 8250 driver init. @@ -650,8 +650,9 @@ static int univ8250_console_match(struct console *co, char *name, int idx, if (port->iotype != iotype) continue; - if ((iotype == UPIO_MEM || iotype == UPIO_MEM32) && - (port->mapbase != addr)) + if ((iotype == UPIO_MEM || iotype == UPIO_MEM16 || + iotype == UPIO_MEM32 || iotype == UPIO_MEM32BE) + && (port->mapbase != addr)) continue; if (iotype == UPIO_PORT && port->iobase != addr) continue; diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index ceb85792a5cf..af62131af21e 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -42,6 +42,8 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse switch (port->iotype) { case UPIO_MEM: return readb(port->membase + offset); + case UPIO_MEM16: + return readw(port->membase + (offset << 1)); case UPIO_MEM32: return readl(port->membase + (offset << 2)); case UPIO_MEM32BE: @@ -59,6 +61,9 @@ |