From: Alan <gnomes@xxxxxxxxxxxxxxxxxxx> This propogates the tty layer RS485 helpers into the serial layer Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxx> --- drivers/tty/serial/serial_core.c | 15 +++++++++++++++ include/linux/serial_core.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 29a7be4..2797f65 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1322,6 +1322,17 @@ static void uart_set_termios(struct tty_struct *tty, } } +static int uart_set_rs485(struct tty_struct *tty, struct serial_rs485 *rs485) +{ + struct uart_state *state = tty->driver_data; + struct uart_port *uport = state->uart_port; + + if (uport->ops->set_rs485) + return uport->ops->set_rs485(uport, rs485); + return -EOPNOTSUPP; +} + + /* * Calls to uart_close() are serialised via the tty_lock in * drivers/tty/tty_io.c:tty_release() @@ -1484,6 +1495,9 @@ static void uart_hangup(struct tty_struct *tty) static int uart_port_activate(struct tty_port *port, struct tty_struct *tty) { + struct uart_state *state = container_of(port, struct uart_state, port); + if (state->rs485) + tty->rs485 = state->rs485; return 0; } @@ -2267,6 +2281,7 @@ static const struct tty_operations uart_ops = { .send_xchar = uart_send_xchar, .set_termios = uart_set_termios, .set_ldisc = uart_set_ldisc, + .set_rs485 = uart_set_rs485, .stop = uart_stop, .start = uart_start, .hangup = uart_hangup, diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index cf3a1e7..06227f7 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -64,6 +64,8 @@ struct uart_ops { void (*set_termios)(struct uart_port *, struct ktermios *new, struct ktermios *old); void (*set_ldisc)(struct uart_port *, int new); + int (*set_rs485)(struct uart_port *, + struct serial_rs485 *rs485); void (*pm)(struct uart_port *, unsigned int state, unsigned int oldstate); @@ -202,6 +204,7 @@ struct uart_port { struct attribute_group *attr_group; /* port specific attributes */ const struct attribute_group **tty_groups; /* all attributes (serial core use only) */ void *private_data; /* generic platform data pointer */ + struct serial_rs485 *rs485; }; static inline int serial_port_in(struct uart_port *up, int offset) @@ -236,6 +239,7 @@ struct uart_state { struct circ_buf xmit; struct uart_port *uart_port; + struct serial_rs485 *rs485; }; #define UART_XMIT_SIZE PAGE_SIZE -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html