diff options
author | Alan Cox <alan@linux.intel.com> | 2010-06-01 16:52:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:40 -0400 |
commit | b4eda9cb48eac1b7369ad33e5d015c33b4376431 (patch) | |
tree | 0faa2f1af52804731765b3793436c0b00956fe2e /drivers/char/stallion.c | |
parent | 8fd4bd22350784d5b2fe9274f6790ba353976415 (diff) |
stallion: prune lock_kernel calls
Remove unneeded tty layer lock kernel bits. Relock the needed bits using the
port mutex. The istallion still has brd state races but those are not new
or introduced by the removal of the lock_kernel logic.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/stallion.c')
-rw-r--r-- | drivers/char/stallion.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 6049fd731924..f2167f8e5aab 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -807,7 +807,6 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
807 | timeout = HZ; | 807 | timeout = HZ; |
808 | tend = jiffies + timeout; | 808 | tend = jiffies + timeout; |
809 | 809 | ||
810 | lock_kernel(); | ||
811 | while (stl_datastate(portp)) { | 810 | while (stl_datastate(portp)) { |
812 | if (signal_pending(current)) | 811 | if (signal_pending(current)) |
813 | break; | 812 | break; |
@@ -815,7 +814,6 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
815 | if (time_after_eq(jiffies, tend)) | 814 | if (time_after_eq(jiffies, tend)) |
816 | break; | 815 | break; |
817 | } | 816 | } |
818 | unlock_kernel(); | ||
819 | } | 817 | } |
820 | 818 | ||
821 | /*****************************************************************************/ | 819 | /*****************************************************************************/ |
@@ -1029,6 +1027,8 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp) | |||
1029 | pr_debug("stl_getserial(portp=%p,sp=%p)\n", portp, sp); | 1027 | pr_debug("stl_getserial(portp=%p,sp=%p)\n", portp, sp); |
1030 | 1028 | ||
1031 | memset(&sio, 0, sizeof(struct serial_struct)); | 1029 | memset(&sio, 0, sizeof(struct serial_struct)); |
1030 | |||
1031 | mutex_lock(&portp->port.mutex); | ||
1032 | sio.line = portp->portnr; | 1032 | sio.line = portp->portnr; |
1033 | sio.port = portp->ioaddr; | 1033 | sio.port = portp->ioaddr; |
1034 | sio.flags = portp->port.flags; | 1034 | sio.flags = portp->port.flags; |
@@ -1048,6 +1048,7 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp) | |||
1048 | brdp = stl_brds[portp->brdnr]; | 1048 | brdp = stl_brds[portp->brdnr]; |
1049 | if (brdp != NULL) | 1049 | if (brdp != NULL) |
1050 | sio.irq = brdp->irq; | 1050 | sio.irq = brdp->irq; |
1051 | mutex_unlock(&portp->port.mutex); | ||
1051 | 1052 | ||
1052 | return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? -EFAULT : 0; | 1053 | return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? -EFAULT : 0; |
1053 | } | 1054 | } |
@@ -1069,12 +1070,15 @@ static int stl_setserial(struct tty_struct *tty, struct serial_struct __user *sp | |||
1069 | 1070 | ||
1070 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) | 1071 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) |
1071 | return -EFAULT; | 1072 | return -EFAULT; |
1073 | mutex_lock(&portp->port.mutex); | ||
1072 | if (!capable(CAP_SYS_ADMIN)) { | 1074 | if (!capable(CAP_SYS_ADMIN)) { |
1073 | if ((sio.baud_base != portp->baud_base) || | 1075 | if ((sio.baud_base != portp->baud_base) || |
1074 | (sio.close_delay != portp->close_delay) || | 1076 | (sio.close_delay != portp->close_delay) || |
1075 | ((sio.flags & ~ASYNC_USR_MASK) != | 1077 | ((sio.flags & ~ASYNC_USR_MASK) != |
1076 | (portp->port.flags & ~ASYNC_USR_MASK))) | 1078 | (portp->port.flags & ~ASYNC_USR_MASK))) { |
1079 | mutex_unlock(&portp->port.mutex); | ||
1077 | return -EPERM; | 1080 | return -EPERM; |
1081 | } | ||
1078 | } | 1082 | } |
1079 | 1083 | ||
1080 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | | 1084 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | |
@@ -1083,6 +1087,7 @@ static int stl_setserial(struct tty_struct *tty, struct serial_struct __user *sp | |||
1083 | portp->close_delay = sio.close_delay; | 1087 | portp->close_delay = sio.close_delay; |
1084 | portp->closing_wait = sio.closing_wait; | 1088 | portp->closing_wait = sio.closing_wait; |
1085 | portp->custom_divisor = sio.custom_divisor; | 1089 | portp->custom_divisor = sio.custom_divisor; |
1090 | mutex_unlock(&portp->port.mutex); | ||
1086 | stl_setport(portp, tty->termios); | 1091 | stl_setport(portp, tty->termios); |
1087 | return 0; | 1092 | return 0; |
1088 | } | 1093 | } |
@@ -1147,8 +1152,6 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1147 | 1152 | ||
1148 | rc = 0; | 1153 | rc = 0; |
1149 | 1154 | ||
1150 | lock_kernel(); | ||
1151 | |||
1152 | switch (cmd) { | 1155 | switch (cmd) { |
1153 | case TIOCGSERIAL: | 1156 | case TIOCGSERIAL: |
1154 | rc = stl_getserial(portp, argp); | 1157 | rc = stl_getserial(portp, argp); |
@@ -1173,7 +1176,6 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1173 | rc = -ENOIOCTLCMD; | 1176 | rc = -ENOIOCTLCMD; |
1174 | break; | 1177 | break; |
1175 | } | 1178 | } |
1176 | unlock_kernel(); | ||
1177 | return rc; | 1179 | return rc; |
1178 | } | 1180 | } |
1179 | 1181 | ||
@@ -2327,6 +2329,7 @@ static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comst | |||
2327 | return -ENODEV; | 2329 | return -ENODEV; |
2328 | } | 2330 | } |
2329 | 2331 | ||
2332 | mutex_lock(&portp->port.mutex); | ||
2330 | portp->stats.state = portp->istate; | 2333 | portp->stats.state = portp->istate; |
2331 | portp->stats.flags = portp->port.flags; | 2334 | portp->stats.flags = portp->port.flags; |
2332 | portp->stats.hwid = portp->hwid; | 2335 | portp->stats.hwid = portp->hwid; |
@@ -2358,6 +2361,7 @@ static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comst | |||
2358 | (STL_TXBUFSIZE - (tail - head)); | 2361 | (STL_TXBUFSIZE - (tail - head)); |
2359 | 2362 | ||
2360 | portp->stats.signals = (unsigned long) stl_getsignals(portp); | 2363 | portp->stats.signals = (unsigned long) stl_getsignals(portp); |
2364 | mutex_unlock(&portp->port.mutex); | ||
2361 | 2365 | ||
2362 | return copy_to_user(cp, &portp->stats, | 2366 | return copy_to_user(cp, &portp->stats, |
2363 | sizeof(comstats_t)) ? -EFAULT : 0; | 2367 | sizeof(comstats_t)) ? -EFAULT : 0; |
@@ -2382,10 +2386,12 @@ static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp) | |||
2382 | return -ENODEV; | 2386 | return -ENODEV; |
2383 | } | 2387 | } |
2384 | 2388 | ||
2389 | mutex_lock(&portp->port.mutex); | ||
2385 | memset(&portp->stats, 0, sizeof(comstats_t)); | 2390 | memset(&portp->stats, 0, sizeof(comstats_t)); |
2386 | portp->stats.brd = portp->brdnr; | 2391 | portp->stats.brd = portp->brdnr; |
2387 | portp->stats.panel = portp->panelnr; | 2392 | portp->stats.panel = portp->panelnr; |
2388 | portp->stats.port = portp->portnr; | 2393 | portp->stats.port = portp->portnr; |
2394 | mutex_unlock(&portp->port.mutex); | ||
2389 | return copy_to_user(cp, &portp->stats, | 2395 | return copy_to_user(cp, &portp->stats, |
2390 | sizeof(comstats_t)) ? -EFAULT : 0; | 2396 | sizeof(comstats_t)) ? -EFAULT : 0; |
2391 | } | 2397 | } |
@@ -2451,7 +2457,6 @@ static long stl_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
2451 | return -ENODEV; | 2457 | return -ENODEV; |
2452 | rc = 0; | 2458 | rc = 0; |
2453 | 2459 | ||
2454 | lock_kernel(); | ||
2455 | switch (cmd) { | 2460 | switch (cmd) { |
2456 | case COM_GETPORTSTATS: | 2461 | case COM_GETPORTSTATS: |
2457 | rc = stl_getportstats(NULL, NULL, argp); | 2462 | rc = stl_getportstats(NULL, NULL, argp); |
@@ -2472,7 +2477,6 @@ static long stl_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
2472 | rc = -ENOIOCTLCMD; | 2477 | rc = -ENOIOCTLCMD; |
2473 | break; | 2478 | break; |
2474 | } | 2479 | } |
2475 | unlock_kernel(); | ||
2476 | return rc; | 2480 | return rc; |
2477 | } | 2481 | } |
2478 | 2482 | ||