]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Add a bunch of cycle_kernel_lock() calls
authorJonathan Corbet <corbet@lwn.net>
Sun, 18 May 2008 21:32:43 +0000 (15:32 -0600)
committerJonathan Corbet <corbet@lwn.net>
Fri, 20 Jun 2008 20:05:53 +0000 (14:05 -0600)
All of the open() functions which don't need the BKL on their face may
still depend on its acquisition to serialize opens against driver
initialization.  So make those functions acquire then release the BKL to be
on the safe side.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
21 files changed:
arch/cris/arch-v10/drivers/eeprom.c
arch/cris/arch-v10/drivers/i2c.c
arch/cris/arch-v32/drivers/cryptocop.c
arch/cris/arch-v32/drivers/i2c.c
drivers/char/cs5535_gpio.c
drivers/char/dtlk.c
drivers/char/ip2/ip2main.c
drivers/char/pc8736x_gpio.c
drivers/char/ppdev.c
drivers/char/scx200_gpio.c
drivers/char/tb0219.c
drivers/char/vr41xx_giu.c
drivers/infiniband/core/ucm.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/isdn/hardware/eicon/divasi.c
drivers/isdn/hardware/eicon/divasmain.c
drivers/net/ppp_generic.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-xxxx.c
drivers/scsi/megaraid.c
drivers/scsi/megaraid/megaraid_sas.c

index 40c6fe4c06f4a010a7fd4a264d36f2d4ac3cf5c9..1f2ae909d3e65a8ec8f1d957b04064042841caf5 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/smp_lock.h>
 #include <linux/wait.h>
 #include <asm/uaccess.h>
 #include "i2c.h"
@@ -375,10 +376,9 @@ int __init eeprom_init(void)
 }
 
 /* Opens the device. */
-/* BKL not needed: no global resources accessed */
 static int eeprom_open(struct inode * inode, struct file * file)
 {
-
+  cycle_kernel_lock();
   if(iminor(inode) != EEPROM_MINOR_NR)
      return -ENXIO;
   if(imajor(inode) != EEPROM_MAJOR_NR)
index d6d22067d0c80529733a4d8818a04ad120e62e59..2797e67ce4f4a591622308f03be6f5c323226827 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -566,6 +567,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
 static int
 i2c_open(struct inode *inode, struct file *filp)
 {
+       cycle_kernel_lock();
        return 0;
 }
 
index c17204289575865513974b9e41fdea1730981a70..67c61ea868136e1f67da952a48ca77f9459f46ea 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 
@@ -2302,11 +2303,11 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
        return 0;
 }
 
-/* No BKL needed here - no global resources accessed */
 static int cryptocop_open(struct inode *inode, struct file *filp)
 {
        int p = iminor(inode);
 
+       cycle_kernel_lock();
        if (p != CRYPTOCOP_MINOR) return -EINVAL;
 
        filp->private_data = NULL;
index c2fb7a5c13960dabe7ac3b80bbcbc14ed319b4f6..179e7b8043313eaab628b2ceabf79d67ba67dab4 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 
 #include <asm/etraxi2c.h>
 
@@ -636,6 +637,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
 static int
 i2c_open(struct inode *inode, struct file *filp)
 {
+       cycle_kernel_lock();
        return 0;
 }
 
index 628e3d3249d216fed6842af53c514514989ff84f..04ba906b4880eb4337a4d539beb30a29778b97d2 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/cdev.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -153,12 +154,11 @@ static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
        return count;
 }
 
-/* No BKL needed here - "mask" is the only global resource used
-   here and it's a boot-time parameter */
 static int cs5535_gpio_open(struct inode *inode, struct file *file)
 {
        u32 m = iminor(inode);
 
+       cycle_kernel_lock();
        /* the mask says which pins are usable by this driver */
        if ((mask & (1 << m)) == 0)
                return -EINVAL;
index 433388c6023565fdb0f7dffe6587e86b172ecc17..6b900b297cc615f7687b8a320fd7ebc4987338a7 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/errno.h>       /* for -EBUSY */
 #include <linux/ioport.h>      /* for request_region */
 #include <linux/delay.h>       /* for loops_per_jiffy */
+#include <linux/smp_lock.h>    /* cycle_kernel_lock() */
 #include <asm/io.h>            /* for inb_p, outb_p, inb, outb, etc. */
 #include <asm/uaccess.h>       /* for get_user, etc. */
 #include <linux/wait.h>                /* for wait_queue */
@@ -288,12 +289,12 @@ static int dtlk_ioctl(struct inode *inode,
        }
 }
 
-/* No BKL needed here; "dtlk_busy" is the only global resource,
-   and it is not ever set by anybody (test is broken) */
+/* Note that nobody ever sets dtlk_busy... */
 static int dtlk_open(struct inode *inode, struct file *file)
 {
        TRACE_TEXT("(dtlk_open");
 
+       cycle_kernel_lock();
        nonseekable_open(inode, file);
        switch (iminor(inode)) {
        case DTLK_MINOR:
index 70957acaa960ac3bcdefc2a8faa6e05aa7055502..a978c57b6b2bcf25c95d6be7d414c3b1ca2629d8 100644 (file)
@@ -98,6 +98,7 @@
 #include <linux/major.h>
 #include <linux/wait.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
@@ -2931,42 +2932,11 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
 static int
 ip2_ipl_open( struct inode *pInode, struct file *pFile )
 {
-       unsigned int iplminor = iminor(pInode);
-       i2eBordStrPtr pB;
-       i2ChanStrPtr  pCh;
 
 #ifdef IP2DEBUG_IPL
        printk (KERN_DEBUG "IP2IPL: open\n" );
 #endif
-
-       switch(iplminor) {
-       // These are the IPL devices
-       case 0:
-       case 4:
-       case 8:
-       case 12:
-               break;
-
-       // These are the status devices
-       case 1:
-       case 5:
-       case 9:
-       case 13:
-               break;
-
-       // These are the debug devices
-       case 2:
-       case 6:
-       case 10:
-       case 14:
-               pB = i2BoardPtrTable[iplminor / 4];
-               pCh = (i2ChanStrPtr) pB->i2eChannelPtr;
-               break;
-
-       // This is the trace device
-       case 3:
-               break;
-       }
+       cycle_kernel_lock();
        return 0;
 }
 
index 8715dc9f4a531f2f64445642970e6c603f04ba82..b930de50407aaac9536c9a74adb8b740ce3bae67 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mutex.h>
 #include <linux/nsc_gpio.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
 #define DEVNAME "pc8736x_gpio"
@@ -212,12 +213,12 @@ static struct nsc_gpio_ops pc8736x_gpio_ops = {
        .gpio_current   = pc8736x_gpio_current
 };
 
-/* No BKL needed here; no global resources accessed */
 static int pc8736x_gpio_open(struct inode *inode, struct file *file)
 {
        unsigned m = iminor(inode);
        file->private_data = &pc8736x_gpio_ops;
 
+       cycle_kernel_lock();
        dev_dbg(&pdev->dev, "open %d\n", m);
 
        if (m >= PC8736X_GPIO_CT)
index ce1987574888370c86b5076e51905dfe5b6bfa6f..f6e6acadd9a017d98b562a9c2f2da7178a412161 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/poll.h>
 #include <linux/major.h>
 #include <linux/ppdev.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
 #define PP_VERSION "ppdev: user-space parallel port driver"
@@ -633,12 +634,12 @@ static int pp_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
-/* No BKL needed here: only local resources used */
 static int pp_open (struct inode * inode, struct file * file)
 {
        unsigned int minor = iminor(inode);
        struct pp_struct *pp;
 
+       cycle_kernel_lock();
        if (minor >= PARPORT_MAX)
                return -ENXIO;
 
index be2c623a9862f6cfa80cfe0170acc3ce15e3161c..1d9100561c8a3e70cd4132d153b73164232bb4f4 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -46,12 +47,12 @@ struct nsc_gpio_ops scx200_gpio_ops = {
 };
 EXPORT_SYMBOL_GPL(scx200_gpio_ops);
 
-/* No BKL needed here: no global resources used */
 static int scx200_gpio_open(struct inode *inode, struct file *file)
 {
        unsigned m = iminor(inode);
        file->private_data = &scx200_gpio_ops;
 
+       cycle_kernel_lock();
        if (m >= MAX_PINS)
                return -EINVAL;
        return nonseekable_open(inode, file);
index db8c2ca2ce4cf2b3d2c0f5e824abc08cda220ed6..6062b62800fd2d97e01a640fedaf655983b6997d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 
 #include <asm/io.h>
 #include <asm/reboot.h>
@@ -232,11 +233,11 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data,
        return i;
 }
 
-/* No BKL needed here; no global resources accessed */
 static int tanbac_tb0219_open(struct inode *inode, struct file *file)
 {
        unsigned int minor;
 
+       cycle_kernel_lock();
        minor = iminor(inode);
        switch (minor) {
        case 0:
index 412937fdb958da364bba8cbe5686a16527b1d8de..ffe9b4e3072e50b02e57c2fa0ac2f58240c85a45 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
@@ -543,12 +544,11 @@ static ssize_t gpio_write(struct file *file, const char __user *data,
        return i;
 }
 
-/* No BKL needed here; only global (giu_nr_pins) is only set
-   at probe time */
 static int gpio_open(struct inode *inode, struct file *file)
 {
        unsigned int pin;
 
+       cycle_kernel_lock();
        pin = iminor(inode);
        if (pin >= giu_nr_pins)
                return -EBADF;
index 3e6a8ff6d76cbc47019160a58a17e1e023f3ff26..b25675faaaf5c584c5d7bc81e65d8e6f3110aa60 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/cdev.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -1155,11 +1156,11 @@ static unsigned int ib_ucm_poll(struct file *filp,
        return mask;
 }
 
-/* No BKL needed here: no global resources used */
 static int ib_ucm_open(struct inode *inode, struct file *filp)
 {
        struct ib_ucm_file *file;
 
+       cycle_kernel_lock();
        file = kmalloc(sizeof(*file), GFP_KERNEL);
        if (!file)
                return -ENOMEM;
index e80cfbd4f3fd2d2536282a4d5e258ff8482b7155..35f301c88b57196d0098e5a7d86ef5adba157d8b 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 #include <asm/pgtable.h>
 
 #include "ipath_kernel.h"
@@ -1812,10 +1813,10 @@ done:
        return ret;
 }
 
-/* No BKL needed here */
 static int ipath_open(struct inode *in, struct file *fp)
 {
        /* The real work is performed later in ipath_assign_port() */
+       cycle_kernel_lock();
        fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL);
        return fp->private_data ? 0 : -ENOMEM;
 }
index 78f141e7746601591902ad8dbf4acb7684737459..f4969fe0a0554ad5f567268075be2a6e90b34bb1 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
 #include "platform.h"
@@ -400,6 +401,7 @@ static unsigned int um_idi_poll(struct file *file, poll_table * wait)
 
 static int um_idi_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        return (0);
 }
 
index 5fcbdccd7a5359aeac614524f37506785f47b59d..65c95019a9ae1064baaad12bb3119afc24e37377 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/poll.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 #include "platform.h"
 #undef ID_MASK
@@ -580,6 +581,7 @@ xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int lengt
  */
 static int divas_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        return (0);
 }
 
index dc8505062da7252d397787015c46c7f7d3e22805..83625fdff3dd810944aa8cbd60165a32b1a3f937 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/if_arp.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/rwsem.h>
 #include <linux/stddef.h>
@@ -351,9 +352,9 @@ static const int npindex_to_ethertype[NUM_NP] = {
  * Open instances of /dev/ppp can be in one of three states:
  * unattached, attached to a ppp unit, or attached to a ppp channel.
  */
-/* No BKL needed here */
 static int ppp_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        /*
         * This could (should?) be enforced by the permissions on /dev/ppp.
         */
index 2239d16fb9b568225df0fa5e0e26eaec4a2be5f7..eaa805df5b003ccb3b6b019763291179398e184e 100644 (file)
@@ -84,6 +84,7 @@
 #include <linux/pci.h>
 #include <linux/time.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -862,13 +863,13 @@ out:
 } /* End twa_chrdev_ioctl() */
 
 /* This function handles open for the character device */
-/* NOTE that this function will race with remove; adding BKL
-   will not help. */
+/* NOTE that this function will race with remove. */
 static int twa_chrdev_open(struct inode *inode, struct file *file)
 {
        unsigned int minor_number;
        int retval = TW_IOCTL_ERROR_OS_ENODEV;
 
+       cycle_kernel_lock();
        minor_number = iminor(inode);
        if (minor_number >= twa_device_extension_count)
                goto out;
index bbff029536ea3dda3dfdd39f4f20734ded7b91c4..a0537f09aa216a3d41f7e92a518e8bae3cf8d05a 100644 (file)
 
 #include <linux/module.h>
 #include <linux/reboot.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/moduleparam.h>
@@ -1027,12 +1028,12 @@ out:
 } /* End tw_chrdev_ioctl() */
 
 /* This function handles open for the character device */
-/* NOTE that this function races with remove - adding BKL
-   won't help */
+/* NOTE that this function races with remove. */
 static int tw_chrdev_open(struct inode *inode, struct file *file)
 {
        unsigned int minor_number;
 
+       cycle_kernel_lock();
        dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
 
        minor_number = iminor(inode);
index c9aa2c45a6992dc2ec65e5b86b6d8d3f7c9f0031..28c9da7d4a5c5f0aad97c0a41f964c8994c4d228 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/smp_lock.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
@@ -3273,12 +3274,11 @@ mega_init_scb(adapter_t *adapter)
  *
  * Routines for the character/ioctl interface to the driver. Find out if this
  * is a valid open. 
- *
- * No BKL needed here.
  */
 static int
 megadev_open (struct inode *inode, struct file *filep)
 {
+       cycle_kernel_lock();
        /*
         * Only allow superuser to access private ioctl interface
         */
index 81374b7c555ce926a4be6321b0b95ec29eb39d4e..fc7ac158476c5d4bc94ecf08a46f1c8604c032ae 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/smp_lock.h>
 #include <linux/uio.h>
 #include <asm/uaccess.h>
 #include <linux/fs.h>
@@ -2860,10 +2861,10 @@ static void megasas_shutdown(struct pci_dev *pdev)
 
 /**
  * megasas_mgmt_open - char node "open" entry point
- * No BKL is needed here.
  */
 static int megasas_mgmt_open(struct inode *inode, struct file *filep)
 {
+       cycle_kernel_lock();
        /*
         * Allow only those users with admin rights
         */