aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/riscom8.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-06-01 16:52:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 16:47:40 -0400
commitbf936f92a7a564a2cdb44bbe3bc797cd811bf625 (patch)
tree248f4515b8bcb0ea7d8b585ed5eaf0d1f66c0e6b /drivers/char/riscom8.c
parent8a1e803d0148e320b9200a442dfb88f8cbde88e7 (diff)
riscom8: kill use of lock_kernel
The riscom8 board uses lock_kernel to protect bits of the port setting ioctl logic. We can use the port mutex for this as the logic is internal and will also lock set versus open (a locking property that has been lost somewhere along the way) 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/riscom8.c')
-rw-r--r--drivers/char/riscom8.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index b02332a5412f..af4de1fe8445 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -47,7 +47,6 @@
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/tty_flip.h> 49#include <linux/tty_flip.h>
50#include <linux/smp_lock.h>
51#include <linux/spinlock.h> 50#include <linux/spinlock.h>
52#include <linux/device.h> 51#include <linux/device.h>
53 52
@@ -1184,6 +1183,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
1184 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) 1183 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1185 return -EFAULT; 1184 return -EFAULT;
1186 1185
1186 mutex_lock(&port->port.mutex);
1187 change_speed = ((port->port.flags & ASYNC_SPD_MASK) != 1187 change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
1188 (tmp.flags & ASYNC_SPD_MASK)); 1188 (tmp.flags & ASYNC_SPD_MASK));
1189 1189
@@ -1191,8 +1191,10 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
1191 if ((tmp.close_delay != port->port.close_delay) || 1191 if ((tmp.close_delay != port->port.close_delay) ||
1192 (tmp.closing_wait != port->port.closing_wait) || 1192 (tmp.closing_wait != port->port.closing_wait) ||
1193 ((tmp.flags & ~ASYNC_USR_MASK) != 1193 ((tmp.flags & ~ASYNC_USR_MASK) !=
1194 (port->port.flags & ~ASYNC_USR_MASK))) 1194 (port->port.flags & ~ASYNC_USR_MASK))) {
1195 mutex_unlock(&port->port.mutex);
1195 return -EPERM; 1196 return -EPERM;
1197 }
1196 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | 1198 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
1197 (tmp.flags & ASYNC_USR_MASK)); 1199 (tmp.flags & ASYNC_USR_MASK));
1198 } else { 1200 } else {
@@ -1208,6 +1210,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
1208 rc_change_speed(tty, bp, port); 1210 rc_change_speed(tty, bp, port);
1209 spin_unlock_irqrestore(&riscom_lock, flags); 1211 spin_unlock_irqrestore(&riscom_lock, flags);
1210 } 1212 }
1213 mutex_unlock(&port->port.mutex);
1211 return 0; 1214 return 0;
1212} 1215}
1213 1216
@@ -1220,12 +1223,15 @@ static int rc_get_serial_info(struct riscom_port *port,
1220 memset(&tmp, 0, sizeof(tmp)); 1223 memset(&tmp, 0, sizeof(tmp));
1221 tmp.type = PORT_CIRRUS; 1224 tmp.type = PORT_CIRRUS;
1222 tmp.line = port - rc_port; 1225 tmp.line = port - rc_port;
1226
1227 mutex_lock(&port->port.mutex);
1223 tmp.port = bp->base; 1228 tmp.port = bp->base;
1224 tmp.irq = bp->irq; 1229 tmp.irq = bp->irq;
1225 tmp.flags = port->port.flags; 1230 tmp.flags = port->port.flags;
1226 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC; 1231 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1227 tmp.close_delay = port->port.close_delay * HZ/100; 1232 tmp.close_delay = port->port.close_delay * HZ/100;
1228 tmp.closing_wait = port->port.closing_wait * HZ/100; 1233 tmp.closing_wait = port->port.closing_wait * HZ/100;
1234 mutex_unlock(&port->port.mutex);
1229 tmp.xmit_fifo_size = CD180_NFIFO; 1235 tmp.xmit_fifo_size = CD180_NFIFO;
1230 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; 1236 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1231} 1237}
@@ -1242,14 +1248,10 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp,
1242 1248
1243 switch (cmd) { 1249 switch (cmd) {
1244 case TIOCGSERIAL: 1250 case TIOCGSERIAL:
1245 lock_kernel();
1246 retval = rc_get_serial_info(port, argp); 1251 retval = rc_get_serial_info(port, argp);
1247 unlock_kernel();
1248 break; 1252 break;
1249 case TIOCSSERIAL: 1253 case TIOCSSERIAL:
1250 lock_kernel();
1251 retval = rc_set_serial_info(tty, port, argp); 1254 retval = rc_set_serial_info(tty, port, argp);
1252 unlock_kernel();
1253 break; 1255 break;
1254 default: 1256 default:
1255 retval = -ENOIOCTLCMD; 1257 retval = -ENOIOCTLCMD;