From 55c7c0fdc5aae43ca7eda3adb22ab782634fcb24 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 29 Nov 2012 09:03:00 +1030 Subject: serial: quatech: add the other serial identifiers and preliminary control code Jonathan Woithe posted an out of tree enabler/control module for these cards. Lift the relevant identifiers and put them in the 8250_pci driver along with code used to control custom registers on these cards. Signed-off-by: Alan Cox Signed-off-by: Jonathan Woithe Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_pci.c | 309 +++++++++++++++++++++++++++++++++++++ 1 file changed, 309 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 26b9dc012ed0..89060ffb6b00 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1040,6 +1040,253 @@ static int pci_asix_setup(struct serial_private *priv, return pci_default_setup(priv, board, port, idx); } +/* Quatech devices have their own extra interface features */ + +struct quatech_feature { + u16 devid; + bool amcc; +}; + +#define QPCR_TEST_FOR1 0x3F +#define QPCR_TEST_GET1 0x00 +#define QPCR_TEST_FOR2 0x40 +#define QPCR_TEST_GET2 0x40 +#define QPCR_TEST_FOR3 0x80 +#define QPCR_TEST_GET3 0x40 +#define QPCR_TEST_FOR4 0xC0 +#define QPCR_TEST_GET4 0x80 + +#define QOPR_CLOCK_X1 0x0000 +#define QOPR_CLOCK_X2 0x0001 +#define QOPR_CLOCK_X4 0x0002 +#define QOPR_CLOCK_X8 0x0003 +#define QOPR_CLOCK_RATE_MASK 0x0003 + + +static struct quatech_feature quatech_cards[] = { + { PCI_DEVICE_ID_QUATECH_QSC100, 1 }, + { PCI_DEVICE_ID_QUATECH_DSC100, 1 }, + { PCI_DEVICE_ID_QUATECH_DSC100E, 0 }, + { PCI_DEVICE_ID_QUATECH_DSC200, 1 }, + { PCI_DEVICE_ID_QUATECH_DSC200E, 0 }, + { PCI_DEVICE_ID_QUATECH_ESC100D, 1 }, + { PCI_DEVICE_ID_QUATECH_ESC100M, 1 }, + { PCI_DEVICE_ID_QUATECH_QSCP100, 1 }, + { PCI_DEVICE_ID_QUATECH_DSCP100, 1 }, + { PCI_DEVICE_ID_QUATECH_QSCP200, 1 }, + { PCI_DEVICE_ID_QUATECH_DSCP200, 1 }, + { PCI_DEVICE_ID_QUATECH_ESCLP100, 0 }, + { PCI_DEVICE_ID_QUATECH_QSCLP100, 0 }, + { PCI_DEVICE_ID_QUATECH_DSCLP100, 0 }, + { PCI_DEVICE_ID_QUATECH_SSCLP100, 0 }, + { PCI_DEVICE_ID_QUATECH_QSCLP200, 0 }, + { PCI_DEVICE_ID_QUATECH_DSCLP200, 0 }, + { PCI_DEVICE_ID_QUATECH_SSCLP200, 0 }, + { PCI_DEVICE_ID_QUATECH_SPPXP_100, 0 }, + { 0, } +}; + +static int pci_quatech_amcc(u16 devid) +{ + struct quatech_feature *qf = &quatech_cards[0]; + while (qf->devid) { + if (qf->devid == devid) + return qf->amcc; + qf++; + } + pr_err("quatech: unknown port type '0x%04X'.\n", devid); + return 0; +}; + +static int pci_quatech_rqopr(struct uart_8250_port *port) +{ + unsigned long base = port->port.iobase; + u8 LCR, val; + + LCR = inb(base + UART_LCR); + outb(0xBF, base + UART_LCR); + val = inb(base + UART_SCR); + outb(LCR, base + UART_LCR); + return val; +} + +static void pci_quatech_wqopr(struct uart_8250_port *port, u8 qopr) +{ + unsigned long base = port->port.iobase; + u8 LCR, val; + + LCR = inb(base + UART_LCR); + outb(0xBF, base + UART_LCR); + val = inb(base + UART_SCR); + outb(qopr, base + UART_SCR); + outb(LCR, base + UART_LCR); +} + +static int pci_quatech_rqmcr(struct uart_8250_port *port) +{ + unsigned long base = port->port.iobase; + u8 LCR, val, qmcr; + + LCR = inb(base + UART_LCR); + outb(0xBF, base + UART_LCR); + val = inb(base + UART_SCR); + outb(val | 0x10, base + UART_SCR); + qmcr = inb(base + UART_MCR); + outb(val, base + UART_SCR); + outb(LCR, base + UART_LCR); + + return qmcr; +} + +static void pci_quatech_wqmcr(struct uart_8250_port *port, u8 qmcr) +{ + unsigned long base = port->port.iobase; + u8 LCR, val; + + LCR = inb(base + UART_LCR); + outb(0xBF, base + UART_LCR); + val = inb(base + UART_SCR); + outb(val | 0x10, base + UART_SCR); + outb(qmcr, base + UART_MCR); + outb(val, base + UART_SCR); + outb(LCR, base + UART_LCR); +} + +static int pci_quatech_has_qmcr(struct uart_8250_port *port) +{ + unsigned long base = port->port.iobase; + u8 LCR, val; + + LCR = inb(base + UART_LCR); + outb(0xBF, base + UART_LCR); + val = inb(base + UART_SCR); + if (val & 0x20) { + outb(0x80, UART_LCR); + if (!(inb(UART_SCR) & 0x20)) { + outb(LCR, base + UART_LCR); + return 1; + } + } + return 0; +} + +static int pci_quatech_test(struct uart_8250_port *port) +{ + u8 reg; + u8 qopr = pci_quatech_rqopr(port); + pci_quatech_wqopr(port, qopr & QPCR_TEST_FOR1); + reg = pci_quatech_rqopr(port) & 0xC0; + if (reg != QPCR_TEST_GET1) + return -EINVAL; + pci_quatech_wqopr(port, (qopr & QPCR_TEST_FOR1)|QPCR_TEST_FOR2); + reg = pci_quatech_rqopr(port) & 0xC0; + if (reg != QPCR_TEST_GET2) + return -EINVAL; + pci_quatech_wqopr(port, (qopr & QPCR_TEST_FOR1)|QPCR_TEST_FOR3); + reg = pci_quatech_rqopr(port) & 0xC0; + if (reg != QPCR_TEST_GET3) + return -EINVAL; + pci_quatech_wqopr(port, (qopr & QPCR_TEST_FOR1)|QPCR_TEST_FOR4); + reg = pci_quatech_rqopr(port) & 0xC0; + if (reg != QPCR_TEST_GET4) + return -EINVAL; + + pci_quatech_wqopr(port, qopr); + return 0; +} + +static int pci_quatech_clock(struct uart_8250_port *port) +{ + u8 qopr, reg, set; + unsigned long clock; + + if (pci_quatech_test(port) < 0) + return 1843200; + + qopr = pci_quatech_rqopr(port); + + pci_quatech_wqopr(port, qopr & ~QOPR_CLOCK_X8); + reg = pci_quatech_rqopr(port); + if (reg & QOPR_CLOCK_X8) { + clock = 1843200; + goto out; + } + pci_quatech_wqopr(port, qopr | QOPR_CLOCK_X8); + reg = pci_quatech_rqopr(port); + if (!(reg & QOPR_CLOCK_X8)) { + clock = 1843200; + goto out; + } + reg &= QOPR_CLOCK_X8; + if (reg == QOPR_CLOCK_X2) { + clock = 3685400; + set = QOPR_CLOCK_X2; + } else if (reg == QOPR_CLOCK_X4) { + clock = 7372800; + set = QOPR_CLOCK_X4; + } else if (reg == QOPR_CLOCK_X8) { + clock = 14745600; + set = QOPR_CLOCK_X8; + } else { + clock = 1843200; + set = QOPR_CLOCK_X1; + } + qopr &= ~QOPR_CLOCK_RATE_MASK; + qopr |= set; + +out: + pci_quatech_wqopr(port, qopr); + return clock; +} + +static int pci_quatech_rs422(struct uart_8250_port *port) +{ + u8 qmcr; + int rs422 = 0; + + if (!pci_quatech_has_qmcr(port)) + return 0; + qmcr = pci_quatech_rqmcr(port); + pci_quatech_wqmcr(port, 0xFF); + if (pci_quatech_rqmcr(port)) + rs422 = 1; + pci_quatech_wqmcr(port, qmcr); + return rs422; +} + +static int pci_quatech_init(struct pci_dev *dev) +{ + if (pci_quatech_amcc(dev->device)) { + unsigned long base = pci_resource_start(dev, 0); + if (base) { + u32 tmp; + outl(inl(base + 0x38), base + 0x38); + tmp = inl(base + 0x3c); + outl(tmp | 0x01000000, base + 0x3c); + outl(tmp, base + 0x3c); + } + } + return 0; +} + +static int pci_quatech_setup(struct serial_private *priv, + const struct pciserial_board *board, + struct uart_8250_port *port, int idx) +{ + /* Needed by pci_quatech calls below */ + port->port.iobase = pci_resource_start(priv->dev, FL_GET_BASE(board->flags)); + /* Set up the clocking */ + port->port.uartclk = pci_quatech_clock(port); + /* For now just warn about RS422 */ + if (pci_quatech_rs422(port)) + pr_warn("quatech: software control of RS422 features not currently supported.\n"); + return pci_default_setup(priv, board, port, idx); +} + +static void __devexit pci_quatech_exit(struct pci_dev *dev) +{ +} + static int pci_default_setup(struct serial_private *priv, const struct pciserial_board *board, struct uart_8250_port *port, int idx) @@ -1528,6 +1775,16 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { .setup = pci_ni8430_setup, .exit = pci_ni8430_exit, }, + /* Quatech */ + { + .vendor = PCI_VENDOR_ID_QUATECH, + .device = PCI_ANY_ID, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .init = pci_quatech_init, + .setup = pci_quatech_setup, + .exit = __devexit_p(pci_quatech_exit), + }, /* * Panacom */ @@ -3475,18 +3732,70 @@ static struct pci_device_id serial_pci_tbl[] = { { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_ROMULUS, 0x10b5, 0x106a, 0, 0, pbn_plx_romulus }, + /* + * Quatech cards. These actually have configurable clocks but for + * now we just use the default. + * + * 100 series are RS232, 200 series RS422, + */ { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSC100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b1_4_115200 }, { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSC100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b1_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSC100E, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSC200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSC200E, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSC200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_4_115200 }, { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_ESC100D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b1_8_115200 }, { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_ESC100M, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b1_8_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSCP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_4_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSCP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSCP200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_4_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSCP200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b1_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSCLP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_4_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSCLP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SSCLP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_1_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSCLP200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_4_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSCLP200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_2_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SSCLP200, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b2_1_115200 }, + { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_ESCLP100, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + pbn_b0_8_115200 }, + { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_OXSEMI_16PCI954, PCI_VENDOR_ID_SPECIALIX, PCI_SUBDEVICE_ID_SPECIALIX_SPEED4, 0, 0, -- cgit v1.2.3 From a6b68a69fa89daeddc6ca6bb90b6f19a86ed7a9f Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Mon, 3 Dec 2012 11:13:24 -0600 Subject: synclink fix ldisc buffer argument Fix call to line discipline receive_buf by synclink drivers. Dummy flag buffer argument is ignored by N_HDLC line discipline but might be of insufficient size if accessed by a different line discipline selected by mistake. flag buffer allocation now matches max size of data buffer. Unused char_buf buffers are removed. Signed-off-by: Paul Fulghum Signed-off-by: Greg Kroah-Hartman --- drivers/char/pcmcia/synclink_cs.c | 12 +++++++++++- drivers/tty/synclink.c | 13 ++++++++++--- drivers/tty/synclink_gt.c | 18 ++++++++++++++++-- drivers/tty/synclinkmp.c | 12 ++++++++++-- 4 files changed, 47 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index b66eaa04f8cb..b2f35d786025 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -210,7 +210,7 @@ typedef struct _mgslpc_info { char testing_irq; unsigned int init_error; /* startup error (DIAGS) */ - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; + char *flag_buf; bool drop_rts_on_tx_done; struct _input_signal_events input_signal_events; @@ -2674,6 +2674,14 @@ static int rx_alloc_buffers(MGSLPC_INFO *info) if (info->rx_buf == NULL) return -ENOMEM; + /* unused flag buffer to satisfy receive_buf calling interface */ + info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); + if (!info->flag_buf) { + kfree(info->rx_buf); + info->rx_buf = NULL; + return -ENOMEM; + } + rx_reset_buffers(info); return 0; } @@ -2682,6 +2690,8 @@ static void rx_free_buffers(MGSLPC_INFO *info) { kfree(info->rx_buf); info->rx_buf = NULL; + kfree(info->flag_buf); + info->flag_buf = NULL; } static int claim_resources(MGSLPC_INFO *info) diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 9e071f6985f6..d42b66195a49 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -291,8 +291,7 @@ struct mgsl_struct { bool lcr_mem_requested; u32 misc_ctrl_value; - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; - char char_buf[MAX_ASYNC_BUFFER_SIZE]; + char *flag_buf; bool drop_rts_on_tx_done; bool loopmode_insert_requested; @@ -3898,7 +3897,13 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info) info->intermediate_rxbuffer = kmalloc(info->max_frame_size, GFP_KERNEL | GFP_DMA); if ( info->intermediate_rxbuffer == NULL ) return -ENOMEM; - + /* unused flag buffer to satisfy receive_buf calling interface */ + info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); + if (!info->flag_buf) { + kfree(info->intermediate_rxbuffer); + info->intermediate_rxbuffer = NULL; + return -ENOMEM; + } return 0; } /* end of mgsl_alloc_intermediate_rxbuffer_memory() */ @@ -3917,6 +3922,8 @@ static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info) { kfree(info->intermediate_rxbuffer); info->intermediate_rxbuffer = NULL; + kfree(info->flag_buf); + info->flag_buf = NULL; } /* end of mgsl_free_intermediate_rxbuffer_memory() */ diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index aba1e59f4a88..62a0db7ead07 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -317,8 +317,7 @@ struct slgt_info { unsigned char *tx_buf; int tx_count; - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; - char char_buf[MAX_ASYNC_BUFFER_SIZE]; + char *flag_buf; bool drop_rts_on_tx_done; struct _input_signal_events input_signal_events; @@ -3355,11 +3354,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, return retval; } +/* + * allocate buffers used for calling line discipline receive_buf + * directly in synchronous mode + * note: add 5 bytes to max frame size to allow appending + * 32-bit CRC and status byte when configured to do so + */ static int alloc_tmp_rbuf(struct slgt_info *info) { info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL); if (info->tmp_rbuf == NULL) return -ENOMEM; + /* unused flag buffer to satisfy receive_buf calling interface */ + info->flag_buf = kzalloc(info->max_frame_size + 5, GFP_KERNEL); + if (!info->flag_buf) { + kfree(info->tmp_rbuf); + info->tmp_rbuf = NULL; + return -ENOMEM; + } return 0; } @@ -3367,6 +3379,8 @@ static void free_tmp_rbuf(struct slgt_info *info) { kfree(info->tmp_rbuf); info->tmp_rbuf = NULL; + kfree(info->flag_buf); + info->flag_buf = NULL; } /* diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index fd43fb6f7cee..33b7314cc6c7 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -262,8 +262,7 @@ typedef struct _synclinkmp_info { bool sca_statctrl_requested; u32 misc_ctrl_value; - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; - char char_buf[MAX_ASYNC_BUFFER_SIZE]; + char *flag_buf; bool drop_rts_on_tx_done; struct _input_signal_events input_signal_events; @@ -3553,6 +3552,13 @@ static int alloc_tmp_rx_buf(SLMP_INFO *info) info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); if (info->tmp_rx_buf == NULL) return -ENOMEM; + /* unused flag buffer to satisfy receive_buf calling interface */ + info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); + if (!info->flag_buf) { + kfree(info->tmp_rx_buf); + info->tmp_rx_buf = NULL; + return -ENOMEM; + } return 0; } @@ -3560,6 +3566,8 @@ static void free_tmp_rx_buf(SLMP_INFO *info) { kfree(info->tmp_rx_buf); info->tmp_rx_buf = NULL; + kfree(info->flag_buf); + info->flag_buf = NULL; } static int claim_resources(SLMP_INFO *info) -- cgit v1.2.3 From fdbc7353e45d78ea8ee4a0cdc9e2700035a3a77d Mon Sep 17 00:00:00 2001 From: Enric Balletbo i Serra Date: Thu, 6 Dec 2012 09:45:04 +0100 Subject: serial: omap: add the functionality of a 9-bit UART with userspaces CMSPAR Some systems require the additional communication functionality of a 9-bit UART. For that we could use the "stick" (mark/space) parity bit supported on omap serial device. When is set, if PARODD is set the parity bit is always 1; if PARODD is not set, then the parity bit is always 0. Signed-off-by: Enric Balletbo i Serra Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/omap-serial.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 57d6b29c039c..ec90651d661a 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -776,6 +776,8 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, cval |= UART_LCR_PARITY; if (!(termios->c_cflag & PARODD)) cval |= UART_LCR_EPAR; + if (termios->c_cflag & CMSPAR) + cval |= UART_LCR_SPAR; /* * Ask the core to calculate the divisor for us. -- cgit v1.2.3 From 6f538fe31c1d453b7e7fc4f6e7c6a9bdead4a6f2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 7 Dec 2012 11:36:08 +0100 Subject: tty: serial core: decouple pm states from ACPI The serial core is using power states lifted from ACPI for no good reason. Remove this reference from the documentation and alter all users to use an enum specific to the serial core instead, and define it in . Signed-off-by: Linus Walleij Acked-by: Alan Cox Reviewed-by: Daniel Lezcano Signed-off-by: Greg Kroah-Hartman --- Documentation/serial/driver | 5 ++--- drivers/tty/serial/serial_core.c | 30 ++++++++++++++++-------------- include/linux/serial_core.h | 14 +++++++++++++- 3 files changed, 31 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/Documentation/serial/driver b/Documentation/serial/driver index 0a25a9191864..a6ef8dc436f1 100644 --- a/Documentation/serial/driver +++ b/Documentation/serial/driver @@ -242,9 +242,8 @@ hardware. pm(port,state,oldstate) Perform any power management related activities on the specified - port. State indicates the new state (defined by ACPI D0-D3), - oldstate indicates the previous state. Essentially, D0 means - fully on, D3 means powered down. + port. State indicates the new state (defined by + enum uart_pm_state), oldstate indicates the previous state. This function should not be used to grab any resources. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2c7230aaefd4..82d7ce8c9409 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -59,7 +59,8 @@ static struct lock_class_key port_lock_key; static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, struct ktermios *old_termios); static void uart_wait_until_sent(struct tty_struct *tty, int timeout); -static void uart_change_pm(struct uart_state *state, int pm_state); +static void uart_change_pm(struct uart_state *state, + enum uart_pm_state pm_state); static void uart_port_shutdown(struct tty_port *port); @@ -1365,7 +1366,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) spin_lock_irqsave(&port->lock, flags); } else if (!uart_console(uport)) { spin_unlock_irqrestore(&port->lock, flags); - uart_change_pm(state, 3); + uart_change_pm(state, UART_PM_STATE_OFF); spin_lock_irqsave(&port->lock, flags); } @@ -1579,7 +1580,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) * Make sure the device is in D0 state. */ if (port->count == 1) - uart_change_pm(state, 0); + uart_change_pm(state, UART_PM_STATE_ON); /* * Start up the serial port. @@ -1620,7 +1621,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) { struct uart_state *state = drv->state + i; struct tty_port *port = &state->port; - int pm_state; + enum uart_pm_state pm_state; struct uart_port *uport = state->uart_port; char stat_buf[32]; unsigned int status; @@ -1645,12 +1646,12 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) if (capable(CAP_SYS_ADMIN)) { mutex_lock(&port->mutex); pm_state = state->pm_state; - if (pm_state) - uart_change_pm(state, 0); + if (pm_state != UART_PM_STATE_ON) + uart_change_pm(state, UART_PM_STATE_ON); spin_lock_irq(&uport->lock); status = uport->ops->get_mctrl(uport); spin_unlock_irq(&uport->lock); - if (pm_state) + if (pm_state != UART_PM_STATE_ON) uart_change_pm(state, pm_state); mutex_unlock(&port->mutex); @@ -1897,7 +1898,8 @@ EXPORT_SYMBOL_GPL(uart_set_options); * * Locking: port->mutex has to be held */ -static void uart_change_pm(struct uart_state *state, int pm_state) +static void uart_change_pm(struct uart_state *state, + enum uart_pm_state pm_state) { struct uart_port *port = state->uart_port; @@ -1982,7 +1984,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) console_stop(uport->cons); if (console_suspend_enabled || !uart_console(uport)) - uart_change_pm(state, 3); + uart_change_pm(state, UART_PM_STATE_OFF); mutex_unlock(&port->mutex); @@ -2027,7 +2029,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) termios = port->tty->termios; if (console_suspend_enabled) - uart_change_pm(state, 0); + uart_change_pm(state, UART_PM_STATE_ON); uport->ops->set_termios(uport, &termios, NULL); if (console_suspend_enabled) console_start(uport->cons); @@ -2037,7 +2039,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) const struct uart_ops *ops = uport->ops; int ret; - uart_change_pm(state, 0); + uart_change_pm(state, UART_PM_STATE_ON); spin_lock_irq(&uport->lock); ops->set_mctrl(uport, 0); spin_unlock_irq(&uport->lock); @@ -2137,7 +2139,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, uart_report_port(drv, port); /* Power up port for set_mctrl() */ - uart_change_pm(state, 0); + uart_change_pm(state, UART_PM_STATE_ON); /* * Ensure that the modem control lines are de-activated. @@ -2161,7 +2163,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, * console if we have one. */ if (!uart_console(port)) - uart_change_pm(state, 3); + uart_change_pm(state, UART_PM_STATE_OFF); } } @@ -2588,7 +2590,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) } state->uart_port = uport; - state->pm_state = -1; + state->pm_state = UART_PM_STATE_UNDEFINED; uport->cons = drv->cons; uport->state = state; diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index c6690a2a27fb..a116daa13113 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -208,13 +208,25 @@ static inline void serial_port_out(struct uart_port *up, int offset, int value) up->serial_out(up, offset, value); } +/** + * enum uart_pm_state - power states for UARTs + * @UART_PM_STATE_ON: UART is powered, up and operational + * @UART_PM_STATE_OFF: UART is powered off + * @UART_PM_STATE_UNDEFINED: sentinel + */ +enum uart_pm_state { + UART_PM_STATE_ON = 0, + UART_PM_STATE_OFF = 3, /* number taken from ACPI */ + UART_PM_STATE_UNDEFINED, +}; + /* * This is the state information which is persistent across opens. */ struct uart_state { struct tty_port port; - int pm_state; + enum uart_pm_state pm_state; struct circ_buf xmit; struct uart_port *uart_port; -- cgit v1.2.3 From 92b336f6af9aafddda9e81c0c66c36e61cf2dc47 Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Sat, 8 Dec 2012 01:09:03 +0000 Subject: tty: vt/Makefile: set the variables to static tty: vt/Makefile: set the variables to static In the file drivers/tty/vt/defkeymap.c generated by command loadkeys --mktable defkeymap.map > defkeymap.c the 6 variables: shift_map, altgr_map, ctrl_map, shift_ctrl_map, alt_map, and ctrl_alt_map should be static because they are used only in this file. There is no reason to remove the static by sed command. Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/vt/Makefile b/drivers/tty/vt/Makefile index 14a51c9960df..17ae94cb29f8 100644 --- a/drivers/tty/vt/Makefile +++ b/drivers/tty/vt/Makefile @@ -27,8 +27,6 @@ $(obj)/defkeymap.o: $(obj)/defkeymap.c ifdef GENERATE_KEYMAP $(obj)/defkeymap.c: $(obj)/%.c: $(src)/%.map - loadkeys --mktable $< > $@.tmp - sed -e 's/^static *//' $@.tmp > $@ - rm $@.tmp + loadkeys --mktable $< > $@ endif -- cgit v1.2.3 From 5425e03f97d1e5847372aae0b895d8d1c9bf2741 Mon Sep 17 00:00:00 2001 From: Barry Song Date: Tue, 25 Dec 2012 17:32:04 +0800 Subject: serial: sirf: add support for new SiRFmarco SMP SoC CSR SiRFmarco's UART IP is same with SiRFprimaII except that it has two more uart ports. this patch makes the old driver support new SiRFmarco as well: 1. add .compatible = "sirf,marco-uart" to OF match table 2. add two ports in the port table 3. take spin_lock in isr to avoid the conflict of threads opening uart on CPU1 and isr running on CPU0. For 3, we did see some problems on SiRFmarco as SiRFmarco is a SMP SoC but the old SiRFprimaII is UP. Signed-off-by: Barry Song Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sirfsoc_uart.c | 19 +++++++++++++++++++ drivers/tty/serial/sirfsoc_uart.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 5da5cb962769..142217cd01f4 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c @@ -75,6 +75,20 @@ static struct sirfsoc_uart_port sirfsoc_uart_ports[SIRFSOC_UART_NR] = { .line = 2, }, }, + [3] = { + .port = { + .iotype = UPIO_MEM, + .flags = UPF_BOOT_AUTOCONF, + .line = 3, + }, + }, + [4] = { + .port = { + .iotype = UPIO_MEM, + .flags = UPF_BOOT_AUTOCONF, + .line = 4, + }, + }, }; static inline struct sirfsoc_uart_port *to_sirfport(struct uart_port *port) @@ -245,6 +259,7 @@ static irqreturn_t sirfsoc_uart_isr(int irq, void *dev_id) struct uart_port *port = &sirfport->port; struct uart_state *state = port->state; struct circ_buf *xmit = &port->state->xmit; + spin_lock(&port->lock); intr_status = rd_regl(port, SIRFUART_INT_STATUS); wr_regl(port, SIRFUART_INT_STATUS, intr_status); intr_status &= rd_regl(port, SIRFUART_INT_EN); @@ -254,6 +269,7 @@ static irqreturn_t sirfsoc_uart_isr(int irq, void *dev_id) goto recv_char; uart_insert_char(port, intr_status, SIRFUART_RX_OFLOW, 0, TTY_BREAK); + spin_unlock(&port->lock); return IRQ_HANDLED; } if (intr_status & SIRFUART_RX_OFLOW) @@ -286,6 +302,7 @@ recv_char: sirfsoc_uart_pio_rx_chars(port, SIRFSOC_UART_IO_RX_MAX_CNT); if (intr_status & SIRFUART_TX_INT_EN) { if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { + spin_unlock(&port->lock); return IRQ_HANDLED; } else { sirfsoc_uart_pio_tx_chars(sirfport, @@ -296,6 +313,7 @@ recv_char: sirfsoc_uart_stop_tx(port); } } + spin_unlock(&port->lock); return IRQ_HANDLED; } @@ -729,6 +747,7 @@ static int sirfsoc_uart_resume(struct platform_device *pdev) static struct of_device_id sirfsoc_uart_ids[] = { { .compatible = "sirf,prima2-uart", }, + { .compatible = "sirf,marco-uart", }, {} }; MODULE_DEVICE_TABLE(of, sirfsoc_serial_of_match); diff --git a/drivers/tty/serial/sirfsoc_uart.h b/drivers/tty/serial/sirfsoc_uart.h index 6e207fdc2fed..6431640c3163 100644 --- a/drivers/tty/serial/sirfsoc_uart.h +++ b/drivers/tty/serial/sirfsoc_uart.h @@ -139,7 +139,7 @@ #define SIRFSOC_UART_MINOR 0 #define SIRFUART_PORT_NAME "sirfsoc-uart" #define SIRFUART_MAP_SIZE 0x200 -#define SIRFSOC_UART_NR 3 +#define SIRFSOC_UART_NR 5 #define SIRFSOC_PORT_TYPE 0xa5 /* Baud Rate Calculation */ -- cgit v1.2.3 From f96f7f7f39af53274d98aa9c29d6fa4d122218a4 Mon Sep 17 00:00:00 2001 From: xiaojin Date: Wed, 19 Dec 2012 11:53:43 +0800 Subject: n_gsm.c: add tx_lock in gsm_send All the call to gsm->output should be in the tx_lock, that could avoid potential race from MUX level. But we have no tx_lock in gsm_send. This patch is to add tx_lock in gsm_send. Signed-off-by: xiaojin Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index dcc0430a49c8..4572117988f8 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -573,6 +573,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control) int len; u8 cbuf[10]; u8 ibuf[3]; + unsigned long flags; switch (gsm->encoding) { case 0: @@ -602,7 +603,9 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control) WARN_ON(1); return; } + spin_lock_irqsave(&gsm->tx_lock, flags); gsm->output(gsm, cbuf, len); + spin_unlock_irqrestore(&gsm->tx_lock, flags); gsm_print_packet("-->", addr, cr, control, NULL, 0); } -- cgit v1.2.3 From 6d8df4b6a3a46b62b1a6f6e8678ebd3acc6df8c8 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Wed, 26 Dec 2012 18:06:39 +0800 Subject: serial: avoid double free after call ioc4_serial_remove_one before goto out5, soft, control, serial are all assigned to idd after finish call ioc4_serial_remove_one, all resources are released we need return instead of go on, or double free Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/ioc4_serial.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index 3e7da10cebba..c4e30b841f94 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c @@ -2883,6 +2883,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) /* error exits that give back resources */ out5: ioc4_serial_remove_one(idd); + return ret; out4: kfree(soft); out3: -- cgit v1.2.3 From a205a56dc24811a2879572e52c902a38425a4473 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 18 Dec 2012 11:41:14 +0100 Subject: serial: Remove RM9000 series serial driver. Now that support for RM9000 and platforms based on it has been removed, remove the serial driver for it as well. It's really only been a quirk for an almost 8250 compatible UART anyway. Signed-off-by: Ralf Baechle drivers/tty/serial/8250/8250.c | 70 +---------------------------------------- drivers/tty/serial/8250/Kconfig | 9 ------ include/linux/serial_core.h | 1 - 3 files changed, 1 insertion(+), 79 deletions(-) Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250.c | 70 +---------------------------------------- drivers/tty/serial/8250/Kconfig | 9 ------ include/linux/serial_core.h | 1 - 3 files changed, 1 insertion(+), 79 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index d085e3a8ec06..5fb6577b94dc 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -239,13 +239,6 @@ static const struct serial8250_config uart_config[] = { .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, .flags = UART_CAP_FIFO | UART_CAP_UUE | UART_CAP_RTOIE, }, - [PORT_RM9000] = { - .name = "RM9000", - .fifo_size = 16, - .tx_loadsz = 16, - .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, - .flags = UART_CAP_FIFO, - }, [PORT_OCTEON] = { .name = "OCTEON", .fifo_size = 64, @@ -364,56 +357,6 @@ static void au_serial_dl_write(struct uart_8250_port *up, int value) #endif -#ifdef CONFIG_SERIAL_8250_RM9K - -static const u8 - regmap_in[8] = { - [UART_RX] = 0x00, - [UART_IER] = 0x0c, - [UART_IIR] = 0x14, - [UART_LCR] = 0x1c, - [UART_MCR] = 0x20, - [UART_LSR] = 0x24, - [UART_MSR] = 0x28, - [UART_SCR] = 0x2c - }, - regmap_out[8] = { - [UART_TX] = 0x04, - [UART_IER] = 0x0c, - [UART_FCR] = 0x18, - [UART_LCR] = 0x1c, - [UART_MCR] = 0x20, - [UART_LSR] = 0x24, - [UART_MSR] = 0x28, - [UART_SCR] = 0x2c - }; - -static unsigned int rm9k_serial_in(struct uart_port *p, int offset) -{ - offset = regmap_in[offset] << p->regshift; - return readl(p->membase + offset); -} - -static void rm9k_serial_out(struct uart_port *p, int offset, int value) -{ - offset = regmap_out[offset] << p->regshift; - writel(value, p->membase + offset); -} - -static int rm9k_serial_dl_read(struct uart_8250_port *up) -{ - return ((__raw_readl(up->port.membase + 0x10) << 8) | - (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff; -} - -static void rm9k_serial_dl_write(struct uart_8250_port *up, int value) -{ - __raw_writel(value, up->port.membase + 0x08); - __raw_writel(value >> 8, up->port.membase + 0x10); -} - -#endif - static unsigned int hub6_serial_in(struct uart_port *p, int offset) { offset = offset << p->regshift; @@ -491,15 +434,6 @@ static void set_io_from_upio(struct uart_port *p) p->serial_out = mem32_serial_out; break; -#ifdef CONFIG_SERIAL_8250_RM9K - case UPIO_RM9000: - p->serial_in = rm9k_serial_in; - p->serial_out = rm9k_serial_out; - up->dl_read = rm9k_serial_dl_read; - up->dl_write = rm9k_serial_dl_write; - break; -#endif - #ifdef CONFIG_MIPS_ALCHEMY case UPIO_AU: p->serial_in = au_serial_in; @@ -1343,9 +1277,7 @@ static void serial8250_start_tx(struct uart_port *port) unsigned char lsr; lsr = serial_in(up, UART_LSR); up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; - if ((port->type == PORT_RM9000) ? - (lsr & UART_LSR_THRE) : - (lsr & UART_LSR_TEMT)) + if (lsr & UART_LSR_TEMT) serial8250_tx_chars(up); } } diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index c31133a6ea8e..d79208f47237 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -249,15 +249,6 @@ config SERIAL_8250_ACORN system, say Y to this option. The driver can handle 1, 2, or 3 port cards. If unsure, say N. -config SERIAL_8250_RM9K - bool "Support for MIPS RM9xxx integrated serial port" - depends on SERIAL_8250 != n && SERIAL_RM9000 - select SERIAL_8250_SHARE_IRQ - help - Selecting this option will add support for the integrated serial - port hardware found on MIPS RM9122 and similar processors. - If unsure, say N. - config SERIAL_8250_FSL bool depends on SERIAL_8250_CONSOLE && PPC_UDBG_16550 diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index a116daa13113..ec5df74c4506 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -136,7 +136,6 @@ struct uart_port { #define UPIO_MEM32 (3) #define UPIO_AU (4) /* Au1x00 type IO */ #define UPIO_TSI (5) /* Tsi108/109 type IO */ -#define UPIO_RM9000 (6) /* RM9000 type IO */ unsigned int read_status_mask; /* driver specific */ unsigned int ignore_status_mask; /* driver specific */ -- cgit v1.2.3 From ef4f527c48c8fcbb5e35dafaef4f9097f5e9d901 Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Wed, 26 Dec 2012 20:43:41 -0800 Subject: tty: Fix comments that reference BKL, eventd, old paths Signed-off-by: Kevin Cernekee Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial_core.c | 18 +++++++++--------- drivers/tty/tty_io.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 82d7ce8c9409..ba7863bbbb4d 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1309,9 +1309,10 @@ static void uart_set_termios(struct tty_struct *tty, } /* - * In 2.4.5, calls to this will be serialized via the BKL in - * linux/drivers/char/tty_io.c:tty_release() - * linux/drivers/char/tty_io.c:do_tty_handup() + * Calls to uart_close() are serialised via the tty_lock in + * drivers/tty/tty_io.c:tty_release() + * drivers/tty/tty_io.c:do_tty_hangup() + * This runs from a workqueue and can sleep for a _short_ time only. */ static void uart_close(struct tty_struct *tty, struct file *filp) { @@ -1438,10 +1439,9 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) } /* - * This is called with the BKL held in - * linux/drivers/char/tty_io.c:do_tty_hangup() - * We're called from the eventd thread, so we can sleep for - * a _short_ time only. + * Calls to uart_hangup() are serialised by the tty_lock in + * drivers/tty/tty_io.c:do_tty_hangup() + * This runs from a workqueue and can sleep for a _short_ time only. */ static void uart_hangup(struct tty_struct *tty) { @@ -1522,8 +1522,8 @@ static void uart_dtr_rts(struct tty_port *port, int onoff) } /* - * calls to uart_open are serialised by the BKL in - * fs/char_dev.c:chrdev_open() + * Calls to uart_open are serialised by the tty_lock in + * drivers/tty/tty_io.c:tty_open() * Note that if this fails, then uart_close() _will_ be called. * * In time, we want to scrap the "opening nonpresent ports" diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index da9fde850754..54a254ab85c7 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -536,7 +536,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup); * __tty_hangup - actual handler for hangup events * @work: tty device * - * This can be called by the "eventd" kernel thread. That is process + * This can be called by a "kworker" kernel thread. That is process * synchronous but doesn't hold any locks, so we need to make sure we * have the appropriate locks for what we're doing. * -- cgit v1.2.3 From 81a7d777497aa4f8c4b5f46b2b8b978779840462 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sat, 29 Dec 2012 00:16:33 +0100 Subject: serial: mxs-auart: Fix typo in sanity check Detected by cppcheck: [others/linux/drivers/tty/serial/mxs-auart.c:553]: (style) Same expression on both sides of '||'. Signed-off-by: Thomas Jarosch Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/mxs-auart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 6db23b035efe..fa31bc38b105 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -550,7 +550,7 @@ static int mxs_auart_dma_init(struct mxs_auart_port *s) return 0; /* We do not get the right DMA channels. */ - if (s->dma_channel_rx == -1 || s->dma_channel_rx == -1) + if (s->dma_channel_rx == -1 || s->dma_channel_tx == -1) return -EINVAL; /* init for RX */ -- cgit v1.2.3 From 41147bfdc5c0d6acb39d2b3b8a4eb6ffb08e4b42 Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Tue, 1 Jan 2013 00:21:55 -0800 Subject: serial: samsung: remove the use of statically remapped controller address The address S3C_VA_UART is a statically ioremapped address. The driver should not be using this. Instead, the driver should setup a mapping during probe. Cc: Kukjin Kim Signed-off-by: Thomas Abraham Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/samsung.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 12e5249d053e..96ae08f34770 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -47,7 +47,6 @@ #include #include -#include #include #include @@ -1144,8 +1143,13 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); + port->membase = devm_ioremap(port->dev, res->start, resource_size(res)); + if (!port->membase) { + dev_err(port->dev, "failed to remap controller address\n"); + return -EBUSY; + } + port->mapbase = res->start; - port->membase = S3C_VA_UART + (res->start & 0xfffff); ret = platform_get_irq(platdev, 0); if (ret < 0) port->irq = 0; -- cgit v1.2.3 From 905f4ba252f933344e43a32ef4524bc8412c2e90 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 09:50:42 +0530 Subject: serial: Samsung: Use of_match_ptr() macro This eliminates having an #ifdef returning NULL for the case when OF is disabled. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/samsung.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 96ae08f34770..0684529eb2ad 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1729,8 +1729,6 @@ static const struct of_device_id s3c24xx_uart_dt_match[] = { {}, }; MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match); -#else -#define s3c24xx_uart_dt_match NULL #endif static struct platform_driver samsung_serial_driver = { @@ -1741,7 +1739,7 @@ static struct platform_driver samsung_serial_driver = { .name = "samsung-uart", .owner = THIS_MODULE, .pm = SERIAL_SAMSUNG_PM_OPS, - .of_match_table = s3c24xx_uart_dt_match, + .of_match_table = of_match_ptr(s3c24xx_uart_dt_match), }, }; -- cgit v1.2.3 From 82313e66b1a449b08682043929003fab38ebf037 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 10:25:02 +0530 Subject: serial: imx: Fix checkpatch errors related to spacing Fixed checkpatch errors and warnings related to incorrect spacing. Cc: Shawn Guo Signed-off-by: Sachin Kamat Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 222 +++++++++++++++++++++++------------------------ 1 file changed, 111 insertions(+), 111 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 59819121fe9b..d6bce6c6329f 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -73,102 +73,102 @@ #define IMX21_UTS 0xb4 /* UART Test Register on all other i.mx*/ /* UART Control Register Bit Fields.*/ -#define URXD_CHARRDY (1<<15) -#define URXD_ERR (1<<14) -#define URXD_OVRRUN (1<<13) -#define URXD_FRMERR (1<<12) -#define URXD_BRK (1<<11) -#define URXD_PRERR (1<<10) -#define UCR1_ADEN (1<<15) /* Auto detect interrupt */ -#define UCR1_ADBR (1<<14) /* Auto detect baud rate */ -#define UCR1_TRDYEN (1<<13) /* Transmitter ready interrupt enable */ -#define UCR1_IDEN (1<<12) /* Idle condition interrupt */ -#define UCR1_RRDYEN (1<<9) /* Recv ready interrupt enable */ -#define UCR1_RDMAEN (1<<8) /* Recv ready DMA enable */ -#define UCR1_IREN (1<<7) /* Infrared interface enable */ -#define UCR1_TXMPTYEN (1<<6) /* Transimitter empty interrupt enable */ -#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */ -#define UCR1_SNDBRK (1<<4) /* Send break */ -#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */ -#define IMX1_UCR1_UARTCLKEN (1<<2) /* UART clock enabled, i.mx1 only */ -#define UCR1_DOZE (1<<1) /* Doze */ -#define UCR1_UARTEN (1<<0) /* UART enabled */ -#define UCR2_ESCI (1<<15) /* Escape seq interrupt enable */ -#define UCR2_IRTS (1<<14) /* Ignore RTS pin */ -#define UCR2_CTSC (1<<13) /* CTS pin control */ -#define UCR2_CTS (1<<12) /* Clear to send */ -#define UCR2_ESCEN (1<<11) /* Escape enable */ -#define UCR2_PREN (1<<8) /* Parity enable */ -#define UCR2_PROE (1<<7) /* Parity odd/even */ -#define UCR2_STPB (1<<6) /* Stop */ -#define UCR2_WS (1<<5) /* Word size */ -#define UCR2_RTSEN (1<<4) /* Request to send interrupt enable */ -#define UCR2_ATEN (1<<3) /* Aging Timer Enable */ -#define UCR2_TXEN (1<<2) /* Transmitter enabled */ -#define UCR2_RXEN (1<<1) /* Receiver enabled */ -#define UCR2_SRST (1<<0) /* SW reset */ -#define UCR3_DTREN (1<<13) /* DTR interrupt enable */ -#define UCR3_PARERREN (1<<12) /* Parity enable */ -#define UCR3_FRAERREN (1<<11) /* Frame error interrupt enable */ -#define UCR3_DSR (1<<10) /* Data set ready */ -#define UCR3_DCD (1<<9) /* Data carrier detect */ -#define UCR3_RI (1<<8) /* Ring indicator */ -#define UCR3_TIMEOUTEN (1<<7) /* Timeout interrupt enable */ -#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */ -#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */ -#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ -#define IMX21_UCR3_RXDMUXSEL (1<<2) /* RXD Muxed Input Select */ -#define UCR3_INVT (1<<1) /* Inverted Infrared transmission */ -#define UCR3_BPEN (1<<0) /* Preset registers enable */ -#define UCR4_CTSTL_SHF 10 /* CTS trigger level shift */ -#define UCR4_CTSTL_MASK 0x3F /* CTS trigger is 6 bits wide */ -#define UCR4_INVR (1<<9) /* Inverted infrared reception */ -#define UCR4_ENIRI (1<<8) /* Serial infrared interrupt enable */ -#define UCR4_WKEN (1<<7) /* Wake interrupt enable */ -#define UCR4_REF16 (1<<6) /* Ref freq 16 MHz */ -#define UCR4_IRSC (1<<5) /* IR special case */ -#define UCR4_TCEN (1<<3) /* Transmit complete interrupt enable */ -#define UCR4_BKEN (1<<2) /* Break condition interrupt enable */ -#define UCR4_OREN (1<<1) /* Receiver overrun interrupt enable */ -#define UCR4_DREN (1<<0) /* Recv data ready interrupt enable */ -#define UFCR_RXTL_SHF 0 /* Receiver trigger level shift */ -#define UFCR_DCEDTE (1<<6) /* DCE/DTE mode select */ -#define UFCR_RFDIV (7<<7) /* Reference freq divider mask */ -#define UFCR_RFDIV_REG(x) (((x) < 7 ? 6 - (x) : 6) << 7) -#define UFCR_TXTL_SHF 10 /* Transmitter trigger level shift */ -#define USR1_PARITYERR (1<<15) /* Parity error interrupt flag */ -#define USR1_RTSS (1<<14) /* RTS pin status */ -#define USR1_TRDY (1<<13) /* Transmitter ready interrupt/dma flag */ -#define USR1_RTSD (1<<12) /* RTS delta */ -#define USR1_ESCF (1<<11) /* Escape seq interrupt flag */ -#define USR1_FRAMERR (1<<10) /* Frame error interrupt flag */ -#define USR1_RRDY (1<<9) /* Receiver ready interrupt/dma flag */ -#define USR1_TIMEOUT (1<<7) /* Receive timeout interrupt status */ -#define USR1_RXDS (1<<6) /* Receiver idle interrupt flag */ -#define USR1_AIRINT (1<<5) /* Async IR wake interrupt flag */ -#define USR1_AWAKE (1<<4) /* Aysnc wake interrupt flag */ -#define USR2_ADET (1<<15) /* Auto baud rate detect complete */ -#define USR2_TXFE (1<<14) /* Transmit buffer FIFO empty */ -#define USR2_DTRF (1<<13) /* DTR edge interrupt flag */ -#define USR2_IDLE (1<<12) /* Idle condition */ -#define USR2_IRINT (1<<8) /* Serial infrared interrupt flag */ -#define USR2_WAKE (1<<7) /* Wake */ -#define USR2_RTSF (1<<4) /* RTS edge interrupt flag */ -#define USR2_TXDC (1<<3) /* Transmitter complete */ -#define USR2_BRCD (1<<2) /* Break condition */ -#define USR2_ORE (1<<1) /* Overrun error */ -#define USR2_RDR (1<<0) /* Recv data ready */ -#define UTS_FRCPERR (1<<13) /* Force parity error */ -#define UTS_LOOP (1<<12) /* Loop tx and rx */ -#define UTS_TXEMPTY (1<<6) /* TxFIFO empty */ -#define UTS_RXEMPTY (1<<5) /* RxFIFO empty */ -#define UTS_TXFULL (1<<4) /* TxFIFO full */ -#define UTS_RXFULL (1<<3) /* RxFIFO full */ -#define UTS_SOFTRST (1<<0) /* Software reset */ +#define URXD_CHARRDY (1<<15) +#define URXD_ERR (1<<14) +#define URXD_OVRRUN (1<<13) +#define URXD_FRMERR (1<<12) +#define URXD_BRK (1<<11) +#define URXD_PRERR (1<<10) +#define UCR1_ADEN (1<<15) /* Auto detect interrupt */ +#define UCR1_ADBR (1<<14) /* Auto detect baud rate */ +#define UCR1_TRDYEN (1<<13) /* Transmitter ready interrupt enable */ +#define UCR1_IDEN (1<<12) /* Idle condition interrupt */ +#define UCR1_RRDYEN (1<<9) /* Recv ready interrupt enable */ +#define UCR1_RDMAEN (1<<8) /* Recv ready DMA enable */ +#define UCR1_IREN (1<<7) /* Infrared interface enable */ +#define UCR1_TXMPTYEN (1<<6) /* Transimitter empty interrupt enable */ +#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */ +#define UCR1_SNDBRK (1<<4) /* Send break */ +#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */ +#define IMX1_UCR1_UARTCLKEN (1<<2) /* UART clock enabled, i.mx1 only */ +#define UCR1_DOZE (1<<1) /* Doze */ +#define UCR1_UARTEN (1<<0) /* UART enabled */ +#define UCR2_ESCI (1<<15) /* Escape seq interrupt enable */ +#define UCR2_IRTS (1<<14) /* Ignore RTS pin */ +#define UCR2_CTSC (1<<13) /* CTS pin control */ +#define UCR2_CTS (1<<12) /* Clear to send */ +#define UCR2_ESCEN (1<<11) /* Escape enable */ +#define UCR2_PREN (1<<8) /* Parity enable */ +#define UCR2_PROE (1<<7) /* Parity odd/even */ +#define UCR2_STPB (1<<6) /* Stop */ +#define UCR2_WS (1<<5) /* Word size */ +#define UCR2_RTSEN (1<<4) /* Request to send interrupt enable */ +#define UCR2_ATEN (1<<3) /* Aging Timer Enable */ +#define UCR2_TXEN (1<<2) /* Transmitter enabled */ +#define UCR2_RXEN (1<<1) /* Receiver enabled */ +#define UCR2_SRST (1<<0) /* SW reset */ +#define UCR3_DTREN (1<<13) /* DTR interrupt enable */ +#define UCR3_PARERREN (1<<12) /* Parity enable */ +#define UCR3_FRAERREN (1<<11) /* Frame error interrupt enable */ +#define UCR3_DSR (1<<10) /* Data set ready */ +#define UCR3_DCD (1<<9) /* Data carrier detect */ +#define UCR3_RI (1<<8) /* Ring indicator */ +#define UCR3_TIMEOUTEN (1<<7) /* Timeout interrupt enable */ +#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */ +#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */ +#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ +#define IMX21_UCR3_RXDMUXSEL (1<<2) /* RXD Muxed Input Select */ +#define UCR3_INVT (1<<1) /* Inverted Infrared transmission */ +#define UCR3_BPEN (1<<0) /* Preset registers enable */ +#define UCR4_CTSTL_SHF 10 /* CTS trigger level shift */ +#define UCR4_CTSTL_MASK 0x3F /* CTS trigger is 6 bits wide */ +#define UCR4_INVR (1<<9) /* Inverted infrared reception */ +#define UCR4_ENIRI (1<<8) /* Serial infrared interrupt enable */ +#define UCR4_WKEN (1<<7) /* Wake interrupt enable */ +#define UCR4_REF16 (1<<6) /* Ref freq 16 MHz */ +#define UCR4_IRSC (1<<5) /* IR special case */ +#define UCR4_TCEN (1<<3) /* Transmit complete interrupt enable */ +#define UCR4_BKEN (1<<2) /* Break condition interrupt enable */ +#define UCR4_OREN (1<<1) /* Receiver overrun interrupt enable */ +#define UCR4_DREN (1<<0) /* Recv data ready interrupt enable */ +#define UFCR_RXTL_SHF 0 /* Receiver trigger level shift */ +#define UFCR_DCEDTE (1<<6) /* DCE/DTE mode select */ +#define UFCR_RFDIV (7<<7) /* Reference freq divider mask */ +#define UFCR_RFDIV_REG(x) (((x) < 7 ? 6 - (x) : 6) << 7) +#define UFCR_TXTL_SHF 10 /* Transmitter trigger level shift */ +#define USR1_PARITYERR (1<<15) /* Parity error interrupt flag */ +#define USR1_RTSS (1<<14) /* RTS pin status */ +#define USR1_TRDY (1<<13) /* Transmitter ready interrupt/dma flag */ +#define USR1_RTSD (1<<12) /* RTS delta */ +#define USR1_ESCF (1<<11) /* Escape seq interrupt flag */ +#define USR1_FRAMERR (1<<10) /* Frame error interrupt flag */ +#define USR1_RRDY (1<<9) /* Receiver ready interrupt/dma flag */ +#define USR1_TIMEOUT (1<<7) /* Receive timeout interrupt status */ +#define USR1_RXDS (1<<6) /* Receiver idle interrupt flag */ +#define USR1_AIRINT (1<<5) /* Async IR wake interrupt flag */ +#define USR1_AWAKE (1<<4) /* Aysnc wake interrupt flag */ +#define USR2_ADET (1<<15) /* Auto baud rate detect complete */ +#define USR2_TXFE (1<<14) /* Transmit buffer FIFO empty */ +#define USR2_DTRF (1<<13) /* DTR edge interrupt flag */ +#define USR2_IDLE (1<<12) /* Idle condition */ +#define USR2_IRINT (1<<8) /* Serial infrared interrupt flag */ +#define USR2_WAKE (1<<7) /* Wake */ +#define USR2_RTSF (1<<4) /* RTS edge interrupt flag */ +#define USR2_TXDC (1<<3) /* Transmitter complete */ +#define USR2_BRCD (1<<2) /* Break condition */ +#define USR2_ORE (1<<1) /* Overrun error */ +#define USR2_RDR (1<<0) /* Recv data ready */ +#define UTS_FRCPERR (1<<13) /* Force parity error */ +#define UTS_LOOP (1<<12) /* Loop tx and rx */ +#define UTS_TXEMPTY (1<<6) /* TxFIFO empty */ +#define UTS_RXEMPTY (1<<5) /* RxFIFO empty */ +#define UTS_TXFULL (1<<4) /* TxFIFO full */ +#define UTS_RXFULL (1<<3) /* RxFIFO full */ +#define UTS_SOFTRST (1<<0) /* Software reset */ /* We've been assigned a range on the "Low-density serial ports" major */ -#define SERIAL_IMX_MAJOR 207 -#define MINOR_START 16 +#define SERIAL_IMX_MAJOR 207 +#define MINOR_START 16 #define DEV_NAME "ttymxc" /* @@ -199,7 +199,7 @@ struct imx_port { struct uart_port port; struct timer_list timer; unsigned int old_status; - int txirq,rxirq,rtsirq; + int txirq, rxirq, rtsirq; unsigned int have_rtscts:1; unsigned int use_irda:1; unsigned int irda_inv_rx:1; @@ -397,7 +397,7 @@ static void imx_stop_rx(struct uart_port *port) unsigned long temp; temp = readl(sport->port.membase + UCR2); - writel(temp &~ UCR2_RXEN, sport->port.membase + UCR2); + writel(temp & ~UCR2_RXEN, sport->port.membase + UCR2); } /* @@ -490,7 +490,7 @@ static irqreturn_t imx_txint(int irq, void *dev_id) struct circ_buf *xmit = &sport->port.state->xmit; unsigned long flags; - spin_lock_irqsave(&sport->port.lock,flags); + spin_lock_irqsave(&sport->port.lock, flags); if (sport->port.x_char) { /* Send next char */ @@ -509,18 +509,18 @@ static irqreturn_t imx_txint(int irq, void *dev_id) uart_write_wakeup(&sport->port); out: - spin_unlock_irqrestore(&sport->port.lock,flags); + spin_unlock_irqrestore(&sport->port.lock, flags); return IRQ_HANDLED; } static irqreturn_t imx_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; - unsigned int rx,flg,ignored = 0; + unsigned int rx, flg, ignored = 0; struct tty_struct *tty = sport->port.state->port.tty; unsigned long flags, temp; - spin_lock_irqsave(&sport->port.lock,flags); + spin_lock_irqsave(&sport->port.lock, flags); while (readl(sport->port.membase + USR2) & USR2_RDR) { flg = TTY_NORMAL; @@ -574,7 +574,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) } out: - spin_unlock_irqrestore(&sport->port.lock,flags); + spin_unlock_irqrestore(&sport->port.lock, flags); tty_flip_buffer_push(tty); return IRQ_HANDLED; } @@ -654,7 +654,7 @@ static void imx_break_ctl(struct uart_port *port, int break_state) temp = readl(sport->port.membase + UCR1) & ~UCR1_SNDBRK; - if ( break_state != 0 ) + if (break_state != 0) temp |= UCR1_SNDBRK; writel(temp, sport->port.membase + UCR1); @@ -696,8 +696,8 @@ static int imx_startup(struct uart_port *port) temp |= UCR4_IRSC; /* set the trigger level for CTS */ - temp &= ~(UCR4_CTSTL_MASK<< UCR4_CTSTL_SHF); - temp |= CTSTL<< UCR4_CTSTL_SHF; + temp &= ~(UCR4_CTSTL_MASK << UCR4_CTSTL_SHF); + temp |= CTSTL << UCR4_CTSTL_SHF; writel(temp & ~UCR4_DREN, sport->port.membase + UCR4); @@ -799,7 +799,7 @@ static int imx_startup(struct uart_port *port) * Enable modem status interrupts */ imx_enable_ms(&sport->port); - spin_unlock_irqrestore(&sport->port.lock,flags); + spin_unlock_irqrestore(&sport->port.lock, flags); if (USE_IRDA(sport)) { struct imxuart_platform_data *pdata; @@ -909,7 +909,7 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios, ucr2 = UCR2_SRST | UCR2_IRTS; if (termios->c_cflag & CRTSCTS) { - if( sport->have_rtscts ) { + if (sport->have_rtscts) { ucr2 &= ~UCR2_IRTS; ucr2 |= UCR2_CTSC; } else { @@ -969,12 +969,12 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios, writel(old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN), sport->port.membase + UCR1); - while ( !(readl(sport->port.membase + USR2) & USR2_TXDC)) + while (!(readl(sport->port.membase + USR2) & USR2_TXDC)) barrier(); /* then, disable everything */ old_txrxen = readl(sport->port.membase + UCR2); - writel(old_txrxen & ~( UCR2_TXEN | UCR2_RXEN), + writel(old_txrxen & ~(UCR2_TXEN | UCR2_RXEN), sport->port.membase + UCR2); old_txrxen &= (UCR2_TXEN | UCR2_RXEN); @@ -1255,7 +1255,7 @@ imx_console_get_options(struct imx_port *sport, int *baud, if (readl(sport->port.membase + UCR1) & UCR1_UARTEN) { /* ok, the port was enabled */ - unsigned int ucr2, ubir,ubmr, uartclk; + unsigned int ucr2, ubir, ubmr, uartclk; unsigned int baud_raw; unsigned int ucfr_rfdiv; @@ -1301,7 +1301,7 @@ imx_console_get_options(struct imx_port *sport, int *baud, *baud = (baud_raw + 50) / 100 * 100; } - if(*baud != baud_raw) + if (*baud != baud_raw) printk(KERN_INFO "Serial: Console IMX rounded baud rate from %d to %d\n", baud_raw, *baud); } @@ -1324,7 +1324,7 @@ imx_console_setup(struct console *co, char *options) if (co->index == -1 || co->index >= ARRAY_SIZE(imx_ports)) co->index = 0; sport = imx_ports[co->index]; - if(sport == NULL) + if (sport == NULL) return -ENODEV; if (options) -- cgit v1.2.3 From e32a9f8f34cc5eaf77100cd2d54e78e81d01f5dc Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 10:25:03 +0530 Subject: serial: imx: Use instead of Silences the following checkpatch warning: WARNING: Use #include instead of Cc: Shawn Guo Acked-by: Sascha Hauer Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index d6bce6c6329f..426253c2821d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -48,8 +48,8 @@ #include #include #include +#include -#include #include #include -- cgit v1.2.3 From 699cbd6726ed9124ce014471aaaa28e8c7f7122e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 10:25:04 +0530 Subject: serial: imx: Fix coding style issue Silences the following checkpatch error: ERROR: that open brace { should be on the previous line Cc: Shawn Guo Acked-by: Sascha Hauer Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 426253c2821d..9bec8a23687a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -491,8 +491,7 @@ static irqreturn_t imx_txint(int irq, void *dev_id) unsigned long flags; spin_lock_irqsave(&sport->port.lock, flags); - if (sport->port.x_char) - { + if (sport->port.x_char) { /* Send next char */ writel(sport->port.x_char, sport->port.membase + URTX0); goto out; -- cgit v1.2.3 From 50bbdba3dd67f2b5958816f6a9460205cd14866a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 10:25:05 +0530 Subject: serial: imx: Use pr_info instead of printk Silences checkpatch warnings. Cc: Shawn Guo Acked-by: Sascha Hauer Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 9bec8a23687a..78f793617e4f 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1301,7 +1301,7 @@ imx_console_get_options(struct imx_port *sport, int *baud, } if (*baud != baud_raw) - printk(KERN_INFO "Serial: Console IMX rounded baud rate from %d to %d\n", + pr_info("Console IMX rounded baud rate from %d to %d\n", baud_raw, *baud); } } @@ -1595,7 +1595,7 @@ static int __init imx_serial_init(void) { int ret; - printk(KERN_INFO "Serial: IMX driver\n"); + pr_info("Serial: IMX driver\n"); ret = uart_register_driver(&imx_reg); if (ret) -- cgit v1.2.3 From 42d34191545be343909417dd05db799686f2e48e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 7 Jan 2013 10:25:06 +0530 Subject: serial: imx: Use devm_* APIs devm_* APIs are device managed and make cleanup and exit code simpler and easier. Cc: Shawn Guo Acked-by: Sascha Hauer Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 78f793617e4f..1a2488495f69 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1461,7 +1461,7 @@ static int serial_imx_probe(struct platform_device *pdev) struct resource *res; struct pinctrl *pinctrl; - sport = kzalloc(sizeof(*sport), GFP_KERNEL); + sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); if (!sport) return -ENOMEM; @@ -1469,19 +1469,15 @@ static int serial_imx_probe(struct platform_device *pdev) if (ret > 0) serial_imx_probe_pdata(sport, pdev); else if (ret < 0) - goto free; + return ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENODEV; - goto free; - } + if (!res) + return -ENODEV; - base = ioremap(res->start, PAGE_SIZE); - if (!base) { - ret = -ENOMEM; - goto free; - } + base = devm_ioremap(&pdev->dev, res->start, PAGE_SIZE); + if (!base) + return -ENOMEM; sport->port.dev = &pdev->dev; sport->port.mapbase = res->start; @@ -1503,21 +1499,21 @@ static int serial_imx_probe(struct platform_device *pdev) if (IS_ERR(pinctrl)) { ret = PTR_ERR(pinctrl); dev_err(&pdev->dev, "failed to get default pinctrl: %d\n", ret); - goto unmap; + return ret; } sport->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(sport->clk_ipg)) { ret = PTR_ERR(sport->clk_ipg); dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret); - goto unmap; + return ret; } sport->clk_per = devm_clk_get(&pdev->dev, "per"); if (IS_ERR(sport->clk_per)) { ret = PTR_ERR(sport->clk_per); dev_err(&pdev->dev, "failed to get per clk: %d\n", ret); - goto unmap; + return ret; } clk_prepare_enable(sport->clk_per); @@ -1546,11 +1542,6 @@ deinit: clkput: clk_disable_unprepare(sport->clk_per); clk_disable_unprepare(sport->clk_ipg); -unmap: - iounmap(sport->port.membase); -free: - kfree(sport); - return ret; } @@ -1571,9 +1562,6 @@ static int serial_imx_remove(struct platform_device *pdev) if (pdata && pdata->exit) pdata->exit(pdev); - iounmap(sport->port.membase); - kfree(sport); - return 0; } -- cgit v1.2.3 From e9ea096dd2259454e0d09d0b0445fe8f0117add4 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 8 Jan 2013 16:27:44 +0530 Subject: serial: tegra: add serial driver NVIDIA's Tegra has multiple UART controller which supports: - APB DMA based controller fifo read/write. - End Of Data interrupt in incoming data to know whether end of frame achieve or not. - HW controlled RTS and CTS flow control to reduce SW overhead. Add serial driver to use all above feature. Signed-off-by: Laxman Dewangan Acked-by: Alan Cox Reviewed-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- .../bindings/serial/nvidia,tegra20-hsuart.txt | 24 + drivers/tty/serial/Kconfig | 11 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/serial-tegra.c | 1399 ++++++++++++++++++++ 4 files changed, 1435 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt create mode 100644 drivers/tty/serial/serial-tegra.c (limited to 'drivers') diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt b/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt new file mode 100644 index 000000000000..392a4493eebd --- /dev/null +++ b/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt @@ -0,0 +1,24 @@ +NVIDIA Tegra20/Tegra30 high speed (DMA based) UART controller driver. + +Required properties: +- compatible : should be "nvidia,tegra30-hsuart", "nvidia,tegra20-hsuart". +- reg: Should contain UART controller registers location and length. +- interrupts: Should contain UART controller interrupts. +- nvidia,dma-request-selector : The Tegra DMA controller's phandle and + request selector for this UART controller. + +Optional properties: +- nvidia,enable-modem-interrupt: Enable modem interrupts. Should be enable + only if all 8 lines of UART controller are pinmuxed. + +Example: + +serial@70006000 { + compatible = "nvidia,tegra30-hsuart", "nvidia,tegra20-hsuart"; + reg = <0x70006000 0x40>; + reg-shift = <2>; + interrupts = <0 36 0x04>; + nvidia,dma-request-selector = <&apbdma 8>; + nvidia,enable-modem-interrupt; + status = "disabled"; +}; diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 59c23d038106..aff3cd356662 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -269,6 +269,17 @@ config SERIAL_SIRFSOC_CONSOLE your boot loader about how to pass options to the kernel at boot time.) +config SERIAL_TEGRA + tristate "NVIDIA Tegra20/30 SoC serial controller" + depends on ARCH_TEGRA && TEGRA20_APB_DMA + select SERIAL_CORE + help + Support for the on-chip UARTs on the NVIDIA Tegra series SOCs + providing /dev/ttyHS0, 1, 2, 3 and 4 (note, some machines may not + provide all of these ports, depending on how the serial port + are enabled). This driver uses the APB DMA to achieve higher baudrate + and better performance. + config SERIAL_MAX3100 tristate "MAX3100 support" depends on SPI diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index df1b998c436b..82e4306bf962 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_MXS_AUART) += mxs-auart.o obj-$(CONFIG_SERIAL_LANTIQ) += lantiq.o obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o +obj-$(CONFIG_SERIAL_TEGRA) += serial-tegra.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c new file mode 100644 index 000000000000..cc4072f50352 --- /dev/null +++ b/drivers/tty/serial/serial-tegra.c @@ -0,0 +1,1399 @@ +/* + * serial_tegra.c + * + * High-speed serial driver for NVIDIA Tegra SoCs + * + * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved. + * + * Author: Laxman Dewangan + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define TEGRA_UART_TYPE "TEGRA_UART" +#define TX_EMPTY_STATUS (UART_LSR_TEMT | UART_LSR_THRE) +#define BYTES_TO_ALIGN(x) ((unsigned long)(x) & 0x3) + +#define TEGRA_UART_RX_DMA_BUFFER_SIZE 4096 +#define TEGRA_UART_LSR_TXFIFO_FULL 0x100 +#define TEGRA_UART_IER_EORD 0x20 +#define TEGRA_UART_MCR_RTS_EN 0x40 +#define TEGRA_UART_MCR_CTS_EN 0x20 +#define TEGRA_UART_LSR_ANY (UART_LSR_OE | UART_LSR_BI | \ + UART_LSR_PE | UART_LSR_FE) +#define TEGRA_UART_IRDA_CSR 0x08 +#define TEGRA_UART_SIR_ENABLED 0x80 + +#define TEGRA_UART_TX_PIO 1 +#define TEGRA_UART_TX_DMA 2 +#define TEGRA_UART_MIN_DMA 16 +#define TEGRA_UART_FIFO_SIZE 32 + +/* + * Tx fifo trigger level setting in tegra uart is in + * reverse way then conventional uart. + */ +#define TEGRA_UART_TX_TRIG_16B 0x00 +#define TEGRA_UART_TX_TRIG_8B 0x10 +#define TEGRA_UART_TX_TRIG_4B 0x20 +#define TEGRA_UART_TX_TRIG_1B 0x30 + +#define TEGRA_UART_MAXIMUM 5 + +/* Default UART setting when started: 115200 no parity, stop, 8 data bits */ +#define TEGRA_UART_DEFAULT_BAUD 115200 +#define TEGRA_UART_DEFAULT_LSR UART_LCR_WLEN8 + +/* Tx transfer mode */ +#define TEGRA_TX_PIO 1 +#define TEGRA_TX_DMA 2 + +/** + * tegra_uart_chip_data: SOC specific data. + * + * @tx_fifo_full_status: Status flag available for checking tx fifo full. + * @allow_txfifo_reset_fifo_mode: allow_tx fifo reset with fifo mode or not. + * Tegra30 does not allow this. + * @support_clk_src_div: Clock source support the clock divider. + */ +struct tegra_uart_chip_data { + bool tx_fifo_full_status; + bool allow_txfifo_reset_fifo_mode; + bool support_clk_src_div; +}; + +struct tegra_uart_port { + struct uart_port uport; + const struct tegra_uart_chip_data *cdata; + + struct clk *uart_clk; + unsigned int current_baud; + + /* Register shadow */ + unsigned long fcr_shadow; + unsigned long mcr_shadow; + unsigned long lcr_shadow; + unsigned long ier_shadow; + bool rts_active; + + int tx_in_progress; + unsigned int tx_bytes; + + bool enable_modem_interrupt; + + bool rx_timeout; + int rx_in_progress; + int symb_bit; + int dma_req_sel; + + struct dma_chan *rx_dma_chan; + struct dma_chan *tx_dma_chan; + dma_addr_t rx_dma_buf_phys; + dma_addr_t tx_dma_buf_phys; + unsigned char *rx_dma_buf_virt; + unsigned char *tx_dma_buf_virt; + struct dma_async_tx_descriptor *tx_dma_desc; + struct dma_async_tx_descriptor *rx_dma_desc; + dma_cookie_t tx_cookie; + dma_cookie_t rx_cookie; + int tx_bytes_requested; + int rx_bytes_requested; +}; + +static void tegra_uart_start_next_tx(struct tegra_uart_port *tup); +static int tegra_uart_start_rx_dma(struct tegra_uart_port *tup); + +static inline unsigned long tegra_uart_read(struct tegra_uart_port *tup, + unsigned long reg) +{ + return readl(tup->uport.membase + (reg << tup->uport.regshift)); +} + +static inline void tegra_uart_write(struct tegra_uart_port *tup, unsigned val, + unsigned long reg) +{ + writel(val, tup->uport.membase + (reg << tup->uport.regshift)); +} + +static inline struct tegra_uart_port *to_tegra_uport(struct uart_port *u) +{ + return container_of(u, struct tegra_uart_port, uport); +} + +static unsigned int tegra_uart_get_mctrl(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + + /* + * RI - Ring detector is active + * CD/DCD/CAR - Carrier detect is always active. For some reason + * linux has different names for carrier detect. + * DSR - Data Set ready is active as the hardware doesn't support it. + * Don't know if the linux support this yet? + * CTS - Clear to send. Always set to active, as the hardware handles + * CTS automatically. + */ + if (tup->enable_modem_interrupt) + return TIOCM_RI | TIOCM_CD | TIOCM_DSR | TIOCM_CTS; + return TIOCM_CTS; +} + +static void set_rts(struct tegra_uart_port *tup, bool active) +{ + unsigned long mcr; + + mcr = tup->mcr_shadow; + if (active) + mcr |= TEGRA_UART_MCR_RTS_EN; + else + mcr &= ~TEGRA_UART_MCR_RTS_EN; + if (mcr != tup->mcr_shadow) { + tegra_uart_write(tup, mcr, UART_MCR); + tup->mcr_shadow = mcr; + } + return; +} + +static void set_dtr(struct tegra_uart_port *tup, bool active) +{ + unsigned long mcr; + + mcr = tup->mcr_shadow; + if (active) + mcr |= UART_MCR_DTR; + else + mcr &= ~UART_MCR_DTR; + if (mcr != tup->mcr_shadow) { + tegra_uart_write(tup, mcr, UART_MCR); + tup->mcr_shadow = mcr; + } + return; +} + +static void tegra_uart_set_mctrl(struct uart_port *u, unsigned int mctrl) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + unsigned long mcr; + int dtr_enable; + + mcr = tup->mcr_shadow; + tup->rts_active = !!(mctrl & TIOCM_RTS); + set_rts(tup, tup->rts_active); + + dtr_enable = !!(mctrl & TIOCM_DTR); + set_dtr(tup, dtr_enable); + return; +} + +static void tegra_uart_break_ctl(struct uart_port *u, int break_ctl) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + unsigned long lcr; + + lcr = tup->lcr_shadow; + if (break_ctl) + lcr |= UART_LCR_SBC; + else + lcr &= ~UART_LCR_SBC; + tegra_uart_write(tup, lcr, UART_LCR); + tup->lcr_shadow = lcr; +} + +/* Wait for a symbol-time. */ +static void tegra_uart_wait_sym_time(struct tegra_uart_port *tup, + unsigned int syms) +{ + if (tup->current_baud) + udelay(DIV_ROUND_UP(syms * tup->symb_bit * 1000000, + tup->current_baud)); +} + +static void tegra_uart_fifo_reset(struct tegra_uart_port *tup, u8 fcr_bits) +{ + unsigned long fcr = tup->fcr_shadow; + + if (tup->cdata->allow_txfifo_reset_fifo_mode) { + fcr |= fcr_bits & (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); + tegra_uart_write(tup, fcr, UART_FCR); + } else { + fcr &= ~UART_FCR_ENABLE_FIFO; + tegra_uart_write(tup, fcr, UART_FCR); + udelay(60); + fcr |= fcr_bits & (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); + tegra_uart_write(tup, fcr, UART_FCR); + fcr |= UART_FCR_ENABLE_FIFO; + tegra_uart_write(tup, fcr, UART_FCR); + } + + /* Dummy read to ensure the write is posted */ + tegra_uart_read(tup, UART_SCR); + + /* Wait for the flush to propagate. */ + tegra_uart_wait_sym_time(tup, 1); +} + +static int tegra_set_baudrate(struct tegra_uart_port *tup, unsigned int baud) +{ + unsigned long rate; + unsigned int divisor; + unsigned long lcr; + int ret; + + if (tup->current_baud == baud) + return 0; + + if (tup->cdata->support_clk_src_div) { + rate = baud * 16; + ret = clk_set_rate(tup->uart_clk, rate); + if (ret < 0) { + dev_err(tup->uport.dev, + "clk_set_rate() failed for rate %lu\n", rate); + return ret; + } + divisor = 1; + } else { + rate = clk_get_rate(tup->uart_clk); + divisor = DIV_ROUND_CLOSEST(rate, baud * 16); + } + + lcr = tup->lcr_shadow; + lcr |= UART_LCR_DLAB; + tegra_uart_write(tup, lcr, UART_LCR); + + tegra_uart_write(tup, divisor & 0xFF, UART_TX); + tegra_uart_write(tup, ((divisor >> 8) & 0xFF), UART_IER); + + lcr &= ~UART_LCR_DLAB; + tegra_uart_write(tup, lcr, UART_LCR); + + /* Dummy read to ensure the write is posted */ + tegra_uart_read(tup, UART_SCR); + + tup->current_baud = baud; + + /* wait two character intervals at new rate */ + tegra_uart_wait_sym_time(tup, 2); + return 0; +} + +static char tegra_uart_decode_rx_error(struct tegra_uart_port *tup, + unsigned long lsr) +{ + char flag = TTY_NORMAL; + + if (unlikely(lsr & TEGRA_UART_LSR_ANY)) { + if (lsr & UART_LSR_OE) { + /* Overrrun error */ + flag |= TTY_OVERRUN; + tup->uport.icount.overrun++; + dev_err(tup->uport.dev, "Got overrun errors\n"); + } else if (lsr & UART_LSR_PE) { + /* Parity error */ + flag |= TTY_PARITY; + tup->uport.icount.parity++; + dev_err(tup->uport.dev, "Got Parity errors\n"); + } else if (lsr & UART_LSR_FE) { + flag |= TTY_FRAME; + tup->uport.icount.frame++; + dev_err(tup->uport.dev, "Got frame errors\n"); + } else if (lsr & UART_LSR_BI) { + dev_err(tup->uport.dev, "Got Break\n"); + tup->uport.icount.brk++; + /* If FIFO read error without any data, reset Rx FIFO */ + if (!(lsr & UART_LSR_DR) && (lsr & UART_LSR_FIFOE)) + tegra_uart_fifo_reset(tup, UART_FCR_CLEAR_RCVR); + } + } + return flag; +} + +static int tegra_uart_request_port(struct uart_port *u) +{ + return 0; +} + +static void tegra_uart_release_port(struct uart_port *u) +{ + /* Nothing to do here */ +} + +static void tegra_uart_fill_tx_fifo(struct tegra_uart_port *tup, int max_bytes) +{ + struct circ_buf *xmit = &tup->uport.state->xmit; + int i; + + for (i = 0; i < max_bytes; i++) { + BUG_ON(uart_circ_empty(xmit)); + if (tup->cdata->tx_fifo_full_status) { + unsigned long lsr = tegra_uart_read(tup, UART_LSR); + if ((lsr & TEGRA_UART_LSR_TXFIFO_FULL)) + break; + } + tegra_uart_write(tup, xmit->buf[xmit->tail], UART_TX); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + tup->uport.icount.tx++; + } +} + +static void tegra_uart_start_pio_tx(struct tegra_uart_port *tup, + unsigned int bytes) +{ + if (bytes > TEGRA_UART_MIN_DMA) + bytes = TEGRA_UART_MIN_DMA; + + tup->tx_in_progress = TEGRA_UART_TX_PIO; + tup->tx_bytes = bytes; + tup->ier_shadow |= UART_IER_THRI; + tegra_uart_write(tup, tup->ier_shadow, UART_IER); +} + +static void tegra_uart_tx_dma_complete(void *args) +{ + struct tegra_uart_port *tup = args; + struct circ_buf *xmit = &tup->uport.state->xmit; + struct dma_tx_state state; + unsigned long flags; + int count; + + dmaengine_tx_status(tup->tx_dma_chan, tup->rx_cookie, &state); + count = tup->tx_bytes_requested - state.residue; + async_tx_ack(tup->tx_dma_desc); + spin_lock_irqsave(&tup->uport.lock, flags); + xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); + tup->tx_in_progress = 0; + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&tup->uport); + tegra_uart_start_next_tx(tup); + spin_unlock_irqrestore(&tup->uport.lock, flags); +} + +static int tegra_uart_start_tx_dma(struct tegra_uart_port *tup, + unsigned long count) +{ + struct circ_buf *xmit = &tup->uport.state->xmit; + dma_addr_t tx_phys_addr; + + dma_sync_single_for_device(tup->uport.dev, tup->tx_dma_buf_phys, + UART_XMIT_SIZE, DMA_TO_DEVICE); + + tup->tx_bytes = count & ~(0xF); + tx_phys_addr = tup->tx_dma_buf_phys + xmit->tail; + tup->tx_dma_desc = dmaengine_prep_slave_single(tup->tx_dma_chan, + tx_phys_addr, tup->tx_bytes, DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT); + if (!tup->tx_dma_desc) { + dev_err(tup->uport.dev, "Not able to get desc for Tx\n"); + return -EIO; + } + + tup->tx_dma_desc->callback = tegra_uart_tx_dma_complete; + tup->tx_dma_desc->callback_param = tup; + tup->tx_in_progress = TEGRA_UART_TX_DMA; + tup->tx_bytes_requested = tup->tx_bytes; + tup->tx_cookie = dmaengine_submit(tup->tx_dma_desc); + dma_async_issue_pending(tup->tx_dma_chan); + return 0; +} + +static void tegra_uart_start_next_tx(struct tegra_uart_port *tup) +{ + unsigned long tail; + unsigned long count; + struct circ_buf *xmit = &tup->uport.state->xmit; + + tail = (unsigned long)&xmit->buf[xmit->tail]; + count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); + if (!count) + return; + + if (count < TEGRA_UART_MIN_DMA) + tegra_uart_start_pio_tx(tup, count); + else if (BYTES_TO_ALIGN(tail) > 0) + tegra_uart_start_pio_tx(tup, BYTES_TO_ALIGN(tail)); + else + tegra_uart_start_tx_dma(tup, count); +} + +/* Called by serial core driver with u->lock taken. */ +static void tegra_uart_start_tx(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + struct circ_buf *xmit = &u->state->xmit; + + if (!uart_circ_empty(xmit) && !tup->tx_in_progress) + tegra_uart_start_next_tx(tup); +} + +static unsigned int tegra_uart_tx_empty(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + unsigned int ret = 0; + unsigned long flags; + + spin_lock_irqsave(&u->lock, flags); + if (!tup->tx_in_progress) { + unsigned long lsr = tegra_uart_read(tup, UART_LSR); + if ((lsr & TX_EMPTY_STATUS) == TX_EMPTY_STATUS) + ret = TIOCSER_TEMT; + } + spin_unlock_irqrestore(&u->lock, flags); + return ret; +} + +static void tegra_uart_stop_tx(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + struct circ_buf *xmit = &tup->uport.state->xmit; + struct dma_tx_state state; + int count; + + dmaengine_terminate_all(tup->tx_dma_chan); + dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state); + count = tup->tx_bytes_requested - state.residue; + async_tx_ack(tup->tx_dma_desc); + xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); + tup->tx_in_progress = 0; + return; +} + +static void tegra_uart_handle_tx_pio(struct tegra_uart_port *tup) +{ + struct circ_buf *xmit = &tup->uport.state->xmit; + + tegra_uart_fill_tx_fifo(tup, tup->tx_bytes); + tup->tx_in_progress = 0; + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&tup->uport); + tegra_uart_start_next_tx(tup); + return; +} + +static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup, + struct tty_struct *tty) +{ + do { + char flag = TTY_NORMAL; + unsigned long lsr = 0; + unsigned char ch; + + lsr = tegra_uart_read(tup, UART_LSR); + if (!(lsr & UART_LSR_DR)) + break; + + flag = tegra_uart_decode_rx_error(tup, lsr); + ch = (unsigned char) tegra_uart_read(tup, UART_RX); + tup->uport.icount.rx++; + + if (!uart_handle_sysrq_char(&tup->uport, ch) && tty) + tty_insert_flip_char(tty, ch, flag); + } while (1); + + return; +} + +static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup, + struct tty_struct *tty, int count) +{ + int copied; + + tup->uport.icount.rx += count; + if (!tty) { + dev_err(tup->uport.dev, "No tty port\n"); + return; + } + dma_sync_single_for_cpu(tup->uport.dev, tup->rx_dma_buf_phys, + TEGRA_UART_RX_DMA_BUFFER_SIZE, DMA_FROM_DEVICE); + copied = tty_insert_flip_string(tty, + ((unsigned char *)(tup->rx_dma_buf_virt)), count); + if (copied != count) { + WARN_ON(1); + dev_err(tup->uport.dev, "RxData copy to tty layer failed\n"); + } + dma_sync_single_for_device(tup->uport.dev, tup->rx_dma_buf_phys, + TEGRA_UART_RX_DMA_BUFFER_SIZE, DMA_TO_DEVICE); +} + +static void tegra_uart_rx_dma_complete(void *args) +{ + struct tegra_uart_port *tup = args; + struct uart_port *u = &tup->uport; + int count = tup->rx_bytes_requested; + struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + unsigned long flags; + + async_tx_ack(tup->rx_dma_desc); + spin_lock_irqsave(&u->lock, flags); + + /* Deactivate flow control to stop sender */ + if (tup->rts_active) + set_rts(tup, false); + + /* If we are here, DMA is stopped */ + if (count) + tegra_uart_copy_rx_to_tty(tup, tty, count); + + tegra_uart_handle_rx_pio(tup, tty); + if (tty) { + tty_flip_buffer_push(tty); + tty_kref_put(tty); + } + tegra_uart_start_rx_dma(tup); + + /* Activate flow control to start transfer */ + if (tup->rts_active) + set_rts(tup, true); + + spin_unlock_irqrestore(&u->lock, flags); +} + +static void tegra_uart_handle_rx_dma(struct tegra_uart_port *tup) +{ + struct dma_tx_state state; + struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + int count; + + /* Deactivate flow control to stop sender */ + if (tup->rts_active) + set_rts(tup, false); + + dmaengine_terminate_all(tup->rx_dma_chan); + dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state); + count = tup->rx_bytes_requested - state.residue; + + /* If we are here, DMA is stopped */ + if (count) + tegra_uart_copy_rx_to_tty(tup, tty, count); + + tegra_uart_handle_rx_pio(tup, tty); + if (tty) { + tty_flip_buffer_push(tty); + tty_kref_put(tty); + } + tegra_uart_start_rx_dma(tup); + + if (tup->rts_active) + set_rts(tup, true); +} + +static int tegra_uart_start_rx_dma(struct tegra_uart_port *tup) +{ + unsigned int count = TEGRA_UART_RX_DMA_BUFFER_SIZE; + + tup->rx_dma_desc = dmaengine_prep_slave_single(tup->rx_dma_chan, + tup->rx_dma_buf_phys, count, DMA_DEV_TO_MEM, + DMA_PREP_INTERRUPT); + if (!tup->rx_dma_desc) { + dev_err(tup->uport.dev, "Not able to get desc for Rx\n"); + return -EIO; + } + + tup->rx_dma_desc->callback = tegra_uart_rx_dma_complete; + tup->rx_dma_desc->callback_param = tup; + dma_sync_single_for_device(tup->uport.dev, tup->rx_dma_buf_phys, + count, DMA_TO_DEVICE); + tup->rx_bytes_requested = count; + tup->rx_cookie = dmaengine_submit(tup->rx_dma_desc); + dma_async_issue_pending(tup->rx_dma_chan); + return 0; +} + +static void tegra_uart_handle_modem_signal_change(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + unsigned long msr; + + msr = tegra_uart_read(tup, UART_MSR); + if (!(msr & UART_MSR_ANY_DELTA)) + return; + + if (msr & UART_MSR_TERI) + tup->uport.icount.rng++; + if (msr & UART_MSR_DDSR) + tup->uport.icount.dsr++; + /* We may only get DDCD when HW init and reset */ + if (msr & UART_MSR_DDCD) + uart_handle_dcd_change(&tup->uport, msr & UART_MSR_DCD); + /* Will start/stop_tx accordingly */ + if (msr & UART_MSR_DCTS) + uart_handle_cts_change(&tup->uport, msr & UART_MSR_CTS); + return; +} + +static irqreturn_t tegra_uart_isr(int irq, void *data) +{ + struct tegra_uart_port *tup = data; + struct uart_port *u = &tup->uport; + unsigned long iir; + unsigned long ier; + bool is_rx_int = false; + unsigned long flags; + + spin_lock_irqsave(&u->lock, flags); + while (1) { + iir = tegra_uart_read(tup, UART_IIR); + if (iir & UART_IIR_NO_INT) { + if (is_rx_int) { + tegra_uart_handle_rx_dma(tup); + if (tup->rx_in_progress) { + ier = tup->ier_shadow; + ier |= (UART_IER_RLSI | UART_IER_RTOIE | + TEGRA_UART_IER_EORD); + tup->ier_shadow = ier; + tegra_uart_write(tup, ier, UART_IER); + } + } + spin_unlock_irqrestore(&u->lock, flags); + return IRQ_HANDLED; + } + + switch ((iir >> 1) & 0x7) { + case 0: /* Modem signal change interrupt */ + tegra_uart_handle_modem_signal_change(u); + break; + + case 1: /* Transmit interrupt only triggered when using PIO */ + tup->ier_shadow &= ~UART_IER_THRI; + tegra_uart_write(tup, tup->ier_shadow, UART_IER); + tegra_uart_handle_tx_pio(tup); + break; + + case 4: /* End of data */ + case 6: /* Rx timeout */ + case 2: /* Receive */ + if (!is_rx_int) { + is_rx_int = true; + /* Disable Rx interrupts */ + ier = tup->ier_shadow; + ier |= UART_IER_RDI; + tegra_uart_write(tup, ier, UART_IER); + ier &= ~(UART_IER_RDI | UART_IER_RLSI | + UART_IER_RTOIE | TEGRA_UART_IER_EORD); + tup->ier_shadow = ier; + tegra_uart_write(tup, ier, UART_IER); + } + break; + + case 3: /* Receive error */ + tegra_uart_decode_rx_error(tup, + tegra_uart_read(tup, UART_LSR)); + break; + + case 5: /* break nothing to handle */ + case 7: /* break nothing to handle */ + break; + } + } +} + +static void tegra_uart_stop_rx(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + struct dma_tx_state state; + unsigned long ier; + int count; + + if (tup->rts_active) + set_rts(tup, false); + + if (!tup->rx_in_progress) + return; + + tegra_uart_wait_sym_time(tup, 1); /* wait a character interval */ + + ier = tup->ier_shadow; + ier &= ~(UART_IER_RDI | UART_IER_RLSI | UART_IER_RTOIE | + TEGRA_UART_IER_EORD); + tup->ier_shadow = ier; + tegra_uart_write(tup, ier, UART_IER); + tup->rx_in_progress = 0; + if (tup->rx_dma_chan) { + dmaengine_terminate_all(tup->rx_dma_chan); + dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state); + async_tx_ack(tup->rx_dma_desc); + count = tup->rx_bytes_requested - state.residue; + tegra_uart_copy_rx_to_tty(tup, tty, count); + tegra_uart_handle_rx_pio(tup, tty); + } else { + tegra_uart_handle_rx_pio(tup, tty); + } + if (tty) { + tty_flip_buffer_push(tty); + tty_kref_put(tty); + } + return; +} + +static void tegra_uart_hw_deinit(struct tegra_uart_port *tup) +{ + unsigned long flags; + unsigned long char_time = DIV_ROUND_UP(10000000, tup->current_baud); + unsigned long fifo_empty_time = tup->uport.fifosize * char_time; + unsigned long wait_time; + unsigned long lsr; + unsigned long msr; + unsigned long mcr; + + /* Disable interrupts */ + tegra_uart_write(tup, 0, UART_IER); + + lsr = tegra_uart_read(tup, UART_LSR); + if ((lsr & UART_LSR_TEMT) != UART_LSR_TEMT) { + msr = tegra_uart_read(tup, UART_MSR); + mcr = tegra_uart_read(tup, UART_MCR); + if ((mcr & TEGRA_UART_MCR_CTS_EN) && (msr & UART_MSR_CTS)) + dev_err(tup->uport.dev, + "Tx Fifo not empty, CTS disabled, waiting\n"); + + /* Wait for Tx fifo to be empty */ + while ((lsr & UART_LSR_TEMT) != UART_LSR_TEMT) { + wait_time = min(fifo_empty_time, 100lu); + udelay(wait_time); + fifo_empty_time -= wait_time; + if (!fifo_empty_time) { + msr = tegra_uart_read(tup, UART_MSR); + mcr = tegra_uart_read(tup, UART_MCR); + if ((mcr & TEGRA_UART_MCR_CTS_EN) && + (msr & UART_MSR_CTS)) + dev_err(tup->uport.dev, + "Slave not ready\n"); + break; + } + lsr = tegra_uart_read(tup, UART_LSR); + } + } + + spin_lock_irqsave(&tup->uport.lock, flags); + /* Reset the Rx and Tx FIFOs */ + tegra_uart_fifo_reset(tup, UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_RCVR); + tup->current_baud = 0; + spin_unlock_irqrestore(&tup->uport.lock, flags); + + clk_disable_unprepare(tup->uart_clk); +} + +static int tegra_uart_hw_init(struct tegra_uart_port *tup) +{ + int ret; + + tup->fcr_shadow = 0; + tup->mcr_shadow = 0; + tup->lcr_shadow = 0; + tup->ier_shadow = 0; + tup->current_baud = 0; + + clk_prepare_enable(tup->uart_clk); + + /* Reset the UART controller to clear all previous status.*/ + tegra_periph_reset_assert(tup->uart_clk); + udelay(10); + tegra_periph_reset_deassert(tup->uart_clk); + + tup->rx_in_progress = 0; + tup->tx_in_progress = 0; + + /* + * Set the trigger level + * + * For PIO mode: + * + * For receive, this will interrupt the CPU after that many number of + * bytes are received, for the remaining bytes the receive timeout + * interrupt is received. Rx high watermark is set to 4. + * + * For transmit, if the trasnmit interrupt is enabled, this will + * interrupt the CPU when the number of entries in the FIFO reaches the + * low watermark. Tx low watermark is set to 16 bytes. + * + * For DMA mode: + * + * Set the Tx trigger to 16. This should match the DMA burst size that + * programmed in the DMA registers. + */ + tup->fcr_shadow = UART_FCR_ENABLE_FIFO; + tup->fcr_shadow |= UART_FCR_R_TRIG_01; + tup->fcr_shadow |= TEGRA_UART_TX_TRIG_16B; + tegra_uart_write(tup, tup->fcr_shadow, UART_FCR); + + /* + * Initialize the UART with default configuration + * (115200, N, 8, 1) so that the receive DMA buffer may be + * enqueued + */ + tup->lcr_shadow = TEGRA_UART_DEFAULT_LSR; + tegra_set_baudrate(tup, TEGRA_UART_DEFAULT_BAUD); + tup->fcr_shadow |= UART_FCR_DMA_SELECT; + tegra_uart_write(tup, tup->fcr_shadow, UART_FCR); + + ret = tegra_uart_start_rx_dma(tup); + if (ret < 0) { + dev_err(tup->uport.dev, "Not able to start Rx DMA\n"); + return ret; + } + tup->rx_in_progress = 1; + + /* + * Enable IE_RXS for the receive status interrupts like line errros. + * Enable IE_RX_TIMEOUT to get the bytes which cannot be DMA'd. + * + * If using DMA mode, enable EORD instead of receive interrupt which + * will interrupt after the UART is done with the receive instead of + * the interrupt when the FIFO "threshold" is reached. + * + * EORD is different interrupt than RX_TIMEOUT - RX_TIMEOUT occurs when + * the DATA is sitting in the FIFO and couldn't be transferred to the + * DMA as the DMA size alignment(4 bytes) is not met. EORD will be + * triggered when there is a pause of the incomming data stream for 4 + * characters long. + * + * For pauses in the data which is not aligned to 4 bytes, we get + * both the EORD as well as RX_TIMEOUT - SW sees RX_TIMEOUT first + * then the EORD. + */ + tup->ier_shadow = UART_IER_RLSI | UART_IER_RTOIE | TEGRA_UART_IER_EORD; + tegra_uart_write(tup, tup->ier_shadow, UART_IER); + return 0; +} + +static int tegra_uart_dma_channel_allocate(struct tegra_uart_port *tup, + bool dma_to_memory) +{ + struct dma_chan *dma_chan; + unsigned char *dma_buf; + dma_addr_t dma_phys; + int ret; + struct dma_slave_config dma_sconfig; + dma_cap_mask_t mask; + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + dma_chan = dma_request_channel(mask, NULL, NULL); + if (!dma_chan) { + dev_err(tup->uport.dev, + "Dma channel is not available, will try later\n"); + return -EPROBE_DEFER; + } + + if (dma_to_memory) { + dma_buf = dma_alloc_coherent(tup->uport.dev, + TEGRA_UART_RX_DMA_BUFFER_SIZE, + &dma_phys, GFP_KERNEL); + if (!dma_buf) { + dev_err(tup->uport.dev, + "Not able to allocate the dma buffer\n"); + dma_release_channel(dma_chan); + return -ENOMEM; + } + } else { + dma_phys = dma_map_single(tup->uport.dev, + tup->uport.state->xmit.buf, UART_XMIT_SIZE, + DMA_TO_DEVICE); + dma_buf = tup->uport.state->xmit.buf; + } + + dma_sconfig.slave_id = tup->dma_req_sel; + if (dma_to_memory) { + dma_sconfig.src_addr = tup->uport.mapbase; + dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dma_sconfig.src_maxburst = 4; + } else { + dma_sconfig.dst_addr = tup->uport.mapbase; + dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dma_sconfig.dst_maxburst = 16; + } + + ret = dmaengine_slave_config(dma_chan, &dma_sconfig); + if (ret < 0) { + dev_err(tup->uport.dev, + "Dma slave config failed, err = %d\n", ret); + goto scrub; + } + + if (dma_to_memory) { + tup->rx_dma_chan = dma_chan; + tup->rx_dma_buf_virt = dma_buf; + tup->rx_dma_buf_phys = dma_phys; + } else { + tup->tx_dma_chan = dma_chan; + tup->tx_dma_buf_virt = dma_buf; + tup->tx_dma_buf_phys = dma_phys; + } + return 0; + +scrub: + dma_release_channel(dma_chan); + return ret; +} + +static void tegra_uart_dma_channel_free(struct tegra_uart_port *tup, + bool dma_to_memory) +{ + struct dma_chan *dma_chan; + + if (dma_to_memory) { + dma_free_coherent(tup->uport.dev, TEGRA_UART_RX_DMA_BUFFER_SIZE, + tup->rx_dma_buf_virt, tup->rx_dma_buf_phys); + dma_chan = tup->rx_dma_chan; + tup->rx_dma_chan = NULL; + tup->rx_dma_buf_phys = 0; + tup->rx_dma_buf_virt = NULL; + } else { + dma_unmap_single(tup->uport.dev, tup->tx_dma_buf_phys, + UART_XMIT_SIZE, DMA_TO_DEVICE); + dma_chan = tup->tx_dma_chan; + tup->tx_dma_chan = NULL; + tup->tx_dma_buf_phys = 0; + tup->tx_dma_buf_virt = NULL; + } + dma_release_channel(dma_chan); +} + +static int tegra_uart_startup(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + int ret; + + ret = tegra_uart_dma_channel_allocate(tup, false); + if (ret < 0) { + dev_err(u->dev, "Tx Dma allocation failed, err = %d\n", ret); + return ret; + } + + ret = tegra_uart_dma_channel_allocate(tup, true); + if (ret < 0) { + dev_err(u->dev, "Rx Dma allocation failed, err = %d\n", ret); + goto fail_rx_dma; + } + + ret = tegra_uart_hw_init(tup); + if (ret < 0) { + dev_err(u->dev, "Uart HW init failed, err = %d\n", ret); + goto fail_hw_init; + } + + ret = request_irq(u->irq, tegra_uart_isr, IRQF_DISABLED, + dev_name(u->dev), tup); + if (ret < 0) { + dev_err(u->dev, "Failed to register ISR for IRQ %d\n", u->irq); + goto fail_hw_init; + } + return 0; + +fail_hw_init: + tegra_uart_dma_channel_free(tup, true); +fail_rx_dma: + tegra_uart_dma_channel_free(tup, false); + return ret; +} + +static void tegra_uart_shutdown(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + + tegra_uart_hw_deinit(tup); + + tup->rx_in_progress = 0; + tup->tx_in_progress = 0; + + tegra_uart_dma_channel_free(tup, true); + tegra_uart_dma_channel_free(tup, false); + free_irq(u->irq, tup); +} + +static void tegra_uart_enable_ms(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + + if (tup->enable_modem_interrupt) { + tup->ier_shadow |= UART_IER_MSI; + tegra_uart_write(tup, tup->ier_shadow, UART_IER); + } +} + +static void tegra_uart_set_termios(struct uart_port *u, + struct ktermios *termios, struct ktermios *oldtermios) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + unsigned int baud; + unsigned long flags; + unsigned int lcr; + int symb_bit = 1; + struct clk *parent_clk = clk_get_parent(tup->uart_clk); + unsigned long parent_clk_rate = clk_get_rate(parent_clk); + int max_divider = (tup->cdata->support_clk_src_div) ? 0x7FFF : 0xFFFF; + + max_divider *= 16; + spin_lock_irqsave(&u->lock, flags); + + /* Changing configuration, it is safe to stop any rx now */ + if (tup->rts_active) + set_rts(tup, false); + + /* Clear all interrupts as configuration is going to be change */ + tegra_uart_write(tup, tup->ier_shadow | UART_IER_RDI, UART_IER); + tegra_uart_read(tup, UART_IER); + tegra_uart_write(tup, 0, UART_IER); + tegra_uart_read(tup, UART_IER); + + /* Parity */ + lcr = tup->lcr_shadow; + lcr &= ~UART_LCR_PARITY; + + /* CMSPAR isn't supported by this driver */ + termios->c_cflag &= ~CMSPAR; + + if ((termios->c_cflag & PARENB) == PARENB) { + symb_bit++; + if (termios->c_cflag & PARODD) { + lcr |= UART_LCR_PARITY; + lcr &= ~UART_LCR_EPAR; + lcr &= ~UART_LCR_SPAR; + } else { + lcr |= UART_LCR_PARITY; + lcr |= UART_LCR_EPAR; + lcr &= ~UART_LCR_SPAR; + } + } + + lcr &= ~UART_LCR_WLEN8; + switch (termios->c_cflag & CSIZE) { + case CS5: + lcr |= UART_LCR_WLEN5; + symb_bit += 5; + break; + case CS6: + lcr |= UART_LCR_WLEN6; + symb_bit += 6; + break; + case CS7: + lcr |= UART_LCR_WLEN7; + symb_bit += 7; + break; + default: + lcr |= UART_LCR_WLEN8; + symb_bit += 8; + break; + } + + /* Stop bits */ + if (termios->c_cflag & CSTOPB) { + lcr |= UART_LCR_STOP; + symb_bit += 2; + } else { + lcr &= ~UART_LCR_STOP; + symb_bit++; + } + + tegra_uart_write(tup, lcr, UART_LCR); + tup->lcr_shadow = lcr; + tup->symb_bit = symb_bit; + + /* Baud rate. */ + baud = uart_get_baud_rate(u, termios, oldtermios, + parent_clk_rate/max_divider, + parent_clk_rate/16); + spin_unlock_irqrestore(&u->lock, flags); + tegra_set_baudrate(tup, baud); + if (tty_termios_baud_rate(termios)) + tty_termios_encode_baud_rate(termios, baud, baud); + spin_lock_irqsave(&u->lock, flags); + + /* Flow control */ + if (termios->c_cflag & CRTSCTS) { + tup->mcr_shadow |= TEGRA_UART_MCR_CTS_EN; + tup->mcr_shadow &= ~TEGRA_UART_MCR_RTS_EN; + tegra_uart_write(tup, tup->mcr_shadow, UART_MCR); + /* if top layer has asked to set rts active then do so here */ + if (tup->rts_active) + set_rts(tup, true); + } else { + tup->mcr_shadow &= ~TEGRA_UART_MCR_CTS_EN; + tup->mcr_shadow &= ~TEGRA_UART_MCR_RTS_EN; + tegra_uart_write(tup, tup->mcr_shadow, UART_MCR); + } + + /* update the port timeout based on new settings */ + uart_update_timeout(u, termios->c_cflag, baud); + + /* Make sure all write has completed */ + tegra_uart_read(tup, UART_IER); + + /* Reenable interrupt */ + tegra_uart_write(tup, tup->ier_shadow, UART_IER); + tegra_uart_read(tup, UART_IER); + + spin_unlock_irqrestore(&u->lock, flags); + return; +} + +/* + * Flush any TX data submitted for DMA and PIO. Called when the + * TX circular buffer is reset. + */ +static void tegra_uart_flush_buffer(struct uart_port *u) +{ + struct tegra_uart_port *tup = to_tegra_uport(u); + + tup->tx_bytes = 0; + if (tup->tx_dma_chan) + dmaengine_terminate_all(tup->tx_dma_chan); + return; +} + +static const char *tegra_uart_type(struct uart_port *u) +{ + return TEGRA_UART_TYPE; +} + +static struct uart_ops tegra_uart_ops = { + .tx_empty = tegra_uart_tx_empty, + .set_mctrl = tegra_uart_set_mctrl, + .get_mctrl = tegra_uart_get_mctrl, + .stop_tx = tegra_uart_stop_tx, + .start_tx = tegra_uart_start_tx, + .stop_rx = tegra_uart_stop_rx, + .flush_buffer = tegra_uart_flush_buffer, + .enable_ms = tegra_uart_enable_ms, + .break_ctl = tegra_uart_break_ctl, + .startup = tegra_uart_startup, + .shutdown = tegra_uart_shutdown, + .set_termios = tegra_uart_set_termios, + .type = tegra_uart_type, + .request_port = tegra_uart_request_port, + .release_port = tegra_uart_release_port, +}; + +static struct uart_driver tegra_uart_driver = { + .owner = THIS_MODULE, + .driver_name = "tegra_hsuart", + .dev_name = "ttyTHS", + .cons = 0, + .nr = TEGRA_UART_MAXIMUM, +}; + +static int tegra_uart_parse_dt(struct platform_device *pdev, + struct tegra_uart_port *tup) +{ + struct device_node *np = pdev->dev.of_node; + u32 of_dma[2]; + int port; + + if (of_property_read_u32_array(np, "nvidia,dma-request-selector", + of_dma, 2) >= 0) { + tup->dma_req_sel = of_dma[1]; + } else { + dev_err(&pdev->dev, "missing dma requestor in device tree\n"); + return -EINVAL; + } + + port = of_alias_get_id(np, "serial"); + if (port < 0) { + dev_err(&pdev->dev, "failed to get alias id, errno %d\n", port); + return port; + } + tup->uport.line = port; + + tup->enable_modem_interrupt = of_property_read_bool(np, + "nvidia,enable-modem-interrupt"); + return 0; +} + +struct tegra_uart_chip_data tegra20_uart_chip_data = { + .tx_fifo_full_status = false, + .allow_txfifo_reset_fifo_mode = true, + .support_clk_src_div = false, +}; + +struct tegra_uart_chip_data tegra30_uart_chip_data = { + .tx_fifo_full_status = true, + .allow_txfifo_reset_fifo_mode = false, + .support_clk_src_div = true, +}; + +static struct of_device_id tegra_uart_of_match[] = { + { + .compatible = "nvidia,tegra30-hsuart", + .data = &tegra30_uart_chip_data, + }, { + .compatible = "nvidia,tegra20-hsuart", + .data = &tegra20_uart_chip_data, + }, { + }, +}; +MODULE_DEVICE_TABLE(of, tegra_uart_of_match); + +static int tegra_uart_probe(struct platform_device *pdev) +{ + struct tegra_uart_port *tup; + struct uart_port *u; + struct resource *resource; + int ret; + const struct tegra_uart_chip_data *cdata; + const struct of_device_id *match; + + match = of_match_device(of_match_ptr(tegra_uart_of_match), + &pdev->dev); + if (!match) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + cdata = match->data; + + tup = devm_kzalloc(&pdev->dev, sizeof(*tup), GFP_KERNEL); + if (!tup) { + dev_err(&pdev->dev, "Failed to allocate memory for tup\n"); + return -ENOMEM; + } + + ret = tegra_uart_parse_dt(pdev, tup); + if (ret < 0) + return ret; + + u = &tup->uport; + u->dev = &pdev->dev; + u->ops = &tegra_uart_ops; + u->type = PORT_TEGRA; + u->fifosize = 32; + tup->cdata = cdata; + + platform_set_drvdata(pdev, tup); + resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!resource) { + dev_err(&pdev->dev, "No IO memory resource\n"); + return -ENODEV; + } + + u->mapbase = resource->start; + u->membase = devm_request_and_ioremap(&pdev->dev, resource); + if (!u->membase) { + dev_err(&pdev->dev, "memregion/iomap address req failed\n"); + return -EADDRNOTAVAIL; + } + + tup->uart_clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(tup->uart_clk)) { + dev_err(&pdev->dev, "Couldn't get the clock\n"); + return PTR_ERR(tup->uart_clk); + } + + u->iotype = UPIO_MEM32; + u->irq = platform_get_irq(pdev, 0); + u->regshift = 2; + ret = uart_add_one_port(&tegra_uart_driver, u); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret); + return ret; + } + return ret; +} + +static int tegra_uart_remove(struct platform_device *pdev) +{ + struct tegra_uart_port *tup = platform_get_drvdata(pdev); + struct uart_port *u = &tup->uport; + + uart_remove_one_port(&tegra_uart_driver, u); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int tegra_uart_suspend(struct device *dev) +{ + struct tegra_uart_port *tup = dev_get_drvdata(dev); + struct uart_port *u = &tup->uport; + + return uart_suspend_port(&tegra_uart_driver, u); +} + +static int tegra_uart_resume(struct device *dev) +{ + struct tegra_uart_port *tup = dev_get_drvdata(dev); + struct uart_port *u = &tup->uport; + + return uart_resume_port(&tegra_uart_driver, u); +} +#endif + +static const struct dev_pm_ops tegra_uart_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(tegra_uart_suspend, tegra_uart_resume) +}; + +static struct platform_driver tegra_uart_platform_driver = { + .probe = tegra_uart_probe, + .remove = tegra_uart_remove, + .driver = { + .name = "serial-tegra", + .of_match_table = of_match_ptr(tegra_uart_of_match), + .pm = &tegra_uart_pm_ops, + }, +}; + +static int __init tegra_uart_init(void) +{ + int ret; + + ret = uart_register_driver(&tegra_uart_driver); + if (ret < 0) { + pr_err("Could not register %s driver\n", + tegra_uart_driver.driver_name); + return ret; + } + + ret = platform_driver_register(&tegra_uart_platform_driver); + if (ret < 0) { + pr_err("Uart platfrom driver register failed, e = %d\n", ret); + uart_unregister_driver(&tegra_uart_driver); + return ret; + } + return 0; +} + +static void __exit tegra_uart_exit(void) +{ + pr_info("Unloading tegra uart driver\n"); + platform_driver_unregister(&tegra_uart_platform_driver); + uart_unregister_driver(&tegra_uart_driver); +} + +module_init(tegra_uart_init); +module_exit(tegra_uart_exit); + +MODULE_ALIAS("platform:serial-tegra"); +MODULE_DESCRIPTION("High speed UART driver for tegra chipset"); +MODULE_AUTHOR("Laxman Dewangan "); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 026bb292c4018dd77186dee1fcb73c9067e69b89 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 11 Jan 2013 11:50:20 +0530 Subject: serial/arc-uart: Don't index with -ve platform_device->id probe routine could index into port[] with -ve index. The check in arc_uart_init_one() was too late. This came to light when trying to port driver to CONFIG_OF, where bydefault of-core code sets -ve platform dev id and in absence of DT serial aliases, driver would use the -ve index. Signed-off-by: Vineet Gupta Cc: Alan Cox Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/arc_uart.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 3e0b3fac6a0e..8089dc355ac5 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -526,15 +526,11 @@ static struct uart_ops arc_serial_pops = { }; static int -arc_uart_init_one(struct platform_device *pdev, struct arc_uart_port *uart) +arc_uart_init_one(struct platform_device *pdev, int dev_id) { struct resource *res, *res2; unsigned long *plat_data; - - if (pdev->id < 0 || pdev->id >= CONFIG_SERIAL_ARC_NR_PORTS) { - dev_err(&pdev->dev, "Wrong uart platform device id.\n"); - return -ENOENT; - } + struct arc_uart_port *uart = &arc_uart_ports[dev_id]; plat_data = ((unsigned long *)(pdev->dev.platform_data)); uart->baud = plat_data[0]; @@ -557,7 +553,7 @@ arc_uart_init_one(struct platform_device *pdev, struct arc_uart_port *uart) uart->port.dev = &pdev->dev; uart->port.iotype = UPIO_MEM; uart->port.flags = UPF_BOOT_AUTOCONF; - uart->port.line = pdev->id; + uart->port.line = dev_id; uart->port.ops = &arc_serial_pops; uart->port.uartclk = plat_data[1]; @@ -657,9 +653,14 @@ static struct __initdata console arc_early_serial_console = { static int arc_serial_probe_earlyprintk(struct platform_device *pdev) { - arc_early_serial_console.index = pdev->id; + int dev_id = pdev->id < 0 ? 0 : pdev->id; + int rc; - arc_uart_init_one(pdev, &arc_uart_ports[pdev->id]); + arc_early_serial_console.index = dev_id; + + rc = arc_uart_init_one(pdev, dev_id); + if (rc) + panic("early console init failed\n"); arc_serial_console_setup(&arc_early_serial_console, NULL); @@ -675,18 +676,18 @@ static int arc_serial_probe_earlyprintk(struct platform_device *pdev) static int arc_serial_probe(struct platform_device *pdev) { - struct arc_uart_port *uart; - int rc; + int rc, dev_id; if (is_early_platform_device(pdev)) return arc_serial_probe_earlyprintk(pdev); - uart = &arc_uart_ports[pdev->id]; - rc = arc_uart_init_one(pdev, uart); + dev_id = pdev->id < 0 ? 0 : pdev->id; + rc = arc_uart_init_one(pdev, dev_id); if (rc) return rc; - return uart_add_one_port(&arc_uart_driver, &uart->port); + rc = uart_add_one_port(&arc_uart_driver, &arc_uart_ports[dev_id].port); + return rc; } static int arc_serial_remove(struct platform_device *pdev) -- cgit v1.2.3 From e163d1f42bc2089efae58b4966287c4d3504d4c7 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 11 Jan 2013 11:50:21 +0530 Subject: serial/arc-uart: split probe from probe_earlyprintk This is in preparation for devicetree based probing, where earlyprintk won't have access to DT serial aliases which the normal probe would absolutely rely on. Signed-off-by: Vineet Gupta Cc: Alan Cox Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/arc_uart.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 8089dc355ac5..9de26ba48d20 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -651,7 +651,7 @@ static struct __initdata console arc_early_serial_console = { .index = -1 }; -static int arc_serial_probe_earlyprintk(struct platform_device *pdev) +static int __init arc_serial_probe_earlyprintk(struct platform_device *pdev) { int dev_id = pdev->id < 0 ? 0 : pdev->id; int rc; @@ -667,20 +667,12 @@ static int arc_serial_probe_earlyprintk(struct platform_device *pdev) register_console(&arc_early_serial_console); return 0; } -#else -static int arc_serial_probe_earlyprintk(struct platform_device *pdev) -{ - return -ENODEV; -} #endif /* CONFIG_SERIAL_ARC_CONSOLE */ static int arc_serial_probe(struct platform_device *pdev) { int rc, dev_id; - if (is_early_platform_device(pdev)) - return arc_serial_probe_earlyprintk(pdev); - dev_id = pdev->id < 0 ? 0 : pdev->id; rc = arc_uart_init_one(pdev, dev_id); if (rc) @@ -706,6 +698,15 @@ static struct platform_driver arc_platform_driver = { }; #ifdef CONFIG_SERIAL_ARC_CONSOLE + +static struct platform_driver early_arc_platform_driver = { + .probe = arc_serial_probe_earlyprintk, + .remove = arc_serial_remove, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; /* * Register an early platform driver of "earlyprintk" class. * ARCH platform code installs the driver and probes the early devices @@ -713,7 +714,7 @@ static struct platform_driver arc_platform_driver = { * or it could be done independently, for all "earlyprintk" class drivers. * [see arch/arc/plat-arcfpga/platform.c] */ -early_platform_init("earlyprintk", &arc_platform_driver); +early_platform_init("earlyprintk", &early_arc_platform_driver); #endif /* CONFIG_SERIAL_ARC_CONSOLE */ -- cgit v1.2.3 From d6c0d06b341803fde45e592df4233579f3afb04e Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 11 Jan 2013 11:50:22 +0530 Subject: serial/arc-uart: platform_data order changed * is_emulated is now 1st element, rather than last * also tucked all platform data refs together Signed-off-by: Vineet Gupta Cc: Alan Cox Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/arc_uart.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 9de26ba48d20..2db64105677b 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -533,7 +533,12 @@ arc_uart_init_one(struct platform_device *pdev, int dev_id) struct arc_uart_port *uart = &arc_uart_ports[dev_id]; plat_data = ((unsigned long *)(pdev->dev.platform_data)); - uart->baud = plat_data[0]; + if (!plat_data) + return -ENODEV; + + uart->is_emulated = !!plat_data[0]; /* workaround ISS bug */ + uart->port.uartclk = plat_data[1]; + uart->baud = plat_data[2]; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -556,7 +561,6 @@ arc_uart_init_one(struct platform_device *pdev, int dev_id) uart->port.line = dev_id; uart->port.ops = &arc_serial_pops; - uart->port.uartclk = plat_data[1]; uart->port.fifosize = ARC_UART_TX_FIFO_SIZE; /* @@ -565,9 +569,6 @@ arc_uart_init_one(struct platform_device *pdev, int dev_id) */ uart->port.ignore_status_mask = 0; - /* Real Hardware vs. emulated to work around a bug */ - uart->is_emulated = !!plat_data[2]; - return 0; } -- cgit v1.2.3 From ea28fd56fcde69af768135e428093f94c5ca6a88 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 11 Jan 2013 11:50:23 +0530 Subject: serial/arc-uart: switch to devicetree based probing * DT binding for arc-uart * With alll the bits in place we can now use DT probing. Note that there's a bit of kludge right now because earlyprintk portion of driver can't use the DT infrastrcuture to get resoures/plat_data. This requires some infrastructre changes to of_flat_ framework Signed-off-by: Vineet Gupta Cc: Grant Likely Cc: Arnd Bergmann Cc: Alan Cox Cc: devicetree-discuss@lists.ozlabs.org Cc: Rob Herring Cc: Rob Landley Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- .../devicetree/bindings/tty/serial/arc-uart.txt | 26 +++++++++++++ drivers/tty/serial/arc_uart.c | 43 ++++++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/tty/serial/arc-uart.txt (limited to 'drivers') diff --git a/Documentation/devicetree/bindings/tty/serial/arc-uart.txt b/Documentation/devicetree/bindings/tty/serial/arc-uart.txt new file mode 100644 index 000000000000..c3bd8f9c9997 --- /dev/null +++ b/Documentation/devicetree/bindings/tty/serial/arc-uart.txt @@ -0,0 +1,26 @@ +* Synopsys ARC UART : Non standard UART used in some of the ARC FPGA boards + +Required properties: +- compatible : "snps,arc-uart" +- reg : offset and length of the register set for the device. +- interrupts : device interrupt +- clock-frequency : the input clock frequency for the UART +- baud : baud rate for UART + +e.g. + +arcuart0: serial@c0fc1000 { + compatible = "snps,arc-uart"; + reg = <0xc0fc1000 0x100>; + interrupts = <5>; + clock-frequency = <80000000>; + baud = <115200>; + status = "okay"; +}; + +Note: Each port should have an alias correctly numbered in "aliases" node. + +e.g. +aliases { + serial0 = &arcuart0; +}; diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 2db64105677b..b46860104312 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include /************************************* * ARC UART Hardware Specs @@ -537,8 +539,26 @@ arc_uart_init_one(struct platform_device *pdev, int dev_id) return -ENODEV; uart->is_emulated = !!plat_data[0]; /* workaround ISS bug */ - uart->port.uartclk = plat_data[1]; - uart->baud = plat_data[2]; + + if (is_early_platform_device(pdev)) { + uart->port.uartclk = plat_data[1]; + uart->baud = plat_data[2]; + } else { + struct device_node *np = pdev->dev.of_node; + u32 val; + + if (of_property_read_u32(np, "clock-frequency", &val)) { + dev_err(&pdev->dev, "clock-frequency property NOTset\n"); + return -EINVAL; + } + uart->port.uartclk = val; + + if (of_property_read_u32(np, "baud", &val)) { + dev_err(&pdev->dev, "baud property NOT set\n"); + return -EINVAL; + } + uart->baud = val; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -673,8 +693,18 @@ static int __init arc_serial_probe_earlyprintk(struct platform_device *pdev) static int arc_serial_probe(struct platform_device *pdev) { int rc, dev_id; + struct device_node *np = pdev->dev.of_node; + + /* no device tree device */ + if (!np) + return -ENODEV; + + dev_id = of_alias_get_id(np, "serial"); + if (dev_id < 0) { + dev_err(&pdev->dev, "failed to get alias id: %d\n", dev_id); + return dev_id; + } - dev_id = pdev->id < 0 ? 0 : pdev->id; rc = arc_uart_init_one(pdev, dev_id); if (rc) return rc; @@ -689,12 +719,19 @@ static int arc_serial_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id arc_uart_dt_ids[] = { + { .compatible = "snps,arc-uart" }, + { /* Sentinel */ } +}; +MODULE_DEVICE_TABLE(of, arc_uart_dt_ids); + static struct platform_driver arc_platform_driver = { .probe = arc_serial_probe, .remove = arc_serial_remove, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = arc_uart_dt_ids, }, }; -- cgit v1.2.3 From 227434f8986c3827a1faedd1feb437acd6285315 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:01 +0100 Subject: TTY: switch tty_buffer_request_room to tty_port Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty pointer in many call sites. Only tty_port will be needed and hence no more tty_port_tty_get calls in those paths. Here we start with tty_buffer_request_room. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/mn10300/kernel/mn10300-serial.c | 5 +++-- arch/um/drivers/chan_kern.c | 3 ++- drivers/char/pcmcia/synclink_cs.c | 3 ++- drivers/isdn/i4l/isdn_common.c | 3 ++- drivers/isdn/i4l/isdn_tty.c | 12 +++++++----- drivers/staging/dgrp/dgrp_net_ops.c | 4 ++-- drivers/tty/cyclades.c | 13 ++++++++----- drivers/tty/ehv_bytechan.c | 2 +- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 2 +- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 5 +++-- drivers/tty/serial/ioc4_serial.c | 2 +- drivers/tty/serial/jsm/jsm_tty.c | 6 ++++-- drivers/tty/serial/mpsc.c | 6 +++--- drivers/tty/serial/mrst_max3110.c | 6 ++++-- drivers/tty/serial/pch_uart.c | 5 +++-- drivers/tty/serial/sh-sci.c | 8 +++++--- drivers/tty/serial/ucc_uart.c | 5 +++-- drivers/tty/tty_buffer.c | 5 ++--- drivers/usb/serial/quatech2.c | 4 ++-- include/linux/tty_flip.h | 2 +- 21 files changed, 60 insertions(+), 43 deletions(-) (limited to 'drivers') diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index 81d5cb9b6569..9b2232a78ff9 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -524,7 +524,8 @@ static int mask_test_and_clear(volatile u8 *ptr, u8 mask) static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) { struct uart_icount *icount = &port->uart.icount; - struct tty_struct *tty = port->uart.state->port.tty; + struct tty_port *port = &port->uart.state->port; + struct tty_struct *tty = port->tty; unsigned ix; int count; u8 st, ch, push, status, overrun; @@ -534,7 +535,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) push = 0; count = CIRC_CNT(port->rx_inp, port->rx_outp, MNSC_BUFFER_SIZE); - count = tty_buffer_request_room(tty, count); + count = tty_buffer_request_room(port, count); if (count == 0) { if (!tty->low_latency) tty_flip_buffer_push(tty); diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index e9a0abc6a32f..4ff2503a1bb8 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -554,6 +554,7 @@ int parse_chan_pair(char *str, struct line *line, int device, void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) { + struct tty_port *port = &line->port; struct chan *chan = line->chan_in; int err; char c; @@ -562,7 +563,7 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) goto out; do { - if (tty && !tty_buffer_request_room(tty, 1)) { + if (!tty_buffer_request_room(port, 1)) { schedule_delayed_work(&line->task, 1); goto out; } diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index b2f35d786025..0b1de715f097 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -888,6 +888,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) { + struct tty_port *port = &info->port; unsigned char data, status, flag; int fifo_count; int work = 0; @@ -913,7 +914,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) } else fifo_count = 32; - tty_buffer_request_room(tty, fifo_count); + tty_buffer_request_room(port, fifo_count); /* Flush received async data to receive data buffer. */ while (fifo_count) { data = read_reg(info, CHA + RXFIFO); diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index e2a945ee9f05..7093169ee0c9 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -878,6 +878,7 @@ isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue int isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) { + struct tty_port *port = tty->port; int count; int count_pull; int count_put; @@ -891,7 +892,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) return 0; - len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); + len = tty_buffer_request_room(port, dev->drv[di]->rcvcount[channel]); if (len == 0) return len; diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index e09dc8a5e743..4f5bcee7cf32 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -60,6 +60,7 @@ static int si2bit[8] = static int isdn_tty_try_read(modem_info *info, struct sk_buff *skb) { + struct tty_port *port = &info->port; int c; int len; struct tty_struct *tty; @@ -68,7 +69,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) if (!info->online) return 0; - tty = info->port.tty; + tty = port->tty; if (!tty) return 0; @@ -81,7 +82,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) #endif ; - c = tty_buffer_request_room(tty, len); + c = tty_buffer_request_room(port, len); if (c < len) return 0; @@ -2230,6 +2231,7 @@ void isdn_tty_at_cout(char *msg, modem_info *info) { struct tty_struct *tty; + struct tty_port *port = &info->port; atemu *m = &info->emu; char *p; char c; @@ -2246,15 +2248,15 @@ isdn_tty_at_cout(char *msg, modem_info *info) l = strlen(msg); spin_lock_irqsave(&info->readlock, flags); - tty = info->port.tty; - if ((info->port.flags & ASYNC_CLOSING) || (!tty)) { + tty = port->tty; + if ((port->flags & ASYNC_CLOSING) || (!tty)) { spin_unlock_irqrestore(&info->readlock, flags); return; } /* use queue instead of direct, if online and */ /* data is in queue or buffer is full */ - if (info->online && ((tty_buffer_request_room(tty, l) < l) || + if (info->online && ((tty_buffer_request_room(port, l) < l) || !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { skb = alloc_skb(l, GFP_ATOMIC); if (!skb) { diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 2d1bbfd5b67c..c0aeaaa094f1 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -211,7 +211,7 @@ static void dgrp_input(struct ch_struct *ch) data_len = (ch->ch_rin - ch->ch_rout) & RBUF_MASK; /* len is the amount of data we are going to transfer here */ - len = tty_buffer_request_room(tty, data_len); + len = tty_buffer_request_room(&ch->port, data_len); /* Check DPA flow control */ if ((nd->nd_dpa_debug) && @@ -2956,7 +2956,7 @@ check_query: I_BRKINT(ch->ch_tun.un_tty) && !(I_IGNBRK(ch->ch_tun.un_tty))) { - tty_buffer_request_room(ch->ch_tun.un_tty, 1); + tty_buffer_request_room(&ch->port, 1); tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); tty_flip_buffer_push(ch->ch_tun.un_tty); diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index b09c8d1f9a66..b85acc74eb0d 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -442,6 +442,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, { struct cyclades_port *info; struct tty_struct *tty; + struct tty_port *port; int len, index = cinfo->bus_index; u8 ivr, save_xir, channel, save_car, data, char_count; @@ -452,11 +453,12 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, save_xir = readb(base_addr + (CyRIR << index)); channel = save_xir & CyIRChannel; info = &cinfo->ports[channel + chip * 4]; + port = &info->port; save_car = cyy_readb(info, CyCAR); cyy_writeb(info, CyCAR, save_xir); ivr = cyy_readb(info, CyRIVR) & CyIVRMask; - tty = tty_port_tty_get(&info->port); + tty = tty_port_tty_get(port); /* if there is nowhere to put the data, discard it */ if (tty == NULL) { if (ivr == CyIVRRxEx) { /* exception */ @@ -487,14 +489,14 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, tty_kref_put(tty); return; } - if (tty_buffer_request_room(tty, 1)) { + if (tty_buffer_request_room(port, 1)) { if (data & info->read_status_mask) { if (data & CyBREAK) { tty_insert_flip_char(tty, cyy_readb(info, CyRDSR), TTY_BREAK); info->icount.rx++; - if (info->port.flags & ASYNC_SAK) + if (port->flags & ASYNC_SAK) do_SAK(tty); } else if (data & CyFRAME) { tty_insert_flip_char(tty, @@ -552,7 +554,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, info->mon.char_max = char_count; info->mon.char_last = char_count; #endif - len = tty_buffer_request_room(tty, char_count); + len = tty_buffer_request_room(port, char_count); while (len--) { data = cyy_readb(info, CyRDSR); tty_insert_flip_char(tty, data, TTY_NORMAL); @@ -928,6 +930,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) { struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; struct cyclades_card *cinfo = info->card; + struct tty_port *port = &info->port; unsigned int char_count; int len; #ifdef BLOCKMOVE @@ -983,7 +986,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) info->idle_stats.recv_bytes += len; } #else - len = tty_buffer_request_room(tty, char_count); + len = tty_buffer_request_room(port, char_count); while (len--) { data = readb(cinfo->base_addr + rx_bufaddr + new_rx_get); diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index c117d775a22f..af97e39d641c 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -386,7 +386,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) * read from the byte channel will be accepted by the TTY layer. */ ev_byte_channel_poll(bc->handle, &rx_count, &tx_count); - count = tty_buffer_request_room(ttys, rx_count); + count = tty_buffer_request_room(&bc->port, rx_count); /* 'count' is the maximum amount of data the TTY layer can accept at * this time. However, during testing, I was never able to get 'count' diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 13ee53bd0bf6..3d2ea92b8505 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -629,7 +629,7 @@ int hvc_poll(struct hvc_struct *hp) /* Read data if any */ for (;;) { - int count = tty_buffer_request_room(tty, N_INBUF); + int count = tty_buffer_request_room(&hp->port, N_INBUF); /* If flip is full, just reschedule a later read */ if (count == 0) { diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 877635733952..4a0ab98e9a63 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -609,7 +609,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd) /* remove the read masks */ hvcsd->todo_mask &= ~(HVCS_READ_MASK); - if (tty_buffer_request_room(tty, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { + if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { got = hvc_get_chars(unit_address, &buf[0], HVCS_BUFF_LEN); diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index ad0caf176808..42d5eb0125b3 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -245,7 +245,8 @@ static void cpm_uart_int_rx(struct uart_port *port) int i; unsigned char ch; u8 *cp; - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; cbd_t __iomem *bdp; u16 status; @@ -276,7 +277,7 @@ static void cpm_uart_int_rx(struct uart_port *port) /* If we have not enough room in tty flip buffer, then we try * later, which will be the next rx-interrupt or a timeout */ - if(tty_buffer_request_room(tty, i) < i) { + if (tty_buffer_request_room(tport, i) < i) { printk(KERN_WARNING "No room in flip buffer\n"); return; } diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index c4e30b841f94..710ce87ffbeb 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c @@ -2356,7 +2356,7 @@ static void receive_chars(struct uart_port *the_port) spin_lock_irqsave(&the_port->lock, pflags); tty = state->port.tty; - request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS); + request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS); if (request_count > 0) { icount = &the_port->icount; diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 4c00c5550b1a..3969e54744cc 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -521,6 +521,7 @@ void jsm_input(struct jsm_channel *ch) { struct jsm_board *bd; struct tty_struct *tp; + struct tty_port *port; u32 rmask; u16 head; u16 tail; @@ -536,7 +537,8 @@ void jsm_input(struct jsm_channel *ch) if (!ch) return; - tp = ch->uart_port.state->port.tty; + port = &ch->uart_port.state->port; + tp = port->tty; bd = ch->ch_bd; if(!bd) @@ -600,7 +602,7 @@ void jsm_input(struct jsm_channel *ch) return; } - len = tty_buffer_request_room(tp, data_len); + len = tty_buffer_request_room(port, data_len); n = len; /* diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c index 6a9c6605666a..50366863cfa3 100644 --- a/drivers/tty/serial/mpsc.c +++ b/drivers/tty/serial/mpsc.c @@ -937,7 +937,8 @@ static int serial_polled; static int mpsc_rx_intr(struct mpsc_port_info *pi) { struct mpsc_rx_desc *rxre; - struct tty_struct *tty = pi->port.state->port.tty; + struct tty_port *port = &pi->port.state->port; + struct tty_struct *tty = port->tty; u32 cmdstat, bytes_in, i; int rc = 0; u8 *bp; @@ -968,8 +969,7 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) } #endif /* Following use of tty struct directly is deprecated */ - if (unlikely(tty_buffer_request_room(tty, bytes_in) - < bytes_in)) { + if (tty_buffer_request_room(port, bytes_in) < bytes_in) { if (tty->low_latency) tty_flip_buffer_push(tty); /* diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index 58734d7e746d..776431ff0190 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c @@ -339,6 +339,7 @@ static int receive_chars(struct uart_max3110 *max, unsigned short *str, int len) { struct uart_port *port = &max->port; + struct tty_port *tport; struct tty_struct *tty; char buf[M3110_RX_FIFO_DEPTH]; int r, w, usable; @@ -347,7 +348,8 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) if (!port->state) return 0; - tty = tty_port_tty_get(&port->state->port); + tport = &port->state->port; + tty = tty_port_tty_get(tport); if (!tty) return 0; @@ -370,7 +372,7 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) } for (r = 0; w; r += usable, w -= usable) { - usable = tty_buffer_request_room(tty, w); + usable = tty_buffer_request_room(tport, w); if (usable) { tty_insert_flip_string(tty, buf + r, usable); port->icount.rx += usable; diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 8318925fbf6b..4f1774be2a8c 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -629,15 +629,16 @@ static int dma_push_rx(struct eg20t_port *priv, int size) struct tty_struct *tty; int room; struct uart_port *port = &priv->port; + struct tty_port *tport = &port->state->port; port = &priv->port; - tty = tty_port_tty_get(&port->state->port); + tty = tty_port_tty_get(tport); if (!tty) { dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); return 0; } - room = tty_buffer_request_room(tty, size); + room = tty_buffer_request_room(tport, size); if (room < size) dev_warn(port->dev, "Rx overrun: dropping %u bytes\n", diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 61477567423f..cf96314770fb 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -596,7 +596,8 @@ static void sci_transmit_chars(struct uart_port *port) static void sci_receive_chars(struct uart_port *port) { struct sci_port *sci_port = to_sci_port(port); - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; int i, count, copied = 0; unsigned short status; unsigned char flag; @@ -607,7 +608,7 @@ static void sci_receive_chars(struct uart_port *port) while (1) { /* Don't copy more bytes than there is room for in the buffer */ - count = tty_buffer_request_room(tty, sci_rxfill(port)); + count = tty_buffer_request_room(tport, sci_rxfill(port)); /* If for any reason we can't copy more data, we're done! */ if (count == 0) @@ -1263,9 +1264,10 @@ static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty, size_t count) { struct uart_port *port = &s->port; + struct tty_port *tport = &port->state->port; int i, active, room; - room = tty_buffer_request_room(tty, count); + room = tty_buffer_request_room(tport, count); if (s->active_rx == s->cookie_rx[0]) { active = 0; diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index f99b0c965f85..ed047d9ab1e2 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c @@ -469,7 +469,8 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) int i; unsigned char ch, *cp; struct uart_port *port = &qe_port->port; - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct qe_bd *bdp; u16 status; unsigned int flg; @@ -491,7 +492,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) /* If we don't have enough room in RX buffer for the entire BD, * then we try later, which will be the next RX interrupt. */ - if (tty_buffer_request_room(tty, i) < i) { + if (tty_buffer_request_room(tport, i) < i) { dev_dbg(port->dev, "ucc-uart: no room in RX buffer\n"); return; } diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 45d916198f78..f897332fb4ee 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -235,7 +235,7 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size) /** * tty_buffer_request_room - grow tty buffer if needed - * @tty: tty structure + * @port: tty port structure * @size: size desired * * Make at least size bytes of linear space available for the tty @@ -243,9 +243,8 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size) * * Locking: Takes port->buf.lock */ -int tty_buffer_request_room(struct tty_struct *tty, size_t size) +int tty_buffer_request_room(struct tty_port *port, size_t size) { - struct tty_port *port = tty->port; unsigned long flags; int length; diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index d152be97d041..1e67fd89e346 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -697,7 +697,7 @@ void qt2_process_read_urb(struct urb *urb) escapeflag = true; break; case QT2_CONTROL_ESCAPE: - tty_buffer_request_room(tty, 2); + tty_buffer_request_room(&port->port, 2); tty_insert_flip_string(tty, ch, 2); i += 2; escapeflag = true; @@ -713,7 +713,7 @@ void qt2_process_read_urb(struct urb *urb) } if (tty) { - tty_buffer_request_room(tty, 1); + tty_buffer_request_room(&port->port, 1); tty_insert_flip_string(tty, ch, 1); } } diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 2002344ed36a..78207ca8fab1 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -1,7 +1,7 @@ #ifndef _LINUX_TTY_FLIP_H #define _LINUX_TTY_FLIP_H -extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); +extern int tty_buffer_request_room(struct tty_port *port, size_t size); extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size); extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); -- cgit v1.2.3 From 2f69335710884ae6112fc8196ebe29b5cda7b79b Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:02 +0100 Subject: TTY: convert more flipping functions Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty pointer in many call sites. Only tty_port will be needed and hence no more tty_port_tty_get calls in those paths. Now 4 string flipping ones are on turn: * tty_insert_flip_string_flags * tty_insert_flip_string_fixed_flag * tty_prepare_flip_string * tty_prepare_flip_string_flags Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgrp/dgrp_net_ops.c | 2 +- drivers/staging/fwserial/fwserial.c | 8 +++++--- drivers/tty/cyclades.c | 2 +- drivers/tty/isicom.c | 4 ++-- drivers/tty/moxa.c | 4 ++-- drivers/tty/rocket.c | 2 +- drivers/tty/serial/msm_smd_tty.c | 2 +- drivers/tty/tty_buffer.c | 32 ++++++++++++++++---------------- drivers/usb/serial/ark3116.c | 2 +- drivers/usb/serial/belkin_sa.c | 2 +- drivers/usb/serial/cypress_m8.c | 2 +- drivers/usb/serial/digi_acceleport.c | 4 ++-- drivers/usb/serial/f81232.c | 2 +- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/pl2303.c | 2 +- drivers/usb/serial/spcp8x5.c | 2 +- drivers/usb/serial/ssu100.c | 2 +- include/linux/tty_flip.h | 16 ++++++++++------ 18 files changed, 49 insertions(+), 43 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index c0aeaaa094f1..df3ebcdf7ed8 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -232,7 +232,7 @@ static void dgrp_input(struct ch_struct *ch) (nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(tty))))) dgrp_dpa_data(nd, 1, myflipbuf, len); - tty_insert_flip_string_flags(tty, myflipbuf, + tty_insert_flip_string_flags(&ch->port, myflipbuf, myflipflagbuf, len); tty_flip_buffer_push(tty); diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 61ee29083b26..85dbdc1eccec 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -507,7 +507,8 @@ static void fwtty_emit_breaks(struct work_struct *work) while (n) { t = min(n, 16); - c = tty_insert_flip_string_fixed_flag(tty, buf, TTY_BREAK, t); + c = tty_insert_flip_string_fixed_flag(&port->port, buf, + TTY_BREAK, t); n -= c; brk += c; if (c < t) @@ -535,7 +536,7 @@ static void fwtty_pushrx(struct work_struct *work) spin_lock_bh(&port->lock); list_for_each_entry_safe(buf, next, &port->buf_list, list) { - n = tty_insert_flip_string_fixed_flag(tty, buf->data, + n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, TTY_NORMAL, buf->n); c += n; port->buffered -= n; @@ -630,7 +631,8 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) } if (!test_bit(BUFFERING_RX, &port->flags)) { - c = tty_insert_flip_string_fixed_flag(tty, data, TTY_NORMAL, n); + c = tty_insert_flip_string_fixed_flag(&port->port, data, + TTY_NORMAL, n); if (c > 0) tty_flip_buffer_push(tty); n -= c; diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index b85acc74eb0d..0b7573dbf439 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -968,7 +968,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) for performance, but because of buffer boundaries, there may be several steps to the operation */ while (1) { - len = tty_prepare_flip_string(tty, &buf, + len = tty_prepare_flip_string(port, &buf, char_count); if (!len) break; diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index 3205b2e9090b..e9fc15f00f48 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c @@ -650,8 +650,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) break; } } else { /* Data Packet */ - - count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); + count = tty_prepare_flip_string(&port->port, &rp, + byte_count & ~1); pr_debug("%s: Can rx %d of %d bytes.\n", __func__, count, byte_count); word_count = count >> 1; diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index f9d28503bdec..fcaac4870d5f 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -1966,7 +1966,7 @@ static int MoxaPortReadData(struct moxa_port *port) ofs = baseAddr + DynPage_addr + bufhead + head; len = (tail >= head) ? (tail - head) : (rx_mask + 1 - head); - len = tty_prepare_flip_string(tty, &dst, + len = tty_prepare_flip_string(&port->port, &dst, min(len, count)); memcpy_fromio(dst, ofs, len); head = (head + len) & rx_mask; @@ -1978,7 +1978,7 @@ static int MoxaPortReadData(struct moxa_port *port) while (count > 0) { writew(pageno, baseAddr + Control_reg); ofs = baseAddr + DynPage_addr + pageofs; - len = tty_prepare_flip_string(tty, &dst, + len = tty_prepare_flip_string(&port->port, &dst, min(Page_size - pageofs, count)); memcpy_fromio(dst, ofs, len); diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index e42009a00529..77d7bc94afaa 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -399,7 +399,7 @@ static void rp_do_receive(struct r_port *info, * characters at time by doing repeated word IO * transfer. */ - space = tty_prepare_flip_string(tty, &cbuf, ToRecv); + space = tty_prepare_flip_string(&info->port, &cbuf, ToRecv); if (space < ToRecv) { #ifdef ROCKET_DEBUG_RECEIVE printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space); diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c index 925d1fa153db..b43b4ec39269 100644 --- a/drivers/tty/serial/msm_smd_tty.c +++ b/drivers/tty/serial/msm_smd_tty.c @@ -70,7 +70,7 @@ static void smd_tty_notify(void *priv, unsigned event) if (avail == 0) break; - avail = tty_prepare_flip_string(tty, &ptr, avail); + avail = tty_prepare_flip_string(&info->port, &ptr, avail); if (smd_read(info->ch, ptr, avail) != avail) { /* shouldn't be possible since we're in interrupt diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index f897332fb4ee..31873e42602a 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -257,7 +257,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); /** * tty_insert_flip_string_fixed_flag - Add characters to the tty buffer - * @tty: tty structure + * @port: tty port * @chars: characters * @flag: flag value for each character * @size: size @@ -268,10 +268,10 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); * Locking: Called functions may take port->buf.lock */ -int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, +int tty_insert_flip_string_fixed_flag(struct tty_port *port, const unsigned char *chars, char flag, size_t size) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; int copied = 0; do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); @@ -280,7 +280,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, struct tty_buffer *tb; spin_lock_irqsave(&buf->lock, flags); - space = __tty_buffer_request_room(tty->port, goal); + space = __tty_buffer_request_room(port, goal); tb = buf->tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) { @@ -302,7 +302,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); /** * tty_insert_flip_string_flags - Add characters to the tty buffer - * @tty: tty structure + * @port: tty port * @chars: characters * @flags: flag bytes * @size: size @@ -314,10 +314,10 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); * Locking: Called functions may take port->buf.lock */ -int tty_insert_flip_string_flags(struct tty_struct *tty, +int tty_insert_flip_string_flags(struct tty_port *port, const unsigned char *chars, const char *flags, size_t size) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; int copied = 0; do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); @@ -326,7 +326,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, struct tty_buffer *tb; spin_lock_irqsave(&buf->lock, __flags); - space = __tty_buffer_request_room(tty->port, goal); + space = __tty_buffer_request_room(port, goal); tb = buf->tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) { @@ -376,7 +376,7 @@ EXPORT_SYMBOL(tty_schedule_flip); /** * tty_prepare_flip_string - make room for characters - * @tty: tty + * @port: tty port * @chars: return pointer for character write area * @size: desired size * @@ -389,16 +389,16 @@ EXPORT_SYMBOL(tty_schedule_flip); * Locking: May call functions taking port->buf.lock */ -int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, +int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, size_t size) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; int space; unsigned long flags; struct tty_buffer *tb; spin_lock_irqsave(&buf->lock, flags); - space = __tty_buffer_request_room(tty->port, size); + space = __tty_buffer_request_room(port, size); tb = buf->tail; if (likely(space)) { @@ -413,7 +413,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); /** * tty_prepare_flip_string_flags - make room for characters - * @tty: tty + * @port: tty port * @chars: return pointer for character write area * @flags: return pointer for status flag write area * @size: desired size @@ -427,16 +427,16 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); * Locking: May call functions taking port->buf.lock */ -int tty_prepare_flip_string_flags(struct tty_struct *tty, +int tty_prepare_flip_string_flags(struct tty_port *port, unsigned char **chars, char **flags, size_t size) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; int space; unsigned long __flags; struct tty_buffer *tb; spin_lock_irqsave(&buf->lock, __flags); - space = __tty_buffer_request_room(tty->port, size); + space = __tty_buffer_request_room(port, size); tb = buf->tail; if (likely(space)) { diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index a88882c0e237..e2d653d00ea2 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -705,7 +705,7 @@ static void ark3116_process_read_urb(struct urb *urb) if (lsr & UART_LSR_OE) tty_insert_flip_char(tty, 0, TTY_OVERRUN); } - tty_insert_flip_string_fixed_flag(tty, data, tty_flag, + tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); tty_flip_buffer_push(tty); tty_kref_put(tty); diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index b72a4c166705..a213d1be9462 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -279,7 +279,7 @@ static void belkin_sa_process_read_urb(struct urb *urb) tty_insert_flip_char(tty, 0, TTY_OVERRUN); } - tty_insert_flip_string_fixed_flag(tty, data, tty_flag, + tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); tty_flip_buffer_push(tty); tty_kref_put(tty); diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index fd8c35fd452e..ac14e3eb95ea 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -1215,7 +1215,7 @@ static void cypress_read_int_callback(struct urb *urb) /* process read if there is data other than line status */ if (tty && bytes > i) { - tty_insert_flip_string_fixed_flag(tty, data + i, + tty_insert_flip_string_fixed_flag(&port->port, data + i, tty_flag, bytes - i); tty_flip_buffer_push(tty); } diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 45d4af62967f..efbc4035410c 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -1455,8 +1455,8 @@ static int digi_read_inb_callback(struct urb *urb) /* data length is len-1 (one byte of len is port_status) */ --len; if (len > 0) { - tty_insert_flip_string_fixed_flag(tty, data, flag, - len); + tty_insert_flip_string_fixed_flag(&port->port, data, + flag, len); tty_flip_buffer_push(tty); } } diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 6e4eb57d0177..a8c6430bf1b3 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -140,7 +140,7 @@ static void f81232_process_read_urb(struct urb *urb) if (!usb_serial_handle_sysrq_char(port, data[i])) tty_insert_flip_char(tty, data[i], tty_flag); } else { - tty_insert_flip_string_fixed_flag(tty, data, tty_flag, + tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 0a373b3ae96a..0416d952a448 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2032,7 +2032,7 @@ static int ftdi_process_packet(struct tty_struct *tty, tty_insert_flip_char(tty, *ch, flag); } } else { - tty_insert_flip_string_fixed_flag(tty, ch, flag, len); + tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); } return len; diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 600241901361..86789b0477c5 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -812,7 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb) if (!usb_serial_handle_sysrq_char(port, data[i])) tty_insert_flip_char(tty, data[i], tty_flag); } else { - tty_insert_flip_string_fixed_flag(tty, data, tty_flag, + tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); } diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index a42536af1256..fa42f1b907d0 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -505,7 +505,7 @@ static void spcp8x5_process_read_urb(struct urb *urb) priv->line_status & MSR_STATUS_LINE_DCD); } - tty_insert_flip_string_fixed_flag(tty, data, tty_flag, + tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); tty_flip_buffer_push(tty); tty_kref_put(tty); diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 4543ea350229..37476c6240c2 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -617,7 +617,7 @@ static int ssu100_process_packet(struct urb *urb, tty_insert_flip_char(tty, *ch, flag); } } else - tty_insert_flip_string_fixed_flag(tty, ch, flag, len); + tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); return len; } diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 78207ca8fab1..743f1d076467 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -2,10 +2,14 @@ #define _LINUX_TTY_FLIP_H extern int tty_buffer_request_room(struct tty_port *port, size_t size); -extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); -extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size); -extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); -extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); +extern int tty_insert_flip_string_flags(struct tty_port *port, + const unsigned char *chars, const char *flags, size_t size); +extern int tty_insert_flip_string_fixed_flag(struct tty_port *port, + const unsigned char *chars, char flag, size_t size); +extern int tty_prepare_flip_string(struct tty_port *port, + unsigned char **chars, size_t size); +extern int tty_prepare_flip_string_flags(struct tty_port *port, + unsigned char **chars, char **flags, size_t size); void tty_schedule_flip(struct tty_struct *tty); static inline int tty_insert_flip_char(struct tty_struct *tty, @@ -17,12 +21,12 @@ static inline int tty_insert_flip_char(struct tty_struct *tty, tb->char_buf_ptr[tb->used++] = ch; return 1; } - return tty_insert_flip_string_flags(tty, &ch, &flag, 1); + return tty_insert_flip_string_flags(tty->port, &ch, &flag, 1); } static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) { - return tty_insert_flip_string_fixed_flag(tty, chars, TTY_NORMAL, size); + return tty_insert_flip_string_fixed_flag(tty->port, chars, TTY_NORMAL, size); } #endif /* _LINUX_TTY_FLIP_H */ -- cgit v1.2.3 From 92a19f9cec9a80ad93c06e115822deb729e2c6ad Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:03 +0100 Subject: TTY: switch tty_insert_flip_char Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. tty_insert_flip_char is the next one to proceed. This one is used all over the code, so the patch is huge. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/srmcons.c | 3 ++- arch/ia64/hp/sim/simserial.c | 3 ++- arch/mn10300/kernel/mn10300-serial.c | 4 +-- arch/parisc/kernel/pdc_cons.c | 2 +- arch/um/drivers/chan_kern.c | 8 +----- arch/xtensa/platforms/iss/console.c | 3 ++- drivers/char/pcmcia/synclink_cs.c | 2 +- drivers/ipack/devices/ipoctal.c | 5 ++-- drivers/isdn/i4l/isdn_common.c | 8 +++--- drivers/isdn/i4l/isdn_tty.c | 12 ++++----- drivers/mmc/card/sdio_uart.c | 5 ++-- drivers/s390/char/con3215.c | 3 ++- drivers/s390/char/keyboard.h | 4 +-- drivers/s390/char/sclp_tty.c | 4 +-- drivers/staging/dgrp/dgrp_net_ops.c | 2 +- drivers/staging/fwserial/fwserial.c | 2 +- drivers/staging/serqt_usb2/serqt_usb2.c | 13 +++++---- drivers/tty/amiserial.c | 4 +-- drivers/tty/cyclades.c | 24 ++++++++--------- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvsi.c | 22 +++++++-------- drivers/tty/isicom.c | 4 +-- drivers/tty/moxa.c | 2 +- drivers/tty/mxser.c | 4 +-- drivers/tty/n_gsm.c | 24 ++++++++++------- drivers/tty/nozomi.c | 2 +- drivers/tty/rocket.c | 3 ++- drivers/tty/serial/68328serial.c | 2 +- drivers/tty/serial/ar933x_uart.c | 10 +++---- drivers/tty/serial/bcm63xx_uart.c | 7 ++--- drivers/tty/serial/bfin_sport_uart.c | 10 ++++--- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +- drivers/tty/serial/crisv10.c | 10 +++---- drivers/tty/serial/efm32-uart.c | 15 +++++------ drivers/tty/serial/icom.c | 7 ++--- drivers/tty/serial/imx.c | 4 ++- drivers/tty/serial/jsm/jsm_tty.c | 8 +++--- drivers/tty/serial/kgdb_nmi.c | 2 +- drivers/tty/serial/lantiq.c | 7 ++--- drivers/tty/serial/lpc32xx_hs.c | 12 +++++---- drivers/tty/serial/m32r_sio.c | 7 ++--- drivers/tty/serial/mpc52xx_uart.c | 7 ++--- drivers/tty/serial/mpsc.c | 4 +-- drivers/tty/serial/msm_serial.c | 12 +++++---- drivers/tty/serial/msm_serial_hs.c | 12 ++++----- drivers/tty/serial/mux.c | 5 ++-- drivers/tty/serial/nwpserial.c | 5 ++-- drivers/tty/serial/pmac_zilog.c | 8 +++--- drivers/tty/serial/sc26xx.c | 10 ++++--- drivers/tty/serial/serial_core.c | 6 ++--- drivers/tty/serial/sh-sci.c | 34 ++++++++++++----------- drivers/tty/serial/sn_console.c | 6 +++-- drivers/tty/serial/sunhv.c | 4 +-- drivers/tty/serial/sunsab.c | 16 +++++------ drivers/tty/serial/sunsu.c | 7 ++--- drivers/tty/serial/sunzilog.c | 17 +++++------- drivers/tty/serial/timbuart.c | 4 +-- drivers/tty/serial/uartlite.c | 8 +++--- drivers/tty/serial/ucc_uart.c | 4 +-- drivers/tty/serial/vt8500_serial.c | 7 ++--- drivers/tty/synclink.c | 4 +-- drivers/tty/synclink_gt.c | 8 +++--- drivers/tty/synclinkmp.c | 42 +++++++++++++---------------- drivers/tty/vt/keyboard.c | 6 ++--- drivers/tty/vt/vt.c | 2 +- drivers/usb/serial/ark3116.c | 2 +- drivers/usb/serial/belkin_sa.c | 2 +- drivers/usb/serial/digi_acceleport.c | 2 +- drivers/usb/serial/f81232.c | 5 ++-- drivers/usb/serial/ftdi_sio.c | 11 ++++---- drivers/usb/serial/generic.c | 2 +- drivers/usb/serial/keyspan.c | 21 ++++++++------- drivers/usb/serial/pl2303.c | 5 ++-- drivers/usb/serial/spcp8x5.c | 2 +- drivers/usb/serial/ssu100.c | 10 +++---- include/linux/tty_flip.h | 6 ++--- 76 files changed, 297 insertions(+), 286 deletions(-) (limited to 'drivers') diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 59b7bbad8394..21b57a66e809 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -46,13 +46,14 @@ typedef union _srmcons_result { static int srmcons_do_receive_chars(struct tty_struct *tty) { + struct tty_port *port = tty->port; srmcons_result result; int count = 0, loops = 0; do { result.as_long = callback_getc(0); if (result.bits.status < 2) { - tty_insert_flip_char(tty, (char)result.bits.c, 0); + tty_insert_flip_char(port, (char)result.bits.c, 0); count++; } } while((result.bits.status & 1) && (++loops < 10)); diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index fc3924d18c1f..f8ae5d8eb106 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -55,6 +55,7 @@ static struct console *console; static void receive_chars(struct tty_struct *tty) { + struct tty_port *port = tty->port; unsigned char ch; static unsigned char seen_esc = 0; @@ -81,7 +82,7 @@ static void receive_chars(struct tty_struct *tty) } seen_esc = 0; - if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) + if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) break; } tty_flip_buffer_push(tty); diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index 9b2232a78ff9..54ef40ceaaed 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -667,14 +667,14 @@ insert: else flag = TTY_NORMAL; - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); } /* overrun is special, since it's reported immediately, and doesn't * affect the current character */ if (overrun) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); count--; if (count <= 0) { diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index efc5e7d30530..4d92a379eb21 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c @@ -147,7 +147,7 @@ static void pdc_console_poll(unsigned long unused) data = pdc_console_poll_key(NULL); if (data == -1) break; - tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); + tty_insert_flip_char(&tty_port, data & 0xFF, TTY_NORMAL); count ++; } diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 4ff2503a1bb8..795bd8102205 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -81,12 +81,6 @@ static const struct chan_ops not_configged_ops = { }; #endif /* CONFIG_NOCONFIG_CHAN */ -static void tty_receive_char(struct tty_struct *tty, char ch) -{ - if (tty) - tty_insert_flip_char(tty, ch, TTY_NORMAL); -} - static int open_one_chan(struct chan *chan) { int fd, err; @@ -569,7 +563,7 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) } err = chan->ops->read(chan->fd, &c, chan->data); if (err > 0) - tty_receive_char(tty, c); + tty_insert_flip_char(port, c, TTY_NORMAL); } while (err > 0); if (err == 0) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 8207a119eee9..62447d63890c 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -98,6 +98,7 @@ static int rs_write(struct tty_struct * tty, static void rs_poll(unsigned long priv) { struct tty_struct* tty = (struct tty_struct*) priv; + struct tty_port *port = tty->port; struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; int i = 0; @@ -107,7 +108,7 @@ static void rs_poll(unsigned long priv) while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){ __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0); - tty_insert_flip_char(tty, c, TTY_NORMAL); + tty_insert_flip_char(port, c, TTY_NORMAL); i++; } diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 0b1de715f097..9bdfe27b2413 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -945,7 +945,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) else if (status & BIT6) flag = TTY_FRAME; } - work += tty_insert_flip_char(tty, data, flag); + work += tty_insert_flip_char(port, data, flag); } issue_command(info, CHA, CMD_RXFIFO); diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 576d53d92677..8e0ed663ba9b 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -136,6 +136,7 @@ static int ipoctal_get_icount(struct tty_struct *tty, static void ipoctal_irq_rx(struct ipoctal_channel *channel, struct tty_struct *tty, u8 sr) { + struct tty_port *port = &channel->tty_port; unsigned char value; unsigned char flag = TTY_NORMAL; u8 isr; @@ -149,7 +150,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, if (sr & SR_OVERRUN_ERROR) { channel->stats.overrun_err++; /* Overrun doesn't affect the current character*/ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); } if (sr & SR_PARITY_ERROR) { channel->stats.parity_err++; @@ -165,7 +166,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, flag = TTY_BREAK; } } - tty_insert_flip_char(tty, value, flag); + tty_insert_flip_char(port, value, flag); /* Check if there are more characters in RX FIFO * If there are more, the isr register for this channel diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 7093169ee0c9..4a387ec021ad 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -913,7 +913,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) while ((count_pull < skb->len) && (len > 0)) { /* push every character but the last to the tty buffer directly */ if (count_put) - tty_insert_flip_char(tty, last, TTY_NORMAL); + tty_insert_flip_char(port, last, TTY_NORMAL); len--; if (dev->drv[di]->DLEflag & DLEmask) { last = DLE; @@ -953,16 +953,16 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) * Now we can dequeue it. */ if (cisco_hack) - tty_insert_flip_char(tty, last, 0xFF); + tty_insert_flip_char(port, last, 0xFF); else - tty_insert_flip_char(tty, last, TTY_NORMAL); + tty_insert_flip_char(port, last, TTY_NORMAL); #ifdef CONFIG_ISDN_AUDIO ISDN_AUDIO_SKB_LOCK(skb) = 0; #endif skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]); dev_kfree_skb(skb); } else { - tty_insert_flip_char(tty, last, TTY_NORMAL); + tty_insert_flip_char(port, last, TTY_NORMAL); /* Not yet emptied this buff, so it * must stay in the queue, for further calls * but we pull off the data we got until now. diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 4f5bcee7cf32..32d65d4bc848 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -92,11 +92,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) unsigned char *dp = skb->data; while (--l) { if (*dp == DLE) - tty_insert_flip_char(tty, DLE, 0); - tty_insert_flip_char(tty, *dp++, 0); + tty_insert_flip_char(port, DLE, 0); + tty_insert_flip_char(port, *dp++, 0); } if (*dp == DLE) - tty_insert_flip_char(tty, DLE, 0); + tty_insert_flip_char(port, DLE, 0); last = *dp; } else { #endif @@ -107,9 +107,9 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) } #endif if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) - tty_insert_flip_char(tty, last, 0xFF); + tty_insert_flip_char(port, last, 0xFF); else - tty_insert_flip_char(tty, last, TTY_NORMAL); + tty_insert_flip_char(port, last, TTY_NORMAL); tty_flip_buffer_push(tty); kfree_skb(skb); @@ -2287,7 +2287,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) if (skb) { *sp++ = c; } else { - if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) + if (tty_insert_flip_char(port, c, TTY_NORMAL) == 0) break; } } diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index bd57a11acc79..894078be0b96 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c @@ -419,7 +419,7 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) if (tty) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(&port->port, ch, flag); /* * Overrun is special. Since it's reported immediately, @@ -427,7 +427,8 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, */ if (*status & ~port->ignore_status_mask & UART_LSR_OE) if (tty) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, + TTY_OVERRUN); *status = sdio_in(port, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 40084501c31b..7c7294590880 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -411,7 +411,8 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, break; case CTRLCHAR_CTRL: - tty_insert_flip_char(tty, cchar, TTY_NORMAL); + tty_insert_flip_char(&raw->port, cchar, + TTY_NORMAL); tty_flip_buffer_push(tty); break; diff --git a/drivers/s390/char/keyboard.h b/drivers/s390/char/keyboard.h index d0ae2be58191..acab28d4f06b 100644 --- a/drivers/s390/char/keyboard.h +++ b/drivers/s390/char/keyboard.h @@ -46,7 +46,7 @@ kbd_put_queue(struct tty_port *port, int ch) struct tty_struct *tty = tty_port_tty_get(port); if (!tty) return; - tty_insert_flip_char(tty, ch, 0); + tty_insert_flip_char(port, ch, 0); tty_schedule_flip(tty); tty_kref_put(tty); } @@ -58,7 +58,7 @@ kbd_puts_queue(struct tty_port *port, char *cp) if (!tty) return; while (*cp) - tty_insert_flip_char(tty, *cp++, 0); + tty_insert_flip_char(port, *cp++, 0); tty_schedule_flip(tty); tty_kref_put(tty); } diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 877fbc37c1e7..c03863a7d455 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -342,7 +342,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) case CTRLCHAR_SYSRQ: break; case CTRLCHAR_CTRL: - tty_insert_flip_char(tty, cchar, TTY_NORMAL); + tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); tty_flip_buffer_push(tty); break; case CTRLCHAR_NONE: @@ -352,7 +352,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) strncmp((const char *) buf + count - 2, "\252n", 2))) { /* add the auto \n */ tty_insert_flip_string(tty, buf, count); - tty_insert_flip_char(tty, '\n', TTY_NORMAL); + tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); } else tty_insert_flip_string(tty, buf, count - 2); tty_flip_buffer_push(tty); diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index df3ebcdf7ed8..e618a667d84c 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -2957,7 +2957,7 @@ check_query: !(I_IGNBRK(ch->ch_tun.un_tty))) { tty_buffer_request_room(&ch->port, 1); - tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); + tty_insert_flip_char(&ch->port, 0, TTY_BREAK); tty_flip_buffer_push(ch->ch_tun.un_tty); } diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 85dbdc1eccec..a2a0c43dec1c 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -617,7 +617,7 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) lsr &= port->status_mask; if (lsr & ~port->ignore_mask & UART_LSR_OE) { - if (!tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { + if (!tty_insert_flip_char(&port->port, 0, TTY_OVERRUN)) { err = -EIO; goto out; } diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 1b3e995d3a27..14965662d09c 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -255,12 +255,11 @@ static void ProcessModemStatus(struct quatech_port *qt_port, wake_up_interruptible(&qt_port->wait); } -static void ProcessRxChar(struct tty_struct *tty, struct usb_serial_port *port, - unsigned char data) +static void ProcessRxChar(struct usb_serial_port *port, unsigned char data) { struct urb *urb = port->read_urb; if (urb->actual_length) - tty_insert_flip_char(tty, data, TTY_NORMAL); + tty_insert_flip_char(&port->port, data, TTY_NORMAL); } static void qt_write_bulk_callback(struct urb *urb) @@ -335,8 +334,8 @@ static void qt_status_change_check(struct tty_struct *tty, case 0xff: dev_dbg(&port->dev, "No status sequence.\n"); - ProcessRxChar(tty, port, data[i]); - ProcessRxChar(tty, port, data[i + 1]); + ProcessRxChar(port, data[i]); + ProcessRxChar(port, data[i + 1]); i += 2; break; @@ -345,8 +344,8 @@ static void qt_status_change_check(struct tty_struct *tty, continue; } - if (tty && urb->actual_length) - tty_insert_flip_char(tty, data[i], TTY_NORMAL); + if (urb->actual_length) + tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); } tty_flip_buffer_push(tty); diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 9d7d00cdfecb..2e670d0c5366 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -328,9 +328,9 @@ static void receive_chars(struct serial_state *info) oe = 1; } } - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(&info->tport, ch, flag); if (oe == 1) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); tty_flip_buffer_push(tty); out: return; diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index 0b7573dbf439..d1fe9a1f8475 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -492,34 +492,34 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, if (tty_buffer_request_room(port, 1)) { if (data & info->read_status_mask) { if (data & CyBREAK) { - tty_insert_flip_char(tty, + tty_insert_flip_char(port, cyy_readb(info, CyRDSR), TTY_BREAK); info->icount.rx++; if (port->flags & ASYNC_SAK) do_SAK(tty); } else if (data & CyFRAME) { - tty_insert_flip_char(tty, + tty_insert_flip_char(port, cyy_readb(info, CyRDSR), TTY_FRAME); info->icount.rx++; info->idle_stats.frame_errs++; } else if (data & CyPARITY) { /* Pieces of seven... */ - tty_insert_flip_char(tty, + tty_insert_flip_char(port, cyy_readb(info, CyRDSR), TTY_PARITY); info->icount.rx++; info->idle_stats.parity_errs++; } else if (data & CyOVERRUN) { - tty_insert_flip_char(tty, 0, + tty_insert_flip_char(port, 0, TTY_OVERRUN); info->icount.rx++; /* If the flip buffer itself is overflowing, we still lose the next incoming character. */ - tty_insert_flip_char(tty, + tty_insert_flip_char(port, cyy_readb(info, CyRDSR), TTY_FRAME); info->icount.rx++; @@ -529,12 +529,12 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, /* } else if(data & CyTIMEOUT) { */ /* } else if(data & CySPECHAR) { */ } else { - tty_insert_flip_char(tty, 0, + tty_insert_flip_char(port, 0, TTY_NORMAL); info->icount.rx++; } } else { - tty_insert_flip_char(tty, 0, TTY_NORMAL); + tty_insert_flip_char(port, 0, TTY_NORMAL); info->icount.rx++; } } else { @@ -557,7 +557,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, len = tty_buffer_request_room(port, char_count); while (len--) { data = cyy_readb(info, CyRDSR); - tty_insert_flip_char(tty, data, TTY_NORMAL); + tty_insert_flip_char(port, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; #ifdef CY_16Y_HACK @@ -992,7 +992,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) new_rx_get); new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1); - tty_insert_flip_char(tty, data, TTY_NORMAL); + tty_insert_flip_char(port, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; } @@ -1117,17 +1117,17 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) switch (cmd) { case C_CM_PR_ERROR: - tty_insert_flip_char(tty, 0, TTY_PARITY); + tty_insert_flip_char(&info->port, 0, TTY_PARITY); info->icount.rx++; special_count++; break; case C_CM_FR_ERROR: - tty_insert_flip_char(tty, 0, TTY_FRAME); + tty_insert_flip_char(&info->port, 0, TTY_FRAME); info->icount.rx++; special_count++; break; case C_CM_RXBRK: - tty_insert_flip_char(tty, 0, TTY_BREAK); + tty_insert_flip_char(&info->port, 0, TTY_BREAK); info->icount.rx++; special_count++; break; diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 3d2ea92b8505..8c2fe3a0e091 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -672,7 +672,7 @@ int hvc_poll(struct hvc_struct *hp) } } #endif /* CONFIG_MAGIC_SYSRQ */ - tty_insert_flip_char(tty, buf[i], 0); + tty_insert_flip_char(&hp->port, buf[i], 0); } read_total += n; diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 68357a6e4de9..1f528b8ebf5f 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -329,8 +329,7 @@ static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet) } } -static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty, - const char *buf, int len) +static void hvsi_insert_chars(struct hvsi_struct *hp, const char *buf, int len) { int i; @@ -346,7 +345,7 @@ static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty, continue; } #endif /* CONFIG_MAGIC_SYSRQ */ - tty_insert_flip_char(tty, c, 0); + tty_insert_flip_char(&hp->port, c, 0); } } @@ -359,8 +358,7 @@ static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty, * revisited. */ #define TTY_THRESHOLD_THROTTLE 128 -static bool hvsi_recv_data(struct hvsi_struct *hp, struct tty_struct *tty, - const uint8_t *packet) +static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet) { const struct hvsi_header *header = (const struct hvsi_header *)packet; const uint8_t *data = packet + sizeof(struct hvsi_header); @@ -377,7 +375,7 @@ static bool hvsi_recv_data(struct hvsi_struct *hp, struct tty_struct *tty, datalen = TTY_THRESHOLD_THROTTLE; } - hvsi_insert_chars(hp, tty, data, datalen); + hvsi_insert_chars(hp, data, datalen); if (overflow > 0) { /* @@ -438,9 +436,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, case VS_DATA_PACKET_HEADER: if (!is_open(hp)) break; - if (tty == NULL) - break; /* no tty buffer to put data in */ - flip = hvsi_recv_data(hp, tty, packet); + flip = hvsi_recv_data(hp, packet); break; case VS_CONTROL_PACKET_HEADER: hvsi_recv_control(hp, packet, tty, handshake); @@ -474,12 +470,12 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, return 1; } -static void hvsi_send_overflow(struct hvsi_struct *hp, struct tty_struct *tty) +static void hvsi_send_overflow(struct hvsi_struct *hp) { pr_debug("%s: delivering %i bytes overflow\n", __func__, hp->n_throttle); - hvsi_insert_chars(hp, tty, hp->throttle_buf, hp->n_throttle); + hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle); hp->n_throttle = 0; } @@ -514,7 +510,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg) if (tty && hp->n_throttle && !test_bit(TTY_THROTTLED, &tty->flags)) { /* we weren't hung up and we weren't throttled, so we can * deliver the rest now */ - hvsi_send_overflow(hp, tty); + hvsi_send_overflow(hp); tty_flip_buffer_push(tty); } spin_unlock_irqrestore(&hp->lock, flags); @@ -1001,7 +997,7 @@ static void hvsi_unthrottle(struct tty_struct *tty) spin_lock_irqsave(&hp->lock, flags); if (hp->n_throttle) { - hvsi_send_overflow(hp, tty); + hvsi_send_overflow(hp); tty_flip_buffer_push(tty); } spin_unlock_irqrestore(&hp->lock, flags); diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index e9fc15f00f48..c70144f55fc0 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c @@ -634,7 +634,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) break; case 1: /* Received Break !!! */ - tty_insert_flip_char(tty, 0, TTY_BREAK); + tty_insert_flip_char(&port->port, 0, TTY_BREAK); if (port->port.flags & ASYNC_SAK) do_SAK(tty); tty_flip_buffer_push(tty); @@ -658,7 +658,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) insw(base, rp, word_count); byte_count -= (word_count << 1); if (count & 0x0001) { - tty_insert_flip_char(tty, inw(base) & 0xff, + tty_insert_flip_char(&port->port, inw(base) & 0xff, TTY_NORMAL); byte_count -= 2; } diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index fcaac4870d5f..f42492db31c9 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -1429,7 +1429,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle, goto put; if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ - tty_insert_flip_char(tty, 0, TTY_BREAK); + tty_insert_flip_char(&p->port, 0, TTY_BREAK); tty_schedule_flip(tty); } diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 40113868bec2..450c4507cb5b 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -2079,7 +2079,7 @@ static void mxser_receive_chars(struct tty_struct *tty, } while (gdl--) { ch = inb(port->ioaddr + UART_RX); - tty_insert_flip_char(tty, ch, 0); + tty_insert_flip_char(&port->port, ch, 0); cnt++; } goto end_intr; @@ -2118,7 +2118,7 @@ intr_old: } else flag = TTY_BREAK; } - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(&port->port, ch, flag); cnt++; if (cnt >= recv_room) { if (!port->ldisc_stop_rx) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 4572117988f8..769016504c88 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1070,9 +1070,9 @@ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci, if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD)) if (!(tty->termios.c_cflag & CLOCAL)) tty_hangup(tty); - if (brk & 0x01) - tty_insert_flip_char(tty, 0, TTY_BREAK); } + if (brk & 0x01) + tty_insert_flip_char(&dlci->port, 0, TTY_BREAK); dlci->modem_rx = mlines; } @@ -1140,6 +1140,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) { + struct tty_port *port; struct tty_struct *tty; unsigned int addr = 0 ; u8 bits; @@ -1163,16 +1164,19 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) bits = *dp; if ((bits & 1) == 0) return; - /* See if we have an uplink tty */ - tty = tty_port_tty_get(&gsm->dlci[addr]->port); + port = &gsm->dlci[addr]->port; + + if (bits & 2) + tty_insert_flip_char(port, 0, TTY_OVERRUN); + if (bits & 4) + tty_insert_flip_char(port, 0, TTY_PARITY); + if (bits & 8) + tty_insert_flip_char(port, 0, TTY_FRAME); + + /* See if we have an uplink tty */ + tty = tty_port_tty_get(port); if (tty) { - if (bits & 2) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); - if (bits & 4) - tty_insert_flip_char(tty, 0, TTY_PARITY); - if (bits & 8) - tty_insert_flip_char(tty, 0, TTY_FRAME); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index a0c69ab04399..437a6366fb7b 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -855,7 +855,7 @@ static int receive_data(enum port_type index, struct nozomi *dc) read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX); if (size == 1) { - tty_insert_flip_char(tty, buf[0], TTY_NORMAL); + tty_insert_flip_char(&port->port, buf[0], TTY_NORMAL); size = 0; } else if (size < RECEIVE_BUF_MAX) { size -= tty_insert_flip_string(tty, (char *) buf, size); diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 77d7bc94afaa..5848a767001a 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -379,7 +379,8 @@ static void rp_do_receive(struct r_port *info, flag = TTY_OVERRUN; else flag = TTY_NORMAL; - tty_insert_flip_char(tty, CharNStat & 0xff, flag); + tty_insert_flip_char(&info->port, CharNStat & 0xff, + flag); ToRecv--; } diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index f99a84526f82..3719273cf0be 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c @@ -305,7 +305,7 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, else if (rx & URX_FRAME_ERROR) flag = TTY_FRAME; - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(&info->tport, ch, flag); #ifndef CONFIG_XCOPILOT_BUGS } while((rx = uart->urx.w) & URX_DATA_READY); #endif diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index 505c490c0b44..6ca5dd615f9e 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -297,10 +297,11 @@ static void ar933x_uart_set_termios(struct uart_port *port, static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) { + struct tty_port *port = &up->port.state->port; struct tty_struct *tty; int max_count = 256; - tty = tty_port_tty_get(&up->port.state->port); + tty = tty_port_tty_get(port); do { unsigned int rdata; unsigned char ch; @@ -313,11 +314,6 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) ar933x_uart_write(up, AR933X_UART_DATA_REG, AR933X_UART_DATA_RX_CSR); - if (!tty) { - /* discard the data if no tty available */ - continue; - } - up->port.icount.rx++; ch = rdata & AR933X_UART_DATA_TX_RX_MASK; @@ -325,7 +321,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) continue; if ((up->port.ignore_status_mask & AR933X_DUMMY_STATUS_RD) == 0) - tty_insert_flip_char(tty, ch, TTY_NORMAL); + tty_insert_flip_char(port, ch, TTY_NORMAL); } while (max_count-- > 0); if (tty) { diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index c76a226080f2..de30b1909728 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c @@ -235,6 +235,7 @@ static const char *bcm_uart_type(struct uart_port *port) */ static void bcm_uart_do_rx(struct uart_port *port) { + struct tty_port *port = &port->state->port; struct tty_struct *tty; unsigned int max_count; @@ -242,7 +243,7 @@ static void bcm_uart_do_rx(struct uart_port *port) * higher than fifo size anyway since we're much faster than * serial port */ max_count = 32; - tty = port->state->port.tty; + tty = port->tty; do { unsigned int iestat, c, cstat; char flag; @@ -261,7 +262,7 @@ static void bcm_uart_do_rx(struct uart_port *port) bcm_uart_writel(port, val, UART_CTL_REG); port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); } if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY))) @@ -300,7 +301,7 @@ static void bcm_uart_do_rx(struct uart_port *port) if ((cstat & port->ignore_status_mask) == 0) - tty_insert_flip_char(tty, c, flag); + tty_insert_flip_char(port, c, flag); } while (--max_count); diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c index f5d117379b60..e4d3ac2e8992 100644 --- a/drivers/tty/serial/bfin_sport_uart.c +++ b/drivers/tty/serial/bfin_sport_uart.c @@ -149,7 +149,8 @@ static int sport_uart_setup(struct sport_uart_port *up, int size, int baud_rate) static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) { struct sport_uart_port *up = dev_id; - struct tty_struct *tty = up->port.state->port.tty; + struct tty_port *port = &up->port.state->port; + struct tty_struct *tty = tport->tty; unsigned int ch; spin_lock(&up->port.lock); @@ -159,7 +160,7 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) up->port.icount.rx++; if (!uart_handle_sysrq_char(&up->port, ch)) - tty_insert_flip_char(tty, ch, TTY_NORMAL); + tty_insert_flip_char(port, ch, TTY_NORMAL); } tty_flip_buffer_push(tty); @@ -182,7 +183,6 @@ static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id) static irqreturn_t sport_uart_err_irq(int irq, void *dev_id) { struct sport_uart_port *up = dev_id; - struct tty_struct *tty = up->port.state->port.tty; unsigned int stat = SPORT_GET_STAT(up); spin_lock(&up->port.lock); @@ -190,7 +190,7 @@ static irqreturn_t sport_uart_err_irq(int irq, void *dev_id) /* Overflow in RX FIFO */ if (stat & ROVF) { up->port.icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&up->port.state->port, 0, TTY_OVERRUN); SPORT_PUT_STAT(up, ROVF); /* Clear ROVF bit */ } /* These should not happen */ @@ -205,6 +205,8 @@ static irqreturn_t sport_uart_err_irq(int irq, void *dev_id) SSYNC(); spin_unlock(&up->port.lock); + /* XXX we don't push the overrun bit to TTY? */ + return IRQ_HANDLED; } diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 42d5eb0125b3..108122f8f3c2 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -303,7 +303,7 @@ static void cpm_uart_int_rx(struct uart_port *port) } #endif error_return: - tty_insert_flip_char(tty, ch, flg); + tty_insert_flip_char(tport, ch, flg); } /* End while (i--) */ diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 35ee6a2c6877..d12306625458 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -1760,8 +1760,7 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl info->icount.rx++; } else { - struct tty_struct *tty = info->port.tty; - tty_insert_flip_char(tty, data, flag); + tty_insert_flip_char(&info->port, data, flag); info->icount.rx++; } @@ -2338,8 +2337,7 @@ more_data: data_in, data_read); char flag = TTY_NORMAL; if (info->errorcode == ERRCODE_INSERT_BREAK) { - struct tty_struct *tty = info->port.tty; - tty_insert_flip_char(tty, 0, flag); + tty_insert_flip_char(&info->port, 0, flag); info->icount.rx++; } @@ -2353,7 +2351,7 @@ more_data: info->icount.frame++; flag = TTY_FRAME; } - tty_insert_flip_char(tty, data, flag); + tty_insert_flip_char(&info->port, data, flag); info->errorcode = 0; } info->break_detected_cnt = 0; @@ -2369,7 +2367,7 @@ more_data: log_int(rdpc(), 0, 0); } ); - tty_insert_flip_char(tty, + tty_insert_flip_char(&info->port, IO_EXTRACT(R_SERIAL0_READ, data_in, data_read), TTY_NORMAL); } else { diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index a8cbb2670521..bdf67b0cb8b6 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c @@ -194,8 +194,7 @@ static void efm32_uart_break_ctl(struct uart_port *port, int ctl) /* not possible without fiddling with gpios */ } -static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port, - struct tty_struct *tty) +static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port) { struct uart_port *port = &efm_port->port; @@ -237,8 +236,8 @@ static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port, rxdata & UARTn_RXDATAX_RXDATA__MASK)) continue; - if (tty && (rxdata & port->ignore_status_mask) == 0) - tty_insert_flip_char(tty, + if ((rxdata & port->ignore_status_mask) == 0) + tty_insert_flip_char(&port->state->port, rxdata & UARTn_RXDATAX_RXDATA__MASK, flag); } } @@ -249,15 +248,16 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) u32 irqflag = efm32_uart_read32(efm_port, UARTn_IF); int handled = IRQ_NONE; struct uart_port *port = &efm_port->port; + struct tty_port *tport = &port->state->port; struct tty_struct *tty; spin_lock(&port->lock); - tty = tty_kref_get(port->state->port.tty); + tty = tty_kref_get(tport->tty); if (irqflag & UARTn_IF_RXDATAV) { efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); - efm32_uart_rx_chars(efm_port, tty); + efm32_uart_rx_chars(efm_port); handled = IRQ_HANDLED; } @@ -265,8 +265,7 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) if (irqflag & UARTn_IF_RXOF) { efm32_uart_write32(efm_port, UARTn_IF_RXOF, UARTn_IFC); port->icount.overrun++; - if (tty) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); handled = IRQ_HANDLED; } diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 72b6334bcf1a..2b0b60ff7f01 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c @@ -734,7 +734,8 @@ static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port) static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) { short int count, rcv_buff; - struct tty_struct *tty = icom_port->uart_port.state->port.tty; + struct tty_port *port = &icom_port->uart_port.state->port; + struct tty_struct *tty = port->tty; unsigned short int status; struct uart_icount *icount; unsigned long offset; @@ -812,7 +813,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) } - tty_insert_flip_char(tty, *(icom_port->recv_buf + offset + count - 1), flag); + tty_insert_flip_char(port, *(icom_port->recv_buf + offset + count - 1), flag); if (status & SA_FLAGS_OVERRUN) /* @@ -820,7 +821,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) * reported immediately, and doesn't * affect the current character */ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); ignore_char: icom_port->statStg->rcv[rcv_buff].flags = 0; icom_port->statStg->rcv[rcv_buff].leLength = 0; diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 1a2488495f69..f60c4028b6e1 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -517,6 +517,8 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) struct imx_port *sport = dev_id; unsigned int rx, flg, ignored = 0; struct tty_struct *tty = sport->port.state->port.tty; + struct tty_port *port = &sport->port.state->port; + struct tty_struct *tty = port->tty; unsigned long flags, temp; spin_lock_irqsave(&sport->port.lock, flags); @@ -569,7 +571,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) #endif } - tty_insert_flip_char(tty, rx, flg); + tty_insert_flip_char(port, rx, flg); } out: diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 3969e54744cc..ac1d36cb2032 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -631,13 +631,13 @@ void jsm_input(struct jsm_channel *ch) * format it likes. */ if (*(ch->ch_equeue +tail +i) & UART_LSR_BI) - tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_BREAK); + tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_BREAK); else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE) - tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_PARITY); + tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_PARITY); else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE) - tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_FRAME); + tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_FRAME); else - tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL); + tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL); } } else { tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ; diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 6ac2b797a764..ba2ef627d9c6 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -216,7 +216,7 @@ static void kgdb_nmi_tty_receiver(unsigned long data) return; while (kfifo_out(&priv->fifo, &ch, 1)) - tty_insert_flip_char(priv->port.tty, ch, TTY_NORMAL); + tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); tty_flip_buffer_push(priv->port.tty); tty_kref_put(tty); diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c index 02da071fe1e7..1933fe3c98dd 100644 --- a/drivers/tty/serial/lantiq.c +++ b/drivers/tty/serial/lantiq.c @@ -162,7 +162,8 @@ lqasc_enable_ms(struct uart_port *port) static int lqasc_rx_chars(struct uart_port *port) { - struct tty_struct *tty = tty_port_tty_get(&port->state->port); + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tty_port_tty_get(tport); unsigned int ch = 0, rsr = 0, fifocnt; if (!tty) { @@ -208,7 +209,7 @@ lqasc_rx_chars(struct uart_port *port) } if ((rsr & port->ignore_status_mask) == 0) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(tport, ch, flag); if (rsr & ASCSTATE_ROE) /* @@ -216,7 +217,7 @@ lqasc_rx_chars(struct uart_port *port) * immediately, and doesn't affect the current * character */ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); } if (ch != 0) tty_flip_buffer_push(tty); diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index 0e86bff3fe2a..5cd180564c03 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -257,8 +257,9 @@ static void __serial_uart_flush(struct uart_port *port) static void __serial_lpc32xx_rx(struct uart_port *port) { + struct tty_port *tport = &port->state->port; unsigned int tmp, flag; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); + struct tty_struct *tty = tty_port_tty_get(tport); if (!tty) { /* Discard data: no tty available */ @@ -281,10 +282,10 @@ static void __serial_lpc32xx_rx(struct uart_port *port) LPC32XX_HSUART_IIR(port->membase)); port->icount.frame++; flag = TTY_FRAME; - tty_insert_flip_char(tty, 0, TTY_FRAME); + tty_insert_flip_char(tport, 0, TTY_FRAME); } - tty_insert_flip_char(tty, (tmp & 0xFF), flag); + tty_insert_flip_char(tport, (tmp & 0xFF), flag); tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); } @@ -332,7 +333,8 @@ exit_tx: static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); + struct tty_port *port = &port->state->port; + struct tty_struct *tty = tty_port_tty_get(tport); u32 status; spin_lock(&port->lock); @@ -356,8 +358,8 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) writel(LPC32XX_HSU_RX_OE_INT, LPC32XX_HSUART_IIR(port->membase)); port->icount.overrun++; + tty_insert_flip_char(tport, 0, TTY_OVERRUN); if (tty) { - tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_schedule_flip(tty); } } diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index b13949ad3408..2e9a390f2ac4 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c @@ -300,7 +300,8 @@ static void m32r_sio_enable_ms(struct uart_port *port) static void receive_chars(struct uart_sio_port *up, int *status) { - struct tty_struct *tty = up->port.state->port.tty; + struct tty_port *port = &up->port.state->port; + struct tty_struct *tty = tport->tty; unsigned char ch; unsigned char flag; int max_count = 256; @@ -355,7 +356,7 @@ static void receive_chars(struct uart_sio_port *up, int *status) if (uart_handle_sysrq_char(&up->port, ch)) goto ignore_char; if ((*status & up->port.ignore_status_mask) == 0) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); if (*status & UART_LSR_OE) { /* @@ -363,7 +364,7 @@ static void receive_chars(struct uart_sio_port *up, int *status) * immediately, and doesn't affect the current * character. */ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); } ignore_char: *status = serial_in(up, UART_LSR); diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c index 7c23c4f4c58d..0145aeb7721c 100644 --- a/drivers/tty/serial/mpc52xx_uart.c +++ b/drivers/tty/serial/mpc52xx_uart.c @@ -941,7 +941,8 @@ static struct uart_ops mpc52xx_uart_ops = { static inline int mpc52xx_uart_int_rx_chars(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; unsigned char ch, flag; unsigned short status; @@ -986,14 +987,14 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT); } - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(tport, ch, flag); if (status & MPC52xx_PSC_SR_OE) { /* * Overrun is special, since it's * reported immediately, and doesn't * affect the current character */ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); port->icount.overrun++; } } diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c index 50366863cfa3..4bcbc66c48c4 100644 --- a/drivers/tty/serial/mpsc.c +++ b/drivers/tty/serial/mpsc.c @@ -1040,10 +1040,10 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) | SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) && !(cmdstat & pi->port.ignore_status_mask)) { - tty_insert_flip_char(tty, *bp, flag); + tty_insert_flip_char(port, *bp, flag); } else { for (i=0; iport.icount.rx += bytes_in; } diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 95fd39be2934..e4eb81a12793 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -91,14 +91,15 @@ static void msm_enable_ms(struct uart_port *port) static void handle_rx_dm(struct uart_port *port, unsigned int misr) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; unsigned int sr; int count = 0; struct msm_port *msm_port = UART_TO_MSM(port); if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); } @@ -146,7 +147,8 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) static void handle_rx(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; unsigned int sr; /* @@ -155,7 +157,7 @@ static void handle_rx(struct uart_port *port) */ if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); } @@ -186,7 +188,7 @@ static void handle_rx(struct uart_port *port) } if (!uart_handle_sysrq_char(port, c)) - tty_insert_flip_char(tty, c, flag); + tty_insert_flip_char(tport, c, flag); } tty_flip_buffer_push(tty); diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index 1fa92284ade0..6aa9d470ef54 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c @@ -908,6 +908,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, unsigned long flags; unsigned int flush; struct tty_struct *tty; + struct tty_port *port; struct uart_port *uport; struct msm_hs_port *msm_uport; @@ -917,7 +918,8 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, spin_lock_irqsave(&uport->lock, flags); clk_enable(msm_uport->clk); - tty = uport->state->port.tty; + port = &uport->state->port; + tty = port->tty; msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); @@ -926,7 +928,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, /* overflow is not connect to data in a FIFO */ if (unlikely((status & UARTDM_SR_OVERRUN_BMSK) && (uport->read_status_mask & CREAD))) { - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); uport->icount.buf_overrun++; error_f = 1; } @@ -939,7 +941,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, uport->icount.parity++; error_f = 1; if (uport->ignore_status_mask & IGNPAR) - tty_insert_flip_char(tty, 0, TTY_PARITY); + tty_insert_flip_char(port, 0, TTY_PARITY); } if (error_f) @@ -1344,7 +1346,6 @@ static irqreturn_t msm_hs_rx_wakeup_isr(int irq, void *dev) unsigned long flags; struct msm_hs_port *msm_uport = dev; struct uart_port *uport = &msm_uport->uport; - struct tty_struct *tty = NULL; spin_lock_irqsave(&uport->lock, flags); if (msm_uport->clk_state == MSM_HS_CLK_OFF) { @@ -1361,8 +1362,7 @@ static irqreturn_t msm_hs_rx_wakeup_isr(int irq, void *dev) * optionally inject char into tty rx */ msm_hs_request_clock_on_locked(uport); if (msm_uport->rx_wakeup.inject_rx) { - tty = uport->state->port.tty; - tty_insert_flip_char(tty, + tty_insert_flip_char(&uport->state->port, msm_uport->rx_wakeup.rx_to_inject, TTY_NORMAL); queue_work(msm_hs_workqueue, &msm_uport->rx.tty_work); diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c index e2775b6df5a5..83b21686020e 100644 --- a/drivers/tty/serial/mux.c +++ b/drivers/tty/serial/mux.c @@ -242,8 +242,9 @@ static void mux_write(struct uart_port *port) */ static void mux_read(struct uart_port *port) { + struct tty_port *tport = &port->state->port; int data; - struct tty_struct *tty = port->state->port.tty; + struct tty_struct *tty = tport->tty; __u32 start_count = port->icount.rx; while(1) { @@ -266,7 +267,7 @@ static void mux_read(struct uart_port *port) if (uart_handle_sysrq_char(port, data & 0xffu)) continue; - tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); + tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL); } if (start_count != port->icount.rx) { diff --git a/drivers/tty/serial/nwpserial.c b/drivers/tty/serial/nwpserial.c index dd4c31d1aee5..10d64a3697fb 100644 --- a/drivers/tty/serial/nwpserial.c +++ b/drivers/tty/serial/nwpserial.c @@ -128,7 +128,8 @@ static void nwpserial_config_port(struct uart_port *port, int flags) static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) { struct nwpserial_port *up = dev_id; - struct tty_struct *tty = up->port.state->port.tty; + struct tty_port *port = &up->port.state->port; + struct tty_struct *tty = port->tty; irqreturn_t ret; unsigned int iir; unsigned char ch; @@ -146,7 +147,7 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) up->port.icount.rx++; ch = dcr_read(up->dcr_host, UART_RX); if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID) - tty_insert_flip_char(tty, ch, TTY_NORMAL); + tty_insert_flip_char(port, ch, TTY_NORMAL); } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); tty_flip_buffer_push(tty); diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 333c8d012b0e..73a3f295e7c4 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c @@ -229,6 +229,7 @@ static void pmz_interrupt_control(struct uart_pmac_port *uap, int enable) static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) { + struct tty_port *port; struct tty_struct *tty = NULL; unsigned char ch, r1, drop, error, flag; int loops = 0; @@ -239,7 +240,8 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) (void)read_zsdata(uap); return NULL; } - tty = uap->port.state->port.tty; + port = &uap->port.state->port; + tty = port->tty; /* TOCTOU above */ while (1) { error = 0; @@ -309,10 +311,10 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) if (uap->port.ignore_status_mask == 0xff || (r1 & uap->port.ignore_status_mask) == 0) { - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); } if (r1 & Rx_OVR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); next_char: /* We can get stuck in an infinite loop getting char 0 when the * line is in a wrong HW state, we break that here. diff --git a/drivers/tty/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c index aced1dd923d8..0cd0e4ac12a6 100644 --- a/drivers/tty/serial/sc26xx.c +++ b/drivers/tty/serial/sc26xx.c @@ -138,14 +138,18 @@ static void sc26xx_disable_irq(struct uart_port *port, int mask) static struct tty_struct *receive_chars(struct uart_port *port) { + struct tty_port *tport = NULL; struct tty_struct *tty = NULL; int limit = 10000; unsigned char ch; char flag; u8 status; - if (port->state != NULL) /* Unopened serial console */ - tty = port->state->port.tty; + /* FIXME what is this trying to achieve? */ + if (port->state != NULL) { /* Unopened serial console */ + tport = &port->state->port; + tty = tport->tty; + } while (limit-- > 0) { status = READ_SC_PORT(port, SR); @@ -185,7 +189,7 @@ static struct tty_struct *receive_chars(struct uart_port *port) if (status & port->ignore_status_mask) continue; - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(tport, ch, flag); } return tty; } diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index ba7863bbbb4d..675343a20f24 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2792,10 +2792,10 @@ EXPORT_SYMBOL_GPL(uart_handle_cts_change); void uart_insert_char(struct uart_port *port, unsigned int status, unsigned int overrun, unsigned int ch, unsigned int flag) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; if ((status & port->ignore_status_mask & ~overrun) == 0) - if (tty_insert_flip_char(tty, ch, flag) == 0) + if (tty_insert_flip_char(tport, ch, flag) == 0) ++port->icount.buf_overrun; /* @@ -2803,7 +2803,7 @@ void uart_insert_char(struct uart_port *port, unsigned int status, * it doesn't affect the current character. */ if (status & ~port->ignore_status_mask & overrun) - if (tty_insert_flip_char(tty, 0, TTY_OVERRUN) == 0) + if (tty_insert_flip_char(tport, 0, TTY_OVERRUN) == 0) ++port->icount.buf_overrun; } EXPORT_SYMBOL_GPL(uart_insert_char); diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index cf96314770fb..ecef748f5385 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -620,7 +620,7 @@ static void sci_receive_chars(struct uart_port *port) sci_port->break_flag) count = 0; else - tty_insert_flip_char(tty, c, TTY_NORMAL); + tty_insert_flip_char(tport, c, TTY_NORMAL); } else { for (i = 0; i < count; i++) { char c = serial_port_in(port, SCxRDR); @@ -662,7 +662,7 @@ static void sci_receive_chars(struct uart_port *port) } else flag = TTY_NORMAL; - tty_insert_flip_char(tty, c, flag); + tty_insert_flip_char(tport, c, flag); } } @@ -721,7 +721,8 @@ static int sci_handle_errors(struct uart_port *port) { int copied = 0; unsigned short status = serial_port_in(port, SCxSR); - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); /* @@ -732,7 +733,7 @@ static int sci_handle_errors(struct uart_port *port) port->icount.overrun++; /* overrun error */ - if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) + if (tty_insert_flip_char(tport, 0, TTY_OVERRUN)) copied++; dev_notice(port->dev, "overrun error"); @@ -756,7 +757,7 @@ static int sci_handle_errors(struct uart_port *port) dev_dbg(port->dev, "BREAK detected\n"); - if (tty_insert_flip_char(tty, 0, TTY_BREAK)) + if (tty_insert_flip_char(tport, 0, TTY_BREAK)) copied++; } @@ -764,7 +765,7 @@ static int sci_handle_errors(struct uart_port *port) /* frame error */ port->icount.frame++; - if (tty_insert_flip_char(tty, 0, TTY_FRAME)) + if (tty_insert_flip_char(tport, 0, TTY_FRAME)) copied++; dev_notice(port->dev, "frame error\n"); @@ -775,7 +776,7 @@ static int sci_handle_errors(struct uart_port *port) /* parity error */ port->icount.parity++; - if (tty_insert_flip_char(tty, 0, TTY_PARITY)) + if (tty_insert_flip_char(tport, 0, TTY_PARITY)) copied++; dev_notice(port->dev, "parity error"); @@ -789,7 +790,8 @@ static int sci_handle_errors(struct uart_port *port) static int sci_handle_fifo_overrun(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); struct plat_sci_reg *reg; int copied = 0; @@ -803,7 +805,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port) port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); tty_flip_buffer_push(tty); dev_notice(port->dev, "overrun error\n"); @@ -817,7 +819,8 @@ static int sci_handle_breaks(struct uart_port *port) { int copied = 0; unsigned short status = serial_port_in(port, SCxSR); - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); if (uart_handle_break(port)) @@ -832,7 +835,7 @@ static int sci_handle_breaks(struct uart_port *port) port->icount.brk++; /* Notify of BREAK */ - if (tty_insert_flip_char(tty, 0, TTY_BREAK)) + if (tty_insert_flip_char(tport, 0, TTY_BREAK)) copied++; dev_dbg(port->dev, "BREAK detected\n"); @@ -1260,8 +1263,7 @@ static void sci_dma_tx_complete(void *arg) } /* Locking: called with port lock held */ -static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty, - size_t count) +static int sci_dma_rx_push(struct sci_port *s, size_t count) { struct uart_port *port = &s->port; struct tty_port *tport = &port->state->port; @@ -1285,7 +1287,7 @@ static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty, return room; for (i = 0; i < room; i++) - tty_insert_flip_char(tty, ((u8 *)sg_virt(&s->sg_rx[active]))[i], + tty_insert_flip_char(tport, ((u8 *)sg_virt(&s->sg_rx[active]))[i], TTY_NORMAL); port->icount.rx += room; @@ -1305,7 +1307,7 @@ static void sci_dma_rx_complete(void *arg) spin_lock_irqsave(&port->lock, flags); - count = sci_dma_rx_push(s, tty, s->buf_len_rx); + count = sci_dma_rx_push(s, s->buf_len_rx); mod_timer(&s->rx_timer, jiffies + s->rx_timeout); @@ -1418,7 +1420,7 @@ static void work_fn_rx(struct work_struct *work) sh_desc->partial, sh_desc->cookie); spin_lock_irqsave(&port->lock, flags); - count = sci_dma_rx_push(s, tty, sh_desc->partial); + count = sci_dma_rx_push(s, sh_desc->partial); spin_unlock_irqrestore(&port->lock, flags); if (count) diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c index 1c6de9f58699..283232c64656 100644 --- a/drivers/tty/serial/sn_console.c +++ b/drivers/tty/serial/sn_console.c @@ -457,6 +457,7 @@ static int sn_debug_printf(const char *fmt, ...) static void sn_receive_chars(struct sn_cons_port *port, unsigned long flags) { + struct tty_port *tport = NULL; int ch; struct tty_struct *tty; @@ -472,7 +473,8 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) if (port->sc_port.state) { /* The serial_core stuffs are initialized, use them */ - tty = port->sc_port.state->port.tty; + tport = &port->sc_port.state->port; + tty = tport->tty; } else { /* Not registered yet - can't pass to tty layer. */ @@ -517,7 +519,7 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) /* record the character to pass up to the tty layer */ if (tty) { - if(tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) + if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0) break; } port->sc_port.icount.rx++; diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c index b9bf9c53f7fd..bbb102e3c035 100644 --- a/drivers/tty/serial/sunhv.c +++ b/drivers/tty/serial/sunhv.c @@ -99,7 +99,7 @@ static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty) uart_handle_dcd_change(port, 1); } - if (tty == NULL) { + if (port->state == NULL) { uart_handle_sysrq_char(port, c); continue; } @@ -109,7 +109,7 @@ static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty) if (uart_handle_sysrq_char(port, c)) continue; - tty_insert_flip_char(tty, c, TTY_NORMAL); + tty_insert_flip_char(&port->state->port, c, TTY_NORMAL); } return saw_console_brk; diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index bd8b3b634103..4abc4d43a8e8 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c @@ -111,6 +111,7 @@ static struct tty_struct * receive_chars(struct uart_sunsab_port *up, union sab82532_irq_status *stat) { + struct tty_port *port = NULL; struct tty_struct *tty = NULL; unsigned char buf[32]; int saw_console_brk = 0; @@ -118,8 +119,10 @@ receive_chars(struct uart_sunsab_port *up, int count = 0; int i; - if (up->port.state != NULL) /* Unopened serial console */ - tty = up->port.state->port.tty; + if (up->port.state != NULL) { /* Unopened serial console */ + port = &up->port.state->port; + tty = port->tty; + } /* Read number of BYTES (Character + Status) available. */ if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { @@ -160,11 +163,6 @@ receive_chars(struct uart_sunsab_port *up, for (i = 0; i < count; i++) { unsigned char ch = buf[i], flag; - if (tty == NULL) { - uart_handle_sysrq_char(&up->port, ch); - continue; - } - flag = TTY_NORMAL; up->port.icount.rx++; @@ -213,9 +211,9 @@ receive_chars(struct uart_sunsab_port *up, if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); if (stat->sreg.isr0 & SAB82532_ISR0_RFO) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); } if (saw_console_brk) diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 220da3f9724f..52325968b06c 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c @@ -318,7 +318,8 @@ static void sunsu_enable_ms(struct uart_port *port) static struct tty_struct * receive_chars(struct uart_sunsu_port *up, unsigned char *status) { - struct tty_struct *tty = up->port.state->port.tty; + struct tty_port *port = &up->port.state->port; + struct tty_struct *tty = port->tty; unsigned char ch, flag; int max_count = 256; int saw_console_brk = 0; @@ -376,14 +377,14 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status) if (uart_handle_sysrq_char(&up->port, ch)) goto ignore_char; if ((*status & up->port.ignore_status_mask) == 0) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); if (*status & UART_LSR_OE) /* * Overrun is special, since it's reported * immediately, and doesn't affect the current * character. */ - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); ignore_char: *status = serial_inp(up, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index aef4fab957c3..4a11be3849f6 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c @@ -327,13 +327,15 @@ static struct tty_struct * sunzilog_receive_chars(struct uart_sunzilog_port *up, struct zilog_channel __iomem *channel) { + struct tty_port *port = NULL; struct tty_struct *tty; unsigned char ch, r1, flag; tty = NULL; - if (up->port.state != NULL && /* Unopened serial console */ - up->port.state->port.tty != NULL) /* Keyboard || mouse */ - tty = up->port.state->port.tty; + if (up->port.state != NULL) { /* Unopened serial console */ + port = &up->port.state->port; + tty = port->tty; /* mouse => tty is NULL */ + } for (;;) { @@ -366,11 +368,6 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, continue; } - if (tty == NULL) { - uart_handle_sysrq_char(&up->port, ch); - continue; - } - /* A real serial line, record the character and status. */ flag = TTY_NORMAL; up->port.icount.rx++; @@ -400,10 +397,10 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, if (up->port.ignore_status_mask == 0xff || (r1 & up->port.ignore_status_mask) == 0) { - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(port, ch, flag); } if (r1 & Rx_OVR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(port, 0, TTY_OVERRUN); } return tty; diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c index 5be0d68feceb..f40c634f7528 100644 --- a/drivers/tty/serial/timbuart.c +++ b/drivers/tty/serial/timbuart.c @@ -91,12 +91,12 @@ static void timbuart_flush_buffer(struct uart_port *port) static void timbuart_rx_chars(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; while (ioread32(port->membase + TIMBUART_ISR) & RXDP) { u8 ch = ioread8(port->membase + TIMBUART_RXFIFO); port->icount.rx++; - tty_insert_flip_char(tty, ch, TTY_NORMAL); + tty_insert_flip_char(tport, ch, TTY_NORMAL); } spin_unlock(&port->lock); diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 89eee43c4e2d..5caf1f0ebc82 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -66,7 +66,7 @@ static struct uart_port ulite_ports[ULITE_NR_UARTS]; static int ulite_receive(struct uart_port *port, int stat) { - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; unsigned char ch = 0; char flag = TTY_NORMAL; @@ -103,13 +103,13 @@ static int ulite_receive(struct uart_port *port, int stat) stat &= ~port->ignore_status_mask; if (stat & ULITE_STATUS_RXVALID) - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(tport, ch, flag); if (stat & ULITE_STATUS_FRAME) - tty_insert_flip_char(tty, 0, TTY_FRAME); + tty_insert_flip_char(tport, 0, TTY_FRAME); if (stat & ULITE_STATUS_OVERRUN) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); return 1; } diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index ed047d9ab1e2..7a2378627fa5 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c @@ -513,7 +513,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) continue; error_return: - tty_insert_flip_char(tty, ch, flg); + tty_insert_flip_char(tport, ch, flg); } @@ -561,7 +561,7 @@ handle_error: /* Overrun does not affect the current character ! */ if (status & BD_SC_OV) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); #ifdef SUPPORT_SYSRQ port->sysrq = 0; #endif diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 8fd181436a6b..7f4112423f3d 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -136,7 +136,8 @@ static void vt8500_enable_ms(struct uart_port *port) static void handle_rx(struct uart_port *port) { - struct tty_struct *tty = tty_port_tty_get(&port->state->port); + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tty_port_tty_get(tport); if (!tty) { /* Discard data: no tty available */ int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8; @@ -151,7 +152,7 @@ static void handle_rx(struct uart_port *port) */ if ((vt8500_read(port, VT8500_URISR) & RXOVER)) { port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(tport, 0, TTY_OVERRUN); } /* and now the main RX loop */ @@ -174,7 +175,7 @@ static void handle_rx(struct uart_port *port) port->icount.rx++; if (!uart_handle_sysrq_char(port, c)) - tty_insert_flip_char(tty, c, flag); + tty_insert_flip_char(tport, c, flag); } tty_flip_buffer_push(tty); diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index d42b66195a49..33656b35db05 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -1507,13 +1507,13 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) else if (status & RXSTATUS_FRAMING_ERROR) flag = TTY_FRAME; } /* end of if (error) */ - tty_insert_flip_char(tty, DataByte, flag); + tty_insert_flip_char(&info->port, DataByte, flag); if (status & RXSTATUS_OVERRUN) { /* Overrun is special, since it's * reported immediately, and doesn't * affect the current character */ - work += tty_insert_flip_char(tty, 0, TTY_OVERRUN); + work += tty_insert_flip_char(&info->port, 0, TTY_OVERRUN); } } diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 62a0db7ead07..473d7406db83 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -1893,10 +1893,8 @@ static void rx_async(struct slgt_info *info) else if (status & BIT0) stat = TTY_FRAME; } - if (tty) { - tty_insert_flip_char(tty, ch, stat); - chars++; - } + tty_insert_flip_char(&info->port, ch, stat); + chars++; } if (i < count) { @@ -2182,7 +2180,7 @@ static void isr_serial(struct slgt_info *info) if (info->port.tty) { if (!(status & info->ignore_status_mask)) { if (info->read_status_mask & MASK_BREAK) { - tty_insert_flip_char(info->port.tty, 0, TTY_BREAK); + tty_insert_flip_char(&info->port, 0, TTY_BREAK); if (info->port.flags & ASYNC_SAK) do_SAK(info->port.tty); } diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 33b7314cc6c7..f5794f3d840f 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -2131,13 +2131,11 @@ static void isr_rxint(SLMP_INFO * info) /* process break detection if tty control * is not set to ignore it */ - if ( tty ) { - if (!(status & info->ignore_status_mask1)) { - if (info->read_status_mask1 & BRKD) { - tty_insert_flip_char(tty, 0, TTY_BREAK); - if (info->port.flags & ASYNC_SAK) - do_SAK(tty); - } + if (!(status & info->ignore_status_mask1)) { + if (info->read_status_mask1 & BRKD) { + tty_insert_flip_char(&info->port, 0, TTY_BREAK); + if (tty && (info->port.flags & ASYNC_SAK)) + do_SAK(tty); } } } @@ -2202,26 +2200,22 @@ static void isr_rxrdy(SLMP_INFO * info) status &= info->read_status_mask2; - if ( tty ) { - if (status & PE) - flag = TTY_PARITY; - else if (status & FRME) - flag = TTY_FRAME; - if (status & OVRN) { - /* Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - over = true; - } + if (status & PE) + flag = TTY_PARITY; + else if (status & FRME) + flag = TTY_FRAME; + if (status & OVRN) { + /* Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + over = true; } } /* end of if (error) */ - if ( tty ) { - tty_insert_flip_char(tty, DataByte, flag); - if (over) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); - } + tty_insert_flip_char(&info->port, DataByte, flag); + if (over) + tty_insert_flip_char(&info->port, 0, TTY_OVERRUN); } if ( debug_level >= DEBUG_LEVEL_ISR ) { diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 681765baef69..5aace4d47cb6 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -309,8 +309,8 @@ static void put_queue(struct vc_data *vc, int ch) { struct tty_struct *tty = vc->port.tty; + tty_insert_flip_char(&vc->port, ch, 0); if (tty) { - tty_insert_flip_char(tty, ch, 0); tty_schedule_flip(tty); } } @@ -323,7 +323,7 @@ static void puts_queue(struct vc_data *vc, char *cp) return; while (*cp) { - tty_insert_flip_char(tty, *cp, 0); + tty_insert_flip_char(&vc->port, *cp, 0); cp++; } tty_schedule_flip(tty); @@ -586,7 +586,7 @@ static void fn_send_intr(struct vc_data *vc) if (!tty) return; - tty_insert_flip_char(tty, 0, TTY_BREAK); + tty_insert_flip_char(&vc->port, 0, TTY_BREAK); tty_schedule_flip(tty); } diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 8fd89687d068..811f2505e9ee 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1336,7 +1336,7 @@ static void csi_m(struct vc_data *vc) static void respond_string(const char *p, struct tty_struct *tty) { while (*p) { - tty_insert_flip_char(tty, *p, 0); + tty_insert_flip_char(tty->port, *p, 0); p++; } tty_schedule_flip(tty); diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index e2d653d00ea2..1614feb6a76e 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -703,7 +703,7 @@ static void ark3116_process_read_urb(struct urb *urb) /* overrun is special, not associated with a char */ if (lsr & UART_LSR_OE) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index a213d1be9462..7ba2c0bdcec9 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -276,7 +276,7 @@ static void belkin_sa_process_read_urb(struct urb *urb) /* Overrun is special, not associated with a char. */ if (status & BELKIN_SA_LSR_OE) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index efbc4035410c..b5fa738512ca 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -1441,7 +1441,7 @@ static int digi_read_inb_callback(struct urb *urb) /* overrun is special, not associated with a char */ if (port_status & DIGI_OVERRUN_ERROR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); /* break takes precedence over parity, */ /* which takes precedence over framing errors */ diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index a8c6430bf1b3..6b880c33d258 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -133,12 +133,13 @@ static void f81232_process_read_urb(struct urb *urb) /* overrun is special, not associated with a char */ if (line_status & UART_OVERRUN_ERROR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); if (port->port.console && port->sysrq) { for (i = 0; i < urb->actual_length; ++i) if (!usb_serial_handle_sysrq_char(port, data[i])) - tty_insert_flip_char(tty, data[i], tty_flag); + tty_insert_flip_char(&port->port, data[i], + tty_flag); } else { tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 0416d952a448..eb59ba3789ad 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1958,9 +1958,8 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port, #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) -static int ftdi_process_packet(struct tty_struct *tty, - struct usb_serial_port *port, struct ftdi_private *priv, - char *packet, int len) +static int ftdi_process_packet(struct usb_serial_port *port, + struct ftdi_private *priv, char *packet, int len) { int i; char status; @@ -2010,7 +2009,7 @@ static int ftdi_process_packet(struct tty_struct *tty, /* Overrun is special, not associated with a char */ if (packet[1] & FTDI_RS_OE) { priv->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } } @@ -2029,7 +2028,7 @@ static int ftdi_process_packet(struct tty_struct *tty, if (port->port.console && port->sysrq) { for (i = 0; i < len; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) - tty_insert_flip_char(tty, *ch, flag); + tty_insert_flip_char(&port->port, *ch, flag); } } else { tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); @@ -2054,7 +2053,7 @@ static void ftdi_process_read_urb(struct urb *urb) for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { len = min_t(int, urb->actual_length - i, priv->max_packet_size); - count += ftdi_process_packet(tty, port, priv, &data[i], len); + count += ftdi_process_packet(port, priv, &data[i], len); } if (count) diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 2ea70a631996..b00110cd5689 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -332,7 +332,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb) else { for (i = 0; i < urb->actual_length; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) - tty_insert_flip_char(tty, *ch, TTY_NORMAL); + tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); } } tty_flip_buffer_push(tty); diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 97bc49f68efd..a4f5caebda43 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -315,7 +315,7 @@ static void usa26_indat_callback(struct urb *urb) else err = 0; for (i = 1; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], err); + tty_insert_flip_char(&port->port, data[i], err); } else { /* some bytes had errors, every byte has status */ dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); @@ -328,7 +328,8 @@ static void usa26_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - tty_insert_flip_char(tty, data[i+1], flag); + tty_insert_flip_char(&port->port, data[i+1], + flag); } } tty_flip_buffer_push(tty); @@ -700,7 +701,8 @@ static void usa49_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - tty_insert_flip_char(tty, data[i+1], flag); + tty_insert_flip_char(&port->port, data[i+1], + flag); } } tty_flip_buffer_push(tty); @@ -751,7 +753,8 @@ static void usa49wg_indat_callback(struct urb *urb) /* no error on any byte */ i++; for (x = 1; x < len ; ++x) - tty_insert_flip_char(tty, data[i++], 0); + tty_insert_flip_char(&port->port, + data[i++], 0); } else { /* * some bytes had errors, every byte has status @@ -765,7 +768,7 @@ static void usa49wg_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - tty_insert_flip_char(tty, + tty_insert_flip_char(&port->port, data[i+1], flag); i += 2; } @@ -824,8 +827,8 @@ static void usa90_indat_callback(struct urb *urb) else err = 0; for (i = 1; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], - err); + tty_insert_flip_char(&port->port, + data[i], err); } else { /* some bytes had errors, every byte has status */ dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); @@ -838,8 +841,8 @@ static void usa90_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - tty_insert_flip_char(tty, data[i+1], - flag); + tty_insert_flip_char(&port->port, + data[i+1], flag); } } } diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 86789b0477c5..00047f3c7293 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -805,12 +805,13 @@ static void pl2303_process_read_urb(struct urb *urb) /* overrun is special, not associated with a char */ if (line_status & UART_OVERRUN_ERROR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); if (port->port.console && port->sysrq) { for (i = 0; i < urb->actual_length; ++i) if (!usb_serial_handle_sysrq_char(port, data[i])) - tty_insert_flip_char(tty, data[i], tty_flag); + tty_insert_flip_char(&port->port, data[i], + tty_flag); } else { tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index fa42f1b907d0..04e373152724 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -498,7 +498,7 @@ static void spcp8x5_process_read_urb(struct urb *urb) /* overrun is special, not associated with a char */ if (status & UART_OVERRUN_ERROR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); if (status & UART_DCD) usb_serial_handle_dcd_change(port, tty, diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 37476c6240c2..38713156e957 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -582,8 +582,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr, } -static int ssu100_process_packet(struct urb *urb, - struct tty_struct *tty) +static int ssu100_process_packet(struct urb *urb) { struct usb_serial_port *port = urb->context; char *packet = (char *)urb->transfer_buffer; @@ -598,7 +597,8 @@ static int ssu100_process_packet(struct urb *urb, if (packet[2] == 0x00) { ssu100_update_lsr(port, packet[3], &flag); if (flag == TTY_OVERRUN) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, + TTY_OVERRUN); } if (packet[2] == 0x01) ssu100_update_msr(port, packet[3]); @@ -614,7 +614,7 @@ static int ssu100_process_packet(struct urb *urb, if (port->port.console && port->sysrq) { for (i = 0; i < len; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) - tty_insert_flip_char(tty, *ch, flag); + tty_insert_flip_char(&port->port, *ch, flag); } } else tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); @@ -632,7 +632,7 @@ static void ssu100_process_read_urb(struct urb *urb) if (!tty) return; - count = ssu100_process_packet(urb, tty); + count = ssu100_process_packet(urb); if (count) tty_flip_buffer_push(tty); diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 743f1d076467..f9acb578c6ad 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -12,16 +12,16 @@ extern int tty_prepare_flip_string_flags(struct tty_port *port, unsigned char **chars, char **flags, size_t size); void tty_schedule_flip(struct tty_struct *tty); -static inline int tty_insert_flip_char(struct tty_struct *tty, +static inline int tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) { - struct tty_buffer *tb = tty->port->buf.tail; + struct tty_buffer *tb = port->buf.tail; if (tb && tb->used < tb->size) { tb->flag_buf_ptr[tb->used] = flag; tb->char_buf_ptr[tb->used++] = ch; return 1; } - return tty_insert_flip_string_flags(tty->port, &ch, &flag, 1); + return tty_insert_flip_string_flags(port, &ch, &flag, 1); } static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) -- cgit v1.2.3 From 05c7cd39907184328f48d3e7899f9cdd653ad336 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:04 +0100 Subject: TTY: switch tty_insert_flip_string Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. tty_insert_flip_string this time. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/isdn/gigaset/interface.c | 2 +- drivers/isdn/i4l/isdn_common.c | 5 ++--- drivers/isdn/i4l/isdn_common.h | 2 +- drivers/isdn/i4l/isdn_tty.c | 6 +++--- drivers/net/usb/hso.c | 7 +++---- drivers/s390/char/con3215.c | 3 ++- drivers/s390/char/sclp_tty.c | 4 ++-- drivers/s390/char/sclp_vt220.c | 2 +- drivers/staging/ccg/u_serial.c | 2 +- drivers/tty/bfin_jtag_comm.c | 2 +- drivers/tty/ehv_bytechan.c | 2 +- drivers/tty/hvc/hvcs.c | 2 +- drivers/tty/ipwireless/tty.c | 2 +- drivers/tty/n_gsm.c | 2 +- drivers/tty/nozomi.c | 14 +++++--------- drivers/tty/pty.c | 2 +- drivers/tty/serial/amba-pl011.c | 6 +++--- drivers/tty/serial/atmel_serial.c | 6 ++++-- drivers/tty/serial/crisv10.c | 2 +- drivers/tty/serial/icom.c | 2 +- drivers/tty/serial/ifx6x60.c | 2 +- drivers/tty/serial/ioc3_serial.c | 3 ++- drivers/tty/serial/ioc4_serial.c | 2 +- drivers/tty/serial/jsm/jsm_tty.c | 2 +- drivers/tty/serial/mfd.c | 5 +++-- drivers/tty/serial/mrst_max3110.c | 2 +- drivers/tty/serial/msm_serial.c | 2 +- drivers/tty/serial/msm_serial_hs.c | 2 +- drivers/tty/serial/mxs-auart.c | 5 +++-- drivers/tty/serial/pch_uart.c | 10 +++++----- drivers/tty/serial/sunhv.c | 13 +++++++------ drivers/usb/class/cdc-acm.c | 3 ++- drivers/usb/gadget/u_serial.c | 11 ++++------- drivers/usb/serial/aircable.c | 9 ++++----- drivers/usb/serial/cyberjack.c | 2 +- drivers/usb/serial/garmin_gps.c | 2 +- drivers/usb/serial/generic.c | 2 +- drivers/usb/serial/io_edgeport.c | 12 ++++++------ drivers/usb/serial/io_ti.c | 13 +++++++------ drivers/usb/serial/ir-usb.c | 2 +- drivers/usb/serial/iuu_phoenix.c | 2 +- drivers/usb/serial/keyspan.c | 8 +++++--- drivers/usb/serial/keyspan_pda.c | 2 +- drivers/usb/serial/kl5kusb105.c | 2 +- drivers/usb/serial/kobil_sct.c | 2 +- drivers/usb/serial/mct_u232.c | 2 +- drivers/usb/serial/metro-usb.c | 2 +- drivers/usb/serial/mos7720.c | 2 +- drivers/usb/serial/mos7840.c | 5 +++-- drivers/usb/serial/navman.c | 2 +- drivers/usb/serial/omninet.c | 5 +++-- drivers/usb/serial/opticon.c | 2 +- drivers/usb/serial/oti6858.c | 2 +- drivers/usb/serial/quatech2.c | 8 +++----- drivers/usb/serial/safe_serial.c | 2 +- drivers/usb/serial/sierra.c | 2 +- drivers/usb/serial/symbolserial.c | 3 ++- drivers/usb/serial/ti_usb_3410_5052.c | 11 +++++------ drivers/usb/serial/usb_wwan.c | 2 +- include/linux/tty_flip.h | 5 +++-- net/bluetooth/rfcomm/tty.c | 5 +++-- net/irda/ircomm/ircomm_tty.c | 2 +- 62 files changed, 130 insertions(+), 127 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 67abf3ff45e8..dd2a57eca2e7 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -569,7 +569,7 @@ void gigaset_if_receive(struct cardstate *cs, return; } - tty_insert_flip_string(tty, buffer, len); + tty_insert_flip_string(&cs->port, buffer, len); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 4a387ec021ad..b87d9e577be2 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -876,9 +876,8 @@ isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue * of the mapping (di,ch)<->minor, happen during the sleep? --he */ int -isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) +isdn_readbchan_tty(int di, int channel, struct tty_port *port, int cisco_hack) { - struct tty_port *port = tty->port; int count; int count_pull; int count_put; @@ -941,7 +940,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) } count_put = count_pull; if (count_put > 1) - tty_insert_flip_string(tty, skb->data, count_put - 1); + tty_insert_flip_string(port, skb->data, count_put - 1); last = skb->data[count_put - 1]; len -= count_put; #ifdef CONFIG_ISDN_AUDIO diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 9a471f62e1d4..2260ef07ab9c 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -37,7 +37,7 @@ extern void isdn_timer_ctrl(int tf, int onoff); extern void isdn_unexclusive_channel(int di, int ch); extern int isdn_getnum(char **); extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); -extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); +extern int isdn_readbchan_tty(int, int, struct tty_port *, int); extern int isdn_get_free_channel(int, int, int, int, int, char *); extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); extern int register_isdn(isdn_if *i); diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 32d65d4bc848..9bb9986659e4 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -101,7 +101,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) } else { #endif if (len > 1) - tty_insert_flip_string(tty, skb->data, len - 1); + tty_insert_flip_string(port, skb->data, len - 1); last = skb->data[len - 1]; #ifdef CONFIG_ISDN_AUDIO } @@ -150,9 +150,9 @@ isdn_tty_readmodem(void) if (info->mcr & UART_MCR_RTS) { /* CISCO AsyncPPP Hack */ if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0); + r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0); else - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1); + r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1); if (r) tty_flip_buffer_push(tty); } else diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index cd8ccb240f4b..d235ca07548f 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2044,10 +2044,9 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) tty_kref_put(tty); return -1; } - curr_write_len = tty_insert_flip_string - (tty, urb->transfer_buffer + - serial->curr_rx_urb_offset, - write_length_remaining); + curr_write_len = tty_insert_flip_string(&serial->port, + urb->transfer_buffer + serial->curr_rx_urb_offset, + write_length_remaining); serial->curr_rx_urb_offset += curr_write_len; write_length_remaining -= curr_write_len; tty_flip_buffer_push(tty); diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 7c7294590880..4c6743dd5357 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -425,7 +425,8 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, count++; } else count -= 2; - tty_insert_flip_string(tty, raw->inbuf, count); + tty_insert_flip_string(&raw->port, raw->inbuf, + count); tty_flip_buffer_push(tty); break; } diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index c03863a7d455..3ffddbb53d2f 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -351,10 +351,10 @@ sclp_tty_input(unsigned char* buf, unsigned int count) (strncmp((const char *) buf + count - 2, "^n", 2) && strncmp((const char *) buf + count - 2, "\252n", 2))) { /* add the auto \n */ - tty_insert_flip_string(tty, buf, count); + tty_insert_flip_string(&sclp_port, buf, count); tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); } else - tty_insert_flip_string(tty, buf, count - 2); + tty_insert_flip_string(&sclp_port, buf, count - 2); tty_flip_buffer_push(tty); break; } diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index effcc8756e0a..b5507f199b24 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -480,7 +480,7 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf) /* Send input to line discipline */ buffer++; count--; - tty_insert_flip_string(tty, buffer, count); + tty_insert_flip_string(&sclp_vt220_port, buffer, count); tty_flip_buffer_push(tty); break; } diff --git a/drivers/staging/ccg/u_serial.c b/drivers/staging/ccg/u_serial.c index 373c40656b52..7df2c02d1137 100644 --- a/drivers/staging/ccg/u_serial.c +++ b/drivers/staging/ccg/u_serial.c @@ -529,7 +529,7 @@ static void gs_rx_push(unsigned long _port) size -= n; } - count = tty_insert_flip_string(tty, packet, size); + count = tty_insert_flip_string(&port->port, packet, size); if (count) do_push = true; if (count != size) { diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 1cfcdbf1d0cc..143c38579cb5 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c @@ -104,7 +104,7 @@ bfin_jc_emudat_manager(void *arg) size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); inbound_len -= num_chars; - tty_insert_flip_string(tty, (unsigned char *)&emudat, num_chars); + tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); tty_flip_buffer_push(tty); } } diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index af97e39d641c..5164f9a57017 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -407,7 +407,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) */ /* Pass the received data to the tty layer. */ - ret = tty_insert_flip_string(ttys, buffer, len); + ret = tty_insert_flip_string(&bc->port, buffer, len); /* 'ret' is the number of bytes that the TTY layer accepted. * If it's not equal to 'len', then it means the buffer is diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 4a0ab98e9a63..7bfc0a924b2f 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -613,7 +613,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd) got = hvc_get_chars(unit_address, &buf[0], HVCS_BUFF_LEN); - tty_insert_flip_string(tty, buf, got); + tty_insert_flip_string(&hvcsd->port, buf, got); } /* Give the TTY time to process the data we just sent. */ diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 2cde13ddf9fc..a3ad5e14cbef 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -176,7 +176,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, } mutex_unlock(&tty->ipw_tty_mutex); - work = tty_insert_flip_string(linux_tty, data, length); + work = tty_insert_flip_string(&tty->port, data, length); if (work != length) printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 769016504c88..4a3342d21c8f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1578,7 +1578,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) /* Line state will go via DLCI 0 controls only */ case 1: default: - tty_insert_flip_string(tty, data, len); + tty_insert_flip_string(port, data, len); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 437a6366fb7b..941fe8060ea5 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -827,15 +827,10 @@ static int receive_data(enum port_type index, struct nozomi *dc) struct tty_struct *tty = tty_port_tty_get(&port->port); int i, ret; - if (unlikely(!tty)) { - DBG1("tty not open for port: %d?", index); - return 1; - } - read_mem32((u32 *) &size, addr, 4); /* DBG1( "%d bytes port: %d", size, index); */ - if (test_bit(TTY_THROTTLED, &tty->flags)) { + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { DBG1("No room in tty, don't read data, don't ack interrupt, " "disable interrupt"); @@ -858,10 +853,11 @@ static int receive_data(enum port_type index, struct nozomi *dc) tty_insert_flip_char(&port->port, buf[0], TTY_NORMAL); size = 0; } else if (size < RECEIVE_BUF_MAX) { - size -= tty_insert_flip_string(tty, (char *) buf, size); + size -= tty_insert_flip_string(&port->port, + (char *)buf, size); } else { - i = tty_insert_flip_string(tty, \ - (char *) buf, RECEIVE_BUF_MAX); + i = tty_insert_flip_string(&port->port, + (char *)buf, RECEIVE_BUF_MAX); size -= i; offset += i; } diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index be6a373601b7..3c285d398f38 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -120,7 +120,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) if (c > 0) { /* Stuff the data into the input queue of the other end */ - c = tty_insert_flip_string(to, buf, c); + c = tty_insert_flip_string(to->port, buf, c); /* And shovel */ if (c) { tty_flip_buffer_push(to); diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 7fca4022a8b2..e1257d17f5f0 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -698,7 +698,8 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, u32 pending, bool use_buf_b, bool readfifo) { - struct tty_struct *tty = uap->port.state->port.tty; + struct tty_port *port = &uap->port.state->port; + struct tty_struct *tty = port->tty; struct pl011_sgbuf *sgbuf = use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; struct device *dev = uap->dmarx.chan->device->dev; @@ -715,8 +716,7 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, * Note that tty_insert_flip_buf() tries to take as many chars * as it can. */ - dma_count = tty_insert_flip_string(uap->port.state->port.tty, - sgbuf->buf, pending); + dma_count = tty_insert_flip_string(port, sgbuf->buf, pending); /* Return buffer to device */ dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE); diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 922e85aeb63a..929567038c5a 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -781,7 +781,8 @@ static void atmel_rx_from_ring(struct uart_port *port) static void atmel_rx_from_dma(struct uart_port *port) { struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; struct atmel_dma_buffer *pdc; int rx_idx = atmel_port->pdc_rx_idx; unsigned int head; @@ -820,7 +821,8 @@ static void atmel_rx_from_dma(struct uart_port *port) */ count = head - tail; - tty_insert_flip_string(tty, pdc->buf + pdc->ofs, count); + tty_insert_flip_string(tport, pdc->buf + pdc->ofs, + count); dma_sync_single_for_device(port->dev, pdc->dma_addr, pdc->dma_size, DMA_FROM_DEVICE); diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index d12306625458..c82601d4dc53 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -2119,7 +2119,7 @@ static void flush_to_flip_buffer(struct e100_serial *info) while ((buffer = info->first_recv_buffer) != NULL) { unsigned int count = buffer->length; - tty_insert_flip_string(tty, buffer->buffer, count); + tty_insert_flip_string(&info->port, buffer->buffer, count); info->recv_cnt -= count; if (count == buffer->length) { diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 2b0b60ff7f01..54903ee5e5ab 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c @@ -762,7 +762,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) /* Block copy all but the last byte as this may have status */ if (count > 0) { first = icom_port->recv_buf[offset]; - tty_insert_flip_string(tty, icom_port->recv_buf + offset, count - 1); + tty_insert_flip_string(port, icom_port->recv_buf + offset, count - 1); } icount = &icom_port->uart_port.icount; diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 675d94ab0aff..bfb634ea8145 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -672,7 +672,7 @@ static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port); if (!tty) return; - tty_insert_flip_string(tty, chars, size); + tty_insert_flip_string(&ifx_dev->tty_port, chars, size); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c index d8f1d1d54471..0f25ce49c7f9 100644 --- a/drivers/tty/serial/ioc3_serial.c +++ b/drivers/tty/serial/ioc3_serial.c @@ -1415,7 +1415,8 @@ static int receive_chars(struct uart_port *the_port) read_count = do_read(the_port, ch, MAX_CHARS); if (read_count > 0) { flip = 1; - read_room = tty_insert_flip_string(tty, ch, read_count); + read_room = tty_insert_flip_string(&state->port, ch, + read_count); the_port->icount.rx += read_count; } spin_unlock_irqrestore(&the_port->lock, pflags); diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index 710ce87ffbeb..3b021b03ae56 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c @@ -2362,7 +2362,7 @@ static void receive_chars(struct uart_port *the_port) icount = &the_port->icount; read_count = do_read(the_port, ch, request_count); if (read_count > 0) { - tty_insert_flip_string(tty, ch, read_count); + tty_insert_flip_string(&state->port, ch, read_count); icount->rx += read_count; } } diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index ac1d36cb2032..c9ce00dd1f8a 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -640,7 +640,7 @@ void jsm_input(struct jsm_channel *ch) tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL); } } else { - tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ; + tty_insert_flip_string(port, ch->ch_rqueue + tail, s); } tail += s; n -= s; diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index 2c01344dc332..60d585ab4870 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c @@ -387,7 +387,8 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) struct hsu_dma_buffer *dbuf = &up->rxbuf; struct hsu_dma_chan *chan = up->rxc; struct uart_port *port = &up->port; - struct tty_struct *tty = port->state->port.tty; + struct tty_port *tport = &port->state->port; + struct tty_struct *tty = tport->tty; int count; if (!tty) @@ -423,7 +424,7 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) * explicitly set tail to 0. So head will * always be greater than tail. */ - tty_insert_flip_string(tty, dbuf->buf, count); + tty_insert_flip_string(tport, dbuf->buf, count); port->icount.rx += count; dma_sync_single_for_device(up->port.dev, dbuf->dma_addr, diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index 776431ff0190..3b8df7b93b73 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c @@ -374,7 +374,7 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) for (r = 0; w; r += usable, w -= usable) { usable = tty_buffer_request_room(tport, w); if (usable) { - tty_insert_flip_string(tty, buf + r, usable); + tty_insert_flip_string(tport, buf + r, usable); port->icount.rx += usable; } } diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index e4eb81a12793..cb787c0e279a 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -133,7 +133,7 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) port->icount.frame++; /* TODO: handle sysrq */ - tty_insert_flip_string(tty, (char *) &c, + tty_insert_flip_string(tport, (char *)&c, (count > 4) ? 4 : count); count -= 4; } diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index 6aa9d470ef54..11b7f5b2eb5f 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c @@ -961,7 +961,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, rx_count = msm_hs_read(uport, UARTDM_RX_TOTAL_SNAP_ADDR); if (0 != (uport->read_status_mask & CREAD)) { - retval = tty_insert_flip_string(tty, msm_uport->rx.buffer, + retval = tty_insert_flip_string(port, msm_uport->rx.buffer, rx_count); BUG_ON(retval != rx_count); } diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index fa31bc38b105..37a0046ef531 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -457,7 +457,8 @@ static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s); static void dma_rx_callback(void *arg) { struct mxs_auart_port *s = (struct mxs_auart_port *) arg; - struct tty_struct *tty = s->port.state->port.tty; + struct tty_port *port = &s->port.state->port; + struct tty_struct *tty = port->tty; int count; u32 stat; @@ -468,7 +469,7 @@ static void dma_rx_callback(void *arg) AUART_STAT_PERR | AUART_STAT_FERR); count = stat & AUART_STAT_RXCOUNT_MASK; - tty_insert_flip_string(tty, s->rx_dma_buf, count); + tty_insert_flip_string(port, s->rx_dma_buf, count); writel(stat, s->port.membase + AUART_STAT); tty_flip_buffer_push(tty); diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 4f1774be2a8c..967f1cb311f3 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -591,17 +591,17 @@ static void pch_uart_hal_set_break(struct eg20t_port *priv, int on) static int push_rx(struct eg20t_port *priv, const unsigned char *buf, int size) { - struct uart_port *port; + struct uart_port *port = &priv->port; + struct tty_port *tport = &port->state->port; struct tty_struct *tty; - port = &priv->port; - tty = tty_port_tty_get(&port->state->port); + tty = tty_port_tty_get(tport); if (!tty) { dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); return -EBUSY; } - tty_insert_flip_string(tty, buf, size); + tty_insert_flip_string(tport, buf, size); tty_flip_buffer_push(tty); tty_kref_put(tty); @@ -646,7 +646,7 @@ static int dma_push_rx(struct eg20t_port *priv, int size) if (!room) return room; - tty_insert_flip_string(tty, sg_virt(&priv->sg_rx), size); + tty_insert_flip_string(tport, sg_virt(&priv->sg_rx), size); port->icount.rx += room; tty_kref_put(tty); diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c index bbb102e3c035..defe92b19e16 100644 --- a/drivers/tty/serial/sunhv.c +++ b/drivers/tty/serial/sunhv.c @@ -72,7 +72,7 @@ static void transmit_chars_write(struct uart_port *port, struct circ_buf *xmit) } } -static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty) +static int receive_chars_getchar(struct uart_port *port) { int saw_console_brk = 0; int limit = 10000; @@ -115,7 +115,7 @@ static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty) return saw_console_brk; } -static int receive_chars_read(struct uart_port *port, struct tty_struct *tty) +static int receive_chars_read(struct uart_port *port) { int saw_console_brk = 0; int limit = 10000; @@ -152,12 +152,13 @@ static int receive_chars_read(struct uart_port *port, struct tty_struct *tty) for (i = 0; i < bytes_read; i++) uart_handle_sysrq_char(port, con_read_page[i]); - if (tty == NULL) + if (port->state == NULL) continue; port->icount.rx += bytes_read; - tty_insert_flip_string(tty, con_read_page, bytes_read); + tty_insert_flip_string(&port->state->port, con_read_page, + bytes_read); } return saw_console_brk; @@ -165,7 +166,7 @@ static int receive_chars_read(struct uart_port *port, struct tty_struct *tty) struct sunhv_ops { void (*transmit_chars)(struct uart_port *port, struct circ_buf *xmit); - int (*receive_chars)(struct uart_port *port, struct tty_struct *tty); + int (*receive_chars)(struct uart_port *port); }; static struct sunhv_ops bychar_ops = { @@ -187,7 +188,7 @@ static struct tty_struct *receive_chars(struct uart_port *port) if (port->state != NULL) /* Unopened serial console */ tty = port->state->port.tty; - if (sunhv_ops->receive_chars(port, tty)) + if (sunhv_ops->receive_chars(port)) sun_do_break(); return tty; diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 8d809a811e16..20dc2add27ba 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -419,7 +419,8 @@ static void acm_process_read_urb(struct acm *acm, struct urb *urb) if (!tty) return; - tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length); + tty_insert_flip_string(&acm->port, urb->transfer_buffer, + urb->actual_length); tty_flip_buffer_push(tty); tty_kref_put(tty); diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index d0f95482f40e..3560799d530a 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c @@ -495,12 +495,8 @@ static void gs_rx_push(unsigned long _port) req = list_first_entry(queue, struct usb_request, list); - /* discard data if tty was closed */ - if (!tty) - goto recycle; - /* leave data queued if tty was rx throttled */ - if (test_bit(TTY_THROTTLED, &tty->flags)) + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) break; switch (req->status) { @@ -533,7 +529,8 @@ static void gs_rx_push(unsigned long _port) size -= n; } - count = tty_insert_flip_string(tty, packet, size); + count = tty_insert_flip_string(&port->port, packet, + size); if (count) do_push = true; if (count != size) { @@ -546,7 +543,7 @@ static void gs_rx_push(unsigned long _port) } port->n_read = 0; } -recycle: + list_move(&req->list, &port->read_pool); port->read_started--; } diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 6d110a3bc7e7..3bb1f8f11fc8 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c @@ -119,9 +119,8 @@ static int aircable_probe(struct usb_serial *serial, return 0; } -static int aircable_process_packet(struct tty_struct *tty, - struct usb_serial_port *port, int has_headers, - char *packet, int len) +static int aircable_process_packet(struct usb_serial_port *port, + int has_headers, char *packet, int len) { if (has_headers) { len -= HCI_HEADER_LENGTH; @@ -132,7 +131,7 @@ static int aircable_process_packet(struct tty_struct *tty, return 0; } - tty_insert_flip_string(tty, packet, len); + tty_insert_flip_string(&port->port, packet, len); return len; } @@ -156,7 +155,7 @@ static void aircable_process_read_urb(struct urb *urb) count = 0; for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) { len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME); - count += aircable_process_packet(tty, port, has_headers, + count += aircable_process_packet(port, has_headers, &data[i], len); } diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 69a4fa1cee25..e6976a974472 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -343,7 +343,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) return; } if (urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 203358d7e7bc..498b5f0da639 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -256,7 +256,7 @@ static void send_to_tty(struct usb_serial_port *port, if (tty && actual_length) { usb_serial_debug_data(&port->dev, __func__, actual_length, data); - tty_insert_flip_string(tty, data, actual_length); + tty_insert_flip_string(&port->port, data, actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index b00110cd5689..3780f6a501b3 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -328,7 +328,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb) stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases where the USB serial is not a console anyway */ if (!port->port.console || !port->sysrq) - tty_insert_flip_string(tty, ch, urb->actual_length); + tty_insert_flip_string(&port->port, ch, urb->actual_length); else { for (i = 0; i < urb->actual_length; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 7b770c7f8b11..f96b91da964f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -232,7 +232,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength); static void process_rcvd_status(struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3); -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, +static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length); static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, @@ -1865,7 +1865,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, if (tty) { dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", __func__, rxLen, edge_serial->rxPort); - edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); + edge_tty_recv(edge_port->port, tty, buffer, rxLen); tty_kref_put(tty); } edge_port->icount.rx += rxLen; @@ -2017,14 +2017,14 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, * edge_tty_recv * this function passes data on to the tty flip buffer *****************************************************************************/ -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, +static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length) { int cnt; - cnt = tty_insert_flip_string(tty, data, length); + cnt = tty_insert_flip_string(&port->port, data, length); if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", + dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); } data += cnt; @@ -2090,7 +2090,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, struct tty_struct *tty = tty_port_tty_get(&edge_port->port->port); if (tty) { - edge_tty_recv(&edge_port->port->dev, tty, &data, 1); + edge_tty_recv(edge_port->port, tty, &data, 1); tty_kref_put(tty); } } diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 58184f3de686..1286a0b2e2b7 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -201,7 +201,7 @@ static int closing_wait = EDGE_CLOSING_WAIT; static bool ignore_cpu_rev; static int default_uart_mode; /* RS232 */ -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, +static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length); static void stop_read(struct edgeport_port *edge_port); @@ -1557,7 +1557,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, if (lsr_data) { tty = tty_port_tty_get(&edge_port->port->port); if (tty) { - edge_tty_recv(&edge_port->port->dev, tty, &data, 1); + edge_tty_recv(edge_port->port, tty, &data, 1); tty_kref_put(tty); } } @@ -1722,7 +1722,8 @@ static void edge_bulk_in_callback(struct urb *urb) dev_dbg(dev, "%s - close pending, dropping data on the floor\n", __func__); else - edge_tty_recv(dev, tty, data, urb->actual_length); + edge_tty_recv(edge_port->port, tty, data, + urb->actual_length); edge_port->icount.rx += urb->actual_length; } tty_kref_put(tty); @@ -1740,14 +1741,14 @@ exit: dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); } -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, +static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length) { int queued; - queued = tty_insert_flip_string(tty, data, length); + queued = tty_insert_flip_string(&port->port, data, length); if (queued < length) - dev_err(dev, "%s - dropping data, %d bytes lost\n", + dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", __func__, length - queued); tty_flip_buffer_push(tty); } diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index e24e2d4f4c1b..171dae1f4a62 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -305,7 +305,7 @@ static void ir_process_read_urb(struct urb *urb) tty = tty_port_tty_get(&port->port); if (!tty) return; - tty_insert_flip_string(tty, data + 1, urb->actual_length - 1); + tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 1e1fbed65ef2..dd0d910730c7 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -596,7 +596,7 @@ static void read_buf_callback(struct urb *urb) if (data == NULL) dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); if (tty && urb->actual_length && data) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index a4f5caebda43..14a219ba4ee6 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -472,7 +472,8 @@ static void usa28_indat_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, + urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); @@ -688,7 +689,7 @@ static void usa49_indat_callback(struct urb *urb) /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no error on any byte */ - tty_insert_flip_string(tty, data + 1, + tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); } else { /* some bytes had errors, every byte has status */ @@ -816,7 +817,8 @@ static void usa90_indat_callback(struct urb *urb) otherwise looks like usa26 data format */ if (p_priv->baud > 57600) - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, + urb->actual_length); else { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 41b01092af07..334b1a295c6b 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -166,7 +166,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) tty = tty_port_tty_get(&port->port); /* rest of message is rx data */ if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data + 1, + tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); tty_flip_buffer_push(tty); } diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index fc9e14a1e9b3..8ee0825ad700 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -411,7 +411,7 @@ static void klsi_105_process_read_urb(struct urb *urb) len = urb->actual_length - KLSI_HDR_LEN; } - tty_insert_flip_string(tty, data + KLSI_HDR_LEN, len); + tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index b747ba615d0b..135c8b4b26f7 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -353,7 +353,7 @@ static void kobil_read_int_callback(struct urb *urb) */ /* END DEBUG */ - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index b6911757c855..ba20bb037b28 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -563,7 +563,7 @@ static void mct_u232_read_int_callback(struct urb *urb) if (urb->actual_length) { tty = tty_port_tty_get(&port->port); if (tty) { - tty_insert_flip_string(tty, data, + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 3d258448c29a..6264f3974ea7 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c @@ -127,7 +127,7 @@ static void metrousb_read_int_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty && urb->actual_length) { /* Loop through the data copying each byte to the tty layer. */ - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); /* Force the data to the tty layer. */ tty_flip_buffer_push(tty); diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index f57a6b1fe787..22818fb765e0 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -915,7 +915,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 66d9e088d9d9..3ddd7a1f7ff3 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -773,9 +773,10 @@ static void mos7840_bulk_in_callback(struct urb *urb) usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); if (urb->actual_length) { - tty = tty_port_tty_get(&mos7840_port->port->port); + struct tty_port *tport = &mos7840_port->port->port; + tty = tty_port_tty_get(tport); if (tty) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(tport, data, urb->actual_length); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 1566f8f500ae..0d96a1a7b9e5 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c @@ -57,7 +57,7 @@ static void navman_read_int_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 7818af931a48..338191bae5a3 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -176,8 +176,9 @@ static void omninet_read_bulk_callback(struct urb *urb) if (urb->actual_length && header->oh_len) { struct tty_struct *tty = tty_port_tty_get(&port->port); if (tty) { - tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET, - header->oh_len); + tty_insert_flip_string(&port->port, + data + OMNINET_DATAOFFSET, + header->oh_len); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index c6bfb83efb1e..d3b74e50aff1 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -57,7 +57,7 @@ static void opticon_process_data_packet(struct usb_serial_port *port, if (!tty) return; - tty_insert_flip_string(tty, buf, len); + tty_insert_flip_string(&port->port, buf, len); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index d217fd6ee43f..7a53fe9f3af3 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c @@ -837,7 +837,7 @@ static void oti6858_read_bulk_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty != NULL && urb->actual_length > 0) { - tty_insert_flip_string(tty, data, urb->actual_length); + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 1e67fd89e346..5dccc4f957df 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -698,7 +698,7 @@ void qt2_process_read_urb(struct urb *urb) break; case QT2_CONTROL_ESCAPE: tty_buffer_request_room(&port->port, 2); - tty_insert_flip_string(tty, ch, 2); + tty_insert_flip_string(&port->port, ch, 2); i += 2; escapeflag = true; break; @@ -712,10 +712,8 @@ void qt2_process_read_urb(struct urb *urb) continue; } - if (tty) { - tty_buffer_request_room(&port->port, 1); - tty_insert_flip_string(tty, ch, 1); - } + tty_buffer_request_room(&port->port, 1); + tty_insert_flip_string(&port->port, ch, 1); } if (tty) { diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index c949ce6ef0c6..ad12e9e2c7ee 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -235,7 +235,7 @@ static void safe_process_read_urb(struct urb *urb) dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); length = actual_length; out: - tty_insert_flip_string(tty, data, length); + tty_insert_flip_string(&port->port, data, length); tty_flip_buffer_push(tty); err: tty_kref_put(tty); diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index af06f2f5f38b..64e53fda149b 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -583,7 +583,7 @@ static void sierra_indat_callback(struct urb *urb) if (urb->actual_length) { tty = tty_port_tty_get(&port->port); if (tty) { - tty_insert_flip_string(tty, data, + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 701fffa8431f..2ffa6ae3b5ed 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c @@ -84,7 +84,8 @@ static void symbol_int_callback(struct urb *urb) */ tty = tty_port_tty_get(&port->port); if (tty) { - tty_insert_flip_string(tty, &data[1], data_length); + tty_insert_flip_string(&port->port, &data[1], + data_length); tty_flip_buffer_push(tty); tty_kref_put(tty); } diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index f2530d2ef3c4..05077e3c7631 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -121,7 +121,7 @@ static void ti_interrupt_callback(struct urb *urb); static void ti_bulk_in_callback(struct urb *urb); static void ti_bulk_out_callback(struct urb *urb); -static void ti_recv(struct device *dev, struct tty_struct *tty, +static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length); static void ti_send(struct ti_port *tport); static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); @@ -1155,8 +1155,7 @@ static void ti_bulk_in_callback(struct urb *urb) dev_dbg(dev, "%s - port closed, dropping data\n", __func__); else - ti_recv(&urb->dev->dev, tty, - urb->transfer_buffer, + ti_recv(port, tty, urb->transfer_buffer, urb->actual_length); spin_lock(&tport->tp_lock); tport->tp_icount.rx += urb->actual_length; @@ -1210,15 +1209,15 @@ static void ti_bulk_out_callback(struct urb *urb) } -static void ti_recv(struct device *dev, struct tty_struct *tty, +static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, unsigned char *data, int length) { int cnt; do { - cnt = tty_insert_flip_string(tty, data, length); + cnt = tty_insert_flip_string(&port->port, data, length); if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", + dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); if (cnt == 0) break; diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 01c94aada56c..293b460030cb 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -291,7 +291,7 @@ static void usb_wwan_indat_callback(struct urb *urb) tty = tty_port_tty_get(&port->port); if (tty) { if (urb->actual_length) { - tty_insert_flip_string(tty, data, + tty_insert_flip_string(&port->port, data, urb->actual_length); tty_flip_buffer_push(tty); } else diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index f9acb578c6ad..5cb694aba322 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -24,9 +24,10 @@ static inline int tty_insert_flip_char(struct tty_port *port, return tty_insert_flip_string_flags(port, &ch, &flag, 1); } -static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) +static inline int tty_insert_flip_string(struct tty_port *port, + const unsigned char *chars, size_t size) { - return tty_insert_flip_string_fixed_flag(tty->port, chars, TTY_NORMAL, size); + return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size); } #endif /* _LINUX_TTY_FLIP_H */ diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index bd6fd0f43d2b..cbec3b642871 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -556,7 +556,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); - tty_insert_flip_string(tty, skb->data, skb->len); + tty_insert_flip_string(&dev->port, skb->data, skb->len); tty_flip_buffer_push(tty); kfree_skb(skb); @@ -633,7 +633,8 @@ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) rfcomm_dlc_lock(dev->dlc); while ((skb = skb_dequeue(&dev->pending))) { - inserted += tty_insert_flip_string(tty, skb->data, skb->len); + inserted += tty_insert_flip_string(&dev->port, skb->data, + skb->len); kfree_skb(skb); } diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index a68c88cdec6e..14b08e376f9f 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -1141,7 +1141,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap, * Use flip buffer functions since the code may be called from interrupt * context */ - tty_insert_flip_string(tty, skb->data, skb->len); + tty_insert_flip_string(&self->port, skb->data, skb->len); tty_flip_buffer_push(tty); tty_kref_put(tty); -- cgit v1.2.3 From d6c53c0e9bd0a83f9f9ddbc9fd80141a54d83896 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:05 +0100 Subject: TTY: move low_latency to tty_port One point is to have less places where we actually need tty pointer. The other is that low_latency is bound to buffer processing and buffers are now in tty_port. So it makes sense to move low_latency to tty_port too. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/ia64/hp/sim/simserial.c | 2 +- arch/mn10300/kernel/mn10300-serial.c | 6 +++--- drivers/char/pcmcia/synclink_cs.c | 2 +- drivers/isdn/gigaset/interface.c | 2 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/irda/irtty-sir.c | 2 +- drivers/s390/char/con3215.c | 2 +- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +- drivers/s390/char/tty3270.c | 4 ++-- drivers/tty/amiserial.c | 4 ++-- drivers/tty/ipwireless/tty.c | 2 +- drivers/tty/mxser.c | 2 +- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +- drivers/tty/serial/crisv10.c | 4 ++-- drivers/tty/serial/ifx6x60.c | 2 +- drivers/tty/serial/ioc3_serial.c | 2 +- drivers/tty/serial/ioc4_serial.c | 2 +- drivers/tty/serial/max3100.c | 2 +- drivers/tty/serial/mpsc.c | 2 +- drivers/tty/serial/mrst_max3110.c | 2 +- drivers/tty/serial/msm_serial_hs.c | 2 +- drivers/tty/serial/serial_core.c | 7 +++---- drivers/tty/synclink.c | 2 +- drivers/tty/synclink_gt.c | 2 +- drivers/tty/synclinkmp.c | 2 +- drivers/tty/tty_buffer.c | 9 +++++---- include/linux/tty.h | 5 +++-- net/irda/ircomm/ircomm_tty.c | 2 +- 29 files changed, 42 insertions(+), 41 deletions(-) (limited to 'drivers') diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index f8ae5d8eb106..942022a5bc86 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -436,7 +436,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) struct tty_port *port = &info->port; tty->driver_data = info; - tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; /* * figure out which console to use (should be one already) diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index 54ef40ceaaed..ae61bd692b4b 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -537,7 +537,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) count = CIRC_CNT(port->rx_inp, port->rx_outp, MNSC_BUFFER_SIZE); count = tty_buffer_request_room(port, count); if (count == 0) { - if (!tty->low_latency) + if (!port->low_latency) tty_flip_buffer_push(tty); return; } @@ -546,7 +546,7 @@ try_again: /* pull chars out of the hat */ ix = ACCESS_ONCE(port->rx_outp); if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { - if (push && !tty->low_latency) + if (push && !port->low_latency) tty_flip_buffer_push(tty); return; } @@ -678,7 +678,7 @@ insert: count--; if (count <= 0) { - if (!tty->low_latency) + if (!port->low_latency) tty_flip_buffer_push(tty); return; } diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 9bdfe27b2413..92dc7327c7aa 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -2522,7 +2522,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) goto cleanup; } - tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); if (info->netcount) { diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index dd2a57eca2e7..6dcecd40a819 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -164,7 +164,7 @@ static int if_open(struct tty_struct *tty, struct file *filp) if (cs->port.count == 1) { tty_port_tty_set(&cs->port, tty); - tty->low_latency = 1; + cs->port.low_latency = 1; } mutex_unlock(&cs->mutex); diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 5de74e762021..666891a9a248 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -91,7 +91,7 @@ static inline void update_tty_status(struct ser_device *ser) ser->tty->hw_stopped << 4 | ser->tty->flow_stopped << 3 | ser->tty->packet << 2 | - ser->tty->low_latency << 1 | + ser->tty->port->low_latency << 1 | ser->tty->warned; } static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c index 6e4d4b62c9a8..a41267197839 100644 --- a/drivers/net/irda/irtty-sir.c +++ b/drivers/net/irda/irtty-sir.c @@ -210,7 +210,7 @@ static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t * been received, which can now be decapsulated and delivered for * further processing * - * calling context depends on underlying driver and tty->low_latency! + * calling context depends on underlying driver and tty->port->low_latency! * for example (low_latency: 1 / 0): * serial.c: uart-interrupt / softint * usbserial: urb-complete-interrupt / softint diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 4c6743dd5357..41b75c5ae0d5 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -968,7 +968,7 @@ static int tty3215_open(struct tty_struct *tty, struct file * filp) tty_port_tty_set(&raw->port, tty); - tty->low_latency = 0; /* don't use bottom half for pushing chars */ + raw->port.low_latency = 0; /* don't use bottom half for pushing chars */ /* * Start up 3215 device */ diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 3ffddbb53d2f..19b7c516c07d 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -65,7 +65,7 @@ sclp_tty_open(struct tty_struct *tty, struct file *filp) { tty_port_tty_set(&sclp_port, tty); tty->driver_data = NULL; - tty->low_latency = 0; + sclp_port.low_latency = 0; return 0; } diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index b5507f199b24..0eca99b98712 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -495,7 +495,7 @@ sclp_vt220_open(struct tty_struct *tty, struct file *filp) { if (tty->count == 1) { tty_port_tty_set(&sclp_vt220_port, tty); - tty->low_latency = 0; + sclp_vt220_port.low_latency = 0; if (!tty->winsize.ws_row && !tty->winsize.ws_col) { tty->winsize.ws_row = 24; tty->winsize.ws_col = 80; diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 43ea0593bdb0..3860e796b65f 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c @@ -860,7 +860,7 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) tty->driver_data = tp; tty->winsize.ws_row = tp->view.rows - 2; tty->winsize.ws_col = tp->view.cols; - tty->low_latency = 0; + tp->port.low_latency = 0; /* why to reassign? */ tty_port_tty_set(&tp->port, tty); tp->inattr = TF_INPUT; @@ -893,7 +893,7 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) } tty_port_tty_set(&tp->port, tty); - tty->low_latency = 0; + tp->port.low_latency = 0; tty->winsize.ws_row = tp->view.rows - 2; tty->winsize.ws_col = tp->view.cols; diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2e670d0c5366..2d1357acbc23 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -1099,7 +1099,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, state->custom_divisor = new_serial.custom_divisor; port->close_delay = new_serial.close_delay * HZ/100; port->closing_wait = new_serial.closing_wait * HZ/100; - tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; check_and_exit: if (port->flags & ASYNC_INITIALIZED) { @@ -1528,7 +1528,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) if (serial_paranoia_check(info, tty->name, "rs_open")) return -ENODEV; - tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; retval = startup(tty, info); if (retval) { diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index a3ad5e14cbef..c43da7445432 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -106,7 +106,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp) tty->port.tty = linux_tty; linux_tty->driver_data = tty; - linux_tty->low_latency = 1; + tty->port.low_latency = 1; if (tty->tty_type == TTYTYPE_MODEM) ipwireless_ppp_open(tty->network); diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 450c4507cb5b..e9cdfdfe06e9 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -1264,7 +1264,7 @@ static int mxser_set_serial_info(struct tty_struct *tty, (new_serial.flags & ASYNC_FLAGS)); port->close_delay = new_serial.close_delay * HZ / 100; port->closing_wait = new_serial.closing_wait * HZ / 100; - tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && (new_serial.baud_base != info->baud_base || new_serial.custom_divisor != diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 108122f8f3c2..0bb24378a3c0 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -508,7 +508,7 @@ static void cpm_uart_set_termios(struct uart_port *port, baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); if (baud < HW_BUF_SPD_THRESHOLD || - (pinfo->port.state && pinfo->port.state->port.tty->low_latency)) + (pinfo->port.state && pinfo->port.state->port.low_latency)) pinfo->rx_fifosize = 1; else pinfo->rx_fifosize = RX_BUF_SIZE; diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index c82601d4dc53..52449adc09ac 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -3462,7 +3462,7 @@ set_serial_info(struct e100_serial *info, info->type = new_serial.type; info->close_delay = new_serial.close_delay; info->closing_wait = new_serial.closing_wait; - info->port.tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->port.low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; check_and_exit: if (info->flags & ASYNC_INITIALIZED) { @@ -4106,7 +4106,7 @@ rs_open(struct tty_struct *tty, struct file * filp) tty->driver_data = info; info->port.tty = tty; - tty->low_latency = !!(info->flags & ASYNC_LOW_LATENCY); + info->port.low_latency = !!(info->flags & ASYNC_LOW_LATENCY); /* * If the port is in the middle of closing, bail out now diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index bfb634ea8145..4bc6e47890b4 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -615,7 +615,7 @@ static int ifx_port_activate(struct tty_port *port, struct tty_struct *tty) tty->driver_data = ifx_dev; /* allows flip string push from int context */ - tty->low_latency = 1; + port->low_latency = 1; /* set flag to allows data transfer */ set_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags); diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c index 0f25ce49c7f9..edbdc4e45075 100644 --- a/drivers/tty/serial/ioc3_serial.c +++ b/drivers/tty/serial/ioc3_serial.c @@ -1000,7 +1000,7 @@ ioc3_change_speed(struct uart_port *the_port, the_port->ignore_status_mask = N_ALL_INPUT; - state->port.tty->low_latency = 1; + state->port.low_latency = 1; if (iflag & IGNPAR) the_port->ignore_status_mask &= ~(N_PARITY_ERROR diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index 3b021b03ae56..86f64ed89b45 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c @@ -1740,7 +1740,7 @@ ioc4_change_speed(struct uart_port *the_port, the_port->ignore_status_mask = N_ALL_INPUT; - state->port.tty->low_latency = 1; + state->port.low_latency = 1; if (iflag & IGNPAR) the_port->ignore_status_mask &= ~(N_PARITY_ERROR diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 7ce3197087bb..e238e80cd981 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -530,7 +530,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, MAX3100_STATUS_OE; /* we are sending char from a workqueue so enable */ - s->port.state->port.tty->low_latency = 1; + s->port.state->port.low_latency = 1; if (s->poll_time > 0) del_timer_sync(&s->timer); diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c index 4bcbc66c48c4..6f2d2ceb326a 100644 --- a/drivers/tty/serial/mpsc.c +++ b/drivers/tty/serial/mpsc.c @@ -970,7 +970,7 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) #endif /* Following use of tty struct directly is deprecated */ if (tty_buffer_request_room(port, bytes_in) < bytes_in) { - if (tty->low_latency) + if (port->low_latency) tty_flip_buffer_push(tty); /* * If this failed then we will throw away the bytes diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index 3b8df7b93b73..4632db7a24b7 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c @@ -495,7 +495,7 @@ static int serial_m3110_startup(struct uart_port *port) | WC_BAUD_DR2; /* as we use thread to handle tx/rx, need set low latency */ - port->state->port.tty->low_latency = 1; + port->state->port.low_latency = 1; if (max->irq) { max->read_thread = NULL; diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index 11b7f5b2eb5f..c356ffff3c71 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c @@ -1400,7 +1400,7 @@ static int msm_hs_startup(struct uart_port *uport) /* do not let tty layer execute RX in global workqueue, use a * dedicated workqueue managed by this driver */ - uport->state->port.tty->low_latency = 1; + uport->state->port.low_latency = 1; /* turn on uart clk */ ret = msm_hs_init_clk_locked(uport); diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 675343a20f24..b5c4e64f2990 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -867,9 +867,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, port->closing_wait = closing_wait; if (new_info->xmit_fifo_size) uport->fifosize = new_info->xmit_fifo_size; - if (port->tty) - port->tty->low_latency = - (uport->flags & UPF_LOW_LATENCY) ? 1 : 0; + port->low_latency = (uport->flags & UPF_LOW_LATENCY) ? 1 : 0; check_and_exit: retval = 0; @@ -1565,7 +1563,8 @@ static int uart_open(struct tty_struct *tty, struct file *filp) */ tty->driver_data = state; state->uart_port->state = state; - tty->low_latency = (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0; + state->port.low_latency = + (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0; tty_port_tty_set(port, tty); /* diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 33656b35db05..2f6967d61a80 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -3415,7 +3415,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) goto cleanup; } - info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); if (info->netcount) { diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 473d7406db83..9a0358a1e0dd 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -682,7 +682,7 @@ static int open(struct tty_struct *tty, struct file *filp) } mutex_lock(&info->port.mutex); - info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); if (info->netcount) { diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index f5794f3d840f..419f58ff4a13 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -761,7 +761,7 @@ static int open(struct tty_struct *tty, struct file *filp) goto cleanup; } - info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); if (info->netcount) { diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 31873e42602a..1bfe97a8e2eb 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -364,7 +364,7 @@ void tty_schedule_flip(struct tty_struct *tty) { struct tty_bufhead *buf = &tty->port->buf; unsigned long flags; - WARN_ON(tty->low_latency); + WARN_ON(tty->port->low_latency); spin_lock_irqsave(&buf->lock, flags); if (buf->tail != NULL) @@ -538,7 +538,7 @@ static void flush_to_ldisc(struct work_struct *work) */ void tty_flush_to_ldisc(struct tty_struct *tty) { - if (!tty->low_latency) + if (!tty->port->low_latency) flush_work(&tty->port->buf.work); } @@ -547,7 +547,8 @@ void tty_flush_to_ldisc(struct tty_struct *tty) * @tty: tty to push * * Queue a push of the terminal flip buffers to the line discipline. This - * function must not be called from IRQ context if tty->low_latency is set. + * function must not be called from IRQ context if port->low_latency is + * set. * * In the event of the queue being busy for flipping the work will be * held off and retried later. @@ -565,7 +566,7 @@ void tty_flip_buffer_push(struct tty_struct *tty) buf->tail->commit = buf->tail->used; spin_unlock_irqrestore(&buf->lock, flags); - if (tty->low_latency) + if (tty->port->low_latency) flush_to_ldisc(&buf->work); else schedule_work(&buf->work); diff --git a/include/linux/tty.h b/include/linux/tty.h index 8db1b569c37a..f16a47a13a09 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -202,7 +202,8 @@ struct tty_port { unsigned long iflags; /* TTYP_ internal flags */ #define TTYP_FLUSHING 1 /* Flushing to ldisc in progress */ #define TTYP_FLUSHPENDING 2 /* Queued buffer flush pending */ - unsigned char console:1; /* port is a console */ + unsigned char console:1, /* port is a console */ + low_latency:1; /* direct buffer flush */ struct mutex mutex; /* Locking */ struct mutex buf_mutex; /* Buffer alloc lock */ unsigned char *xmit_buf; /* Optional buffer */ @@ -254,7 +255,7 @@ struct tty_struct { int count; struct winsize winsize; /* termios mutex */ unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; - unsigned char low_latency:1, warned:1; + unsigned char warned:1; unsigned char ctrl_status; /* ctrl_lock */ unsigned int receive_room; /* Bytes free for queue */ diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 14b08e376f9f..2491f6f53871 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -452,7 +452,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) self->line, self->port.count); /* Not really used by us, but lets do it anyway */ - tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; + self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; /* * If the port is the middle of closing, bail out now -- cgit v1.2.3 From 2e124b4a390ca85325fae75764bef92f0547fa25 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:06 +0100 Subject: TTY: switch tty_flip_buffer_push Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. Now, the one where most of tty_port_tty_get gets removed: tty_flip_buffer_push. IOW we also closed all the races in drivers not using tty_port_tty_get at all yet. Also we move tty_flip_buffer_push declaration from include/linux/tty.h to include/linux/tty_flip.h to all others while we are changing it anyway. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/ia64/hp/sim/simserial.c | 18 ++------- arch/mn10300/kernel/mn10300-serial.c | 7 ++-- arch/parisc/kernel/pdc_cons.c | 8 +--- arch/um/drivers/chan.h | 3 +- arch/um/drivers/chan_kern.c | 14 +++---- arch/um/drivers/line.c | 7 ++-- arch/xtensa/platforms/iss/console.c | 9 ++--- drivers/char/pcmcia/synclink_cs.c | 14 ++----- drivers/ipack/devices/ipoctal.c | 14 ++----- drivers/isdn/gigaset/interface.c | 10 +---- drivers/isdn/i4l/isdn_tty.c | 39 ++++++++----------- drivers/mmc/card/sdio_uart.c | 14 ++----- drivers/net/usb/hso.c | 31 ++++++++------- drivers/s390/char/con3215.c | 4 +- drivers/s390/char/sclp_tty.c | 4 +- drivers/s390/char/sclp_vt220.c | 8 +--- drivers/staging/ccg/u_serial.c | 11 ++---- drivers/staging/dgrp/dgrp_net_ops.c | 4 +- drivers/staging/fwserial/fwserial.c | 41 ++++++++------------ drivers/staging/serqt_usb2/serqt_usb2.c | 9 ++--- drivers/tty/amiserial.c | 5 +-- drivers/tty/bfin_jtag_comm.c | 22 +++++------ drivers/tty/ehv_bytechan.c | 9 +---- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 2 +- drivers/tty/hvc/hvsi.c | 6 +-- drivers/tty/ipwireless/tty.c | 8 +--- drivers/tty/isicom.c | 4 +- drivers/tty/mxser.c | 2 +- drivers/tty/n_gsm.c | 58 ++++++++++++++--------------- drivers/tty/nozomi.c | 14 +++---- drivers/tty/pty.c | 2 +- drivers/tty/rocket.c | 25 ++++++------- drivers/tty/serial/21285.c | 3 +- drivers/tty/serial/8250/8250.c | 3 +- drivers/tty/serial/altera_jtaguart.c | 2 +- drivers/tty/serial/altera_uart.c | 2 +- drivers/tty/serial/amba-pl010.c | 3 +- drivers/tty/serial/amba-pl011.c | 7 +--- drivers/tty/serial/apbuart.c | 3 +- drivers/tty/serial/ar933x_uart.c | 7 +--- drivers/tty/serial/arc_uart.c | 8 +--- drivers/tty/serial/atmel_serial.c | 5 +-- drivers/tty/serial/bcm63xx_uart.c | 4 +- drivers/tty/serial/bfin_sport_uart.c | 4 +- drivers/tty/serial/bfin_uart.c | 10 ++--- drivers/tty/serial/clps711x.c | 8 +--- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 3 +- drivers/tty/serial/crisv10.c | 17 +-------- drivers/tty/serial/dz.c | 4 +- drivers/tty/serial/efm32-uart.c | 8 +--- drivers/tty/serial/icom.c | 3 +- drivers/tty/serial/ifx6x60.c | 6 +-- drivers/tty/serial/imx.c | 3 +- drivers/tty/serial/ioc3_serial.c | 6 +-- drivers/tty/serial/ioc4_serial.c | 6 +-- drivers/tty/serial/jsm/jsm_tty.c | 2 +- drivers/tty/serial/kgdb_nmi.c | 10 +---- drivers/tty/serial/lantiq.c | 15 +++----- drivers/tty/serial/lpc32xx_hs.c | 16 +------- drivers/tty/serial/m32r_sio.c | 3 +- drivers/tty/serial/max3100.c | 8 ++-- drivers/tty/serial/max310x.c | 8 +--- drivers/tty/serial/mcf.c | 2 +- drivers/tty/serial/mfd.c | 12 +----- drivers/tty/serial/mpc52xx_uart.c | 3 +- drivers/tty/serial/mpsc.c | 5 +-- drivers/tty/serial/mrst_max3110.c | 11 +----- drivers/tty/serial/msm_serial.c | 6 +-- drivers/tty/serial/msm_serial_hs.c | 3 +- drivers/tty/serial/msm_smd_tty.c | 2 +- drivers/tty/serial/mux.c | 6 +-- drivers/tty/serial/mxs-auart.c | 6 +-- drivers/tty/serial/netx-serial.c | 4 +- drivers/tty/serial/nwpserial.c | 3 +- drivers/tty/serial/omap-serial.c | 3 +- drivers/tty/serial/pch_uart.c | 19 +--------- drivers/tty/serial/pmac_zilog.c | 30 +++++++-------- drivers/tty/serial/pnx8xxx_uart.c | 3 +- drivers/tty/serial/pxa.c | 3 +- drivers/tty/serial/sa1100.c | 3 +- drivers/tty/serial/samsung.c | 3 +- drivers/tty/serial/sb1250-duart.c | 2 +- drivers/tty/serial/sc26xx.c | 27 ++++++-------- drivers/tty/serial/sccnxp.c | 8 +--- drivers/tty/serial/serial_ks8695.c | 3 +- drivers/tty/serial/serial_txx9.c | 3 +- drivers/tty/serial/sh-sci.c | 18 +++------ drivers/tty/serial/sirfsoc_uart.c | 8 +--- drivers/tty/serial/sn_console.c | 12 ++---- drivers/tty/serial/sunhv.c | 16 ++++---- drivers/tty/serial/sunsab.c | 20 ++++------ drivers/tty/serial/sunsu.c | 13 ++----- drivers/tty/serial/sunzilog.c | 28 ++++++-------- drivers/tty/serial/timbuart.c | 2 +- drivers/tty/serial/uartlite.c | 2 +- drivers/tty/serial/ucc_uart.c | 3 +- drivers/tty/serial/vr41xx_siu.c | 4 +- drivers/tty/serial/vt8500_serial.c | 12 +----- drivers/tty/serial/xilinx_uartps.c | 14 ++----- drivers/tty/serial/zs.c | 2 +- drivers/tty/synclink.c | 5 +-- drivers/tty/synclink_gt.c | 5 +-- drivers/tty/synclinkmp.c | 4 +- drivers/tty/tty_buffer.c | 8 ++-- drivers/usb/class/cdc-acm.c | 10 +---- drivers/usb/gadget/u_serial.c | 4 +- drivers/usb/serial/aircable.c | 8 +--- drivers/usb/serial/ark3116.c | 8 +--- drivers/usb/serial/belkin_sa.c | 8 +--- drivers/usb/serial/cyberjack.c | 9 +---- drivers/usb/serial/cypress_m8.c | 4 +- drivers/usb/serial/digi_acceleport.c | 8 +--- drivers/usb/serial/f81232.c | 8 +--- drivers/usb/serial/ftdi_sio.c | 8 +--- drivers/usb/serial/garmin_gps.c | 7 +--- drivers/usb/serial/generic.c | 8 +--- drivers/usb/serial/io_edgeport.c | 35 +++++++---------- drivers/usb/serial/io_ti.c | 27 +++++--------- drivers/usb/serial/ir-usb.c | 7 +--- drivers/usb/serial/iuu_phoenix.c | 7 +--- drivers/usb/serial/keyspan.c | 31 ++++----------- drivers/usb/serial/keyspan_pda.c | 7 +--- drivers/usb/serial/kl5kusb105.c | 8 +--- drivers/usb/serial/kobil_sct.c | 7 +--- drivers/usb/serial/mct_u232.c | 11 ++---- drivers/usb/serial/metro-usb.c | 7 +--- drivers/usb/serial/mos7720.c | 7 +--- drivers/usb/serial/mos7840.c | 9 +---- drivers/usb/serial/navman.c | 7 +--- drivers/usb/serial/omninet.c | 11 ++---- drivers/usb/serial/opticon.c | 9 +---- drivers/usb/serial/oti6858.c | 7 +--- drivers/usb/serial/pl2303.c | 8 +--- drivers/usb/serial/quatech2.c | 19 +--------- drivers/usb/serial/safe_serial.c | 13 ++----- drivers/usb/serial/sierra.c | 17 +++------ drivers/usb/serial/spcp8x5.c | 18 ++++----- drivers/usb/serial/ssu100.c | 23 ++---------- drivers/usb/serial/symbolserial.c | 10 +---- drivers/usb/serial/ti_usb_3410_5052.c | 39 ++++++++----------- drivers/usb/serial/usb_wwan.c | 17 +++------ include/linux/tty.h | 1 - include/linux/tty_flip.h | 1 + net/bluetooth/rfcomm/tty.c | 16 +++----- net/irda/ircomm/ircomm_tty.c | 4 +- 146 files changed, 446 insertions(+), 988 deletions(-) (limited to 'drivers') diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index 942022a5bc86..da2f319fb71d 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -53,9 +53,8 @@ struct tty_driver *hp_simserial_driver; static struct console *console; -static void receive_chars(struct tty_struct *tty) +static void receive_chars(struct tty_port *port) { - struct tty_port *port = tty->port; unsigned char ch; static unsigned char seen_esc = 0; @@ -85,7 +84,7 @@ static void receive_chars(struct tty_struct *tty) if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) break; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } /* @@ -94,18 +93,9 @@ static void receive_chars(struct tty_struct *tty) static irqreturn_t rs_interrupt_single(int irq, void *dev_id) { struct serial_state *info = dev_id; - struct tty_struct *tty = tty_port_tty_get(&info->port); - if (!tty) { - printk(KERN_INFO "%s: tty=0 problem\n", __func__); - return IRQ_NONE; - } - /* - * pretty simple in our case, because we only get interrupts - * on inbound traffic - */ - receive_chars(tty); - tty_kref_put(tty); + receive_chars(&info->port); + return IRQ_HANDLED; } diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index ae61bd692b4b..1dd20dbfd098 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -525,7 +525,6 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) { struct uart_icount *icount = &port->uart.icount; struct tty_port *port = &port->uart.state->port; - struct tty_struct *tty = port->tty; unsigned ix; int count; u8 st, ch, push, status, overrun; @@ -538,7 +537,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) count = tty_buffer_request_room(port, count); if (count == 0) { if (!port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } @@ -547,7 +546,7 @@ try_again: ix = ACCESS_ONCE(port->rx_outp); if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { if (push && !port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } @@ -679,7 +678,7 @@ insert: count--; if (count <= 0) { if (!port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 4d92a379eb21..d5cae55195ec 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c @@ -138,10 +138,6 @@ static const struct tty_operations pdc_console_tty_ops = { static void pdc_console_poll(unsigned long unused) { int data, count = 0; - struct tty_struct *tty = tty_port_tty_get(&tty_port); - - if (!tty) - return; while (1) { data = pdc_console_poll_key(NULL); @@ -152,9 +148,7 @@ static void pdc_console_poll(unsigned long unused) } if (count) - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&tty_port); if (pdc_cons.flags & CON_ENABLED) mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h index 02b5a76e98d9..78f1b8999964 100644 --- a/arch/um/drivers/chan.h +++ b/arch/um/drivers/chan.h @@ -27,8 +27,7 @@ struct chan { void *data; }; -extern void chan_interrupt(struct line *line, - struct tty_struct *tty, int irq); +extern void chan_interrupt(struct line *line, int irq); extern int parse_chan_pair(char *str, struct line *line, int device, const struct chan_opts *opts, char **error_out); extern int write_chan(struct chan *chan, const char *buf, int len, diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 795bd8102205..15c553c239a1 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -131,11 +131,9 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty) static void line_timer_cb(struct work_struct *work) { struct line *line = container_of(work, struct line, task.work); - struct tty_struct *tty = tty_port_tty_get(&line->port); if (!line->throttled) - chan_interrupt(line, tty, line->driver->read_irq); - tty_kref_put(tty); + chan_interrupt(line, line->driver->read_irq); } int enable_chan(struct line *line) @@ -546,7 +544,7 @@ int parse_chan_pair(char *str, struct line *line, int device, return 0; } -void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) +void chan_interrupt(struct line *line, int irq) { struct tty_port *port = &line->port; struct chan *chan = line->chan_in; @@ -570,8 +568,11 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) reactivate_fd(chan->fd, irq); if (err == -EIO) { if (chan->primary) { - if (tty != NULL) + struct tty_struct *tty = tty_port_tty_get(&line->port); + if (tty != NULL) { tty_hangup(tty); + tty_kref_put(tty); + } if (line->chan_out != chan) close_one_chan(line->chan_out, 1); } @@ -580,6 +581,5 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) return; } out: - if (tty) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 9ffc28bd4b7a..f1b38571f94e 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -19,11 +19,10 @@ static irqreturn_t line_interrupt(int irq, void *data) { struct chan *chan = data; struct line *line = chan->line; - struct tty_struct *tty = tty_port_tty_get(&line->port); if (line) - chan_interrupt(line, tty, irq); - tty_kref_put(tty); + chan_interrupt(line, irq); + return IRQ_HANDLED; } @@ -234,7 +233,7 @@ void line_unthrottle(struct tty_struct *tty) struct line *line = tty->driver_data; line->throttled = 0; - chan_interrupt(line, tty, line->driver->read_irq); + chan_interrupt(line, line->driver->read_irq); /* * Maybe there is enough stuff pending that calling the interrupt diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 62447d63890c..da9866f7fecf 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -58,7 +58,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp) tty->port = &serial_port; spin_lock(&timer_lock); if (tty->count == 1) { - setup_timer(&serial_timer, rs_poll, (unsigned long)tty); + setup_timer(&serial_timer, rs_poll, + (unsigned long)&serial_port); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); } spin_unlock(&timer_lock); @@ -97,9 +98,7 @@ static int rs_write(struct tty_struct * tty, static void rs_poll(unsigned long priv) { - struct tty_struct* tty = (struct tty_struct*) priv; - struct tty_port *port = tty->port; - + struct tty_port *port = (struct tty_port *)priv; struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; int i = 0; unsigned char c; @@ -113,7 +112,7 @@ static void rs_poll(unsigned long priv) } if (i) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 92dc7327c7aa..f334aec65fc7 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -886,7 +886,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) issue_command(info, CHA, CMD_RXFIFO); } -static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) +static void rx_ready_async(MGSLPC_INFO *info, int tcd) { struct tty_port *port = &info->port; unsigned char data, status, flag; @@ -894,14 +894,6 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) int work = 0; struct mgsl_icount *icount = &info->icount; - if (!tty) { - /* tty is not available anymore */ - issue_command(info, CHA, CMD_RXRESET); - if (debug_level >= DEBUG_LEVEL_ISR) - printk("%s(%d):rx_ready_async(tty=NULL)\n",__FILE__,__LINE__); - return; - } - if (tcd) { /* early termination, get FIFO count from RBCL register */ fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); @@ -958,7 +950,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) } if (work) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } @@ -1218,7 +1210,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) if (info->params.mode == MGSL_MODE_HDLC) rx_ready_hdlc(info, isr & IRQ_RXEOM); else - rx_ready_async(info, isr & IRQ_RXEOM, tty); + rx_ready_async(info, isr & IRQ_RXEOM); } /* transmit IRQs */ diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 8e0ed663ba9b..ab20a0851dd2 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -133,8 +133,7 @@ static int ipoctal_get_icount(struct tty_struct *tty, return 0; } -static void ipoctal_irq_rx(struct ipoctal_channel *channel, - struct tty_struct *tty, u8 sr) +static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) { struct tty_port *port = &channel->tty_port; unsigned char value; @@ -176,7 +175,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, sr = ioread8(&channel->regs->r.sr); } while (isr & channel->isr_rx_rdy_mask); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } static void ipoctal_irq_tx(struct ipoctal_channel *channel) @@ -209,15 +208,11 @@ static void ipoctal_irq_tx(struct ipoctal_channel *channel) static void ipoctal_irq_channel(struct ipoctal_channel *channel) { u8 isr, sr; - struct tty_struct *tty; /* If there is no client, skip the check */ if (!atomic_read(&channel->open)) return; - tty = tty_port_tty_get(&channel->tty_port); - if (!tty) - return; /* The HW is organized in pair of channels. See which register we need * to read from */ isr = ioread8(&channel->block_regs->r.isr); @@ -236,14 +231,13 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel) /* RX data */ if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY)) - ipoctal_irq_rx(channel, tty, sr); + ipoctal_irq_rx(channel, sr); /* TX of each character */ if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY)) ipoctal_irq_tx(channel); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&channel->tty_port); } static irqreturn_t ipoctal_irq_handler(void *arg) diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 6dcecd40a819..0fbf4f215d86 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -562,16 +562,8 @@ void gigaset_if_free(struct cardstate *cs) void gigaset_if_receive(struct cardstate *cs, unsigned char *buffer, size_t len) { - struct tty_struct *tty = tty_port_tty_get(&cs->port); - - if (tty == NULL) { - gig_dbg(DEBUG_IF, "receive on closed device"); - return; - } - tty_insert_flip_string(&cs->port, buffer, len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&cs->port); } EXPORT_SYMBOL_GPL(gigaset_if_receive); diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 9bb9986659e4..d8a7d8323414 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -63,16 +63,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) struct tty_port *port = &info->port; int c; int len; - struct tty_struct *tty; char last; if (!info->online) return 0; - tty = port->tty; - if (!tty) - return 0; - if (!(info->mcr & UART_MCR_RTS)) return 0; @@ -110,7 +105,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) tty_insert_flip_char(port, last, 0xFF); else tty_insert_flip_char(port, last, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); kfree_skb(skb); return 1; @@ -127,7 +122,6 @@ isdn_tty_readmodem(void) int midx; int i; int r; - struct tty_struct *tty; modem_info *info; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { @@ -145,20 +139,21 @@ isdn_tty_readmodem(void) if ((info->vonline & 1) && (info->emu.vpar[1])) isdn_audio_eval_silence(info); #endif - tty = info->port.tty; - if (tty) { - if (info->mcr & UART_MCR_RTS) { - /* CISCO AsyncPPP Hack */ - if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0); - else - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1); - if (r) - tty_flip_buffer_push(tty); - } else - r = 1; + if (info->mcr & UART_MCR_RTS) { + /* CISCO AsyncPPP Hack */ + if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) + r = isdn_readbchan_tty(info->isdn_driver, + info->isdn_channel, + &info->port, 0); + else + r = isdn_readbchan_tty(info->isdn_driver, + info->isdn_channel, + &info->port, 1); + if (r) + tty_flip_buffer_push(&info->port); } else r = 1; + if (r) { info->rcvsched = 0; resched = 1; @@ -2230,7 +2225,6 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) void isdn_tty_at_cout(char *msg, modem_info *info) { - struct tty_struct *tty; struct tty_port *port = &info->port; atemu *m = &info->emu; char *p; @@ -2248,8 +2242,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) l = strlen(msg); spin_lock_irqsave(&info->readlock, flags); - tty = port->tty; - if ((port->flags & ASYNC_CLOSING) || (!tty)) { + if (port->flags & ASYNC_CLOSING) { spin_unlock_irqrestore(&info->readlock, flags); return; } @@ -2301,7 +2294,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) } else { spin_unlock_irqrestore(&info->readlock, flags); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } } diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index 894078be0b96..c931dfe6a59c 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c @@ -381,7 +381,6 @@ static void sdio_uart_stop_rx(struct sdio_uart_port *port) static void sdio_uart_receive_chars(struct sdio_uart_port *port, unsigned int *status) { - struct tty_struct *tty = tty_port_tty_get(&port->port); unsigned int ch, flag; int max_count = 256; @@ -418,24 +417,19 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, } if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) - if (tty) - tty_insert_flip_char(&port->port, ch, flag); + tty_insert_flip_char(&port->port, ch, flag); /* * Overrun is special. Since it's reported immediately, * it doesn't affect the current character. */ if (*status & ~port->ignore_status_mask & UART_LSR_OE) - if (tty) - tty_insert_flip_char(&port->port, 0, - TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); *status = sdio_in(port, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + + tty_flip_buffer_push(&port->port); } static void sdio_uart_transmit_chars(struct sdio_uart_port *port) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index d235ca07548f..f902a14da88c 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2035,24 +2035,23 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) tty = tty_port_tty_get(&serial->port); /* Push data to tty */ - if (tty) { - write_length_remaining = urb->actual_length - - serial->curr_rx_urb_offset; - D1("data to push to tty"); - while (write_length_remaining) { - if (test_bit(TTY_THROTTLED, &tty->flags)) { - tty_kref_put(tty); - return -1; - } - curr_write_len = tty_insert_flip_string(&serial->port, - urb->transfer_buffer + serial->curr_rx_urb_offset, - write_length_remaining); - serial->curr_rx_urb_offset += curr_write_len; - write_length_remaining -= curr_write_len; - tty_flip_buffer_push(tty); + write_length_remaining = urb->actual_length - + serial->curr_rx_urb_offset; + D1("data to push to tty"); + while (write_length_remaining) { + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { + tty_kref_put(tty); + return -1; } - tty_kref_put(tty); + curr_write_len = tty_insert_flip_string(&serial->port, + urb->transfer_buffer + serial->curr_rx_urb_offset, + write_length_remaining); + serial->curr_rx_urb_offset += curr_write_len; + write_length_remaining -= curr_write_len; + tty_flip_buffer_push(&serial->port); } + tty_kref_put(tty); + if (write_length_remaining == 0) { serial->curr_rx_urb_offset = 0; serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 41b75c5ae0d5..2f58e9fde156 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -413,7 +413,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, case CTRLCHAR_CTRL: tty_insert_flip_char(&raw->port, cchar, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&raw->port); break; case CTRLCHAR_NONE: @@ -427,7 +427,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, count -= 2; tty_insert_flip_string(&raw->port, raw->inbuf, count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&raw->port); break; } } else if (req->type == RAW3215_WRITE) { diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 19b7c516c07d..14b4cb8abcc8 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -343,7 +343,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) break; case CTRLCHAR_CTRL: tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_port); break; case CTRLCHAR_NONE: /* send (normal) input to line discipline */ @@ -355,7 +355,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); } else tty_insert_flip_string(&sclp_port, buf, count - 2); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_port); break; } tty_kref_put(tty); diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 0eca99b98712..6c92f62623be 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -461,14 +461,9 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf) { - struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port); char *buffer; unsigned int count; - /* Ignore input if device is not open */ - if (tty == NULL) - return; - buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); count = evbuf->length - sizeof(struct evbuf_header); @@ -481,10 +476,9 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf) buffer++; count--; tty_insert_flip_string(&sclp_vt220_port, buffer, count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_vt220_port); break; } - tty_kref_put(tty); } /* diff --git a/drivers/staging/ccg/u_serial.c b/drivers/staging/ccg/u_serial.c index 7df2c02d1137..b10947ae0ac5 100644 --- a/drivers/staging/ccg/u_serial.c +++ b/drivers/staging/ccg/u_serial.c @@ -491,12 +491,8 @@ static void gs_rx_push(unsigned long _port) req = list_first_entry(queue, struct usb_request, list); - /* discard data if tty was closed */ - if (!tty) - goto recycle; - /* leave data queued if tty was rx throttled */ - if (test_bit(TTY_THROTTLED, &tty->flags)) + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) break; switch (req->status) { @@ -542,7 +538,6 @@ static void gs_rx_push(unsigned long _port) } port->n_read = 0; } -recycle: list_move(&req->list, &port->read_pool); port->read_started--; } @@ -550,8 +545,8 @@ recycle: /* Push from tty to ldisc; without low_latency set this is handled by * a workqueue, so we won't get callbacks and can hold port_lock */ - if (tty && do_push) - tty_flip_buffer_push(tty); + if (do_push) + tty_flip_buffer_push(&port->port); /* We want our data queue to become empty ASAP, keeping data diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index e618a667d84c..4c7abfabf197 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -234,7 +234,7 @@ static void dgrp_input(struct ch_struct *ch) tty_insert_flip_string_flags(&ch->port, myflipbuf, myflipflagbuf, len); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&ch->port); ch->ch_rxcount += len; } @@ -2958,7 +2958,7 @@ check_query: tty_buffer_request_room(&ch->port, 1); tty_insert_flip_char(&ch->port, 0, TTY_BREAK); - tty_flip_buffer_push(ch->ch_tun.un_tty); + tty_flip_buffer_push(&ch->port); } diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index a2a0c43dec1c..b403393c49c3 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -489,16 +489,11 @@ static void fwtty_do_hangup(struct work_struct *work) static void fwtty_emit_breaks(struct work_struct *work) { struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); - struct tty_struct *tty; static const char buf[16]; unsigned long now = jiffies; unsigned long elapsed = now - port->break_last; int n, t, c, brk = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* generate breaks at the line rate (but at least 1) */ n = (elapsed * port->cps) / HZ + 1; port->break_last = now; @@ -514,9 +509,7 @@ static void fwtty_emit_breaks(struct work_struct *work) if (c < t) break; } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); if (port->mstatus & (UART_LSR_BI << 24)) schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); @@ -530,10 +523,6 @@ static void fwtty_pushrx(struct work_struct *work) struct buffered_rx *buf, *next; int n, c = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - spin_lock_bh(&port->lock); list_for_each_entry_safe(buf, next, &port->buf_list, list) { n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, @@ -545,7 +534,11 @@ static void fwtty_pushrx(struct work_struct *work) memmove(buf->data, buf->data + n, buf->n - n); buf->n -= n; } - __fwtty_throttle(port, tty); + tty = tty_port_tty_get(&port->port); + if (tty) { + __fwtty_throttle(port, tty); + tty_kref_put(tty); + } break; } else { list_del(&buf->list); @@ -553,13 +546,11 @@ static void fwtty_pushrx(struct work_struct *work) } } if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); if (list_empty(&port->buf_list)) clear_bit(BUFFERING_RX, &port->flags); spin_unlock_bh(&port->lock); - - tty_kref_put(tty); } static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) @@ -594,10 +585,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) unsigned lsr; int err = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return -ENOENT; - fwtty_dbg(port, "%d", n); profile_size_distrib(port->stats.reads, n); @@ -634,16 +621,20 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) c = tty_insert_flip_string_fixed_flag(&port->port, data, TTY_NORMAL, n); if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); n -= c; if (n) { /* start buffering and throttling */ n -= fwtty_buffer_rx(port, &data[c], n); - spin_lock_bh(&port->lock); - __fwtty_throttle(port, tty); - spin_unlock_bh(&port->lock); + tty = tty_port_tty_get(&port->port); + if (tty) { + spin_lock_bh(&port->lock); + __fwtty_throttle(port, tty); + spin_unlock_bh(&port->lock); + tty_kref_put(tty); + } } } else n -= fwtty_buffer_rx(port, data, n); @@ -654,8 +645,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) } out: - tty_kref_put(tty); - port->icount.rx += len; port->stats.lost += n; return err; diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 14965662d09c..df29a3de29f2 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -290,8 +290,7 @@ static void qt_interrupt_callback(struct urb *urb) /* FIXME */ } -static void qt_status_change_check(struct tty_struct *tty, - struct urb *urb, +static void qt_status_change_check(struct urb *urb, struct quatech_port *qt_port, struct usb_serial_port *port) { @@ -348,7 +347,7 @@ static void qt_status_change_check(struct tty_struct *tty, tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } static void qt_read_bulk_callback(struct urb *urb) @@ -411,7 +410,7 @@ static void qt_read_bulk_callback(struct urb *urb) } if (urb->actual_length) - qt_status_change_check(tty, urb, qt_port, port); + qt_status_change_check(urb, qt_port, port); /* Continue trying to always read */ usb_fill_bulk_urb(port->read_urb, serial->dev, @@ -427,7 +426,7 @@ static void qt_read_bulk_callback(struct urb *urb) __func__, result); else { if (urb->actual_length) { - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); tty_schedule_flip(tty); } } diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2d1357acbc23..4c7d70172193 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -251,7 +251,6 @@ static void receive_chars(struct serial_state *info) { int status; int serdatr; - struct tty_struct *tty = info->tport.tty; unsigned char ch, flag; struct async_icount *icount; int oe = 0; @@ -314,7 +313,7 @@ static void receive_chars(struct serial_state *info) #endif flag = TTY_BREAK; if (info->tport.flags & ASYNC_SAK) - do_SAK(tty); + do_SAK(info->tport.tty); } else if (status & UART_LSR_PE) flag = TTY_PARITY; else if (status & UART_LSR_FE) @@ -331,7 +330,7 @@ static void receive_chars(struct serial_state *info) tty_insert_flip_char(&info->tport, ch, flag); if (oe == 1) tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->tport); out: return; } diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 143c38579cb5..a93a424873fa 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c @@ -95,18 +95,16 @@ bfin_jc_emudat_manager(void *arg) /* if incoming data is ready, eat it */ if (bfin_read_DBGSTAT() & EMUDIF) { - if (tty != NULL) { - uint32_t emudat = bfin_read_emudat(); - if (inbound_len == 0) { - pr_debug("incoming length: 0x%08x\n", emudat); - inbound_len = emudat; - } else { - size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); - pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); - inbound_len -= num_chars; - tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); - tty_flip_buffer_push(tty); - } + uint32_t emudat = bfin_read_emudat(); + if (inbound_len == 0) { + pr_debug("incoming length: 0x%08x\n", emudat); + inbound_len = emudat; + } else { + size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); + pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); + inbound_len -= num_chars; + tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); + tty_flip_buffer_push(&port); } } diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 5164f9a57017..ed92622b8949 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -371,16 +371,11 @@ console_initcall(ehv_bc_console_init); static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) { struct ehv_bc_data *bc = data; - struct tty_struct *ttys = tty_port_tty_get(&bc->port); unsigned int rx_count, tx_count, len; int count; char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; int ret; - /* ttys could be NULL during a hangup */ - if (!ttys) - return IRQ_HANDLED; - /* Find out how much data needs to be read, and then ask the TTY layer * if it can handle that much. We want to ensure that every byte we * read from the byte channel will be accepted by the TTY layer. @@ -422,9 +417,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) } /* Tell the tty layer that we're done. */ - tty_flip_buffer_push(ttys); - - tty_kref_put(ttys); + tty_flip_buffer_push(&bc->port); return IRQ_HANDLED; } diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 8c2fe3a0e091..eb255e807c06 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -691,7 +691,7 @@ int hvc_poll(struct hvc_struct *hp) a minimum for performance. */ timeout = MIN_TIMEOUT; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } tty_kref_put(tty); diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 7bfc0a924b2f..1956593ee89d 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -623,7 +623,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd) spin_unlock_irqrestore(&hvcsd->lock, flags); /* This is synch because tty->low_latency == 1 */ if(got) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hvcsd->port); if (!got) { /* Do this _after_ the flip_buffer_push */ diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 1f528b8ebf5f..dc591290120b 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -465,7 +465,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, compact_inbuf(hp, packet); if (flip) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); return 1; } @@ -511,7 +511,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg) /* we weren't hung up and we weren't throttled, so we can * deliver the rest now */ hvsi_send_overflow(hp); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } spin_unlock_irqrestore(&hp->lock, flags); @@ -998,7 +998,7 @@ static void hvsi_unthrottle(struct tty_struct *tty) spin_lock_irqsave(&hp->lock, flags); if (hp->n_throttle) { hvsi_send_overflow(hp); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } spin_unlock_irqrestore(&hp->lock, flags); diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index c43da7445432..8fd72ff9436e 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -160,15 +160,9 @@ static void ipw_close(struct tty_struct *linux_tty, struct file *filp) void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, unsigned int length) { - struct tty_struct *linux_tty; int work = 0; mutex_lock(&tty->ipw_tty_mutex); - linux_tty = tty->port.tty; - if (linux_tty == NULL) { - mutex_unlock(&tty->ipw_tty_mutex); - return; - } if (!tty->port.count) { mutex_unlock(&tty->ipw_tty_mutex); @@ -187,7 +181,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, * This may sleep if ->low_latency is set */ if (work) - tty_flip_buffer_push(linux_tty); + tty_flip_buffer_push(&tty->port); } static void ipw_write_packet_sent_callback(void *callback_data, diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index c70144f55fc0..858291ca889c 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c @@ -637,7 +637,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) tty_insert_flip_char(&port->port, 0, TTY_BREAK); if (port->port.flags & ASYNC_SAK) do_SAK(tty); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); break; case 2: /* Statistics */ @@ -671,7 +671,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) byte_count -= 2; } } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } outw(0x0000, base+0x04); /* enable interrupts */ spin_unlock(&card->card_lock); diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index e9cdfdfe06e9..ad34a202a34d 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -2145,7 +2145,7 @@ end_intr: * recursive locking. */ spin_unlock(&port->slock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); spin_lock(&port->slock); } diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 4a3342d21c8f..d84dcfeadce3 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1141,7 +1141,6 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) { struct tty_port *port; - struct tty_struct *tty; unsigned int addr = 0 ; u8 bits; int len = clen; @@ -1174,12 +1173,8 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) if (bits & 8) tty_insert_flip_char(port, 0, TTY_FRAME); - /* See if we have an uplink tty */ - tty = tty_port_tty_get(port); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(port); + gsm_control_reply(gsm, CMD_RLS, data, clen); } @@ -1552,36 +1547,37 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) { /* krefs .. */ struct tty_port *port = &dlci->port; - struct tty_struct *tty = tty_port_tty_get(port); + struct tty_struct *tty; unsigned int modem = 0; int len = clen; if (debug & 16) - pr_debug("%d bytes for tty %p\n", len, tty); - if (tty) { - switch (dlci->adaption) { - /* Unsupported types */ - /* Packetised interruptible data */ - case 4: - break; - /* Packetised uininterruptible voice/data */ - case 3: - break; - /* Asynchronous serial with line state in each frame */ - case 2: - while (gsm_read_ea(&modem, *data++) == 0) { - len--; - if (len == 0) - return; - } + pr_debug("%d bytes for tty\n", len); + switch (dlci->adaption) { + /* Unsupported types */ + /* Packetised interruptible data */ + case 4: + break; + /* Packetised uininterruptible voice/data */ + case 3: + break; + /* Asynchronous serial with line state in each frame */ + case 2: + while (gsm_read_ea(&modem, *data++) == 0) { + len--; + if (len == 0) + return; + } + tty = tty_port_tty_get(port); + if (tty) { gsm_process_modem(tty, dlci, modem, clen); - /* Line state will go via DLCI 0 controls only */ - case 1: - default: - tty_insert_flip_string(port, data, len); - tty_flip_buffer_push(tty); + tty_kref_put(tty); } - tty_kref_put(tty); + /* Line state will go via DLCI 0 controls only */ + case 1: + default: + tty_insert_flip_string(port, data, len); + tty_flip_buffer_push(port); } } diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 941fe8060ea5..afdd7732d925 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -1272,15 +1272,11 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) exit_handler: spin_unlock(&dc->spin_mutex); - for (a = 0; a < NOZOMI_MAX_PORTS; a++) { - struct tty_struct *tty; - if (test_and_clear_bit(a, &dc->flip)) { - tty = tty_port_tty_get(&dc->port[a].port); - if (tty) - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } - } + + for (a = 0; a < NOZOMI_MAX_PORTS; a++) + if (test_and_clear_bit(a, &dc->flip)) + tty_flip_buffer_push(&dc->port[a].port); + return IRQ_HANDLED; none: spin_unlock(&dc->spin_mutex); diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 3c285d398f38..32d027c303aa 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -123,7 +123,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) c = tty_insert_flip_string(to->port, buf, c); /* And shovel */ if (c) { - tty_flip_buffer_push(to); + tty_flip_buffer_push(to->port); tty_wakeup(tty); } } diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 5848a767001a..8073cc0dff59 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -315,9 +315,8 @@ static inline int rocket_paranoia_check(struct r_port *info, * that receive data is present on a serial port. Pulls data from FIFO, moves it into the * tty layer. */ -static void rp_do_receive(struct r_port *info, - struct tty_struct *tty, - CHANNEL_t * cp, unsigned int ChanStatus) +static void rp_do_receive(struct r_port *info, CHANNEL_t *cp, + unsigned int ChanStatus) { unsigned int CharNStat; int ToRecv, wRecv, space; @@ -416,7 +415,7 @@ static void rp_do_receive(struct r_port *info, cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); } /* Push the data up to the tty layer */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } /* @@ -495,7 +494,6 @@ static void rp_do_transmit(struct r_port *info) static void rp_handle_port(struct r_port *info) { CHANNEL_t *cp; - struct tty_struct *tty; unsigned int IntMask, ChanStatus; if (!info) @@ -506,12 +504,7 @@ static void rp_handle_port(struct r_port *info) "info->flags & NOT_INIT\n"); return; } - tty = tty_port_tty_get(&info->port); - if (!tty) { - printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " - "tty==NULL\n"); - return; - } + cp = &info->channel; IntMask = sGetChanIntID(cp) & info->intmask; @@ -520,7 +513,7 @@ static void rp_handle_port(struct r_port *info) #endif ChanStatus = sGetChanStatus(cp); if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ - rp_do_receive(info, tty, cp, ChanStatus); + rp_do_receive(info, cp, ChanStatus); } if (IntMask & DELTA_CD) { /* CD change */ #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) @@ -528,10 +521,15 @@ static void rp_handle_port(struct r_port *info) (ChanStatus & CD_ACT) ? "on" : "off"); #endif if (!(ChanStatus & CD_ACT) && info->cd_status) { + struct tty_struct *tty; #ifdef ROCKET_DEBUG_HANGUP printk(KERN_INFO "CD drop, calling hangup.\n"); #endif - tty_hangup(tty); + tty = tty_port_tty_get(&info->port); + if (tty) { + tty_hangup(tty); + tty_kref_put(tty); + } } info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; wake_up_interruptible(&info->port.open_wait); @@ -544,7 +542,6 @@ static void rp_handle_port(struct r_port *info) printk(KERN_INFO "DSR change...\n"); } #endif - tty_kref_put(tty); } /* diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c index a44345a2dbb4..c7e8b60b6177 100644 --- a/drivers/tty/serial/21285.c +++ b/drivers/tty/serial/21285.c @@ -85,7 +85,6 @@ static void serial21285_enable_ms(struct uart_port *port) static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = port->state->port.tty; unsigned int status, ch, flag, rxs, max_count = 256; status = *CSR_UARTFLG; @@ -115,7 +114,7 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) status = *CSR_UARTFLG; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 5fb6577b94dc..0d771ec16750 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -1323,7 +1323,6 @@ unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) { struct uart_port *port = &up->port; - struct tty_struct *tty = port->state->port.tty; unsigned char ch; int max_count = 256; char flag; @@ -1388,7 +1387,7 @@ ignore_char: lsr = serial_in(up, UART_LSR); } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); spin_unlock(&port->lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); spin_lock(&port->lock); return lsr; } diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c index 872f14ae43d2..84b90fd48063 100644 --- a/drivers/tty/serial/altera_jtaguart.c +++ b/drivers/tty/serial/altera_jtaguart.c @@ -139,7 +139,7 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp) uart_insert_char(port, 0, 0, ch, flag); } - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); } static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp) diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index 684a0808e1c7..e133c8814bb5 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c @@ -231,7 +231,7 @@ static void altera_uart_rx_chars(struct altera_uart *pp) flag); } - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); } static void altera_uart_tx_chars(struct altera_uart *pp) diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 22317dd16474..c36840519527 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -116,7 +116,6 @@ static void pl010_enable_ms(struct uart_port *port) static void pl010_rx_chars(struct uart_amba_port *uap) { - struct tty_struct *tty = uap->port.state->port.tty; unsigned int status, ch, flag, rsr, max_count = 256; status = readb(uap->port.membase + UART01x_FR); @@ -165,7 +164,7 @@ static void pl010_rx_chars(struct uart_amba_port *uap) status = readb(uap->port.membase + UART01x_FR); } spin_unlock(&uap->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uap->port.state->port); spin_lock(&uap->port.lock); } diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index e1257d17f5f0..3ea5408fcbeb 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -699,7 +699,6 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, bool readfifo) { struct tty_port *port = &uap->port.state->port; - struct tty_struct *tty = port->tty; struct pl011_sgbuf *sgbuf = use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; struct device *dev = uap->dmarx.chan->device->dev; @@ -754,7 +753,7 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, dev_vdbg(uap->port.dev, "Took %d chars from DMA buffer and %d chars from the FIFO\n", dma_count, fifotaken); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); spin_lock(&uap->port.lock); } @@ -1076,12 +1075,10 @@ static void pl011_enable_ms(struct uart_port *port) static void pl011_rx_chars(struct uart_amba_port *uap) { - struct tty_struct *tty = uap->port.state->port.tty; - pl011_fifo_to_tty(uap); spin_unlock(&uap->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uap->port.state->port); /* * If we were temporarily out of DMA mode for a while, * attempt to switch back to DMA mode again. diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c index 59ae2b53e765..6331464d9101 100644 --- a/drivers/tty/serial/apbuart.c +++ b/drivers/tty/serial/apbuart.c @@ -78,7 +78,6 @@ static void apbuart_enable_ms(struct uart_port *port) static void apbuart_rx_chars(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; unsigned int status, ch, rsr, flag; unsigned int max_chars = port->fifosize; @@ -126,7 +125,7 @@ static void apbuart_rx_chars(struct uart_port *port) status = UART_GET_STATUS(port); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); } static void apbuart_tx_chars(struct uart_port *port) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index 6ca5dd615f9e..27f20c57abed 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -298,10 +298,8 @@ static void ar933x_uart_set_termios(struct uart_port *port, static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) { struct tty_port *port = &up->port.state->port; - struct tty_struct *tty; int max_count = 256; - tty = tty_port_tty_get(port); do { unsigned int rdata; unsigned char ch; @@ -324,10 +322,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) tty_insert_flip_char(port, ch, TTY_NORMAL); } while (max_count-- > 0); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(port); } static void ar933x_uart_tx_chars(struct ar933x_uart_port *up) diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index b46860104312..da734222e537 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -211,12 +211,8 @@ static void arc_serial_start_tx(struct uart_port *port) static void arc_serial_rx_chars(struct arc_uart_port *uart) { - struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port); unsigned int status, ch, flg = 0; - if (!tty) - return; - /* * UART has 4 deep RX-FIFO. Driver's recongnition of this fact * is very subtle. Here's how ... @@ -252,10 +248,8 @@ static void arc_serial_rx_chars(struct arc_uart_port *uart) uart_insert_char(&uart->port, status, RXOERR, ch, flg); done: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } - - tty_kref_put(tty); } /* diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 929567038c5a..d4a7c241b751 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -774,7 +774,7 @@ static void atmel_rx_from_ring(struct uart_port *port) * uart_start(), which takes the lock. */ spin_unlock(&port->lock); - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); spin_lock(&port->lock); } @@ -782,7 +782,6 @@ static void atmel_rx_from_dma(struct uart_port *port) { struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct atmel_dma_buffer *pdc; int rx_idx = atmel_port->pdc_rx_idx; unsigned int head; @@ -850,7 +849,7 @@ static void atmel_rx_from_dma(struct uart_port *port) * uart_start(), which takes the lock. */ spin_unlock(&port->lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); spin_lock(&port->lock); UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT); diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index de30b1909728..719594e5fc21 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c @@ -236,14 +236,12 @@ static const char *bcm_uart_type(struct uart_port *port) static void bcm_uart_do_rx(struct uart_port *port) { struct tty_port *port = &port->state->port; - struct tty_struct *tty; unsigned int max_count; /* limit number of char read in interrupt, should not be * higher than fifo size anyway since we're much faster than * serial port */ max_count = 32; - tty = port->tty; do { unsigned int iestat, c, cstat; char flag; @@ -305,7 +303,7 @@ static void bcm_uart_do_rx(struct uart_port *port) } while (--max_count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } /* diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c index e4d3ac2e8992..487c173b0f72 100644 --- a/drivers/tty/serial/bfin_sport_uart.c +++ b/drivers/tty/serial/bfin_sport_uart.c @@ -150,7 +150,6 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) { struct sport_uart_port *up = dev_id; struct tty_port *port = &up->port.state->port; - struct tty_struct *tty = tport->tty; unsigned int ch; spin_lock(&up->port.lock); @@ -162,7 +161,8 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) if (!uart_handle_sysrq_char(&up->port, ch)) tty_insert_flip_char(port, ch, TTY_NORMAL); } - tty_flip_buffer_push(tty); + /* XXX this won't deadlock with lowlat? */ + tty_flip_buffer_push(port); spin_unlock(&up->port.lock); diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 2e2b2c1cb722..12dceda9db33 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c @@ -223,7 +223,6 @@ static void bfin_serial_enable_ms(struct uart_port *port) #ifdef CONFIG_SERIAL_BFIN_PIO static void bfin_serial_rx_chars(struct bfin_serial_port *uart) { - struct tty_struct *tty = NULL; unsigned int status, ch, flg; static struct timeval anomaly_start = { .tv_sec = 0 }; @@ -242,11 +241,9 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) return; } - if (!uart->port.state || !uart->port.state->port.tty) + if (!uart->port.state) return; #endif - tty = uart->port.state->port.tty; - if (ANOMALY_05000363) { /* The BF533 (and BF561) family of processors have a nice anomaly * where they continuously generate characters for a "single" break. @@ -325,7 +322,7 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) uart_insert_char(&uart->port, status, OE, ch, flg); ignore_char: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } static void bfin_serial_tx_chars(struct bfin_serial_port *uart) @@ -426,7 +423,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) { - struct tty_struct *tty = uart->port.state->port.tty; int i, flg, status; status = UART_GET_LSR(uart); @@ -471,7 +467,7 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) } dma_ignore_char: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c index 3fd2526d121e..bfb17968c8db 100644 --- a/drivers/tty/serial/clps711x.c +++ b/drivers/tty/serial/clps711x.c @@ -85,12 +85,8 @@ static void uart_clps711x_enable_ms(struct uart_port *port) static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); unsigned int status, ch, flg; - if (!tty) - return IRQ_HANDLED; - for (;;) { status = clps_readl(SYSFLG(port)); if (status & SYSFLG_URXFE) @@ -130,9 +126,7 @@ static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) uart_insert_char(port, status, UARTDR_OVERR, ch, flg); } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 0bb24378a3c0..97f4e1858649 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -246,7 +246,6 @@ static void cpm_uart_int_rx(struct uart_port *port) unsigned char ch; u8 *cp; struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; cbd_t __iomem *bdp; u16 status; @@ -323,7 +322,7 @@ static void cpm_uart_int_rx(struct uart_port *port) pinfo->rx_cur = bdp; /* activate BH processing */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); return; diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 52449adc09ac..45acf103433e 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -2104,17 +2104,10 @@ static int force_eop_if_needed(struct e100_serial *info) static void flush_to_flip_buffer(struct e100_serial *info) { - struct tty_struct *tty; struct etrax_recv_buffer *buffer; unsigned long flags; local_irq_save(flags); - tty = info->port.tty; - - if (!tty) { - local_irq_restore(flags); - return; - } while ((buffer = info->first_recv_buffer) != NULL) { unsigned int count = buffer->length; @@ -2138,7 +2131,7 @@ static void flush_to_flip_buffer(struct e100_serial *info) local_irq_restore(flags); /* This includes a check for low-latency */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } static void check_flush_timeout(struct e100_serial *info) @@ -2274,12 +2267,6 @@ static struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) { unsigned long data_read; - struct tty_struct *tty = info->port.tty; - - if (!tty) { - printk("!NO TTY!\n"); - return info; - } /* Read data and status at the same time */ data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); @@ -2382,7 +2369,7 @@ more_data: goto more_data; } - tty_flip_buffer_push(info->port.tty); + tty_flip_buffer_push(&info->port); return info; } diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c index 6491b8644a7f..2f2b2e538a54 100644 --- a/drivers/tty/serial/dz.c +++ b/drivers/tty/serial/dz.c @@ -187,7 +187,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) { struct uart_port *uport; struct dz_port *dport = &mux->dport[0]; - struct tty_struct *tty = NULL; struct uart_icount *icount; int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; unsigned char ch, flag; @@ -197,7 +196,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { dport = &mux->dport[LINE(status)]; uport = &dport->port; - tty = uport->state->port.tty; /* point to the proper dev */ ch = UCHAR(status); /* grab the char */ flag = TTY_NORMAL; @@ -249,7 +247,7 @@ static inline void dz_receive_chars(struct dz_mux *mux) } for (i = 0; i < DZ_NB_PORT; i++) if (lines_rx[i]) - tty_flip_buffer_push(mux->dport[i].port.state->port.tty); + tty_flip_buffer_push(&mux->dport[i].port.state->port); } /* diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index bdf67b0cb8b6..de14bd7dce10 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c @@ -249,12 +249,9 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) int handled = IRQ_NONE; struct uart_port *port = &efm_port->port; struct tty_port *tport = &port->state->port; - struct tty_struct *tty; spin_lock(&port->lock); - tty = tty_kref_get(tport->tty); - if (irqflag & UARTn_IF_RXDATAV) { efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); efm32_uart_rx_chars(efm_port); @@ -270,10 +267,7 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) handled = IRQ_HANDLED; } - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(tport); spin_unlock(&port->lock); diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 54903ee5e5ab..bc9e6b017b05 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c @@ -735,7 +735,6 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) { short int count, rcv_buff; struct tty_port *port = &icom_port->uart_port.state->port; - struct tty_struct *tty = port->tty; unsigned short int status; struct uart_icount *icount; unsigned long offset; @@ -835,7 +834,7 @@ ignore_char: status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); } icom_port->next_rcv = rcv_buff; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } static void process_interrupt(u16 port_int_reg, diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 4bc6e47890b4..6a6668bbb330 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -669,12 +669,8 @@ static const struct tty_operations ifx_spi_serial_ops = { static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, unsigned char *chars, size_t size) { - struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port); - if (!tty) - return; tty_insert_flip_string(&ifx_dev->tty_port, chars, size); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&ifx_dev->tty_port); } /** diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index f60c4028b6e1..be26345bf6a4 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -518,7 +518,6 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) unsigned int rx, flg, ignored = 0; struct tty_struct *tty = sport->port.state->port.tty; struct tty_port *port = &sport->port.state->port; - struct tty_struct *tty = port->tty; unsigned long flags, temp; spin_lock_irqsave(&sport->port.lock, flags); @@ -576,7 +575,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) out: spin_unlock_irqrestore(&sport->port.lock, flags); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c index edbdc4e45075..6e4c715c5d26 100644 --- a/drivers/tty/serial/ioc3_serial.c +++ b/drivers/tty/serial/ioc3_serial.c @@ -1393,7 +1393,6 @@ static inline int do_read(struct uart_port *the_port, char *buf, int len) */ static int receive_chars(struct uart_port *the_port) { - struct tty_struct *tty; unsigned char ch[MAX_CHARS]; int read_count = 0, read_room, flip = 0; struct uart_state *state = the_port->state; @@ -1403,14 +1402,11 @@ static int receive_chars(struct uart_port *the_port) /* Make sure all the pointers are "good" ones */ if (!state) return 0; - if (!state->port.tty) - return 0; if (!(port->ip_flags & INPUT_ENABLE)) return 0; spin_lock_irqsave(&the_port->lock, pflags); - tty = state->port.tty; read_count = do_read(the_port, ch, MAX_CHARS); if (read_count > 0) { @@ -1422,7 +1418,7 @@ static int receive_chars(struct uart_port *the_port) spin_unlock_irqrestore(&the_port->lock, pflags); if (flip) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&state->port); return read_count; } diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index 86f64ed89b45..e2520abcb1c4 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c @@ -2340,7 +2340,6 @@ static inline int do_read(struct uart_port *the_port, unsigned char *buf, */ static void receive_chars(struct uart_port *the_port) { - struct tty_struct *tty; unsigned char ch[IOC4_MAX_CHARS]; int read_count, request_count = IOC4_MAX_CHARS; struct uart_icount *icount; @@ -2350,11 +2349,8 @@ static void receive_chars(struct uart_port *the_port) /* Make sure all the pointers are "good" ones */ if (!state) return; - if (!state->port.tty) - return; spin_lock_irqsave(&the_port->lock, pflags); - tty = state->port.tty; request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS); @@ -2369,7 +2365,7 @@ static void receive_chars(struct uart_port *the_port) spin_unlock_irqrestore(&the_port->lock, pflags); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&state->port); } /** diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index c9ce00dd1f8a..00f250ae14c5 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -654,7 +654,7 @@ void jsm_input(struct jsm_channel *ch) spin_unlock_irqrestore(&ch->ch_lock, lock_flags); /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp); + tty_flip_buffer_push(port); jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n"); } diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index ba2ef627d9c6..26a50b0c868b 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -202,7 +202,6 @@ bool kgdb_nmi_poll_knock(void) static void kgdb_nmi_tty_receiver(unsigned long data) { struct kgdb_nmi_tty_priv *priv = (void *)data; - struct tty_struct *tty; char ch; tasklet_schedule(&priv->tlet); @@ -210,16 +209,9 @@ static void kgdb_nmi_tty_receiver(unsigned long data) if (likely(!kgdb_nmi_tty_enabled || !kfifo_len(&priv->fifo))) return; - /* Port is there, but tty might be hung up, check. */ - tty = tty_port_tty_get(kgdb_nmi_port); - if (!tty) - return; - while (kfifo_out(&priv->fifo, &ch, 1)) tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); - tty_flip_buffer_push(priv->port.tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&priv->port); } static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c index 1933fe3c98dd..15733da757c6 100644 --- a/drivers/tty/serial/lantiq.c +++ b/drivers/tty/serial/lantiq.c @@ -163,21 +163,15 @@ static int lqasc_rx_chars(struct uart_port *port) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tty_port_tty_get(tport); unsigned int ch = 0, rsr = 0, fifocnt; - if (!tty) { - dev_dbg(port->dev, "%s:tty is busy now", __func__); - return -EBUSY; - } - fifocnt = - ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; + fifocnt = ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; while (fifocnt--) { u8 flag = TTY_NORMAL; ch = ltq_r8(port->membase + LTQ_ASC_RBUF); rsr = (ltq_r32(port->membase + LTQ_ASC_STATE) & ASCSTATE_ANY) | UART_DUMMY_UER_RX; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); port->icount.rx++; /* @@ -219,9 +213,10 @@ lqasc_rx_chars(struct uart_port *port) */ tty_insert_flip_char(tport, 0, TTY_OVERRUN); } + if (ch != 0) - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(tport); + return 0; } diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index 5cd180564c03..c8448e6f52e5 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -259,16 +259,6 @@ static void __serial_lpc32xx_rx(struct uart_port *port) { struct tty_port *tport = &port->state->port; unsigned int tmp, flag; - struct tty_struct *tty = tty_port_tty_get(tport); - - if (!tty) { - /* Discard data: no tty available */ - while (!(readl(LPC32XX_HSUART_FIFO(port->membase)) & - LPC32XX_HSU_RX_EMPTY)) - ; - - return; - } /* Read data from FIFO and push into terminal */ tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); @@ -289,8 +279,7 @@ static void __serial_lpc32xx_rx(struct uart_port *port) tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(tport); } static void __serial_lpc32xx_tx(struct uart_port *port) @@ -367,8 +356,7 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) /* Data received? */ if (status & (LPC32XX_HSU_RX_TIMEOUT_INT | LPC32XX_HSU_RX_TRIG_INT)) { __serial_lpc32xx_rx(port); - if (tty) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); } /* Transmit data request? */ diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index 2e9a390f2ac4..bb1afa0922e1 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c @@ -301,7 +301,6 @@ static void m32r_sio_enable_ms(struct uart_port *port) static void receive_chars(struct uart_sio_port *up, int *status) { struct tty_port *port = &up->port.state->port; - struct tty_struct *tty = tport->tty; unsigned char ch; unsigned char flag; int max_count = 256; @@ -369,7 +368,7 @@ static void receive_chars(struct uart_sio_port *up, int *status) ignore_char: *status = serial_in(up, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } static void transmit_chars(struct uart_sio_port *up) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index e238e80cd981..791e1dfb8b11 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -311,8 +311,8 @@ static void max3100_work(struct work_struct *w) } } - if (rxchars > 16 && s->port.state->port.tty != NULL) { - tty_flip_buffer_push(s->port.state->port.tty); + if (rxchars > 16) { + tty_flip_buffer_push(&s->port.state->port); rxchars = 0; } if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) @@ -324,8 +324,8 @@ static void max3100_work(struct work_struct *w) (!uart_circ_empty(xmit) && !uart_tx_stopped(&s->port)))); - if (rxchars > 0 && s->port.state->port.tty != NULL) - tty_flip_buffer_push(s->port.state->port.tty); + if (rxchars > 0) + tty_flip_buffer_push(&s->port.state->port); } static irqreturn_t max3100_irq(int irqno, void *dev_id) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index a801f6872cad..0c2422cb04ea 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -460,10 +460,6 @@ static int max310x_set_ref_clk(struct max310x_port *s) static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) { unsigned int sts = 0, ch = 0, flag; - struct tty_struct *tty = tty_port_tty_get(&s->port.state->port); - - if (!tty) - return; if (unlikely(rxlen >= MAX310X_FIFO_SIZE)) { dev_warn(s->port.dev, "Possible RX FIFO overrun %d\n", rxlen); @@ -516,9 +512,7 @@ static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) ch, flag); } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&s->port.state->port); } static void max310x_handle_tx(struct max310x_port *s) diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index fcd56ab6053f..7ed99274572f 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c @@ -310,7 +310,7 @@ static void mcf_rx_chars(struct mcf_uart *pp) uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); } - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); } /****************************************************************************/ diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index 60d585ab4870..5f4765a7a5c5 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c @@ -388,12 +388,8 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) struct hsu_dma_chan *chan = up->rxc; struct uart_port *port = &up->port; struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; int count; - if (!tty) - return; - /* * First need to know how many is already transferred, * then check if its a timeout DMA irq, and return @@ -438,7 +434,7 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) | (0x1 << 16) | (0x1 << 24) /* timeout bit, see HSU Errata 1 */ ); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); chan_writel(chan, HSU_CH_CR, 0x3); @@ -461,13 +457,9 @@ static void serial_hsu_stop_rx(struct uart_port *port) static inline void receive_chars(struct uart_hsu_port *up, int *status) { - struct tty_struct *tty = up->port.state->port.tty; unsigned int ch, flag; unsigned int max_count = 256; - if (!tty) - return; - do { ch = serial_in(up, UART_RX); flag = TTY_NORMAL; @@ -523,7 +515,7 @@ static inline void receive_chars(struct uart_hsu_port *up, int *status) ignore_char: *status = serial_in(up, UART_LSR); } while ((*status & UART_LSR_DR) && max_count--); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&up->port.state->port); } static void transmit_chars(struct uart_hsu_port *up) diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c index 0145aeb7721c..c0e1fad51be7 100644 --- a/drivers/tty/serial/mpc52xx_uart.c +++ b/drivers/tty/serial/mpc52xx_uart.c @@ -942,7 +942,6 @@ static inline int mpc52xx_uart_int_rx_chars(struct uart_port *port) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; unsigned char ch, flag; unsigned short status; @@ -1000,7 +999,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) } spin_unlock(&port->lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); spin_lock(&port->lock); return psc_ops->raw_rx_rdy(port); diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c index 6f2d2ceb326a..bc24f4931670 100644 --- a/drivers/tty/serial/mpsc.c +++ b/drivers/tty/serial/mpsc.c @@ -938,7 +938,6 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) { struct mpsc_rx_desc *rxre; struct tty_port *port = &pi->port.state->port; - struct tty_struct *tty = port->tty; u32 cmdstat, bytes_in, i; int rc = 0; u8 *bp; @@ -971,7 +970,7 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) /* Following use of tty struct directly is deprecated */ if (tty_buffer_request_room(port, bytes_in) < bytes_in) { if (port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); /* * If this failed then we will throw away the bytes * but must do so to clear interrupts. @@ -1081,7 +1080,7 @@ next_frame: if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0) mpsc_start_rx(pi); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return rc; } diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index 4632db7a24b7..f641c232beca 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c @@ -340,7 +340,6 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) { struct uart_port *port = &max->port; struct tty_port *tport; - struct tty_struct *tty; char buf[M3110_RX_FIFO_DEPTH]; int r, w, usable; @@ -349,9 +348,6 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) return 0; tport = &port->state->port; - tty = tty_port_tty_get(tport); - if (!tty) - return 0; for (r = 0, w = 0; r < len; r++) { if (str[r] & MAX3110_BREAK && @@ -366,10 +362,8 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) } } - if (!w) { - tty_kref_put(tty); + if (!w) return 0; - } for (r = 0; w; r += usable, w -= usable) { usable = tty_buffer_request_room(tport, w); @@ -378,8 +372,7 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) port->icount.rx += usable; } } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(tport); return r; } diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index cb787c0e279a..b11e99797fd8 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -92,7 +92,6 @@ static void msm_enable_ms(struct uart_port *port) static void handle_rx_dm(struct uart_port *port, unsigned int misr) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; unsigned int sr; int count = 0; struct msm_port *msm_port = UART_TO_MSM(port); @@ -138,7 +137,7 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) count -= 4; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); if (misr & (UART_IMR_RXSTALE)) msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); msm_write(port, 0xFFFFFF, UARTDM_DMRX); @@ -148,7 +147,6 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) static void handle_rx(struct uart_port *port) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; unsigned int sr; /* @@ -191,7 +189,7 @@ static void handle_rx(struct uart_port *port) tty_insert_flip_char(tport, c, flag); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); } static void reset_dm_count(struct uart_port *port) diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index c356ffff3c71..4a942c78347e 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c @@ -981,9 +981,8 @@ static void msm_hs_tty_flip_buffer_work(struct work_struct *work) { struct msm_hs_port *msm_uport = container_of(work, struct msm_hs_port, rx.tty_work); - struct tty_struct *tty = msm_uport->uport.state->port.tty; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&msm_uport->uport.state->port); } /* diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c index b43b4ec39269..e722ff163d91 100644 --- a/drivers/tty/serial/msm_smd_tty.c +++ b/drivers/tty/serial/msm_smd_tty.c @@ -80,7 +80,7 @@ static void smd_tty_notify(void *priv, unsigned event) pr_err("OOPS - smd_tty_buffer mismatch?!"); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } /* XXX only when writable and necessary */ diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c index 83b21686020e..7fd6aaaacd8e 100644 --- a/drivers/tty/serial/mux.c +++ b/drivers/tty/serial/mux.c @@ -244,7 +244,6 @@ static void mux_read(struct uart_port *port) { struct tty_port *tport = &port->state->port; int data; - struct tty_struct *tty = tport->tty; __u32 start_count = port->icount.rx; while(1) { @@ -270,9 +269,8 @@ static void mux_read(struct uart_port *port) tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL); } - if (start_count != port->icount.rx) { - tty_flip_buffer_push(tty); - } + if (start_count != port->icount.rx) + tty_flip_buffer_push(tport); } /** diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 37a0046ef531..df0ba32f88ad 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -364,7 +364,6 @@ out: static void mxs_auart_rx_chars(struct mxs_auart_port *s) { - struct tty_struct *tty = s->port.state->port.tty; u32 stat = 0; for (;;) { @@ -375,7 +374,7 @@ static void mxs_auart_rx_chars(struct mxs_auart_port *s) } writel(stat, s->port.membase + AUART_STAT); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&s->port.state->port); } static int mxs_auart_request_port(struct uart_port *u) @@ -458,7 +457,6 @@ static void dma_rx_callback(void *arg) { struct mxs_auart_port *s = (struct mxs_auart_port *) arg; struct tty_port *port = &s->port.state->port; - struct tty_struct *tty = port->tty; int count; u32 stat; @@ -472,7 +470,7 @@ static void dma_rx_callback(void *arg) tty_insert_flip_string(port, s->rx_dma_buf, count); writel(stat, s->port.membase + AUART_STAT); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); /* start the next DMA for RX. */ mxs_auart_dma_prep_rx(s); diff --git a/drivers/tty/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c index d40da78e7c85..b9a40ed70be2 100644 --- a/drivers/tty/serial/netx-serial.c +++ b/drivers/tty/serial/netx-serial.c @@ -199,7 +199,6 @@ static void netx_txint(struct uart_port *port) static void netx_rxint(struct uart_port *port) { unsigned char rx, flg, status; - struct tty_struct *tty = port->state->port.tty; while (!(readl(port->membase + UART_FR) & FR_RXFE)) { rx = readl(port->membase + UART_DR); @@ -237,8 +236,7 @@ static void netx_rxint(struct uart_port *port) uart_insert_char(port, status, SR_OE, rx, flg); } - tty_flip_buffer_push(tty); - return; + tty_flip_buffer_push(&port->state->port); } static irqreturn_t netx_int(int irq, void *dev_id) diff --git a/drivers/tty/serial/nwpserial.c b/drivers/tty/serial/nwpserial.c index 10d64a3697fb..77287c54f331 100644 --- a/drivers/tty/serial/nwpserial.c +++ b/drivers/tty/serial/nwpserial.c @@ -129,7 +129,6 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) { struct nwpserial_port *up = dev_id; struct tty_port *port = &up->port.state->port; - struct tty_struct *tty = port->tty; irqreturn_t ret; unsigned int iir; unsigned char ch; @@ -150,7 +149,7 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) tty_insert_flip_char(port, ch, TTY_NORMAL); } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); ret = IRQ_HANDLED; /* clear interrupt */ diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ec90651d661a..6f3dbf740f05 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -483,7 +483,6 @@ static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr) static irqreturn_t serial_omap_irq(int irq, void *dev_id) { struct uart_omap_port *up = dev_id; - struct tty_struct *tty = up->port.state->port.tty; unsigned int iir, lsr; unsigned int type; irqreturn_t ret = IRQ_NONE; @@ -530,7 +529,7 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id) spin_unlock(&up->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&up->port.state->port); pm_runtime_mark_last_busy(up->dev); pm_runtime_put_autosuspend(up->dev); diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 967f1cb311f3..8b40a1fc9681 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -593,17 +593,9 @@ static int push_rx(struct eg20t_port *priv, const unsigned char *buf, { struct uart_port *port = &priv->port; struct tty_port *tport = &port->state->port; - struct tty_struct *tty; - - tty = tty_port_tty_get(tport); - if (!tty) { - dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); - return -EBUSY; - } tty_insert_flip_string(tport, buf, size); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(tport); return 0; } @@ -744,19 +736,12 @@ static void pch_dma_rx_complete(void *arg) { struct eg20t_port *priv = arg; struct uart_port *port = &priv->port; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); int count; - if (!tty) { - dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); - return; - } - dma_sync_sg_for_cpu(port->dev, &priv->sg_rx, 1, DMA_FROM_DEVICE); count = dma_push_rx(priv, priv->trigger_level); if (count) - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->state->port); async_tx_ack(priv->desc_rx); pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_RX_INT | PCH_UART_HAL_RX_ERR_INT); diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 73a3f295e7c4..b1785f58b6e3 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c @@ -227,21 +227,19 @@ static void pmz_interrupt_control(struct uart_pmac_port *uap, int enable) write_zsreg(uap, R1, uap->curregs[1]); } -static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) +static bool pmz_receive_chars(struct uart_pmac_port *uap) { struct tty_port *port; - struct tty_struct *tty = NULL; unsigned char ch, r1, drop, error, flag; int loops = 0; /* Sanity check, make sure the old bug is no longer happening */ - if (uap->port.state == NULL || uap->port.state->port.tty == NULL) { + if (uap->port.state == NULL) { WARN_ON(1); (void)read_zsdata(uap); - return NULL; + return false; } port = &uap->port.state->port; - tty = port->tty; /* TOCTOU above */ while (1) { error = 0; @@ -330,11 +328,11 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) break; } - return tty; + return true; flood: pmz_interrupt_control(uap, 0); pmz_error("pmz: rx irq flood !\n"); - return tty; + return true; } static void pmz_status_handle(struct uart_pmac_port *uap) @@ -455,7 +453,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) struct uart_pmac_port *uap_a; struct uart_pmac_port *uap_b; int rc = IRQ_NONE; - struct tty_struct *tty; + bool push; u8 r3; uap_a = pmz_get_port_A(uap); @@ -468,7 +466,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) pmz_debug("irq, r3: %x\n", r3); #endif /* Channel A */ - tty = NULL; + push = false; if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { if (!ZS_IS_OPEN(uap_a)) { pmz_debug("ChanA interrupt while not open !\n"); @@ -479,21 +477,21 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) if (r3 & CHAEXT) pmz_status_handle(uap_a); if (r3 & CHARxIP) - tty = pmz_receive_chars(uap_a); + push = pmz_receive_chars(uap_a); if (r3 & CHATxIP) pmz_transmit_chars(uap_a); rc = IRQ_HANDLED; } skip_a: spin_unlock(&uap_a->port.lock); - if (tty != NULL) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&uap->port.state->port); if (!uap_b) goto out; spin_lock(&uap_b->port.lock); - tty = NULL; + push = false; if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { if (!ZS_IS_OPEN(uap_b)) { pmz_debug("ChanB interrupt while not open !\n"); @@ -504,15 +502,15 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) if (r3 & CHBEXT) pmz_status_handle(uap_b); if (r3 & CHBRxIP) - tty = pmz_receive_chars(uap_b); + push = pmz_receive_chars(uap_b); if (r3 & CHBTxIP) pmz_transmit_chars(uap_b); rc = IRQ_HANDLED; } skip_b: spin_unlock(&uap_b->port.lock); - if (tty != NULL) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&uap->port.state->port); out: return rc; diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c index 0aa75a97531c..7e277a5384a7 100644 --- a/drivers/tty/serial/pnx8xxx_uart.c +++ b/drivers/tty/serial/pnx8xxx_uart.c @@ -181,7 +181,6 @@ static void pnx8xxx_enable_ms(struct uart_port *port) static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) { - struct tty_struct *tty = sport->port.state->port.tty; unsigned int status, ch, flg; status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | @@ -238,7 +237,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sport->port.state->port); } static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport) diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c index 2764828251f5..3b671bc3f966 100644 --- a/drivers/tty/serial/pxa.c +++ b/drivers/tty/serial/pxa.c @@ -98,7 +98,6 @@ static void serial_pxa_stop_rx(struct uart_port *port) static inline void receive_chars(struct uart_pxa_port *up, int *status) { - struct tty_struct *tty = up->port.state->port.tty; unsigned int ch, flag; int max_count = 256; @@ -168,7 +167,7 @@ static inline void receive_chars(struct uart_pxa_port *up, int *status) ignore_char: *status = serial_in(up, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&up->port.state->port); /* work around Errata #20 according to * Intel(R) PXA27x Processor Family diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c index 5d4b9b449b4a..af6b3e3ad24d 100644 --- a/drivers/tty/serial/sa1100.c +++ b/drivers/tty/serial/sa1100.c @@ -188,7 +188,6 @@ static void sa1100_enable_ms(struct uart_port *port) static void sa1100_rx_chars(struct sa1100_port *sport) { - struct tty_struct *tty = sport->port.state->port.tty; unsigned int status, ch, flg; status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | @@ -233,7 +232,7 @@ sa1100_rx_chars(struct sa1100_port *sport) status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | UTSR0_TO_SM(UART_GET_UTSR0(sport)); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sport->port.state->port); } static void sa1100_tx_chars(struct sa1100_port *sport) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 0684529eb2ad..3aa3c4c83f8b 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -220,7 +220,6 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id) { struct s3c24xx_uart_port *ourport = dev_id; struct uart_port *port = &ourport->port; - struct tty_struct *tty = port->state->port.tty; unsigned int ufcon, ch, flag, ufstat, uerstat; unsigned long flags; int max_count = 64; @@ -298,7 +297,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id) ignore_char: continue; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); out: spin_unlock_irqrestore(&port->lock, flags); diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c index f76b1688c5c8..a7cdec2962dd 100644 --- a/drivers/tty/serial/sb1250-duart.c +++ b/drivers/tty/serial/sb1250-duart.c @@ -384,7 +384,7 @@ static void sbd_receive_chars(struct sbd_port *sport) uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag); } - tty_flip_buffer_push(uport->state->port.tty); + tty_flip_buffer_push(&uport->state->port); } static void sbd_transmit_chars(struct sbd_port *sport) diff --git a/drivers/tty/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c index 0cd0e4ac12a6..c9735680762d 100644 --- a/drivers/tty/serial/sc26xx.c +++ b/drivers/tty/serial/sc26xx.c @@ -136,20 +136,17 @@ static void sc26xx_disable_irq(struct uart_port *port, int mask) WRITE_SC(port, IMR, up->imr); } -static struct tty_struct *receive_chars(struct uart_port *port) +static bool receive_chars(struct uart_port *port) { struct tty_port *tport = NULL; - struct tty_struct *tty = NULL; int limit = 10000; unsigned char ch; char flag; u8 status; /* FIXME what is this trying to achieve? */ - if (port->state != NULL) { /* Unopened serial console */ + if (port->state != NULL) /* Unopened serial console */ tport = &port->state->port; - tty = tport->tty; - } while (limit-- > 0) { status = READ_SC_PORT(port, SR); @@ -191,7 +188,7 @@ static struct tty_struct *receive_chars(struct uart_port *port) tty_insert_flip_char(tport, ch, flag); } - return tty; + return !!tport; } static void transmit_chars(struct uart_port *port) @@ -221,36 +218,36 @@ static void transmit_chars(struct uart_port *port) static irqreturn_t sc26xx_interrupt(int irq, void *dev_id) { struct uart_sc26xx_port *up = dev_id; - struct tty_struct *tty; unsigned long flags; + bool push; u8 isr; spin_lock_irqsave(&up->port[0].lock, flags); - tty = NULL; + push = false; isr = READ_SC(&up->port[0], ISR); if (isr & ISR_TXRDYA) transmit_chars(&up->port[0]); if (isr & ISR_RXRDYA) - tty = receive_chars(&up->port[0]); + push = receive_chars(&up->port[0]); spin_unlock(&up->port[0].lock); - if (tty) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&up->port[0].state->port); spin_lock(&up->port[1].lock); - tty = NULL; + push = false; if (isr & ISR_TXRDYB) transmit_chars(&up->port[1]); if (isr & ISR_RXRDYB) - tty = receive_chars(&up->port[1]); + push = receive_chars(&up->port[1]); spin_unlock_irqrestore(&up->port[1].lock, flags); - if (tty) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&up->port[1].state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index 418b495e3233..2ced871becff 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -285,10 +285,6 @@ static void sccnxp_handle_rx(struct uart_port *port) { u8 sr; unsigned int ch, flag; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); - - if (!tty) - return; for (;;) { sr = sccnxp_port_read(port, SCCNXP_SR_REG); @@ -333,9 +329,7 @@ static void sccnxp_handle_rx(struct uart_port *port) uart_insert_char(port, sr, SR_OVR, ch, flag); } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->state->port); } static void sccnxp_handle_tx(struct uart_port *port) diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c index 9bd004f9da89..e1caa99e3d3b 100644 --- a/drivers/tty/serial/serial_ks8695.c +++ b/drivers/tty/serial/serial_ks8695.c @@ -153,7 +153,6 @@ static void ks8695uart_disable_ms(struct uart_port *port) static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = port->state->port.tty; unsigned int status, ch, lsr, flg, max_count = 256; status = UART_GET_LSR(port); /* clears pending LSR interrupts */ @@ -200,7 +199,7 @@ static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) ignore_char: status = UART_GET_LSR(port); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c index b52b21aeb250..fe48a0c2b4ca 100644 --- a/drivers/tty/serial/serial_txx9.c +++ b/drivers/tty/serial/serial_txx9.c @@ -277,7 +277,6 @@ static void serial_txx9_initialize(struct uart_port *port) static inline void receive_chars(struct uart_txx9_port *up, unsigned int *status) { - struct tty_struct *tty = up->port.state->port.tty; unsigned char ch; unsigned int disr = *status; int max_count = 256; @@ -346,7 +345,7 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status) disr = sio_in(up, TXX9_SIDISR); } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); spin_unlock(&up->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&up->port.state->port); spin_lock(&up->port.lock); *status = disr; } diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ecef748f5385..156418619949 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -597,7 +597,6 @@ static void sci_receive_chars(struct uart_port *port) { struct sci_port *sci_port = to_sci_port(port); struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; int i, count, copied = 0; unsigned short status; unsigned char flag; @@ -675,7 +674,7 @@ static void sci_receive_chars(struct uart_port *port) if (copied) { /* Tell the rest of the system the news. New characters! */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); } else { serial_port_in(port, SCxSR); /* dummy read */ serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); @@ -722,7 +721,6 @@ static int sci_handle_errors(struct uart_port *port) int copied = 0; unsigned short status = serial_port_in(port, SCxSR); struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); /* @@ -783,7 +781,7 @@ static int sci_handle_errors(struct uart_port *port) } if (copied) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); return copied; } @@ -791,7 +789,6 @@ static int sci_handle_errors(struct uart_port *port) static int sci_handle_fifo_overrun(struct uart_port *port) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); struct plat_sci_reg *reg; int copied = 0; @@ -806,7 +803,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port) port->icount.overrun++; tty_insert_flip_char(tport, 0, TTY_OVERRUN); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); dev_notice(port->dev, "overrun error\n"); copied++; @@ -820,7 +817,6 @@ static int sci_handle_breaks(struct uart_port *port) int copied = 0; unsigned short status = serial_port_in(port, SCxSR); struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct sci_port *s = to_sci_port(port); if (uart_handle_break(port)) @@ -842,7 +838,7 @@ static int sci_handle_breaks(struct uart_port *port) } if (copied) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); copied += sci_handle_fifo_overrun(port); @@ -1299,7 +1295,6 @@ static void sci_dma_rx_complete(void *arg) { struct sci_port *s = arg; struct uart_port *port = &s->port; - struct tty_struct *tty = port->state->port.tty; unsigned long flags; int count; @@ -1314,7 +1309,7 @@ static void sci_dma_rx_complete(void *arg) spin_unlock_irqrestore(&port->lock, flags); if (count) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); schedule_work(&s->work_rx); } @@ -1408,7 +1403,6 @@ static void work_fn_rx(struct work_struct *work) if (dma_async_is_tx_complete(s->chan_rx, s->active_rx, NULL, NULL) != DMA_SUCCESS) { /* Handle incomplete DMA receive */ - struct tty_struct *tty = port->state->port.tty; struct dma_chan *chan = s->chan_rx; struct shdma_desc *sh_desc = container_of(desc, struct shdma_desc, async_tx); @@ -1424,7 +1418,7 @@ static void work_fn_rx(struct work_struct *work) spin_unlock_irqrestore(&port->lock, flags); if (count) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); sci_submit_rx(s); diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 142217cd01f4..8f3d6c091acc 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c @@ -206,11 +206,6 @@ static unsigned int sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) { unsigned int ch, rx_count = 0; - struct tty_struct *tty; - - tty = tty_port_tty_get(&port->state->port); - if (!tty) - return -ENODEV; while (!(rd_regl(port, SIRFUART_RX_FIFO_STATUS) & SIRFUART_FIFOEMPTY_MASK(port))) { @@ -224,8 +219,7 @@ sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) } port->icount.rx += rx_count; - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->state->port); return rx_count; } diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c index 283232c64656..f51ffdc696fd 100644 --- a/drivers/tty/serial/sn_console.c +++ b/drivers/tty/serial/sn_console.c @@ -459,7 +459,6 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) { struct tty_port *tport = NULL; int ch; - struct tty_struct *tty; if (!port) { printk(KERN_ERR "sn_receive_chars - port NULL so can't receive\n"); @@ -474,11 +473,6 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) if (port->sc_port.state) { /* The serial_core stuffs are initialized, use them */ tport = &port->sc_port.state->port; - tty = tport->tty; - } - else { - /* Not registered yet - can't pass to tty layer. */ - tty = NULL; } while (port->sc_ops->sal_input_pending()) { @@ -518,15 +512,15 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) #endif /* CONFIG_MAGIC_SYSRQ */ /* record the character to pass up to the tty layer */ - if (tty) { + if (tport) { if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0) break; } port->sc_port.icount.rx++; } - if (tty) - tty_flip_buffer_push(tty); + if (tport) + tty_flip_buffer_push(tport); } /** diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c index defe92b19e16..ba60708053e0 100644 --- a/drivers/tty/serial/sunhv.c +++ b/drivers/tty/serial/sunhv.c @@ -181,17 +181,17 @@ static struct sunhv_ops bywrite_ops = { static struct sunhv_ops *sunhv_ops = &bychar_ops; -static struct tty_struct *receive_chars(struct uart_port *port) +static struct tty_port *receive_chars(struct uart_port *port) { - struct tty_struct *tty = NULL; + struct tty_port *tport = NULL; if (port->state != NULL) /* Unopened serial console */ - tty = port->state->port.tty; + tport = &port->state->port; if (sunhv_ops->receive_chars(port)) sun_do_break(); - return tty; + return tport; } static void transmit_chars(struct uart_port *port) @@ -214,16 +214,16 @@ static void transmit_chars(struct uart_port *port) static irqreturn_t sunhv_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty; + struct tty_port *tport; unsigned long flags; spin_lock_irqsave(&port->lock, flags); - tty = receive_chars(port); + tport = receive_chars(port); transmit_chars(port); spin_unlock_irqrestore(&port->lock, flags); - if (tty) - tty_flip_buffer_push(tty); + if (tport) + tty_flip_buffer_push(tport); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 4abc4d43a8e8..8de2213664e0 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c @@ -107,22 +107,19 @@ static __inline__ void sunsab_cec_wait(struct uart_sunsab_port *up) udelay(1); } -static struct tty_struct * +static struct tty_port * receive_chars(struct uart_sunsab_port *up, union sab82532_irq_status *stat) { struct tty_port *port = NULL; - struct tty_struct *tty = NULL; unsigned char buf[32]; int saw_console_brk = 0; int free_fifo = 0; int count = 0; int i; - if (up->port.state != NULL) { /* Unopened serial console */ + if (up->port.state != NULL) /* Unopened serial console */ port = &up->port.state->port; - tty = port->tty; - } /* Read number of BYTES (Character + Status) available. */ if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { @@ -139,7 +136,7 @@ receive_chars(struct uart_sunsab_port *up, if (stat->sreg.isr0 & SAB82532_ISR0_TIME) { sunsab_cec_wait(up); writeb(SAB82532_CMDR_RFRD, &up->regs->w.cmdr); - return tty; + return port; } if (stat->sreg.isr0 & SAB82532_ISR0_RFO) @@ -219,7 +216,7 @@ receive_chars(struct uart_sunsab_port *up, if (saw_console_brk) sun_do_break(); - return tty; + return port; } static void sunsab_stop_tx(struct uart_port *); @@ -302,7 +299,7 @@ static void check_status(struct uart_sunsab_port *up, static irqreturn_t sunsab_interrupt(int irq, void *dev_id) { struct uart_sunsab_port *up = dev_id; - struct tty_struct *tty; + struct tty_port *port = NULL; union sab82532_irq_status status; unsigned long flags; unsigned char gis; @@ -316,12 +313,11 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id) if (gis & 2) status.sreg.isr1 = readb(&up->regs->r.isr1); - tty = NULL; if (status.stat) { if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME | SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) || (status.sreg.isr1 & SAB82532_ISR1_BRK)) - tty = receive_chars(up, &status); + port = receive_chars(up, &status); if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) || (status.sreg.isr1 & SAB82532_ISR1_CSC)) check_status(up, &status); @@ -331,8 +327,8 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id) spin_unlock_irqrestore(&up->port.lock, flags); - if (tty) - tty_flip_buffer_push(tty); + if (port) + tty_flip_buffer_push(port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 52325968b06c..e343d6670854 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c @@ -315,11 +315,10 @@ static void sunsu_enable_ms(struct uart_port *port) spin_unlock_irqrestore(&up->port.lock, flags); } -static struct tty_struct * +static void receive_chars(struct uart_sunsu_port *up, unsigned char *status) { struct tty_port *port = &up->port.state->port; - struct tty_struct *tty = port->tty; unsigned char ch, flag; int max_count = 256; int saw_console_brk = 0; @@ -391,8 +390,6 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status) if (saw_console_brk) sun_do_break(); - - return tty; } static void transmit_chars(struct uart_sunsu_port *up) @@ -461,20 +458,16 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id) spin_lock_irqsave(&up->port.lock, flags); do { - struct tty_struct *tty; - status = serial_inp(up, UART_LSR); - tty = NULL; if (status & UART_LSR_DR) - tty = receive_chars(up, &status); + receive_chars(up, &status); check_modem_status(up); if (status & UART_LSR_THRE) transmit_chars(up); spin_unlock_irqrestore(&up->port.lock, flags); - if (tty) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&up->port.state->port); spin_lock_irqsave(&up->port.lock, flags); diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index 4a11be3849f6..27669ff3d446 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c @@ -323,19 +323,15 @@ static void sunzilog_kbdms_receive_chars(struct uart_sunzilog_port *up, } } -static struct tty_struct * +static struct tty_port * sunzilog_receive_chars(struct uart_sunzilog_port *up, struct zilog_channel __iomem *channel) { struct tty_port *port = NULL; - struct tty_struct *tty; unsigned char ch, r1, flag; - tty = NULL; - if (up->port.state != NULL) { /* Unopened serial console */ + if (up->port.state != NULL) /* Unopened serial console */ port = &up->port.state->port; - tty = port->tty; /* mouse => tty is NULL */ - } for (;;) { @@ -403,7 +399,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, tty_insert_flip_char(port, 0, TTY_OVERRUN); } - return tty; + return port; } static void sunzilog_status_handle(struct uart_sunzilog_port *up, @@ -536,21 +532,21 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) while (up) { struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(&up->port); - struct tty_struct *tty; + struct tty_port *port; unsigned char r3; spin_lock(&up->port.lock); r3 = read_zsreg(channel, R3); /* Channel A */ - tty = NULL; + port = NULL; if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHARxIP) - tty = sunzilog_receive_chars(up, channel); + port = sunzilog_receive_chars(up, channel); if (r3 & CHAEXT) sunzilog_status_handle(up, channel); if (r3 & CHATxIP) @@ -558,22 +554,22 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); - if (tty) - tty_flip_buffer_push(tty); + if (port) + tty_flip_buffer_push(port); /* Channel B */ up = up->next; channel = ZILOG_CHANNEL_FROM_PORT(&up->port); spin_lock(&up->port.lock); - tty = NULL; + port = NULL; if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHBRxIP) - tty = sunzilog_receive_chars(up, channel); + port = sunzilog_receive_chars(up, channel); if (r3 & CHBEXT) sunzilog_status_handle(up, channel); if (r3 & CHBTxIP) @@ -581,8 +577,8 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); - if (tty) - tty_flip_buffer_push(tty); + if (port) + tty_flip_buffer_push(port); up = up->next; } diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c index f40c634f7528..6818410a2bea 100644 --- a/drivers/tty/serial/timbuart.c +++ b/drivers/tty/serial/timbuart.c @@ -100,7 +100,7 @@ static void timbuart_rx_chars(struct uart_port *port) } spin_unlock(&port->lock); - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(tport); spin_lock(&port->lock); dev_dbg(port->dev, "%s - total read %d bytes\n", diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 5caf1f0ebc82..5486505e87c7 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -156,7 +156,7 @@ static irqreturn_t ulite_isr(int irq, void *dev_id) /* work done? */ if (n > 1) { - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } else { return IRQ_NONE; diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index 7a2378627fa5..7355303dad99 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c @@ -470,7 +470,6 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) unsigned char ch, *cp; struct uart_port *port = &qe_port->port; struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct qe_bd *bdp; u16 status; unsigned int flg; @@ -531,7 +530,7 @@ error_return: qe_port->rx_cur = bdp; /* Activate BH processing */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); return; diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c index 62ee0166bc65..f655997f44af 100644 --- a/drivers/tty/serial/vr41xx_siu.c +++ b/drivers/tty/serial/vr41xx_siu.c @@ -313,12 +313,10 @@ static void siu_break_ctl(struct uart_port *port, int ctl) static inline void receive_chars(struct uart_port *port, uint8_t *status) { - struct tty_struct *tty; uint8_t lsr, ch; char flag; int max_count = RX_MAX_COUNT; - tty = port->state->port.tty; lsr = *status; do { @@ -365,7 +363,7 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status) lsr = siu_read(port, UART_LSR); } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); *status = lsr; } diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 7f4112423f3d..f1a398c672fa 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -137,15 +137,6 @@ static void vt8500_enable_ms(struct uart_port *port) static void handle_rx(struct uart_port *port) { struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tty_port_tty_get(tport); - if (!tty) { - /* Discard data: no tty available */ - int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8; - u16 ch; - while (count--) - ch = readw(port->membase + VT8500_RXFIFO); - return; - } /* * Handle overrun @@ -178,8 +169,7 @@ static void handle_rx(struct uart_port *port) tty_insert_flip_char(tport, c, flag); } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(tport); } static void handle_tx(struct uart_port *port) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 9ab910370c56..82a3151e393c 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -147,15 +147,11 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) { struct uart_port *port = (struct uart_port *)dev_id; - struct tty_struct *tty; unsigned long flags; unsigned int isrstatus, numbytes; unsigned int data; char status = TTY_NORMAL; - /* Get the tty which could be NULL so don't assume it's valid */ - tty = tty_port_tty_get(&port->state->port); - spin_lock_irqsave(&port->lock, flags); /* Read the interrupt status register to determine which @@ -187,14 +183,11 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) } else if (isrstatus & XUARTPS_IXR_OVERRUN) port->icount.overrun++; - if (tty) - uart_insert_char(port, isrstatus, - XUARTPS_IXR_OVERRUN, data, - status); + uart_insert_char(port, isrstatus, XUARTPS_IXR_OVERRUN, + data, status); } spin_unlock(&port->lock); - if (tty) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); spin_lock(&port->lock); } @@ -237,7 +230,6 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) /* be sure to release the lock and tty before leaving */ spin_unlock_irqrestore(&port->lock, flags); - tty_kref_put(tty); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c index 92c00b24d0df..6a169877109b 100644 --- a/drivers/tty/serial/zs.c +++ b/drivers/tty/serial/zs.c @@ -603,7 +603,7 @@ static void zs_receive_chars(struct zs_port *zport) uart_insert_char(uport, status, Rx_OVR, ch, flag); } - tty_flip_buffer_push(uport->state->port.tty); + tty_flip_buffer_push(&uport->state->port); } static void zs_raw_transmit_chars(struct zs_port *zport) diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 2f6967d61a80..555fdc0ed0f1 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -1439,7 +1439,6 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) u16 status; int work = 0; unsigned char DataByte; - struct tty_struct *tty = info->port.tty; struct mgsl_icount *icount = &info->icount; if ( debug_level >= DEBUG_LEVEL_ISR ) @@ -1501,7 +1500,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) if (status & RXSTATUS_BREAK_RECEIVED) { flag = TTY_BREAK; if (info->port.flags & ASYNC_SAK) - do_SAK(tty); + do_SAK(info->port.tty); } else if (status & RXSTATUS_PARITY_ERROR) flag = TTY_PARITY; else if (status & RXSTATUS_FRAMING_ERROR) @@ -1524,7 +1523,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) } if(work) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } /* mgsl_isr_misc() diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 9a0358a1e0dd..fced6acc74ee 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -1854,7 +1854,6 @@ static void hdlcdev_exit(struct slgt_info *info) */ static void rx_async(struct slgt_info *info) { - struct tty_struct *tty = info->port.tty; struct mgsl_icount *icount = &info->icount; unsigned int start, end; unsigned char *p; @@ -1915,8 +1914,8 @@ static void rx_async(struct slgt_info *info) break; } - if (tty && chars) - tty_flip_buffer_push(tty); + if (chars) + tty_flip_buffer_push(&info->port); } /* diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 419f58ff4a13..e4a2904af565 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -2167,7 +2167,6 @@ static void isr_rxrdy(SLMP_INFO * info) { u16 status; unsigned char DataByte; - struct tty_struct *tty = info->port.tty; struct mgsl_icount *icount = &info->icount; if ( debug_level >= DEBUG_LEVEL_ISR ) @@ -2225,8 +2224,7 @@ static void isr_rxrdy(SLMP_INFO * info) icount->frame,icount->overrun); } - if ( tty ) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } static void isr_txeom(SLMP_INFO * info, unsigned char status) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 1bfe97a8e2eb..b6efacadf23b 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -544,7 +544,7 @@ void tty_flush_to_ldisc(struct tty_struct *tty) /** * tty_flip_buffer_push - terminal - * @tty: tty to push + * @port: tty port to push * * Queue a push of the terminal flip buffers to the line discipline. This * function must not be called from IRQ context if port->low_latency is @@ -556,9 +556,9 @@ void tty_flush_to_ldisc(struct tty_struct *tty) * Locking: tty buffer lock. Driver locks in low latency mode. */ -void tty_flip_buffer_push(struct tty_struct *tty) +void tty_flip_buffer_push(struct tty_port *port) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; unsigned long flags; spin_lock_irqsave(&buf->lock, flags); @@ -566,7 +566,7 @@ void tty_flip_buffer_push(struct tty_struct *tty) buf->tail->commit = buf->tail->used; spin_unlock_irqrestore(&buf->lock, flags); - if (tty->port->low_latency) + if (port->low_latency) flush_to_ldisc(&buf->work); else schedule_work(&buf->work); diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 20dc2add27ba..15b36e2efa85 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -410,20 +410,12 @@ static int acm_submit_read_urbs(struct acm *acm, gfp_t mem_flags) static void acm_process_read_urb(struct acm *acm, struct urb *urb) { - struct tty_struct *tty; - if (!urb->actual_length) return; - tty = tty_port_tty_get(&acm->port); - if (!tty) - return; - tty_insert_flip_string(&acm->port, urb->transfer_buffer, urb->actual_length); - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&acm->port); } static void acm_read_bulk_callback(struct urb *urb) diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index 3560799d530a..ca4fc3d3e7ff 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c @@ -551,8 +551,8 @@ static void gs_rx_push(unsigned long _port) /* Push from tty to ldisc; without low_latency set this is handled by * a workqueue, so we won't get callbacks and can hold port_lock */ - if (tty && do_push) - tty_flip_buffer_push(tty); + if (do_push) + tty_flip_buffer_push(&port->port); /* We want our data queue to become empty ASAP, keeping data diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 3bb1f8f11fc8..6e320cec397d 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c @@ -140,16 +140,11 @@ static void aircable_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; char *data = (char *)urb->transfer_buffer; - struct tty_struct *tty; int has_headers; int count; int len; int i; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); count = 0; @@ -160,8 +155,7 @@ static void aircable_process_read_urb(struct urb *urb) } if (count) - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static struct usb_serial_driver aircable_device = { diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 1614feb6a76e..cbd904b8fba5 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -674,7 +674,6 @@ static void ark3116_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct ark3116_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; char tty_flag = TTY_NORMAL; unsigned long flags; @@ -689,10 +688,6 @@ static void ark3116_process_read_urb(struct urb *urb) if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - if (lsr & UART_LSR_BRK_ERROR_BITS) { if (lsr & UART_LSR_BI) tty_flag = TTY_BREAK; @@ -707,8 +702,7 @@ static void ark3116_process_read_urb(struct urb *urb) } tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static struct usb_serial_driver ark3116_device = { diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 7ba2c0bdcec9..84217e78ded4 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -242,7 +242,6 @@ static void belkin_sa_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct belkin_sa_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; unsigned long flags; unsigned char status; @@ -259,10 +258,6 @@ static void belkin_sa_process_read_urb(struct urb *urb) if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - if (status & BELKIN_SA_LSR_ERR) { /* Break takes precedence over parity, which takes precedence * over framing errors. */ @@ -281,8 +276,7 @@ static void belkin_sa_process_read_urb(struct urb *urb) tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static void belkin_sa_set_termios(struct tty_struct *tty, diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index e6976a974472..629bd2894506 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -324,7 +324,6 @@ static void cyberjack_read_bulk_callback(struct urb *urb) struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); struct device *dev = &port->dev; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; short todo; int result; @@ -337,16 +336,10 @@ static void cyberjack_read_bulk_callback(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (!tty) { - dev_dbg(dev, "%s - ignoring since device not open\n", __func__); - return; - } if (urb->actual_length) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); spin_lock(&priv->lock); diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index ac14e3eb95ea..8efa19d0e9fb 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -1214,10 +1214,10 @@ static void cypress_read_int_callback(struct urb *urb) spin_unlock_irqrestore(&priv->lock, flags); /* process read if there is data other than line status */ - if (tty && bytes > i) { + if (bytes > i) { tty_insert_flip_string_fixed_flag(&port->port, data + i, tty_flag, bytes - i); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } spin_lock_irqsave(&priv->lock, flags); diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index b5fa738512ca..ebe45fa0ed50 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -1399,9 +1399,7 @@ static void digi_read_bulk_callback(struct urb *urb) static int digi_read_inb_callback(struct urb *urb) { - struct usb_serial_port *port = urb->context; - struct tty_struct *tty; struct digi_port *priv = usb_get_serial_port_data(port); int opcode = ((unsigned char *)urb->transfer_buffer)[0]; int len = ((unsigned char *)urb->transfer_buffer)[1]; @@ -1425,7 +1423,6 @@ static int digi_read_inb_callback(struct urb *urb) return -1; } - tty = tty_port_tty_get(&port->port); spin_lock(&priv->dp_port_lock); /* check for throttle; if set, do not resubmit read urb */ @@ -1435,7 +1432,7 @@ static int digi_read_inb_callback(struct urb *urb) priv->dp_throttle_restart = 1; /* receive data */ - if (tty && opcode == DIGI_CMD_RECEIVE_DATA) { + if (opcode == DIGI_CMD_RECEIVE_DATA) { /* get flag from port_status */ flag = 0; @@ -1457,11 +1454,10 @@ static int digi_read_inb_callback(struct urb *urb) if (len > 0) { tty_insert_flip_string_fixed_flag(&port->port, data, flag, len); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } } spin_unlock(&priv->dp_port_lock); - tty_kref_put(tty); if (opcode == DIGI_CMD_RECEIVE_DISABLE) dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 6b880c33d258..b1b2dc64b50b 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -100,7 +100,6 @@ static void f81232_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct f81232_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; char tty_flag = TTY_NORMAL; unsigned long flags; @@ -117,10 +116,6 @@ static void f81232_process_read_urb(struct urb *urb) if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* break takes precedence over parity, */ /* which takes precedence over framing errors */ if (line_status & UART_BREAK_ERROR) @@ -145,8 +140,7 @@ static void f81232_process_read_urb(struct urb *urb) urb->actual_length); } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static int set_control_lines(struct usb_device *dev, u8 value) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index eb59ba3789ad..a96083b7fabc 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2040,25 +2040,19 @@ static int ftdi_process_packet(struct usb_serial_port *port, static void ftdi_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty; struct ftdi_private *priv = usb_get_serial_port_data(port); char *data = (char *)urb->transfer_buffer; int i; int len; int count = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { len = min_t(int, urb->actual_length - i, priv->max_packet_size); count += ftdi_process_packet(port, priv, &data[i], len); } if (count) - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static void ftdi_break_ctl(struct tty_struct *tty, int break_state) diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 498b5f0da639..1a07b12ef341 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -252,14 +252,11 @@ static inline int isAbortTrfCmnd(const unsigned char *buf) static void send_to_tty(struct usb_serial_port *port, char *data, unsigned int actual_length) { - struct tty_struct *tty = tty_port_tty_get(&port->port); - - if (tty && actual_length) { + if (actual_length) { usb_serial_debug_data(&port->dev, __func__, actual_length, data); tty_insert_flip_string(&port->port, data, actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); } diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 3780f6a501b3..4c5c23f1cae5 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -313,17 +313,12 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs); void usb_serial_generic_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty; char *ch = (char *)urb->transfer_buffer; int i; if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* The per character mucking around with sysrq path it too slow for stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases where the USB serial is not a console anyway */ @@ -335,8 +330,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb) tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); } } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb); diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index f96b91da964f..b00e5cbf741f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -232,8 +232,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength); static void process_rcvd_status(struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3); -static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length); +static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, + int length); static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data); @@ -1752,7 +1752,6 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, struct device *dev = &edge_serial->serial->dev->dev; struct usb_serial_port *port; struct edgeport_port *edge_port; - struct tty_struct *tty; __u16 lastBufferLength; __u16 rxLen; @@ -1860,14 +1859,11 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, edge_serial->rxPort]; edge_port = usb_get_serial_port_data(port); if (edge_port->open) { - tty = tty_port_tty_get( - &edge_port->port->port); - if (tty) { - dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", - __func__, rxLen, edge_serial->rxPort); - edge_tty_recv(edge_port->port, tty, buffer, rxLen); - tty_kref_put(tty); - } + dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", + __func__, rxLen, + edge_serial->rxPort); + edge_tty_recv(edge_port->port, buffer, + rxLen); edge_port->icount.rx += rxLen; } buffer += rxLen; @@ -2017,8 +2013,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, * edge_tty_recv * this function passes data on to the tty flip buffer *****************************************************************************/ -static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length) +static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, + int length) { int cnt; @@ -2030,7 +2026,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, data += cnt; length -= cnt; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } @@ -2086,14 +2082,9 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, } /* Place LSR data byte into Rx buffer */ - if (lsrData) { - struct tty_struct *tty = - tty_port_tty_get(&edge_port->port->port); - if (tty) { - edge_tty_recv(edge_port->port, tty, &data, 1); - tty_kref_put(tty); - } - } + if (lsrData) + edge_tty_recv(edge_port->port, &data, 1); + /* update input line counters */ icount = &edge_port->icount; if (newLsr & LSR_BREAK) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 1286a0b2e2b7..d6485be49ebf 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -201,8 +201,8 @@ static int closing_wait = EDGE_CLOSING_WAIT; static bool ignore_cpu_rev; static int default_uart_mode; /* RS232 */ -static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length); +static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, + int length); static void stop_read(struct edgeport_port *edge_port); static int restart_read(struct edgeport_port *edge_port); @@ -1540,7 +1540,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, struct async_icount *icount; __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); - struct tty_struct *tty; dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); @@ -1554,13 +1553,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); /* Place LSR data byte into Rx buffer */ - if (lsr_data) { - tty = tty_port_tty_get(&edge_port->port->port); - if (tty) { - edge_tty_recv(edge_port->port, tty, &data, 1); - tty_kref_put(tty); - } - } + if (lsr_data) + edge_tty_recv(edge_port->port, &data, 1); /* update input line counters */ icount = &edge_port->icount; @@ -1676,7 +1670,6 @@ static void edge_bulk_in_callback(struct urb *urb) struct edgeport_port *edge_port = urb->context; struct device *dev = &edge_port->port->dev; unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; int retval = 0; int port_number; int status = urb->status; @@ -1715,18 +1708,16 @@ static void edge_bulk_in_callback(struct urb *urb) ++data; } - tty = tty_port_tty_get(&edge_port->port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { usb_serial_debug_data(dev, __func__, urb->actual_length, data); if (edge_port->close_pending) dev_dbg(dev, "%s - close pending, dropping data on the floor\n", __func__); else - edge_tty_recv(edge_port->port, tty, data, + edge_tty_recv(edge_port->port, data, urb->actual_length); edge_port->icount.rx += urb->actual_length; } - tty_kref_put(tty); exit: /* continue read unless stopped */ @@ -1741,8 +1732,8 @@ exit: dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); } -static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length) +static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, + int length) { int queued; @@ -1750,7 +1741,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, if (queued < length) dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", __func__, length - queued); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } static void edge_bulk_out_callback(struct urb *urb) diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 171dae1f4a62..716930ab1bb1 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -287,7 +287,6 @@ static void ir_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; if (!urb->actual_length) return; @@ -302,12 +301,8 @@ static void ir_process_read_urb(struct urb *urb) if (urb->actual_length == 1) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static void ir_set_termios_callback(struct urb *urb) diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index dd0d910730c7..ff77027160aa 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -581,7 +581,6 @@ static void read_buf_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; int status = urb->status; if (status) { @@ -592,14 +591,12 @@ static void read_buf_callback(struct urb *urb) } dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); - tty = tty_port_tty_get(&port->port); if (data == NULL) dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); - if (tty && urb->actual_length && data) { + if (urb->actual_length && data) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); iuu_led_activity_on(urb); } diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 14a219ba4ee6..f6d7f68fa43c 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -291,7 +291,6 @@ static void usa26_indat_callback(struct urb *urb) int i, err; int endpoint; struct usb_serial_port *port; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -304,8 +303,7 @@ static void usa26_indat_callback(struct urb *urb) } port = urb->context; - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no errors on individual bytes, only @@ -332,9 +330,8 @@ static void usa26_indat_callback(struct urb *urb) flag); } } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); /* Resubmit urb so we continue receiving */ err = usb_submit_urb(urb, GFP_ATOMIC); @@ -447,7 +444,6 @@ static void usa28_indat_callback(struct urb *urb) { int err; struct usb_serial_port *port; - struct tty_struct *tty; unsigned char *data; struct keyspan_port_private *p_priv; int status = urb->status; @@ -470,13 +466,11 @@ static void usa28_indat_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); /* Resubmit urb so we continue receiving */ err = usb_submit_urb(urb, GFP_ATOMIC); @@ -671,7 +665,6 @@ static void usa49_indat_callback(struct urb *urb) int i, err; int endpoint; struct usb_serial_port *port; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -684,8 +677,7 @@ static void usa49_indat_callback(struct urb *urb) } port = urb->context; - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no error on any byte */ @@ -706,9 +698,8 @@ static void usa49_indat_callback(struct urb *urb) flag); } } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); /* Resubmit urb so we continue receiving */ err = usb_submit_urb(urb, GFP_ATOMIC); @@ -721,7 +712,6 @@ static void usa49wg_indat_callback(struct urb *urb) int i, len, x, err; struct usb_serial *serial; struct usb_serial_port *port; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -746,7 +736,6 @@ static void usa49wg_indat_callback(struct urb *urb) return; } port = serial->port[data[i++]]; - tty = tty_port_tty_get(&port->port); len = data[i++]; /* 0x80 bit is error flag */ @@ -774,8 +763,7 @@ static void usa49wg_indat_callback(struct urb *urb) i += 2; } } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } } @@ -796,7 +784,6 @@ static void usa90_indat_callback(struct urb *urb) int endpoint; struct usb_serial_port *port; struct keyspan_port_private *p_priv; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -812,7 +799,6 @@ static void usa90_indat_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (urb->actual_length) { - tty = tty_port_tty_get(&port->port); /* if current mode is DMA, looks like usa28 format otherwise looks like usa26 data format */ @@ -848,8 +834,7 @@ static void usa90_indat_callback(struct urb *urb) } } } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } /* Resubmit urb so we continue receiving */ diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 334b1a295c6b..3b17d5d13dc8 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -138,7 +138,6 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) static void keyspan_pda_rx_interrupt(struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int retval; int status = urb->status; @@ -163,14 +162,12 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) /* see if the message is data or a status interrupt */ switch (data[0]) { case 0: - tty = tty_port_tty_get(&port->port); /* rest of message is rx data */ - if (tty && urb->actual_length) { + if (urb->actual_length) { tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); break; case 1: /* status interrupt */ diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 8ee0825ad700..769d910ae0a5 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -389,7 +389,6 @@ static void klsi_105_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; unsigned len; /* empty urbs seem to happen, we ignore them */ @@ -401,10 +400,6 @@ static void klsi_105_process_read_urb(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - len = get_unaligned_le16(data); if (len > urb->actual_length - KLSI_HDR_LEN) { dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); @@ -412,8 +407,7 @@ static void klsi_105_process_read_urb(struct urb *urb) } tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static void klsi_105_set_termios(struct tty_struct *tty, diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 135c8b4b26f7..903d938e174b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -324,7 +324,6 @@ static void kobil_read_int_callback(struct urb *urb) { int result; struct usb_serial_port *port = urb->context; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -333,8 +332,7 @@ static void kobil_read_int_callback(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { /* BEGIN DEBUG */ /* @@ -354,9 +352,8 @@ static void kobil_read_int_callback(struct urb *urb) /* END DEBUG */ tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index ba20bb037b28..f42528e05d7b 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -531,7 +531,6 @@ static void mct_u232_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct mct_u232_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int retval; int status = urb->status; @@ -561,13 +560,9 @@ static void mct_u232_read_int_callback(struct urb *urb) */ if (urb->transfer_buffer_length > 2) { if (urb->actual_length) { - tty = tty_port_tty_get(&port->port); - if (tty) { - tty_insert_flip_string(&port->port, data, - urb->actual_length); - tty_flip_buffer_push(tty); - } - tty_kref_put(tty); + tty_insert_flip_string(&port->port, data, + urb->actual_length); + tty_flip_buffer_push(&port->port); } goto exit; } diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 6264f3974ea7..bf3c7a23553e 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c @@ -95,7 +95,6 @@ static void metrousb_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int throttled = 0; int result = 0; @@ -124,15 +123,13 @@ static void metrousb_read_int_callback(struct urb *urb) /* Set the data read from the usb port into the serial port buffer. */ - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { /* Loop through the data copying each byte to the tty layer. */ tty_insert_flip_string(&port->port, data, urb->actual_length); /* Force the data to the tty layer. */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); /* Set any port variables. */ spin_lock_irqsave(&metro_priv->lock, flags); diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 22818fb765e0..e0ebec3b5d6a 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -899,7 +899,6 @@ static void mos7720_bulk_in_callback(struct urb *urb) int retval; unsigned char *data ; struct usb_serial_port *port; - struct tty_struct *tty; int status = urb->status; if (status) { @@ -913,12 +912,10 @@ static void mos7720_bulk_in_callback(struct urb *urb) data = urb->transfer_buffer; - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); if (port->read_urb->status != -EINPROGRESS) { retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 3ddd7a1f7ff3..809fb329eca5 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -744,7 +744,6 @@ static void mos7840_bulk_in_callback(struct urb *urb) struct usb_serial *serial; struct usb_serial_port *port; struct moschip_port *mos7840_port; - struct tty_struct *tty; int status = urb->status; mos7840_port = urb->context; @@ -774,12 +773,8 @@ static void mos7840_bulk_in_callback(struct urb *urb) if (urb->actual_length) { struct tty_port *tport = &mos7840_port->port->port; - tty = tty_port_tty_get(tport); - if (tty) { - tty_insert_flip_string(tport, data, urb->actual_length); - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_insert_flip_string(tport, data, urb->actual_length); + tty_flip_buffer_push(tport); mos7840_port->icount.rx += urb->actual_length; smp_wmb(); dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 0d96a1a7b9e5..38725fc8c2c8 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c @@ -32,7 +32,6 @@ static void navman_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; int status = urb->status; int result; @@ -55,12 +54,10 @@ static void navman_read_int_callback(struct urb *urb) usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); - tty = tty_port_tty_get(&port->port); - if (tty && urb->actual_length) { + if (urb->actual_length) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); exit: result = usb_submit_urb(urb, GFP_ATOMIC); diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 338191bae5a3..1e1cafe287e4 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -174,14 +174,9 @@ static void omninet_read_bulk_callback(struct urb *urb) } if (urb->actual_length && header->oh_len) { - struct tty_struct *tty = tty_port_tty_get(&port->port); - if (tty) { - tty_insert_flip_string(&port->port, - data + OMNINET_DATAOFFSET, - header->oh_len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_insert_flip_string(&port->port, data + OMNINET_DATAOFFSET, + header->oh_len); + tty_flip_buffer_push(&port->port); } /* Continue trying to always read */ diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index d3b74e50aff1..e13e1a4d3e1e 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -51,15 +51,8 @@ struct opticon_private { static void opticon_process_data_packet(struct usb_serial_port *port, const unsigned char *buf, size_t len) { - struct tty_struct *tty; - - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - tty_insert_flip_string(&port->port, buf, len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static void opticon_process_status_packet(struct usb_serial_port *port, diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 7a53fe9f3af3..a958fd41b5b3 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c @@ -820,7 +820,6 @@ static void oti6858_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct oti6858_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; unsigned long flags; int status = urb->status; @@ -835,12 +834,10 @@ static void oti6858_read_bulk_callback(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (tty != NULL && urb->actual_length > 0) { + if (urb->actual_length > 0) { tty_insert_flip_string(&port->port, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } - tty_kref_put(tty); /* schedule the interrupt urb */ result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 00047f3c7293..54adc9125e5c 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -772,7 +772,6 @@ static void pl2303_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct pl2303_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; char tty_flag = TTY_NORMAL; unsigned long flags; @@ -789,10 +788,6 @@ static void pl2303_process_read_urb(struct urb *urb) if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* break takes precedence over parity, */ /* which takes precedence over framing errors */ if (line_status & UART_BREAK_ERROR) @@ -817,8 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb) urb->actual_length); } - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } /* All of the device info needed for the PL2303 SIO serial converter */ diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 5dccc4f957df..6850745808c3 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -609,7 +609,6 @@ void qt2_process_read_urb(struct urb *urb) struct qt2_serial_private *serial_priv; struct usb_serial_port *port; struct qt2_port_private *port_priv; - struct tty_struct *tty; bool escapeflag; unsigned char *ch; int i; @@ -620,15 +619,11 @@ void qt2_process_read_urb(struct urb *urb) return; ch = urb->transfer_buffer; - tty = NULL; serial = urb->context; serial_priv = usb_get_serial_data(serial); port = serial->port[serial_priv->current_port]; port_priv = usb_get_serial_port_data(port); - if (port_priv->is_open) - tty = tty_port_tty_get(&port->port); - for (i = 0; i < urb->actual_length; i++) { ch = (unsigned char *)urb->transfer_buffer + i; if ((i <= (len - 3)) && @@ -666,10 +661,7 @@ void qt2_process_read_urb(struct urb *urb) __func__); break; } - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(&port->port); newport = *(ch + 3); @@ -683,10 +675,6 @@ void qt2_process_read_urb(struct urb *urb) serial_priv->current_port = newport; port = serial->port[serial_priv->current_port]; port_priv = usb_get_serial_port_data(port); - if (port_priv->is_open) - tty = tty_port_tty_get(&port->port); - else - tty = NULL; i += 3; escapeflag = true; break; @@ -716,10 +704,7 @@ void qt2_process_read_urb(struct urb *urb) tty_insert_flip_string(&port->port, ch, 1); } - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(&port->port); } static void qt2_write_bulk_callback(struct urb *urb) diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index ad12e9e2c7ee..21cd7bf2a8cc 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -207,38 +207,31 @@ static void safe_process_read_urb(struct urb *urb) unsigned char *data = urb->transfer_buffer; unsigned char length = urb->actual_length; int actual_length; - struct tty_struct *tty; __u16 fcs; if (!length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - if (!safe) goto out; fcs = fcs_compute10(data, length, CRC10_INITFCS); if (fcs) { dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); - goto err; + return; } actual_length = data[length - 2] >> 2; if (actual_length > (length - 2)) { dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n", __func__, actual_length, length); - goto err; + return; } dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); length = actual_length; out: tty_insert_flip_string(&port->port, data, length); - tty_flip_buffer_push(tty); -err: - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static int safe_prepare_write_buffer(struct usb_serial_port *port, diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 64e53fda149b..70aee8d59f23 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -569,7 +569,6 @@ static void sierra_indat_callback(struct urb *urb) int err; int endpoint; struct usb_serial_port *port; - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -581,16 +580,12 @@ static void sierra_indat_callback(struct urb *urb) " endpoint %02x\n", __func__, status, endpoint); } else { if (urb->actual_length) { - tty = tty_port_tty_get(&port->port); - if (tty) { - tty_insert_flip_string(&port->port, data, - urb->actual_length); - tty_flip_buffer_push(tty); - - tty_kref_put(tty); - usb_serial_debug_data(&port->dev, __func__, - urb->actual_length, data); - } + tty_insert_flip_string(&port->port, data, + urb->actual_length); + tty_flip_buffer_push(&port->port); + + usb_serial_debug_data(&port->dev, __func__, + urb->actual_length, data); } else { dev_dbg(&port->dev, "%s: empty read urb" " received\n", __func__); diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 04e373152724..91ff8e3bddbd 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -462,7 +462,6 @@ static void spcp8x5_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct spcp8x5_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; unsigned long flags; u8 status; @@ -481,9 +480,6 @@ static void spcp8x5_process_read_urb(struct urb *urb) if (!urb->actual_length) return; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; if (status & UART_STATE_TRANSIENT_MASK) { /* break takes precedence over parity, which takes precedence @@ -500,15 +496,19 @@ static void spcp8x5_process_read_urb(struct urb *urb) if (status & UART_OVERRUN_ERROR) tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); - if (status & UART_DCD) - usb_serial_handle_dcd_change(port, tty, - priv->line_status & MSR_STATUS_LINE_DCD); + if (status & UART_DCD) { + struct tty_struct *tty = tty_port_tty_get(&port->port); + if (tty) { + usb_serial_handle_dcd_change(port, tty, + priv->line_status & MSR_STATUS_LINE_DCD); + tty_kref_put(tty); + } + } } tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, urb->actual_length); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static int spcp8x5_wait_modem_info(struct usb_serial_port *port, diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 38713156e957..58bc7e793524 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -582,7 +582,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr, } -static int ssu100_process_packet(struct urb *urb) +static void ssu100_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; char *packet = (char *)urb->transfer_buffer; @@ -609,7 +609,7 @@ static int ssu100_process_packet(struct urb *urb) ch = packet; if (!len) - return 0; /* status only */ + return; /* status only */ if (port->port.console && port->sysrq) { for (i = 0; i < len; i++, ch++) { @@ -619,24 +619,7 @@ static int ssu100_process_packet(struct urb *urb) } else tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); - return len; -} - -static void ssu100_process_read_urb(struct urb *urb) -{ - struct usb_serial_port *port = urb->context; - struct tty_struct *tty; - int count; - - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - - count = ssu100_process_packet(urb); - - if (count) - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); } static struct usb_serial_driver ssu100_device = { diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 2ffa6ae3b5ed..be05e6caf9a3 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c @@ -48,7 +48,6 @@ static void symbol_int_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; struct usb_serial_port *port = priv->port; int status = urb->status; - struct tty_struct *tty; int result; int data_length; @@ -82,13 +81,8 @@ static void symbol_int_callback(struct urb *urb) * we pretty much just ignore the size and send everything * else to the tty layer. */ - tty = tty_port_tty_get(&port->port); - if (tty) { - tty_insert_flip_string(&port->port, &data[1], - data_length); - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_insert_flip_string(&port->port, &data[1], data_length); + tty_flip_buffer_push(&port->port); } else { dev_dbg(&priv->udev->dev, "Improper amount of data received from the device, " diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 05077e3c7631..39cb9b807c3c 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -121,8 +121,8 @@ static void ti_interrupt_callback(struct urb *urb); static void ti_bulk_in_callback(struct urb *urb); static void ti_bulk_out_callback(struct urb *urb); -static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length); +static void ti_recv(struct usb_serial_port *port, unsigned char *data, + int length); static void ti_send(struct ti_port *tport); static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); static int ti_get_lsr(struct ti_port *tport); @@ -1118,7 +1118,6 @@ static void ti_bulk_in_callback(struct urb *urb) struct device *dev = &urb->dev->dev; int status = urb->status; int retval = 0; - struct tty_struct *tty; switch (status) { case 0: @@ -1145,23 +1144,18 @@ static void ti_bulk_in_callback(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (tty) { - if (urb->actual_length) { - usb_serial_debug_data(dev, __func__, urb->actual_length, - urb->transfer_buffer); + if (urb->actual_length) { + usb_serial_debug_data(dev, __func__, urb->actual_length, + urb->transfer_buffer); - if (!tport->tp_is_open) - dev_dbg(dev, "%s - port closed, dropping data\n", - __func__); - else - ti_recv(port, tty, urb->transfer_buffer, - urb->actual_length); - spin_lock(&tport->tp_lock); - tport->tp_icount.rx += urb->actual_length; - spin_unlock(&tport->tp_lock); - } - tty_kref_put(tty); + if (!tport->tp_is_open) + dev_dbg(dev, "%s - port closed, dropping data\n", + __func__); + else + ti_recv(port, urb->transfer_buffer, urb->actual_length); + spin_lock(&tport->tp_lock); + tport->tp_icount.rx += urb->actual_length; + spin_unlock(&tport->tp_lock); } exit: @@ -1209,8 +1203,8 @@ static void ti_bulk_out_callback(struct urb *urb) } -static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, - unsigned char *data, int length) +static void ti_recv(struct usb_serial_port *port, unsigned char *data, + int length) { int cnt; @@ -1222,11 +1216,10 @@ static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, if (cnt == 0) break; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); data += cnt; length -= cnt; } while (length > 0); - } diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 293b460030cb..a547c91e3c05 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -275,7 +275,6 @@ static void usb_wwan_indat_callback(struct urb *urb) int err; int endpoint; struct usb_serial_port *port; - struct tty_struct *tty; struct device *dev; unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -288,16 +287,12 @@ static void usb_wwan_indat_callback(struct urb *urb) dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", __func__, status, endpoint); } else { - tty = tty_port_tty_get(&port->port); - if (tty) { - if (urb->actual_length) { - tty_insert_flip_string(&port->port, data, - urb->actual_length); - tty_flip_buffer_push(tty); - } else - dev_dbg(dev, "%s: empty read urb received\n", __func__); - tty_kref_put(tty); - } + if (urb->actual_length) { + tty_insert_flip_string(&port->port, data, + urb->actual_length); + tty_flip_buffer_push(&port->port); + } else + dev_dbg(dev, "%s: empty read urb received\n", __func__); /* Resubmit urb so we continue receiving */ err = usb_submit_urb(urb, GFP_ATOMIC); diff --git a/include/linux/tty.h b/include/linux/tty.h index f16a47a13a09..f89acd1ed6d3 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -387,7 +387,6 @@ extern void do_SAK(struct tty_struct *tty); extern void __do_SAK(struct tty_struct *tty); extern void disassociate_ctty(int priv); extern void no_tty(void); -extern void tty_flip_buffer_push(struct tty_struct *tty); extern void tty_flush_to_ldisc(struct tty_struct *tty); extern void tty_buffer_free_all(struct tty_port *port); extern void tty_buffer_flush(struct tty_struct *tty); diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 5cb694aba322..c5572807633a 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -10,6 +10,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, size_t size); extern int tty_prepare_flip_string_flags(struct tty_port *port, unsigned char **chars, char **flags, size_t size); +extern void tty_flip_buffer_push(struct tty_port *port); void tty_schedule_flip(struct tty_struct *tty); static inline int tty_insert_flip_char(struct tty_port *port, diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index cbec3b642871..b6e44ad6cca6 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -541,23 +541,21 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) { struct rfcomm_dev *dev = dlc->owner; - struct tty_struct *tty; if (!dev) { kfree_skb(skb); return; } - tty = dev->port.tty; - if (!tty || !skb_queue_empty(&dev->pending)) { + if (!skb_queue_empty(&dev->pending)) { skb_queue_tail(&dev->pending, skb); return; } - BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); + BT_DBG("dlc %p len %d", dlc, skb->len); tty_insert_flip_string(&dev->port, skb->data, skb->len); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&dev->port); kfree_skb(skb); } @@ -621,14 +619,10 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig) /* ---- TTY functions ---- */ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) { - struct tty_struct *tty = dev->port.tty; struct sk_buff *skb; int inserted = 0; - if (!tty) - return; - - BT_DBG("dev %p tty %p", dev, tty); + BT_DBG("dev %p", dev); rfcomm_dlc_lock(dev->dlc); @@ -641,7 +635,7 @@ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) rfcomm_dlc_unlock(dev->dlc); if (inserted > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&dev->port); } static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 2491f6f53871..9a5fd3c3e530 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -1136,14 +1136,14 @@ static int ircomm_tty_data_indication(void *instance, void *sap, ircomm_tty_send_initial_parameters(self); ircomm_tty_link_established(self); } + tty_kref_put(tty); /* * Use flip buffer functions since the code may be called from interrupt * context */ tty_insert_flip_string(&self->port, skb->data, skb->len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&self->port); /* No need to kfree_skb - see ircomm_ttp_data_indication() */ -- cgit v1.2.3 From 6732c8bb8671acbdac6cdc93dd72ddd581dd5e25 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:07 +0100 Subject: TTY: switch tty_schedule_flip Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. This is the last one: tty_schedule_flip Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/srmcons.c | 17 ++++++++--------- drivers/s390/char/keyboard.h | 12 ++---------- drivers/staging/serqt_usb2/serqt_usb2.c | 19 ++++++------------- drivers/tty/cyclades.c | 33 ++++++++++++--------------------- drivers/tty/moxa.c | 4 ++-- drivers/tty/serial/68328serial.c | 15 ++++----------- drivers/tty/serial/lpc32xx_hs.c | 6 +----- drivers/tty/tty_buffer.c | 8 ++++---- drivers/tty/vt/keyboard.c | 19 +++---------------- drivers/tty/vt/vt.c | 16 ++++++++-------- include/linux/tty_flip.h | 2 +- 11 files changed, 51 insertions(+), 100 deletions(-) (limited to 'drivers') diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 21b57a66e809..6f01d9ad7b81 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -44,9 +44,8 @@ typedef union _srmcons_result { /* called with callback_lock held */ static int -srmcons_do_receive_chars(struct tty_struct *tty) +srmcons_do_receive_chars(struct tty_port *port) { - struct tty_port *port = tty->port; srmcons_result result; int count = 0, loops = 0; @@ -59,7 +58,7 @@ srmcons_do_receive_chars(struct tty_struct *tty) } while((result.bits.status & 1) && (++loops < 10)); if (count) - tty_schedule_flip(tty); + tty_schedule_flip(port); return count; } @@ -74,7 +73,7 @@ srmcons_receive_chars(unsigned long data) local_irq_save(flags); if (spin_trylock(&srmcons_callback_lock)) { - if (!srmcons_do_receive_chars(port->tty)) + if (!srmcons_do_receive_chars(port)) incr = 100; spin_unlock(&srmcons_callback_lock); } @@ -89,7 +88,7 @@ srmcons_receive_chars(unsigned long data) /* called with callback_lock held */ static int -srmcons_do_write(struct tty_struct *tty, const char *buf, int count) +srmcons_do_write(struct tty_port *port, const char *buf, int count) { static char str_cr[1] = "\r"; long c, remaining = count; @@ -114,10 +113,10 @@ srmcons_do_write(struct tty_struct *tty, const char *buf, int count) cur += result.bits.c; /* - * Check for pending input iff a tty was provided + * Check for pending input iff a tty port was provided */ - if (tty) - srmcons_do_receive_chars(tty); + if (port) + srmcons_do_receive_chars(port); } while (need_cr) { @@ -136,7 +135,7 @@ srmcons_write(struct tty_struct *tty, unsigned long flags; spin_lock_irqsave(&srmcons_callback_lock, flags); - srmcons_do_write(tty, (const char *) buf, count); + srmcons_do_write(tty->port, (const char *) buf, count); spin_unlock_irqrestore(&srmcons_callback_lock, flags); return count; diff --git a/drivers/s390/char/keyboard.h b/drivers/s390/char/keyboard.h index acab28d4f06b..a31f339211d5 100644 --- a/drivers/s390/char/keyboard.h +++ b/drivers/s390/char/keyboard.h @@ -43,22 +43,14 @@ int kbd_ioctl(struct kbd_data *, unsigned int, unsigned long); static inline void kbd_put_queue(struct tty_port *port, int ch) { - struct tty_struct *tty = tty_port_tty_get(port); - if (!tty) - return; tty_insert_flip_char(port, ch, 0); - tty_schedule_flip(tty); - tty_kref_put(tty); + tty_schedule_flip(port); } static inline void kbd_puts_queue(struct tty_port *port, char *cp) { - struct tty_struct *tty = tty_port_tty_get(port); - if (!tty) - return; while (*cp) tty_insert_flip_char(port, *cp++, 0); - tty_schedule_flip(tty); - tty_kref_put(tty); + tty_schedule_flip(port); } diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index df29a3de29f2..b1bb1a6abe81 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -356,7 +356,6 @@ static void qt_read_bulk_callback(struct urb *urb) struct usb_serial_port *port = urb->context; struct usb_serial *serial = get_usb_serial(port, __func__); struct quatech_port *qt_port = qt_get_port_private(port); - struct tty_struct *tty; int result; if (urb->status) { @@ -367,27 +366,23 @@ static void qt_read_bulk_callback(struct urb *urb) return; } - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - dev_dbg(&port->dev, "%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding); if (port_paranoia_check(port, __func__) != 0) { qt_port->ReadBulkStopped = 1; - goto exit; + return; } if (!serial) - goto exit; + return; if (qt_port->closePending == 1) { /* Were closing , stop reading */ dev_dbg(&port->dev, "%s - (qt_port->closepending == 1\n", __func__); qt_port->ReadBulkStopped = 1; - goto exit; + return; } /* @@ -397,7 +392,7 @@ static void qt_read_bulk_callback(struct urb *urb) */ if (qt_port->RxHolding == 1) { qt_port->ReadBulkStopped = 1; - goto exit; + return; } if (urb->status) { @@ -406,7 +401,7 @@ static void qt_read_bulk_callback(struct urb *urb) dev_dbg(&port->dev, "%s - nonzero read bulk status received: %d\n", __func__, urb->status); - goto exit; + return; } if (urb->actual_length) @@ -427,13 +422,11 @@ static void qt_read_bulk_callback(struct urb *urb) else { if (urb->actual_length) { tty_flip_buffer_push(&port->port); - tty_schedule_flip(tty); + tty_schedule_flip(&port->port); } } schedule_work(&port->work); -exit: - tty_kref_put(tty); } /* diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index d1fe9a1f8475..42a329b8af9f 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -441,7 +441,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, void __iomem *base_addr) { struct cyclades_port *info; - struct tty_struct *tty; struct tty_port *port; int len, index = cinfo->bus_index; u8 ivr, save_xir, channel, save_car, data, char_count; @@ -458,18 +457,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, cyy_writeb(info, CyCAR, save_xir); ivr = cyy_readb(info, CyRIVR) & CyIVRMask; - tty = tty_port_tty_get(port); - /* if there is nowhere to put the data, discard it */ - if (tty == NULL) { - if (ivr == CyIVRRxEx) { /* exception */ - data = cyy_readb(info, CyRDSR); - } else { /* normal character reception */ - char_count = cyy_readb(info, CyRDCR); - while (char_count--) - data = cyy_readb(info, CyRDSR); - } - goto end; - } /* there is an open port for this data */ if (ivr == CyIVRRxEx) { /* exception */ data = cyy_readb(info, CyRDSR); @@ -486,7 +473,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, if (data & info->ignore_status_mask) { info->icount.rx++; - tty_kref_put(tty); return; } if (tty_buffer_request_room(port, 1)) { @@ -496,8 +482,14 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, cyy_readb(info, CyRDSR), TTY_BREAK); info->icount.rx++; - if (port->flags & ASYNC_SAK) - do_SAK(tty); + if (port->flags & ASYNC_SAK) { + struct tty_struct *tty = + tty_port_tty_get(port); + if (tty) { + do_SAK(tty); + tty_kref_put(tty); + } + } } else if (data & CyFRAME) { tty_insert_flip_char(port, cyy_readb(info, CyRDSR), @@ -566,9 +558,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, } info->idle_stats.recv_idle = jiffies; } - tty_schedule_flip(tty); - tty_kref_put(tty); -end: + tty_schedule_flip(port); + /* end of service */ cyy_writeb(info, CyRIR, save_xir & 0x3f); cyy_writeb(info, CyCAR, save_car); @@ -1012,7 +1003,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) jiffies + 1); #endif info->idle_stats.recv_idle = jiffies; - tty_schedule_flip(tty); + tty_schedule_flip(&info->port); } /* Update rx_get */ cy_writel(&buf_ctrl->rx_get, new_rx_get); @@ -1191,7 +1182,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) if (delta_count) wake_up_interruptible(&info->port.delta_msr_wait); if (special_count) - tty_schedule_flip(tty); + tty_schedule_flip(&info->port); tty_kref_put(tty); } } diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index f42492db31c9..adeac255e526 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -1405,7 +1405,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle, if (inited && !test_bit(TTY_THROTTLED, &tty->flags) && MoxaPortRxQueue(p) > 0) { /* RX */ MoxaPortReadData(p); - tty_schedule_flip(tty); + tty_schedule_flip(&p->port); } } else { clear_bit(EMPTYWAIT, &p->statusflags); @@ -1430,7 +1430,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle, if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ tty_insert_flip_char(&p->port, 0, TTY_BREAK); - tty_schedule_flip(tty); + tty_schedule_flip(&p->port); } if (intr & IntrLine) diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 3719273cf0be..641a5a4d73d9 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c @@ -262,8 +262,7 @@ static void rs_start(struct tty_struct *tty) local_irq_restore(flags); } -static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, - unsigned short rx) +static void receive_chars(struct m68k_serial *info, unsigned short rx) { m68328_uart *uart = &uart_addr[info->line]; unsigned char ch, flag; @@ -293,9 +292,6 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, } } - if(!tty) - goto clear_and_exit; - flag = TTY_NORMAL; if (rx & URX_PARITY_ERROR) @@ -310,10 +306,7 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, } while((rx = uart->urx.w) & URX_DATA_READY); #endif - tty_schedule_flip(tty); - -clear_and_exit: - return; + tty_schedule_flip(&info->tport); } static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty) @@ -367,11 +360,11 @@ irqreturn_t rs_interrupt(int irq, void *dev_id) tx = uart->utx.w; if (rx & URX_DATA_READY) - receive_chars(info, tty, rx); + receive_chars(info, rx); if (tx & UTX_TX_AVAIL) transmit_chars(info, tty); #else - receive_chars(info, tty, rx); + receive_chars(info, rx); #endif tty_kref_put(tty); diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index c8448e6f52e5..c01b58f3729c 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -323,7 +323,6 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; struct tty_port *port = &port->state->port; - struct tty_struct *tty = tty_port_tty_get(tport); u32 status; spin_lock(&port->lock); @@ -348,9 +347,7 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) LPC32XX_HSUART_IIR(port->membase)); port->icount.overrun++; tty_insert_flip_char(tport, 0, TTY_OVERRUN); - if (tty) { - tty_schedule_flip(tty); - } + tty_schedule_flip(tport); } /* Data received? */ @@ -366,7 +363,6 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) } spin_unlock(&port->lock); - tty_kref_put(tty); return IRQ_HANDLED; } diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index b6efacadf23b..d6969f6e4c43 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -349,7 +349,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags); /** * tty_schedule_flip - push characters to ldisc - * @tty: tty to push from + * @port: tty port to push from * * Takes any pending buffers and transfers their ownership to the * ldisc side of the queue. It then schedules those characters for @@ -360,11 +360,11 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags); * Locking: Takes port->buf.lock */ -void tty_schedule_flip(struct tty_struct *tty) +void tty_schedule_flip(struct tty_port *port) { - struct tty_bufhead *buf = &tty->port->buf; + struct tty_bufhead *buf = &port->buf; unsigned long flags; - WARN_ON(tty->port->low_latency); + WARN_ON(port->low_latency); spin_lock_irqsave(&buf->lock, flags); if (buf->tail != NULL) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 5aace4d47cb6..a9af1b9ae160 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -307,26 +307,17 @@ int kbd_rate(struct kbd_repeat *rep) */ static void put_queue(struct vc_data *vc, int ch) { - struct tty_struct *tty = vc->port.tty; - tty_insert_flip_char(&vc->port, ch, 0); - if (tty) { - tty_schedule_flip(tty); - } + tty_schedule_flip(&vc->port); } static void puts_queue(struct vc_data *vc, char *cp) { - struct tty_struct *tty = vc->port.tty; - - if (!tty) - return; - while (*cp) { tty_insert_flip_char(&vc->port, *cp, 0); cp++; } - tty_schedule_flip(tty); + tty_schedule_flip(&vc->port); } static void applkey(struct vc_data *vc, int key, char mode) @@ -582,12 +573,8 @@ static void fn_inc_console(struct vc_data *vc) static void fn_send_intr(struct vc_data *vc) { - struct tty_struct *tty = vc->port.tty; - - if (!tty) - return; tty_insert_flip_char(&vc->port, 0, TTY_BREAK); - tty_schedule_flip(tty); + tty_schedule_flip(&vc->port); } static void fn_scroll_forw(struct vc_data *vc) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 811f2505e9ee..1a2728034599 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1333,13 +1333,13 @@ static void csi_m(struct vc_data *vc) update_attr(vc); } -static void respond_string(const char *p, struct tty_struct *tty) +static void respond_string(const char *p, struct tty_port *port) { while (*p) { - tty_insert_flip_char(tty->port, *p, 0); + tty_insert_flip_char(port, *p, 0); p++; } - tty_schedule_flip(tty); + tty_schedule_flip(port); } static void cursor_report(struct vc_data *vc, struct tty_struct *tty) @@ -1347,17 +1347,17 @@ static void cursor_report(struct vc_data *vc, struct tty_struct *tty) char buf[40]; sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); - respond_string(buf, tty); + respond_string(buf, tty->port); } static inline void status_report(struct tty_struct *tty) { - respond_string("\033[0n", tty); /* Terminal ok */ + respond_string("\033[0n", tty->port); /* Terminal ok */ } -static inline void respond_ID(struct tty_struct * tty) +static inline void respond_ID(struct tty_struct *tty) { - respond_string(VT102ID, tty); + respond_string(VT102ID, tty->port); } void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) @@ -1366,7 +1366,7 @@ void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx), (char)('!' + mry)); - respond_string(buf, tty); + respond_string(buf, tty->port); } /* invoked via ioctl(TIOCLINUX) and through set_selection */ diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index c5572807633a..e0f252633b47 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -11,7 +11,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, extern int tty_prepare_flip_string_flags(struct tty_port *port, unsigned char **chars, char **flags, size_t size); extern void tty_flip_buffer_push(struct tty_port *port); -void tty_schedule_flip(struct tty_struct *tty); +void tty_schedule_flip(struct tty_port *port); static inline int tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) -- cgit v1.2.3 From dabe2c1385cd53d91c0a318c0fb7d2c015c61458 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:08 +0100 Subject: cyclades: push down tty_port_tty_get Now, the tty is not needed at all places in the ISR. So we can just request in on demand when really needed. This cleans TX and RX paths a bit as the indentation level can be dropped by two now when we also invert the char_count if condition. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/tty/cyclades.c | 237 ++++++++++++++++++++++++------------------------- 1 file changed, 115 insertions(+), 122 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index 42a329b8af9f..345bd0e0884e 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c @@ -917,7 +917,7 @@ cyz_issue_cmd(struct cyclades_card *cinfo, return 0; } /* cyz_issue_cmd */ -static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) +static void cyz_handle_rx(struct cyclades_port *info) { struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; struct cyclades_card *cinfo = info->card; @@ -940,80 +940,77 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) else char_count = rx_put - rx_get + rx_bufsize; - if (char_count) { + if (!char_count) + return; + #ifdef CY_ENABLE_MONITORING - info->mon.int_count++; - info->mon.char_count += char_count; - if (char_count > info->mon.char_max) - info->mon.char_max = char_count; - info->mon.char_last = char_count; + info->mon.int_count++; + info->mon.char_count += char_count; + if (char_count > info->mon.char_max) + info->mon.char_max = char_count; + info->mon.char_last = char_count; #endif - if (tty == NULL) { - /* flush received characters */ - new_rx_get = (new_rx_get + char_count) & - (rx_bufsize - 1); - info->rflush_count++; - } else { + #ifdef BLOCKMOVE - /* we'd like to use memcpy(t, f, n) and memset(s, c, count) - for performance, but because of buffer boundaries, there - may be several steps to the operation */ - while (1) { - len = tty_prepare_flip_string(port, &buf, - char_count); - if (!len) - break; + /* we'd like to use memcpy(t, f, n) and memset(s, c, count) + for performance, but because of buffer boundaries, there + may be several steps to the operation */ + while (1) { + len = tty_prepare_flip_string(port, &buf, + char_count); + if (!len) + break; - len = min_t(unsigned int, min(len, char_count), - rx_bufsize - new_rx_get); + len = min_t(unsigned int, min(len, char_count), + rx_bufsize - new_rx_get); - memcpy_fromio(buf, cinfo->base_addr + - rx_bufaddr + new_rx_get, len); + memcpy_fromio(buf, cinfo->base_addr + + rx_bufaddr + new_rx_get, len); - new_rx_get = (new_rx_get + len) & - (rx_bufsize - 1); - char_count -= len; - info->icount.rx += len; - info->idle_stats.recv_bytes += len; - } + new_rx_get = (new_rx_get + len) & + (rx_bufsize - 1); + char_count -= len; + info->icount.rx += len; + info->idle_stats.recv_bytes += len; + } #else - len = tty_buffer_request_room(port, char_count); - while (len--) { - data = readb(cinfo->base_addr + rx_bufaddr + - new_rx_get); - new_rx_get = (new_rx_get + 1) & - (rx_bufsize - 1); - tty_insert_flip_char(port, data, TTY_NORMAL); - info->idle_stats.recv_bytes++; - info->icount.rx++; - } + len = tty_buffer_request_room(port, char_count); + while (len--) { + data = readb(cinfo->base_addr + rx_bufaddr + + new_rx_get); + new_rx_get = (new_rx_get + 1) & + (rx_bufsize - 1); + tty_insert_flip_char(port, data, TTY_NORMAL); + info->idle_stats.recv_bytes++; + info->icount.rx++; + } #endif #ifdef CONFIG_CYZ_INTR - /* Recalculate the number of chars in the RX buffer and issue - a cmd in case it's higher than the RX high water mark */ - rx_put = readl(&buf_ctrl->rx_put); - if (rx_put >= rx_get) - char_count = rx_put - rx_get; - else - char_count = rx_put - rx_get + rx_bufsize; - if (char_count >= readl(&buf_ctrl->rx_threshold) && - !timer_pending(&cyz_rx_full_timer[ - info->line])) - mod_timer(&cyz_rx_full_timer[info->line], - jiffies + 1); + /* Recalculate the number of chars in the RX buffer and issue + a cmd in case it's higher than the RX high water mark */ + rx_put = readl(&buf_ctrl->rx_put); + if (rx_put >= rx_get) + char_count = rx_put - rx_get; + else + char_count = rx_put - rx_get + rx_bufsize; + if (char_count >= readl(&buf_ctrl->rx_threshold) && + !timer_pending(&cyz_rx_full_timer[ + info->line])) + mod_timer(&cyz_rx_full_timer[info->line], + jiffies + 1); #endif - info->idle_stats.recv_idle = jiffies; - tty_schedule_flip(&info->port); - } - /* Update rx_get */ - cy_writel(&buf_ctrl->rx_get, new_rx_get); - } + info->idle_stats.recv_idle = jiffies; + tty_schedule_flip(&info->port); + + /* Update rx_get */ + cy_writel(&buf_ctrl->rx_get, new_rx_get); } -static void cyz_handle_tx(struct cyclades_port *info, struct tty_struct *tty) +static void cyz_handle_tx(struct cyclades_port *info) { struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; struct cyclades_card *cinfo = info->card; + struct tty_struct *tty; u8 data; unsigned int char_count; #ifdef BLOCKMOVE @@ -1033,63 +1030,63 @@ static void cyz_handle_tx(struct cyclades_port *info, struct tty_struct *tty) else char_count = tx_get - tx_put - 1; - if (char_count) { - - if (tty == NULL) - goto ztxdone; + if (!char_count) + return; + + tty = tty_port_tty_get(&info->port); + if (tty == NULL) + goto ztxdone; - if (info->x_char) { /* send special char */ - data = info->x_char; + if (info->x_char) { /* send special char */ + data = info->x_char; - cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); - tx_put = (tx_put + 1) & (tx_bufsize - 1); - info->x_char = 0; - char_count--; - info->icount.tx++; - } + cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); + tx_put = (tx_put + 1) & (tx_bufsize - 1); + info->x_char = 0; + char_count--; + info->icount.tx++; + } #ifdef BLOCKMOVE - while (0 < (small_count = min_t(unsigned int, - tx_bufsize - tx_put, min_t(unsigned int, - (SERIAL_XMIT_SIZE - info->xmit_tail), - min_t(unsigned int, info->xmit_cnt, - char_count))))) { - - memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + - tx_put), - &info->port.xmit_buf[info->xmit_tail], - small_count); - - tx_put = (tx_put + small_count) & (tx_bufsize - 1); - char_count -= small_count; - info->icount.tx += small_count; - info->xmit_cnt -= small_count; - info->xmit_tail = (info->xmit_tail + small_count) & - (SERIAL_XMIT_SIZE - 1); - } + while (0 < (small_count = min_t(unsigned int, + tx_bufsize - tx_put, min_t(unsigned int, + (SERIAL_XMIT_SIZE - info->xmit_tail), + min_t(unsigned int, info->xmit_cnt, + char_count))))) { + + memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put), + &info->port.xmit_buf[info->xmit_tail], + small_count); + + tx_put = (tx_put + small_count) & (tx_bufsize - 1); + char_count -= small_count; + info->icount.tx += small_count; + info->xmit_cnt -= small_count; + info->xmit_tail = (info->xmit_tail + small_count) & + (SERIAL_XMIT_SIZE - 1); + } #else - while (info->xmit_cnt && char_count) { - data = info->port.xmit_buf[info->xmit_tail]; - info->xmit_cnt--; - info->xmit_tail = (info->xmit_tail + 1) & - (SERIAL_XMIT_SIZE - 1); - - cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); - tx_put = (tx_put + 1) & (tx_bufsize - 1); - char_count--; - info->icount.tx++; - } + while (info->xmit_cnt && char_count) { + data = info->port.xmit_buf[info->xmit_tail]; + info->xmit_cnt--; + info->xmit_tail = (info->xmit_tail + 1) & + (SERIAL_XMIT_SIZE - 1); + + cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); + tx_put = (tx_put + 1) & (tx_bufsize - 1); + char_count--; + info->icount.tx++; + } #endif - tty_wakeup(tty); + tty_wakeup(tty); + tty_kref_put(tty); ztxdone: - /* Update tx_put */ - cy_writel(&buf_ctrl->tx_put, tx_put); - } + /* Update tx_put */ + cy_writel(&buf_ctrl->tx_put, tx_put); } static void cyz_handle_cmd(struct cyclades_card *cinfo) { struct BOARD_CTRL __iomem *board_ctrl = cinfo->board_ctrl; - struct tty_struct *tty; struct cyclades_port *info; __u32 channel, param, fw_ver; __u8 cmd; @@ -1102,9 +1099,6 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) special_count = 0; delta_count = 0; info = &cinfo->ports[channel]; - tty = tty_port_tty_get(&info->port); - if (tty == NULL) - continue; switch (cmd) { case C_CM_PR_ERROR: @@ -1130,8 +1124,14 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) readl(&info->u.cyz.ch_ctrl->rs_status); if (dcd & C_RS_DCD) wake_up_interruptible(&info->port.open_wait); - else - tty_hangup(tty); + else { + struct tty_struct *tty; + tty = tty_port_tty_get(&info->port); + if (tty) { + tty_hangup(tty); + tty_kref_put(tty); + } + } } break; case C_CM_MCTS: @@ -1160,7 +1160,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) printk(KERN_DEBUG "cyz_interrupt: rcvd intr, card %d, " "port %ld\n", info->card, channel); #endif - cyz_handle_rx(info, tty); + cyz_handle_rx(info); break; case C_CM_TXBEMPTY: case C_CM_TXLOWWM: @@ -1170,7 +1170,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) printk(KERN_DEBUG "cyz_interrupt: xmit intr, card %d, " "port %ld\n", info->card, channel); #endif - cyz_handle_tx(info, tty); + cyz_handle_tx(info); break; #endif /* CONFIG_CYZ_INTR */ case C_CM_FATAL: @@ -1183,7 +1183,6 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) wake_up_interruptible(&info->port.delta_msr_wait); if (special_count) tty_schedule_flip(&info->port); - tty_kref_put(tty); } } @@ -1249,17 +1248,11 @@ static void cyz_poll(unsigned long arg) cyz_handle_cmd(cinfo); for (port = 0; port < cinfo->nports; port++) { - struct tty_struct *tty; - info = &cinfo->ports[port]; - tty = tty_port_tty_get(&info->port); - /* OK to pass NULL to the handle functions below. - They need to drop the data in that case. */ if (!info->throttle) - cyz_handle_rx(info, tty); - cyz_handle_tx(info, tty); - tty_kref_put(tty); + cyz_handle_rx(info); + cyz_handle_tx(info); } /* poll every 'cyz_polling_cycle' period */ expires = jiffies + cyz_polling_cycle; -- cgit v1.2.3 From cc5ab61086334e72afdf970c032fecf5e5fcf7ca Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:09 +0100 Subject: TTY: synclink, remove unneeded tests info in synclink bottom-halves cannot be NULL because it is taken from work_struct using container_of. Remove the tests. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/char/pcmcia/synclink_cs.c | 3 --- drivers/tty/synclink_gt.c | 2 -- drivers/tty/synclinkmp.c | 3 --- 3 files changed, 8 deletions(-) (limited to 'drivers') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index f334aec65fc7..34e52ed0ea8c 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -765,9 +765,6 @@ static void bh_handler(struct work_struct *work) struct tty_struct *tty; int action; - if (!info) - return; - if (debug_level >= DEBUG_LEVEL_BH) printk( "%s(%d):bh_handler(%s) entry\n", __FILE__,__LINE__,info->device_name); diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index fced6acc74ee..ac8599a76820 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -1957,8 +1957,6 @@ static void bh_handler(struct work_struct *work) struct slgt_info *info = container_of(work, struct slgt_info, task); int action; - if (!info) - return; info->bh_running = true; while((action = bh_action(info))) { diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index e4a2904af565..545402509cab 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -2007,9 +2007,6 @@ static void bh_handler(struct work_struct *work) SLMP_INFO *info = container_of(work, SLMP_INFO, task); int action; - if (!info) - return; - if ( debug_level >= DEBUG_LEVEL_BH ) printk( "%s(%d):%s bh_handler() entry\n", __FILE__,__LINE__,info->device_name); -- cgit v1.2.3 From fa47ba75ec2d5818d7aeeb540e738827c4b69194 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:40 +0100 Subject: TTY: nozomi, remove dead code We test for !dc twice, remove the second test. Coverity found this. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/tty/nozomi.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index afdd7732d925..2dff19796157 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -1679,12 +1679,6 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count); - /* notify card */ - if (unlikely(dc == NULL)) { - DBG1("No device context?"); - goto exit; - } - spin_lock_irqsave(&dc->spin_mutex, flags); /* CTS is only valid on the modem channel */ if (port == &(dc->port[PORT_MDM])) { @@ -1700,7 +1694,6 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, } spin_unlock_irqrestore(&dc->spin_mutex, flags); -exit: return rval; } -- cgit v1.2.3 From d73dfc6a4199e0e37b54c647549828eabda67c7c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 15 Jan 2013 22:44:48 -0800 Subject: serial: 8250_pci: remove __devexit usage Some __devexit markings came in from an older patch, this removes them. Reported-by: Wu Fengguang Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 89060ffb6b00..3b0cc3a09deb 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1283,7 +1283,7 @@ static int pci_quatech_setup(struct serial_private *priv, return pci_default_setup(priv, board, port, idx); } -static void __devexit pci_quatech_exit(struct pci_dev *dev) +static void pci_quatech_exit(struct pci_dev *dev) { } @@ -1783,7 +1783,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { .subdevice = PCI_ANY_ID, .init = pci_quatech_init, .setup = pci_quatech_setup, - .exit = __devexit_p(pci_quatech_exit), + .exit = pci_quatech_exit, }, /* * Panacom -- cgit v1.2.3 From 4e18585d51434c28269e625e56a06396d70d0ff2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 15 Jan 2013 22:48:15 -0800 Subject: Revert "n_gsm.c: add tx_lock in gsm_send" This reverts commit f96f7f7f39af53274d98aa9c29d6fa4d122218a4, at the request of Jin. Cc: xiaojin Cc: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index d84dcfeadce3..e0f80ce0cf8f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -573,7 +573,6 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control) int len; u8 cbuf[10]; u8 ibuf[3]; - unsigned long flags; switch (gsm->encoding) { case 0: @@ -603,9 +602,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control) WARN_ON(1); return; } - spin_lock_irqsave(&gsm->tx_lock, flags); gsm->output(gsm, cbuf, len); - spin_unlock_irqrestore(&gsm->tx_lock, flags); gsm_print_packet("-->", addr, cr, control, NULL, 0); } -- cgit v1.2.3 From 82f8c35f86a878a504f92559d631ea03f0f62152 Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Sat, 12 Jan 2013 05:01:21 +0100 Subject: tty: cleanup the panic message the "\n" in panic message is excess, so we remove it in tty/pty.c as what it is used in other places. Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 32d027c303aa..916825f984a9 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -795,7 +795,7 @@ static void __init unix98_pty_init(void) cdev_init(&ptmx_cdev, &ptmx_fops); if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) - panic("Couldn't register /dev/ptmx driver\n"); + panic("Couldn't register /dev/ptmx driver"); device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); } -- cgit v1.2.3 From b9f8033f28448732612e64046b13087b08dd25f7 Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Sat, 12 Jan 2013 05:01:22 +0100 Subject: tty: cleanup checkpatch warning in pty.c spaces are used for indent in 3 places of tty/pty.c, we change it to tab. Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 916825f984a9..4ec11f326d6d 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -55,9 +55,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp) set_bit(TTY_OTHER_CLOSED, &tty->flags); #ifdef CONFIG_UNIX98_PTYS if (tty->driver == ptm_driver) { - mutex_lock(&devpts_mutex); + mutex_lock(&devpts_mutex); devpts_pty_kill(tty->link->driver_data); - mutex_unlock(&devpts_mutex); + mutex_unlock(&devpts_mutex); } #endif tty_unlock(tty); @@ -661,7 +661,7 @@ static const struct tty_operations pty_unix98_ops = { * Allocate a unix98 pty master device from the ptmx driver. * * Locking: tty_mutex protects the init_dev work. tty->count should - * protect the rest. + * protect the rest. * allocated_ptys_lock handles the list of free pty numbers */ -- cgit v1.2.3 From 37c44b52b102eb144fe4487f4a7ac39a70caee19 Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Sat, 12 Jan 2013 05:42:07 +0100 Subject: tty: add parenthesis to macro POLL_PERIOD in rocket.c Macros should be enclosed in parenthesis Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/rocket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 8073cc0dff59..69c16fc06e58 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -55,7 +55,7 @@ #undef REV_PCI_ORDER #undef ROCKET_DEBUG_IO -#define POLL_PERIOD HZ/100 /* Polling period .01 seconds (10ms) */ +#define POLL_PERIOD (HZ/100) /* Polling period .01 seconds (10ms) */ /****** Kernel includes ******/ -- cgit v1.2.3 From b81273a132177edd806476b953f6afeb17b786d5 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Tue, 15 Jan 2013 23:26:22 +0100 Subject: TTY: do not reset master's packet mode Now that login from util-linux is forced to drop all references to a TTY which it wants to hangup (to reach reference count 1) we are seeing issues with telnet. When login closes its last reference to the slave PTY, it also resets packet mode on the *master* side. And we have a race here. What telnet does is fork+exec of `login'. Then there are two scenarios: * `login' closes the slave TTY and resets thus master's packet mode, but even now telnet properly sets the mode, or * `telnetd' sets packet mode on the master, `login' closes the slave TTY and resets master's packet mode. The former case is OK. However the latter happens in much more cases, by the order of magnitude to be precise. So when one tries to login to such a messed telnet setup, they see the following: inux login: ogin incorrect Note the missing first letters -- telnet thinks it is still in the packet mode, so when it receives "linux login" from `login', it considers "l" as the type of the packet and strips it. SuS does not mention how the implementation should behave. Both BSDs I checked (Free and Net) do not reset the flag upon the last close. By this I am resurrecting an old bug, see References. We are hitting it regularly now, i.e. with updated util-linux, ergo login. Here, I am changing a behavior introduced back in 2.1 times. It would better have a long time testing before goes upstream. Signed-off-by: Jiri Slaby Cc: Mauro Carvalho Chehab Cc: Bryan Mason References: https://lkml.org/lkml/2009/11/11/223 References: https://bugzilla.redhat.com/show_bug.cgi?id=504703 References: https://bugzilla.novell.com/show_bug.cgi?id=797042 Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 4ec11f326d6d..40ff2bf68b43 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp) /* Review - krefs on tty_link ?? */ if (!tty->link) return; - tty->link->packet = 0; set_bit(TTY_OTHER_CLOSED, &tty->link->flags); wake_up_interruptible(&tty->link->read_wait); wake_up_interruptible(&tty->link->write_wait); -- cgit v1.2.3 From 496c907740ff083499f5449d2907af442e79ceb0 Mon Sep 17 00:00:00 2001 From: Quoc-Viet Nguyen Date: Tue, 15 Jan 2013 09:32:53 +1000 Subject: serial: mcf: Add support RS485 in ColdFire serial driver Signed-off-by: Quoc-Viet Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/mcf.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index 7ed99274572f..e956377a38fe 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,7 @@ struct mcf_uart { struct uart_port port; unsigned int sigs; /* Local copy of line sigs */ unsigned char imr; /* Local IMR mirror */ + struct serial_rs485 rs485; /* RS485 settings */ }; /****************************************************************************/ @@ -101,6 +103,12 @@ static void mcf_start_tx(struct uart_port *port) { struct mcf_uart *pp = container_of(port, struct mcf_uart, port); + if (pp->rs485.flags & SER_RS485_ENABLED) { + /* Enable Transmitter */ + writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR); + /* Manually assert RTS */ + writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1); + } pp->imr |= MCFUART_UIR_TXREADY; writeb(pp->imr, port->membase + MCFUART_UIMR); } @@ -196,6 +204,7 @@ static void mcf_shutdown(struct uart_port *port) static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { + struct mcf_uart *pp = container_of(port, struct mcf_uart, port); unsigned long flags; unsigned int baud, baudclk; #if defined(CONFIG_M5272) @@ -248,6 +257,11 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, mr2 |= MCFUART_MR2_TXCTS; } + if (pp->rs485.flags & SER_RS485_ENABLED) { + dev_dbg(port->dev, "Setting UART to RS485\n"); + mr2 |= MCFUART_MR2_TXRTS; + } + spin_lock_irqsave(&port->lock, flags); uart_update_timeout(port, termios->c_cflag, baud); writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); @@ -342,6 +356,10 @@ static void mcf_tx_chars(struct mcf_uart *pp) if (xmit->head == xmit->tail) { pp->imr &= ~MCFUART_UIR_TXREADY; writeb(pp->imr, port->membase + MCFUART_UIMR); + /* Disable TX to negate RTS automatically */ + if (pp->rs485.flags & SER_RS485_ENABLED) + writeb(MCFUART_UCR_TXDISABLE, + port->membase + MCFUART_UCR); } } @@ -418,6 +436,58 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser) /****************************************************************************/ +/* Enable or disable the RS485 support */ +static void mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) +{ + struct mcf_uart *pp = container_of(port, struct mcf_uart, port); + unsigned long flags; + unsigned char mr1, mr2; + + spin_lock_irqsave(&port->lock, flags); + /* Get mode registers */ + mr1 = readb(port->membase + MCFUART_UMR); + mr2 = readb(port->membase + MCFUART_UMR); + if (rs485->flags & SER_RS485_ENABLED) { + dev_dbg(port->dev, "Setting UART to RS485\n"); + /* Automatically negate RTS after TX completes */ + mr2 |= MCFUART_MR2_TXRTS; + } else { + dev_dbg(port->dev, "Setting UART to RS232\n"); + mr2 &= ~MCFUART_MR2_TXRTS; + } + writeb(mr1, port->membase + MCFUART_UMR); + writeb(mr2, port->membase + MCFUART_UMR); + pp->rs485 = *rs485; + spin_unlock_irqrestore(&port->lock, flags); +} + +static int mcf_ioctl(struct uart_port *port, unsigned int cmd, + unsigned long arg) +{ + switch (cmd) { + case TIOCSRS485: { + struct serial_rs485 rs485; + if (copy_from_user(&rs485, (struct serial_rs485 *)arg, + sizeof(struct serial_rs485))) + return -EFAULT; + mcf_config_rs485(port, &rs485); + break; + } + case TIOCGRS485: { + struct mcf_uart *pp = container_of(port, struct mcf_uart, port); + if (copy_to_user((struct serial_rs485 *)arg, &pp->rs485, + sizeof(struct serial_rs485))) + return -EFAULT; + break; + } + default: + return -ENOIOCTLCMD; + } + return 0; +} + +/****************************************************************************/ + /* * Define the basic serial functions we support. */ @@ -438,6 +508,7 @@ static const struct uart_ops mcf_uart_ops = { .release_port = mcf_release_port, .config_port = mcf_config_port, .verify_port = mcf_verify_port, + .ioctl = mcf_ioctl, }; static struct mcf_uart mcf_ports[4]; -- cgit v1.2.3 From ec063899b7b308019afa9f5eb32f0a58a6c6ee53 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Mon, 3 Dec 2012 22:23:31 +0400 Subject: serial: sccnxp: Implement polling mode This patch adds support for polling work mode, i.e. system is perform periodical check chip status when IRQ-line is not connected to CPU. Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sccnxp.c | 148 ++++++++++++++++++++++++----------- include/linux/platform_data/sccnxp.h | 2 + 2 files changed, 105 insertions(+), 45 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index 2ced871becff..3a4c57e6ea1e 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,7 @@ enum { struct sccnxp_port { struct uart_driver uart; struct uart_port port[SCCNXP_MAX_UARTS]; + bool opened[SCCNXP_MAX_UARTS]; const char *name; int irq; @@ -122,7 +124,10 @@ struct sccnxp_port { struct console console; #endif - struct mutex sccnxp_mutex; + spinlock_t lock; + + bool poll; + struct timer_list timer; struct sccnxp_pdata pdata; }; @@ -371,31 +376,48 @@ static void sccnxp_handle_tx(struct uart_port *port) uart_write_wakeup(port); } -static irqreturn_t sccnxp_ist(int irq, void *dev_id) +static void sccnxp_handle_events(struct sccnxp_port *s) { int i; u8 isr; - struct sccnxp_port *s = (struct sccnxp_port *)dev_id; - - mutex_lock(&s->sccnxp_mutex); - for (;;) { + do { isr = sccnxp_read(&s->port[0], SCCNXP_ISR_REG); isr &= s->imr; if (!isr) break; - dev_dbg(s->port[0].dev, "IRQ status: 0x%02x\n", isr); - for (i = 0; i < s->uart.nr; i++) { - if (isr & ISR_RXRDY(i)) + if (s->opened[i] && (isr & ISR_RXRDY(i))) sccnxp_handle_rx(&s->port[i]); - if (isr & ISR_TXRDY(i)) + if (s->opened[i] && (isr & ISR_TXRDY(i))) sccnxp_handle_tx(&s->port[i]); } - } + } while (1); +} + +static void sccnxp_timer(unsigned long data) +{ + struct sccnxp_port *s = (struct sccnxp_port *)data; + unsigned long flags; - mutex_unlock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); + sccnxp_handle_events(s); + spin_unlock_irqrestore(&s->lock, flags); + + if (!timer_pending(&s->timer)) + mod_timer(&s->timer, jiffies + + usecs_to_jiffies(s->pdata.poll_time_us)); +} + +static irqreturn_t sccnxp_ist(int irq, void *dev_id) +{ + struct sccnxp_port *s = (struct sccnxp_port *)dev_id; + unsigned long flags; + + spin_lock_irqsave(&s->lock, flags); + sccnxp_handle_events(s); + spin_unlock_irqrestore(&s->lock, flags); return IRQ_HANDLED; } @@ -403,8 +425,9 @@ static irqreturn_t sccnxp_ist(int irq, void *dev_id) static void sccnxp_start_tx(struct uart_port *port) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); /* Set direction to output */ if (s->flags & SCCNXP_HAVE_IO) @@ -412,7 +435,7 @@ static void sccnxp_start_tx(struct uart_port *port) sccnxp_enable_irq(port, IMR_TXRDY); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static void sccnxp_stop_tx(struct uart_port *port) @@ -423,20 +446,22 @@ static void sccnxp_stop_tx(struct uart_port *port) static void sccnxp_stop_rx(struct uart_port *port) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); sccnxp_port_write(port, SCCNXP_CR_REG, CR_RX_DISABLE); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static unsigned int sccnxp_tx_empty(struct uart_port *port) { u8 val; + unsigned long flags; struct sccnxp_port *s = dev_get_drvdata(port->dev); - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); val = sccnxp_port_read(port, SCCNXP_SR_REG); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); return (val & SR_TXEMT) ? TIOCSER_TEMT : 0; } @@ -449,28 +474,30 @@ static void sccnxp_enable_ms(struct uart_port *port) static void sccnxp_set_mctrl(struct uart_port *port, unsigned int mctrl) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; if (!(s->flags & SCCNXP_HAVE_IO)) return; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); sccnxp_set_bit(port, DTR_OP, mctrl & TIOCM_DTR); sccnxp_set_bit(port, RTS_OP, mctrl & TIOCM_RTS); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static unsigned int sccnxp_get_mctrl(struct uart_port *port) { u8 bitmask, ipr; + unsigned long flags; struct sccnxp_port *s = dev_get_drvdata(port->dev); unsigned int mctrl = TIOCM_DSR | TIOCM_CTS | TIOCM_CAR; if (!(s->flags & SCCNXP_HAVE_IO)) return mctrl; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); ipr = ~sccnxp_read(port, SCCNXP_IPCR_REG); @@ -499,7 +526,7 @@ static unsigned int sccnxp_get_mctrl(struct uart_port *port) mctrl |= (ipr & bitmask) ? TIOCM_RNG : 0; } - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); return mctrl; } @@ -507,21 +534,23 @@ static unsigned int sccnxp_get_mctrl(struct uart_port *port) static void sccnxp_break_ctl(struct uart_port *port, int break_state) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); sccnxp_port_write(port, SCCNXP_CR_REG, break_state ? CR_CMD_START_BREAK : CR_CMD_STOP_BREAK); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static void sccnxp_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; u8 mr1, mr2; int baud; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); /* Mask termios capabilities we don't support */ termios->c_cflag &= ~CMSPAR; @@ -588,20 +617,22 @@ static void sccnxp_set_termios(struct uart_port *port, /* Update timeout according to new baud rate */ uart_update_timeout(port, termios->c_cflag, baud); + /* Report actual baudrate back to core */ if (tty_termios_baud_rate(termios)) tty_termios_encode_baud_rate(termios, baud, baud); /* Enable RX & TX */ sccnxp_port_write(port, SCCNXP_CR_REG, CR_RX_ENABLE | CR_TX_ENABLE); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static int sccnxp_startup(struct uart_port *port) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); if (s->flags & SCCNXP_HAVE_IO) { /* Outputs are controlled manually */ @@ -620,7 +651,9 @@ static int sccnxp_startup(struct uart_port *port) /* Enable RX interrupt */ sccnxp_enable_irq(port, IMR_RXRDY); - mutex_unlock(&s->sccnxp_mutex); + s->opened[port->line] = 1; + + spin_unlock_irqrestore(&s->lock, flags); return 0; } @@ -628,8 +661,11 @@ static int sccnxp_startup(struct uart_port *port) static void sccnxp_shutdown(struct uart_port *port) { struct sccnxp_port *s = dev_get_drvdata(port->dev); + unsigned long flags; + + spin_lock_irqsave(&s->lock, flags); - mutex_lock(&s->sccnxp_mutex); + s->opened[port->line] = 0; /* Disable interrupts */ sccnxp_disable_irq(port, IMR_TXRDY | IMR_RXRDY); @@ -641,7 +677,7 @@ static void sccnxp_shutdown(struct uart_port *port) if (s->flags & SCCNXP_HAVE_IO) sccnxp_set_bit(port, DIR_OP, 0); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static const char *sccnxp_type(struct uart_port *port) @@ -715,10 +751,11 @@ static void sccnxp_console_write(struct console *co, const char *c, unsigned n) { struct sccnxp_port *s = (struct sccnxp_port *)co->data; struct uart_port *port = &s->port[co->index]; + unsigned long flags; - mutex_lock(&s->sccnxp_mutex); + spin_lock_irqsave(&s->lock, flags); uart_console_write(port, c, n, sccnxp_console_putchar); - mutex_unlock(&s->sccnxp_mutex); + spin_unlock_irqrestore(&s->lock, flags); } static int sccnxp_console_setup(struct console *co, char *options) @@ -757,7 +794,7 @@ static int sccnxp_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, s); - mutex_init(&s->sccnxp_mutex); + spin_lock_init(&s->lock); /* Individual chip settings */ switch (chiptype) { @@ -854,11 +891,19 @@ static int sccnxp_probe(struct platform_device *pdev) } else memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata)); - s->irq = platform_get_irq(pdev, 0); - if (s->irq <= 0) { - dev_err(&pdev->dev, "Missing irq resource data\n"); - ret = -ENXIO; - goto err_out; + if (pdata->poll_time_us) { + dev_info(&pdev->dev, "Using poll mode, resolution %u usecs\n", + pdata->poll_time_us); + s->poll = 1; + } + + if (!s->poll) { + s->irq = platform_get_irq(pdev, 0); + if (s->irq < 0) { + dev_err(&pdev->dev, "Missing irq resource data\n"); + ret = -ENXIO; + goto err_out; + } } /* Check input frequency */ @@ -923,13 +968,23 @@ static int sccnxp_probe(struct platform_device *pdev) if (s->pdata.init) s->pdata.init(); - ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, sccnxp_ist, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev_name(&pdev->dev), s); - if (!ret) + if (!s->poll) { + ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, + sccnxp_ist, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + dev_name(&pdev->dev), s); + if (!ret) + return 0; + + dev_err(&pdev->dev, "Unable to reguest IRQ %i\n", s->irq); + } else { + init_timer(&s->timer); + setup_timer(&s->timer, sccnxp_timer, (unsigned long)s); + mod_timer(&s->timer, jiffies + + usecs_to_jiffies(s->pdata.poll_time_us)); return 0; - - dev_err(&pdev->dev, "Unable to reguest IRQ %i\n", s->irq); + } err_out: platform_set_drvdata(pdev, NULL); @@ -942,7 +997,10 @@ static int sccnxp_remove(struct platform_device *pdev) int i; struct sccnxp_port *s = platform_get_drvdata(pdev); - devm_free_irq(&pdev->dev, s->irq, s); + if (!s->poll) + devm_free_irq(&pdev->dev, s->irq, s); + else + del_timer_sync(&s->timer); for (i = 0; i < s->uart.nr; i++) uart_remove_one_port(&s->uart, &s->port[i]); diff --git a/include/linux/platform_data/sccnxp.h b/include/linux/platform_data/sccnxp.h index 7311ccd3217f..096de90cf848 100644 --- a/include/linux/platform_data/sccnxp.h +++ b/include/linux/platform_data/sccnxp.h @@ -84,6 +84,8 @@ struct sccnxp_pdata { const u8 reg_shift; /* Modem control lines configuration */ const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; + /* Timer value for polling mode (usecs) */ + const unsigned int poll_time_us; /* Called during startup */ void (*init)(void); /* Called before finish */ -- cgit v1.2.3 From 463dcc42e4832150eb3de804682b924f9b73a91a Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Mon, 3 Dec 2012 22:23:32 +0400 Subject: serial: sccnxp: Rename header file to match functionality Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman --- arch/mips/sni/a20r.c | 2 +- drivers/tty/serial/sccnxp.c | 2 +- include/linux/platform_data/sccnxp.h | 95 ----------------------------- include/linux/platform_data/serial-sccnxp.h | 95 +++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 97 deletions(-) delete mode 100644 include/linux/platform_data/sccnxp.h create mode 100644 include/linux/platform_data/serial-sccnxp.h (limited to 'drivers') diff --git a/arch/mips/sni/a20r.c b/arch/mips/sni/a20r.c index 9cb9d43a3a0e..e05ad4da44d9 100644 --- a/arch/mips/sni/a20r.c +++ b/arch/mips/sni/a20r.c @@ -118,7 +118,7 @@ static struct resource sc26xx_rsrc[] = { } }; -#include +#include static struct sccnxp_pdata sccnxp_data = { .reg_shift = 2, diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index 3a4c57e6ea1e..c864353352c5 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #define SCCNXP_NAME "uart-sccnxp" #define SCCNXP_MAJOR 204 diff --git a/include/linux/platform_data/sccnxp.h b/include/linux/platform_data/sccnxp.h deleted file mode 100644 index 096de90cf848..000000000000 --- a/include/linux/platform_data/sccnxp.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * NXP (Philips) SCC+++(SCN+++) serial driver - * - * Copyright (C) 2012 Alexander Shiyan - * - * Based on sc26xx.c, by Thomas Bogendörfer (tsbogend@alpha.franken.de) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __SCCNXP_H -#define __SCCNXP_H - -#define SCCNXP_MAX_UARTS 2 - -/* Output lines */ -#define LINE_OP0 1 -#define LINE_OP1 2 -#define LINE_OP2 3 -#define LINE_OP3 4 -#define LINE_OP4 5 -#define LINE_OP5 6 -#define LINE_OP6 7 -#define LINE_OP7 8 - -/* Input lines */ -#define LINE_IP0 9 -#define LINE_IP1 10 -#define LINE_IP2 11 -#define LINE_IP3 12 -#define LINE_IP4 13 -#define LINE_IP5 14 -#define LINE_IP6 15 - -/* Signals */ -#define DTR_OP 0 /* DTR */ -#define RTS_OP 4 /* RTS */ -#define DSR_IP 8 /* DSR */ -#define CTS_IP 12 /* CTS */ -#define DCD_IP 16 /* DCD */ -#define RNG_IP 20 /* RNG */ - -#define DIR_OP 24 /* Special signal for control RS-485. - * Goes high when transmit, - * then goes low. - */ - -/* Routing control signal 'sig' to line 'line' */ -#define MCTRL_SIG(sig, line) ((line) << (sig)) - -/* - * Example board initialization data: - * - * static struct resource sc2892_resources[] = { - * DEFINE_RES_MEM(UART_PHYS_START, 0x10), - * DEFINE_RES_IRQ(IRQ_EXT2), - * }; - * - * static struct sccnxp_pdata sc2892_info = { - * .frequency = 3686400, - * .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0), - * .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1), - * }; - * - * static struct platform_device sc2892 = { - * .name = "sc2892", - * .id = -1, - * .resource = sc2892_resources, - * .num_resources = ARRAY_SIZE(sc2892_resources), - * .dev = { - * .platform_data = &sc2892_info, - * }, - * }; - */ - -/* SCCNXP platform data structure */ -struct sccnxp_pdata { - /* Frequency (extrenal clock or crystal) */ - int frequency; - /* Shift for A0 line */ - const u8 reg_shift; - /* Modem control lines configuration */ - const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; - /* Timer value for polling mode (usecs) */ - const unsigned int poll_time_us; - /* Called during startup */ - void (*init)(void); - /* Called before finish */ - void (*exit)(void); -}; - -#endif diff --git a/include/linux/platform_data/serial-sccnxp.h b/include/linux/platform_data/serial-sccnxp.h new file mode 100644 index 000000000000..215574d1e81d --- /dev/null +++ b/include/linux/platform_data/serial-sccnxp.h @@ -0,0 +1,95 @@ +/* + * NXP (Philips) SCC+++(SCN+++) serial driver + * + * Copyright (C) 2012 Alexander Shiyan + * + * Based on sc26xx.c, by Thomas Bogendörfer (tsbogend@alpha.franken.de) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _PLATFORM_DATA_SERIAL_SCCNXP_H_ +#define _PLATFORM_DATA_SERIAL_SCCNXP_H_ + +#define SCCNXP_MAX_UARTS 2 + +/* Output lines */ +#define LINE_OP0 1 +#define LINE_OP1 2 +#define LINE_OP2 3 +#define LINE_OP3 4 +#define LINE_OP4 5 +#define LINE_OP5 6 +#define LINE_OP6 7 +#define LINE_OP7 8 + +/* Input lines */ +#define LINE_IP0 9 +#define LINE_IP1 10 +#define LINE_IP2 11 +#define LINE_IP3 12 +#define LINE_IP4 13 +#define LINE_IP5 14 +#define LINE_IP6 15 + +/* Signals */ +#define DTR_OP 0 /* DTR */ +#define RTS_OP 4 /* RTS */ +#define DSR_IP 8 /* DSR */ +#define CTS_IP 12 /* CTS */ +#define DCD_IP 16 /* DCD */ +#define RNG_IP 20 /* RNG */ + +#define DIR_OP 24 /* Special signal for control RS-485. + * Goes high when transmit, + * then goes low. + */ + +/* Routing control signal 'sig' to line 'line' */ +#define MCTRL_SIG(sig, line) ((line) << (sig)) + +/* + * Example board initialization data: + * + * static struct resource sc2892_resources[] = { + * DEFINE_RES_MEM(UART_PHYS_START, 0x10), + * DEFINE_RES_IRQ(IRQ_EXT2), + * }; + * + * static struct sccnxp_pdata sc2892_info = { + * .frequency = 3686400, + * .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0), + * .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1), + * }; + * + * static struct platform_device sc2892 = { + * .name = "sc2892", + * .id = -1, + * .resource = sc2892_resources, + * .num_resources = ARRAY_SIZE(sc2892_resources), + * .dev = { + * .platform_data = &sc2892_info, + * }, + * }; + */ + +/* SCCNXP platform data structure */ +struct sccnxp_pdata { + /* Frequency (extrenal clock or crystal) */ + int frequency; + /* Shift for A0 line */ + const u8 reg_shift; + /* Modem control lines configuration */ + const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; + /* Timer value for polling mode (usecs) */ + const unsigned int poll_time_us; + /* Called during startup */ + void (*init)(void); + /* Called before finish */ + void (*exit)(void); +}; + +#endif -- cgit v1.2.3 From 074d35cebe96da07ac07f78118bc6a09e60350b5 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 4 Dec 2012 00:16:18 -0500 Subject: TTY: hvsi: use for_each_compatible_node() macro Use for_each_compatible_node() macro instead of open coding it. Signed-off-by: Wei Yongjun Acked-by: Grant Likely Signed-off-by: Greg Kroah-Hartman --- drivers/tty/hvc/hvsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index dc591290120b..ef95a154854a 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -1183,9 +1183,7 @@ static int __init hvsi_console_init(void) hvsi_wait = poll_for_state; /* no irqs yet; must poll */ /* search device tree for vty nodes */ - for (vty = of_find_compatible_node(NULL, "serial", "hvterm-protocol"); - vty != NULL; - vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) { + for_each_compatible_node(vty, "serial", "hvterm-protocol") { struct hvsi_struct *hp; const uint32_t *vtermno, *irq; -- cgit v1.2.3 From b342dd512f7af0e0e14e29c3e1f863150cfc46ff Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Thu, 27 Dec 2012 15:51:31 +0800 Subject: drivers/tty/serial: extern function which for release resource, need check pointer, before free it for extern function uart_remove_one_port: need check pointer whether be NULL, before the main work. just like what the other extern function uart_add_one_port has done. uart_add_one_port and uart_remove_one_port are pair information: for the callers (such as drivers/tty/serial/jsm: jsm_tty.c, jsm_driver.c) they realy assume that: they still can call uart_remove_one_port, after uart_add_one_port failed we (as an extern function), have to understand it (just like kfree). Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial_core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index b5c4e64f2990..ca98a3f65fe1 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2643,6 +2643,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport) { struct uart_state *state = drv->state + uport->line; struct tty_port *port = &state->port; + int ret = 0; BUG_ON(in_interrupt()); @@ -2657,6 +2658,11 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport) * succeeding while we shut down the port. */ mutex_lock(&port->mutex); + if (!state->uart_port) { + mutex_unlock(&port->mutex); + ret = -EINVAL; + goto out; + } uport->flags |= UPF_DEAD; mutex_unlock(&port->mutex); @@ -2680,9 +2686,10 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport) uport->type = PORT_UNKNOWN; state->uart_port = NULL; +out: mutex_unlock(&port_mutex); - return 0; + return ret; } /* -- cgit v1.2.3 From bd5d7ce9afdd0cddc5ab65e20d1134ccad824418 Mon Sep 17 00:00:00 2001 From: Ivo Sieben Date: Tue, 18 Dec 2012 15:48:50 +0100 Subject: tty: Only wakeup the line discipline idle queue when queue is active Before waking up the tty line discipline idle queue first check if the queue is active (non empty). This prevents unnecessary entering the critical section in the wake_up() function and therefore avoid needless scheduling overhead on a PREEMPT_RT system caused by two processes being in the same critical section. Signed-off-by: Ivo Sieben Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_ldisc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index c5782294e532..e96d1876bd62 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -64,7 +64,9 @@ static void put_ldisc(struct tty_ldisc *ld) return; } raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); - wake_up(&ld->wq_idle); + + if (waitqueue_active(&ld->wq_idle)) + wake_up(&ld->wq_idle); } /** -- cgit v1.2.3 From 9660497c98e4b64e8646d7604480b40d8a0d413e Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:05 +0200 Subject: serial: 8250: Allow drivers to deliver capabilities Modern UARTs are able to provide information about their capabilities such as FIFO size. This allows the drivers to deliver this information to 8250.c when they are registering ports. Signed-off-by: Heikki Krogerus Reviewed-by: Jamie Iles Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 0d771ec16750..e2ac25a037ef 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -1911,9 +1911,12 @@ static int serial8250_startup(struct uart_port *port) if (port->type == PORT_8250_CIR) return -ENODEV; - port->fifosize = uart_config[up->port.type].fifo_size; - up->tx_loadsz = uart_config[up->port.type].tx_loadsz; - up->capabilities = uart_config[up->port.type].flags; + if (!port->fifosize) + port->fifosize = uart_config[port->type].fifo_size; + if (!up->tx_loadsz) + up->tx_loadsz = uart_config[port->type].tx_loadsz; + if (!up->capabilities) + up->capabilities = uart_config[port->type].flags; up->mcr = 0; if (port->iotype != up->cur_iotype) @@ -2746,9 +2749,12 @@ static void serial8250_init_fixed_type_port(struct uart_8250_port *up, unsigned int type) { up->port.type = type; - up->port.fifosize = uart_config[type].fifo_size; - up->capabilities = uart_config[type].flags; - up->tx_loadsz = uart_config[type].tx_loadsz; + if (!up->port.fifosize) + up->port.fifosize = uart_config[type].fifo_size; + if (!up->tx_loadsz) + up->tx_loadsz = uart_config[type].tx_loadsz; + if (!up->capabilities) + up->capabilities = uart_config[type].flags; } static void __init @@ -3182,6 +3188,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->bugs = up->bugs; uart->port.mapbase = up->port.mapbase; uart->port.private_data = up->port.private_data; + uart->port.fifosize = up->port.fifosize; + uart->tx_loadsz = up->tx_loadsz; + uart->capabilities = up->capabilities; + if (up->port.dev) uart->port.dev = up->port.dev; -- cgit v1.2.3 From 966c4e39b5f7f249d7bb4c409176c9e6c5d48025 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:06 +0200 Subject: serial: 8250_dw: Don't use UPF_FIXED_TYPE Allow 8250.c to determine the port type for us. This allows the driver take advantage of FIFO on Designware UARTs that have it. Signed-off-by: Heikki Krogerus Reviewed-by: Jamie Iles Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 1d0dba2d562d..ff83ea518760 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -112,7 +112,7 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.handle_irq = dw8250_handle_irq; uart.port.type = PORT_8250; uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP | - UPF_FIXED_PORT | UPF_FIXED_TYPE; + UPF_FIXED_PORT; uart.port.dev = &pdev->dev; uart.port.iotype = UPIO_MEM; -- cgit v1.2.3 From f93366ff9ac282fc01effe70df0dd84418f8344e Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:07 +0200 Subject: serial: 8250_dw: Map IO memory This needs to be done in order to later access the Designware specific registers. Signed-off-by: Heikki Krogerus Reviewed-by: Jamie Iles Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index ff83ea518760..e1749012e8e3 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -111,10 +111,13 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.irq = irq->start; uart.port.handle_irq = dw8250_handle_irq; uart.port.type = PORT_8250; - uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP | - UPF_FIXED_PORT; + uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT; uart.port.dev = &pdev->dev; + uart.port.membase = ioremap(regs->start, resource_size(regs)); + if (!uart.port.membase) + return -ENOMEM; + uart.port.iotype = UPIO_MEM; uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; -- cgit v1.2.3 From a7260c8ce07d06da4cbb09120b4e9e8074d122cc Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:08 +0200 Subject: serial: 8250_dw: Move device tree code to separate function Trivial cleanup. This makes it easier to add different methods to enumerate the device, for example ACPI 5.0 enumeration. Signed-off-by: Heikki Krogerus Reviewed-by: Jamie Iles Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 78 +++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index e1749012e8e3..d96e02e25be4 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -87,25 +87,51 @@ static int dw8250_handle_irq(struct uart_port *p) return 0; } +static int dw8250_probe_of(struct uart_port *p) +{ + struct device_node *np = p->dev->of_node; + u32 val; + + if (!of_property_read_u32(np, "reg-io-width", &val)) { + switch (val) { + case 1: + break; + case 4: + p->iotype = UPIO_MEM32; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; + break; + default: + dev_err(p->dev, "unsupported reg-io-width (%u)\n", val); + return -EINVAL; + } + } + + if (!of_property_read_u32(np, "reg-shift", &val)) + p->regshift = val; + + if (of_property_read_u32(np, "clock-frequency", &val)) { + dev_err(p->dev, "no clock-frequency property set\n"); + return -EINVAL; + } + p->uartclk = val; + + return 0; +} + static int dw8250_probe(struct platform_device *pdev) { struct uart_8250_port uart = {}; struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - struct device_node *np = pdev->dev.of_node; - u32 val; struct dw8250_data *data; + int err; if (!regs || !irq) { dev_err(&pdev->dev, "no registers/irq defined\n"); return -EINVAL; } - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - uart.port.private_data = data; - spin_lock_init(&uart.port.lock); uart.port.mapbase = regs->start; uart.port.irq = irq->start; @@ -121,30 +147,20 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.iotype = UPIO_MEM; uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; - if (!of_property_read_u32(np, "reg-io-width", &val)) { - switch (val) { - case 1: - break; - case 4: - uart.port.iotype = UPIO_MEM32; - uart.port.serial_in = dw8250_serial_in32; - uart.port.serial_out = dw8250_serial_out32; - break; - default: - dev_err(&pdev->dev, "unsupported reg-io-width (%u)\n", - val); - return -EINVAL; - } + + if (pdev->dev.of_node) { + err = dw8250_probe_of(&uart.port); + if (err) + return err; + } else { + return -ENODEV; } - if (!of_property_read_u32(np, "reg-shift", &val)) - uart.port.regshift = val; + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; - if (of_property_read_u32(np, "clock-frequency", &val)) { - dev_err(&pdev->dev, "no clock-frequency property set\n"); - return -EINVAL; - } - uart.port.uartclk = val; + uart.port.private_data = data; data->line = serial8250_register_8250_port(&uart); if (data->line < 0) @@ -187,17 +203,17 @@ static int dw8250_resume(struct platform_device *pdev) #define dw8250_resume NULL #endif /* CONFIG_PM */ -static const struct of_device_id dw8250_match[] = { +static const struct of_device_id dw8250_of_match[] = { { .compatible = "snps,dw-apb-uart" }, { /* Sentinel */ } }; -MODULE_DEVICE_TABLE(of, dw8250_match); +MODULE_DEVICE_TABLE(of, dw8250_of_match); static struct platform_driver dw8250_platform_driver = { .driver = { .name = "dw-apb-uart", .owner = THIS_MODULE, - .of_match_table = dw8250_match, + .of_match_table = dw8250_of_match, }, .probe = dw8250_probe, .remove = dw8250_remove, -- cgit v1.2.3 From 30046df261875dfeaf92b44fe5cd6cde9716a561 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:09 +0200 Subject: serial: 8250_dw: Set FIFO size dynamically Designware UART provides optional Component Parameter Register that lists most of the capabilities of the UART, including FIFO size. This uses that register to set FIFO size for the port before registering it. Signed-off-by: Heikki Krogerus Reviewed-by: Jamie Iles Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 57 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index d96e02e25be4..e104092f7d51 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -25,6 +25,28 @@ #include #include +/* Offsets for the DesignWare specific registers */ +#define DW_UART_USR 0x1f /* UART Status Register */ +#define DW_UART_CPR 0xf4 /* Component Parameter Register */ +#define DW_UART_UCV 0xf8 /* UART Component Version */ + +/* Component Parameter Register bits */ +#define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) +#define DW_UART_CPR_AFCE_MODE (1 << 4) +#define DW_UART_CPR_THRE_MODE (1 << 5) +#define DW_UART_CPR_SIR_MODE (1 << 6) +#define DW_UART_CPR_SIR_LP_MODE (1 << 7) +#define DW_UART_CPR_ADDITIONAL_FEATURES (1 << 8) +#define DW_UART_CPR_FIFO_ACCESS (1 << 9) +#define DW_UART_CPR_FIFO_STAT (1 << 10) +#define DW_UART_CPR_SHADOW (1 << 11) +#define DW_UART_CPR_ENCODED_PARMS (1 << 12) +#define DW_UART_CPR_DMA_EXTRA (1 << 13) +#define DW_UART_CPR_FIFO_MODE (0xff << 16) +/* Helper for fifo size calculation */ +#define DW_UART_CPR_FIFO_SIZE(a) (((a >> 16) & 0xff) * 16) + + struct dw8250_data { int last_lcr; int line; @@ -66,9 +88,6 @@ static unsigned int dw8250_serial_in32(struct uart_port *p, int offset) return readl(p->membase + offset); } -/* Offset for the DesignWare's UART Status Register. */ -#define UART_USR 0x1f - static int dw8250_handle_irq(struct uart_port *p) { struct dw8250_data *d = p->private_data; @@ -78,7 +97,7 @@ static int dw8250_handle_irq(struct uart_port *p) return 1; } else if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { /* Clear the USR and write the LCR again. */ - (void)p->serial_in(p, UART_USR); + (void)p->serial_in(p, DW_UART_USR); p->serial_out(p, d->last_lcr, UART_LCR); return 1; @@ -119,6 +138,34 @@ static int dw8250_probe_of(struct uart_port *p) return 0; } +static void dw8250_setup_port(struct uart_8250_port *up) +{ + struct uart_port *p = &up->port; + u32 reg = readl(p->membase + DW_UART_UCV); + + /* + * If the Component Version Register returns zero, we know that + * ADDITIONAL_FEATURES are not enabled. No need to go any further. + */ + if (!reg) + return; + + dev_dbg_ratelimited(p->dev, "Designware UART version %c.%c%c\n", + (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); + + reg = readl(p->membase + DW_UART_CPR); + if (!reg) + return; + + /* Select the type based on fifo */ + if (reg & DW_UART_CPR_FIFO_MODE) { + p->type = PORT_16550A; + p->flags |= UPF_FIXED_TYPE; + p->fifosize = DW_UART_CPR_FIFO_SIZE(reg); + up->tx_loadsz = p->fifosize; + } +} + static int dw8250_probe(struct platform_device *pdev) { struct uart_8250_port uart = {}; @@ -156,6 +203,8 @@ static int dw8250_probe(struct platform_device *pdev) return -ENODEV; } + dw8250_setup_port(&uart); + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; -- cgit v1.2.3 From 6a7320c4669fbf26a8e71a4c8af4101923152375 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:10 +0200 Subject: serial: 8250_dw: Add ACPI 5.0 support This adds support for ACPI 5.0 enumerated Designware UARTs. ACPI does not deliver information about uart clk, so delivering it with the driver_data. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 41 +++++++++++++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index e104092f7d51..f6eeff02dced 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -2,6 +2,7 @@ * Synopsys DesignWare 8250 driver. * * Copyright 2011 Picochip, Jamie Iles. + * Copyright 2013 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,12 +25,16 @@ #include #include #include +#include /* Offsets for the DesignWare specific registers */ #define DW_UART_USR 0x1f /* UART Status Register */ #define DW_UART_CPR 0xf4 /* Component Parameter Register */ #define DW_UART_UCV 0xf8 /* UART Component Version */ +/* Intel Low Power Subsystem specific */ +#define LPSS_PRV_CLOCK_PARAMS 0x800 + /* Component Parameter Register bits */ #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) #define DW_UART_CPR_AFCE_MODE (1 << 4) @@ -138,6 +143,30 @@ static int dw8250_probe_of(struct uart_port *p) return 0; } +static int dw8250_probe_acpi(struct uart_port *p) +{ + const struct acpi_device_id *id; + u32 reg; + + id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); + if (!id) + return -ENODEV; + + p->iotype = UPIO_MEM32; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; + p->regshift = 2; + p->uartclk = (unsigned int)id->driver_data; + + /* Fix Haswell issue where the clocks do not get enabled */ + if (!strcmp(id->id, "INT33C4") || !strcmp(id->id, "INT33C5")) { + reg = readl(p->membase + LPSS_PRV_CLOCK_PARAMS); + writel(reg | 1, p->membase + LPSS_PRV_CLOCK_PARAMS); + } + + return 0; +} + static void dw8250_setup_port(struct uart_8250_port *up) { struct uart_port *p = &up->port; @@ -199,6 +228,10 @@ static int dw8250_probe(struct platform_device *pdev) err = dw8250_probe_of(&uart.port); if (err) return err; + } else if (ACPI_HANDLE(&pdev->dev)) { + err = dw8250_probe_acpi(&uart.port); + if (err) + return err; } else { return -ENODEV; } @@ -258,11 +291,19 @@ static const struct of_device_id dw8250_of_match[] = { }; MODULE_DEVICE_TABLE(of, dw8250_of_match); +static const struct acpi_device_id dw8250_acpi_match[] = { + { "INT33C4", 100000000 }, + { "INT33C5", 100000000 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); + static struct platform_driver dw8250_platform_driver = { .driver = { .name = "dw-apb-uart", .owner = THIS_MODULE, .of_match_table = dw8250_of_match, + .acpi_match_table = ACPI_PTR(dw8250_acpi_match), }, .probe = dw8250_probe, .remove = dw8250_remove, diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index d79208f47237..3ce3e7533e4c 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -256,7 +256,7 @@ config SERIAL_8250_FSL config SERIAL_8250_DW tristate "Support for Synopsys DesignWare 8250 quirks" - depends on SERIAL_8250 && OF + depends on SERIAL_8250 help Selecting this option will enable handling of the extra features present in the Synopsys DesignWare APB UART. -- cgit v1.2.3 From 9ee4b83e51f741a645c43e61b9f3f8075ca0fdf4 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:11 +0200 Subject: serial: 8250: Add support for dmaengine Add support for dmaengine API. The drivers can implement the struct uart_8250_dma member in struct uart_8250_port and 8250.c can take care of the rest. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250.c | 31 +++++- drivers/tty/serial/8250/8250.h | 50 +++++++++ drivers/tty/serial/8250/8250_dma.c | 213 +++++++++++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 8 ++ drivers/tty/serial/8250/Makefile | 1 + include/linux/serial_8250.h | 4 + 6 files changed, 304 insertions(+), 3 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_dma.c (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index e2ac25a037ef..cb7db5a8ae92 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -1269,7 +1269,9 @@ static void serial8250_start_tx(struct uart_port *port) struct uart_8250_port *up = container_of(port, struct uart_8250_port, port); - if (!(up->ier & UART_IER_THRI)) { + if (up->dma && !serial8250_tx_dma(up)) { + return; + } else if (!(up->ier & UART_IER_THRI)) { up->ier |= UART_IER_THRI; serial_port_out(port, UART_IER, up->ier); @@ -1467,6 +1469,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) unsigned long flags; struct uart_8250_port *up = container_of(port, struct uart_8250_port, port); + int dma_err = 0; if (iir & UART_IIR_NO_INT) return 0; @@ -1477,8 +1480,13 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) DEBUG_INTR("status = %x...", status); - if (status & (UART_LSR_DR | UART_LSR_BI)) - status = serial8250_rx_chars(up, status); + if (status & (UART_LSR_DR | UART_LSR_BI)) { + if (up->dma) + dma_err = serial8250_rx_dma(up, iir); + + if (!up->dma || dma_err) + status = serial8250_rx_chars(up, status); + } serial8250_modem_status(up); if (status & UART_LSR_THRE) serial8250_tx_chars(up); @@ -2120,6 +2128,18 @@ dont_test_tx_en: up->lsr_saved_flags = 0; up->msr_saved_flags = 0; + /* + * Request DMA channels for both RX and TX. + */ + if (up->dma) { + retval = serial8250_request_dma(up); + if (retval) { + pr_warn_ratelimited("ttyS%d - failed to request DMA\n", + serial_index(port)); + up->dma = NULL; + } + } + /* * Finally, enable interrupts. Note: Modem status interrupts * are set via set_termios(), which will be occurring imminently @@ -2153,6 +2173,9 @@ static void serial8250_shutdown(struct uart_port *port) up->ier = 0; serial_port_out(port, UART_IER, 0); + if (up->dma) + serial8250_release_dma(up); + spin_lock_irqsave(&port->lock, flags); if (port->flags & UPF_FOURPORT) { /* reset interrupts on the AST Fourport board */ @@ -3217,6 +3240,8 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->dl_read = up->dl_read; if (up->dl_write) uart->dl_write = up->dl_write; + if (up->dma) + uart->dma = up->dma; if (serial8250_isa_config != NULL) serial8250_isa_config(0, &uart->port, diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 3b4ea84898c2..363d549d2e0d 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -12,6 +12,35 @@ */ #include +#include + +struct uart_8250_dma { + dma_filter_fn fn; + void *rx_param; + void *tx_param; + + int rx_chan_id; + int tx_chan_id; + + struct dma_slave_config rxconf; + struct dma_slave_config txconf; + + struct dma_chan *rxchan; + struct dma_chan *txchan; + + dma_addr_t rx_addr; + dma_addr_t tx_addr; + + dma_cookie_t rx_cookie; + dma_cookie_t tx_cookie; + + void *rx_buf; + + size_t rx_size; + size_t tx_size; + + unsigned char tx_running:1; +}; struct old_serial_port { unsigned int uart; @@ -142,3 +171,24 @@ static inline int is_omap1510_8250(struct uart_8250_port *pt) return 0; } #endif + +#ifdef CONFIG_SERIAL_8250_DMA +extern int serial8250_tx_dma(struct uart_8250_port *); +extern int serial8250_rx_dma(struct uart_8250_port *, unsigned int iir); +extern int serial8250_request_dma(struct uart_8250_port *); +extern void serial8250_release_dma(struct uart_8250_port *); +#else +static inline int serial8250_tx_dma(struct uart_8250_port *p) +{ + return -1; +} +static inline int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir) +{ + return -1; +} +static inline int serial8250_request_dma(struct uart_8250_port *p) +{ + return -1; +} +static inline void serial8250_release_dma(struct uart_8250_port *p) { } +#endif diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c new file mode 100644 index 000000000000..95516a15a441 --- /dev/null +++ b/drivers/tty/serial/8250/8250_dma.c @@ -0,0 +1,213 @@ +/* + * 8250_dma.c - DMA Engine API support for 8250.c + * + * Copyright (C) 2013 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include + +#include "8250.h" + +static void __dma_tx_complete(void *param) +{ + struct uart_8250_port *p = param; + struct uart_8250_dma *dma = p->dma; + struct circ_buf *xmit = &p->port.state->xmit; + + dma->tx_running = 0; + + dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr, + UART_XMIT_SIZE, DMA_TO_DEVICE); + + xmit->tail += dma->tx_size; + xmit->tail &= UART_XMIT_SIZE - 1; + p->port.icount.tx += dma->tx_size; + + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&p->port); + + if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) { + serial8250_tx_dma(p); + uart_write_wakeup(&p->port); + } +} + +static void __dma_rx_complete(void *param) +{ + struct uart_8250_port *p = param; + struct uart_8250_dma *dma = p->dma; + struct tty_struct *tty = p->port.state->port.tty; + struct dma_tx_state state; + + dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr, + dma->rx_size, DMA_FROM_DEVICE); + + dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); + dmaengine_terminate_all(dma->rxchan); + + tty_insert_flip_string(tty, dma->rx_buf, dma->rx_size - state.residue); + p->port.icount.rx += dma->rx_size - state.residue; + + tty_flip_buffer_push(tty); +} + +int serial8250_tx_dma(struct uart_8250_port *p) +{ + struct uart_8250_dma *dma = p->dma; + struct circ_buf *xmit = &p->port.state->xmit; + struct dma_async_tx_descriptor *desc; + + if (dma->tx_running) { + uart_write_wakeup(&p->port); + return -EBUSY; + } + + dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); + + desc = dmaengine_prep_slave_single(dma->txchan, + dma->tx_addr + xmit->tail, + dma->tx_size, DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + if (!desc) + return -EBUSY; + + dma->tx_running = 1; + + desc->callback = __dma_tx_complete; + desc->callback_param = p; + + dma->tx_cookie = dmaengine_submit(desc); + + dma_sync_single_for_device(dma->txchan->device->dev, dma->tx_addr, + UART_XMIT_SIZE, DMA_TO_DEVICE); + + dma_async_issue_pending(dma->txchan); + + return 0; +} +EXPORT_SYMBOL_GPL(serial8250_tx_dma); + +int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir) +{ + struct uart_8250_dma *dma = p->dma; + struct dma_async_tx_descriptor *desc; + struct dma_tx_state state; + int dma_status; + + /* + * If RCVR FIFO trigger level was not reached, complete the transfer and + * let 8250.c copy the remaining data. + */ + if ((iir & 0x3f) == UART_IIR_RX_TIMEOUT) { + dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, + &state); + if (dma_status == DMA_IN_PROGRESS) { + dmaengine_pause(dma->rxchan); + __dma_rx_complete(p); + } + return -ETIMEDOUT; + } + + desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, + dma->rx_size, DMA_DEV_TO_MEM, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + if (!desc) + return -EBUSY; + + desc->callback = __dma_rx_complete; + desc->callback_param = p; + + dma->rx_cookie = dmaengine_submit(desc); + + dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr, + dma->rx_size, DMA_FROM_DEVICE); + + dma_async_issue_pending(dma->rxchan); + + return 0; +} +EXPORT_SYMBOL_GPL(serial8250_rx_dma); + +int serial8250_request_dma(struct uart_8250_port *p) +{ + struct uart_8250_dma *dma = p->dma; + dma_cap_mask_t mask; + + dma->rxconf.src_addr = p->port.mapbase + UART_RX; + dma->txconf.dst_addr = p->port.mapbase + UART_TX; + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + + /* Get a channel for RX */ + dma->rxchan = dma_request_channel(mask, dma->fn, dma->rx_param); + if (!dma->rxchan) + return -ENODEV; + + dmaengine_slave_config(dma->rxchan, &dma->rxconf); + + /* Get a channel for TX */ + dma->txchan = dma_request_channel(mask, dma->fn, dma->tx_param); + if (!dma->txchan) { + dma_release_channel(dma->rxchan); + return -ENODEV; + } + + dmaengine_slave_config(dma->txchan, &dma->txconf); + + /* RX buffer */ + if (!dma->rx_size) + dma->rx_size = PAGE_SIZE; + + dma->rx_buf = dma_alloc_coherent(dma->rxchan->device->dev, dma->rx_size, + &dma->rx_addr, GFP_KERNEL); + if (!dma->rx_buf) { + dma_release_channel(dma->rxchan); + dma_release_channel(dma->txchan); + return -ENOMEM; + } + + /* TX buffer */ + dma->tx_addr = dma_map_single(dma->txchan->device->dev, + p->port.state->xmit.buf, + UART_XMIT_SIZE, + DMA_TO_DEVICE); + + dev_dbg_ratelimited(p->port.dev, "got both dma channels\n"); + + return 0; +} +EXPORT_SYMBOL_GPL(serial8250_request_dma); + +void serial8250_release_dma(struct uart_8250_port *p) +{ + struct uart_8250_dma *dma = p->dma; + + if (!dma) + return; + + /* Release RX resources */ + dmaengine_terminate_all(dma->rxchan); + dma_free_coherent(dma->rxchan->device->dev, dma->rx_size, dma->rx_buf, + dma->rx_addr); + dma_release_channel(dma->rxchan); + dma->rxchan = NULL; + + /* Release TX resources */ + dmaengine_terminate_all(dma->txchan); + dma_unmap_single(dma->txchan->device->dev, dma->tx_addr, + UART_XMIT_SIZE, DMA_TO_DEVICE); + dma_release_channel(dma->txchan); + dma->txchan = NULL; + dma->tx_running = 0; + + dev_dbg_ratelimited(p->port.dev, "dma channels released\n"); +} +EXPORT_SYMBOL_GPL(serial8250_release_dma); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 3ce3e7533e4c..d31f4c63d4ba 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -84,6 +84,14 @@ config SERIAL_8250_GSC depends on SERIAL_8250 && GSC default SERIAL_8250 +config SERIAL_8250_DMA + bool "DMA support for 16550 compatible UART controllers" if EXPERT + depends on SERIAL_8250 && DMADEVICES=y + default SERIAL_8250 + help + This builds DMA support that can be used with 8250/16650 + compatible UART controllers that support DMA signaling. + config SERIAL_8250_PCI tristate "8250/16550 PCI device support" if EXPERT depends on SERIAL_8250 && PCI diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index 108fe7fe13e2..a23838a4d535 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250_core.o 8250_core-y := 8250.o 8250_core-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o +8250_core-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index c490d20b3fb8..af47a8af6024 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -59,6 +59,8 @@ enum { PLAT8250_DEV_SM501, }; +struct uart_8250_dma; + /* * This should be used by drivers which want to register * their own 8250 ports without registering their own @@ -91,6 +93,8 @@ struct uart_8250_port { #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA unsigned char msr_saved_flags; + struct uart_8250_dma *dma; + /* 8250 specific callbacks */ int (*dl_read)(struct uart_8250_port *); void (*dl_write)(struct uart_8250_port *, int); -- cgit v1.2.3 From 7277b2a1c687b728a4ec0511d2ae076aed6ed5b4 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 10 Jan 2013 11:25:12 +0200 Subject: serial: 8250_dw: Enable DMA support with ACPI With ACPI 5.0 we can use the FixedDMA Resource Descriptor to extract the needed information for DMA support. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index f6eeff02dced..ceacf5e36f2e 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -27,6 +27,8 @@ #include #include +#include "8250.h" + /* Offsets for the DesignWare specific registers */ #define DW_UART_USR 0x1f /* UART Status Register */ #define DW_UART_CPR 0xf4 /* Component Parameter Register */ @@ -143,9 +145,64 @@ static int dw8250_probe_of(struct uart_port *p) return 0; } +static bool dw8250_acpi_dma_filter(struct dma_chan *chan, void *parm) +{ + return chan->chan_id == *(int *)parm; +} + +static acpi_status +dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) +{ + struct uart_port *p = data; + struct uart_8250_port *port; + struct uart_8250_dma *dma; + struct acpi_resource_fixed_dma *fixed_dma; + struct dma_slave_config *slave; + + port = container_of(p, struct uart_8250_port, port); + + switch (res->type) { + case ACPI_RESOURCE_TYPE_FIXED_DMA: + fixed_dma = &res->data.fixed_dma; + + /* TX comes first */ + if (!port->dma) { + dma = devm_kzalloc(p->dev, sizeof(*dma), GFP_KERNEL); + if (!dma) + return AE_NO_MEMORY; + + port->dma = dma; + slave = &dma->txconf; + + slave->direction = DMA_MEM_TO_DEV; + slave->dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave->slave_id = fixed_dma->request_lines; + + dma->tx_chan_id = fixed_dma->channels; + dma->tx_param = &dma->tx_chan_id; + dma->fn = dw8250_acpi_dma_filter; + } else { + dma = port->dma; + slave = &dma->rxconf; + + slave->direction = DMA_DEV_TO_MEM; + slave->src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave->slave_id = fixed_dma->request_lines; + + dma->rx_chan_id = fixed_dma->channels; + dma->rx_param = &dma->rx_chan_id; + } + + break; + } + + return AE_OK; +} + static int dw8250_probe_acpi(struct uart_port *p) { const struct acpi_device_id *id; + acpi_status status; u32 reg; id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); @@ -158,6 +215,14 @@ static int dw8250_probe_acpi(struct uart_port *p) p->regshift = 2; p->uartclk = (unsigned int)id->driver_data; + status = acpi_walk_resources(ACPI_HANDLE(p->dev), METHOD_NAME__CRS, + dw8250_acpi_walk_resource, p); + if (ACPI_FAILURE(status)) { + dev_err_ratelimited(p->dev, "%s failed \"%s\"\n", __func__, + acpi_format_exception(status)); + return -ENODEV; + } + /* Fix Haswell issue where the clocks do not get enabled */ if (!strcmp(id->id, "INT33C4") || !strcmp(id->id, "INT33C5")) { reg = readl(p->membase + LPSS_PRV_CLOCK_PARAMS); -- cgit v1.2.3 From 852e4a8152b427c3f318bb0e1b5e938d64dcdc32 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 25 Dec 2012 23:02:48 +0100 Subject: tty: don't deadlock while flushing workqueue Since commit 89c8d91e31f2 ("tty: localise the lock") I see a dead lock in one of my dummy_hcd + g_nokia test cases. The first run was usually okay, the second often resulted in a splat by lockdep and the third was usually a dead lock. Lockdep complained about tty->hangup_work and tty->legacy_mutex taken both ways: | ====================================================== | [ INFO: possible circular locking dependency detected ] | 3.7.0-rc6+ #204 Not tainted | ------------------------------------------------------- | kworker/2:1/35 is trying to acquire lock: | (&tty->legacy_mutex){+.+.+.}, at: [] tty_lock_nested+0x36/0x80 | | but task is already holding lock: | ((&tty->hangup_work)){+.+...}, at: [] process_one_work+0x124/0x5e0 | | which lock already depends on the new lock. | | the existing dependency chain (in reverse order) is: | | -> #2 ((&tty->hangup_work)){+.+...}: | [] lock_acquire+0x84/0x190 | [] flush_work+0x3d/0x240 | [] tty_ldisc_flush_works+0x16/0x30 | [] tty_ldisc_release+0x21/0x70 | [] tty_release+0x35c/0x470 | [] __fput+0xd8/0x270 | [] ____fput+0xd/0x10 | [] task_work_run+0xb9/0xf0 | [] do_notify_resume+0x51/0x80 | [] work_notifysig+0x35/0x3b | | -> #1 (&tty->legacy_mutex/1){+.+...}: | [] lock_acquire+0x84/0x190 | [] mutex_lock_nested+0x6c/0x2f0 | [] tty_lock_nested+0x36/0x80 | [] tty_lock_pair+0x29/0x70 | [] tty_release+0x118/0x470 | [] __fput+0xd8/0x270 | [] ____fput+0xd/0x10 | [] task_work_run+0xb9/0xf0 | [] do_notify_resume+0x51/0x80 | [] work_notifysig+0x35/0x3b | | -> #0 (&tty->legacy_mutex){+.+.+.}: | [] __lock_acquire+0x1189/0x16a0 | [] lock_acquire+0x84/0x190 | [] mutex_lock_nested+0x6c/0x2f0 | [] tty_lock_nested+0x36/0x80 | [] tty_lock+0xf/0x20 | [] __tty_hangup+0x54/0x410 | [] do_tty_hangup+0x12/0x20 | [] process_one_work+0x1a3/0x5e0 | [] worker_thread+0x119/0x3a0 | [] kthread+0x94/0xa0 | [] ret_from_kernel_thread+0x1b/0x28 | |other info that might help us debug this: | |Chain exists of: | &tty->legacy_mutex --> &tty->legacy_mutex/1 --> (&tty->hangup_work) | | Possible unsafe locking scenario: | | CPU0 CPU1 | ---- ---- | lock((&tty->hangup_work)); | lock(&tty->legacy_mutex/1); | lock((&tty->hangup_work)); | lock(&tty->legacy_mutex); | | *** DEADLOCK *** Before the path mentioned tty_ldisc_release() look like this: | tty_ldisc_halt(tty); | tty_ldisc_flush_works(tty); | tty_lock(); As it can be seen, it first flushes the workqueue and then grabs the tty_lock. Now we grab the lock first: | tty_lock_pair(tty, o_tty); | tty_ldisc_halt(tty); | tty_ldisc_flush_works(tty); so lockdep's complaint seems valid. The earlier version of this patch took the ldisc_mutex since the other user of tty_ldisc_flush_works() (tty_set_ldisc()) did this. Peter Hurley then said that it is should not be requried. Since it wasn't done earlier, I dropped this part. The code under tty_ldisc_kill() was executed earlier with the tty lock taken so it is taken again. I was able to reproduce the deadlock on v3.8-rc1, this patch fixes the problem in my testcase. I didn't notice any problems so far. Cc: Alan Cox Cc: Peter Hurley Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_ldisc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index e96d1876bd62..d794087c327e 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -936,17 +936,17 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty) * race with the set_ldisc code path. */ - tty_lock_pair(tty, o_tty); tty_ldisc_halt(tty); - tty_ldisc_flush_works(tty); - if (o_tty) { + if (o_tty) tty_ldisc_halt(o_tty); + + tty_ldisc_flush_works(tty); + if (o_tty) tty_ldisc_flush_works(o_tty); - } + tty_lock_pair(tty, o_tty); /* This will need doing differently if we need to lock */ tty_ldisc_kill(tty); - if (o_tty) tty_ldisc_kill(o_tty); -- cgit v1.2.3 From 6f3fe3b1027bf50c0a0859e5c9ee93b174b95543 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 16 Jan 2013 14:08:13 +0200 Subject: serial: 8250_dma: Switch to using tty_port The tty buffer functions are converted to using tty_port structure instead of struct tty, so we must do the same. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index 95516a15a441..02333fc17f41 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -43,8 +43,9 @@ static void __dma_rx_complete(void *param) { struct uart_8250_port *p = param; struct uart_8250_dma *dma = p->dma; - struct tty_struct *tty = p->port.state->port.tty; + struct tty_port *tty_port = &p->port.state->port; struct dma_tx_state state; + int count; dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr, dma->rx_size, DMA_FROM_DEVICE); @@ -52,10 +53,12 @@ static void __dma_rx_complete(void *param) dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); dmaengine_terminate_all(dma->rxchan); - tty_insert_flip_string(tty, dma->rx_buf, dma->rx_size - state.residue); - p->port.icount.rx += dma->rx_size - state.residue; + count = dma->rx_size - state.residue; - tty_flip_buffer_push(tty); + tty_insert_flip_string(tty_port, dma->rx_buf, count); + p->port.icount.rx += count; + + tty_flip_buffer_push(tty_port); } int serial8250_tx_dma(struct uart_8250_port *p) -- cgit v1.2.3 From a3b0397fdf19b3c23f37012532482c787e01d4a0 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 16 Jan 2013 14:08:14 +0200 Subject: serial: 8250_dma: TX optimisation Remove one useless wakeup, and do not use DMA with zero byte transfers. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index 02333fc17f41..b9f7fd28112e 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -67,12 +67,12 @@ int serial8250_tx_dma(struct uart_8250_port *p) struct circ_buf *xmit = &p->port.state->xmit; struct dma_async_tx_descriptor *desc; - if (dma->tx_running) { - uart_write_wakeup(&p->port); + if (dma->tx_running) return -EBUSY; - } dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); + if (!dma->tx_size) + return -EINVAL; desc = dmaengine_prep_slave_single(dma->txchan, dma->tx_addr + xmit->tail, -- cgit v1.2.3 From 053fac36b1d9f76adde96a2f731965aaab3c632b Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 16 Jan 2013 14:08:15 +0200 Subject: serial: 8250_dw: Use ifdef with ACPI There are no stubs for ACPI functions so the driver needs to have this ifdef or it will not compile without ACPI. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index ceacf5e36f2e..bfdaf8b2680b 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -145,6 +145,7 @@ static int dw8250_probe_of(struct uart_port *p) return 0; } +#ifdef CONFIG_ACPI static bool dw8250_acpi_dma_filter(struct dma_chan *chan, void *parm) { return chan->chan_id == *(int *)parm; @@ -231,6 +232,12 @@ static int dw8250_probe_acpi(struct uart_port *p) return 0; } +#else +static inline int dw8250_probe_acpi(struct uart_port *p) +{ + return -ENODEV; +} +#endif /* CONFIG_ACPI */ static void dw8250_setup_port(struct uart_8250_port *up) { -- cgit v1.2.3 From f5836a55dee705d47a16c32139c02721763ff699 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 16 Jan 2013 14:08:16 +0200 Subject: serial: 8250_dw: Set maxburst size The default burst is often 1 byte which is not very optimal. The ideal burst size when using 16550A type port would be 1/2 of fifosize, but this does not work with all Designware implementations. Setting it to 1/4 fifosize. Signed-off-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index bfdaf8b2680b..117bb8b03598 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -178,6 +178,7 @@ dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) slave->direction = DMA_MEM_TO_DEV; slave->dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; slave->slave_id = fixed_dma->request_lines; + slave->dst_maxburst = port->tx_loadsz / 4; dma->tx_chan_id = fixed_dma->channels; dma->tx_param = &dma->tx_chan_id; @@ -189,6 +190,7 @@ dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) slave->direction = DMA_DEV_TO_MEM; slave->src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; slave->slave_id = fixed_dma->request_lines; + slave->src_maxburst = p->fifosize / 4; dma->rx_chan_id = fixed_dma->channels; dma->rx_param = &dma->rx_chan_id; @@ -296,6 +298,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; + dw8250_setup_port(&uart); + if (pdev->dev.of_node) { err = dw8250_probe_of(&uart.port); if (err) @@ -308,8 +312,6 @@ static int dw8250_probe(struct platform_device *pdev) return -ENODEV; } - dw8250_setup_port(&uart); - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; -- cgit v1.2.3 From 2894500dec707a3318e8c28a8df24d828af9a5e3 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 16 Jan 2013 14:45:06 +0100 Subject: TTY: ip22zilog, fix tty_flip_buffer_push call This one was omitted by the "TTY: switch tty_flip_buffer_push" patch because I did not compile-test mips driver. Now I do. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/ip22zilog.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c index 7b1cda59ebb5..cb3c81eb0996 100644 --- a/drivers/tty/serial/ip22zilog.c +++ b/drivers/tty/serial/ip22zilog.c @@ -248,17 +248,12 @@ static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up, #define Rx_BRK 0x0100 /* BREAK event software flag. */ #define Rx_SYS 0x0200 /* SysRq event software flag. */ -static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up, +static bool ip22zilog_receive_chars(struct uart_ip22zilog_port *up, struct zilog_channel *channel) { - struct tty_struct *tty; unsigned char ch, flag; unsigned int r1; - - tty = NULL; - if (up->port.state != NULL && - up->port.state->port.tty != NULL) - tty = up->port.state->port.tty; + bool push = up->port.state != NULL; for (;;) { ch = readb(&channel->control); @@ -312,10 +307,10 @@ static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up if (uart_handle_sysrq_char(&up->port, ch)) continue; - if (tty) + if (push) uart_insert_char(&up->port, r1, Rx_OVR, ch, flag); } - return tty; + return push; } static void ip22zilog_status_handle(struct uart_ip22zilog_port *up, @@ -438,21 +433,20 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) while (up) { struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port); - struct tty_struct *tty; unsigned char r3; + bool push = false; spin_lock(&up->port.lock); r3 = read_zsreg(channel, R3); /* Channel A */ - tty = NULL; if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHARxIP) - tty = ip22zilog_receive_chars(up, channel); + push = ip22zilog_receive_chars(up, channel); if (r3 & CHAEXT) ip22zilog_status_handle(up, channel); if (r3 & CHATxIP) @@ -460,22 +454,22 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); - if (tty) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&up->port.state->port); /* Channel B */ up = up->next; channel = ZILOG_CHANNEL_FROM_PORT(&up->port); + push = false; spin_lock(&up->port.lock); - tty = NULL; if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHBRxIP) - tty = ip22zilog_receive_chars(up, channel); + push = ip22zilog_receive_chars(up, channel); if (r3 & CHBEXT) ip22zilog_status_handle(up, channel); if (r3 & CHBTxIP) @@ -483,8 +477,8 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); - if (tty) - tty_flip_buffer_push(tty); + if (push) + tty_flip_buffer_push(&up->port.state->port); up = up->next; } -- cgit v1.2.3 From e27a7d7977b07d701ba247e2ddb95466d95c898f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 16 Jan 2013 07:38:04 -0800 Subject: Staging: sb105x: mark it BROKEN It isn't using the port logic, and breaks the build at the moment, so mark it BROKEN. Cc: Jiri Slaby Cc: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sb105x/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/sb105x/Kconfig b/drivers/staging/sb105x/Kconfig index ac87c5e38dee..3d0d0eb95b8c 100644 --- a/drivers/staging/sb105x/Kconfig +++ b/drivers/staging/sb105x/Kconfig @@ -1,7 +1,7 @@ config SB105X tristate "SystemBase PCI Multiport UART" select SERIAL_CORE - depends on PCI + depends on PCI && BROKEN help A driver for the SystemBase Multi-2/PCI serial card -- cgit v1.2.3 From ac4ce718893c546f7a2d34ab55a8f75842399f86 Mon Sep 17 00:00:00 2001 From: Barry Song Date: Wed, 16 Jan 2013 14:49:27 +0800 Subject: serial: sirf: only use lookup table to set baudrate when ioclk=150MHz The fast lookup table to set baudrate is only right when ioclk is 150MHz. for most platforms, ioclk is 150MHz, but some boards might set ioclk to other frequency. so re-calc the clk_div_reg when ioclk is not 150MHz. this patch also gets clk in probe and puts it in remove. Signed-off-by: Barry Song Cc: Russell King Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sirfsoc_uart.c | 28 +++++++++++++++++++++------- drivers/tty/serial/sirfsoc_uart.h | 1 + 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 8f3d6c091acc..6bbfe9934a4d 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c @@ -357,7 +357,6 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, struct ktermios *old) { struct sirfsoc_uart_port *sirfport = to_sirfport(port); - unsigned long ioclk_rate; unsigned long config_reg = 0; unsigned long baud_rate; unsigned long setted_baud; @@ -369,7 +368,6 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, int threshold_div; int temp; - ioclk_rate = 150000000; switch (termios->c_cflag & CSIZE) { default: case CS8: @@ -425,14 +423,17 @@ static void sirfsoc_uart_set_termios(struct uart_port *port, sirfsoc_uart_disable_ms(port); } - /* common rate: fast calculation */ - for (ic = 0; ic < SIRF_BAUD_RATE_SUPPORT_NR; ic++) - if (baud_rate == baudrate_to_regv[ic].baud_rate) - clk_div_reg = baudrate_to_regv[ic].reg_val; + if (port->uartclk == 150000000) { + /* common rate: fast calculation */ + for (ic = 0; ic < SIRF_BAUD_RATE_SUPPORT_NR; ic++) + if (baud_rate == baudrate_to_regv[ic].baud_rate) + clk_div_reg = baudrate_to_regv[ic].reg_val; + } + setted_baud = baud_rate; /* arbitary rate setting */ if (unlikely(clk_div_reg == 0)) - clk_div_reg = sirfsoc_calc_sample_div(baud_rate, ioclk_rate, + clk_div_reg = sirfsoc_calc_sample_div(baud_rate, port->uartclk, &setted_baud); wr_regl(port, SIRFUART_DIVISOR, clk_div_reg); @@ -691,6 +692,14 @@ int sirfsoc_uart_probe(struct platform_device *pdev) goto err; } + sirfport->clk = clk_get(&pdev->dev, NULL); + if (IS_ERR(sirfport->clk)) { + ret = PTR_ERR(sirfport->clk); + goto clk_err; + } + clk_prepare_enable(sirfport->clk); + port->uartclk = clk_get_rate(sirfport->clk); + port->ops = &sirfsoc_uart_ops; spin_lock_init(&port->lock); @@ -704,6 +713,9 @@ int sirfsoc_uart_probe(struct platform_device *pdev) return 0; port_err: + clk_disable_unprepare(sirfport->clk); + clk_put(sirfport->clk); +clk_err: platform_set_drvdata(pdev, NULL); if (sirfport->hw_flow_ctrl) pinctrl_put(sirfport->p); @@ -718,6 +730,8 @@ static int sirfsoc_uart_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); if (sirfport->hw_flow_ctrl) pinctrl_put(sirfport->p); + clk_disable_unprepare(sirfport->clk); + clk_put(sirfport->clk); uart_remove_one_port(&sirfsoc_uart_drv, port); return 0; } diff --git a/drivers/tty/serial/sirfsoc_uart.h b/drivers/tty/serial/sirfsoc_uart.h index 6431640c3163..85328ba0c4e3 100644 --- a/drivers/tty/serial/sirfsoc_uart.h +++ b/drivers/tty/serial/sirfsoc_uart.h @@ -163,6 +163,7 @@ struct sirfsoc_uart_port { struct uart_port port; struct pinctrl *p; + struct clk *clk; }; /* Hardware Flow Control */ -- cgit v1.2.3 From 795b5bbe215c7b988fcf218613d2f3357924f0d2 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Wed, 16 Jan 2013 13:47:23 +0530 Subject: serial/arc-uart: Fix section mistmatch Commit "serial/arc-uart: split probe from probe_earlyprintk" introduced a build time warning: "WARNING: vmlinux.o(.data+0x5baa0): Section mismatch in reference from the variable early_arc_platform_driver to the function .init.text:arc_serial_probe_earlyprintk()" While at it - fixed another incorrectly placed initdata annotation. Signed-off-by: Vineet Gupta Reported-by: kbuild test robot Cc: Greg Kroah-Hartman Cc: fengguang.wu@intel.com Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/arc_uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index da734222e537..6f7eadc424a3 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -659,7 +659,7 @@ static __init void early_serial_write(struct console *con, const char *s, } } -static struct __initdata console arc_early_serial_console = { +static struct console arc_early_serial_console __initdata = { .name = "early_ARCuart", .write = early_serial_write, .flags = CON_PRINTBUFFER | CON_BOOT, @@ -731,7 +731,7 @@ static struct platform_driver arc_platform_driver = { #ifdef CONFIG_SERIAL_ARC_CONSOLE -static struct platform_driver early_arc_platform_driver = { +static struct platform_driver early_arc_platform_driver __initdata = { .probe = arc_serial_probe_earlyprintk, .remove = arc_serial_remove, .driver = { -- cgit v1.2.3 From 5fe2123647c15089c3a905137bea87b16973c896 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Wed, 16 Jan 2013 05:08:06 -0500 Subject: OMAP/serial: Support 1Mbaud and similar baudrates that require Mode16 instead of Mode13 Original table in OMAP TRM named "UART Mode Baud Rates, Divisor Values, and Error Rates" determines modes not for all common baud rates. E.g. for 1000000 baud rate mode should be 16x, but according to that table it's determined as 13x. According to current implementation of mode divisor selection, after requesting 1000000 baudrate from driver, later one will configure chip to use MODE13 divisor. Assuming 48Mhz as common UART clock speed, MODE13 divisor will effectively give 1230769 baudrate, what is quite far from desired 1000000 baudrate. While with MODE16 divisor, chip will produce exact 1000000 baudrate. In old driver that served UART devices (8250.c and serial_core.c) this divisor could have been configured by user-space program, but in omap_serial.c driver implementation this ability was not implemented (afaik, by design) thus disallowing proper usage of MODE16-compatible baudrates. Signed-off-by: Alexey Pelykh Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/omap-serial.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 6f3dbf740f05..9915e4d1418c 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -231,25 +231,43 @@ static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) pdata->enable_wakeup(up->dev, enable); } +/* + * serial_omap_baud_is_mode16 - check if baud rate is MODE16X + * @port: uart port info + * @baud: baudrate for which mode needs to be determined + * + * Returns true if baud rate is MODE16X and false if MODE13X + * Original table in OMAP TRM named "UART Mode Baud Rates, Divisor Values, + * and Error Rates" determines modes not for all common baud rates. + * E.g. for 1000000 baud rate mode must be 16x, but according to that + * table it's determined as 13x. + */ +static bool +serial_omap_baud_is_mode16(struct uart_port *port, unsigned int baud) +{ + unsigned int n13 = port->uartclk / (13 * baud); + unsigned int n16 = port->uartclk / (16 * baud); + int baudAbsDiff13 = baud - (port->uartclk / (13 * n13)); + int baudAbsDiff16 = baud - (port->uartclk / (16 * n16)); + if(baudAbsDiff13 < 0) + baudAbsDiff13 = -baudAbsDiff13; + if(baudAbsDiff16 < 0) + baudAbsDiff16 = -baudAbsDiff16; + + return (baudAbsDiff13 > baudAbsDiff16); +} + /* * serial_omap_get_divisor - calculate divisor value * @port: uart port info * @baud: baudrate for which divisor needs to be calculated. - * - * We have written our own function to get the divisor so as to support - * 13x mode. 3Mbps Baudrate as an different divisor. - * Reference OMAP TRM Chapter 17: - * Table 17-1. UART Mode Baud Rates, Divisor Values, and Error Rates - * referring to oversampling - divisor value - * baudrate 460,800 to 3,686,400 all have divisor 13 - * except 3,000,000 which has divisor value 16 */ static unsigned int serial_omap_get_divisor(struct uart_port *port, unsigned int baud) { unsigned int divisor; - if (baud > OMAP_MODE13X_SPEED && baud != 3000000) + if (!serial_omap_baud_is_mode16(port, baud)) divisor = 13; else divisor = 16; @@ -916,7 +934,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, serial_out(up, UART_EFR, up->efr); serial_out(up, UART_LCR, cval); - if (baud > 230400 && baud != 3000000) + if (!serial_omap_baud_is_mode16(port, baud)) up->mdr1 = UART_OMAP_MDR1_13X_MODE; else up->mdr1 = UART_OMAP_MDR1_16X_MODE; -- cgit v1.2.3 From 9ef20d52e0cd0d6ab78cab13563b16496bdc6995 Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Wed, 16 Jan 2013 23:30:43 +0100 Subject: tty: serial/68328serial.c: remove unnecessary null pointer check The pointer info is dereferened in line 1009, so it is not necessary to check null again in line 1012. Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/68328serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 641a5a4d73d9..49399470794d 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c @@ -1002,7 +1002,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) m68328_uart *uart = &uart_addr[info->line]; unsigned long flags; - if (!info || serial_paranoia_check(info, tty->name, "rs_close")) + if (serial_paranoia_check(info, tty->name, "rs_close")) return; local_irq_save(flags); -- cgit v1.2.3 From f938f3781fa877146236042341ddbcf06bc49f0a Mon Sep 17 00:00:00 2001 From: Cong Ding Date: Wed, 16 Jan 2013 23:30:44 +0100 Subject: tty: serial/crisv10.c: remove unnecessary null pointer check The pointer tty is dereferened in line 3135, so it is not necessary to check null again in line 3140. Signed-off-by: Cong Ding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/crisv10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 45acf103433e..5f37c31e32bc 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -3122,7 +3122,7 @@ static int rs_raw_write(struct tty_struct *tty, /* first some sanity checks */ - if (!tty || !info->xmit.buf) + if (!info->xmit.buf) return 0; #ifdef SERIAL_DEBUG_DATA -- cgit v1.2.3 From 27dd2e04923341cff96aae164117c44da1072c32 Mon Sep 17 00:00:00 2001 From: Tony Prisk Date: Thu, 17 Jan 2013 08:05:40 +1300 Subject: serial: vt8500: Fix range-checking on vt8500_uart_ports Fix two instances where the index to vt8500_uart_ports is tested against > VT8500_MAX_PORTS. Correct usage should be >= VT8500_MAX_PORTS. Signed-off-by: Tony Prisk Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/vt8500_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index f1a398c672fa..e50deb771616 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -560,7 +560,7 @@ static int vt8500_serial_probe(struct platform_device *pdev) if (np) port = of_alias_get_id(np, "serial"); - if (port > VT8500_MAX_PORTS) + if (port >= VT8500_MAX_PORTS) port = -1; else port = -1; @@ -571,7 +571,7 @@ static int vt8500_serial_probe(struct platform_device *pdev) sizeof(vt8500_ports_in_use)); } - if (port > VT8500_MAX_PORTS) + if (port >= VT8500_MAX_PORTS) return -ENODEV; /* reserve the port id */ -- cgit v1.2.3 From 4053036580f0423be14e79483a939a4aef48c592 Mon Sep 17 00:00:00 2001 From: Tony Prisk Date: Thu, 17 Jan 2013 08:05:41 +1300 Subject: serial: vt8500: ioremap'd resource is never freed Memory mapped via ioremap call is never released. Rather than add an iounmap call, change allocation function to devm_request_and_ioremap. Also, change the error on failure for this call to -EADDRNOTAVAIL rather than -ENOMEM. Signed-off-by: Tony Prisk Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/vt8500_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index e50deb771616..ff391db0a220 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -606,9 +606,9 @@ static int vt8500_serial_probe(struct platform_device *pdev) snprintf(vt8500_port->name, sizeof(vt8500_port->name), "VT8500 UART%d", pdev->id); - vt8500_port->uart.membase = ioremap(mmres->start, resource_size(mmres)); + vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); if (!vt8500_port->uart.membase) { - ret = -ENOMEM; + ret = -EADDRNOTAVAIL; goto err; } -- cgit v1.2.3 From b9d42395a09b8ff81df45b8dfd763fd36e900946 Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Wed, 16 Jan 2013 20:28:39 -0800 Subject: tty: rocket: Explicitly list supported PCI IDs Matching PCI_ANY_ID causes conflicts with RocketPort 2 adapters, which are supported by a different driver. Signed-off-by: Kevin Cernekee Signed-off-by: Greg Kroah-Hartman --- drivers/tty/rocket.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 69c16fc06e58..1d270034bfc3 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -1756,8 +1756,29 @@ static void rp_flush_buffer(struct tty_struct *tty) #ifdef CONFIG_PCI -static struct pci_device_id __used rocket_pci_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_ANY_ID) }, +static DEFINE_PCI_DEVICE_TABLE(rocket_pci_ids) = { + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP4QUAD) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8OCTA) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_URP8OCTA) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_URP8INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8J) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP4J) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8SNI) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP16SNI) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP16INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_URP16INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_CRP16INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP32INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_URP32INTF) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RPP4) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RPP8) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP2_232) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP2_422) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP6M) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP4M) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_UPCI_RM3_8PORT) }, + { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_UPCI_RM3_4PORT) }, { } }; MODULE_DEVICE_TABLE(pci, rocket_pci_ids); @@ -1779,7 +1800,8 @@ static __init int register_PCI(int i, struct pci_dev *dev) WordIO_t ConfigIO = 0; ByteIO_t UPCIRingInd = 0; - if (!dev || pci_enable_device(dev)) + if (!dev || !pci_match_id(rocket_pci_ids, dev) || + pci_enable_device(dev)) return 0; rcktpt_io_addr[i] = pci_resource_start(dev, 0); -- cgit v1.2.3 From 7d9f49afa451d8565d00a5cea39acf9bb26feb50 Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Wed, 16 Jan 2013 20:28:40 -0800 Subject: serial: rp2: New driver for Comtrol RocketPort 2 cards This driver supports the RocketPort EXPRESS and RocketPort INFINITY families of PCI/PCIe multiport serial adapters. These adapters use a "RocketPort 2" ASIC that is not compatible with the original RocketPort driver (CONFIG_ROCKETPORT). Tested with the RocketPort EXPRESS Octa DB9 and Quad DB9. Also added an old RocketPort 8J PCI card to the same system to verify that rocket.c and rp2.c coexist peacefully. Signed-off-by: Kevin Cernekee Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/Kconfig | 24 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/rp2.c | 885 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 4 files changed, 913 insertions(+) create mode 100644 drivers/tty/serial/rp2.c (limited to 'drivers') diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index aff3cd356662..2dc429357fe3 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1458,4 +1458,28 @@ config SERIAL_ARC_NR_PORTS Set this to the number of serial ports you want the driver to support. +config SERIAL_RP2 + tristate "Comtrol RocketPort EXPRESS/INFINITY support" + depends on PCI + select SERIAL_CORE + help + This driver supports the Comtrol RocketPort EXPRESS and + RocketPort INFINITY families of PCI/PCIe multiport serial adapters. + These adapters use a "RocketPort 2" ASIC that is not compatible + with the original RocketPort driver (CONFIG_ROCKETPORT). + + To compile this driver as a module, choose M here: the + module will be called rp2. + + If you want to compile this driver into the kernel, say Y here. If + you don't have a suitable RocketPort card installed, say N. + +config SERIAL_RP2_NR_UARTS + int "Maximum number of RocketPort EXPRESS/INFINITY ports" + depends on SERIAL_RP2 + default "32" + help + If multiple cards are present, the default limit of 32 ports may + need to be increased. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 82e4306bf962..eedfec40e3dd 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -84,3 +84,4 @@ obj-$(CONFIG_SERIAL_TEGRA) += serial-tegra.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o obj-$(CONFIG_SERIAL_ARC) += arc_uart.o +obj-$(CONFIG_SERIAL_RP2) += rp2.o diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c new file mode 100644 index 000000000000..a314a943f124 --- /dev/null +++ b/drivers/tty/serial/rp2.c @@ -0,0 +1,885 @@ +/* + * Driver for Comtrol RocketPort EXPRESS/INFINITY cards + * + * Copyright (C) 2012 Kevin Cernekee + * + * Inspired by, and loosely based on: + * + * ar933x_uart.c + * Copyright (C) 2011 Gabor Juhos + * + * rocketport_infinity_express-linux-1.20.tar.gz + * Copyright (C) 2004-2011 Comtrol, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "rp2" + +#define RP2_FW_NAME "rp2.fw" +#define RP2_UCODE_BYTES 0x3f + +#define PORTS_PER_ASIC 16 +#define ALL_PORTS_MASK (BIT(PORTS_PER_ASIC) - 1) + +#define UART_CLOCK 44236800 +#define DEFAULT_BAUD_DIV (UART_CLOCK / (9600 * 16)) +#define FIFO_SIZE 512 + +/* BAR0 registers */ +#define RP2_FPGA_CTL0 0x110 +#define RP2_FPGA_CTL1 0x11c +#define RP2_IRQ_MASK 0x1ec +#define RP2_IRQ_MASK_EN_m BIT(0) +#define RP2_IRQ_STATUS 0x1f0 + +/* BAR1 registers */ +#define RP2_ASIC_SPACING 0x1000 +#define RP2_ASIC_OFFSET(i) ((i) << ilog2(RP2_ASIC_SPACING)) + +#define RP2_PORT_BASE 0x000 +#define RP2_PORT_SPACING 0x040 + +#define RP2_UCODE_BASE 0x400 +#define RP2_UCODE_SPACING 0x80 + +#define RP2_CLK_PRESCALER 0xc00 +#define RP2_CH_IRQ_STAT 0xc04 +#define RP2_CH_IRQ_MASK 0xc08 +#define RP2_ASIC_IRQ 0xd00 +#define RP2_ASIC_IRQ_EN_m BIT(20) +#define RP2_GLOBAL_CMD 0xd0c +#define RP2_ASIC_CFG 0xd04 + +/* port registers */ +#define RP2_DATA_DWORD 0x000 + +#define RP2_DATA_BYTE 0x008 +#define RP2_DATA_BYTE_ERR_PARITY_m BIT(8) +#define RP2_DATA_BYTE_ERR_OVERRUN_m BIT(9) +#define RP2_DATA_BYTE_ERR_FRAMING_m BIT(10) +#define RP2_DATA_BYTE_BREAK_m BIT(11) + +/* This lets uart_insert_char() drop bytes received on a !CREAD port */ +#define RP2_DUMMY_READ BIT(16) + +#define RP2_DATA_BYTE_EXCEPTION_MASK (RP2_DATA_BYTE_ERR_PARITY_m | \ + RP2_DATA_BYTE_ERR_OVERRUN_m | \ + RP2_DATA_BYTE_ERR_FRAMING_m | \ + RP2_DATA_BYTE_BREAK_m) + +#define RP2_RX_FIFO_COUNT 0x00c +#define RP2_TX_FIFO_COUNT 0x00e + +#define RP2_CHAN_STAT 0x010 +#define RP2_CHAN_STAT_RXDATA_m BIT(0) +#define RP2_CHAN_STAT_DCD_m BIT(3) +#define RP2_CHAN_STAT_DSR_m BIT(4) +#define RP2_CHAN_STAT_CTS_m BIT(5) +#define RP2_CHAN_STAT_RI_m BIT(6) +#define RP2_CHAN_STAT_OVERRUN_m BIT(13) +#define RP2_CHAN_STAT_DSR_CHANGED_m BIT(16) +#define RP2_CHAN_STAT_CTS_CHANGED_m BIT(17) +#define RP2_CHAN_STAT_CD_CHANGED_m BIT(18) +#define RP2_CHAN_STAT_RI_CHANGED_m BIT(22) +#define RP2_CHAN_STAT_TXEMPTY_m BIT(25) + +#define RP2_CHAN_STAT_MS_CHANGED_MASK (RP2_CHAN_STAT_DSR_CHANGED_m | \ + RP2_CHAN_STAT_CTS_CHANGED_m | \ + RP2_CHAN_STAT_CD_CHANGED_m | \ + RP2_CHAN_STAT_RI_CHANGED_m) + +#define RP2_TXRX_CTL 0x014 +#define RP2_TXRX_CTL_MSRIRQ_m BIT(0) +#define RP2_TXRX_CTL_RXIRQ_m BIT(2) +#define RP2_TXRX_CTL_RX_TRIG_s 3 +#define RP2_TXRX_CTL_RX_TRIG_m (0x3 << RP2_TXRX_CTL_RX_TRIG_s) +#define RP2_TXRX_CTL_RX_TRIG_1 (0x1 << RP2_TXRX_CTL_RX_TRIG_s) +#define RP2_TXRX_CTL_RX_TRIG_256 (0x2 << RP2_TXRX_CTL_RX_TRIG_s) +#define RP2_TXRX_CTL_RX_TRIG_448 (0x3 << RP2_TXRX_CTL_RX_TRIG_s) +#define RP2_TXRX_CTL_RX_EN_m BIT(5) +#define RP2_TXRX_CTL_RTSFLOW_m BIT(6) +#define RP2_TXRX_CTL_DTRFLOW_m BIT(7) +#define RP2_TXRX_CTL_TX_TRIG_s 16 +#define RP2_TXRX_CTL_TX_TRIG_m (0x3 << RP2_TXRX_CTL_RX_TRIG_s) +#define RP2_TXRX_CTL_DSRFLOW_m BIT(18) +#define RP2_TXRX_CTL_TXIRQ_m BIT(19) +#define RP2_TXRX_CTL_CTSFLOW_m BIT(23) +#define RP2_TXRX_CTL_TX_EN_m BIT(24) +#define RP2_TXRX_CTL_RTS_m BIT(25) +#define RP2_TXRX_CTL_DTR_m BIT(26) +#define RP2_TXRX_CTL_LOOP_m BIT(27) +#define RP2_TXRX_CTL_BREAK_m BIT(28) +#define RP2_TXRX_CTL_CMSPAR_m BIT(29) +#define RP2_TXRX_CTL_nPARODD_m BIT(30) +#define RP2_TXRX_CTL_PARENB_m BIT(31) + +#define RP2_UART_CTL 0x018 +#define RP2_UART_CTL_MODE_s 0 +#define RP2_UART_CTL_MODE_m (0x7 << RP2_UART_CTL_MODE_s) +#define RP2_UART_CTL_MODE_rs232 (0x1 << RP2_UART_CTL_MODE_s) +#define RP2_UART_CTL_FLUSH_RX_m BIT(3) +#define RP2_UART_CTL_FLUSH_TX_m BIT(4) +#define RP2_UART_CTL_RESET_CH_m BIT(5) +#define RP2_UART_CTL_XMIT_EN_m BIT(6) +#define RP2_UART_CTL_DATABITS_s 8 +#define RP2_UART_CTL_DATABITS_m (0x3 << RP2_UART_CTL_DATABITS_s) +#define RP2_UART_CTL_DATABITS_8 (0x3 << RP2_UART_CTL_DATABITS_s) +#define RP2_UART_CTL_DATABITS_7 (0x2 << RP2_UART_CTL_DATABITS_s) +#define RP2_UART_CTL_DATABITS_6 (0x1 << RP2_UART_CTL_DATABITS_s) +#define RP2_UART_CTL_DATABITS_5 (0x0 << RP2_UART_CTL_DATABITS_s) +#define RP2_UART_CTL_STOPBITS_m BIT(10) + +#define RP2_BAUD 0x01c + +/* ucode registers */ +#define RP2_TX_SWFLOW 0x02 +#define RP2_TX_SWFLOW_ena 0x81 +#define RP2_TX_SWFLOW_dis 0x9d + +#define RP2_RX_SWFLOW 0x0c +#define RP2_RX_SWFLOW_ena 0x81 +#define RP2_RX_SWFLOW_dis 0x8d + +#define RP2_RX_FIFO 0x37 +#define RP2_RX_FIFO_ena 0x08 +#define RP2_RX_FIFO_dis 0x81 + +static struct uart_driver rp2_uart_driver = { + .owner = THIS_MODULE, + .driver_name = DRV_NAME, + .dev_name = "ttyRP", + .nr = CONFIG_SERIAL_RP2_NR_UARTS, +}; + +struct rp2_card; + +struct rp2_uart_port { + struct uart_port port; + int idx; + int ignore_rx; + struct rp2_card *card; + void __iomem *asic_base; + void __iomem *base; + void __iomem *ucode; +}; + +struct rp2_card { + struct pci_dev *pdev; + struct rp2_uart_port *ports; + int n_ports; + int initialized_ports; + int minor_start; + int smpte; + void __iomem *bar0; + void __iomem *bar1; + spinlock_t card_lock; + struct completion fw_loaded; +}; + +#define RP_ID(prod) PCI_VDEVICE(RP, (prod)) +#define RP_CAP(ports, smpte) (((ports) << 8) | ((smpte) << 0)) + +static inline void rp2_decode_cap(const struct pci_device_id *id, + int *ports, int *smpte) +{ + *ports = id->driver_data >> 8; + *smpte = id->driver_data & 0xff; +} + +static DEFINE_SPINLOCK(rp2_minor_lock); +static int rp2_minor_next; + +static int rp2_alloc_ports(int n_ports) +{ + int ret = -ENOSPC; + + spin_lock(&rp2_minor_lock); + if (rp2_minor_next + n_ports <= CONFIG_SERIAL_RP2_NR_UARTS) { + /* sorry, no support for hot unplugging individual cards */ + ret = rp2_minor_next; + rp2_minor_next += n_ports; + } + spin_unlock(&rp2_minor_lock); + + return ret; +} + +static inline struct rp2_uart_port *port_to_up(struct uart_port *port) +{ + return container_of(port, struct rp2_uart_port, port); +} + +static void rp2_rmw(struct rp2_uart_port *up, int reg, + u32 clr_bits, u32 set_bits) +{ + u32 tmp = readl(up->base + reg); + tmp &= ~clr_bits; + tmp |= set_bits; + writel(tmp, up->base + reg); +} + +static void rp2_rmw_clr(struct rp2_uart_port *up, int reg, u32 val) +{ + rp2_rmw(up, reg, val, 0); +} + +static void rp2_rmw_set(struct rp2_uart_port *up, int reg, u32 val) +{ + rp2_rmw(up, reg, 0, val); +} + +static void rp2_mask_ch_irq(struct rp2_uart_port *up, int ch_num, + int is_enabled) +{ + unsigned long flags, irq_mask; + + spin_lock_irqsave(&up->card->card_lock, flags); + + irq_mask = readl(up->asic_base + RP2_CH_IRQ_MASK); + if (is_enabled) + irq_mask &= ~BIT(ch_num); + else + irq_mask |= BIT(ch_num); + writel(irq_mask, up->asic_base + RP2_CH_IRQ_MASK); + + spin_unlock_irqrestore(&up->card->card_lock, flags); +} + +static unsigned int rp2_uart_tx_empty(struct uart_port *port) +{ + struct rp2_uart_port *up = port_to_up(port); + unsigned long tx_fifo_bytes, flags; + + /* + * This should probably check the transmitter, not the FIFO. + * But the TXEMPTY bit doesn't seem to work unless the TX IRQ is + * enabled. + */ + spin_lock_irqsave(&up->port.lock, flags); + tx_fifo_bytes = readw(up->base + RP2_TX_FIFO_COUNT); + spin_unlock_irqrestore(&up->port.lock, flags); + + return tx_fifo_bytes ? 0 : TIOCSER_TEMT; +} + +static unsigned int rp2_uart_get_mctrl(struct uart_port *port) +{ + struct rp2_uart_port *up = port_to_up(port); + u32 status; + + status = readl(up->base + RP2_CHAN_STAT); + return ((status & RP2_CHAN_STAT_DCD_m) ? TIOCM_CAR : 0) | + ((status & RP2_CHAN_STAT_DSR_m) ? TIOCM_DSR : 0) | + ((status & RP2_CHAN_STAT_CTS_m) ? TIOCM_CTS : 0) | + ((status & RP2_CHAN_STAT_RI_m) ? TIOCM_RI : 0); +} + +static void rp2_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) +{ + rp2_rmw(port_to_up(port), RP2_TXRX_CTL, + RP2_TXRX_CTL_DTR_m | RP2_TXRX_CTL_RTS_m | RP2_TXRX_CTL_LOOP_m, + ((mctrl & TIOCM_DTR) ? RP2_TXRX_CTL_DTR_m : 0) | + ((mctrl & TIOCM_RTS) ? RP2_TXRX_CTL_RTS_m : 0) | + ((mctrl & TIOCM_LOOP) ? RP2_TXRX_CTL_LOOP_m : 0)); +} + +static void rp2_uart_start_tx(struct uart_port *port) +{ + rp2_rmw_set(port_to_up(port), RP2_TXRX_CTL, RP2_TXRX_CTL_TXIRQ_m); +} + +static void rp2_uart_stop_tx(struct uart_port *port) +{ + rp2_rmw_clr(port_to_up(port), RP2_TXRX_CTL, RP2_TXRX_CTL_TXIRQ_m); +} + +static void rp2_uart_stop_rx(struct uart_port *port) +{ + rp2_rmw_clr(port_to_up(port), RP2_TXRX_CTL, RP2_TXRX_CTL_RXIRQ_m); +} + +static void rp2_uart_break_ctl(struct uart_port *port, int break_state) +{ + unsigned long flags; + + spin_lock_irqsave(&port->lock, flags); + rp2_rmw(port_to_up(port), RP2_TXRX_CTL, RP2_TXRX_CTL_BREAK_m, + break_state ? RP2_TXRX_CTL_BREAK_m : 0); + spin_unlock_irqrestore(&port->lock, flags); +} + +static void rp2_uart_enable_ms(struct uart_port *port) +{ + rp2_rmw_set(port_to_up(port), RP2_TXRX_CTL, RP2_TXRX_CTL_MSRIRQ_m); +} + +static void __rp2_uart_set_termios(struct rp2_uart_port *up, + unsigned long cfl, + unsigned long ifl, + unsigned int baud_div) +{ + /* baud rate divisor (calculated elsewhere). 0 = divide-by-1 */ + writew(baud_div - 1, up->base + RP2_BAUD); + + /* data bits and stop bits */ + rp2_rmw(up, RP2_UART_CTL, + RP2_UART_CTL_STOPBITS_m | RP2_UART_CTL_DATABITS_m, + ((cfl & CSTOPB) ? RP2_UART_CTL_STOPBITS_m : 0) | + (((cfl & CSIZE) == CS8) ? RP2_UART_CTL_DATABITS_8 : 0) | + (((cfl & CSIZE) == CS7) ? RP2_UART_CTL_DATABITS_7 : 0) | + (((cfl & CSIZE) == CS6) ? RP2_UART_CTL_DATABITS_6 : 0) | + (((cfl & CSIZE) == CS5) ? RP2_UART_CTL_DATABITS_5 : 0)); + + /* parity and hardware flow control */ + rp2_rmw(up, RP2_TXRX_CTL, + RP2_TXRX_CTL_PARENB_m | RP2_TXRX_CTL_nPARODD_m | + RP2_TXRX_CTL_CMSPAR_m | RP2_TXRX_CTL_DTRFLOW_m | + RP2_TXRX_CTL_DSRFLOW_m | RP2_TXRX_CTL_RTSFLOW_m | + RP2_TXRX_CTL_CTSFLOW_m, + ((cfl & PARENB) ? RP2_TXRX_CTL_PARENB_m : 0) | + ((cfl & PARODD) ? 0 : RP2_TXRX_CTL_nPARODD_m) | + ((cfl & CMSPAR) ? RP2_TXRX_CTL_CMSPAR_m : 0) | + ((cfl & CRTSCTS) ? (RP2_TXRX_CTL_RTSFLOW_m | + RP2_TXRX_CTL_CTSFLOW_m) : 0)); + + /* XON/XOFF software flow control */ + writeb((ifl & IXON) ? RP2_TX_SWFLOW_ena : RP2_TX_SWFLOW_dis, + up->ucode + RP2_TX_SWFLOW); + writeb((ifl & IXOFF) ? RP2_RX_SWFLOW_ena : RP2_RX_SWFLOW_dis, + up->ucode + RP2_RX_SWFLOW); +} + +static void rp2_uart_set_termios(struct uart_port *port, + struct ktermios *new, + struct ktermios *old) +{ + struct rp2_uart_port *up = port_to_up(port); + unsigned long flags; + unsigned int baud, baud_div; + + baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); + baud_div = uart_get_divisor(port, baud); + + if (tty_termios_baud_rate(new)) + tty_termios_encode_baud_rate(new, baud, baud); + + spin_lock_irqsave(&port->lock, flags); + + /* ignore all characters if CREAD is not set */ + port->ignore_status_mask = (new->c_cflag & CREAD) ? 0 : RP2_DUMMY_READ; + + __rp2_uart_set_termios(up, new->c_cflag, new->c_iflag, baud_div); + uart_update_timeout(port, new->c_cflag, baud); + + spin_unlock_irqrestore(&port->lock, flags); +} + +static void rp2_rx_chars(struct rp2_uart_port *up) +{ + u16 bytes = readw(up->base + RP2_RX_FIFO_COUNT); + struct tty_port *port = &up->port.state->port; + + for (; bytes != 0; bytes--) { + u32 byte = readw(up->base + RP2_DATA_BYTE) | RP2_DUMMY_READ; + char ch = byte & 0xff; + + if (likely(!(byte & RP2_DATA_BYTE_EXCEPTION_MASK))) { + if (!uart_handle_sysrq_char(&up->port, ch)) + uart_insert_char(&up->port, byte, 0, ch, + TTY_NORMAL); + } else { + char flag = TTY_NORMAL; + + if (byte & RP2_DATA_BYTE_BREAK_m) + flag = TTY_BREAK; + else if (byte & RP2_DATA_BYTE_ERR_FRAMING_m) + flag = TTY_FRAME; + else if (byte & RP2_DATA_BYTE_ERR_PARITY_m) + flag = TTY_PARITY; + uart_insert_char(&up->port, byte, + RP2_DATA_BYTE_ERR_OVERRUN_m, ch, flag); + } + up->port.icount.rx++; + } + + tty_flip_buffer_push(port); +} + +static void rp2_tx_chars(struct rp2_uart_port *up) +{ + u16 max_tx = FIFO_SIZE - readw(up->base + RP2_TX_FIFO_COUNT); + struct circ_buf *xmit = &up->port.state->xmit; + + if (uart_tx_stopped(&up->port)) { + rp2_uart_stop_tx(&up->port); + return; + } + + for (; max_tx != 0; max_tx--) { + if (up->port.x_char) { + writeb(up->port.x_char, up->base + RP2_DATA_BYTE); + up->port.x_char = 0; + up->port.icount.tx++; + continue; + } + if (uart_circ_empty(xmit)) { + rp2_uart_stop_tx(&up->port); + break; + } + writeb(xmit->buf[xmit->tail], up->base + RP2_DATA_BYTE); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + up->port.icount.tx++; + } + + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&up->port); +} + +static void rp2_ch_interrupt(struct rp2_uart_port *up) +{ + u32 status; + + spin_lock(&up->port.lock); + + /* + * The IRQ status bits are clear-on-write. Other status bits in + * this register aren't, so it's harmless to write to them. + */ + status = readl(up->base + RP2_CHAN_STAT); + writel(status, up->base + RP2_CHAN_STAT); + + if (status & RP2_CHAN_STAT_RXDATA_m) + rp2_rx_chars(up); + if (status & RP2_CHAN_STAT_TXEMPTY_m) + rp2_tx_chars(up); + if (status & RP2_CHAN_STAT_MS_CHANGED_MASK) + wake_up_interruptible(&up->port.state->port.delta_msr_wait); + + spin_unlock(&up->port.lock); +} + +static int rp2_asic_interrupt(struct rp2_card *card, unsigned int asic_id) +{ + void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); + int ch, handled = 0; + unsigned long status = readl(base + RP2_CH_IRQ_STAT) & + ~readl(base + RP2_CH_IRQ_MASK); + + for_each_set_bit(ch, &status, PORTS_PER_ASIC) { + rp2_ch_interrupt(&card->ports[ch]); + handled++; + } + return handled; +} + +static irqreturn_t rp2_uart_interrupt(int irq, void *dev_id) +{ + struct rp2_card *card = dev_id; + int handled; + + handled = rp2_asic_interrupt(card, 0); + if (card->n_ports >= PORTS_PER_ASIC) + handled += rp2_asic_interrupt(card, 1); + + return handled ? IRQ_HANDLED : IRQ_NONE; +} + +static inline void rp2_flush_fifos(struct rp2_uart_port *up) +{ + rp2_rmw_set(up, RP2_UART_CTL, + RP2_UART_CTL_FLUSH_RX_m | RP2_UART_CTL_FLUSH_TX_m); + readl(up->base + RP2_UART_CTL); + udelay(10); + rp2_rmw_clr(up, RP2_UART_CTL, + RP2_UART_CTL_FLUSH_RX_m | RP2_UART_CTL_FLUSH_TX_m); +} + +static int rp2_uart_startup(struct uart_port *port) +{ + struct rp2_uart_port *up = port_to_up(port); + + rp2_flush_fifos(up); + rp2_rmw(up, RP2_TXRX_CTL, RP2_TXRX_CTL_MSRIRQ_m, RP2_TXRX_CTL_RXIRQ_m); + rp2_rmw(up, RP2_TXRX_CTL, RP2_TXRX_CTL_RX_TRIG_m, + RP2_TXRX_CTL_RX_TRIG_1); + rp2_rmw(up, RP2_CHAN_STAT, 0, 0); + rp2_mask_ch_irq(up, up->idx, 1); + + return 0; +} + +static void rp2_uart_shutdown(struct uart_port *port) +{ + struct rp2_uart_port *up = port_to_up(port); + unsigned long flags; + + rp2_uart_break_ctl(port, 0); + + spin_lock_irqsave(&port->lock, flags); + rp2_mask_ch_irq(up, up->idx, 0); + rp2_rmw(up, RP2_CHAN_STAT, 0, 0); + spin_unlock_irqrestore(&port->lock, flags); +} + +static const char *rp2_uart_type(struct uart_port *port) +{ + return (port->type == PORT_RP2) ? "RocketPort 2 UART" : NULL; +} + +static void rp2_uart_release_port(struct uart_port *port) +{ + /* Nothing to release ... */ +} + +static int rp2_uart_request_port(struct uart_port *port) +{ + /* UARTs always present */ + return 0; +} + +static void rp2_uart_config_port(struct uart_port *port, int flags) +{ + if (flags & UART_CONFIG_TYPE) + port->type = PORT_RP2; +} + +static int rp2_uart_verify_port(struct uart_port *port, + struct serial_struct *ser) +{ + if (ser->type != PORT_UNKNOWN && ser->type != PORT_RP2) + return -EINVAL; + + return 0; +} + +static const struct uart_ops rp2_uart_ops = { + .tx_empty = rp2_uart_tx_empty, + .set_mctrl = rp2_uart_set_mctrl, + .get_mctrl = rp2_uart_get_mctrl, + .stop_tx = rp2_uart_stop_tx, + .start_tx = rp2_uart_start_tx, + .stop_rx = rp2_uart_stop_rx, + .enable_ms = rp2_uart_enable_ms, + .break_ctl = rp2_uart_break_ctl, + .startup = rp2_uart_startup, + .shutdown = rp2_uart_shutdown, + .set_termios = rp2_uart_set_termios, + .type = rp2_uart_type, + .release_port = rp2_uart_release_port, + .request_port = rp2_uart_request_port, + .config_port = rp2_uart_config_port, + .verify_port = rp2_uart_verify_port, +}; + +static void rp2_reset_asic(struct rp2_card *card, unsigned int asic_id) +{ + void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); + u32 clk_cfg; + + writew(1, base + RP2_GLOBAL_CMD); + readw(base + RP2_GLOBAL_CMD); + msleep(100); + writel(0, base + RP2_CLK_PRESCALER); + + /* TDM clock configuration */ + clk_cfg = readw(base + RP2_ASIC_CFG); + clk_cfg = (clk_cfg & ~BIT(8)) | BIT(9); + writew(clk_cfg, base + RP2_ASIC_CFG); + + /* IRQ routing */ + writel(ALL_PORTS_MASK, base + RP2_CH_IRQ_MASK); + writel(RP2_ASIC_IRQ_EN_m, base + RP2_ASIC_IRQ); +} + +static void rp2_init_card(struct rp2_card *card) +{ + writel(4, card->bar0 + RP2_FPGA_CTL0); + writel(0, card->bar0 + RP2_FPGA_CTL1); + + rp2_reset_asic(card, 0); + if (card->n_ports >= PORTS_PER_ASIC) + rp2_reset_asic(card, 1); + + writel(RP2_IRQ_MASK_EN_m, card->bar0 + RP2_IRQ_MASK); +} + +static void rp2_init_port(struct rp2_uart_port *up, const struct firmware *fw) +{ + int i; + + writel(RP2_UART_CTL_RESET_CH_m, up->base + RP2_UART_CTL); + readl(up->base + RP2_UART_CTL); + udelay(1); + + writel(0, up->base + RP2_TXRX_CTL); + writel(0, up->base + RP2_UART_CTL); + readl(up->base + RP2_UART_CTL); + udelay(1); + + rp2_flush_fifos(up); + + for (i = 0; i < min_t(int, fw->size, RP2_UCODE_BYTES); i++) + writeb(fw->data[i], up->ucode + i); + + __rp2_uart_set_termios(up, CS8 | CREAD | CLOCAL, 0, DEFAULT_BAUD_DIV); + rp2_uart_set_mctrl(&up->port, 0); + + writeb(RP2_RX_FIFO_ena, up->ucode + RP2_RX_FIFO); + rp2_rmw(up, RP2_UART_CTL, RP2_UART_CTL_MODE_m, + RP2_UART_CTL_XMIT_EN_m | RP2_UART_CTL_MODE_rs232); + rp2_rmw_set(up, RP2_TXRX_CTL, + RP2_TXRX_CTL_TX_EN_m | RP2_TXRX_CTL_RX_EN_m); +} + +static void rp2_remove_ports(struct rp2_card *card) +{ + int i; + + for (i = 0; i < card->initialized_ports; i++) + uart_remove_one_port(&rp2_uart_driver, &card->ports[i].port); + card->initialized_ports = 0; +} + +static void rp2_fw_cb(const struct firmware *fw, void *context) +{ + struct rp2_card *card = context; + resource_size_t phys_base; + int i, rc = -ENOENT; + + if (!fw) { + dev_err(&card->pdev->dev, "cannot find '%s' firmware image\n", + RP2_FW_NAME); + goto no_fw; + } + + phys_base = pci_resource_start(card->pdev, 1); + + for (i = 0; i < card->n_ports; i++) { + struct rp2_uart_port *rp = &card->ports[i]; + struct uart_port *p; + int j = (unsigned)i % PORTS_PER_ASIC; + + rp->asic_base = card->bar1; + rp->base = card->bar1 + RP2_PORT_BASE + j*RP2_PORT_SPACING; + rp->ucode = card->bar1 + RP2_UCODE_BASE + j*RP2_UCODE_SPACING; + rp->card = card; + rp->idx = j; + + p = &rp->port; + p->line = card->minor_start + i; + p->dev = &card->pdev->dev; + p->type = PORT_RP2; + p->iotype = UPIO_MEM32; + p->uartclk = UART_CLOCK; + p->regshift = 2; + p->fifosize = FIFO_SIZE; + p->ops = &rp2_uart_ops; + p->irq = card->pdev->irq; + p->membase = rp->base; + p->mapbase = phys_base + RP2_PORT_BASE + j*RP2_PORT_SPACING; + + if (i >= PORTS_PER_ASIC) { + rp->asic_base += RP2_ASIC_SPACING; + rp->base += RP2_ASIC_SPACING; + rp->ucode += RP2_ASIC_SPACING; + p->mapbase += RP2_ASIC_SPACING; + } + + rp2_init_port(rp, fw); + rc = uart_add_one_port(&rp2_uart_driver, p); + if (rc) { + dev_err(&card->pdev->dev, + "error registering port %d: %d\n", i, rc); + rp2_remove_ports(card); + break; + } + card->initialized_ports++; + } + + release_firmware(fw); +no_fw: + /* + * rp2_fw_cb() is called from a workqueue long after rp2_probe() + * has already returned success. So if something failed here, + * we'll just leave the now-dormant device in place until somebody + * unbinds it. + */ + if (rc) + dev_warn(&card->pdev->dev, "driver initialization failed\n"); + + complete(&card->fw_loaded); +} + +static int rp2_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct rp2_card *card; + struct rp2_uart_port *ports; + void __iomem * const *bars; + int rc; + + card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + pci_set_drvdata(pdev, card); + spin_lock_init(&card->card_lock); + init_completion(&card->fw_loaded); + + rc = pcim_enable_device(pdev); + if (rc) + return rc; + + rc = pcim_iomap_regions_request_all(pdev, 0x03, DRV_NAME); + if (rc) + return rc; + + bars = pcim_iomap_table(pdev); + card->bar0 = bars[0]; + card->bar1 = bars[1]; + card->pdev = pdev; + + rp2_decode_cap(id, &card->n_ports, &card->smpte); + dev_info(&pdev->dev, "found new card with %d ports\n", card->n_ports); + + card->minor_start = rp2_alloc_ports(card->n_ports); + if (card->minor_start < 0) { + dev_err(&pdev->dev, + "too many ports (try increasing CONFIG_SERIAL_RP2_NR_UARTS)\n"); + return -EINVAL; + } + + rp2_init_card(card); + + ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports, + GFP_KERNEL); + if (!ports) + return -ENOMEM; + card->ports = ports; + + rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt, + IRQF_SHARED, DRV_NAME, card); + if (rc) + return rc; + + /* + * Only catastrophic errors (e.g. ENOMEM) are reported here. + * If the FW image is missing, we'll find out in rp2_fw_cb() + * and print an error message. + */ + rc = request_firmware_nowait(THIS_MODULE, 1, RP2_FW_NAME, &pdev->dev, + GFP_KERNEL, card, rp2_fw_cb); + if (rc) + return rc; + dev_dbg(&pdev->dev, "waiting for firmware blob...\n"); + + return 0; +} + +static void rp2_remove(struct pci_dev *pdev) +{ + struct rp2_card *card = pci_get_drvdata(pdev); + + wait_for_completion(&card->fw_loaded); + rp2_remove_ports(card); +} + +static DEFINE_PCI_DEVICE_TABLE(rp2_pci_tbl) = { + + /* RocketPort INFINITY cards */ + + { RP_ID(0x0040), RP_CAP(8, 0) }, /* INF Octa, RJ45, selectable */ + { RP_ID(0x0041), RP_CAP(32, 0) }, /* INF 32, ext interface */ + { RP_ID(0x0042), RP_CAP(8, 0) }, /* INF Octa, ext interface */ + { RP_ID(0x0043), RP_CAP(16, 0) }, /* INF 16, ext interface */ + { RP_ID(0x0044), RP_CAP(4, 0) }, /* INF Quad, DB, selectable */ + { RP_ID(0x0045), RP_CAP(8, 0) }, /* INF Octa, DB, selectable */ + { RP_ID(0x0046), RP_CAP(4, 0) }, /* INF Quad, ext interface */ + { RP_ID(0x0047), RP_CAP(4, 0) }, /* INF Quad, RJ45 */ + { RP_ID(0x004a), RP_CAP(4, 0) }, /* INF Plus, Quad */ + { RP_ID(0x004b), RP_CAP(8, 0) }, /* INF Plus, Octa */ + { RP_ID(0x004c), RP_CAP(8, 0) }, /* INF III, Octa */ + { RP_ID(0x004d), RP_CAP(4, 0) }, /* INF III, Quad */ + { RP_ID(0x004e), RP_CAP(2, 0) }, /* INF Plus, 2, RS232 */ + { RP_ID(0x004f), RP_CAP(2, 1) }, /* INF Plus, 2, SMPTE */ + { RP_ID(0x0050), RP_CAP(4, 0) }, /* INF Plus, Quad, RJ45 */ + { RP_ID(0x0051), RP_CAP(8, 0) }, /* INF Plus, Octa, RJ45 */ + { RP_ID(0x0052), RP_CAP(8, 1) }, /* INF Octa, SMPTE */ + + /* RocketPort EXPRESS cards */ + + { RP_ID(0x0060), RP_CAP(8, 0) }, /* EXP Octa, RJ45, selectable */ + { RP_ID(0x0061), RP_CAP(32, 0) }, /* EXP 32, ext interface */ + { RP_ID(0x0062), RP_CAP(8, 0) }, /* EXP Octa, ext interface */ + { RP_ID(0x0063), RP_CAP(16, 0) }, /* EXP 16, ext interface */ + { RP_ID(0x0064), RP_CAP(4, 0) }, /* EXP Quad, DB, selectable */ + { RP_ID(0x0065), RP_CAP(8, 0) }, /* EXP Octa, DB, selectable */ + { RP_ID(0x0066), RP_CAP(4, 0) }, /* EXP Quad, ext interface */ + { RP_ID(0x0067), RP_CAP(4, 0) }, /* EXP Quad, RJ45 */ + { RP_ID(0x0068), RP_CAP(8, 0) }, /* EXP Octa, RJ11 */ + { RP_ID(0x0072), RP_CAP(8, 1) }, /* EXP Octa, SMPTE */ + { } +}; +MODULE_DEVICE_TABLE(pci, rp2_pci_tbl); + +static struct pci_driver rp2_pci_driver = { + .name = DRV_NAME, + .id_table = rp2_pci_tbl, + .probe = rp2_probe, + .remove = rp2_remove, +}; + +static int __init rp2_uart_init(void) +{ + int rc; + + rc = uart_register_driver(&rp2_uart_driver); + if (rc) + return rc; + + rc = pci_register_driver(&rp2_pci_driver); + if (rc) { + uart_unregister_driver(&rp2_uart_driver); + return rc; + } + + return 0; +} + +static void __exit rp2_uart_exit(void) +{ + pci_unregister_driver(&rp2_pci_driver); + uart_unregister_driver(&rp2_uart_driver); +} + +module_init(rp2_uart_init); +module_exit(rp2_uart_exit); + +MODULE_DESCRIPTION("Comtrol RocketPort EXPRESS/INFINITY driver"); +MODULE_AUTHOR("Kevin Cernekee "); +MODULE_LICENSE("GPL v2"); +MODULE_FIRMWARE(RP2_FW_NAME); diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h index 78f99d97475b..9dd47a569726 100644 --- a/include/uapi/linux/serial_core.h +++ b/include/uapi/linux/serial_core.h @@ -219,4 +219,7 @@ /* ARC (Synopsys) on-chip UART */ #define PORT_ARC 101 +/* Rocketport EXPRESS/INFINITY */ +#define PORT_RP2 102 + #endif /* _UAPILINUX_SERIAL_CORE_H */ -- cgit v1.2.3 From b786337d8c2867962348711e8d1211b292b6e3c5 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Thu, 17 Jan 2013 18:34:45 +0400 Subject: serial: sccnxp: Fix possible crash if no platform data supplied This patch fix possible kernel crash if no platform data supplied. We should not use platform data in this case, instead we will use default values from private driver structure. Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sccnxp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index c864353352c5..c5f0e964ec05 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -891,9 +891,9 @@ static int sccnxp_probe(struct platform_device *pdev) } else memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata)); - if (pdata->poll_time_us) { + if (s->pdata.poll_time_us) { dev_info(&pdev->dev, "Using poll mode, resolution %u usecs\n", - pdata->poll_time_us); + s->pdata.poll_time_us); s->poll = 1; } -- cgit v1.2.3 From ed35e09248c12d246b49b6b3ce9fdcec8a5badb6 Mon Sep 17 00:00:00 2001 From: Haojun Bao Date: Thu, 17 Jan 2013 00:01:51 -0800 Subject: serial: pxa: Do not tweak clock in pxa serial write() function The write() function could be used by printk(), which is atomic and tweaking clock there can cause "BUG: sleeping function called from invalid context". Signed-off-by: Bao Haojun Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/pxa.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c index 3b671bc3f966..a67f9e156ada 100644 --- a/drivers/tty/serial/pxa.c +++ b/drivers/tty/serial/pxa.c @@ -672,7 +672,6 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count) unsigned long flags; int locked = 1; - clk_prepare_enable(up->clk); local_irq_save(flags); if (up->port.sysrq) @@ -701,7 +700,6 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count) spin_unlock(&up->port.lock); local_irq_restore(flags); - clk_disable_unprepare(up->clk); } #ifdef CONFIG_CONSOLE_POLL -- cgit v1.2.3 From 45e786a6baeff2fa6a350bed5b880e2e9381deaf Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 17 Jan 2013 10:45:13 -0200 Subject: serial: imx: Remove unused 'tty' variable Commit 2e124b4a39 (TTY: switch tty_flip_buffer_push) introduced the following build warning: drivers/tty/serial/imx.c:519:21: warning: unused variable 'tty' [-Wunused-variable] Remove the unused 'tty' variable. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index be26345bf6a4..a220f77ceab6 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -516,7 +516,6 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; unsigned int rx, flg, ignored = 0; - struct tty_struct *tty = sport->port.state->port.tty; struct tty_port *port = &sport->port.state->port; unsigned long flags, temp; -- cgit v1.2.3 From 962963e4ee23bc7518dfee754de5f20d35de71d9 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 17 Jan 2013 14:31:45 +0100 Subject: serial: tegra: Switch to using struct tty_port Many of the tty functions were converted to use a struct tty_port instead of a struct tty_struct. Update the Tegra driver accordingly to avoid build breakage. Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial-tegra.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index cc4072f50352..30d6ff6eddb0 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c @@ -504,7 +504,7 @@ static void tegra_uart_handle_tx_pio(struct tegra_uart_port *tup) } static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup, - struct tty_struct *tty) + struct tty_port *tty) { do { char flag = TTY_NORMAL; @@ -527,7 +527,7 @@ static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup, } static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup, - struct tty_struct *tty, int count) + struct tty_port *tty, int count) { int copied; @@ -554,6 +554,7 @@ static void tegra_uart_rx_dma_complete(void *args) struct uart_port *u = &tup->uport; int count = tup->rx_bytes_requested; struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + struct tty_port *port = &u->state->port; unsigned long flags; async_tx_ack(tup->rx_dma_desc); @@ -565,11 +566,11 @@ static void tegra_uart_rx_dma_complete(void *args) /* If we are here, DMA is stopped */ if (count) - tegra_uart_copy_rx_to_tty(tup, tty, count); + tegra_uart_copy_rx_to_tty(tup, port, count); - tegra_uart_handle_rx_pio(tup, tty); + tegra_uart_handle_rx_pio(tup, port); if (tty) { - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); tty_kref_put(tty); } tegra_uart_start_rx_dma(tup); @@ -585,6 +586,7 @@ static void tegra_uart_handle_rx_dma(struct tegra_uart_port *tup) { struct dma_tx_state state; struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + struct tty_port *port = &tup->uport.state->port; int count; /* Deactivate flow control to stop sender */ @@ -597,11 +599,11 @@ static void tegra_uart_handle_rx_dma(struct tegra_uart_port *tup) /* If we are here, DMA is stopped */ if (count) - tegra_uart_copy_rx_to_tty(tup, tty, count); + tegra_uart_copy_rx_to_tty(tup, port, count); - tegra_uart_handle_rx_pio(tup, tty); + tegra_uart_handle_rx_pio(tup, port); if (tty) { - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); tty_kref_put(tty); } tegra_uart_start_rx_dma(tup); @@ -724,6 +726,7 @@ static void tegra_uart_stop_rx(struct uart_port *u) { struct tegra_uart_port *tup = to_tegra_uport(u); struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); + struct tty_port *port = &u->state->port; struct dma_tx_state state; unsigned long ier; int count; @@ -747,13 +750,13 @@ static void tegra_uart_stop_rx(struct uart_port *u) dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state); async_tx_ack(tup->rx_dma_desc); count = tup->rx_bytes_requested - state.residue; - tegra_uart_copy_rx_to_tty(tup, tty, count); - tegra_uart_handle_rx_pio(tup, tty); + tegra_uart_copy_rx_to_tty(tup, port, count); + tegra_uart_handle_rx_pio(tup, port); } else { - tegra_uart_handle_rx_pio(tup, tty); + tegra_uart_handle_rx_pio(tup, port); } if (tty) { - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); tty_kref_put(tty); } return; -- cgit v1.2.3 From 12faa35ae5cbfbd0d90e2103688e87ceb46c5886 Mon Sep 17 00:00:00 2001 From: Tony Prisk Date: Fri, 18 Jan 2013 15:05:31 +1300 Subject: serial: vt8500: UART uses gated clock rather than 24Mhz reference UART modules on Wondermedia SoCs are connected via a gated clock source, rather than directly to the 24Mhz reference clock. While uboot enables UART0 for debugging, other UART ports are unavailable until the clock is enabled. This patch checks that a valid clock is actually passed from devicetree, enables the clock in probe. This change removes the fallback when a clock was not specified as it doesn't apply any longer (and would only work if the UART clock was already enabled). DTSI files are updated for VT8500, WM8505 and WM8650. Signed-off-by: Tony Prisk Signed-off-by: Greg Kroah-Hartman --- arch/arm/boot/dts/vt8500.dtsi | 40 ++++++++++++++++++++++--- arch/arm/boot/dts/wm8505.dtsi | 60 ++++++++++++++++++++++++++++++++++---- arch/arm/boot/dts/wm8650.dtsi | 20 +++++++++++-- drivers/tty/serial/vt8500_serial.c | 34 +++++++++++---------- 4 files changed, 127 insertions(+), 27 deletions(-) (limited to 'drivers') diff --git a/arch/arm/boot/dts/vt8500.dtsi b/arch/arm/boot/dts/vt8500.dtsi index d8645e990b21..cf31ced46602 100644 --- a/arch/arm/boot/dts/vt8500.dtsi +++ b/arch/arm/boot/dts/vt8500.dtsi @@ -45,6 +45,38 @@ compatible = "fixed-clock"; clock-frequency = <24000000>; }; + + clkuart0: uart0 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <1>; + }; + + clkuart1: uart1 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <2>; + }; + + clkuart2: uart2 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <3>; + }; + + clkuart3: uart3 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <4>; + }; }; }; @@ -83,28 +115,28 @@ compatible = "via,vt8500-uart"; reg = <0xd8200000 0x1040>; interrupts = <32>; - clocks = <&ref24>; + clocks = <&clkuart0>; }; uart@d82b0000 { compatible = "via,vt8500-uart"; reg = <0xd82b0000 0x1040>; interrupts = <33>; - clocks = <&ref24>; + clocks = <&clkuart1>; }; uart@d8210000 { compatible = "via,vt8500-uart"; reg = <0xd8210000 0x1040>; interrupts = <47>; - clocks = <&ref24>; + clocks = <&clkuart2>; }; uart@d82c0000 { compatible = "via,vt8500-uart"; reg = <0xd82c0000 0x1040>; interrupts = <50>; - clocks = <&ref24>; + clocks = <&clkuart3>; }; rtc@d8100000 { diff --git a/arch/arm/boot/dts/wm8505.dtsi b/arch/arm/boot/dts/wm8505.dtsi index 330f833ac3b0..e74a1c0fb9a2 100644 --- a/arch/arm/boot/dts/wm8505.dtsi +++ b/arch/arm/boot/dts/wm8505.dtsi @@ -59,6 +59,54 @@ compatible = "fixed-clock"; clock-frequency = <24000000>; }; + + clkuart0: uart0 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <1>; + }; + + clkuart1: uart1 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <2>; + }; + + clkuart2: uart2 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <3>; + }; + + clkuart3: uart3 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <4>; + }; + + clkuart4: uart4 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <22>; + }; + + clkuart5: uart5 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <23>; + }; }; }; @@ -96,42 +144,42 @@ compatible = "via,vt8500-uart"; reg = <0xd8200000 0x1040>; interrupts = <32>; - clocks = <&ref24>; + clocks = <&clkuart0>; }; uart@d82b0000 { compatible = "via,vt8500-uart"; reg = <0xd82b0000 0x1040>; interrupts = <33>; - clocks = <&ref24>; + clocks = <&clkuart1>; }; uart@d8210000 { compatible = "via,vt8500-uart"; reg = <0xd8210000 0x1040>; interrupts = <47>; - clocks = <&ref24>; + clocks = <&clkuart2>; }; uart@d82c0000 { compatible = "via,vt8500-uart"; reg = <0xd82c0000 0x1040>; interrupts = <50>; - clocks = <&ref24>; + clocks = <&clkuart3>; }; uart@d8370000 { compatible = "via,vt8500-uart"; reg = <0xd8370000 0x1040>; interrupts = <31>; - clocks = <&ref24>; + clocks = <&clkuart4>; }; uart@d8380000 { compatible = "via,vt8500-uart"; reg = <0xd8380000 0x1040>; interrupts = <30>; - clocks = <&ref24>; + clocks = <&clkuart5>; }; rtc@d8100000 { diff --git a/arch/arm/boot/dts/wm8650.dtsi b/arch/arm/boot/dts/wm8650.dtsi index 83b9467559bb..db3c0a12e052 100644 --- a/arch/arm/boot/dts/wm8650.dtsi +++ b/arch/arm/boot/dts/wm8650.dtsi @@ -75,6 +75,22 @@ reg = <0x204>; }; + clkuart0: uart0 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <1>; + }; + + clkuart1: uart1 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <&ref24>; + enable-reg = <0x250>; + enable-bit = <2>; + }; + arm: arm { #clock-cells = <0>; compatible = "via,vt8500-device-clock"; @@ -128,14 +144,14 @@ compatible = "via,vt8500-uart"; reg = <0xd8200000 0x1040>; interrupts = <32>; - clocks = <&ref24>; + clocks = <&clkuart0>; }; uart@d82b0000 { compatible = "via,vt8500-uart"; reg = <0xd82b0000 0x1040>; interrupts = <33>; - clocks = <&ref24>; + clocks = <&clkuart1>; }; rtc@d8100000 { diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index ff391db0a220..798bf944a2e5 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -584,6 +584,23 @@ static int vt8500_serial_probe(struct platform_device *pdev) if (!vt8500_port) return -ENOMEM; + vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); + if (!vt8500_port->uart.membase) + return -EADDRNOTAVAIL; + + vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); + if (IS_ERR(vt8500_port->clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = -EINVAL; + goto err; + } + + ret = clk_prepare_enable(vt8500_port->clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err; + } + vt8500_port->uart.type = PORT_VT8500; vt8500_port->uart.iotype = UPIO_MEM; vt8500_port->uart.mapbase = mmres->start; @@ -593,25 +610,11 @@ static int vt8500_serial_probe(struct platform_device *pdev) vt8500_port->uart.line = port; vt8500_port->uart.dev = &pdev->dev; vt8500_port->uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF; - - vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); - if (vt8500_port->clk) { - vt8500_port->uart.uartclk = clk_get_rate(vt8500_port->clk); - } else { - /* use the default of 24Mhz if not specified and warn */ - pr_warn("%s: serial clock source not specified\n", __func__); - vt8500_port->uart.uartclk = 24000000; - } + vt8500_port->uart.uartclk = clk_get_rate(vt8500_port->clk); snprintf(vt8500_port->name, sizeof(vt8500_port->name), "VT8500 UART%d", pdev->id); - vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); - if (!vt8500_port->uart.membase) { - ret = -EADDRNOTAVAIL; - goto err; - } - vt8500_uart_ports[port] = vt8500_port; uart_add_one_port(&vt8500_uart_driver, &vt8500_port->uart); @@ -630,6 +633,7 @@ static int vt8500_serial_remove(struct platform_device *pdev) struct vt8500_port *vt8500_port = platform_get_drvdata(pdev); platform_set_drvdata(pdev, NULL); + clk_disable_unprepare(vt8500_port->clk); uart_remove_one_port(&vt8500_uart_driver, &vt8500_port->uart); kfree(vt8500_port); -- cgit v1.2.3 From 49abd90c4bb7b35e84c430dbba6b6368786fbf62 Mon Sep 17 00:00:00 2001 From: Tony Prisk Date: Fri, 18 Jan 2013 15:05:32 +1300 Subject: serial: vt8500: Cleanup code using devm_ function Convert the last memory allocation (vt8500_port) to use devm_kzalloc and remove the fail path cleanup code from vt8500_serial_probe. Reorder iomem mapping above clk_enable to simplify fail code. The clock is only enabled if all other resources are available. Signed-off-by: Tony Prisk Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/vt8500_serial.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 798bf944a2e5..5fb59c53abf9 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -580,7 +580,8 @@ static int vt8500_serial_probe(struct platform_device *pdev) return -EBUSY; } - vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL); + vt8500_port = devm_kzalloc(&pdev->dev, sizeof(struct vt8500_port), + GFP_KERNEL); if (!vt8500_port) return -ENOMEM; @@ -591,14 +592,13 @@ static int vt8500_serial_probe(struct platform_device *pdev) vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); if (IS_ERR(vt8500_port->clk)) { dev_err(&pdev->dev, "failed to get clock\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } ret = clk_prepare_enable(vt8500_port->clk); if (ret) { dev_err(&pdev->dev, "failed to enable clock\n"); - goto err; + return ret; } vt8500_port->uart.type = PORT_VT8500; @@ -622,10 +622,6 @@ static int vt8500_serial_probe(struct platform_device *pdev) platform_set_drvdata(pdev, vt8500_port); return 0; - -err: - kfree(vt8500_port); - return ret; } static int vt8500_serial_remove(struct platform_device *pdev) @@ -635,7 +631,6 @@ static int vt8500_serial_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); clk_disable_unprepare(vt8500_port->clk); uart_remove_one_port(&vt8500_uart_driver, &vt8500_port->uart); - kfree(vt8500_port); return 0; } -- cgit v1.2.3 From 33aeb9da1b5248c8ffce046be4e992ff5d97d529 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 18 Jan 2013 08:25:51 +0100 Subject: serial: lpc32xx: Fix fallout from tty_port conversion A duplicate definition of the port variable was introduced in the interrupt handler, which causes the build to break. The fix is to rename the variable to tport, which is already properly used in subsequent code. Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/lpc32xx_hs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index c01b58f3729c..dffea6b2cd7d 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -322,7 +322,7 @@ exit_tx: static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_port *port = &port->state->port; + struct tty_port *tport = &port->state->port; u32 status; spin_lock(&port->lock); -- cgit v1.2.3 From a1bf9584429d61b7096f93ae09325e1ba538e9e8 Mon Sep 17 00:00:00 2001 From: Ilya Zykov Date: Wed, 16 Jan 2013 13:07:50 +0400 Subject: tty: Add driver unthrottle in ioctl(...,TCFLSH,..). Regression 'tty: fix "IRQ45: nobody cared"' Regression commit 7b292b4bf9a9d6098440d85616d6ca4c608b8304 Function reset_buffer_flags() also invoked during the ioctl(...,TCFLSH,..). At the time of request we can have full buffers and throttled driver too. If we don't unthrottle driver, we can get forever throttled driver, because, after request, we will have empty buffers and throttled driver and there is no place to unthrottle driver. It simple reproduce with "pty" pair then one side sleep on tty->write_wait, and other side do ioctl(...,TCFLSH,..). Then there is no place to do writers wake up. Signed-off-by: Ilya Zykov Cc: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 8481b29d5b3a..cc0fc52787c7 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -1096,12 +1096,16 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) ld = tty_ldisc_ref_wait(tty); switch (arg) { case TCIFLUSH: - if (ld && ld->ops->flush_buffer) + if (ld && ld->ops->flush_buffer) { ld->ops->flush_buffer(tty); + tty_unthrottle(tty); + } break; case TCIOFLUSH: - if (ld && ld->ops->flush_buffer) + if (ld && ld->ops->flush_buffer) { ld->ops->flush_buffer(tty); + tty_unthrottle(tty); + } /* fall through */ case TCOFLUSH: tty_driver_flush_buffer(tty); -- cgit v1.2.3 From 4f73bc4dd3e8563ef4109f293a092820dff66d92 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 17 Jan 2013 22:44:22 -0800 Subject: tty: Added a CONFIG_TTY option to allow removal of TTY The option allows you to remove TTY and compile without errors. This saves space on systems that won't support TTY interfaces anyway. bloat-o-meter output is below. The bulk of this patch consists of Kconfig changes adding "depends on TTY" to various serial devices and similar drivers that require the TTY layer. Ideally, these dependencies would occur on a common intermediate symbol such as SERIO, but most drivers "select SERIO" rather than "depends on SERIO", and "select" does not respect dependencies. bloat-o-meter output comparing our previous minimal to new minimal by removing TTY. The list is filtered to not show removed entries with awk '$3 != "-"' as the list was very long. add/remove: 0/226 grow/shrink: 2/14 up/down: 6/-35356 (-35350) function old new delta chr_dev_init 166 170 +4 allow_signal 80 82 +2 static.__warned 143 142 -1 disallow_signal 63 62 -1 __set_special_pids 95 94 -1 unregister_console 126 121 -5 start_kernel 546 541 -5 register_console 593 588 -5 copy_from_user 45 40 -5 sys_setsid 128 120 -8 sys_vhangup 32 19 -13 do_exit 1543 1526 -17 bitmap_zero 60 40 -20 arch_local_irq_save 137 117 -20 release_task 674 652 -22 static.spin_unlock_irqrestore 308 260 -48 Signed-off-by: Joe Millenbach Reviewed-by: Jamey Sharp Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- arch/alpha/Kconfig | 2 ++ arch/ia64/hp/sim/Kconfig | 1 + arch/m68k/Kconfig.devices | 2 +- arch/parisc/Kconfig | 1 + arch/tile/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/xtensa/Kconfig | 1 + drivers/bluetooth/Kconfig | 1 + drivers/char/Kconfig | 7 +++--- drivers/char/pcmcia/Kconfig | 4 ++-- drivers/i2c/busses/Kconfig | 2 +- drivers/input/joystick/Kconfig | 4 ++++ drivers/input/keyboard/Kconfig | 10 ++++++++- drivers/input/mouse/Kconfig | 3 +++ drivers/input/serio/Kconfig | 1 + drivers/input/touchscreen/Kconfig | 22 +++++++++++++++++++ drivers/ipack/devices/Kconfig | 2 +- drivers/isdn/Kconfig | 1 + drivers/isdn/capi/Kconfig | 1 + drivers/isdn/gigaset/Kconfig | 1 + drivers/isdn/hardware/mISDN/Kconfig | 1 + drivers/lguest/Kconfig | 2 +- drivers/media/radio/wl128x/Kconfig | 2 +- drivers/misc/Kconfig | 2 +- drivers/misc/ti-st/Kconfig | 2 +- drivers/mmc/card/Kconfig | 1 + drivers/net/caif/Kconfig | 2 +- drivers/net/can/Kconfig | 2 +- drivers/net/hamradio/Kconfig | 4 ++-- drivers/net/irda/Kconfig | 2 +- drivers/net/ppp/Kconfig | 3 +++ drivers/net/slip/Kconfig | 1 + drivers/net/usb/Kconfig | 4 ++-- drivers/net/wan/Kconfig | 2 +- drivers/pps/clients/Kconfig | 2 +- drivers/s390/char/Kconfig | 8 +++---- drivers/staging/ccg/Kconfig | 2 +- drivers/staging/dgrp/Kconfig | 2 +- drivers/staging/fwserial/Kconfig | 2 +- drivers/staging/sb105x/Kconfig | 2 +- drivers/tty/Kconfig | 13 +++++++++++ drivers/tty/Makefile | 2 +- drivers/tty/hvc/Kconfig | 3 +++ drivers/tty/serial/Kconfig | 4 ++++ drivers/usb/class/Kconfig | 2 +- drivers/usb/gadget/Kconfig | 6 +++++ drivers/usb/serial/Kconfig | 2 +- fs/proc/Makefile | 3 ++- include/linux/console.h | 5 +++++ include/linux/proc_fs.h | 5 +++++ include/linux/tty.h | 44 +++++++++++++++++++++++++++---------- lib/Kconfig.kgdb | 1 + net/bluetooth/rfcomm/Kconfig | 1 + net/irda/ircomm/Kconfig | 2 +- sound/soc/codecs/Kconfig | 3 ++- 55 files changed, 165 insertions(+), 47 deletions(-) (limited to 'drivers') diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 9d5904cc7712..1ef196ddadeb 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -125,6 +125,7 @@ choice config ALPHA_GENERIC bool "Generic" + depends on TTY help A generic kernel will run on all supported Alpha hardware. @@ -491,6 +492,7 @@ config VGA_HOSE config ALPHA_SRM bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME + depends on TTY default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL ---help--- There are two different types of booting firmware on Alphas: SRM, diff --git a/arch/ia64/hp/sim/Kconfig b/arch/ia64/hp/sim/Kconfig index 8d513a8c5266..d84707d55203 100644 --- a/arch/ia64/hp/sim/Kconfig +++ b/arch/ia64/hp/sim/Kconfig @@ -8,6 +8,7 @@ config HP_SIMETH config HP_SIMSERIAL bool "Simulated serial driver support" + depends on TTY config HP_SIMSERIAL_CONSOLE bool "Console for HP simulator" diff --git a/arch/m68k/Kconfig.devices b/arch/m68k/Kconfig.devices index c4cdfe444c64..4bc945dfe467 100644 --- a/arch/m68k/Kconfig.devices +++ b/arch/m68k/Kconfig.devices @@ -41,7 +41,7 @@ config NFBLOCK config NFCON tristate "NatFeat console driver" - depends on NATFEAT + depends on TTY && NATFEAT help Say Y to include support for the ARAnyM NatFeat console driver which allows the console output to be redirected to the stderr diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index b77feffbadea..df5beb639760 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -23,6 +23,7 @@ config PARISC select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select CLONE_BACKWARDS + select TTY # Needed for pdc_cons.c help The PA-RISC microprocessor is designed by Hewlett-Packard and used diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 875d008828b8..ae8a7ca67fa4 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -121,6 +121,7 @@ config DEBUG_COPY_FROM_USER def_bool n config HVC_TILE + depends on TTY select HVC_DRIVER def_bool y diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common index 648121b037d5..bceee6623b00 100644 --- a/arch/um/Kconfig.common +++ b/arch/um/Kconfig.common @@ -12,6 +12,7 @@ config UML select GENERIC_CPU_DEVICES select GENERIC_IO select GENERIC_CLOCKEVENTS + select TTY # Needed for line.c config MMU bool diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 5aab1acabf1c..ad64c73b8675 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -132,6 +132,7 @@ choice config XTENSA_PLATFORM_ISS bool "ISS" + depends on TTY select XTENSA_CALIBRATE_CCOUNT select SERIAL_CONSOLE select XTENSA_ISS_NETWORK diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index e9f203eadb1f..fdfd61a2d523 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -26,6 +26,7 @@ config BT_HCIBTSDIO config BT_HCIUART tristate "HCI UART driver" + depends on TTY help Bluetooth HCI UART driver. This driver is required if you want to use Bluetooth devices with diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 72bedad6bf8c..3bb6fa3930be 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -53,7 +53,7 @@ source "drivers/tty/serial/Kconfig" config TTY_PRINTK bool "TTY driver to output user messages via printk" - depends on EXPERT + depends on EXPERT && TTY default n ---help--- If you say Y here, the support for writing user messages (i.e. @@ -159,7 +159,7 @@ source "drivers/tty/hvc/Kconfig" config VIRTIO_CONSOLE tristate "Virtio console" - depends on VIRTIO + depends on VIRTIO && TTY select HVC_DRIVER help Virtio console for use with lguest and other hypervisors. @@ -392,6 +392,7 @@ config XILINX_HWICAP config R3964 tristate "Siemens R3964 line discipline" + depends on TTY ---help--- This driver allows synchronous communication with devices using the Siemens R3964 packet protocol. Unless you are dealing with special @@ -439,7 +440,7 @@ source "drivers/char/pcmcia/Kconfig" config MWAVE tristate "ACP Modem (Mwave) support" - depends on X86 + depends on X86 && TTY select SERIAL_8250 ---help--- The ACP modem (Mwave) for Linux is a WinModem. It is composed of a diff --git a/drivers/char/pcmcia/Kconfig b/drivers/char/pcmcia/Kconfig index 6614416a8623..2a166d56738a 100644 --- a/drivers/char/pcmcia/Kconfig +++ b/drivers/char/pcmcia/Kconfig @@ -7,7 +7,7 @@ menu "PCMCIA character devices" config SYNCLINK_CS tristate "SyncLink PC Card support" - depends on PCMCIA + depends on PCMCIA && TTY help Enable support for the SyncLink PC Card serial adapter, running asynchronous and HDLC communications up to 512Kbps. The port is @@ -45,7 +45,7 @@ config CARDMAN_4040 config IPWIRELESS tristate "IPWireless 3G UMTS PCMCIA card support" - depends on PCMCIA && NETDEVICES + depends on PCMCIA && NETDEVICES && TTY select PPP help This is a driver for 3G UMTS PCMCIA card from IPWireless company. In diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index bdca5111eb9d..cf474b2df4ae 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -803,7 +803,7 @@ config I2C_PARPORT_LIGHT config I2C_TAOS_EVM tristate "TAOS evaluation module" - depends on EXPERIMENTAL + depends on EXPERIMENTAL && TTY select SERIO select SERIO_SERPORT default n diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig index 56eb471b5576..055bcaba774c 100644 --- a/drivers/input/joystick/Kconfig +++ b/drivers/input/joystick/Kconfig @@ -132,6 +132,8 @@ config JOYSTICK_TMDC source "drivers/input/joystick/iforce/Kconfig" +if TTY + config JOYSTICK_WARRIOR tristate "Logitech WingMan Warrior joystick" select SERIO @@ -205,6 +207,8 @@ config JOYSTICK_ZHENHUA To compile this driver as a module, choose M here: the module will be called zhenhua. +endif # TTY + config JOYSTICK_DB9 tristate "Multisystem, Sega Genesis, Saturn joysticks and gamepads" depends on PARPORT diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 5a240c60342d..008f96aaf19e 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -69,6 +69,7 @@ config KEYBOARD_ATARI config KEYBOARD_ATKBD tristate "AT keyboard" if EXPERT || !X86 default y + depends on TTY select SERIO select SERIO_LIBPS2 select SERIO_I8042 if X86 @@ -153,6 +154,7 @@ config KEYBOARD_BFIN config KEYBOARD_LKKBD tristate "DECstation/VAXstation LK201/LK401 keyboard" + depends on TTY select SERIO help Say Y here if you want to use a LK201 or LK401 style serial @@ -268,7 +270,7 @@ config KEYBOARD_HIL_OLD config KEYBOARD_HIL tristate "HP HIL keyboard/pointer support" - depends on GSC || HP300 + depends on (GSC || HP300) && TTY default y select HP_SDC select HIL_MLC @@ -400,6 +402,7 @@ config KEYBOARD_IMX config KEYBOARD_NEWTON tristate "Newton keyboard" + depends on TTY select SERIO help Say Y here if you have a Newton keyboard on a serial port. @@ -479,6 +482,8 @@ config KEYBOARD_SAMSUNG To compile this driver as a module, choose M here: the module will be called samsung-keypad. +if TTY + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIO @@ -501,6 +506,8 @@ config KEYBOARD_SUNKBD To compile this driver as a module, choose M here: the module will be called sunkbd. +endif # TTY + config KEYBOARD_SH_KEYSC tristate "SuperH KEYSC keypad support" depends on SUPERH || ARCH_SHMOBILE @@ -597,6 +604,7 @@ config KEYBOARD_TWL4030 config KEYBOARD_XTKBD tristate "XT keyboard" + depends on TTY select SERIO help Say Y here if you want to use the old IBM PC/XT keyboard (or diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index cd6268cf7cd5..fc160f72dc4e 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig @@ -14,6 +14,7 @@ if INPUT_MOUSE config MOUSE_PS2 tristate "PS/2 mouse" + depends on TTY default y select SERIO select SERIO_LIBPS2 @@ -138,6 +139,7 @@ config MOUSE_PS2_OLPC config MOUSE_SERIAL tristate "Serial mouse" + depends on TTY select SERIO help Say Y here if you have a serial (RS-232, COM port) mouse connected @@ -262,6 +264,7 @@ config MOUSE_RISCPC config MOUSE_VSXXXAA tristate "DEC VSXXX-AA/GA mouse and VSXXX-AB tablet" + depends on TTY select SERIO help Say Y (or M) if you want to use a DEC VSXXX-AA (hockey diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index 4a4e182c33e7..81ee7551148e 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig @@ -4,6 +4,7 @@ config SERIO tristate "Serial I/O support" if EXPERT || !X86 default y + depends on TTY help Say Yes here if you have any input device that uses serial I/O to communicate with the system. This includes the diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 515cfe790543..3d6f548dd3d4 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -192,6 +192,8 @@ config TOUCHSCREEN_DA9052 To compile this driver as a module, choose M here: the module will be called da9052_tsi. +if TTY + config TOUCHSCREEN_DYNAPRO tristate "Dynapro serial touchscreen" select SERIO @@ -216,6 +218,8 @@ config TOUCHSCREEN_HAMPSHIRE To compile this driver as a module, choose M here: the module will be called hampshire. +endif # TTY + config TOUCHSCREEN_EETI tristate "EETI touchscreen panel support" depends on I2C @@ -237,6 +241,7 @@ config TOUCHSCREEN_EGALAX config TOUCHSCREEN_FUJITSU tristate "Fujitsu serial touchscreen" + depends on TTY select SERIO help Say Y here if you have the Fujitsu touchscreen (such as one @@ -275,6 +280,8 @@ config TOUCHSCREEN_S3C2410 To compile this driver as a module, choose M here: the module will be called s3c2410_ts. +if TTY + config TOUCHSCREEN_GUNZE tristate "Gunze AHL-51S touchscreen" select SERIO @@ -311,6 +318,8 @@ config TOUCHSCREEN_WACOM_W8001 To compile this driver as a module, choose M here: the module will be called wacom_w8001. +endif # TTY + config TOUCHSCREEN_WACOM_I2C tristate "Wacom Tablet support (I2C)" depends on I2C @@ -369,6 +378,8 @@ config TOUCHSCREEN_MMS114 To compile this driver as a module, choose M here: the module will be called mms114. +if TTY + config TOUCHSCREEN_MTOUCH tristate "MicroTouch serial touchscreens" select SERIO @@ -393,6 +404,8 @@ config TOUCHSCREEN_INEXIO To compile this driver as a module, choose M here: the module will be called inexio. +endif # TTY + config TOUCHSCREEN_INTEL_MID tristate "Intel MID platform resistive touchscreen" depends on INTEL_SCU_IPC @@ -450,6 +463,7 @@ config TOUCHSCREEN_HTCPEN config TOUCHSCREEN_PENMOUNT tristate "Penmount serial touchscreen" + depends on TTY select SERIO help Say Y here if you have a Penmount serial touchscreen connected to @@ -493,6 +507,8 @@ config TOUCHSCREEN_TNETV107X To compile this driver as a module, choose M here: the module will be called tnetv107x-ts. +if TTY + config TOUCHSCREEN_TOUCHRIGHT tristate "Touchright serial touchscreen" select SERIO @@ -517,6 +533,8 @@ config TOUCHSCREEN_TOUCHWIN To compile this driver as a module, choose M here: the module will be called touchwin. +endif # TTY + config TOUCHSCREEN_TI_AM335X_TSC tristate "TI Touchscreen Interface" depends on MFD_TI_AM335X_TSCADC @@ -790,6 +808,8 @@ config TOUCHSCREEN_USB_EASYTOUCH Say Y here if you have an EasyTouch USB Touch controller. If unsure, say N. +if TTY + config TOUCHSCREEN_TOUCHIT213 tristate "Sahara TouchIT-213 touchscreen" select SERIO @@ -813,6 +833,8 @@ config TOUCHSCREEN_TSC_SERIO To compile this driver as a module, choose M here: the module will be called tsc40. +endif # TTY + config TOUCHSCREEN_TSC2005 tristate "TSC2005 based touchscreens" depends on SPI_MASTER && GENERIC_HARDIRQS diff --git a/drivers/ipack/devices/Kconfig b/drivers/ipack/devices/Kconfig index 0b82fdc198c0..907a8cb48f2a 100644 --- a/drivers/ipack/devices/Kconfig +++ b/drivers/ipack/devices/Kconfig @@ -1,6 +1,6 @@ config SERIAL_IPOCTAL tristate "IndustryPack IP-OCTAL uart support" - depends on IPACK_BUS + depends on IPACK_BUS && TTY help This driver supports the IPOCTAL serial port device for the IndustryPack bus. default n diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig index 86cd75a0e84d..ef661acdda17 100644 --- a/drivers/isdn/Kconfig +++ b/drivers/isdn/Kconfig @@ -22,6 +22,7 @@ if ISDN menuconfig ISDN_I4L tristate "Old ISDN4Linux (deprecated)" + depends on TTY ---help--- This driver allows you to use an ISDN adapter for networking connections and as dialin/out device. The isdn-tty's have a built diff --git a/drivers/isdn/capi/Kconfig b/drivers/isdn/capi/Kconfig index 15c3ffd9d860..f04686580040 100644 --- a/drivers/isdn/capi/Kconfig +++ b/drivers/isdn/capi/Kconfig @@ -18,6 +18,7 @@ config CAPI_TRACE config ISDN_CAPI_MIDDLEWARE bool "CAPI2.0 Middleware support" + depends on TTY help This option will enhance the capabilities of the /dev/capi20 interface. It will provide a means of moving a data connection, diff --git a/drivers/isdn/gigaset/Kconfig b/drivers/isdn/gigaset/Kconfig index b18a92c32184..dde5e09e6267 100644 --- a/drivers/isdn/gigaset/Kconfig +++ b/drivers/isdn/gigaset/Kconfig @@ -1,5 +1,6 @@ menuconfig ISDN_DRV_GIGASET tristate "Siemens Gigaset support" + depends on TTY select CRC_CCITT select BITREVERSE help diff --git a/drivers/isdn/hardware/mISDN/Kconfig b/drivers/isdn/hardware/mISDN/Kconfig index eadc1cd34a20..b8611e3e5e74 100644 --- a/drivers/isdn/hardware/mISDN/Kconfig +++ b/drivers/isdn/hardware/mISDN/Kconfig @@ -76,6 +76,7 @@ config MISDN_NETJET tristate "Support for NETJet cards" depends on MISDN depends on PCI + depends on TTY select MISDN_IPAC select ISDN_HDLC select ISDN_I4L diff --git a/drivers/lguest/Kconfig b/drivers/lguest/Kconfig index 34ae49dc557c..f9c43145a611 100644 --- a/drivers/lguest/Kconfig +++ b/drivers/lguest/Kconfig @@ -1,6 +1,6 @@ config LGUEST tristate "Linux hypervisor example code" - depends on X86_32 && EXPERIMENTAL && EVENTFD + depends on X86_32 && EXPERIMENTAL && EVENTFD && TTY select HVC_DRIVER ---help--- This is a very simple module which allows you to run diff --git a/drivers/media/radio/wl128x/Kconfig b/drivers/media/radio/wl128x/Kconfig index ea1e6545df36..f359be7e9dd9 100644 --- a/drivers/media/radio/wl128x/Kconfig +++ b/drivers/media/radio/wl128x/Kconfig @@ -4,7 +4,7 @@ menu "Texas Instruments WL128x FM driver (ST based)" config RADIO_WL128X tristate "Texas Instruments WL128x FM Radio" - depends on VIDEO_V4L2 && RFKILL && GPIOLIB + depends on VIDEO_V4L2 && RFKILL && GPIOLIB && TTY select TI_ST if NET help Choose Y here if you have this FM radio chip. diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index b151b7c1bd59..4b2bb939dde1 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -127,7 +127,7 @@ config PHANTOM config INTEL_MID_PTI tristate "Parallel Trace Interface for MIPI P1149.7 cJTAG standard" - depends on PCI + depends on PCI && TTY default n help The PTI (Parallel Trace Interface) driver directs diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig index abb5de1afce3..f34dcc514730 100644 --- a/drivers/misc/ti-st/Kconfig +++ b/drivers/misc/ti-st/Kconfig @@ -5,7 +5,7 @@ menu "Texas Instruments shared transport line discipline" config TI_ST tristate "Shared transport core driver" - depends on NET && GPIOLIB + depends on NET && GPIOLIB && TTY select FW_LOADER help This enables the shared transport core driver for TI diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig index 3b1f783bf924..5562308699bc 100644 --- a/drivers/mmc/card/Kconfig +++ b/drivers/mmc/card/Kconfig @@ -52,6 +52,7 @@ config MMC_BLOCK_BOUNCE config SDIO_UART tristate "SDIO UART/GPS class support" + depends on TTY help SDIO function driver for SDIO cards that implements the UART class, as well as the GPS class which appears like a UART. diff --git a/drivers/net/caif/Kconfig b/drivers/net/caif/Kconfig index abf4d7a9dcce..60c2142373c9 100644 --- a/drivers/net/caif/Kconfig +++ b/drivers/net/caif/Kconfig @@ -6,7 +6,7 @@ comment "CAIF transport drivers" config CAIF_TTY tristate "CAIF TTY transport driver" - depends on CAIF + depends on CAIF && TTY default n ---help--- The CAIF TTY transport driver is a Line Discipline (ldisc) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index b56bd9e80957..72df3a306a08 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -13,7 +13,7 @@ config CAN_VCAN config CAN_SLCAN tristate "Serial / USB serial CAN Adaptors (slcan)" - depends on CAN + depends on CAN && TTY ---help--- CAN driver for several 'low cost' CAN interfaces that are attached via serial lines or via USB-to-serial adapters using the LAWICEL diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig index 95dbcfdf131d..bf5e59687680 100644 --- a/drivers/net/hamradio/Kconfig +++ b/drivers/net/hamradio/Kconfig @@ -1,6 +1,6 @@ config MKISS tristate "Serial port KISS driver" - depends on AX25 + depends on AX25 && TTY select CRC16 ---help--- KISS is a protocol used for the exchange of data between a computer @@ -18,7 +18,7 @@ config MKISS config 6PACK tristate "Serial port 6PACK driver" - depends on AX25 + depends on AX25 && TTY ---help--- 6pack is a transmission protocol for the data exchange between your PC and your TNC (the Terminal Node Controller acts as a kind of diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig index 595205406d73..e1454cdec14b 100644 --- a/drivers/net/irda/Kconfig +++ b/drivers/net/irda/Kconfig @@ -5,7 +5,7 @@ comment "SIR device drivers" config IRTTY_SIR tristate "IrTTY (uses Linux serial driver)" - depends on IRDA + depends on IRDA && TTY help Say Y here if you want to build support for the IrTTY line discipline. To compile it as a module, choose M here: the module diff --git a/drivers/net/ppp/Kconfig b/drivers/net/ppp/Kconfig index 872df3ef07a6..3d9ef4f1e600 100644 --- a/drivers/net/ppp/Kconfig +++ b/drivers/net/ppp/Kconfig @@ -147,6 +147,7 @@ config PPPOL2TP Support for PPP-over-L2TP socket family. L2TP is a protocol used by ISPs and enterprises to tunnel PPP traffic over UDP tunnels. L2TP is replacing PPTP for VPN uses. +if TTY config PPP_ASYNC tristate "PPP support for async serial ports" @@ -172,4 +173,6 @@ config PPP_SYNC_TTY To compile this driver as a module, choose M here. +endif # TTY + endif # PPP diff --git a/drivers/net/slip/Kconfig b/drivers/net/slip/Kconfig index 211b160e4e9c..48e68714eef3 100644 --- a/drivers/net/slip/Kconfig +++ b/drivers/net/slip/Kconfig @@ -4,6 +4,7 @@ config SLIP tristate "SLIP (serial line) support" + depends on TTY ---help--- Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to connect to your Internet service provider or to connect to some diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index ef976215b649..bd33153261ce 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -445,7 +445,7 @@ config USB_NET_QMI_WWAN config USB_HSO tristate "Option USB High Speed Mobile Devices" - depends on USB && RFKILL + depends on USB && RFKILL && TTY default n help Choose this option if you have an Option HSDPA/HSUPA card. @@ -493,7 +493,7 @@ config USB_SIERRA_NET config USB_VL600 tristate "LG VL600 modem dongle" - depends on USB_NET_CDCETHER + depends on USB_NET_CDCETHER && TTY select USB_ACM help Select this if you want to use an LG Electronics 4G/LTE usb modem diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index d58431e99f73..61eb8994b34f 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig @@ -429,7 +429,7 @@ config LAPBETHER config X25_ASY tristate "X.25 async driver (EXPERIMENTAL)" - depends on LAPB && X25 + depends on LAPB && X25 && TTY ---help--- Send and receive X.25 frames over regular asynchronous serial lines such as telephone lines equipped with ordinary modems. diff --git a/drivers/pps/clients/Kconfig b/drivers/pps/clients/Kconfig index 445197d4a8c4..6efd9b60d8ff 100644 --- a/drivers/pps/clients/Kconfig +++ b/drivers/pps/clients/Kconfig @@ -17,7 +17,7 @@ config PPS_CLIENT_KTIMER config PPS_CLIENT_LDISC tristate "PPS line discipline" - depends on PPS + depends on PPS && TTY help If you say yes here you get support for a PPS source connected with the CD (Carrier Detect) pin of your serial port. diff --git a/drivers/s390/char/Kconfig b/drivers/s390/char/Kconfig index 2c9a776bd63c..71bf959732fe 100644 --- a/drivers/s390/char/Kconfig +++ b/drivers/s390/char/Kconfig @@ -11,7 +11,7 @@ config TN3270 config TN3270_TTY def_tristate y prompt "Support for tty input/output on 3270 terminals" - depends on TN3270 + depends on TN3270 && TTY help Include support for using an IBM 3270 terminal as a Linux tty. @@ -33,7 +33,7 @@ config TN3270_CONSOLE config TN3215 def_bool y prompt "Support for 3215 line mode terminal" - depends on CCW + depends on CCW && TTY help Include support for IBM 3215 line-mode terminals. @@ -51,7 +51,7 @@ config CCW_CONSOLE config SCLP_TTY def_bool y prompt "Support for SCLP line mode terminal" - depends on S390 + depends on S390 && TTY help Include support for IBM SCLP line-mode terminals. @@ -66,7 +66,7 @@ config SCLP_CONSOLE config SCLP_VT220_TTY def_bool y prompt "Support for SCLP VT220-compatible terminal" - depends on S390 + depends on S390 && TTY help Include support for an IBM SCLP VT220-compatible terminal. diff --git a/drivers/staging/ccg/Kconfig b/drivers/staging/ccg/Kconfig index 8997a8c757aa..7ed5bc6caadb 100644 --- a/drivers/staging/ccg/Kconfig +++ b/drivers/staging/ccg/Kconfig @@ -2,7 +2,7 @@ if USB_GADGET config USB_G_CCG tristate "Configurable Composite Gadget (STAGING)" - depends on STAGING && BLOCK && NET && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM + depends on STAGING && BLOCK && NET && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM && TTY help The Configurable Composite Gadget supports multiple USB functions: acm, mass storage, rndis and FunctionFS. diff --git a/drivers/staging/dgrp/Kconfig b/drivers/staging/dgrp/Kconfig index 39f4bb65ec83..e4c41552923a 100644 --- a/drivers/staging/dgrp/Kconfig +++ b/drivers/staging/dgrp/Kconfig @@ -1,7 +1,7 @@ config DGRP tristate "Digi Realport driver" default n - depends on SYSFS + depends on SYSFS && TTY ---help--- Support for Digi Realport devices. These devices allow you to access remote serial ports as if they are local tty devices. This diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig index 580406cb1808..9cdb3cdc4b66 100644 --- a/drivers/staging/fwserial/Kconfig +++ b/drivers/staging/fwserial/Kconfig @@ -1,6 +1,6 @@ config FIREWIRE_SERIAL tristate "TTY over Firewire" - depends on FIREWIRE + depends on FIREWIRE && TTY help This enables TTY over IEEE 1394, providing high-speed serial connectivity to cabled peers. diff --git a/drivers/staging/sb105x/Kconfig b/drivers/staging/sb105x/Kconfig index 3d0d0eb95b8c..6a2e1b78e844 100644 --- a/drivers/staging/sb105x/Kconfig +++ b/drivers/staging/sb105x/Kconfig @@ -1,7 +1,7 @@ config SB105X tristate "SystemBase PCI Multiport UART" select SERIAL_CORE - depends on PCI && BROKEN + depends on PCI && TTY && BROKEN help A driver for the SystemBase Multi-2/PCI serial card diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 0ecf22b6a38e..a79fd8ebd56e 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -1,3 +1,14 @@ +config TTY + bool "Enable TTY" if EXPERT + default y + ---help--- + Allows you to remove TTY support which can save space, and + blocks features that require TTY from inclusion in the kernel. + TTY is required for any text terminals or serial port + communication. Most users should leave this enabled. + +if TTY + config VT bool "Virtual terminal" if EXPERT depends on !S390 && !UML @@ -388,3 +399,5 @@ config PPC_EARLY_DEBUG_EHV_BC_HANDLE If the number you specify is not a valid byte channel handle, then there simply will be no early console output. This is true also if you don't boot under a hypervisor at all. + +endif # TTY diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index 2953059530e4..df5663d0d55e 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -1,4 +1,4 @@ -obj-y += tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o \ +obj-$(CONFIG_TTY) += tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o \ tty_buffer.o tty_port.o tty_mutex.o obj-$(CONFIG_LEGACY_PTYS) += pty.o obj-$(CONFIG_UNIX98_PTYS) += pty.o diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig index f47b734c6a7a..8902f9b4df71 100644 --- a/drivers/tty/hvc/Kconfig +++ b/drivers/tty/hvc/Kconfig @@ -1,3 +1,5 @@ +if TTY + config HVC_DRIVER bool help @@ -119,3 +121,4 @@ config HVCS which will also be compiled when this driver is built as a module. +endif # TTY diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2dc429357fe3..e9aeccdfbe35 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -2,6 +2,8 @@ # Serial device configuration # +if TTY + menu "Serial drivers" depends on HAS_IOMEM @@ -1483,3 +1485,5 @@ config SERIAL_RP2_NR_UARTS need to be increased. endmenu + +endif # TTY diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig index 2519e320098f..316aac8e4ca1 100644 --- a/drivers/usb/class/Kconfig +++ b/drivers/usb/class/Kconfig @@ -6,7 +6,7 @@ comment "USB Device Class drivers" config USB_ACM tristate "USB Modem (CDC ACM) support" - depends on USB + depends on USB && TTY ---help--- This driver supports USB modems and ISDN adapters which support the Communication Device Class Abstract Control Model interface. diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 14625fd2cecd..a1bd951f9cb7 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -750,6 +750,7 @@ config USB_GADGET_TARGET config USB_G_SERIAL tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" + depends on TTY select USB_LIBCOMPOSITE help The Serial Gadget talks to the Linux-USB generic serial driver. @@ -799,6 +800,8 @@ config USB_G_PRINTER For more information, see Documentation/usb/gadget_printer.txt which includes sample code for accessing the device file. +if TTY + config USB_CDC_COMPOSITE tristate "CDC Composite Device (Ethernet and ACM)" depends on NET @@ -879,6 +882,8 @@ config USB_G_MULTI_CDC If unsure, say "y". +endif # TTY + config USB_G_HID tristate "HID Gadget" select USB_LIBCOMPOSITE @@ -895,6 +900,7 @@ config USB_G_HID # Standalone / single function gadgets config USB_G_DBGP tristate "EHCI Debug Device Gadget" + depends on TTY select USB_LIBCOMPOSITE help This gadget emulates an EHCI Debug device. This is useful when you want diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 76f462241738..d8e35fe30b0c 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -4,7 +4,7 @@ menuconfig USB_SERIAL tristate "USB Serial Converter support" - depends on USB + depends on USB && TTY ---help--- Say Y here if you have a USB device that provides normal serial ports, or acts like a serial device, and you want to connect it to diff --git a/fs/proc/Makefile b/fs/proc/Makefile index 981b05601931..712f24db9600 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile @@ -8,7 +8,8 @@ proc-y := nommu.o task_nommu.o proc-$(CONFIG_MMU) := mmu.o task_mmu.o proc-y += inode.o root.o base.o generic.o array.o \ - proc_tty.o fd.o + fd.o +proc-$(CONFIG_TTY) += proc_tty.o proc-y += cmdline.o proc-y += consoles.o proc-y += cpuinfo.o diff --git a/include/linux/console.h b/include/linux/console.h index dedb082fe50f..3b709da1786e 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -157,7 +157,12 @@ extern int is_console_locked(void); extern int braille_register_console(struct console *, int index, char *console_options, char *braille_options); extern int braille_unregister_console(struct console *); +#ifdef CONFIG_TTY extern void console_sysfs_notify(void); +#else +static inline void console_sysfs_notify(void) +{ } +#endif extern bool console_suspend_enabled; /* Suspend and resume console messages over PM events */ diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 32676b35d2f5..3c22538aab66 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -127,7 +127,12 @@ extern void pid_ns_release_proc(struct pid_namespace *ns); * proc_tty.c */ struct tty_driver; +#ifdef CONFIG_TTY extern void proc_tty_init(void); +#else +static inline void proc_tty_init(void) +{ } +#endif extern void proc_tty_register_driver(struct tty_driver *driver); extern void proc_tty_unregister_driver(struct tty_driver *driver); diff --git a/include/linux/tty.h b/include/linux/tty.h index f89acd1ed6d3..c75d886b0307 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -318,11 +318,43 @@ struct tty_file_private { #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) +#ifdef CONFIG_TTY +extern void console_init(void); +extern void tty_kref_put(struct tty_struct *tty); +extern struct pid *tty_get_pgrp(struct tty_struct *tty); +extern void tty_vhangup_self(void); +extern void disassociate_ctty(int priv); +extern dev_t tty_devnum(struct tty_struct *tty); +extern void proc_clear_tty(struct task_struct *p); +extern struct tty_struct *get_current_tty(void); +/* tty_io.c */ +extern int __init tty_init(void); +#else +static inline void console_init(void) +{ } +static inline void tty_kref_put(struct tty_struct *tty) +{ } +static inline struct pid *tty_get_pgrp(struct tty_struct *tty) +{ return NULL; } +static inline void tty_vhangup_self(void) +{ } +static inline void disassociate_ctty(int priv) +{ } +static inline dev_t tty_devnum(struct tty_struct *tty) +{ return 0; } +static inline void proc_clear_tty(struct task_struct *p) +{ } +static inline struct tty_struct *get_current_tty(void) +{ return NULL; } +/* tty_io.c */ +static inline int __init tty_init(void) +{ return 0; } +#endif + extern void tty_write_flush(struct tty_struct *); extern struct ktermios tty_std_termios; -extern void console_init(void); extern int vcs_init(void); extern struct class *tty_class; @@ -342,7 +374,6 @@ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty) kref_get(&tty->kref); return tty; } -extern void tty_kref_put(struct tty_struct *tty); extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, const char *routine); @@ -374,18 +405,15 @@ extern void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty); extern void tty_free_termios(struct tty_struct *tty); extern int is_current_pgrp_orphaned(void); -extern struct pid *tty_get_pgrp(struct tty_struct *tty); extern int is_ignored(int sig); extern int tty_signal(int sig, struct tty_struct *tty); extern void tty_hangup(struct tty_struct *tty); extern void tty_vhangup(struct tty_struct *tty); extern void tty_vhangup_locked(struct tty_struct *tty); -extern void tty_vhangup_self(void); extern void tty_unhangup(struct file *filp); extern int tty_hung_up_p(struct file *filp); extern void do_SAK(struct tty_struct *tty); extern void __do_SAK(struct tty_struct *tty); -extern void disassociate_ctty(int priv); extern void no_tty(void); extern void tty_flush_to_ldisc(struct tty_struct *tty); extern void tty_buffer_free_all(struct tty_port *port); @@ -415,9 +443,6 @@ extern long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg); extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); -extern dev_t tty_devnum(struct tty_struct *tty); -extern void proc_clear_tty(struct task_struct *p); -extern struct tty_struct *get_current_tty(void); extern void tty_default_fops(struct file_operations *fops); extern struct tty_struct *alloc_tty_struct(void); extern int tty_alloc_file(struct file *file); @@ -543,9 +568,6 @@ static inline int tty_audit_push_task(struct task_struct *tsk, } #endif -/* tty_io.c */ -extern int __init tty_init(void); - /* tty_ioctl.c */ extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb index 43cb93fa2651..30894fab84d6 100644 --- a/lib/Kconfig.kgdb +++ b/lib/Kconfig.kgdb @@ -22,6 +22,7 @@ config KGDB_SERIAL_CONSOLE tristate "KGDB: use kgdb over the serial console" select CONSOLE_POLL select MAGIC_SYSRQ + depends on TTY default y help Share a serial console with kgdb. Sysrq-g must be used diff --git a/net/bluetooth/rfcomm/Kconfig b/net/bluetooth/rfcomm/Kconfig index 22e718b554e4..18d352ea2bc7 100644 --- a/net/bluetooth/rfcomm/Kconfig +++ b/net/bluetooth/rfcomm/Kconfig @@ -12,6 +12,7 @@ config BT_RFCOMM config BT_RFCOMM_TTY bool "RFCOMM TTY support" depends on BT_RFCOMM + depends on TTY help This option enables TTY emulation support for RFCOMM channels. diff --git a/net/irda/ircomm/Kconfig b/net/irda/ircomm/Kconfig index 2d4c6b4a78d6..19492c1707b7 100644 --- a/net/irda/ircomm/Kconfig +++ b/net/irda/ircomm/Kconfig @@ -1,6 +1,6 @@ config IRCOMM tristate "IrCOMM protocol" - depends on IRDA + depends on IRDA && TTY help Say Y here if you want to build support for the IrCOMM protocol. To compile it as modules, choose M here: the modules will be diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 3a847828932a..298822c0ad65 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -34,7 +34,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_CS42L73 if I2C select SND_SOC_CS4270 if I2C select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI - select SND_SOC_CX20442 + select SND_SOC_CX20442 if TTY select SND_SOC_DA7210 if I2C select SND_SOC_DA732X if I2C select SND_SOC_DA9055 if I2C @@ -236,6 +236,7 @@ config SND_SOC_CS4271 config SND_SOC_CX20442 tristate + depends on TTY config SND_SOC_JZ4740_CODEC select REGMAP_MMIO -- cgit v1.2.3 From f8a2b220afef7699f7a90d97dbc2d8830979874e Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sun, 20 Jan 2013 17:36:02 +0800 Subject: drivers/tty/serial/8250: use strlcpy instead of strcpy The fields must be null-terminated, or next printk for %s, will cause issue. Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_early.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index f53a7db4350d..721904f8efa9 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -194,7 +194,7 @@ static int __init parse_options(struct early_serial8250_device *device, options++; device->baud = simple_strtoul(options, NULL, 0); length = min(strcspn(options, " "), sizeof(device->options)); - strncpy(device->options, options, length); + strlcpy(device->options, options, length); } else { device->baud = probe_baud(port); snprintf(device->options, sizeof(device->options), "%u", -- cgit v1.2.3 From 64325a3be08d364a62ee8f84b2cf86934bc2544a Mon Sep 17 00:00:00 2001 From: Ilya Zykov Date: Sat, 19 Jan 2013 18:16:20 +0400 Subject: tty: Correct tty buffer flush. The root of problem is carelessly zeroing pointer(in function __tty_buffer_flush()), when another thread can use it. It can be cause of "NULL pointer dereference". Main idea of the patch, this is never free last (struct tty_buffer) in the active buffer. Only flush the data for ldisc(buf->head->read = buf->head->commit). At that moment driver can collect(write) data in buffer without conflict. It is repeat behavior of flush_to_ldisc(), only without feeding data to ldisc. Also revert: commit c56a00a165712fd73081f40044b1e64407bb1875 tty: hold lock across tty buffer finding and buffer filling In order to delete the unneeded locks any more. Signed-off-by: Ilya Zykov CC: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_buffer.c | 92 ++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 70 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index d6969f6e4c43..61ec4ddf47e0 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -119,11 +119,14 @@ static void __tty_buffer_flush(struct tty_port *port) struct tty_bufhead *buf = &port->buf; struct tty_buffer *thead; - while ((thead = buf->head) != NULL) { - buf->head = thead->next; - tty_buffer_free(port, thead); + if (unlikely(buf->head == NULL)) + return; + while ((thead = buf->head->next) != NULL) { + tty_buffer_free(port, buf->head); + buf->head = thead; } - buf->tail = NULL; + WARN_ON(buf->head != buf->tail); + buf->head->read = buf->head->commit; } /** @@ -194,19 +197,22 @@ static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size) have queued and recycle that ? */ } /** - * __tty_buffer_request_room - grow tty buffer if needed + * tty_buffer_request_room - grow tty buffer if needed * @tty: tty structure * @size: size desired * * Make at least size bytes of linear space available for the tty * buffer. If we fail return the size we managed to find. - * Locking: Caller must hold port->buf.lock + * + * Locking: Takes port->buf.lock */ -static int __tty_buffer_request_room(struct tty_port *port, size_t size) +int tty_buffer_request_room(struct tty_port *port, size_t size) { struct tty_bufhead *buf = &port->buf; struct tty_buffer *b, *n; int left; + unsigned long flags; + spin_lock_irqsave(&buf->lock, flags); /* OPTIMISATION: We could keep a per tty "zero" sized buffer to remove this conditional if its worth it. This would be invisible to the callers */ @@ -228,31 +234,9 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size) } else size = left; } - + spin_unlock_irqrestore(&buf->lock, flags); return size; } - - -/** - * tty_buffer_request_room - grow tty buffer if needed - * @port: tty port structure - * @size: size desired - * - * Make at least size bytes of linear space available for the tty - * buffer. If we fail return the size we managed to find. - * - * Locking: Takes port->buf.lock - */ -int tty_buffer_request_room(struct tty_port *port, size_t size) -{ - unsigned long flags; - int length; - - spin_lock_irqsave(&port->buf.lock, flags); - length = __tty_buffer_request_room(port, size); - spin_unlock_irqrestore(&port->buf.lock, flags); - return length; -} EXPORT_SYMBOL_GPL(tty_buffer_request_room); /** @@ -271,26 +255,18 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); int tty_insert_flip_string_fixed_flag(struct tty_port *port, const unsigned char *chars, char flag, size_t size) { - struct tty_bufhead *buf = &port->buf; int copied = 0; do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); - int space; - unsigned long flags; - struct tty_buffer *tb; - - spin_lock_irqsave(&buf->lock, flags); - space = __tty_buffer_request_room(port, goal); - tb = buf->tail; + int space = tty_buffer_request_room(port, goal); + struct tty_buffer *tb = port->buf.tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) { - spin_unlock_irqrestore(&buf->lock, flags); break; } memcpy(tb->char_buf_ptr + tb->used, chars, space); memset(tb->flag_buf_ptr + tb->used, flag, space); tb->used += space; - spin_unlock_irqrestore(&buf->lock, flags); copied += space; chars += space; /* There is a small chance that we need to split the data over @@ -317,26 +293,18 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); int tty_insert_flip_string_flags(struct tty_port *port, const unsigned char *chars, const char *flags, size_t size) { - struct tty_bufhead *buf = &port->buf; int copied = 0; do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); - int space; - unsigned long __flags; - struct tty_buffer *tb; - - spin_lock_irqsave(&buf->lock, __flags); - space = __tty_buffer_request_room(port, goal); - tb = buf->tail; + int space = tty_buffer_request_room(port, goal); + struct tty_buffer *tb = port->buf.tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) { - spin_unlock_irqrestore(&buf->lock, __flags); break; } memcpy(tb->char_buf_ptr + tb->used, chars, space); memcpy(tb->flag_buf_ptr + tb->used, flags, space); tb->used += space; - spin_unlock_irqrestore(&buf->lock, __flags); copied += space; chars += space; flags += space; @@ -392,21 +360,13 @@ EXPORT_SYMBOL(tty_schedule_flip); int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, size_t size) { - struct tty_bufhead *buf = &port->buf; - int space; - unsigned long flags; - struct tty_buffer *tb; - - spin_lock_irqsave(&buf->lock, flags); - space = __tty_buffer_request_room(port, size); - - tb = buf->tail; + int space = tty_buffer_request_room(port, size); if (likely(space)) { + struct tty_buffer *tb = port->buf.tail; *chars = tb->char_buf_ptr + tb->used; memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); tb->used += space; } - spin_unlock_irqrestore(&buf->lock, flags); return space; } EXPORT_SYMBOL_GPL(tty_prepare_flip_string); @@ -430,21 +390,13 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); int tty_prepare_flip_string_flags(struct tty_port *port, unsigned char **chars, char **flags, size_t size) { - struct tty_bufhead *buf = &port->buf; - int space; - unsigned long __flags; - struct tty_buffer *tb; - - spin_lock_irqsave(&buf->lock, __flags); - space = __tty_buffer_request_room(port, size); - - tb = buf->tail; + int space = tty_buffer_request_room(port, size); if (likely(space)) { + struct tty_buffer *tb = port->buf.tail; *chars = tb->char_buf_ptr + tb->used; *flags = tb->flag_buf_ptr + tb->used; tb->used += space; } - spin_unlock_irqrestore(&buf->lock, __flags); return space; } EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); -- cgit v1.2.3 From 384e301e3519599b000c1a2ecd938b533fc15d85 Mon Sep 17 00:00:00 2001 From: Liang Li Date: Sat, 19 Jan 2013 17:52:10 +0800 Subject: pch_uart: fix a deadlock when pch_uart as console When we use pch_uart as system console like 'console=ttyPCH0,115200', then 'send break' to it. We'll encounter the deadlock on a cpu/core, with interrupts disabled on the core. When we happen to have all irqs affinity to cpu0 then the deadlock on cpu0 actually deadlock whole system. In pch_uart_interrupt, we have spin_lock_irqsave(&priv->lock, flags) then call pch_uart_err_ir when break is received. Then the call to dev_err would actually call to pch_console_write then we'll run into another spin_lock(&priv->lock), with interrupts disabled. So in the call sequence lead by pch_uart_interrupt, we should be carefully to call functions that will 'print message to console' only in case the uart port is not being used as serial console. Signed-off-by: Liang Li Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/pch_uart.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 8b40a1fc9681..10e1a95b0c92 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -1024,22 +1024,37 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr) { u8 fcr = ioread8(priv->membase + UART_FCR); + struct uart_port *port = &priv->port; + struct tty_struct *tty = tty_port_tty_get(&port->state->port); + char *error_msg[5] = {}; + int i = 0; /* Reset FIFO */ fcr |= UART_FCR_CLEAR_RCVR; iowrite8(fcr, priv->membase + UART_FCR); if (lsr & PCH_UART_LSR_ERR) - dev_err(&priv->pdev->dev, "Error data in FIFO\n"); + error_msg[i++] = "Error data in FIFO\n"; + + if (lsr & UART_LSR_FE) { + port->icount.frame++; + error_msg[i++] = " Framing Error\n"; + } - if (lsr & UART_LSR_FE) - dev_err(&priv->pdev->dev, "Framing Error\n"); + if (lsr & UART_LSR_PE) { + port->icount.parity++; + error_msg[i++] = " Parity Error\n"; + } - if (lsr & UART_LSR_PE) - dev_err(&priv->pdev->dev, "Parity Error\n"); + if (lsr & UART_LSR_OE) { + port->icount.overrun++; + error_msg[i++] = " Overrun Error\n"; + } - if (lsr & UART_LSR_OE) - dev_err(&priv->pdev->dev, "Overrun Error\n"); + if (tty == NULL) { + for (i = 0; error_msg[i] != NULL; i++) + dev_err(&priv->pdev->dev, error_msg[i]); + } } static irqreturn_t pch_uart_interrupt(int irq, void *dev_id) -- cgit v1.2.3 From 1f9db0921f212ad8fdf4bacfdf23590e64272f90 Mon Sep 17 00:00:00 2001 From: Liang Li Date: Sat, 19 Jan 2013 17:52:11 +0800 Subject: pch_uart: add sysrq support When send break to the uart port, we always get 'frame error', but we can not just reset receive fifo in such case, otherwise the sysrq cmd will not be received correctly. When we handle sysrq output via pch_console_write, the priv lock has already been taken so no need to take the lock in pch_console_write. Signed-off-by: Liang Li Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/pch_uart.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 10e1a95b0c92..1ddfc66b1084 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -14,18 +14,21 @@ *along with this program; if not, write to the Free Software *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ +#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif #include #include #include #include #include +#include #include #include #include #include #include #include -#include #include #include @@ -553,12 +556,24 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, { int i; u8 rbr, lsr; + struct uart_port *port = &priv->port; lsr = ioread8(priv->membase + UART_LSR); for (i = 0, lsr = ioread8(priv->membase + UART_LSR); - i < rx_size && lsr & UART_LSR_DR; + i < rx_size && lsr & (UART_LSR_DR | UART_LSR_BI); lsr = ioread8(priv->membase + UART_LSR)) { rbr = ioread8(priv->membase + PCH_UART_RBR); + + if (lsr & UART_LSR_BI) { + port->icount.brk++; + if (uart_handle_break(port)) + continue; + } + if (port->sysrq) { + if (uart_handle_sysrq_char(port, rbr)) + continue; + } + buf[i++] = rbr; } return i; @@ -1023,16 +1038,11 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr) { - u8 fcr = ioread8(priv->membase + UART_FCR); struct uart_port *port = &priv->port; struct tty_struct *tty = tty_port_tty_get(&port->state->port); char *error_msg[5] = {}; int i = 0; - /* Reset FIFO */ - fcr |= UART_FCR_CLEAR_RCVR; - iowrite8(fcr, priv->membase + UART_FCR); - if (lsr & PCH_UART_LSR_ERR) error_msg[i++] = "Error data in FIFO\n"; @@ -1565,7 +1575,8 @@ pch_console_write(struct console *co, const char *s, unsigned int count) local_irq_save(flags); if (priv->port.sysrq) { - spin_lock(&priv->lock); + /* call to uart_handle_sysrq_char already took the priv lock */ + priv_locked = 0; /* serial8250_handle_port() already took the port lock */ port_locked = 0; } else if (oops_in_progress) { -- cgit v1.2.3 From 2326669ccbd901dffeefb66ed742c294b2e8041b Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Mon, 21 Jan 2013 19:57:41 +0100 Subject: serial: xilinx_uartps: Get clock rate info from dts Add support for specifying clock information for the uart clk via the device tree. This eliminates the need to hardcode rates in the device tree. Signed-off-by: Josh Cartwright Signed-off-by: Wei Yongjun Acked-by: Michal Simek Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/arm/boot/dts/zynq-7000.dtsi | 4 ++-- drivers/tty/serial/xilinx_uartps.c | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi index 401c1262d4ed..5914b5654591 100644 --- a/arch/arm/boot/dts/zynq-7000.dtsi +++ b/arch/arm/boot/dts/zynq-7000.dtsi @@ -44,14 +44,14 @@ compatible = "xlnx,xuartps"; reg = <0xE0000000 0x1000>; interrupts = <0 27 4>; - clock = <50000000>; + clocks = <&uart_clk 0>; }; uart1: uart@e0001000 { compatible = "xlnx,xuartps"; reg = <0xE0001000 0x1000>; interrupts = <0 50 4>; - clock = <50000000>; + clocks = <&uart_clk 1>; }; slcr: slcr@f8000000 { diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 82a3151e393c..e426603d934e 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -936,16 +937,18 @@ static int xuartps_probe(struct platform_device *pdev) int rc; struct uart_port *port; struct resource *res, *res2; - int clk = 0; + struct clk *clk; - const unsigned int *prop; - - prop = of_get_property(pdev->dev.of_node, "clock", NULL); - if (prop) - clk = be32_to_cpup(prop); - if (!clk) { + clk = of_clk_get(pdev->dev.of_node, 0); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "no clock specified\n"); - return -ENODEV; + return PTR_ERR(clk); + } + + rc = clk_prepare_enable(clk); + if (rc) { + dev_err(&pdev->dev, "could not enable clock\n"); + return -EBUSY; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -970,7 +973,8 @@ static int xuartps_probe(struct platform_device *pdev) port->mapbase = res->start; port->irq = res2->start; port->dev = &pdev->dev; - port->uartclk = clk; + port->uartclk = clk_get_rate(clk); + port->private_data = clk; dev_set_drvdata(&pdev->dev, port); rc = uart_add_one_port(&xuartps_uart_driver, port); if (rc) { @@ -992,14 +996,14 @@ static int xuartps_probe(struct platform_device *pdev) static int xuartps_remove(struct platform_device *pdev) { struct uart_port *port = dev_get_drvdata(&pdev->dev); - int rc = 0; + struct clk *clk = port->private_data; + int rc; /* Remove the xuartps port from the serial core */ - if (port) { - rc = uart_remove_one_port(&xuartps_uart_driver, port); - dev_set_drvdata(&pdev->dev, NULL); - port->mapbase = 0; - } + rc = uart_remove_one_port(&xuartps_uart_driver, port); + dev_set_drvdata(&pdev->dev, NULL); + port->mapbase = 0; + clk_disable_unprepare(clk); return rc; } -- cgit v1.2.3 From c098020d0368ded1c6ba8d7b612feffe067509a6 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Mon, 21 Jan 2013 14:22:56 +0100 Subject: serial/efm32: parse location property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The non-dt probing allowed passing the location via platform data from the beginning. So make up leeway for device tree probing. Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- .../devicetree/bindings/tty/serial/efm32-uart.txt | 6 +++++ drivers/tty/serial/efm32-uart.c | 31 +++++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/Documentation/devicetree/bindings/tty/serial/efm32-uart.txt b/Documentation/devicetree/bindings/tty/serial/efm32-uart.txt index 6588b6950a7f..8e080b893b49 100644 --- a/Documentation/devicetree/bindings/tty/serial/efm32-uart.txt +++ b/Documentation/devicetree/bindings/tty/serial/efm32-uart.txt @@ -5,10 +5,16 @@ Required properties: - reg : Address and length of the register set - interrupts : Should contain uart interrupt +Optional properties: +- location : Decides the location of the USART I/O pins. + Allowed range : [0 .. 5] + Default: 0 + Example: uart@0x4000c400 { compatible = "efm32,uart"; reg = <0x4000c400 0x400>; interrupts = <15>; + location = <0>; }; diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index de14bd7dce10..7d199c8e1a75 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c @@ -81,6 +81,7 @@ struct efm32_uart_port { struct uart_port port; unsigned int txirq; struct clk *clk; + struct efm32_uart_pdata pdata; }; #define to_efm_port(_port) container_of(_port, struct efm32_uart_port, port) #define efm_debug(efm_port, format, arg...) \ @@ -293,13 +294,8 @@ static irqreturn_t efm32_uart_txirq(int irq, void *data) static int efm32_uart_startup(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); - u32 location = 0; - struct efm32_uart_pdata *pdata = dev_get_platdata(port->dev); int ret; - if (pdata) - location = UARTn_ROUTE_LOCATION(pdata->location); - ret = clk_enable(efm_port->clk); if (ret) { efm_debug(efm_port, "failed to enable clk\n"); @@ -308,7 +304,9 @@ static int efm32_uart_startup(struct uart_port *port) port->uartclk = clk_get_rate(efm_port->clk); /* Enable pins at configured location */ - efm32_uart_write32(efm_port, location | UARTn_ROUTE_RXPEN | UARTn_ROUTE_TXPEN, + efm32_uart_write32(efm_port, + UARTn_ROUTE_LOCATION(efm_port->pdata.location) | + UARTn_ROUTE_RXPEN | UARTn_ROUTE_TXPEN, UARTn_ROUTE); ret = request_irq(port->irq, efm32_uart_rxirq, 0, @@ -667,11 +665,24 @@ static int efm32_uart_probe_dt(struct platform_device *pdev, struct efm32_uart_port *efm_port) { struct device_node *np = pdev->dev.of_node; + u32 location; int ret; if (!np) return 1; + ret = of_property_read_u32(np, "location", &location); + if (!ret) { + if (location > 5) { + dev_err(&pdev->dev, "invalid location\n"); + return -EINVAL; + } + efm_debug(efm_port, "using location %u\n", location); + efm_port->pdata.location = location; + } else { + efm_debug(efm_port, "fall back to location 0\n"); + } + ret = of_alias_get_id(np, "serial"); if (ret < 0) { dev_err(&pdev->dev, "failed to get alias id: %d\n", ret); @@ -731,10 +742,16 @@ static int efm32_uart_probe(struct platform_device *pdev) efm_port->port.flags = UPF_BOOT_AUTOCONF; ret = efm32_uart_probe_dt(pdev, efm_port); - if (ret > 0) + if (ret > 0) { /* not created by device tree */ + const struct efm32_uart_pdata *pdata = dev_get_platdata(&pdev->dev); + efm_port->port.line = pdev->id; + if (pdata) + efm_port->pdata = *pdata; + } + if (efm_port->port.line >= 0 && efm_port->port.line < ARRAY_SIZE(efm32_uart_ports)) efm32_uart_ports[efm_port->port.line] = efm_port; -- cgit v1.2.3 From f548b96de684c86c72cd7ba019c03a7afe94fd53 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Mon, 21 Jan 2013 19:38:56 +0400 Subject: serial: sccnxp: Reset break and overrun bits in RX handler This patch adds a hardware reset the break and overflow bits for these events. Without resetting the bits they will be reported to the core every time, when once occur. Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sccnxp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index c5f0e964ec05..c7dec1678f65 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -305,14 +305,19 @@ static void sccnxp_handle_rx(struct uart_port *port) if (unlikely(sr)) { if (sr & SR_BRK) { port->icount.brk++; + sccnxp_port_write(port, SCCNXP_CR_REG, + CR_CMD_BREAK_RESET); if (uart_handle_break(port)) continue; } else if (sr & SR_PE) port->icount.parity++; else if (sr & SR_FE) port->icount.frame++; - else if (sr & SR_OVR) + else if (sr & SR_OVR) { port->icount.overrun++; + sccnxp_port_write(port, SCCNXP_CR_REG, + CR_CMD_STATUS_RESET); + } sr &= port->read_status_mask; if (sr & SR_BRK) -- cgit v1.2.3 From 4bbed6bc41aa76183449ade053891e28dec0ae3b Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Mon, 21 Jan 2013 19:38:57 +0400 Subject: serial: sccnxp: Make baudrate table struct static This struct is used only for driver, so it should be static. Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sccnxp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index c7dec1678f65..caccbe8fc1be 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c @@ -179,14 +179,12 @@ static int sccnxp_update_best_err(int a, int b, int *besterr) return 1; } -struct baud_table { +static const struct { u8 csr; u8 acr; u8 mr0; int baud; -}; - -const struct baud_table baud_std[] = { +} baud_std[] = { { 0, ACR_BAUD0, MR0_BAUD_NORMAL, 50, }, { 0, ACR_BAUD1, MR0_BAUD_NORMAL, 75, }, { 1, ACR_BAUD0, MR0_BAUD_NORMAL, 110, }, -- cgit v1.2.3 From 666b7793d4bfa9f150b5c2007ab48c755ddc53ca Mon Sep 17 00:00:00 2001 From: Arve Hjønnevåg Date: Mon, 21 Jan 2013 23:38:47 +0000 Subject: goldfish: tty driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides a console driver for the Goldfish virtual platform. The original is from Arve with changes from Jun Nakajima and Tom Keel. This has been then been ported to the current kernel and to the tty port mechanism by Alan Cox. In the process it gained proper POSIX semantics and vhangup works. The default name is not ttyS as this belongs to the 8250 driver. Instead ttyGFx is now used. In the normal usage case the first port serves as a kernel logging console and the second one carries various other data streams for the emulation. Signed-off-by: Arve Hjønnevåg [Cleaned up to handle x86] Signed-off-by: Sheng Yang Signed-off-by: Yunhong Jiang Signed-off-by: Xiaohui Xin Signed-off-by: Jun Nakajima Signed-off-by: Bruce Beare [Moved to 3.7 and chunks rewritten to use tty_port layer] Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/Kconfig | 6 + drivers/tty/Makefile | 1 + drivers/tty/goldfish.c | 333 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 340 insertions(+) create mode 100644 drivers/tty/goldfish.c (limited to 'drivers') diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index a79fd8ebd56e..29dfc24f2dbb 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -400,4 +400,10 @@ config PPC_EARLY_DEBUG_EHV_BC_HANDLE there simply will be no early console output. This is true also if you don't boot under a hypervisor at all. +config GOLDFISH_TTY + tristate "Goldfish TTY Driver" + depends on GOLDFISH + help + Console and system TTY driver for the Goldfish virtual platform. + endif # TTY diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index df5663d0d55e..35649d35abf0 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -27,5 +27,6 @@ obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o obj-$(CONFIG_SYNCLINK) += synclink.o obj-$(CONFIG_PPC_EPAPR_HV_BYTECHAN) += ehv_bytechan.o +obj-$(CONFIG_GOLDFISH_TTY) += goldfish.o obj-y += ipwireless/ diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c new file mode 100644 index 000000000000..e2ccb6daa6c5 --- /dev/null +++ b/drivers/tty/goldfish.c @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2007 Google, Inc. + * Copyright (C) 2012 Intel, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + GOLDFISH_TTY_PUT_CHAR = 0x00, + GOLDFISH_TTY_BYTES_READY = 0x04, + GOLDFISH_TTY_CMD = 0x08, + + GOLDFISH_TTY_DATA_PTR = 0x10, + GOLDFISH_TTY_DATA_LEN = 0x14, + + GOLDFISH_TTY_CMD_INT_DISABLE = 0, + GOLDFISH_TTY_CMD_INT_ENABLE = 1, + GOLDFISH_TTY_CMD_WRITE_BUFFER = 2, + GOLDFISH_TTY_CMD_READ_BUFFER = 3, +}; + +struct goldfish_tty { + struct tty_port port; + spinlock_t lock; + void __iomem *base; + u32 irq; + int opencount; + struct console console; +}; + +static DEFINE_MUTEX(goldfish_tty_lock); +static struct tty_driver *goldfish_tty_driver; +static u32 goldfish_tty_line_count = 8; +static u32 goldfish_tty_current_line_count; +static struct goldfish_tty *goldfish_ttys; + +static void goldfish_tty_do_write(int line, const char *buf, unsigned count) +{ + unsigned long irq_flags; + struct goldfish_tty *qtty = &goldfish_ttys[line]; + void __iomem *base = qtty->base; + spin_lock_irqsave(&qtty->lock, irq_flags); + writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); + writel(count, base + GOLDFISH_TTY_DATA_LEN); + writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); + spin_unlock_irqrestore(&qtty->lock, irq_flags); +} + +static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) +{ + struct platform_device *pdev = dev_id; + struct goldfish_tty *qtty = &goldfish_ttys[pdev->id]; + void __iomem *base = qtty->base; + unsigned long irq_flags; + unsigned char *buf; + u32 count; + struct tty_struct *tty; + + count = readl(base + GOLDFISH_TTY_BYTES_READY); + if(count == 0) + return IRQ_NONE; + + tty = tty_port_tty_get(&qtty->port); + if (tty) { + count = tty_prepare_flip_string(tty, &buf, count); + spin_lock_irqsave(&qtty->lock, irq_flags); + writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); + writel(count, base + GOLDFISH_TTY_DATA_LEN); + writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); + spin_unlock_irqrestore(&qtty->lock, irq_flags); + tty_schedule_flip(tty); + tty_kref_put(tty); + } + return IRQ_HANDLED; +} + +static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) +{ + struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); + writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_CMD); + return 0; +} + +static void goldfish_tty_shutdown(struct tty_port *port) +{ + struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); + writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_CMD); +} + +static int goldfish_tty_open(struct tty_struct * tty, struct file * filp) +{ + struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; + return tty_port_open(&qtty->port, tty, filp); +} + +static void goldfish_tty_close(struct tty_struct * tty, struct file * filp) +{ + tty_port_close(tty->port, tty, filp); +} + +static void goldfish_tty_hangup(struct tty_struct *tty) +{ + tty_port_hangup(tty->port); +} + +static int goldfish_tty_write(struct tty_struct * tty, const unsigned char *buf, int count) +{ + goldfish_tty_do_write(tty->index, buf, count); + return count; +} + +static int goldfish_tty_write_room(struct tty_struct *tty) +{ + return 0x10000; +} + +static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) +{ + struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; + void __iomem *base = qtty->base; + return readl(base + GOLDFISH_TTY_BYTES_READY); +} + +static void goldfish_tty_console_write(struct console *co, const char *b, unsigned count) +{ + goldfish_tty_do_write(co->index, b, count); +} + +static struct tty_driver *goldfish_tty_console_device(struct console *c, int *index) +{ + *index = c->index; + return goldfish_tty_driver; +} + +static int goldfish_tty_console_setup(struct console *co, char *options) +{ + if((unsigned)co->index > goldfish_tty_line_count) + return -ENODEV; + if(goldfish_ttys[co->index].base == 0) + return -ENODEV; + return 0; +} + +static struct tty_port_operations goldfish_port_ops = { + .activate = goldfish_tty_activate, + .shutdown = goldfish_tty_shutdown +}; + +static struct tty_operations goldfish_tty_ops = { + .open = goldfish_tty_open, + .close = goldfish_tty_close, + .hangup = goldfish_tty_hangup, + .write = goldfish_tty_write, + .write_room = goldfish_tty_write_room, + .chars_in_buffer = goldfish_tty_chars_in_buffer, +}; + +static int goldfish_tty_create_driver(void) +{ + int ret; + struct tty_driver *tty; + + goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * goldfish_tty_line_count, GFP_KERNEL); + if(goldfish_ttys == NULL) { + ret = -ENOMEM; + goto err_alloc_goldfish_ttys_failed; + } + tty = alloc_tty_driver(goldfish_tty_line_count); + if(tty == NULL) { + ret = -ENOMEM; + goto err_alloc_tty_driver_failed; + } + tty->driver_name = "goldfish"; + tty->name = "ttyGF"; + tty->type = TTY_DRIVER_TYPE_SERIAL; + tty->subtype = SERIAL_TYPE_NORMAL; + tty->init_termios = tty_std_termios; + tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + tty_set_operations(tty, &goldfish_tty_ops); + ret = tty_register_driver(tty); + if(ret) + goto err_tty_register_driver_failed; + + goldfish_tty_driver = tty; + return 0; + +err_tty_register_driver_failed: + put_tty_driver(tty); +err_alloc_tty_driver_failed: + kfree(goldfish_ttys); + goldfish_ttys = NULL; +err_alloc_goldfish_ttys_failed: + return ret; +} + +static void goldfish_tty_delete_driver(void) +{ + tty_unregister_driver(goldfish_tty_driver); + put_tty_driver(goldfish_tty_driver); + goldfish_tty_driver = NULL; + kfree(goldfish_ttys); + goldfish_ttys = NULL; +} + +static int goldfish_tty_probe(struct platform_device *pdev) +{ + struct goldfish_tty *qtty; + int ret = -EINVAL; + int i; + struct resource *r; + struct device *ttydev; + void __iomem *base; + u32 irq; + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if(r == NULL) + return -EINVAL; + + base = ioremap(r->start, 0x1000); + if (base == NULL) + pr_err("goldfish_tty: unable to remap base\n"); + + r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if(r == NULL) + goto err_unmap; + + irq = r->start; + + if(pdev->id >= goldfish_tty_line_count) + goto err_unmap; + + mutex_lock(&goldfish_tty_lock); + if(goldfish_tty_current_line_count == 0) { + ret = goldfish_tty_create_driver(); + if(ret) + goto err_create_driver_failed; + } + goldfish_tty_current_line_count++; + + qtty = &goldfish_ttys[pdev->id]; + spin_lock_init(&qtty->lock); + tty_port_init(&qtty->port); + qtty->port.ops = &goldfish_port_ops; + qtty->base = base; + qtty->irq = irq; + + writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_CMD); + + ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, "goldfish_tty", pdev); + if(ret) + goto err_request_irq_failed; + + + ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, + pdev->id, &pdev->dev); + if(IS_ERR(ttydev)) { + ret = PTR_ERR(ttydev); + goto err_tty_register_device_failed; + } + + strcpy(qtty->console.name, "ttyGF"); + qtty->console.write = goldfish_tty_console_write; + qtty->console.device = goldfish_tty_console_device; + qtty->console.setup = goldfish_tty_console_setup; + qtty->console.flags = CON_PRINTBUFFER; + qtty->console.index = pdev->id; + register_console(&qtty->console); + + mutex_unlock(&goldfish_tty_lock); + return 0; + + tty_unregister_device(goldfish_tty_driver, i); +err_tty_register_device_failed: + free_irq(irq, pdev); +err_request_irq_failed: + goldfish_tty_current_line_count--; + if(goldfish_tty_current_line_count == 0) + goldfish_tty_delete_driver(); +err_create_driver_failed: + mutex_unlock(&goldfish_tty_lock); +err_unmap: + iounmap(base); + return ret; +} + +static int goldfish_tty_remove(struct platform_device *pdev) +{ + struct goldfish_tty *qtty; + + mutex_lock(&goldfish_tty_lock); + + qtty = &goldfish_ttys[pdev->id]; + unregister_console(&qtty->console); + tty_unregister_device(goldfish_tty_driver, pdev->id); + iounmap(qtty->base); + qtty->base = 0; + free_irq(qtty->irq, pdev); + goldfish_tty_current_line_count--; + if(goldfish_tty_current_line_count == 0) + goldfish_tty_delete_driver(); + mutex_unlock(&goldfish_tty_lock); + return 0; +} + +static struct platform_driver goldfish_tty_platform_driver = { + .probe = goldfish_tty_probe, + .remove = goldfish_tty_remove, + .driver = { + .name = "goldfish_tty" + } +}; + +module_platform_driver(goldfish_tty_platform_driver); + +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From aea95548c0dedea31a9dbb78eae762b220553921 Mon Sep 17 00:00:00 2001 From: channing Date: Tue, 22 Jan 2013 16:08:46 +0800 Subject: serial:ifx6x60: Remove memset for SPI frame There is no need to memset 0 to SPI frame memory before preparing transfer frame bits, because SPI frame header are encoded with valid data size, so don't need to worry about adopting dirty bits, more, memset zero for each SPI frame may impact the spi throughput efficiency. Signed-off-by: Chen Jun Signed-off-by: channing Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/ifx6x60.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 6a6668bbb330..f083641bf475 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -481,7 +481,6 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev) unsigned char *tx_buffer; tx_buffer = ifx_dev->tx_buffer; - memset(tx_buffer, 0, IFX_SPI_TRANSFER_SIZE); /* make room for required SPI header */ tx_buffer += IFX_SPI_HEADER_OVERHEAD; -- cgit v1.2.3 From eb51d917a7e6b7d5ce1a58941f4a5840ac06553a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 22 Jan 2013 13:11:11 +0100 Subject: serial: xilinx_uartps: Remove leftover __exit_p() __exit_p() need to be removed after the __devexit removal from the driver. Warning log: drivers/tty/serial/xilinx_uartps.c:996:12: warning: 'xuartps_remove' defined but not used [-Wunused-function] Signed-off-by: Michal Simek Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e426603d934e..ba451c7209fc 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1044,7 +1044,7 @@ MODULE_DEVICE_TABLE(of, xuartps_of_match); static struct platform_driver xuartps_platform_driver = { .probe = xuartps_probe, /* Probe method */ - .remove = __exit_p(xuartps_remove), /* Detach method */ + .remove = xuartps_remove, /* Detach method */ .suspend = xuartps_suspend, /* Suspend */ .resume = xuartps_resume, /* Resume after a suspend */ .driver = { -- cgit v1.2.3 From ebcf09816c68d1082aec5a2646e9f20715384502 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 25 Jan 2013 15:05:30 +0000 Subject: goldfish: move to tty_port for flip buffers Sorry forgot to merge this in the original submission. Resync with the tty tree changes moving the buffers into the tty_port Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/goldfish.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index e2ccb6daa6c5..f17d2e4ee2ca 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -72,23 +72,18 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) unsigned long irq_flags; unsigned char *buf; u32 count; - struct tty_struct *tty; count = readl(base + GOLDFISH_TTY_BYTES_READY); if(count == 0) return IRQ_NONE; - tty = tty_port_tty_get(&qtty->port); - if (tty) { - count = tty_prepare_flip_string(tty, &buf, count); - spin_lock_irqsave(&qtty->lock, irq_flags); - writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); - writel(count, base + GOLDFISH_TTY_DATA_LEN); - writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); - spin_unlock_irqrestore(&qtty->lock, irq_flags); - tty_schedule_flip(tty); - tty_kref_put(tty); - } + count = tty_prepare_flip_string(&qtty->port, &buf, count); + spin_lock_irqsave(&qtty->lock, irq_flags); + writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); + writel(count, base + GOLDFISH_TTY_DATA_LEN); + writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); + spin_unlock_irqrestore(&qtty->lock, irq_flags); + tty_schedule_flip(&qtty->port); return IRQ_HANDLED; } -- cgit v1.2.3 From 58f82be334ede87aa6ff6fa1afdb05552be907be Mon Sep 17 00:00:00 2001 From: Karthik Manamcheri Date: Wed, 23 Jan 2013 16:36:18 -0600 Subject: n_tty: Unthrottle tty when flushing read buffer When the tty input buffer is full and thereby throttled, flushing/resetting the read buffer should unthrottle to allow more data to be received. Signed-off-by: Karthik Manamcheri Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 19083efa2314..d5cea3bb01ea 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -229,6 +229,8 @@ static void reset_buffer_flags(struct tty_struct *tty) ldata->canon_head = ldata->canon_data = ldata->erasing = 0; bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); n_tty_set_room(tty); + + check_unthrottle(tty); } /** -- cgit v1.2.3 From e8c5b56fdca7bb3006914f0bf7d09b4d64254172 Mon Sep 17 00:00:00 2001 From: Liang Li Date: Thu, 24 Jan 2013 12:31:27 +0800 Subject: serial: pch_uart: fix sysrq handling for pch_uart When PCH_UART_CONSOLE and SERIAL_CORE_CONSOLE is not set neither, the uart_port will have no 'sysrq' member hence their will need a '#ifdef' in pch_uart.c to handle the case, otherwise we'll see compile error like this: CC [M] drivers/tty/serial/pch_uart.o drivers/tty/serial/pch_uart.c: In function 'pch_uart_hal_read': drivers/tty/serial/pch_uart.c:572:11: error: 'struct uart_port' has no member named 'sysrq' make[4]: *** [drivers/tty/serial/pch_uart.o] Error 1 Reported-by: Randy Dunlap CC: Stephen Rothwell Signed-off-by: Liang Li Acked-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/pch_uart.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 1ddfc66b1084..7a6c989924b3 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -569,10 +569,12 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, if (uart_handle_break(port)) continue; } +#ifdef SUPPORT_SYSRQ if (port->sysrq) { if (uart_handle_sysrq_char(port, rbr)) continue; } +#endif buf[i++] = rbr; } -- cgit v1.2.3 From 9429ccbf386c9fce9d998a96474a0926391208cf Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 23 Jan 2013 09:52:25 +0800 Subject: serial: pxa: fine-tune clk useage 1) add clk_enable/disable in serial_pxa_console_write() 2) add clk_prepare() to follow common clock driver Signed-off-by: Yi Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/pxa.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c index a67f9e156ada..05f504e0c271 100644 --- a/drivers/tty/serial/pxa.c +++ b/drivers/tty/serial/pxa.c @@ -672,7 +672,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count) unsigned long flags; int locked = 1; - + clk_enable(up->clk); local_irq_save(flags); if (up->port.sysrq) locked = 0; @@ -699,6 +699,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count) if (locked) spin_unlock(&up->port.lock); local_irq_restore(flags); + clk_disable(up->clk); } @@ -896,6 +897,12 @@ static int serial_pxa_probe(struct platform_device *dev) goto err_free; } + ret = clk_prepare(sport->clk); + if (ret) { + clk_put(sport->clk); + goto err_free; + } + sport->port.type = PORT_PXA; sport->port.iotype = UPIO_MEM; sport->port.mapbase = mmres->start; @@ -927,6 +934,7 @@ static int serial_pxa_probe(struct platform_device *dev) return 0; err_clk: + clk_unprepare(sport->clk); clk_put(sport->clk); err_free: kfree(sport); @@ -940,6 +948,8 @@ static int serial_pxa_remove(struct platform_device *dev) platform_set_drvdata(dev, NULL); uart_remove_one_port(&serial_pxa_reg, &sport->port); + + clk_unprepare(sport->clk); clk_put(sport->clk); kfree(sport); -- cgit v1.2.3 From dbf5bef8da169b38db804996a661f8d634df8295 Mon Sep 17 00:00:00 2001 From: Venu Byravarasu Date: Wed, 23 Jan 2013 12:52:13 +0530 Subject: serial: tegra: Fix compilation error Fix compilation error, by adding the correct header file for Tegra clocks. Signed-off-by: Venu Byravarasu Reviewed-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index 30d6ff6eddb0..4f5e62989a2b 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c @@ -43,7 +43,7 @@ #include #include -#include +#include #define TEGRA_UART_TYPE "TEGRA_UART" #define TX_EMPTY_STATUS (UART_LSR_TEMT | UART_LSR_THRE) -- cgit v1.2.3 From 1651d0a9be0009460c5fdc822505749f295c5ba9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 29 Jan 2013 23:35:35 -0500 Subject: Revert "n_tty: Unthrottle tty when flushing read buffer" This reverts commit 58f82be334ede87aa6ff6fa1afdb05552be907be. This was fixed by a previous patch already. Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index d5cea3bb01ea..19083efa2314 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -229,8 +229,6 @@ static void reset_buffer_flags(struct tty_struct *tty) ldata->canon_head = ldata->canon_data = ldata->erasing = 0; bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); n_tty_set_room(tty); - - check_unthrottle(tty); } /** -- cgit v1.2.3 From abd7bacae672298ec99ce6cfdc75ae1e1f9159b6 Mon Sep 17 00:00:00 2001 From: Stephen Chivers Date: Mon, 28 Jan 2013 19:49:20 +1100 Subject: serial/8250: Add suport for later SUNIX (TIMEDIA) boards. Add support for later SUNIX (TIMEDIA) Universal PCI Single and Multi-Port Communications Boards. These boards have PCI Vendor ID 1fd4 with device ID 1999 but otherwise appear to be the same as the TIMEDIA boards already supported by 8250_pci and parport_serial. Tested with: a. the two port serial board part number SER5037A, b. the two port serial and one port parallel board part number MIO5079A. Signed-off-by: Stephen Chivers Signed-off-by: Greg Kroah-Hartman --- drivers/parport/parport_serial.c | 21 +++++++++++++++++++++ drivers/tty/serial/8250/8250_pci.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'drivers') diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c index ef6169adb845..1b8bdb7e9bf4 100644 --- a/drivers/parport/parport_serial.c +++ b/drivers/parport/parport_serial.c @@ -63,6 +63,7 @@ enum parport_pc_pci_cards { timedia_9079b, timedia_9079c, wch_ch353_2s1p, + sunix_2s1p, }; /* each element directly indexed from enum list, above */ @@ -148,8 +149,12 @@ static struct parport_pc_pci cards[] = { /* timedia_9079b */ { 1, { { 2, 3 }, } }, /* timedia_9079c */ { 1, { { 2, 3 }, } }, /* wch_ch353_2s1p*/ { 1, { { 2, -1}, } }, + /* sunix_2s1p */ { 1, { { 3, -1 }, } }, }; +#define PCI_VENDOR_ID_SUNIX 0x1fd4 +#define PCI_DEVICE_ID_SUNIX_1999 0x1999 + static struct pci_device_id parport_serial_pci_tbl[] = { /* PCI cards */ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_110L, @@ -246,8 +251,18 @@ static struct pci_device_id parport_serial_pci_tbl[] = { { 0x1409, 0x7168, 0x1409, 0xb079, 0, 0, timedia_9079a }, { 0x1409, 0x7168, 0x1409, 0xc079, 0, 0, timedia_9079b }, { 0x1409, 0x7168, 0x1409, 0xd079, 0, 0, timedia_9079c }, + /* WCH CARDS */ { 0x4348, 0x7053, 0x4348, 0x3253, 0, 0, wch_ch353_2s1p}, + + /* + * More SUNIX variations. At least one of these has part number + * '5079A but subdevice 0x102. That board reports 0x0708 as + * its PCI Class. + */ + { PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, PCI_VENDOR_ID_SUNIX, + 0x0102, 0, 0, sunix_2s1p }, + { 0, } /* terminate list */ }; MODULE_DEVICE_TABLE(pci,parport_serial_pci_tbl); @@ -470,6 +485,12 @@ static struct pciserial_board pci_parport_serial_boards[] = { .base_baud = 115200, .uart_offset = 8, }, + [sunix_2s1p] = { + .flags = FL_BASE0|FL_BASE_BARS, + .num_ports = 2, + .base_baud = 921600, + .uart_offset = 8, + }, }; struct parport_serial_private { diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 3cb333242912..791c5a77ec61 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -1565,6 +1565,9 @@ pci_wch_ch353_setup(struct serial_private *priv, #define PCI_DEVICE_ID_COMMTECH_4222PCIE 0x0022 #define PCI_DEVICE_ID_BROADCOM_TRUMANAGE 0x160a +#define PCI_VENDOR_ID_SUNIX 0x1fd4 +#define PCI_DEVICE_ID_SUNIX_1999 0x1999 + /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 @@ -1960,6 +1963,23 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { .subdevice = PCI_ANY_ID, .setup = pci_timedia_setup, }, + /* + * SUNIX (Timedia) cards + * Do not "probe" for these cards as there is at least one combination + * card that should be handled by parport_pc that doesn't match the + * rule in pci_timedia_probe. + * It is part number is MIO5079A but its subdevice ID is 0x0102. + * There are some boards with part number SER5037AL that report + * subdevice ID 0x0002. + */ + { + .vendor = PCI_VENDOR_ID_SUNIX, + .device = PCI_DEVICE_ID_SUNIX_1999, + .subvendor = PCI_VENDOR_ID_SUNIX, + .subdevice = PCI_ANY_ID, + .init = pci_timedia_init, + .setup = pci_timedia_setup, + }, /* * Exar cards */ @@ -4210,6 +4230,19 @@ static struct pci_device_id serial_pci_tbl[] = { PCI_VENDOR_ID_TIMEDIA, PCI_ANY_ID, 0, 0, pbn_b0_bt_1_921600 }, + /* + * SUNIX (TIMEDIA) + */ + { PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, + PCI_VENDOR_ID_SUNIX, PCI_ANY_ID, + PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xffff00, + pbn_b0_bt_1_921600 }, + + { PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, + PCI_VENDOR_ID_SUNIX, PCI_ANY_ID, + PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, + pbn_b0_bt_1_921600 }, + /* * AFAVLAB serial card, from Harald Welte */ -- cgit v1.2.3 From 9fe8074b82ed14358be50c62ab9d081bcb911607 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 27 Jan 2013 18:21:00 -0800 Subject: TTY: synclink: Convert + to | for bit operations Dan Carpenter noticed a missing set of parentheses around a multiple field addition. https://lkml.org/lkml/2013/1/27/166 His original commit message: There is a kind of precedence problem here, but it doesn't affect how the code works because ->serial_signals is unsigned char. We want to clear two flags here. #define SerialSignal_RTS 0x20 /* Request to Send */ #define SerialSignal_DTR 0x80 /* Data Terminal Ready */ Without the parenthesis then it does: info->serial_signals &= 0x5f; With the parenthesis it does: info->serial_signals &= 0xffffff5f; info->serial_signals is an unsigned char so the two statements are equivalent, but it's cleaner to add the parenthesis. In other dtr_rts() functions the parenthesis are there so this makes it more consistent. Other changes: Convert all + uses to | for these bit operations. Reorder the multiple fields for consistency. Update the comments too. Reported-by: Dan Carpenter Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/char/pcmcia/synclink_cs.c | 26 ++++++++++++------------- drivers/tty/synclink.c | 26 ++++++++++++------------- drivers/tty/synclink_gt.c | 26 ++++++++++++------------- drivers/tty/synclinkmp.c | 40 +++++++++++++++++++-------------------- 4 files changed, 59 insertions(+), 59 deletions(-) (limited to 'drivers') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 34e52ed0ea8c..d0c9852ab875 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1343,7 +1343,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) reset_device(info); if (!tty || tty->termios.c_cflag & HUPCL) { - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); } @@ -1405,12 +1405,12 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) cflag = tty->termios.c_cflag; - /* if B0 rate (hangup) specified then negate DTR and RTS */ - /* otherwise assert DTR and RTS */ + /* if B0 rate (hangup) specified then negate RTS and DTR */ + /* otherwise assert RTS and DTR */ if (cflag & CBAUD) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ @@ -2301,7 +2301,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term /* Handle transition to B0 status */ if (old_termios->c_cflag & CBAUD && !(tty->termios.c_cflag & CBAUD)) { - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); spin_lock_irqsave(&info->lock,flags); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); @@ -2464,9 +2464,9 @@ static void dtr_rts(struct tty_port *port, int onoff) spin_lock_irqsave(&info->lock,flags); if (onoff) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -3575,8 +3575,8 @@ static void get_signals(MGSLPC_INFO *info) { unsigned char status = 0; - /* preserve DTR and RTS */ - info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; + /* preserve RTS and DTR */ + info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; if (read_reg(info, CHB + VSTR) & BIT7) info->serial_signals |= SerialSignal_DCD; @@ -3590,7 +3590,7 @@ static void get_signals(MGSLPC_INFO *info) info->serial_signals |= SerialSignal_DSR; } -/* Set the state of DTR and RTS based on contents of +/* Set the state of RTS and DTR based on contents of * serial_signals member of device extension. */ static void set_signals(MGSLPC_INFO *info) @@ -4009,8 +4009,8 @@ static int hdlcdev_open(struct net_device *dev) spin_unlock_irqrestore(&info->netlock, flags); return rc; } - /* assert DTR and RTS, apply hardware settings */ - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + /* assert RTS and DTR, apply hardware settings */ + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; mgslpc_program_hw(info, tty); tty_kref_put(tty); diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 555fdc0ed0f1..8983276aa35e 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -1850,7 +1850,7 @@ static void shutdown(struct mgsl_struct * info) usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12)); if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); usc_set_serial_signals(info); } @@ -1915,12 +1915,12 @@ static void mgsl_change_params(struct mgsl_struct *info) cflag = info->port.tty->termios.c_cflag; - /* if B0 rate (hangup) specified then negate DTR and RTS */ - /* otherwise assert DTR and RTS */ + /* if B0 rate (hangup) specified then negate RTS and DTR */ + /* otherwise assert RTS and DTR */ if (cflag & CBAUD) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ @@ -3044,7 +3044,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio /* Handle transition to B0 status */ if (old_termios->c_cflag & CBAUD && !(tty->termios.c_cflag & CBAUD)) { - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); spin_lock_irqsave(&info->irq_spinlock,flags); usc_set_serial_signals(info); spin_unlock_irqrestore(&info->irq_spinlock,flags); @@ -3243,9 +3243,9 @@ static void dtr_rts(struct tty_port *port, int on) spin_lock_irqsave(&info->irq_spinlock,flags); if (on) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); usc_set_serial_signals(info); spin_unlock_irqrestore(&info->irq_spinlock,flags); } @@ -6239,8 +6239,8 @@ static void usc_get_serial_signals( struct mgsl_struct *info ) { u16 status; - /* clear all serial signals except DTR and RTS */ - info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; + /* clear all serial signals except RTS and DTR */ + info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; /* Read the Misc Interrupt status Register (MISR) to get */ /* the V24 status signals. */ @@ -6265,7 +6265,7 @@ static void usc_get_serial_signals( struct mgsl_struct *info ) /* usc_set_serial_signals() * - * Set the state of DTR and RTS based on contents of + * Set the state of RTS and DTR based on contents of * serial_signals member of device extension. * * Arguments: info pointer to device instance data @@ -7779,8 +7779,8 @@ static int hdlcdev_open(struct net_device *dev) return rc; } - /* assert DTR and RTS, apply hardware settings */ - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + /* assert RTS and DTR, apply hardware settings */ + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; mgsl_program_hw(info); /* enable network layer transmit */ diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index ac8599a76820..aa9eece35c3b 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -785,7 +785,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) /* Handle transition to B0 status */ if (old_termios->c_cflag & CBAUD && !(tty->termios.c_cflag & CBAUD)) { - info->signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); spin_lock_irqsave(&info->lock,flags); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); @@ -1560,8 +1560,8 @@ static int hdlcdev_open(struct net_device *dev) return rc; } - /* assert DTR and RTS, apply hardware settings */ - info->signals |= SerialSignal_RTS + SerialSignal_DTR; + /* assert RTS and DTR, apply hardware settings */ + info->signals |= SerialSignal_RTS | SerialSignal_DTR; program_hw(info); /* enable network layer transmit */ @@ -2488,7 +2488,7 @@ static void shutdown(struct slgt_info *info) slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { - info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); } @@ -2548,12 +2548,12 @@ static void change_params(struct slgt_info *info) cflag = info->port.tty->termios.c_cflag; - /* if B0 rate (hangup) specified then negate DTR and RTS */ - /* otherwise assert DTR and RTS */ + /* if B0 rate (hangup) specified then negate RTS and DTR */ + /* otherwise assert RTS and DTR */ if (cflag & CBAUD) - info->signals |= SerialSignal_RTS + SerialSignal_DTR; + info->signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ @@ -3256,9 +3256,9 @@ static void dtr_rts(struct tty_port *port, int on) spin_lock_irqsave(&info->lock,flags); if (on) - info->signals |= SerialSignal_RTS + SerialSignal_DTR; + info->signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -4119,7 +4119,7 @@ static void reset_port(struct slgt_info *info) tx_stop(info); rx_stop(info); - info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); @@ -4546,8 +4546,8 @@ static void get_signals(struct slgt_info *info) { unsigned short status = rd_reg16(info, SSR); - /* clear all serial signals except DTR and RTS */ - info->signals &= SerialSignal_DTR + SerialSignal_RTS; + /* clear all serial signals except RTS and DTR */ + info->signals &= SerialSignal_RTS | SerialSignal_DTR; if (status & BIT3) info->signals |= SerialSignal_DSR; diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 545402509cab..6d5780cf1d57 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -882,7 +882,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) /* Handle transition to B0 status */ if (old_termios->c_cflag & CBAUD && !(tty->termios.c_cflag & CBAUD)) { - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); spin_lock_irqsave(&info->lock,flags); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); @@ -1676,8 +1676,8 @@ static int hdlcdev_open(struct net_device *dev) return rc; } - /* assert DTR and RTS, apply hardware settings */ - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + /* assert RTS and DTR, apply hardware settings */ + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; program_hw(info); /* enable network layer transmit */ @@ -2706,7 +2706,7 @@ static void shutdown(SLMP_INFO * info) reset_port(info); if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); } @@ -2768,12 +2768,12 @@ static void change_params(SLMP_INFO *info) cflag = info->port.tty->termios.c_cflag; - /* if B0 rate (hangup) specified then negate DTR and RTS */ - /* otherwise assert DTR and RTS */ + /* if B0 rate (hangup) specified then negate RTS and DTR */ + /* otherwise assert RTS and DTR */ if (cflag & CBAUD) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ @@ -3212,12 +3212,12 @@ static int tiocmget(struct tty_struct *tty) get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + - ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + - ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + - ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + - ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + - ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); + result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS : 0) | + ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR : 0) | + ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR : 0) | + ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG : 0) | + ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR : 0) | + ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS : 0); if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):%s tiocmget() value=%08X\n", @@ -3272,9 +3272,9 @@ static void dtr_rts(struct tty_port *port, int on) spin_lock_irqsave(&info->lock,flags); if (on) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -4354,7 +4354,7 @@ static void reset_port(SLMP_INFO *info) tx_stop(info); rx_stop(info); - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); /* disable all port interrupts */ @@ -4750,8 +4750,8 @@ static void get_signals(SLMP_INFO *info) u16 gpstatus = read_status_reg(info); u16 testbit; - /* clear all serial signals except DTR and RTS */ - info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; + /* clear all serial signals except RTS and DTR */ + info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; /* set serial signal bits to reflect MISR */ @@ -4770,7 +4770,7 @@ static void get_signals(SLMP_INFO *info) info->serial_signals |= SerialSignal_DSR; } -/* Set the state of DTR and RTS based on contents of +/* Set the state of RTS and DTR based on contents of * serial_signals member of device context. */ static void set_signals(SLMP_INFO *info) -- cgit v1.2.3 From c420811f117a59a4a7d4e34b362437b91c7fafa1 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 25 Jan 2013 19:39:51 +0100 Subject: serial: ralink: adds support for the serial core found on ralink wisoc The MIPS based Ralink WiSoC platform has 1 or more 8250 compatible serial cores. To make them work we require the same quirks that are used by AU1x00. Signed-off-by: John Crispin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250.c | 6 +++--- drivers/tty/serial/8250/Kconfig | 8 ++++++++ include/linux/serial_core.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 24939ca3eedc..0efc815a4968 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -317,9 +317,9 @@ static void default_serial_dl_write(struct uart_8250_port *up, int value) serial_out(up, UART_DLM, value >> 8 & 0xff); } -#ifdef CONFIG_MIPS_ALCHEMY +#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) -/* Au1x00 UART hardware has a weird register layout */ +/* Au1x00/RT288x UART hardware has a weird register layout */ static const u8 au_io_in_map[] = { [UART_RX] = 0, [UART_IER] = 2, @@ -440,7 +440,7 @@ static void set_io_from_upio(struct uart_port *p) p->serial_out = mem32_serial_out; break; -#ifdef CONFIG_MIPS_ALCHEMY +#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) case UPIO_AU: p->serial_in = au_serial_in; p->serial_out = au_serial_out; diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index d31f4c63d4ba..2ef9537bcb2c 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -276,3 +276,11 @@ config SERIAL_8250_EM Selecting this option will add support for the integrated serial port hardware found on the Emma Mobile line of processors. If unsure, say N. + +config SERIAL_8250_RT288X + bool "Ralink RT288x/RT305x/RT3662/RT3883 serial port support" + depends on SERIAL_8250 && (SOC_RT288X || SOC_RT305X || SOC_RT3883) + help + If you have a Ralink RT288x/RT305x SoC based board and want to use the + serial port, say Y to this option. The driver can handle up to 2 serial + ports. If unsure, say N. diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 82aebc8ff77f..d97142159e0f 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -134,7 +134,7 @@ struct uart_port { #define UPIO_HUB6 (1) #define UPIO_MEM (2) #define UPIO_MEM32 (3) -#define UPIO_AU (4) /* Au1x00 type IO */ +#define UPIO_AU (4) /* Au1x00 and RT288x type IO */ #define UPIO_TSI (5) /* Tsi108/109 type IO */ unsigned int read_status_mask; /* driver specific */ -- cgit v1.2.3 From 4d9b109060f690f5c835130ff54165ae157b3087 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Wed, 30 Jan 2013 11:44:50 +0100 Subject: tty: Prevent deadlock in n_gsm driver This change fixes a deadlock when the multiplexer is closed while there are still client side ports open. When the multiplexer is closed and there are active tty's it tries to close them with tty_vhangup. This has a problem though, because tty_vhangup needs the tty_lock. This patch changes it to unlock the tty_lock before attempting the hangup and relocks afterwards. The additional call to tty_port_tty_set is needed because otherwise the port stays active because of the reference counter. This change also exposed another problem that other code paths don't expect that the multiplexer could have been closed. This patch also adds checks for these cases in the gsmtty_ class of function that could be called. The documentation explicitly states that "first close all virtual ports before closing the physical port" but we've found this to not always reality in our field situations. The GPRS / UTMS modem sometimes crashes and needs a power cycle in that case which means cleanly shutting down everything is not always possible. This change makes it much more robust for our situation where at least the system is recoverable with this patch and doesn't hang in a deadlock situation inside the kernel. The patch is against the long term support kernel (3.4.27) and should apply cleanly to more recent branches. Tested with a Telit GE864-QUADV2 and Telit HE910 modem. Signed-off-by: Dirkjan Bussink Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index e0f80ce0cf8f..4a43ef5d7962 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1689,6 +1689,8 @@ static inline void dlci_put(struct gsm_dlci *dlci) tty_port_put(&dlci->port); } +static void gsm_destroy_network(struct gsm_dlci *dlci); + /** * gsm_dlci_release - release DLCI * @dlci: DLCI to destroy @@ -1702,9 +1704,19 @@ static void gsm_dlci_release(struct gsm_dlci *dlci) { struct tty_struct *tty = tty_port_tty_get(&dlci->port); if (tty) { + mutex_lock(&dlci->mutex); + gsm_destroy_network(dlci); + mutex_unlock(&dlci->mutex); + + /* tty_vhangup needs the tty_lock, so unlock and + relock after doing the hangup. */ + tty_unlock(tty); tty_vhangup(tty); + tty_lock(tty); + tty_port_tty_set(&dlci->port, NULL); tty_kref_put(tty); } + dlci->state = DLCI_CLOSED; dlci_put(dlci); } @@ -2947,6 +2959,8 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp) if (dlci == NULL) return; + if (dlci->state == DLCI_CLOSED) + return; mutex_lock(&dlci->mutex); gsm_destroy_network(dlci); mutex_unlock(&dlci->mutex); @@ -2965,6 +2979,8 @@ out: static void gsmtty_hangup(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return; tty_port_hangup(&dlci->port); gsm_dlci_begin_close(dlci); } @@ -2972,9 +2988,12 @@ static void gsmtty_hangup(struct tty_struct *tty) static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf, int len) { + int sent; struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; /* Stuff the bytes into the fifo queue */ - int sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock); + sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock); /* Need to kick the channel */ gsm_dlci_data_kick(dlci); return sent; @@ -2983,18 +3002,24 @@ static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf, static int gsmtty_write_room(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; return TX_SIZE - kfifo_len(dlci->fifo); } static int gsmtty_chars_in_buffer(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; return kfifo_len(dlci->fifo); } static void gsmtty_flush_buffer(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return; /* Caution needed: If we implement reliable transport classes then the data being transmitted can't simply be junked once it has first hit the stack. Until then we can just blow it @@ -3013,6 +3038,8 @@ static void gsmtty_wait_until_sent(struct tty_struct *tty, int timeout) static int gsmtty_tiocmget(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; return dlci->modem_rx; } @@ -3022,6 +3049,8 @@ static int gsmtty_tiocmset(struct tty_struct *tty, struct gsm_dlci *dlci = tty->driver_data; unsigned int modem_tx = dlci->modem_tx; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; modem_tx &= ~clear; modem_tx |= set; @@ -3040,6 +3069,8 @@ static int gsmtty_ioctl(struct tty_struct *tty, struct gsm_netconfig nc; int index; + if (dlci->state == DLCI_CLOSED) + return -EINVAL; switch (cmd) { case GSMIOC_ENABLE_NET: if (copy_from_user(&nc, (void __user *)arg, sizeof(nc))) @@ -3066,6 +3097,9 @@ static int gsmtty_ioctl(struct tty_struct *tty, static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old) { + struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return; /* For the moment its fixed. In actual fact the speed information for the virtual channel can be propogated in both directions by the RPN control message. This however rapidly gets nasty as we @@ -3077,6 +3111,8 @@ static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old) static void gsmtty_throttle(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return; if (tty->termios.c_cflag & CRTSCTS) dlci->modem_tx &= ~TIOCM_DTR; dlci->throttled = 1; @@ -3087,6 +3123,8 @@ static void gsmtty_throttle(struct tty_struct *tty) static void gsmtty_unthrottle(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; + if (dlci->state == DLCI_CLOSED) + return; if (tty->termios.c_cflag & CRTSCTS) dlci->modem_tx |= TIOCM_DTR; dlci->throttled = 0; @@ -3098,6 +3136,8 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state) { struct gsm_dlci *dlci = tty->driver_data; int encode = 0; /* Off */ + if (dlci->state == DLCI_CLOSED) + return -EINVAL; if (state == -1) /* "On indefinitely" - we can't encode this properly */ -- cgit v1.2.3 From 183d95cdd834381c594d3aa801c1f9f9c0c54fa9 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Tue, 29 Jan 2013 20:07:41 +0100 Subject: tty: set_termios/set_termiox should not return -EINTR See https://bugzilla.redhat.com/show_bug.cgi?id=904907 read command causes bash to abort with double free or corruption (out). A simple test-case from Roman: // Compile the reproducer and send sigchld ti that process. // EINTR occurs even if SA_RESTART flag is set. void handler(int sig) { } main() { struct sigaction act; act.sa_handler = handler; act.sa_flags = SA_RESTART; sigaction (SIGCHLD, &act, 0); struct termio ttp; ioctl(0, TCGETA, &ttp); while(1) { if (ioctl(0, TCSETAW, ttp) < 0) { if (errno == EINTR) { fprintf(stderr, "BUG!"); return(1); } } } } Change set_termios/set_termiox to return -ERESTARTSYS to fix this particular problem. I didn't dare to change other EINTR's in drivers/tty/, but they look equally wrong. Reported-by: Roman Rakus Reported-by: Lingzhu Xiang Signed-off-by: Oleg Nesterov Cc: Jiri Slaby Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index cc0fc52787c7..d58b92cc187c 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -617,7 +617,7 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt) if (opt & TERMIOS_WAIT) { tty_wait_until_sent(tty, 0); if (signal_pending(current)) - return -EINTR; + return -ERESTARTSYS; } tty_set_termios(tty, &tmp_termios); @@ -684,7 +684,7 @@ static int set_termiox(struct tty_struct *tty, void __user *arg, int opt) if (opt & TERMIOS_WAIT) { tty_wait_until_sent(tty, 0); if (signal_pending(current)) - return -EINTR; + return -ERESTARTSYS; } mutex_lock(&tty->termios_mutex); -- cgit v1.2.3 From 98001214c0436c2b697d696fde3696d32620d394 Mon Sep 17 00:00:00 2001 From: Ivo Sieben Date: Mon, 28 Jan 2013 13:32:01 +0100 Subject: tty: Use raw spin lock to protect the TTY read section The "normal" spin lock that guards the N_TTY line discipline read section is replaced by a raw spin lock. On a PREEMP_RT system this prevents unwanted scheduling overhead when data is read at the same time as data is being received: while RX IRQ threaded handling is busy a TTY read call is performed from a RT priority > threaded IRQ priority. The read call tries to take the read section spin lock (held by the threaded IRQ) which blocks and causes a context switch to/from the threaded IRQ handler until the spin lock is unlocked. Signed-off-by: Ivo Sieben Reviewed-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 19083efa2314..095072899b5e 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -100,7 +100,7 @@ struct n_tty_data { struct mutex atomic_read_lock; struct mutex output_lock; struct mutex echo_lock; - spinlock_t read_lock; + raw_spinlock_t read_lock; }; static inline int tty_put_user(struct tty_struct *tty, unsigned char x, @@ -182,9 +182,9 @@ static void put_tty_queue(unsigned char c, struct n_tty_data *ldata) * The problem of stomping on the buffers ends here. * Why didn't anyone see this one coming? --AJK */ - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); put_tty_queue_nolock(c, ldata); - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); } /** @@ -218,9 +218,9 @@ static void reset_buffer_flags(struct tty_struct *tty) struct n_tty_data *ldata = tty->disc_data; unsigned long flags; - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); ldata->read_head = ldata->read_tail = ldata->read_cnt = 0; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); mutex_lock(&ldata->echo_lock); ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0; @@ -276,7 +276,7 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) unsigned long flags; ssize_t n = 0; - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); if (!ldata->icanon) { n = ldata->read_cnt; } else if (ldata->canon_data) { @@ -284,7 +284,7 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) ldata->canon_head - ldata->read_tail : ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail); } - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); return n; } @@ -915,19 +915,19 @@ static void eraser(unsigned char c, struct tty_struct *tty) kill_type = WERASE; else { if (!L_ECHO(tty)) { - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & (N_TTY_BUF_SIZE - 1)); ldata->read_head = ldata->canon_head; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); return; } if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & (N_TTY_BUF_SIZE - 1)); ldata->read_head = ldata->canon_head; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); finish_erasing(ldata); echo_char(KILL_CHAR(tty), tty); /* Add a newline if ECHOK is on and ECHOKE is off. */ @@ -961,10 +961,10 @@ static void eraser(unsigned char c, struct tty_struct *tty) break; } cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1); - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); ldata->read_head = head; ldata->read_cnt -= cnt; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); if (L_ECHO(tty)) { if (L_ECHOPRT(tty)) { if (!ldata->erasing) { @@ -1344,12 +1344,12 @@ send_signal: put_tty_queue(c, ldata); handle_newline: - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); set_bit(ldata->read_head, ldata->read_flags); put_tty_queue_nolock(c, ldata); ldata->canon_head = ldata->read_head; ldata->canon_data++; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); kill_fasync(&tty->fasync, SIGIO, POLL_IN); if (waitqueue_active(&tty->read_wait)) wake_up_interruptible(&tty->read_wait); @@ -1423,7 +1423,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, unsigned long cpuflags; if (ldata->real_raw) { - spin_lock_irqsave(&ldata->read_lock, cpuflags); + raw_spin_lock_irqsave(&ldata->read_lock, cpuflags); i = min(N_TTY_BUF_SIZE - ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_head); i = min(count, i); @@ -1439,7 +1439,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, memcpy(ldata->read_buf + ldata->read_head, cp, i); ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1); ldata->read_cnt += i; - spin_unlock_irqrestore(&ldata->read_lock, cpuflags); + raw_spin_unlock_irqrestore(&ldata->read_lock, cpuflags); } else { for (i = count, p = cp, f = fp; i; i--, p++) { if (f) @@ -1635,7 +1635,7 @@ static int n_tty_open(struct tty_struct *tty) mutex_init(&ldata->atomic_read_lock); mutex_init(&ldata->output_lock); mutex_init(&ldata->echo_lock); - spin_lock_init(&ldata->read_lock); + raw_spin_lock_init(&ldata->read_lock); /* These are ugly. Currently a malloc failure here can panic */ ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); @@ -1703,10 +1703,10 @@ static int copy_from_read_buf(struct tty_struct *tty, bool is_eof; retval = 0; - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail); n = min(*nr, n); - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); if (n) { retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n); n -= retval; @@ -1714,13 +1714,13 @@ static int copy_from_read_buf(struct tty_struct *tty, ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty); tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n, ldata->icanon); - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1); ldata->read_cnt -= n; /* Turn single EOF into zero-length read */ if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt) n = 0; - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); *b += n; *nr -= n; } @@ -1900,7 +1900,7 @@ do_it_again: if (ldata->icanon && !L_EXTPROC(tty)) { /* N.B. avoid overrun if nr == 0 */ - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); while (nr && ldata->read_cnt) { int eol; @@ -1918,25 +1918,25 @@ do_it_again: if (--ldata->canon_data < 0) ldata->canon_data = 0; } - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); if (!eol || (c != __DISABLED_CHAR)) { if (tty_put_user(tty, c, b++)) { retval = -EFAULT; b--; - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); break; } nr--; } if (eol) { tty_audit_push(tty); - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); break; } - spin_lock_irqsave(&ldata->read_lock, flags); + raw_spin_lock_irqsave(&ldata->read_lock, flags); } - spin_unlock_irqrestore(&ldata->read_lock, flags); + raw_spin_unlock_irqrestore(&ldata->read_lock, flags); if (retval) break; } else { -- cgit v1.2.3 From 16559ae48c76f1ceb970b9719dea62b77eb5d06b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 4 Feb 2013 15:35:26 -0800 Subject: kgdb: remove #include from kgdb.h There's no reason kgdb.h itself needs to include the 8250 serial port header file. So push it down to the _very_ limited number of individual drivers that need the values in that file, and fix up the places where people really wanted serial_core.h and platform_device.h. Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/gma500/cdv_intel_dp.c | 1 + drivers/tty/serial/kgdb_nmi.c | 1 + drivers/video/auo_k190x.c | 1 + drivers/video/backlight/ot200_bl.c | 1 + include/linux/kgdb.h | 1 - kernel/debug/debug_core.c | 1 + kernel/debug/gdbstub.c | 1 + 7 files changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c index 51044cc55cf2..88d9ef6b5b4a 100644 --- a/drivers/gpu/drm/gma500/cdv_intel_dp.c +++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 26a50b0c868b..5dafcf1c227b 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/video/auo_k190x.c b/drivers/video/auo_k190x.c index 97f79356141e..53846cb534d4 100644 --- a/drivers/video/auo_k190x.c +++ b/drivers/video/auo_k190x.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c index 469cf0f109d2..fdbb6ee5027c 100644 --- a/drivers/video/backlight/ot200_bl.c +++ b/drivers/video/backlight/ot200_bl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include static struct cs5535_mfgpt_timer *pwm_timer; diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 4dff0c6ed58f..c6e091bf39a5 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -13,7 +13,6 @@ #ifndef _KGDB_H_ #define _KGDB_H_ -#include #include #include #include diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 9a61738cefc8..c26278fd4851 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -29,6 +29,7 @@ */ #include #include +#include #include #include #include diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index ce615e064482..38573f35a5ad 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From 7acf6cd80b201f77371a5374a786144153629be8 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Wed, 30 Jan 2013 12:43:49 -0500 Subject: pty: Fix BUG()s when ptmx_open() errors out If pmtx_open() fails to get a slave inode or fails the pty_open(), the tty is released as part of the error cleanup. As evidenced by the first BUG stacktrace below, pty_close() assumes that the linked pty has a valid, initialized inode* stored in driver_data. Also, as evidenced by the second BUG stacktrace below, pty_unix98_shutdown() assumes that the master pty's driver_data has been initialized. 1) Fix the invalid assumption in pty_close(). 2) Initialize driver_data immediately so proper devpts fs cleanup occurs. Fixes this BUG: [ 815.868844] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 [ 815.869018] IP: [] devpts_pty_kill+0x1c/0xa0 [ 815.869190] PGD 7c775067 PUD 79deb067 PMD 0 [ 815.869315] Oops: 0000 [#1] PREEMPT SMP [ 815.869443] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi microcode snd_rawmidi psmouse serio_raw snd_seq_midi_event snd_seq snd_timer$ [ 815.870025] CPU 0 [ 815.870143] Pid: 27819, comm: stress_test_tty Tainted: G W 3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs [ 815.870386] RIP: 0010:[] [] devpts_pty_kill+0x1c/0xa0 [ 815.870540] RSP: 0018:ffff88007d3e1ac8 EFLAGS: 00010282 [ 815.870661] RAX: ffff880079c20800 RBX: 0000000000000000 RCX: 0000000000000000 [ 815.870804] RDX: ffff880079c209a8 RSI: 0000000000000286 RDI: 0000000000000000 [ 815.870933] RBP: ffff88007d3e1ae8 R08: 0000000000000000 R09: 0000000000000000 [ 815.871078] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88007bfb7e00 [ 815.871209] R13: 0000000000000005 R14: ffff880079c20c00 R15: ffff880079c20c00 [ 815.871343] FS: 00007f2e86206700(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000 [ 815.871495] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 815.871617] CR2: 0000000000000028 CR3: 000000007ae56000 CR4: 00000000000006f0 [ 815.871752] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 815.871902] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 815.872012] Process stress_test_tty (pid: 27819, threadinfo ffff88007d3e0000, task ffff88007c874530) [ 815.872012] Stack: [ 815.872012] ffff88007bfb7e00 ffff880079c20c00 ffff88007bfb7e00 0000000000000005 [ 815.872012] ffff88007d3e1b08 ffffffff81417be7 ffff88007caa9bd8 ffff880079c20800 [ 815.872012] ffff88007d3e1bc8 ffffffff8140e5f8 0000000000000000 0000000000000000 [ 815.872012] Call Trace: [ 815.872012] [] pty_close+0x157/0x170 [ 815.872012] [] tty_release+0x138/0x580 [ 815.872012] [] ? _raw_spin_lock+0x23/0x30 [ 815.872012] [] ? _raw_spin_unlock+0x1a/0x40 [ 815.872012] [] ? __mutex_unlock_slowpath+0x48/0x60 [ 815.872012] [] ptmx_open+0x11f/0x180 [ 815.872012] [] chrdev_open+0x9b/0x1c0 [ 815.872012] [] do_dentry_open+0x203/0x290 [ 815.872012] [] ? cdev_put+0x30/0x30 [ 815.872012] [] finish_open+0x35/0x50 [ 815.872012] [] do_last+0x6fe/0xe90 [ 815.872012] [] ? link_path_walk+0x7f/0x880 [ 815.872012] [] ? cpuacct_charge+0x75/0x80 [ 815.872012] [] path_openat+0xbc/0x4e0 [ 815.872012] [] ? __schedule+0x400/0x7f0 [ 815.872012] [] ? tty_release+0x496/0x580 [ 815.872012] [] do_filp_open+0x41/0xa0 [ 815.872012] [] ? _raw_spin_unlock+0x1a/0x40 [ 815.872012] [] ? __alloc_fd+0xe9/0x140 [ 815.872012] [] do_sys_open+0xf4/0x1e0 [ 815.872012] [] sys_open+0x21/0x30 [ 815.872012] [] system_call_fastpath+0x16/0x1b [ 815.872012] Code: 0f 1f 80 00 00 00 00 45 31 e4 eb d7 0f 0b 90 0f 1f 44 00 00 55 48 89 e5 48 83 ec 20 48 89 5d e8 48 89 fb 4c 89 65 f0 4c 89 6d f8 <48> 8b 47 28 48 81 78 58 d1 1c 0$ [ 815.872012] RIP [] devpts_pty_kill+0x1c/0xa0 [ 815.872012] RSP [ 815.872012] CR2: 0000000000000028 [ 815.897036] ---[ end trace eadf50b7f34e47d5 ]--- Fixes this BUG also: [ 608.366836] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 [ 608.366948] IP: [] devpts_kill_index+0x18/0x70 [ 608.367050] PGD 7c75b067 PUD 7b919067 PMD 0 [ 608.367135] Oops: 0000 [#1] PREEMPT SMP [ 608.367201] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event microcode snd_seq psmouse snd_timer snd_seq_device serio_raw snd mac_hid soundcore snd_page_alloc rfcomm virtio_balloon parport_pc bnep bluetooth ppdev i2c_piix4 lp parport floppy [ 608.367617] CPU 2 [ 608.367669] Pid: 1918, comm: stress_test_tty Tainted: G W 3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs [ 608.367796] RIP: 0010:[] [] devpts_kill_index+0x18/0x70 [ 608.367885] RSP: 0018:ffff88007ae41a88 EFLAGS: 00010286 [ 608.367951] RAX: ffffffff81417e80 RBX: ffff880036472400 RCX: 0000000180400028 [ 608.368010] RDX: ffff880036470004 RSI: 0000000000000004 RDI: 0000000000000000 [ 608.368010] RBP: ffff88007ae41a98 R08: 0000000000000000 R09: 0000000000000001 [ 608.368010] R10: ffffea0001f22e40 R11: ffffffff814151d5 R12: 0000000000000004 [ 608.368010] R13: ffff880036470000 R14: 0000000000000004 R15: ffff880036472400 [ 608.368010] FS: 00007ff7a5268700(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000 [ 608.368010] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 608.368010] CR2: 0000000000000028 CR3: 000000007a0fd000 CR4: 00000000000006e0 [ 608.368010] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 608.368010] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 608.368010] Process stress_test_tty (pid: 1918, threadinfo ffff88007ae40000, task ffff88003688dc40) [ 608.368010] Stack: [ 608.368010] ffff880036472400 0000000000000001 ffff88007ae41aa8 ffffffff81417e98 [ 608.368010] ffff88007ae41ac8 ffffffff8140c42b ffff88007ac73100 ffff88007ac73100 [ 608.368010] ffff88007ae41b98 ffffffff8140ead5 ffff88007ae41b38 ffff88007ca40e40 [ 608.368010] Call Trace: [ 608.368010] [] pty_unix98_shutdown+0x18/0x20 [ 608.368010] [] release_tty+0x3b/0xe0 [ 608.368010] [] __tty_release+0x575/0x5d0 [ 608.368010] [] ? _raw_spin_lock+0x23/0x30 [ 608.368010] [] ? _raw_spin_unlock+0x1a/0x40 [ 608.368010] [] ? __mutex_unlock_slowpath+0x48/0x60 [ 608.368010] [] tty_open+0x449/0x5f0 [ 608.368010] [] chrdev_open+0x9b/0x1c0 [ 608.368010] [] do_dentry_open+0x203/0x290 [ 608.368010] [] ? cdev_put+0x30/0x30 [ 608.368010] [] finish_open+0x35/0x50 [ 608.368010] [] do_last+0x6fe/0xe90 [ 608.368010] [] ? link_path_walk+0x7f/0x880 [ 608.368010] [] path_openat+0xbc/0x4e0 [ 608.368010] [] do_filp_open+0x41/0xa0 [ 608.368010] [] ? _raw_spin_unlock+0x1a/0x40 [ 608.368010] [] ? __alloc_fd+0xe9/0x140 [ 608.368010] [] do_sys_open+0xf4/0x1e0 [ 608.368010] [] ? _raw_spin_lock+0x23/0x30 [ 608.368010] [] sys_open+0x21/0x30 [ 608.368010] [] system_call_fastpath+0x16/0x1b [ 608.368010] Code: ec 48 83 c4 10 5b 41 5c 5d c3 66 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 48 83 ec 10 4c 89 65 f8 41 89 f4 48 89 5d f0 <48> 8b 47 28 48 81 78 58 d1 1c 00 00 74 0b 48 8b 05 4b 66 cf 00 [ 608.368010] RIP [] devpts_kill_index+0x18/0x70 [ 608.368010] RSP [ 608.368010] CR2: 0000000000000028 [ 608.394153] ---[ end trace afe83b0fb5fbda93 ]--- Reported-by: Ilya Zykov Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 755600f6120f..96dc6dd31425 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -55,7 +55,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp) #ifdef CONFIG_UNIX98_PTYS if (tty->driver == ptm_driver) { mutex_lock(&devpts_mutex); - devpts_pty_kill(tty->link->driver_data); + if (tty->link->driver_data) + devpts_pty_kill(tty->link->driver_data); mutex_unlock(&devpts_mutex); } #endif @@ -703,6 +704,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) mutex_unlock(&tty_mutex); set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ + tty->driver_data = inode; tty_add_file(tty, filp); @@ -713,14 +715,13 @@ static int ptmx_open(struct inode *inode, struct file *filp) retval = PTR_ERR(slave_inode); goto err_release; } + tty->link->driver_data = slave_inode; retval = ptm_driver->ops->open(tty, filp); if (retval) goto err_release; tty_unlock(tty); - tty->driver_data = inode; - tty->link->driver_data = slave_inode; return 0; err_release: tty_unlock(tty); -- cgit v1.2.3 From 699390354da6c258b65bf8fa79cfd5feaede50b6 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Wed, 30 Jan 2013 12:43:50 -0500 Subject: pty: Ignore slave pty close() if never successfully opened If the master and slave ptys are opened in parallel, the slave open fails because the pty is still locked. This is as designed. However, pty_close() is still called for the slave pty which sets TTY_OTHER_CLOSED in the master pty. This can cause the master open to fail as well. Use a common pattern in other tty drivers by setting TTY_IO_ERROR until the open is successful and only closing the pty if not set. Note: the master pty always closes regardless of whether the open was successful, so that proper cleanup can occur. Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 96dc6dd31425..d38455fab4b7 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -38,9 +38,12 @@ static void pty_close(struct tty_struct *tty, struct file *filp) if (tty->driver->subtype == PTY_TYPE_MASTER) WARN_ON(tty->count > 1); else { + if (test_bit(TTY_IO_ERROR, &tty->flags)) + return; if (tty->count > 2) return; } + set_bit(TTY_IO_ERROR, &tty->flags); wake_up_interruptible(&tty->read_wait); wake_up_interruptible(&tty->write_wait); tty->packet = 0; @@ -246,6 +249,8 @@ static int pty_open(struct tty_struct *tty, struct file *filp) if (!tty || !tty->link) goto out; + set_bit(TTY_IO_ERROR, &tty->flags); + retval = -EIO; if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) goto out; @@ -254,6 +259,7 @@ static int pty_open(struct tty_struct *tty, struct file *filp) if (tty->link->count != 1) goto out; + clear_bit(TTY_IO_ERROR, &tty->flags); clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); set_bit(TTY_THROTTLED, &tty->flags); retval = 0; -- cgit v1.2.3 From 80cace72566633bb99da1f022f71d3dac3498b02 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Wed, 30 Jan 2013 12:43:52 -0500 Subject: pty: Ignore slave open count for master pty open Multiple slave pty opens may be performed in parallel with the master open. Of course, all the slave opens will fail because the master pty is still locked but during this time the slave pty count will be artificially greater than 1. This is should not cause the master pty open to fail. Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/tty/pty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d38455fab4b7..c24b4db243b9 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -256,7 +256,7 @@ static int pty_open(struct tty_struct *tty, struct file *filp) goto out; if (test_bit(TTY_PTY_LOCK, &tty->link->flags)) goto out; - if (tty->link->count != 1) + if (tty->driver->subtype == PTY_TYPE_SLAVE && tty->link->count != 1) goto out; clear_bit(TTY_IO_ERROR, &tty->flags); -- cgit v1.2.3 From f26402e81743d06b938a388925904bd47763277a Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 31 Jan 2013 12:01:53 -0700 Subject: tty: of_serial: unexport tegra_serial_handle_break Tegra is only booted through device-tree now; there are no board files left that use this function. Hence, don't export it. Move the static inline definition into of_serial.c, so we can delete of_serial.h too. Signed-off-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/of_serial.c | 7 ++++--- include/linux/of_serial.h | 17 ----------------- 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 include/linux/of_serial.h (limited to 'drivers') diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index e7cae1c2d7d2..d5874605682b 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -45,8 +44,10 @@ void tegra_serial_handle_break(struct uart_port *p) udelay(1); } while (1); } -/* FIXME remove this export when tegra finishes conversion to open firmware */ -EXPORT_SYMBOL_GPL(tegra_serial_handle_break); +#else +static inline void tegra_serial_handle_break(struct uart_port *port) +{ +} #endif /* diff --git a/include/linux/of_serial.h b/include/linux/of_serial.h deleted file mode 100644 index 4a73ed80b4c0..000000000000 --- a/include/linux/of_serial.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __LINUX_OF_SERIAL_H -#define __LINUX_OF_SERIAL_H - -/* - * FIXME remove this file when tegra finishes conversion to open firmware, - * expectation is that all quirks will then be self-contained in - * drivers/tty/serial/of_serial.c. - */ -#ifdef CONFIG_ARCH_TEGRA -extern void tegra_serial_handle_break(struct uart_port *port); -#else -static inline void tegra_serial_handle_break(struct uart_port *port) -{ -} -#endif - -#endif /* __LINUX_OF_SERIAL */ -- cgit v1.2.3 From 1776fd059c40907297d6c26c51876575d63fd9e2 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Mon, 4 Feb 2013 12:19:46 -0500 Subject: OMAP/serial: Fix incorrect Rx FIFO threshold setting, LSR validation on Tx, and Tx FIFO IRQ generation Original configuration of Rx FIFO threshold contained an error that resulted Rx threshold to be effectively set to 1 character instead of 16 characters, as noted in comments. Checking LSR to contain UART_LSR_THRE bit set caused issue when not all UART_IER_THRI interrupts have been properly handled. This caused gap in Tx data, visible on high baud rates using oscilloscope. Setting OMAP_UART_SCR_TX_EMPTY bit in SCR caused UART_IER_THRI interrupt to be raised only when Tx FIFO and Tx shift registers are empty. Signed-off-by: Alexey Pelykh Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/omap-serial.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 9915e4d1418c..4dc41408ecb7 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -59,6 +59,7 @@ /* SCR register bitmasks */ #define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK (1 << 7) +#define OMAP_UART_SCR_TX_TRIG_GRANU1_MASK (1 << 6) #define OMAP_UART_SCR_TX_EMPTY (1 << 3) /* FCR register bitmasks */ @@ -320,9 +321,6 @@ static void transmit_chars(struct uart_omap_port *up, unsigned int lsr) struct circ_buf *xmit = &up->port.state->xmit; int count; - if (!(lsr & UART_LSR_THRE)) - return; - if (up->port.x_char) { serial_out(up, UART_TX, up->port.x_char); up->port.icount.tx++; @@ -864,7 +862,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, serial_out(up, UART_IER, up->ier); serial_out(up, UART_LCR, cval); /* reset DLAB */ up->lcr = cval; - up->scr = OMAP_UART_SCR_TX_EMPTY; + up->scr = 0; /* FIFOs and DMA Settings */ @@ -888,8 +886,6 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); /* FIFO ENABLE, DMA MODE */ - up->scr |= OMAP_UART_SCR_RX_TRIG_GRANU1_MASK; - /* Set receive FIFO threshold to 16 characters and * transmit FIFO threshold to 16 spaces */ -- cgit v1.2.3 From 61bc65599f8118fc53975670f19c37fe2be92a3d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 5 Feb 2013 18:07:42 +0100 Subject: tty: serial: altera_uart: Simplify altera_uart_init() No need for two separate return statements, consolidate them. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/altera_uart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index e133c8814bb5..13471dd95793 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c @@ -637,11 +637,9 @@ static int __init altera_uart_init(void) if (rc) return rc; rc = platform_driver_register(&altera_uart_platform_driver); - if (rc) { + if (rc) uart_unregister_driver(&altera_uart_driver); - return rc; - } - return 0; + return rc; } static void __exit altera_uart_exit(void) -- cgit v1.2.3 From b16ea4b04c3b74524805a409ee2747b751b7a138 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 5 Feb 2013 18:07:22 +0100 Subject: tty: serial: altera_jtaguart: Simplify altera_jtaguart_init() No need for two separate return statements, consolidate them. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/altera_jtaguart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c index 84b90fd48063..c6bdb943726b 100644 --- a/drivers/tty/serial/altera_jtaguart.c +++ b/drivers/tty/serial/altera_jtaguart.c @@ -493,11 +493,9 @@ static int __init altera_jtaguart_init(void) if (rc) return rc; rc = platform_driver_register(&altera_jtaguart_platform_driver); - if (rc) { + if (rc) uart_unregister_driver(&altera_jtaguart_driver); - return rc; - } - return 0; + return rc; } static void __exit altera_jtaguart_exit(void) -- cgit v1.2.3 From cdc8da3998dcc50cee2f81904c16ebdbd7ec2cee Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 5 Feb 2013 16:12:31 -0200 Subject: serial: imx: Move imx_port_ucrs_save/restore under CONFIG_CONSOLE_POLL If CONFIG_CONSOLE_POLL is not defined, the following build warning happens: drivers/tty/serial/imx.c:274:13: warning: 'imx_port_ucrs_save' defined but not used [-Wunused-function] drivers/tty/serial/imx.c:283:13: warning: 'imx_port_ucrs_restore' defined but not used [-Wunused-function] Move imx_port_ucrs_saver/restore under CONFIG_CONSOLE_POLL ifdef block to fix it. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a220f77ceab6..a657f966b852 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -268,27 +268,6 @@ static inline int is_imx21_uart(struct imx_port *sport) return sport->devdata->devtype == IMX21_UART; } -/* - * Save and restore functions for UCR1, UCR2 and UCR3 registers - */ -static void imx_port_ucrs_save(struct uart_port *port, - struct imx_port_ucrs *ucr) -{ - /* save control registers */ - ucr->ucr1 = readl(port->membase + UCR1); - ucr->ucr2 = readl(port->membase + UCR2); - ucr->ucr3 = readl(port->membase + UCR3); -} - -static void imx_port_ucrs_restore(struct uart_port *port, - struct imx_port_ucrs *ucr) -{ - /* restore control registers */ - writel(ucr->ucr1, port->membase + UCR1); - writel(ucr->ucr2, port->membase + UCR2); - writel(ucr->ucr3, port->membase + UCR3); -} - /* * Handle any change of modem status signal since we were last called. */ @@ -1103,6 +1082,27 @@ imx_verify_port(struct uart_port *port, struct serial_struct *ser) } #if defined(CONFIG_CONSOLE_POLL) +/* + * Save and restore functions for UCR1, UCR2 and UCR3 registers + */ +static void imx_port_ucrs_save(struct uart_port *port, + struct imx_port_ucrs *ucr) +{ + /* save control registers */ + ucr->ucr1 = readl(port->membase + UCR1); + ucr->ucr2 = readl(port->membase + UCR2); + ucr->ucr3 = readl(port->membase + UCR3); +} + +static void imx_port_ucrs_restore(struct uart_port *port, + struct imx_port_ucrs *ucr) +{ + /* restore control registers */ + writel(ucr->ucr1, port->membase + UCR1); + writel(ucr->ucr2, port->membase + UCR2); + writel(ucr->ucr3, port->membase + UCR3); +} + static int imx_poll_get_char(struct uart_port *port) { struct imx_port_ucrs old_ucr; -- cgit v1.2.3 From 8200e38a0cbf95dd2acaa565badb9b6a71c0e9c3 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 6 Feb 2013 14:45:01 +0000 Subject: tty: metag_da: Add metag DA TTY driver Add a TTY driver for communicating over a Meta DA (Debug Adapter) channel using the bios channel SWITCH operation. Signed-off-by: James Hogan Cc: Jiri Slaby Acked-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/tty/Kconfig | 13 + drivers/tty/Makefile | 1 + drivers/tty/metag_da.c | 680 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 694 insertions(+) create mode 100644 drivers/tty/metag_da.c (limited to 'drivers') diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 29dfc24f2dbb..978db344bda0 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -406,4 +406,17 @@ config GOLDFISH_TTY help Console and system TTY driver for the Goldfish virtual platform. +config DA_TTY + bool "DA TTY" + depends on METAG_DA + select SERIAL_NONSTANDARD + help + This enables a TTY on a Dash channel. + +config DA_CONSOLE + bool "DA Console" + depends on DA_TTY + help + This enables a console on a Dash channel. + endif # TTY diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index 35649d35abf0..6b78399bc7c9 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -28,5 +28,6 @@ obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o obj-$(CONFIG_SYNCLINK) += synclink.o obj-$(CONFIG_PPC_EPAPR_HV_BYTECHAN) += ehv_bytechan.o obj-$(CONFIG_GOLDFISH_TTY) += goldfish.o +obj-$(CONFIG_DA_TTY) += metag_da.o obj-y += ipwireless/ diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c new file mode 100644 index 000000000000..fc2a36bddd3f --- /dev/null +++ b/drivers/tty/metag_da.c @@ -0,0 +1,680 @@ +/* + * dashtty.c - tty driver for Dash channels interface. + * + * Copyright (C) 2007,2008,2012 Imagination Technologies + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Channel error codes */ +#define CONAOK 0 +#define CONERR 1 +#define CONBAD 2 +#define CONPRM 3 +#define CONADR 4 +#define CONCNT 5 +#define CONCBF 6 +#define CONCBE 7 +#define CONBSY 8 + +/* Default channel for the console */ +#define CONSOLE_CHANNEL 1 + +#define NUM_TTY_CHANNELS 6 + +/* Auto allocate */ +#define DA_TTY_MAJOR 0 + +/* A speedy poll rate helps the userland debug process connection response. + * But, if you set it too high then no other userland processes get much + * of a look in. + */ +#define DA_TTY_POLL (HZ / 50) + +/* + * A short put delay improves latency but has a high throughput overhead + */ +#define DA_TTY_PUT_DELAY (HZ / 100) + +static atomic_t num_channels_need_poll = ATOMIC_INIT(0); + +static struct timer_list poll_timer; + +static struct tty_driver *channel_driver; + +static struct timer_list put_timer; +static struct task_struct *dashtty_thread; + +#define RX_BUF_SIZE 1024 + +enum { + INCHR = 1, + OUTCHR, + RDBUF, + WRBUF, + RDSTAT +}; + +/** + * struct dashtty_port - Wrapper struct for dashtty tty_port. + * @port: TTY port data + * @rx_lock: Lock for rx_buf. + * This protects between the poll timer and user context. + * It's also held during read SWITCH operations. + * @rx_buf: Read buffer + * @xmit_lock: Lock for xmit_*, and port.xmit_buf. + * This protects between user context and kernel thread. + * It's also held during write SWITCH operations. + * @xmit_cnt: Size of xmit buffer contents + * @xmit_head: Head of xmit buffer where data is written + * @xmit_tail: Tail of xmit buffer where data is read + * @xmit_empty: Completion for xmit buffer being empty + */ +struct dashtty_port { + struct tty_port port; + spinlock_t rx_lock; + void *rx_buf; + struct mutex xmit_lock; + unsigned int xmit_cnt; + unsigned int xmit_head; + unsigned int xmit_tail; + struct completion xmit_empty; +}; + +static struct dashtty_port dashtty_ports[NUM_TTY_CHANNELS]; + +static atomic_t dashtty_xmit_cnt = ATOMIC_INIT(0); +static wait_queue_head_t dashtty_waitqueue; + +/* + * Low-level DA channel access routines + */ +static int chancall(int in_bios_function, int in_channel, + int in_arg2, void *in_arg3, + void *in_arg4) +{ + register int bios_function asm("D1Ar1") = in_bios_function; + register int channel asm("D0Ar2") = in_channel; + register int arg2 asm("D1Ar3") = in_arg2; + register void *arg3 asm("D0Ar4") = in_arg3; + register void *arg4 asm("D1Ar5") = in_arg4; + register int bios_call asm("D0Ar6") = 3; + register int result asm("D0Re0"); + + asm volatile ( + "MSETL [A0StP++], %6,%4,%2\n\t" + "ADD A0StP, A0StP, #8\n\t" + "SWITCH #0x0C30208\n\t" + "GETD %0, [A0StP+#-8]\n\t" + "SUB A0StP, A0StP, #(4*6)+8\n\t" + : "=d" (result) /* outs */ + : "d" (bios_function), + "d" (channel), + "d" (arg2), + "d" (arg3), + "d" (arg4), + "d" (bios_call) /* ins */ + : "memory"); + + return result; +} + +/* + * Attempts to fetch count bytes from channel and returns actual count. + */ +static int fetch_data(struct tty_struct *tty) +{ + unsigned int channel = tty->index; + struct dashtty_port *dport = &dashtty_ports[channel]; + int received = 0; + + spin_lock_bh(&dport->rx_lock); + /* check the port isn't being shut down */ + if (!dport->rx_buf) + goto unlock; + if (chancall(RDBUF, channel, RX_BUF_SIZE, + (void *)dport->rx_buf, &received) == CONAOK) { + if (received) { + int space; + unsigned char *cbuf; + + space = tty_prepare_flip_string(&dport->port, &cbuf, + received); + + if (space <= 0) + goto unlock; + + memcpy(cbuf, dport->rx_buf, space); + tty_flip_buffer_push(&dport->port); + } + } +unlock: + spin_unlock_bh(&dport->rx_lock); + + return received; +} + +/** + * find_channel_to_poll() - Returns kref to the next channel tty to poll. + * Returns: The TTY of the next channel to poll, or NULL if no TTY needs + * polling. Release with tty_kref_put(). + */ +static struct tty_struct *find_channel_to_poll(void) +{ + static int last_polled_channel; + int last = last_polled_channel; + int chan; + struct tty_struct *tty = NULL; + + for (chan = last + 1; ; ++chan) { + if (chan >= NUM_TTY_CHANNELS) + chan = 0; + + tty = tty_port_tty_get(&dashtty_ports[chan].port); + if (tty) { + last_polled_channel = chan; + return tty; + } + + if (chan == last) + break; + } + return tty; +} + +/** + * put_channel_data() - Write out a block of channel data. + * @chan: DA channel number. + * + * Write a single block of data out to the debug adapter. If the circular buffer + * is wrapped then only the first block is written. + * + * Returns: 1 if the remote buffer was too full to accept data. + * 0 otherwise. + */ +static int put_channel_data(unsigned int chan) +{ + struct dashtty_port *dport; + struct tty_struct *tty; + int number_written; + unsigned int count = 0; + + dport = &dashtty_ports[chan]; + mutex_lock(&dport->xmit_lock); + if (dport->xmit_cnt) { + count = min((unsigned int)(SERIAL_XMIT_SIZE - dport->xmit_tail), + dport->xmit_cnt); + chancall(WRBUF, chan, count, + dport->port.xmit_buf + dport->xmit_tail, + &number_written); + dport->xmit_cnt -= number_written; + if (!dport->xmit_cnt) { + /* reset pointers to avoid wraps */ + dport->xmit_head = 0; + dport->xmit_tail = 0; + complete(&dport->xmit_empty); + } else { + dport->xmit_tail += number_written; + if (dport->xmit_tail >= SERIAL_XMIT_SIZE) + dport->xmit_tail -= SERIAL_XMIT_SIZE; + } + atomic_sub(number_written, &dashtty_xmit_cnt); + } + mutex_unlock(&dport->xmit_lock); + + /* if we've made more data available, wake up tty */ + if (count && number_written) { + tty = tty_port_tty_get(&dport->port); + if (tty) { + tty_wakeup(tty); + tty_kref_put(tty); + } + } + + /* did the write fail? */ + return count && !number_written; +} + +/** + * put_data() - Kernel thread to write out blocks of channel data to DA. + * @arg: Unused. + * + * This kernel thread runs while @dashtty_xmit_cnt != 0, and loops over the + * channels to write out any buffered data. If any of the channels stall due to + * the remote buffer being full, a hold off happens to allow the debugger to + * drain the buffer. + */ +static int put_data(void *arg) +{ + unsigned int chan, stall; + + __set_current_state(TASK_RUNNING); + while (!kthread_should_stop()) { + /* + * For each channel see if there's anything to transmit in the + * port's xmit_buf. + */ + stall = 0; + for (chan = 0; chan < NUM_TTY_CHANNELS; ++chan) + stall += put_channel_data(chan); + + /* + * If some of the buffers are full, hold off for a short while + * to allow them to empty. + */ + if (stall) + msleep(25); + + wait_event_interruptible(dashtty_waitqueue, + atomic_read(&dashtty_xmit_cnt)); + } + + return 0; +} + +/* + * This gets called every DA_TTY_POLL and polls the channels for data + */ +static void dashtty_timer(unsigned long ignored) +{ + struct tty_struct *tty; + + /* If there are no ports open do nothing and don't poll again. */ + if (!atomic_read(&num_channels_need_poll)) + return; + + tty = find_channel_to_poll(); + + /* Did we find a channel to poll? */ + if (tty) { + fetch_data(tty); + tty_kref_put(tty); + } + + mod_timer_pinned(&poll_timer, jiffies + DA_TTY_POLL); +} + +static void add_poll_timer(struct timer_list *poll_timer) +{ + setup_timer(poll_timer, dashtty_timer, 0); + poll_timer->expires = jiffies + DA_TTY_POLL; + + /* + * Always attach the timer to the boot CPU. The DA channels are per-CPU + * so all polling should be from a single CPU. + */ + add_timer_on(poll_timer, 0); +} + +static int dashtty_port_activate(struct tty_port *port, struct tty_struct *tty) +{ + struct dashtty_port *dport = container_of(port, struct dashtty_port, + port); + void *rx_buf; + + /* Allocate the buffer we use for writing data */ + if (tty_port_alloc_xmit_buf(port) < 0) + goto err; + + /* Allocate the buffer we use for reading data */ + rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL); + if (!rx_buf) + goto err_free_xmit; + + spin_lock_bh(&dport->rx_lock); + dport->rx_buf = rx_buf; + spin_unlock_bh(&dport->rx_lock); + + /* + * Don't add the poll timer if we're opening a console. This + * avoids the overhead of polling the Dash but means it is not + * possible to have a login on /dev/console. + * + */ + if (dport != &dashtty_ports[CONSOLE_CHANNEL]) + if (atomic_inc_return(&num_channels_need_poll) == 1) + add_poll_timer(&poll_timer); + + return 0; +err_free_xmit: + tty_port_free_xmit_buf(port); +err: + return -ENOMEM; +} + +static void dashtty_port_shutdown(struct tty_port *port) +{ + struct dashtty_port *dport = container_of(port, struct dashtty_port, + port); + void *rx_buf; + unsigned int count; + + /* stop reading */ + if (dport != &dashtty_ports[CONSOLE_CHANNEL]) + if (atomic_dec_and_test(&num_channels_need_poll)) + del_timer_sync(&poll_timer); + + mutex_lock(&dport->xmit_lock); + count = dport->xmit_cnt; + mutex_unlock(&dport->xmit_lock); + if (count) { + /* + * There's still data to write out, so wake and wait for the + * writer thread to drain the buffer. + */ + del_timer(&put_timer); + wake_up_interruptible(&dashtty_waitqueue); + wait_for_completion(&dport->xmit_empty); + } + + /* Null the read buffer (timer could still be running!) */ + spin_lock_bh(&dport->rx_lock); + rx_buf = dport->rx_buf; + dport->rx_buf = NULL; + spin_unlock_bh(&dport->rx_lock); + /* Free the read buffer */ + kfree(rx_buf); + + /* Free the write buffer */ + tty_port_free_xmit_buf(port); +} + +static const struct tty_port_operations dashtty_port_ops = { + .activate = dashtty_port_activate, + .shutdown = dashtty_port_shutdown, +}; + +static int dashtty_install(struct tty_driver *driver, struct tty_struct *tty) +{ + return tty_port_install(&dashtty_ports[tty->index].port, driver, tty); +} + +static int dashtty_open(struct tty_struct *tty, struct file *filp) +{ + return tty_port_open(tty->port, tty, filp); +} + +static void dashtty_close(struct tty_struct *tty, struct file *filp) +{ + return tty_port_close(tty->port, tty, filp); +} + +static void dashtty_hangup(struct tty_struct *tty) +{ + int channel; + struct dashtty_port *dport; + + channel = tty->index; + dport = &dashtty_ports[channel]; + + /* drop any data in the xmit buffer */ + mutex_lock(&dport->xmit_lock); + if (dport->xmit_cnt) { + atomic_sub(dport->xmit_cnt, &dashtty_xmit_cnt); + dport->xmit_cnt = 0; + dport->xmit_head = 0; + dport->xmit_tail = 0; + complete(&dport->xmit_empty); + } + mutex_unlock(&dport->xmit_lock); + + tty_port_hangup(tty->port); +} + +/** + * dashtty_put_timer() - Delayed wake up of kernel thread. + * @ignored: unused + * + * This timer function wakes up the kernel thread if any data exists in the + * buffers. It is used to delay the expensive writeout until the writer has + * stopped writing. + */ +static void dashtty_put_timer(unsigned long ignored) +{ + if (atomic_read(&dashtty_xmit_cnt)) + wake_up_interruptible(&dashtty_waitqueue); +} + +static int dashtty_write(struct tty_struct *tty, const unsigned char *buf, + int total) +{ + int channel, count, block; + struct dashtty_port *dport; + + /* Determine the channel */ + channel = tty->index; + dport = &dashtty_ports[channel]; + + /* + * Write to output buffer. + * + * The reason that we asynchronously write the buffer is because if we + * were to write the buffer synchronously then because DA channels are + * per-CPU the buffer would be written to the channel of whatever CPU + * we're running on. + * + * What we actually want to happen is have all input and output done on + * one CPU. + */ + mutex_lock(&dport->xmit_lock); + /* work out how many bytes we can write to the xmit buffer */ + total = min(total, (int)(SERIAL_XMIT_SIZE - dport->xmit_cnt)); + atomic_add(total, &dashtty_xmit_cnt); + dport->xmit_cnt += total; + /* write the actual bytes (may need splitting if it wraps) */ + for (count = total; count; count -= block) { + block = min(count, (int)(SERIAL_XMIT_SIZE - dport->xmit_head)); + memcpy(dport->port.xmit_buf + dport->xmit_head, buf, block); + dport->xmit_head += block; + if (dport->xmit_head >= SERIAL_XMIT_SIZE) + dport->xmit_head -= SERIAL_XMIT_SIZE; + buf += block; + } + count = dport->xmit_cnt; + /* xmit buffer no longer empty? */ + if (count) + INIT_COMPLETION(dport->xmit_empty); + mutex_unlock(&dport->xmit_lock); + + if (total) { + /* + * If the buffer is full, wake up the kthread, otherwise allow + * some more time for the buffer to fill up a bit before waking + * it. + */ + if (count == SERIAL_XMIT_SIZE) { + del_timer(&put_timer); + wake_up_interruptible(&dashtty_waitqueue); + } else { + mod_timer(&put_timer, jiffies + DA_TTY_PUT_DELAY); + } + } + return total; +} + +static int dashtty_write_room(struct tty_struct *tty) +{ + struct dashtty_port *dport; + int channel; + int room; + + channel = tty->index; + dport = &dashtty_ports[channel]; + + /* report the space in the xmit buffer */ + mutex_lock(&dport->xmit_lock); + room = SERIAL_XMIT_SIZE - dport->xmit_cnt; + mutex_unlock(&dport->xmit_lock); + + return room; +} + +static int dashtty_chars_in_buffer(struct tty_struct *tty) +{ + struct dashtty_port *dport; + int channel; + int chars; + + channel = tty->index; + dport = &dashtty_ports[channel]; + + /* report the number of bytes in the xmit buffer */ + mutex_lock(&dport->xmit_lock); + chars = dport->xmit_cnt; + mutex_unlock(&dport->xmit_lock); + + return chars; +} + +static const struct tty_operations dashtty_ops = { + .install = dashtty_install, + .open = dashtty_open, + .close = dashtty_close, + .hangup = dashtty_hangup, + .write = dashtty_write, + .write_room = dashtty_write_room, + .chars_in_buffer = dashtty_chars_in_buffer, +}; + +static int __init dashtty_init(void) +{ + int ret; + int nport; + struct dashtty_port *dport; + + if (!metag_da_enabled()) + return -ENODEV; + + channel_driver = tty_alloc_driver(NUM_TTY_CHANNELS, + TTY_DRIVER_REAL_RAW); + if (IS_ERR(channel_driver)) + return PTR_ERR(channel_driver); + + channel_driver->driver_name = "metag_da"; + channel_driver->name = "ttyDA"; + channel_driver->major = DA_TTY_MAJOR; + channel_driver->minor_start = 0; + channel_driver->type = TTY_DRIVER_TYPE_SERIAL; + channel_driver->subtype = SERIAL_TYPE_NORMAL; + channel_driver->init_termios = tty_std_termios; + channel_driver->init_termios.c_cflag |= CLOCAL; + + tty_set_operations(channel_driver, &dashtty_ops); + for (nport = 0; nport < NUM_TTY_CHANNELS; nport++) { + dport = &dashtty_ports[nport]; + tty_port_init(&dport->port); + dport->port.ops = &dashtty_port_ops; + spin_lock_init(&dport->rx_lock); + mutex_init(&dport->xmit_lock); + /* the xmit buffer starts empty, i.e. completely written */ + init_completion(&dport->xmit_empty); + complete(&dport->xmit_empty); + } + + setup_timer(&put_timer, dashtty_put_timer, 0); + + init_waitqueue_head(&dashtty_waitqueue); + dashtty_thread = kthread_create(put_data, NULL, "ttyDA"); + if (IS_ERR(dashtty_thread)) { + pr_err("Couldn't create dashtty thread\n"); + ret = PTR_ERR(dashtty_thread); + goto err_destroy_ports; + } + /* + * Bind the writer thread to the boot CPU so it can't migrate. + * DA channels are per-CPU and we want all channel I/O to be on a single + * predictable CPU. + */ + kthread_bind(dashtty_thread, 0); + wake_up_process(dashtty_thread); + + ret = tty_register_driver(channel_driver); + + if (ret < 0) { + pr_err("Couldn't install dashtty driver: err %d\n", + ret); + goto err_stop_kthread; + } + + return 0; + +err_stop_kthread: + kthread_stop(dashtty_thread); +err_destroy_ports: + for (nport = 0; nport < NUM_TTY_CHANNELS; nport++) { + dport = &dashtty_ports[nport]; + tty_port_destroy(&dport->port); + } + put_tty_driver(channel_driver); + return ret; +} + +static void dashtty_exit(void) +{ + int nport; + struct dashtty_port *dport; + + del_timer_sync(&put_timer); + kthread_stop(dashtty_thread); + del_timer_sync(&poll_timer); + tty_unregister_driver(channel_driver); + for (nport = 0; nport < NUM_TTY_CHANNELS; nport++) { + dport = &dashtty_ports[nport]; + tty_port_destroy(&dport->port); + } + put_tty_driver(channel_driver); +} + +module_init(dashtty_init); +module_exit(dashtty_exit); + +#ifdef CONFIG_DA_CONSOLE + +static void dash_console_write(struct console *co, const char *s, + unsigned int count) +{ + int actually_written; + + chancall(WRBUF, CONSOLE_CHANNEL, count, (void *)s, &actually_written); +} + +static struct tty_driver *dash_console_device(struct console *c, int *index) +{ + *index = c->index; + return channel_driver; +} + +struct console dash_console = { + .name = "ttyDA", + .write = dash_console_write, + .device = dash_console_device, + .flags = CON_PRINTBUFFER, + .index = 1, +}; + +#endif -- cgit v1.2.3 From a8cd98586b1f9e3b5dd7e141bcfe8f078fbb39ed Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 6 Feb 2013 14:45:02 +0000 Subject: tty: metag_da: avoid getting tty kref in dashtty_timer() Getting the tty kref in dashtty_timer() is no longer necessary since it isn't needed in fetch_data() any longer (due to changes which make the tty flip functions refer to tty_ports instead of tty_structs), so just pass around a channel number instead. Signed-off-by: James Hogan Acked-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/tty/metag_da.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c index fc2a36bddd3f..0e888621f484 100644 --- a/drivers/tty/metag_da.c +++ b/drivers/tty/metag_da.c @@ -147,9 +147,8 @@ static int chancall(int in_bios_function, int in_channel, /* * Attempts to fetch count bytes from channel and returns actual count. */ -static int fetch_data(struct tty_struct *tty) +static int fetch_data(unsigned int channel) { - unsigned int channel = tty->index; struct dashtty_port *dport = &dashtty_ports[channel]; int received = 0; @@ -180,31 +179,31 @@ unlock: } /** - * find_channel_to_poll() - Returns kref to the next channel tty to poll. - * Returns: The TTY of the next channel to poll, or NULL if no TTY needs - * polling. Release with tty_kref_put(). + * find_channel_to_poll() - Returns number of the next channel to poll. + * Returns: The number of the next channel to poll, or -1 if none need + * polling. */ -static struct tty_struct *find_channel_to_poll(void) +static int find_channel_to_poll(void) { static int last_polled_channel; int last = last_polled_channel; int chan; - struct tty_struct *tty = NULL; + struct dashtty_port *dport; for (chan = last + 1; ; ++chan) { if (chan >= NUM_TTY_CHANNELS) chan = 0; - tty = tty_port_tty_get(&dashtty_ports[chan].port); - if (tty) { + dport = &dashtty_ports[chan]; + if (dport->rx_buf) { last_polled_channel = chan; - return tty; + return chan; } if (chan == last) break; } - return tty; + return -1; } /** @@ -302,19 +301,17 @@ static int put_data(void *arg) */ static void dashtty_timer(unsigned long ignored) { - struct tty_struct *tty; + int channel; /* If there are no ports open do nothing and don't poll again. */ if (!atomic_read(&num_channels_need_poll)) return; - tty = find_channel_to_poll(); + channel = find_channel_to_poll(); /* Did we find a channel to poll? */ - if (tty) { - fetch_data(tty); - tty_kref_put(tty); - } + if (channel >= 0) + fetch_data(channel); mod_timer_pinned(&poll_timer, jiffies + DA_TTY_POLL); } -- cgit v1.2.3 From 238d9f6e551d87bd6fbcfa3069592dfb407937fb Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Tue, 5 Feb 2013 17:58:34 -0800 Subject: input: drop unnecessary dependencies on TTY Backing out changes made in earlier TTY removal patch. Switched to only one dependency in SERPORT on TTY instead of many incorrect dependencies. Signed-off-by: Joe Millenbach Reported-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/Kconfig | 4 ---- drivers/input/keyboard/Kconfig | 10 +--------- drivers/input/mouse/Kconfig | 3 --- drivers/input/serio/Kconfig | 2 +- drivers/input/touchscreen/Kconfig | 22 ---------------------- 5 files changed, 2 insertions(+), 39 deletions(-) (limited to 'drivers') diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig index 055bcaba774c..56eb471b5576 100644 --- a/drivers/input/joystick/Kconfig +++ b/drivers/input/joystick/Kconfig @@ -132,8 +132,6 @@ config JOYSTICK_TMDC source "drivers/input/joystick/iforce/Kconfig" -if TTY - config JOYSTICK_WARRIOR tristate "Logitech WingMan Warrior joystick" select SERIO @@ -207,8 +205,6 @@ config JOYSTICK_ZHENHUA To compile this driver as a module, choose M here: the module will be called zhenhua. -endif # TTY - config JOYSTICK_DB9 tristate "Multisystem, Sega Genesis, Saturn joysticks and gamepads" depends on PARPORT diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 008f96aaf19e..5a240c60342d 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -69,7 +69,6 @@ config KEYBOARD_ATARI config KEYBOARD_ATKBD tristate "AT keyboard" if EXPERT || !X86 default y - depends on TTY select SERIO select SERIO_LIBPS2 select SERIO_I8042 if X86 @@ -154,7 +153,6 @@ config KEYBOARD_BFIN config KEYBOARD_LKKBD tristate "DECstation/VAXstation LK201/LK401 keyboard" - depends on TTY select SERIO help Say Y here if you want to use a LK201 or LK401 style serial @@ -270,7 +268,7 @@ config KEYBOARD_HIL_OLD config KEYBOARD_HIL tristate "HP HIL keyboard/pointer support" - depends on (GSC || HP300) && TTY + depends on GSC || HP300 default y select HP_SDC select HIL_MLC @@ -402,7 +400,6 @@ config KEYBOARD_IMX config KEYBOARD_NEWTON tristate "Newton keyboard" - depends on TTY select SERIO help Say Y here if you have a Newton keyboard on a serial port. @@ -482,8 +479,6 @@ config KEYBOARD_SAMSUNG To compile this driver as a module, choose M here: the module will be called samsung-keypad. -if TTY - config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIO @@ -506,8 +501,6 @@ config KEYBOARD_SUNKBD To compile this driver as a module, choose M here: the module will be called sunkbd. -endif # TTY - config KEYBOARD_SH_KEYSC tristate "SuperH KEYSC keypad support" depends on SUPERH || ARCH_SHMOBILE @@ -604,7 +597,6 @@ config KEYBOARD_TWL4030 config KEYBOARD_XTKBD tristate "XT keyboard" - depends on TTY select SERIO help Say Y here if you want to use the old IBM PC/XT keyboard (or diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index fc160f72dc4e..cd6268cf7cd5 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig @@ -14,7 +14,6 @@ if INPUT_MOUSE config MOUSE_PS2 tristate "PS/2 mouse" - depends on TTY default y select SERIO select SERIO_LIBPS2 @@ -139,7 +138,6 @@ config MOUSE_PS2_OLPC config MOUSE_SERIAL tristate "Serial mouse" - depends on TTY select SERIO help Say Y here if you have a serial (RS-232, COM port) mouse connected @@ -264,7 +262,6 @@ config MOUSE_RISCPC config MOUSE_VSXXXAA tristate "DEC VSXXX-AA/GA mouse and VSXXX-AB tablet" - depends on TTY select SERIO help Say Y (or M) if you want to use a DEC VSXXX-AA (hockey diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index 81ee7551148e..fe4e4953d5f5 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig @@ -4,7 +4,6 @@ config SERIO tristate "Serial I/O support" if EXPERT || !X86 default y - depends on TTY help Say Yes here if you have any input device that uses serial I/O to communicate with the system. This includes the @@ -37,6 +36,7 @@ config SERIO_I8042 config SERIO_SERPORT tristate "Serial port line discipline" default y + depends on TTY help Say Y here if you plan to use an input device (mouse, joystick, tablet, 6dof) that communicates over the RS232 serial (COM) port. diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 3d6f548dd3d4..515cfe790543 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -192,8 +192,6 @@ config TOUCHSCREEN_DA9052 To compile this driver as a module, choose M here: the module will be called da9052_tsi. -if TTY - config TOUCHSCREEN_DYNAPRO tristate "Dynapro serial touchscreen" select SERIO @@ -218,8 +216,6 @@ config TOUCHSCREEN_HAMPSHIRE To compile this driver as a module, choose M here: the module will be called hampshire. -endif # TTY - config TOUCHSCREEN_EETI tristate "EETI touchscreen panel support" depends on I2C @@ -241,7 +237,6 @@ config TOUCHSCREEN_EGALAX config TOUCHSCREEN_FUJITSU tristate "Fujitsu serial touchscreen" - depends on TTY select SERIO help Say Y here if you have the Fujitsu touchscreen (such as one @@ -280,8 +275,6 @@ config TOUCHSCREEN_S3C2410 To compile this driver as a module, choose M here: the module will be called s3c2410_ts. -if TTY - config TOUCHSCREEN_GUNZE tristate "Gunze AHL-51S touchscreen" select SERIO @@ -318,8 +311,6 @@ config TOUCHSCREEN_WACOM_W8001 To compile this driver as a module, choose M here: the module will be called wacom_w8001. -endif # TTY - config TOUCHSCREEN_WACOM_I2C tristate "Wacom Tablet support (I2C)" depends on I2C @@ -378,8 +369,6 @@ config TOUCHSCREEN_MMS114 To compile this driver as a module, choose M here: the module will be called mms114. -if TTY - config TOUCHSCREEN_MTOUCH tristate "MicroTouch serial touchscreens" select SERIO @@ -404,8 +393,6 @@ config TOUCHSCREEN_INEXIO To compile this driver as a module, choose M here: the module will be called inexio. -endif # TTY - config TOUCHSCREEN_INTEL_MID tristate "Intel MID platform resistive touchscreen" depends on INTEL_SCU_IPC @@ -463,7 +450,6 @@ config TOUCHSCREEN_HTCPEN config TOUCHSCREEN_PENMOUNT tristate "Penmount serial touchscreen" - depends on TTY select SERIO help Say Y here if you have a Penmount serial touchscreen connected to @@ -507,8 +493,6 @@ config TOUCHSCREEN_TNETV107X To compile this driver as a module, choose M here: the module will be called tnetv107x-ts. -if TTY - config TOUCHSCREEN_TOUCHRIGHT tristate "Touchright serial touchscreen" select SERIO @@ -533,8 +517,6 @@ config TOUCHSCREEN_TOUCHWIN To compile this driver as a module, choose M here: the module will be called touchwin. -endif # TTY - config TOUCHSCREEN_TI_AM335X_TSC tristate "TI Touchscreen Interface" depends on MFD_TI_AM335X_TSCADC @@ -808,8 +790,6 @@ config TOUCHSCREEN_USB_EASYTOUCH Say Y here if you have an EasyTouch USB Touch controller. If unsure, say N. -if TTY - config TOUCHSCREEN_TOUCHIT213 tristate "Sahara TouchIT-213 touchscreen" select SERIO @@ -833,8 +813,6 @@ config TOUCHSCREEN_TSC_SERIO To compile this driver as a module, choose M here: the module will be called tsc40. -endif # TTY - config TOUCHSCREEN_TSC2005 tristate "TSC2005 based touchscreens" depends on SPI_MASTER && GENERIC_HARDIRQS -- cgit v1.2.3 From 44a754117a53cf965d9e17767463a52c9d9ccbb3 Mon Sep 17 00:00:00 2001 From: "fabio.estevam@freescale.com" Date: Wed, 6 Feb 2013 19:00:02 -0200 Subject: Revert "serial: imx: Move imx_port_ucrs_save/restore under CONFIG_CONSOLE_POLL" This reverts commit cdc8da3998dcc50cee2f81904c16ebdbd7ec2cee. In my attempt to fix a build warning on arm randconfig a build error on imx_v6_v7_defconfig was introduced, so revert it for now. Reported-by: kbuild test robot Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a657f966b852..a220f77ceab6 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -268,6 +268,27 @@ static inline int is_imx21_uart(struct imx_port *sport) return sport->devdata->devtype == IMX21_UART; } +/* + * Save and restore functions for UCR1, UCR2 and UCR3 registers + */ +static void imx_port_ucrs_save(struct uart_port *port, + struct imx_port_ucrs *ucr) +{ + /* save control registers */ + ucr->ucr1 = readl(port->membase + UCR1); + ucr->ucr2 = readl(port->membase + UCR2); + ucr->ucr3 = readl(port->membase + UCR3); +} + +static void imx_port_ucrs_restore(struct uart_port *port, + struct imx_port_ucrs *ucr) +{ + /* restore control registers */ + writel(ucr->ucr1, port->membase + UCR1); + writel(ucr->ucr2, port->membase + UCR2); + writel(ucr->ucr3, port->membase + UCR3); +} + /* * Handle any change of modem status signal since we were last called. */ @@ -1082,27 +1103,6 @@ imx_verify_port(struct uart_port *port, struct serial_struct *ser) } #if defined(CONFIG_CONSOLE_POLL) -/* - * Save and restore functions for UCR1, UCR2 and UCR3 registers - */ -static void imx_port_ucrs_save(struct uart_port *port, - struct imx_port_ucrs *ucr) -{ - /* save control registers */ - ucr->ucr1 = readl(port->membase + UCR1); - ucr->ucr2 = readl(port->membase + UCR2); - ucr->ucr3 = readl(port->membase + UCR3); -} - -static void imx_port_ucrs_restore(struct uart_port *port, - struct imx_port_ucrs *ucr) -{ - /* restore control registers */ - writel(ucr->ucr1, port->membase + UCR1); - writel(ucr->ucr2, port->membase + UCR2); - writel(ucr->ucr3, port->membase + UCR3); -} - static int imx_poll_get_char(struct uart_port *port) { struct imx_port_ucrs old_ucr; -- cgit v1.2.3 From f2eca58f2ad92ed20cc96b765a18525d5ace2d19 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 6 Feb 2013 17:24:03 +0100 Subject: drivers/serial: add GENERIC_HARDIRQS dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since SERIAL_CORE needs GENERIC_HARDIRQS (see below) and most serial drivers select it, just add a GENERIC_HARDIRQS dependency to all serial drivers. Fixes the compile error below: drivers/tty/serial/serial_core.c: In function ‘uart_set_info’: drivers/tty/serial/serial_core.c:725:2: error: implicit declaration of function ‘irq_canonicalize’ Cc: Jiri Slaby Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index e9aeccdfbe35..a0162cbf0557 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -5,7 +5,7 @@ if TTY menu "Serial drivers" - depends on HAS_IOMEM + depends on HAS_IOMEM && GENERIC_HARDIRQS source "drivers/tty/serial/8250/Kconfig" -- cgit v1.2.3 From 11c62d4f1d8583dd6305824d704f33301da4e93a Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Mon, 11 Feb 2013 14:11:41 +0530 Subject: serial/arc-uart: Miscll DT related updates (Grant's review comments) -replace "baud" with "current-speed" -if uart alias doesn't exist in DT, don't abort, pick 0 Signed-off-by: Vineet Gupta Cc: Greg Kroah-Hartman Cc: Grant Likely Cc: Arnd Bergmann Cc: devicetree-discuss@lists.ozlabs.org Cc: Rob Herring Cc: Rob Landley Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- Documentation/devicetree/bindings/tty/serial/arc-uart.txt | 4 ++-- drivers/tty/serial/arc_uart.c | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/Documentation/devicetree/bindings/tty/serial/arc-uart.txt b/Documentation/devicetree/bindings/tty/serial/arc-uart.txt index c3bd8f9c9997..5cae2eb686f8 100644 --- a/Documentation/devicetree/bindings/tty/serial/arc-uart.txt +++ b/Documentation/devicetree/bindings/tty/serial/arc-uart.txt @@ -5,7 +5,7 @@ Required properties: - reg : offset and length of the register set for the device. - interrupts : device interrupt - clock-frequency : the input clock frequency for the UART -- baud : baud rate for UART +- current-speed : baud rate for UART e.g. @@ -14,7 +14,7 @@ arcuart0: serial@c0fc1000 { reg = <0xc0fc1000 0x100>; interrupts = <5>; clock-frequency = <80000000>; - baud = <115200>; + current-speed = <115200>; status = "okay"; }; diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 6f7eadc424a3..d97e194b6bc5 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -547,8 +547,8 @@ arc_uart_init_one(struct platform_device *pdev, int dev_id) } uart->port.uartclk = val; - if (of_property_read_u32(np, "baud", &val)) { - dev_err(&pdev->dev, "baud property NOT set\n"); + if (of_property_read_u32(np, "current-speed", &val)) { + dev_err(&pdev->dev, "current-speed property NOT set\n"); return -EINVAL; } uart->baud = val; @@ -694,10 +694,8 @@ static int arc_serial_probe(struct platform_device *pdev) return -ENODEV; dev_id = of_alias_get_id(np, "serial"); - if (dev_id < 0) { - dev_err(&pdev->dev, "failed to get alias id: %d\n", dev_id); - return dev_id; - } + if (dev_id < 0) + dev_id = 0; rc = arc_uart_init_one(pdev, dev_id); if (rc) -- cgit v1.2.3 From 3240b48d492b368339a8a5cb3a4dc5b35432ef43 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 11 Feb 2013 19:04:33 +0100 Subject: tty: serial: uartlite: Fix sparse and checkpatch warnings Clean coding style and sparse warnings. Signed-off-by: Michal Simek Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/uartlite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 5486505e87c7..f3b09ee767ff 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -615,7 +615,7 @@ static struct platform_driver ulite_platform_driver = { * Module setup/teardown */ -int __init ulite_init(void) +static int __init ulite_init(void) { int ret; @@ -634,11 +634,11 @@ int __init ulite_init(void) err_plat: uart_unregister_driver(&ulite_uart_driver); err_uart: - printk(KERN_ERR "registering uartlite driver failed: err=%i", ret); + pr_err("registering uartlite driver failed: err=%i", ret); return ret; } -void __exit ulite_exit(void) +static void __exit ulite_exit(void) { platform_driver_unregister(&ulite_platform_driver); uart_unregister_driver(&ulite_uart_driver); -- cgit v1.2.3 From 6d53c3b71d32da665dc2742c1e8663741f27d3cd Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 11 Feb 2013 19:04:34 +0100 Subject: tty: serial: uartlite: Support uartlite on big and little endian systems Use big and little endian accessors function to reflect system configuration. Detection is done via control register in ulite_request_port. Tested on Microblaze LE, BE, PPC440 and Arm zynq. Signed-off-by: Michal Simek Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/uartlite.c | 101 +++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index f3b09ee767ff..5f90ef24d475 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -34,7 +34,7 @@ * Register definitions * * For register details see datasheet: - * http://www.xilinx.com/support/documentation/ip_documentation/opb_uartlite.pdf + * http://www.xilinx.com/support/documentation/ip_documentation/opb_uartlite.pdf */ #define ULITE_RX 0x00 @@ -57,6 +57,54 @@ #define ULITE_CONTROL_RST_RX 0x02 #define ULITE_CONTROL_IE 0x10 +struct uartlite_reg_ops { + u32 (*in)(void __iomem *addr); + void (*out)(u32 val, void __iomem *addr); +}; + +static u32 uartlite_inbe32(void __iomem *addr) +{ + return ioread32be(addr); +} + +static void uartlite_outbe32(u32 val, void __iomem *addr) +{ + iowrite32be(val, addr); +} + +static struct uartlite_reg_ops uartlite_be = { + .in = uartlite_inbe32, + .out = uartlite_outbe32, +}; + +static u32 uartlite_inle32(void __iomem *addr) +{ + return ioread32(addr); +} + +static void uartlite_outle32(u32 val, void __iomem *addr) +{ + iowrite32(val, addr); +} + +static struct uartlite_reg_ops uartlite_le = { + .in = uartlite_inle32, + .out = uartlite_outle32, +}; + +static inline u32 uart_in32(u32 offset, struct uart_port *port) +{ + struct uartlite_reg_ops *reg_ops = port->private_data; + + return reg_ops->in(port->membase + offset); +} + +static inline void uart_out32(u32 val, u32 offset, struct uart_port *port) +{ + struct uartlite_reg_ops *reg_ops = port->private_data; + + reg_ops->out(val, port->membase + offset); +} static struct uart_port ulite_ports[ULITE_NR_UARTS]; @@ -77,7 +125,7 @@ static int ulite_receive(struct uart_port *port, int stat) /* stats */ if (stat & ULITE_STATUS_RXVALID) { port->icount.rx++; - ch = ioread32be(port->membase + ULITE_RX); + ch = uart_in32(ULITE_RX, port); if (stat & ULITE_STATUS_PARITY) port->icount.parity++; @@ -122,7 +170,7 @@ static int ulite_transmit(struct uart_port *port, int stat) return 0; if (port->x_char) { - iowrite32be(port->x_char, port->membase + ULITE_TX); + uart_out32(port->x_char, ULITE_TX, port); port->x_char = 0; port->icount.tx++; return 1; @@ -131,7 +179,7 @@ static int ulite_transmit(struct uart_port *port, int stat) if (uart_circ_empty(xmit) || uart_tx_stopped(port)) return 0; - iowrite32be(xmit->buf[xmit->tail], port->membase + ULITE_TX); + uart_out32(xmit->buf[xmit->tail], ULITE_TX, port); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1); port->icount.tx++; @@ -148,7 +196,7 @@ static irqreturn_t ulite_isr(int irq, void *dev_id) int busy, n = 0; do { - int stat = ioread32be(port->membase + ULITE_STATUS); + int stat = uart_in32(ULITE_STATUS, port); busy = ulite_receive(port, stat); busy |= ulite_transmit(port, stat); n++; @@ -169,7 +217,7 @@ static unsigned int ulite_tx_empty(struct uart_port *port) unsigned int ret; spin_lock_irqsave(&port->lock, flags); - ret = ioread32be(port->membase + ULITE_STATUS); + ret = uart_in32(ULITE_STATUS, port); spin_unlock_irqrestore(&port->lock, flags); return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0; @@ -192,7 +240,7 @@ static void ulite_stop_tx(struct uart_port *port) static void ulite_start_tx(struct uart_port *port) { - ulite_transmit(port, ioread32be(port->membase + ULITE_STATUS)); + ulite_transmit(port, uart_in32(ULITE_STATUS, port)); } static void ulite_stop_rx(struct uart_port *port) @@ -220,17 +268,17 @@ static int ulite_startup(struct uart_port *port) if (ret) return ret; - iowrite32be(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX, - port->membase + ULITE_CONTROL); - iowrite32be(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL); + uart_out32(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX, + ULITE_CONTROL, port); + uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port); return 0; } static void ulite_shutdown(struct uart_port *port) { - iowrite32be(0, port->membase + ULITE_CONTROL); - ioread32be(port->membase + ULITE_CONTROL); /* dummy */ + uart_out32(0, ULITE_CONTROL, port); + uart_in32(ULITE_CONTROL, port); /* dummy */ free_irq(port->irq, port); } @@ -281,6 +329,8 @@ static void ulite_release_port(struct uart_port *port) static int ulite_request_port(struct uart_port *port) { + int ret; + pr_debug("ulite console: port=%p; port->mapbase=%llx\n", port, (unsigned long long) port->mapbase); @@ -296,6 +346,14 @@ static int ulite_request_port(struct uart_port *port) return -EBUSY; } + port->private_data = &uartlite_be; + ret = uart_in32(ULITE_CONTROL, port); + uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port); + ret = uart_in32(ULITE_STATUS, port); + /* Endianess detection */ + if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY) + port->private_data = &uartlite_le; + return 0; } @@ -314,20 +372,19 @@ static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser) #ifdef CONFIG_CONSOLE_POLL static int ulite_get_poll_char(struct uart_port *port) { - if (!(ioread32be(port->membase + ULITE_STATUS) - & ULITE_STATUS_RXVALID)) + if (!(uart_in32(ULITE_STATUS, port) & ULITE_STATUS_RXVALID)) return NO_POLL_CHAR; - return ioread32be(port->membase + ULITE_RX); + return uart_in32(ULITE_RX, port); } static void ulite_put_poll_char(struct uart_port *port, unsigned char ch) { - while (ioread32be(port->membase + ULITE_STATUS) & ULITE_STATUS_TXFULL) + while (uart_in32(ULITE_STATUS, port) & ULITE_STATUS_TXFULL) cpu_relax(); /* write char to device */ - iowrite32be(ch, port->membase + ULITE_TX); + uart_out32(ch, ULITE_TX, port); } #endif @@ -366,7 +423,7 @@ static void ulite_console_wait_tx(struct uart_port *port) /* Spin waiting for TX fifo to have space available */ for (i = 0; i < 100000; i++) { - val = ioread32be(port->membase + ULITE_STATUS); + val = uart_in32(ULITE_STATUS, port); if ((val & ULITE_STATUS_TXFULL) == 0) break; cpu_relax(); @@ -376,7 +433,7 @@ static void ulite_console_wait_tx(struct uart_port *port) static void ulite_console_putchar(struct uart_port *port, int ch) { ulite_console_wait_tx(port); - iowrite32be(ch, port->membase + ULITE_TX); + uart_out32(ch, ULITE_TX, port); } static void ulite_console_write(struct console *co, const char *s, @@ -393,8 +450,8 @@ static void ulite_console_write(struct console *co, const char *s, spin_lock_irqsave(&port->lock, flags); /* save and disable interrupt */ - ier = ioread32be(port->membase + ULITE_STATUS) & ULITE_STATUS_IE; - iowrite32be(0, port->membase + ULITE_CONTROL); + ier = uart_in32(ULITE_STATUS, port) & ULITE_STATUS_IE; + uart_out32(0, ULITE_CONTROL, port); uart_console_write(port, s, count, ulite_console_putchar); @@ -402,7 +459,7 @@ static void ulite_console_write(struct console *co, const char *s, /* restore interrupt state */ if (ier) - iowrite32be(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL); + uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port); if (locked) spin_unlock_irqrestore(&port->lock, flags); -- cgit v1.2.3 From 513b032c98b4b9414aa4e9b4a315cb1bf0380101 Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Sun, 10 Feb 2013 04:08:32 -0500 Subject: pps: Add pps_lookup_dev() function The PPS serial line discipline wants to attach a PPS device to a tty without changing the tty code to add a struct pps_device * pointer. Since the number of PPS devices in a typical system is generally very low (n=1 is by far the most common), it's practical to search the entire list of allocated pps devices. (We capture the timestamp before the lookup, so the timing isn't affected.) It is a bit ugly that this function, which is part of the in-kernel PPS API, has to be in pps.c as opposed to kapi,c, but that's not something that affects users. Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/pps/pps.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pps_kernel.h | 17 ++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index 2420d5af0583..a70e384262e5 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c @@ -352,10 +352,43 @@ free_idr: void pps_unregister_cdev(struct pps_device *pps) { + pps->lookup_cookie = NULL; device_destroy(pps_class, pps->dev->devt); cdev_del(&pps->cdev); } +/* + * Look up a pps device by magic cookie. + * The cookie is usually a pointer to some enclosing device, but this + * code doesn't care; you should never be dereferencing it. + * + * This is a bit of a kludge that is currently used only by the PPS + * serial line discipline. It may need to be tweaked when a second user + * is found. + * + * There is no function interface for setting the lookup_cookie field. + * It's initialized to NULL when the pps device is created, and if a + * client wants to use it, just fill it in afterward. + * + * The cookie is automatically set to NULL in pps_unregister_source() + * so that it will not be used again, even if the pps device cannot + * be removed from the idr due to pending references holding the minor + * number in use. + */ +struct pps_device *pps_lookup_dev(void const *cookie) +{ + struct pps_device *pps; + unsigned id; + + rcu_read_lock(); + idr_for_each_entry(&pps_idr, pps, id) + if (cookie == pps->lookup_cookie) + break; + rcu_read_unlock(); + return pps; +} +EXPORT_SYMBOL(pps_lookup_dev); + /* * Module stuff */ diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 0cc45ae1afd5..7db3eb93a079 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -43,7 +43,7 @@ struct pps_source_info { int event, void *data); /* PPS echo function */ struct module *owner; - struct device *dev; + struct device *dev; /* Parent device for device_create */ }; struct pps_event_time { @@ -69,6 +69,7 @@ struct pps_device { wait_queue_head_t queue; /* PPS event queue */ unsigned int id; /* PPS source unique ID */ + void const *lookup_cookie; /* pps_lookup_dev only */ struct cdev cdev; struct device *dev; struct fasync_struct *async_queue; /* fasync method */ @@ -81,6 +82,16 @@ struct pps_device { extern struct device_attribute pps_attrs[]; +/* + * Internal functions. + * + * These are not actually part of the exported API, but this is a + * convenient header file to put them in. + */ + +extern int pps_register_cdev(struct pps_device *pps); +extern void pps_unregister_cdev(struct pps_device *pps); + /* * Exported functions */ @@ -88,10 +99,10 @@ extern struct device_attribute pps_attrs[]; extern struct pps_device *pps_register_source( struct pps_source_info *info, int default_params); extern void pps_unregister_source(struct pps_device *pps); -extern int pps_register_cdev(struct pps_device *pps); -extern void pps_unregister_cdev(struct pps_device *pps); extern void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event, void *data); +/* Look up a pps device by magic cookie */ +struct pps_device *pps_lookup_dev(void const *cookie); static inline void timespec_to_pps_ktime(struct pps_ktime *kt, struct timespec ts) -- cgit v1.2.3 From 03a7ffe4e542310838bac70ef85acc17536b6d7c Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Sun, 10 Feb 2013 04:41:56 -0500 Subject: pps: Use pps_lookup_dev to reduce ldisc coupling Now that N_TTY uses tty->disc_data for its private data, 'subclass' ldiscs cannot use ->disc_data for their own private data. (This is a regression is v3.8-rc1) Use pps_lookup_dev to associate the tty with the pps source instead. This fixes a crashing regression in 3.8-rc1. Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/pps/clients/pps-ldisc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c index 79451f2dea6a..60cee9e0ecb3 100644 --- a/drivers/pps/clients/pps-ldisc.c +++ b/drivers/pps/clients/pps-ldisc.c @@ -31,7 +31,7 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, struct pps_event_time *ts) { - struct pps_device *pps = (struct pps_device *)tty->disc_data; + struct pps_device *pps = pps_lookup_dev(tty); BUG_ON(pps == NULL); @@ -67,9 +67,9 @@ static int pps_tty_open(struct tty_struct *tty) pr_err("cannot register PPS source \"%s\"\n", info.path); return -ENOMEM; } - tty->disc_data = pps; + pps->lookup_cookie = tty; - /* Should open N_TTY ldisc too */ + /* Now open the base class N_TTY ldisc */ ret = alias_n_tty_open(tty); if (ret < 0) { pr_err("cannot open tty ldisc \"%s\"\n", info.path); @@ -81,7 +81,6 @@ static int pps_tty_open(struct tty_struct *tty) return 0; err_unregister: - tty->disc_data = NULL; pps_unregister_source(pps); return ret; } @@ -90,11 +89,10 @@ static void (*alias_n_tty_close)(struct tty_struct *tty); static void pps_tty_close(struct tty_struct *tty) { - struct pps_device *pps = (struct pps_device *)tty->disc_data; + struct pps_device *pps = pps_lookup_dev(tty); alias_n_tty_close(tty); - tty->disc_data = NULL; dev_info(pps->dev, "removed\n"); pps_unregister_source(pps); } -- cgit v1.2.3 From d953e0e837e65ecc1ddaa4f9560f7925878a0de6 Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Tue, 12 Feb 2013 02:27:20 -0500 Subject: pps: Fix a use-after free bug when unregistering a source. Remove the cdev from the system (with cdev_del) *before* deallocating it (in pps_device_destruct, called via kobject_put from device_destroy). Also prevent deallocating a device with open file handles. A better long-term fix is probably to remove the cdev from the pps_device entirely, and instead have all devices reference one global cdev. Then the deallocation ordering becomes simpler. But that's more complex and invasive change, so we leave that for later. Signed-off-by: George Spelvin Cc: stable Acked-by: Rodolfo Giometti Signed-off-by: Greg Kroah-Hartman --- drivers/pps/pps.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index a70e384262e5..6437703eb10f 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c @@ -247,12 +247,15 @@ static int pps_cdev_open(struct inode *inode, struct file *file) struct pps_device *pps = container_of(inode->i_cdev, struct pps_device, cdev); file->private_data = pps; - + kobject_get(&pps->dev->kobj); return 0; } static int pps_cdev_release(struct inode *inode, struct file *file) { + struct pps_device *pps = container_of(inode->i_cdev, + struct pps_device, cdev); + kobject_put(&pps->dev->kobj); return 0; } @@ -274,8 +277,10 @@ static void pps_device_destruct(struct device *dev) { struct pps_device *pps = dev_get_drvdata(dev); - /* release id here to protect others from using it while it's - * still in use */ + cdev_del(&pps->cdev); + + /* Now we can release the ID for re-use */ + pr_debug("deallocating pps%d\n", pps->id); mutex_lock(&pps_idr_lock); idr_remove(&pps_idr, pps->id); mutex_unlock(&pps_idr_lock); @@ -332,6 +337,7 @@ int pps_register_cdev(struct pps_device *pps) goto del_cdev; } + /* Override the release function with our own */ pps->dev->release = pps_device_destruct; pr_debug("source %s got cdev (%d:%d)\n", pps->info.name, @@ -352,9 +358,9 @@ free_idr: void pps_unregister_cdev(struct pps_device *pps) { + pr_debug("unregistering pps%d\n", pps->id); pps->lookup_cookie = NULL; device_destroy(pps_class, pps->dev->devt); - cdev_del(&pps->cdev); } /* -- cgit v1.2.3 From ce3da1a654c83c6c9cb0b33477815e5d1293cc00 Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Sun, 10 Feb 2013 04:43:41 -0500 Subject: pps: Don't crash the machine when exiting will do PPS is not really the must-have subsystem that warrants crashing the machine if the ldisc interface is broken. Signed-off-by: Peter Hurley Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Signed-off-by: Greg Kroah-Hartman --- drivers/pps/clients/pps-ldisc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c index 60cee9e0ecb3..a94f73e1480d 100644 --- a/drivers/pps/clients/pps-ldisc.c +++ b/drivers/pps/clients/pps-ldisc.c @@ -25,6 +25,7 @@ #include #include #include +#include #define PPS_TTY_MAGIC 0x0001 @@ -33,7 +34,12 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, { struct pps_device *pps = pps_lookup_dev(tty); - BUG_ON(pps == NULL); + /* + * This should never fail, but the ldisc locking is very + * convoluted, so don't crash just in case. + */ + if (WARN_ON_ONCE(pps == NULL)) + return; /* Now do the PPS event report */ pps_event(pps, ts, status ? PPS_CAPTUREASSERT : @@ -93,6 +99,9 @@ static void pps_tty_close(struct tty_struct *tty) alias_n_tty_close(tty); + if (WARN_ON(!pps)) + return; + dev_info(pps->dev, "removed\n"); pps_unregister_source(pps); } -- cgit v1.2.3 From 593fb1ae457aab28b392ac114f6e3358788da985 Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Tue, 12 Feb 2013 02:00:43 -0500 Subject: pps: Move timestamp read into PPS code proper The PPS (Pulse-Per-Second) line discipline has developed a number of unhealthy attachments to core tty data and functions, ultimately leading to its breakage. The previous patches fixed the crashing. This one reduces coupling further by eliminating the timestamp parameter from the dcd_change ldisc method. This reduces header file linkage and makes the extension more generic, and the timestamp read is delayed only slightly, from just before the ldisc->ops->dcd_change method call to just after. Fix attendant build breakage in drivers/tty/n_tty.c drivers/tty/tty_buffer.c drivers/staging/speakup/selection.c drivers/staging/dgrp/dgrp_*.c Cc: William Hubbs Cc: Chris Brannon Cc: Kirk Reiser Cc: Samuel Thibault Signed-off-by: Peter Hurley Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Signed-off-by: Greg Kroah-Hartman --- drivers/pps/clients/pps-ldisc.c | 11 +++++++---- drivers/staging/dgrp/dgrp_net_ops.c | 1 + drivers/staging/dgrp/dgrp_tty.c | 1 + drivers/staging/speakup/selection.c | 1 + drivers/tty/n_tty.c | 3 ++- drivers/tty/serial/serial_core.c | 5 +---- drivers/tty/tty_buffer.c | 1 + include/linux/serial_core.h | 1 - include/linux/tty_ldisc.h | 11 ++++------- 9 files changed, 18 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c index a94f73e1480d..73bd3bb4d93b 100644 --- a/drivers/pps/clients/pps-ldisc.c +++ b/drivers/pps/clients/pps-ldisc.c @@ -29,11 +29,14 @@ #define PPS_TTY_MAGIC 0x0001 -static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, - struct pps_event_time *ts) +static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status) { - struct pps_device *pps = pps_lookup_dev(tty); + struct pps_device *pps; + struct pps_event_time ts; + + pps_get_ts(&ts); + pps = pps_lookup_dev(tty); /* * This should never fail, but the ldisc locking is very * convoluted, so don't crash just in case. @@ -42,7 +45,7 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, return; /* Now do the PPS event report */ - pps_event(pps, ts, status ? PPS_CAPTUREASSERT : + pps_event(pps, &ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR, NULL); dev_dbg(pps->dev, "PPS %s at %lu\n", diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 4c7abfabf197..e6018823b9de 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index 51d3ed3dca27..654f6010b473 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c index 0612df06a4bf..2aa22379fda0 100644 --- a/drivers/staging/speakup/selection.c +++ b/drivers/staging/speakup/selection.c @@ -2,6 +2,7 @@ #include #include #include +#include /* for dev_warn */ #include #include "speakup.h" diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 095072899b5e..05e72bea9b07 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -49,6 +49,7 @@ #include #include #include +#include /* number of characters left in xmit buffer before select has we have room */ @@ -2188,7 +2189,7 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { * n_tty_inherit_ops - inherit N_TTY methods * @ops: struct tty_ldisc_ops where to save N_TTY methods * - * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY + * Enables a 'subclass' line discipline to 'inherit' N_TTY * methods. */ diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index ca98a3f65fe1..765be520cd2e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2726,13 +2726,12 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) struct uart_state *state = uport->state; struct tty_port *port = &state->port; struct tty_ldisc *ld = NULL; - struct pps_event_time ts; struct tty_struct *tty = port->tty; if (tty) ld = tty_ldisc_ref(tty); if (ld && ld->ops->dcd_change) - pps_get_ts(&ts); + ld->ops->dcd_change(tty, status); uport->icount.dcd++; #ifdef CONFIG_HARD_PPS @@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) tty_hangup(tty); } - if (ld && ld->ops->dcd_change) - ld->ops->dcd_change(tty, status, &ts); if (ld) tty_ldisc_deref(ld); } diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 61ec4ddf47e0..bb119934e76c 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -16,6 +16,7 @@ #include #include #include +#include /** * tty_buffer_free_all - free buffers used by a tty diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index d97142159e0f..87d4bbc773fc 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -29,7 +29,6 @@ #include #include #include -#include #include struct uart_port; diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index fb79dd8d1537..455a0d7bf220 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -100,16 +100,14 @@ * seek to perform this action quickly but should wait until * any pending driver I/O is completed. * - * void (*dcd_change)(struct tty_struct *tty, unsigned int status, - * struct pps_event_time *ts) + * void (*dcd_change)(struct tty_struct *tty, unsigned int status) * - * Tells the discipline that the DCD pin has changed its status and - * the relative timestamp. Pointer ts cannot be NULL. + * Tells the discipline that the DCD pin has changed its status. + * Used exclusively by the N_PPS (Pulse-Per-Second) line discipline. */ #include #include -#include #include struct tty_ldisc_ops { @@ -144,8 +142,7 @@ struct tty_ldisc_ops { void (*receive_buf)(struct tty_struct *, const unsigned char *cp, char *fp, int count); void (*write_wakeup)(struct tty_struct *); - void (*dcd_change)(struct tty_struct *, unsigned int, - struct pps_event_time *); + void (*dcd_change)(struct tty_struct *, unsigned int); struct module *owner; -- cgit v1.2.3 From 42381572f586d4da57e7d65e0fcb45422be3ba7b Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Sun, 10 Feb 2013 04:44:30 -0500 Subject: pps: Additional cleanups in uart_handle_dcd_change An extension of the previous commit, there is no semantic change here, just fewer lines of source code. Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 765be520cd2e..6ce40c1822fc 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2723,15 +2723,15 @@ EXPORT_SYMBOL(uart_match_port); */ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) { - struct uart_state *state = uport->state; - struct tty_port *port = &state->port; - struct tty_ldisc *ld = NULL; + struct tty_port *port = &uport->state->port; struct tty_struct *tty = port->tty; + struct tty_ldisc *ld = tty ? tty_ldisc_ref(tty) : NULL; - if (tty) - ld = tty_ldisc_ref(tty); - if (ld && ld->ops->dcd_change) - ld->ops->dcd_change(tty, status); + if (ld) { + if (ld->ops->dcd_change) + ld->ops->dcd_change(tty, status); + tty_ldisc_deref(ld); + } uport->icount.dcd++; #ifdef CONFIG_HARD_PPS @@ -2745,9 +2745,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) else if (tty) tty_hangup(tty); } - - if (ld) - tty_ldisc_deref(ld); } EXPORT_SYMBOL_GPL(uart_handle_dcd_change); -- cgit v1.2.3 From bc80fbe46be7430487a45ad92841932bb2eaa3e6 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Wed, 6 Feb 2013 10:55:16 -0500 Subject: tty: Remove ancient hardpps() hardpps() functionality is provided through the N_PPS line discipline now. The new function signature was added in commit 025b40ab (2011-01-12). There was no previous macro or function hardpps(), at least since before the initial commit of v2.6.12 in 2005. It's unlikely this code has been compiled since. Signed-off-by: Peter Hurley Signed-off-by: George Spelvin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/amiserial.c | 5 ----- drivers/tty/serial/serial_core.c | 4 ---- 2 files changed, 9 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 4c7d70172193..fc700342d43f 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -393,11 +393,6 @@ static void check_modem_status(struct serial_state *info) icount->dsr++; if (dstatus & SER_DCD) { icount->dcd++; -#ifdef CONFIG_HARD_PPS - if ((port->flags & ASYNC_HARDPPS_CD) && - !(status & SER_DCD)) - hardpps(); -#endif } if (dstatus & SER_CTS) icount->cts++; diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 6ce40c1822fc..a400002dfa84 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2734,10 +2734,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) } uport->icount.dcd++; -#ifdef CONFIG_HARD_PPS - if ((uport->flags & UPF_HARDPPS_CD) && status) - hardpps(); -#endif if (port->flags & ASYNC_CHECK_CD) { if (status) -- cgit v1.2.3 From 677fe555cbfb188af58cce105f4dae9505e58c31 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 14 Feb 2013 21:01:06 +0100 Subject: serial: imx: Fix recursive locking bug commit 9ec1882df2 (tty: serial: imx: console write routing is unsafe on SMP) introduced a recursive locking bug in imx_console_write(). The callchain is: imx_rxint() spin_lock_irqsave(&sport->port.lock,flags); ... uart_handle_sysrq_char(); sysrq_function(); printk(); imx_console_write(); spin_lock_irqsave(&sport->port.lock,flags); <--- DEAD The bad news is that the kernel debugging facilities can dectect the problem, but the printks never surface on the serial console for obvious reasons. There is a similar issue with oops_in_progress. If the kernel crashes we really don't want to be stuck on the lock and unable to tell what happened. In general most UP originated drivers miss these checks and nobody ever notices because CONFIG_PROVE_LOCKING seems to be still ignored by a large number of developers. The solution is to avoid locking in the sysrq case and trylock in the oops_in_progress case. This scheme is used in other drivers as well and it would be nice if we could move this to a common place, so the usual copy/paste/modify bugs can be avoided. Now there is another issue with this scheme: CPU0 CPU1 printk() rxint() sysrq_detection() -> sets port->sysrq return from interrupt console_write() if (port->sysrq) avoid locking port->sysrq is reset with the next receive character. So as long as the port->sysrq is not reset and this can take an endless amount of time if after the break no futher receive character follows, all console writes happen unlocked. While the current writer is protected against other console writers by the console sem, it's unprotected against open/close or other operations which fiddle with the port. That's what the above mentioned commit tried to solve. That's an issue in all drivers which use that scheme and unfortunately there is no easy workaround. The only solution is to have a separate indicator port->sysrq_cpu. uart_handle_sysrq_char() then sets it to smp_processor_id() before calling into handle_sysrq() and resets it to -1 after that. Then change the locking check to: if (port->sysrq_cpu == smp_processor_id()) locked = 0; else if (oops_in_progress) locked = spin_trylock_irqsave(port->lock, flags); else spin_lock_irqsave(port->lock, flags); That would force all other cpus into the spin_lock path. Problem solved, but that's way beyond the scope of this fix and really wants to be implemented in a common function which calls the uart specific write function to avoid another gazillion of hard to debug copy/paste/modify bugs. Reported-and-tested-by: Tim Sander Signed-off-by: Thomas Gleixner Cc: stable # 3.6+ Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a220f77ceab6..adf76117a733 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1212,8 +1212,14 @@ imx_console_write(struct console *co, const char *s, unsigned int count) struct imx_port_ucrs old_ucr; unsigned int ucr1; unsigned long flags; + int locked = 1; - spin_lock_irqsave(&sport->port.lock, flags); + if (sport->port.sysrq) + locked = 0; + else if (oops_in_progress) + locked = spin_trylock_irqsave(&sport->port.lock, flags); + else + spin_lock_irqsave(&sport->port.lock, flags); /* * First, save UCR1/2/3 and then disable interrupts @@ -1240,7 +1246,8 @@ imx_console_write(struct console *co, const char *s, unsigned int count) imx_port_ucrs_restore(&sport->port, &old_ucr); - spin_unlock_irqrestore(&sport->port.lock, flags); + if (locked) + spin_unlock_irqrestore(&sport->port.lock, flags); } /* -- cgit v1.2.3 From 76bf7228694b172dc42900cafbc09bec954949c4 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 14 Feb 2013 23:26:51 +0100 Subject: fb/exynos: include platform_device.h Patch 16559ae "kgdb: remove #include from kgdb.h" removed an implicit inclusion of linux/platform_device.h from the exynos framebuffer driver. This adds back the required explicit header file inclusions. Signed-off-by: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Ajay Kumar Cc: Florian Tobias Schandinat Signed-off-by: Greg Kroah-Hartman --- drivers/video/exynos/exynos_mipi_dsi_common.c | 1 + drivers/video/exynos/exynos_mipi_dsi_lowlevel.c | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/video/exynos/exynos_mipi_dsi_common.c b/drivers/video/exynos/exynos_mipi_dsi_common.c index 3cd29a4fc10a..c70cb8926df6 100644 --- a/drivers/video/exynos/exynos_mipi_dsi_common.c +++ b/drivers/video/exynos/exynos_mipi_dsi_common.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include