diff options
-rw-r--r-- | drivers/tty/serial/sc16is7xx.c | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 7a7911384eca..df9a384dfbda 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c | |||
@@ -304,8 +304,6 @@ struct sc16is7xx_one { | |||
304 | struct uart_port port; | 304 | struct uart_port port; |
305 | struct work_struct tx_work; | 305 | struct work_struct tx_work; |
306 | struct work_struct md_work; | 306 | struct work_struct md_work; |
307 | |||
308 | struct serial_rs485 rs485; | ||
309 | }; | 307 | }; |
310 | 308 | ||
311 | struct sc16is7xx_port { | 309 | struct sc16is7xx_port { |
@@ -657,15 +655,15 @@ static void sc16is7xx_stop_tx(struct uart_port* port) | |||
657 | struct circ_buf *xmit = &one->port.state->xmit; | 655 | struct circ_buf *xmit = &one->port.state->xmit; |
658 | 656 | ||
659 | /* handle rs485 */ | 657 | /* handle rs485 */ |
660 | if (one->rs485.flags & SER_RS485_ENABLED) { | 658 | if (port->rs485.flags & SER_RS485_ENABLED) { |
661 | /* do nothing if current tx not yet completed */ | 659 | /* do nothing if current tx not yet completed */ |
662 | int lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG); | 660 | int lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG); |
663 | if (!(lsr & SC16IS7XX_LSR_TEMT_BIT)) | 661 | if (!(lsr & SC16IS7XX_LSR_TEMT_BIT)) |
664 | return; | 662 | return; |
665 | 663 | ||
666 | if (uart_circ_empty(xmit) && | 664 | if (uart_circ_empty(xmit) && |
667 | (one->rs485.delay_rts_after_send > 0)) | 665 | (port->rs485.delay_rts_after_send > 0)) |
668 | mdelay(one->rs485.delay_rts_after_send); | 666 | mdelay(port->rs485.delay_rts_after_send); |
669 | } | 667 | } |
670 | 668 | ||
671 | sc16is7xx_port_update(port, SC16IS7XX_IER_REG, | 669 | sc16is7xx_port_update(port, SC16IS7XX_IER_REG, |
@@ -688,9 +686,9 @@ static void sc16is7xx_start_tx(struct uart_port *port) | |||
688 | struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); | 686 | struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); |
689 | 687 | ||
690 | /* handle rs485 */ | 688 | /* handle rs485 */ |
691 | if ((one->rs485.flags & SER_RS485_ENABLED) && | 689 | if ((port->rs485.flags & SER_RS485_ENABLED) && |
692 | (one->rs485.delay_rts_before_send > 0)) { | 690 | (port->rs485.delay_rts_before_send > 0)) { |
693 | mdelay(one->rs485.delay_rts_before_send); | 691 | mdelay(port->rs485.delay_rts_before_send); |
694 | } | 692 | } |
695 | 693 | ||
696 | if (!work_pending(&one->tx_work)) | 694 | if (!work_pending(&one->tx_work)) |
@@ -830,47 +828,20 @@ static void sc16is7xx_set_termios(struct uart_port *port, | |||
830 | uart_update_timeout(port, termios->c_cflag, baud); | 828 | uart_update_timeout(port, termios->c_cflag, baud); |
831 | } | 829 | } |
832 | 830 | ||
833 | static void sc16is7xx_config_rs485(struct uart_port *port, | 831 | static int sc16is7xx_config_rs485(struct uart_port *port, |
834 | struct serial_rs485 *rs485) | 832 | struct serial_rs485 *rs485) |
835 | { | 833 | { |
836 | struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); | 834 | if (port->rs485.flags & SER_RS485_ENABLED) |
837 | |||
838 | one->rs485 = *rs485; | ||
839 | |||
840 | if (one->rs485.flags & SER_RS485_ENABLED) { | ||
841 | sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, | 835 | sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, |
842 | SC16IS7XX_EFCR_AUTO_RS485_BIT, | 836 | SC16IS7XX_EFCR_AUTO_RS485_BIT, |
843 | SC16IS7XX_EFCR_AUTO_RS485_BIT); | 837 | SC16IS7XX_EFCR_AUTO_RS485_BIT); |
844 | } else { | 838 | else |
845 | sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, | 839 | sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, |
846 | SC16IS7XX_EFCR_AUTO_RS485_BIT, | 840 | SC16IS7XX_EFCR_AUTO_RS485_BIT, |
847 | 0); | 841 | 0); |
848 | } | 842 | port->rs485 = *rs485; |
849 | } | ||
850 | |||
851 | static int sc16is7xx_ioctl(struct uart_port *port, unsigned int cmd, | ||
852 | unsigned long arg) | ||
853 | { | ||
854 | struct serial_rs485 rs485; | ||
855 | 843 | ||
856 | switch (cmd) { | 844 | return 0; |
857 | case TIOCSRS485: | ||
858 | if (copy_from_user(&rs485, (void __user *)arg, sizeof(rs485))) | ||
859 | return -EFAULT; | ||
860 | |||
861 | sc16is7xx_config_rs485(port, &rs485); | ||
862 | return 0; | ||
863 | case TIOCGRS485: | ||
864 | if (copy_to_user((void __user *)arg, | ||
865 | &(to_sc16is7xx_one(port, port)->rs485), | ||
866 | sizeof(rs485))) | ||
867 | return -EFAULT; | ||
868 | return 0; | ||
869 | default: | ||
870 | break; | ||
871 | } | ||
872 | |||
873 | return -ENOIOCTLCMD; | ||
874 | } | 845 | } |
875 | 846 | ||
876 | static int sc16is7xx_startup(struct uart_port *port) | 847 | static int sc16is7xx_startup(struct uart_port *port) |
@@ -996,7 +967,6 @@ static const struct uart_ops sc16is7xx_ops = { | |||
996 | .release_port = sc16is7xx_null_void, | 967 | .release_port = sc16is7xx_null_void, |
997 | .config_port = sc16is7xx_config_port, | 968 | .config_port = sc16is7xx_config_port, |
998 | .verify_port = sc16is7xx_verify_port, | 969 | .verify_port = sc16is7xx_verify_port, |
999 | .ioctl = sc16is7xx_ioctl, | ||
1000 | .pm = sc16is7xx_pm, | 970 | .pm = sc16is7xx_pm, |
1001 | }; | 971 | }; |
1002 | 972 | ||
@@ -1126,6 +1096,7 @@ static int sc16is7xx_probe(struct device *dev, | |||
1126 | s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; | 1096 | s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; |
1127 | s->p[i].port.iotype = UPIO_PORT; | 1097 | s->p[i].port.iotype = UPIO_PORT; |
1128 | s->p[i].port.uartclk = freq; | 1098 | s->p[i].port.uartclk = freq; |
1099 | s->p[i].port.rs485_config = sc16is7xx_config_rs485; | ||
1129 | s->p[i].port.ops = &sc16is7xx_ops; | 1100 | s->p[i].port.ops = &sc16is7xx_ops; |
1130 | /* Disable all interrupts */ | 1101 | /* Disable all interrupts */ |
1131 | sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); | 1102 | sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); |