diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-30 03:53:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:45 -0400 |
commit | 978e595f88a1fba5869aa42a4af4fba36f33ecac (patch) | |
tree | 60848f49949c5b7b518621ee36cdc6d500244539 /drivers/serial | |
parent | ac0e4b7d319bf284bb64bc7e1c051417386b34a4 (diff) |
tty/serial: lay the foundations for the next set of reworks
- Stop drivers calling their own flush method indirectly, it obfuscates code
and it will change soon anyway
- A few more lock_kernel paths temporarily needed in some driver internal
waiting code
- Remove private put_char method that does a write call for one char - we
have that anyway
- Most but not yet all of the termios copy under lock fixing (some has other
dependencies to follow)
- Note a few locking bugs in drivers found in the process
- Kill remaining [ab]users of TIOCG/SSOFTCAR in the driver, these must go to
fix the termios locking
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/68328serial.c | 18 | ||||
-rw-r--r-- | drivers/serial/68360serial.c | 17 | ||||
-rw-r--r-- | drivers/serial/crisv10.c | 23 | ||||
-rw-r--r-- | drivers/serial/mcfserial.c | 18 | ||||
-rw-r--r-- | drivers/serial/netx-serial.c | 1 |
5 files changed, 20 insertions, 57 deletions
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c index 2b8a410e0959..5ce3e57bff0b 100644 --- a/drivers/serial/68328serial.c +++ b/drivers/serial/68328serial.c | |||
@@ -1017,18 +1017,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, | |||
1017 | tty_wait_until_sent(tty, 0); | 1017 | tty_wait_until_sent(tty, 0); |
1018 | send_break(info, arg ? arg*(100) : 250); | 1018 | send_break(info, arg ? arg*(100) : 250); |
1019 | return 0; | 1019 | return 0; |
1020 | case TIOCGSOFTCAR: | ||
1021 | error = put_user(C_CLOCAL(tty) ? 1 : 0, | ||
1022 | (unsigned long *) arg); | ||
1023 | if (error) | ||
1024 | return error; | ||
1025 | return 0; | ||
1026 | case TIOCSSOFTCAR: | ||
1027 | get_user(arg, (unsigned long *) arg); | ||
1028 | tty->termios->c_cflag = | ||
1029 | ((tty->termios->c_cflag & ~CLOCAL) | | ||
1030 | (arg ? CLOCAL : 0)); | ||
1031 | return 0; | ||
1032 | case TIOCGSERIAL: | 1020 | case TIOCGSERIAL: |
1033 | if (access_ok(VERIFY_WRITE, (void *) arg, | 1021 | if (access_ok(VERIFY_WRITE, (void *) arg, |
1034 | sizeof(struct serial_struct))) | 1022 | sizeof(struct serial_struct))) |
@@ -1061,9 +1049,6 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1061 | { | 1049 | { |
1062 | struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; | 1050 | struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; |
1063 | 1051 | ||
1064 | if (tty->termios->c_cflag == old_termios->c_cflag) | ||
1065 | return; | ||
1066 | |||
1067 | change_speed(info); | 1052 | change_speed(info); |
1068 | 1053 | ||
1069 | if ((old_termios->c_cflag & CRTSCTS) && | 1054 | if ((old_termios->c_cflag & CRTSCTS) && |
@@ -1140,8 +1125,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1140 | uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); | 1125 | uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); |
1141 | 1126 | ||
1142 | shutdown(info); | 1127 | shutdown(info); |
1143 | if (tty->driver->flush_buffer) | 1128 | rs_flush_buffer(tty); |
1144 | tty->driver->flush_buffer(tty); | ||
1145 | 1129 | ||
1146 | tty_ldisc_flush(tty); | 1130 | tty_ldisc_flush(tty); |
1147 | tty->closing = 0; | 1131 | tty->closing = 0; |
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c index 6f540107d0bb..f4f737bfa0a7 100644 --- a/drivers/serial/68360serial.c +++ b/drivers/serial/68360serial.c | |||
@@ -1436,18 +1436,6 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file, | |||
1436 | return retval; | 1436 | return retval; |
1437 | end_break(info); | 1437 | end_break(info); |
1438 | return 0; | 1438 | return 0; |
1439 | case TIOCGSOFTCAR: | ||
1440 | /* return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); */ | ||
1441 | put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); | ||
1442 | return 0; | ||
1443 | case TIOCSSOFTCAR: | ||
1444 | error = get_user(arg, (unsigned int *) arg); | ||
1445 | if (error) | ||
1446 | return error; | ||
1447 | tty->termios->c_cflag = | ||
1448 | ((tty->termios->c_cflag & ~CLOCAL) | | ||
1449 | (arg ? CLOCAL : 0)); | ||
1450 | return 0; | ||
1451 | #ifdef maybe | 1439 | #ifdef maybe |
1452 | case TIOCSERGETLSR: /* Get line status register */ | 1440 | case TIOCSERGETLSR: /* Get line status register */ |
1453 | return get_lsr_info(info, (unsigned int *) arg); | 1441 | return get_lsr_info(info, (unsigned int *) arg); |
@@ -1665,8 +1653,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp) | |||
1665 | rs_360_wait_until_sent(tty, info->timeout); | 1653 | rs_360_wait_until_sent(tty, info->timeout); |
1666 | } | 1654 | } |
1667 | shutdown(info); | 1655 | shutdown(info); |
1668 | if (tty->driver->flush_buffer) | 1656 | rs_360_flush_buffer(tty); |
1669 | tty->driver->flush_buffer(tty); | ||
1670 | tty_ldisc_flush(tty); | 1657 | tty_ldisc_flush(tty); |
1671 | tty->closing = 0; | 1658 | tty->closing = 0; |
1672 | info->event = 0; | 1659 | info->event = 0; |
@@ -1717,6 +1704,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1717 | printk("jiff=%lu...", jiffies); | 1704 | printk("jiff=%lu...", jiffies); |
1718 | #endif | 1705 | #endif |
1719 | 1706 | ||
1707 | lock_kernel(); | ||
1720 | /* We go through the loop at least once because we can't tell | 1708 | /* We go through the loop at least once because we can't tell |
1721 | * exactly when the last character exits the shifter. There can | 1709 | * exactly when the last character exits the shifter. There can |
1722 | * be at least two characters waiting to be sent after the buffers | 1710 | * be at least two characters waiting to be sent after the buffers |
@@ -1745,6 +1733,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1745 | bdp--; | 1733 | bdp--; |
1746 | } while (bdp->status & BD_SC_READY); | 1734 | } while (bdp->status & BD_SC_READY); |
1747 | current->state = TASK_RUNNING; | 1735 | current->state = TASK_RUNNING; |
1736 | unlock_kernel(); | ||
1748 | #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT | 1737 | #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT |
1749 | printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); | 1738 | printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); |
1750 | #endif | 1739 | #endif |
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 88e7c1d5b919..8b9af73c1d59 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -3581,8 +3581,9 @@ rs_tiocmset(struct tty_struct *tty, struct file *file, | |||
3581 | unsigned int set, unsigned int clear) | 3581 | unsigned int set, unsigned int clear) |
3582 | { | 3582 | { |
3583 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3583 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3584 | unsigned long flags; | ||
3584 | 3585 | ||
3585 | lock_kernel(); | 3586 | local_irq_save(flags); |
3586 | 3587 | ||
3587 | if (clear & TIOCM_RTS) | 3588 | if (clear & TIOCM_RTS) |
3588 | e100_rts(info, 0); | 3589 | e100_rts(info, 0); |
@@ -3604,7 +3605,7 @@ rs_tiocmset(struct tty_struct *tty, struct file *file, | |||
3604 | if (set & TIOCM_CD) | 3605 | if (set & TIOCM_CD) |
3605 | e100_cd_out(info, 1); | 3606 | e100_cd_out(info, 1); |
3606 | 3607 | ||
3607 | unlock_kernel(); | 3608 | local_irq_restore(flags); |
3608 | return 0; | 3609 | return 0; |
3609 | } | 3610 | } |
3610 | 3611 | ||
@@ -3613,8 +3614,10 @@ rs_tiocmget(struct tty_struct *tty, struct file *file) | |||
3613 | { | 3614 | { |
3614 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3615 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3615 | unsigned int result; | 3616 | unsigned int result; |
3617 | unsigned long flags; | ||
3618 | |||
3619 | local_irq_save(flags); | ||
3616 | 3620 | ||
3617 | lock_kernel(); | ||
3618 | result = | 3621 | result = |
3619 | (!E100_RTS_GET(info) ? TIOCM_RTS : 0) | 3622 | (!E100_RTS_GET(info) ? TIOCM_RTS : 0) |
3620 | | (!E100_DTR_GET(info) ? TIOCM_DTR : 0) | 3623 | | (!E100_DTR_GET(info) ? TIOCM_DTR : 0) |
@@ -3623,7 +3626,7 @@ rs_tiocmget(struct tty_struct *tty, struct file *file) | |||
3623 | | (!E100_CD_GET(info) ? TIOCM_CAR : 0) | 3626 | | (!E100_CD_GET(info) ? TIOCM_CAR : 0) |
3624 | | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); | 3627 | | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); |
3625 | 3628 | ||
3626 | unlock_kernel(); | 3629 | local_irq_restore(flags); |
3627 | 3630 | ||
3628 | #ifdef SERIAL_DEBUG_IO | 3631 | #ifdef SERIAL_DEBUG_IO |
3629 | printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n", | 3632 | printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n", |
@@ -3702,10 +3705,6 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
3702 | { | 3705 | { |
3703 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3706 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3704 | 3707 | ||
3705 | if (tty->termios->c_cflag == old_termios->c_cflag && | ||
3706 | tty->termios->c_iflag == old_termios->c_iflag) | ||
3707 | return; | ||
3708 | |||
3709 | change_speed(info); | 3708 | change_speed(info); |
3710 | 3709 | ||
3711 | /* Handle turning off CRTSCTS */ | 3710 | /* Handle turning off CRTSCTS */ |
@@ -3808,10 +3807,8 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3808 | #endif | 3807 | #endif |
3809 | 3808 | ||
3810 | shutdown(info); | 3809 | shutdown(info); |
3811 | if (tty->driver->flush_buffer) | 3810 | rs_flush_buffer(tty); |
3812 | tty->driver->flush_buffer(tty); | 3811 | tty_ldisc_flush_buffer(tty); |
3813 | if (tty->ldisc.flush_buffer) | ||
3814 | tty->ldisc.flush_buffer(tty); | ||
3815 | tty->closing = 0; | 3812 | tty->closing = 0; |
3816 | info->event = 0; | 3813 | info->event = 0; |
3817 | info->tty = 0; | 3814 | info->tty = 0; |
@@ -3885,6 +3882,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) | |||
3885 | * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO | 3882 | * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO |
3886 | * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k) | 3883 | * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k) |
3887 | */ | 3884 | */ |
3885 | lock_kernel(); | ||
3888 | orig_jiffies = jiffies; | 3886 | orig_jiffies = jiffies; |
3889 | while (info->xmit.head != info->xmit.tail || /* More in send queue */ | 3887 | while (info->xmit.head != info->xmit.tail || /* More in send queue */ |
3890 | (*info->ostatusadr & 0x007f) || /* more in FIFO */ | 3888 | (*info->ostatusadr & 0x007f) || /* more in FIFO */ |
@@ -3901,6 +3899,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) | |||
3901 | curr_time_usec - info->last_tx_active_usec; | 3899 | curr_time_usec - info->last_tx_active_usec; |
3902 | } | 3900 | } |
3903 | set_current_state(TASK_RUNNING); | 3901 | set_current_state(TASK_RUNNING); |
3902 | unlock_kernel(); | ||
3904 | } | 3903 | } |
3905 | 3904 | ||
3906 | /* | 3905 | /* |
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c index ddd3aa50d4ad..aafa1704e1ab 100644 --- a/drivers/serial/mcfserial.c +++ b/drivers/serial/mcfserial.c | |||
@@ -1072,18 +1072,6 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file, | |||
1072 | tty_wait_until_sent(tty, 0); | 1072 | tty_wait_until_sent(tty, 0); |
1073 | send_break(info, arg ? arg*(HZ/10) : HZ/4); | 1073 | send_break(info, arg ? arg*(HZ/10) : HZ/4); |
1074 | return 0; | 1074 | return 0; |
1075 | case TIOCGSOFTCAR: | ||
1076 | error = put_user(C_CLOCAL(tty) ? 1 : 0, | ||
1077 | (unsigned long *) arg); | ||
1078 | if (error) | ||
1079 | return error; | ||
1080 | return 0; | ||
1081 | case TIOCSSOFTCAR: | ||
1082 | get_user(arg, (unsigned long *) arg); | ||
1083 | tty->termios->c_cflag = | ||
1084 | ((tty->termios->c_cflag & ~CLOCAL) | | ||
1085 | (arg ? CLOCAL : 0)); | ||
1086 | return 0; | ||
1087 | case TIOCGSERIAL: | 1075 | case TIOCGSERIAL: |
1088 | if (access_ok(VERIFY_WRITE, (void *) arg, | 1076 | if (access_ok(VERIFY_WRITE, (void *) arg, |
1089 | sizeof(struct serial_struct))) | 1077 | sizeof(struct serial_struct))) |
@@ -1222,8 +1210,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp) | |||
1222 | } else | 1210 | } else |
1223 | #endif | 1211 | #endif |
1224 | shutdown(info); | 1212 | shutdown(info); |
1225 | if (tty->driver->flush_buffer) | 1213 | mcfrs_flush_buffer(tty); |
1226 | tty->driver->flush_buffer(tty); | ||
1227 | tty_ldisc_flush(tty); | 1214 | tty_ldisc_flush(tty); |
1228 | 1215 | ||
1229 | tty->closing = 0; | 1216 | tty->closing = 0; |
@@ -1276,6 +1263,8 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1276 | * Note: we have to use pretty tight timings here to satisfy | 1263 | * Note: we have to use pretty tight timings here to satisfy |
1277 | * the NIST-PCTS. | 1264 | * the NIST-PCTS. |
1278 | */ | 1265 | */ |
1266 | lock_kernel(); | ||
1267 | |||
1279 | fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; | 1268 | fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; |
1280 | char_time = fifo_time / 5; | 1269 | char_time = fifo_time / 5; |
1281 | if (char_time == 0) | 1270 | if (char_time == 0) |
@@ -1312,6 +1301,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1312 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) | 1301 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) |
1313 | break; | 1302 | break; |
1314 | } | 1303 | } |
1304 | unlock_kernel(); | ||
1315 | #else | 1305 | #else |
1316 | /* | 1306 | /* |
1317 | * For the other coldfire models, assume all data has been sent | 1307 | * For the other coldfire models, assume all data has been sent |
diff --git a/drivers/serial/netx-serial.c b/drivers/serial/netx-serial.c index 3123ffeac8ad..81ac9bb4f39b 100644 --- a/drivers/serial/netx-serial.c +++ b/drivers/serial/netx-serial.c | |||
@@ -287,6 +287,7 @@ static void netx_set_mctrl(struct uart_port *port, unsigned int mctrl) | |||
287 | { | 287 | { |
288 | unsigned int val; | 288 | unsigned int val; |
289 | 289 | ||
290 | /* FIXME: Locking needed ? */ | ||
290 | if (mctrl & TIOCM_RTS) { | 291 | if (mctrl & TIOCM_RTS) { |
291 | val = readl(port->membase + UART_RTS_CR); | 292 | val = readl(port->membase + UART_RTS_CR); |
292 | writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR); | 293 | writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR); |