diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-05 10:30:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-05 10:30:48 -0700 |
commit | e63a94f12b5fc67b2b92a89d4058e7a9021e900e (patch) | |
tree | 9fddf35df3289bd41c2310937bf2faed4d036603 /drivers/tty/serial/serial_core.c | |
parent | 1a3b85ea36d38d5732fdd86b321b10bcaeb53512 (diff) | |
parent | 3840ed9548f778717aaab5eab744da798c3ea055 (diff) | |
download | talos-op-linux-e63a94f12b5fc67b2b92a89d4058e7a9021e900e.tar.gz talos-op-linux-e63a94f12b5fc67b2b92a89d4058e7a9021e900e.zip |
Merge tag 'tty-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial updates from Greg KH:
"Here is the big tty/serial driver update for 4.14-rc1.
Well, not all that big, just a number of small serial driver fixes,
and a new serial driver. Also in here are some much needed goldfish
tty driver (emulator) fixes to try to get that codebase under control.
All of these have been in linux-next for a while with no reported
issues"
* tag 'tty-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (94 commits)
tty: goldfish: Implement support for kernel 'earlycon' parameter
tty: goldfish: Use streaming DMA for r/w operations on Ranchu platforms
tty: goldfish: Refactor constants to better reflect their nature
serial: 8250_port: Remove useless NULL checks
earlycon: initialise baud field of earlycon device structure
tty: hvcs: make ktermios const
pty: show associative slave of ptmx in fdinfo
tty: n_gsm: Add compat_ioctl
tty: hvcs: constify vio_device_id
tty: hvc_vio: constify vio_device_id
tty: mips_ejtag_fdc: constify mips_cdmm_device_id
Introduce 8250_men_mcb
mcb: introduce mcb_get_resource()
serial: imx: Avoid post-PIO cleanup if TX DMA is started
tty: serial: imx: disable irq after suspend
serial: 8250_uniphier: add suspend/resume support
serial: 8250_uniphier: use CHAR register for canary to detect power-off
serial: 8250_uniphier: fix serial port index in private data
serial: 8250: of: Add new port type for MediaTek BTIF controller on MT7622/23 SoC
dt-bindings: serial: 8250: Add MediaTek BTIF controller bindings
...
Diffstat (limited to 'drivers/tty/serial/serial_core.c')
-rw-r--r-- | drivers/tty/serial/serial_core.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f534a40aebde..3a14cccbd7ff 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -36,7 +36,7 @@ #include <linux/delay.h> #include <linux/mutex.h> -#include <asm/irq.h> +#include <linux/irq.h> #include <linux/uaccess.h> /* @@ -165,6 +165,27 @@ uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear) #define uart_set_mctrl(port, set) uart_update_mctrl(port, set, 0) #define uart_clear_mctrl(port, clear) uart_update_mctrl(port, 0, clear) +static void uart_port_dtr_rts(struct uart_port *uport, int raise) +{ + int rs485_on = uport->rs485_config && + (uport->rs485.flags & SER_RS485_ENABLED); + int RTS_after_send = !!(uport->rs485.flags & SER_RS485_RTS_AFTER_SEND); + + if (raise) { + if (rs485_on && !RTS_after_send) { + uart_set_mctrl(uport, TIOCM_DTR); + uart_clear_mctrl(uport, TIOCM_RTS); + } else { + uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); + } + } else { + unsigned int clear = TIOCM_DTR; + + clear |= (!rs485_on || !RTS_after_send) ? TIOCM_RTS : 0; + uart_clear_mctrl(uport, clear); + } +} + /* * Startup the port. This will be called once per open. All calls * will be serialised by the per-port mutex. @@ -214,7 +235,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, * port is open and ready to respond. */ if (init_hw && C_BAUD(tty)) - uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR); + uart_port_dtr_rts(uport, 1); } /* @@ -272,7 +293,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) uport->cons->cflag = tty->termios.c_cflag; if (!tty || C_HUPCL(tty)) - uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); + uart_port_dtr_rts(uport, 0); uart_port_shutdown(port); } @@ -744,7 +765,7 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) if (HIGH_BITS_OFFSET) retinfo->port_high = (long) uport->iobase >> HIGH_BITS_OFFSET; retinfo->irq = uport->irq; - retinfo->flags = uport->flags; + retinfo->flags = (__force int)uport->flags; retinfo->xmit_fifo_size = uport->fifosize; retinfo->baud_base = uport->uartclk / 16; retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; @@ -818,7 +839,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, new_info->type != uport->type); old_flags = uport->flags; - new_flags = new_info->flags; + new_flags = (__force upf_t)new_info->flags; old_custom_divisor = uport->custom_divisor; if (!capable(CAP_SYS_ADMIN)) { @@ -1658,7 +1679,7 @@ static int uart_carrier_raised(struct tty_port *port) return 0; } -static void uart_dtr_rts(struct tty_port *port, int onoff) +static void uart_dtr_rts(struct tty_port *port, int raise) { struct uart_state *state = container_of(port, struct uart_state, port); struct uart_port *uport; @@ -1666,12 +1687,7 @@ static void uart_dtr_rts(struct tty_port *port, int onoff) uport = uart_port_ref(state); if (!uport) return; - - if (onoff) - uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); - else - uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); - + uart_port_dtr_rts(uport, raise); uart_port_deref(uport); } @@ -2083,8 +2099,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) tty_dev = device_find_child(uport->dev, &match, serial_match_port); if (tty_dev && device_may_wakeup(tty_dev)) { - if (!enable_irq_wake(uport->irq)) - uport->irq_wake = 1; + enable_irq_wake(uport->irq); put_device(tty_dev); mutex_unlock(&port->mutex); return 0; @@ -2147,10 +2162,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) tty_dev = device_find_child(uport->dev, &match, serial_match_port); if (!uport->suspended && device_may_wakeup(tty_dev)) { - if (uport->irq_wake) { + if (irqd_is_wakeup_set(irq_get_irq_data((uport->irq)))) disable_irq_wake(uport->irq); - uport->irq_wake = 0; - } put_device(tty_dev); mutex_unlock(&port->mutex); return 0; |