2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-18 15:44:02 +08:00

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>
This commit is contained in:
Alan Cox 2010-06-01 22:52:43 +02:00 committed by Greg Kroah-Hartman
parent 8a1e803d01
commit bf936f92a7

View File

@ -47,7 +47,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/device.h> #include <linux/device.h>
@ -1184,6 +1183,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
if (copy_from_user(&tmp, newinfo, sizeof(tmp))) if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
return -EFAULT; return -EFAULT;
mutex_lock(&port->port.mutex);
change_speed = ((port->port.flags & ASYNC_SPD_MASK) != change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
(tmp.flags & ASYNC_SPD_MASK)); (tmp.flags & ASYNC_SPD_MASK));
@ -1191,8 +1191,10 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
if ((tmp.close_delay != port->port.close_delay) || if ((tmp.close_delay != port->port.close_delay) ||
(tmp.closing_wait != port->port.closing_wait) || (tmp.closing_wait != port->port.closing_wait) ||
((tmp.flags & ~ASYNC_USR_MASK) != ((tmp.flags & ~ASYNC_USR_MASK) !=
(port->port.flags & ~ASYNC_USR_MASK))) (port->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&port->port.mutex);
return -EPERM; return -EPERM;
}
port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
(tmp.flags & ASYNC_USR_MASK)); (tmp.flags & ASYNC_USR_MASK));
} else { } else {
@ -1208,6 +1210,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
rc_change_speed(tty, bp, port); rc_change_speed(tty, bp, port);
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
mutex_unlock(&port->port.mutex);
return 0; return 0;
} }
@ -1220,12 +1223,15 @@ static int rc_get_serial_info(struct riscom_port *port,
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
tmp.type = PORT_CIRRUS; tmp.type = PORT_CIRRUS;
tmp.line = port - rc_port; tmp.line = port - rc_port;
mutex_lock(&port->port.mutex);
tmp.port = bp->base; tmp.port = bp->base;
tmp.irq = bp->irq; tmp.irq = bp->irq;
tmp.flags = port->port.flags; tmp.flags = port->port.flags;
tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC; tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
tmp.close_delay = port->port.close_delay * HZ/100; tmp.close_delay = port->port.close_delay * HZ/100;
tmp.closing_wait = port->port.closing_wait * HZ/100; tmp.closing_wait = port->port.closing_wait * HZ/100;
mutex_unlock(&port->port.mutex);
tmp.xmit_fifo_size = CD180_NFIFO; tmp.xmit_fifo_size = CD180_NFIFO;
return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
} }
@ -1242,14 +1248,10 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp,
switch (cmd) { switch (cmd) {
case TIOCGSERIAL: case TIOCGSERIAL:
lock_kernel();
retval = rc_get_serial_info(port, argp); retval = rc_get_serial_info(port, argp);
unlock_kernel();
break; break;
case TIOCSSERIAL: case TIOCSSERIAL:
lock_kernel();
retval = rc_set_serial_info(tty, port, argp); retval = rc_set_serial_info(tty, port, argp);
unlock_kernel();
break; break;
default: default:
retval = -ENOIOCTLCMD; retval = -ENOIOCTLCMD;