]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
tty: Drop the lock_kernel in the private ioctl hook
authorAlan Cox <alan@redhat.com>
Fri, 2 Jan 2009 13:48:56 +0000 (13:48 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 2 Jan 2009 18:19:42 +0000 (10:19 -0800)
We don't need the BKL here any more so it can go. In a couple of spots the
driver requirements are not clear so push the lock down into the driver.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/usb-serial.c

index fb6f2933b01badb0075c285078fb6067fc7b6827..ef6cfa5a447feba817ffd8a8a819a8451db1918e 100644 (file)
@@ -1054,6 +1054,8 @@ static int set_serial_info(struct tty_struct *tty,
 
        if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
                return -EFAULT;
+
+       lock_kernel();
        old_priv = *priv;
 
        /* Do error checking and permission checking */
@@ -1069,8 +1071,10 @@ static int set_serial_info(struct tty_struct *tty,
        }
 
        if ((new_serial.baud_base != priv->baud_base) &&
-           (new_serial.baud_base < 9600))
+           (new_serial.baud_base < 9600)) {
+               unlock_kernel();
                return -EINVAL;
+       }
 
        /* Make the changes - these are privileged changes! */
 
@@ -1098,8 +1102,11 @@ check_and_exit:
             (priv->flags & ASYNC_SPD_MASK)) ||
            (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
             (old_priv.custom_divisor != priv->custom_divisor))) {
+               unlock_kernel();
                change_speed(tty, port);
        }
+       else
+               unlock_kernel();
        return 0;
 
 } /* set_serial_info */
index dc36a052766fc2015dd3574a5c0ac3020cd32d5a..fcd9082f3e7f05d93fedc3073e3f6a87c318a6a8 100644 (file)
@@ -878,6 +878,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
 
        dbg("%sstate=%d", __func__, break_state);
 
+       /* LOCKING */
        if (break_state)
                lcr |= MCT_U232_SET_BREAK;
 
index 07710cf31d0d23ddd83afce4411264c418132afc..82930a7d509327c2797ef474042e0a3d2a4106ac 100644 (file)
@@ -721,10 +721,10 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
 
        spin_lock_irqsave(&priv->lock, flags);
        lcr = priv->last_lcr;
-       spin_unlock_irqrestore(&priv->lock, flags);
 
        if (break_state)
                lcr |= MCT_U232_SET_BREAK;
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        mct_u232_set_line_ctrl(serial, lcr);
 } /* mct_u232_break_ctl */
index fda4a6421c44226abf6d905a707eb5e4f5bec505..96a8c7713212871cf98ce1031cdefe8cfdfae430 100644 (file)
@@ -1343,6 +1343,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
        else
                data = mos7840_port->shadowLCR & ~LCR_SET_BREAK;
 
+       /* FIXME: no locking on shadowLCR anywhere in driver */
        mos7840_port->shadowLCR = data;
        dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
            mos7840_port->shadowLCR);
@@ -2214,10 +2215,12 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
                break;
        }
 
+       lock_kernel();
        mos7840_port->shadowMCR = mcr;
 
        Data = mos7840_port->shadowMCR;
        status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
+       unlock_kernel();
        if (status < 0) {
                dbg("setting MODEM_CONTROL_REGISTER Failed\n");
                return -1;
index 8d5189096470fe15fa9912c1aea062576fa8310f..080ade223d53fe1306206f8b0f93388f75c17246 100644 (file)
@@ -382,9 +382,7 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
        /* pass on to the driver specific version of this function
           if it is available */
        if (port->serial->type->ioctl) {
-               lock_kernel();
                retval = port->serial->type->ioctl(tty, file, cmd, arg);
-               unlock_kernel();
        } else
                retval = -ENOIOCTLCMD;
        return retval;
@@ -413,11 +411,8 @@ static int serial_break(struct tty_struct *tty, int break_state)
        WARN_ON(!port->port.count);
        /* pass on to the driver specific version of this function
           if it is available */
-       if (port->serial->type->break_ctl) {
-               lock_kernel();
+       if (port->serial->type->break_ctl)
                port->serial->type->break_ctl(tty, break_state);
-               unlock_kernel();
-       }
        return 0;
 }