Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
bf936f92 8a1e803d

+8 -6
+8 -6
drivers/char/riscom8.c
··· 47 47 #include <linux/init.h> 48 48 #include <linux/delay.h> 49 49 #include <linux/tty_flip.h> 50 - #include <linux/smp_lock.h> 51 50 #include <linux/spinlock.h> 52 51 #include <linux/device.h> 53 52 ··· 1183 1184 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) 1184 1185 return -EFAULT; 1185 1186 1187 + mutex_lock(&port->port.mutex); 1186 1188 change_speed = ((port->port.flags & ASYNC_SPD_MASK) != 1187 1189 (tmp.flags & ASYNC_SPD_MASK)); 1188 1190 ··· 1191 1191 if ((tmp.close_delay != port->port.close_delay) || 1192 1192 (tmp.closing_wait != port->port.closing_wait) || 1193 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 1196 return -EPERM; 1197 + } 1196 1198 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | 1197 1199 (tmp.flags & ASYNC_USR_MASK)); 1198 1200 } else { ··· 1210 1208 rc_change_speed(tty, bp, port); 1211 1209 spin_unlock_irqrestore(&riscom_lock, flags); 1212 1210 } 1211 + mutex_unlock(&port->port.mutex); 1213 1212 return 0; 1214 1213 } 1215 1214 ··· 1223 1220 memset(&tmp, 0, sizeof(tmp)); 1224 1221 tmp.type = PORT_CIRRUS; 1225 1222 tmp.line = port - rc_port; 1223 + 1224 + mutex_lock(&port->port.mutex); 1226 1225 tmp.port = bp->base; 1227 1226 tmp.irq = bp->irq; 1228 1227 tmp.flags = port->port.flags; 1229 1228 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC; 1230 1229 tmp.close_delay = port->port.close_delay * HZ/100; 1231 1230 tmp.closing_wait = port->port.closing_wait * HZ/100; 1231 + mutex_unlock(&port->port.mutex); 1232 1232 tmp.xmit_fifo_size = CD180_NFIFO; 1233 1233 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; 1234 1234 } ··· 1248 1242 1249 1243 switch (cmd) { 1250 1244 case TIOCGSERIAL: 1251 - lock_kernel(); 1252 1245 retval = rc_get_serial_info(port, argp); 1253 - unlock_kernel(); 1254 1246 break; 1255 1247 case TIOCSSERIAL: 1256 - lock_kernel(); 1257 1248 retval = rc_set_serial_info(tty, port, argp); 1258 - unlock_kernel(); 1259 1249 break; 1260 1250 default: 1261 1251 retval = -ENOIOCTLCMD;