]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge commit 'v2.6.26' into bkl-removal
authorJonathan Corbet <corbet@lwn.net>
Mon, 14 Jul 2008 21:29:34 +0000 (15:29 -0600)
committerJonathan Corbet <corbet@lwn.net>
Mon, 14 Jul 2008 21:29:34 +0000 (15:29 -0600)
179 files changed:
arch/blackfin/mach-bf561/coreb.c
arch/cris/arch-v10/drivers/eeprom.c
arch/cris/arch-v10/drivers/gpio.c
arch/cris/arch-v10/drivers/i2c.c
arch/cris/arch-v10/drivers/sync_serial.c
arch/cris/arch-v32/drivers/cryptocop.c
arch/cris/arch-v32/drivers/i2c.c
arch/cris/arch-v32/drivers/mach-a3/gpio.c
arch/cris/arch-v32/drivers/mach-fs/gpio.c
arch/cris/arch-v32/drivers/sync_serial.c
arch/m68k/bvme6000/rtc.c
arch/m68k/mvme16x/rtc.c
arch/mips/basler/excite/excite_iodev.c
arch/mips/kernel/rtlx.c
arch/mips/kernel/vpe.c
arch/mips/sibyte/common/sb_tbprof.c
arch/parisc/kernel/perf.c
arch/s390/crypto/prng.c
arch/sh/boards/landisk/gio.c
arch/sparc/kernel/apc.c
arch/sparc64/kernel/time.c
arch/um/drivers/harddog_kern.c
arch/um/drivers/mmapper_kern.c
arch/um/drivers/random.c
arch/x86/kernel/apm_32.c
arch/x86/kernel/cpu/mcheck/mce_64.c
arch/x86/kernel/cpuid.c
arch/x86/kernel/microcode.c
arch/x86/kernel/msr.c
block/bsg.c
drivers/block/aoe/aoechr.c
drivers/block/paride/pg.c
drivers/block/paride/pt.c
drivers/bluetooth/hci_vhci.c
drivers/char/agp/frontend.c
drivers/char/apm-emulation.c
drivers/char/briq_panel.c
drivers/char/cs5535_gpio.c
drivers/char/drm/drm_fops.c
drivers/char/ds1286.c
drivers/char/ds1620.c
drivers/char/dsp56k.c
drivers/char/dtlk.c
drivers/char/efirtc.c
drivers/char/genrtc.c
drivers/char/hpet.c
drivers/char/hw_random/core.c
drivers/char/ip2/ip2main.c
drivers/char/ip27-rtc.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/ipmi/ipmi_watchdog.c
drivers/char/lcd.c
drivers/char/lp.c
drivers/char/mbcs.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/mwave/mwavedd.c
drivers/char/nvram.c
drivers/char/pc8736x_gpio.c
drivers/char/ppdev.c
drivers/char/raw.c
drivers/char/rtc.c
drivers/char/scx200_gpio.c
drivers/char/snsc.c
drivers/char/sonypi.c
drivers/char/tb0219.c
drivers/char/tlclk.c
drivers/char/tpm/tpm.c
drivers/char/tty_io.c
drivers/char/vc_screen.c
drivers/char/viotape.c
drivers/char/vr41xx_giu.c
drivers/char/xilinx_hwicap/xilinx_hwicap.c
drivers/hid/hidraw.c
drivers/i2c/i2c-dev.c
drivers/ide/ide-tape.c
drivers/infiniband/core/ucm.c
drivers/infiniband/core/ucma.c
drivers/infiniband/core/user_mad.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/input/input.c
drivers/input/misc/hp_sdc_rtc.c
drivers/input/misc/uinput.c
drivers/input/mousedev.c
drivers/input/serio/serio_raw.c
drivers/isdn/capi/capi.c
drivers/isdn/hardware/eicon/divamnt.c
drivers/isdn/hardware/eicon/divasi.c
drivers/isdn/hardware/eicon/divasmain.c
drivers/isdn/i4l/isdn_common.c
drivers/macintosh/adb.c
drivers/macintosh/ans-lcd.c
drivers/macintosh/smu.c
drivers/macintosh/via-pmu.c
drivers/media/dvb/dvb-core/dvbdev.c
drivers/media/radio/miropcm20-rds.c
drivers/media/video/videodev.c
drivers/message/fusion/mptctl.c
drivers/message/i2o/i2o_config.c
drivers/misc/hdpuftrs/hdpu_cpustate.c
drivers/misc/phantom.c
drivers/misc/sony-laptop.c
drivers/mtd/mtdchar.c
drivers/mtd/ubi/cdev.c
drivers/net/ppp_generic.c
drivers/net/tun.c
drivers/net/wan/cosa.c
drivers/parisc/eisa_eeprom.c
drivers/pcmcia/pcmcia_ioctl.c
drivers/rtc/rtc-dev.c
drivers/rtc/rtc-m41t80.c
drivers/s390/block/dasd_eer.c
drivers/s390/char/fs3270.c
drivers/s390/char/monreader.c
drivers/s390/char/monwriter.c
drivers/s390/char/tape_char.c
drivers/s390/char/vmcp.c
drivers/s390/char/vmlogrdr.c
drivers/s390/char/vmur.c
drivers/s390/char/vmwatchdog.c
drivers/s390/crypto/zcrypt_api.c
drivers/sbus/char/bpp.c
drivers/sbus/char/cpwatchdog.c
drivers/sbus/char/display7seg.c
drivers/sbus/char/envctrl.c
drivers/sbus/char/flash.c
drivers/sbus/char/jsflash.c
drivers/sbus/char/openprom.c
drivers/sbus/char/riowatchdog.c
drivers/sbus/char/rtc.c
drivers/sbus/char/uctrl.c
drivers/sbus/char/vfc_dev.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-xxxx.c
drivers/scsi/aacraid/linit.c
drivers/scsi/ch.c
drivers/scsi/dpt_i2o.c
drivers/scsi/gdth.c
drivers/scsi/megaraid.c
drivers/scsi/megaraid/megaraid_mm.c
drivers/scsi/megaraid/megaraid_sas.c
drivers/scsi/osst.c
drivers/scsi/scsi_tgt_if.c
drivers/scsi/sg.c
drivers/scsi/st.c
drivers/spi/spidev.c
drivers/telephony/phonedev.c
drivers/uio/uio.c
drivers/usb/core/devio.c
drivers/usb/core/file.c
drivers/usb/gadget/printer.c
drivers/usb/mon/mon_bin.c
drivers/video/fbmem.c
fs/char_dev.c
fs/cifs/cifsfs.c
fs/dlm/user.c
fs/ecryptfs/file.c
fs/fat/cache.c
fs/fat/dir.c
fs/fat/file.c
fs/fat/inode.c
fs/fcntl.c
fs/gfs2/ops_file.c
fs/msdos/namei.c
fs/ncpfs/file.c
fs/nfs/file.c
fs/ocfs2/stack_user.c
fs/read_write.c
fs/smbfs/file.c
fs/vfat/namei.c
include/linux/fs.h
include/linux/smp_lock.h
kernel/pm_qos_params.c
net/irda/irnet/irnet.h
net/irda/irnet/irnet_ppp.c
sound/core/pcm_native.c
sound/core/sound.c
sound/sound_core.c

index 1b44e9e6dc3b6b44956f817d0a56bc622ea4f67b..8598098c08408e85382bb21960f219a130a71ec5 100644 (file)
@@ -194,6 +194,7 @@ static loff_t coreb_lseek(struct file *file, loff_t offset, int origin)
        return ret;
 }
 
+/* No BKL needed here */
 static int coreb_open(struct inode *inode, struct file *file)
 {
        spin_lock_irq(&coreb_lock);
index f1cac9dc75b8150bfdad17e904450f7738428438..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. */
-
 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 68a998bd10697cade8c194ed01bd96003f712995..86048e697eb5eb57c1cf241f5124f72e76b9cf97 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -323,6 +324,7 @@ gpio_open(struct inode *inode, struct file *filp)
        if (!priv)
                return -ENOMEM;
 
+       lock_kernel();
        priv->minor = p;
 
        /* initialize the io/alarm struct */
@@ -357,6 +359,7 @@ gpio_open(struct inode *inode, struct file *filp)
        alarmlist = priv;
        spin_unlock_irqrestore(&gpio_lock, flags);
 
+       unlock_kernel();
        return 0;
 }
 
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 069546e342c55fca11432fdc660ae99ffc6d7668..91fea623c7c9e6c4528d6239a4b7042969a3aa91 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
@@ -443,18 +444,21 @@ static int sync_serial_open(struct inode *inode, struct file *file)
        int dev = MINOR(inode->i_rdev);
        struct sync_port *port;
        int mode;
+       int err = -EBUSY;
 
+       lock_kernel();
        DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
 
        if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
                DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
        port = &ports[dev];
        /* Allow open this device twice (assuming one reader and one writer) */
        if (port->busy == 2) {
                DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
-               return -EBUSY;
+               goto out;
        }
        if (port->init_irqs) {
                if (port->use_dma) {
@@ -465,14 +469,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                &ports[0])) {
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 1 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (request_irq(25, rx_interrupt, 0,
                                                "synchronous serial 1 dma rx",
                                                &ports[0])) {
                                        free_irq(24, &port[0]);
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 1 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (cris_request_dma(8,
                                                "synchronous serial 1 dma tr",
                                                DMA_VERBOSE_ON_ERROR,
@@ -482,7 +486,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 1 "
                                                "TX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (cris_request_dma(9,
                                                "synchronous serial 1 dma rec",
                                                DMA_VERBOSE_ON_ERROR,
@@ -493,7 +497,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 1 "
                                                "RX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                }
 #endif
                                RESET_DMA(8); WAIT_DMA(8);
@@ -520,14 +524,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                &ports[1])) {
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 3 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (request_irq(21, rx_interrupt, 0,
                                                "synchronous serial 3 dma rx",
                                                &ports[1])) {
                                        free_irq(20, &ports[1]);
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 3 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (cris_request_dma(4,
                                                "synchronous serial 3 dma tr",
                                                DMA_VERBOSE_ON_ERROR,
@@ -537,7 +541,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 3 "
                                                "TX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (cris_request_dma(5,
                                                "synchronous serial 3 dma rec",
                                                DMA_VERBOSE_ON_ERROR,
@@ -548,7 +552,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial port 3 "
                                                "RX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                }
 #endif
                                RESET_DMA(4); WAIT_DMA(4);
@@ -581,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                &ports[0])) {
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial manual irq");
-                                       return -EBUSY;
+                                       goto out;
                                }
                        } else if (port == &ports[1]) {
                                if (request_irq(8,
@@ -591,7 +595,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                &ports[1])) {
                                        printk(KERN_CRIT "Can't alloc "
                                                "sync serial manual irq");
-                                       return -EBUSY;
+                                       goto out;
                                }
                        }
                        port->init_irqs = 0;
@@ -620,7 +624,11 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                        *R_IRQ_MASK1_SET = 1 << port->data_avail_bit;
                DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev));
        }
-       return 0;
+       ret = 0;
+       
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int sync_serial_release(struct inode *inode, struct file *file)
index 9fb58202be99b8d54d729c161dba9983cc29352d..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;
 }
 
-
 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 de107dad9f4ffb13bde029fdd1c6b5f9544ffd09..ef98608e50672dbcc3823c1cfdfcd94fece0979e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 #include <asm/etraxgpio.h>
 #include <hwregs/reg_map.h>
@@ -390,6 +391,8 @@ static int gpio_open(struct inode *inode, struct file *filp)
 
        if (!priv)
                return -ENOMEM;
+
+       lock_kernel();
        memset(priv, 0, sizeof(*priv));
 
        priv->minor = p;
@@ -412,6 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
                spin_unlock_irq(&gpio_lock);
        }
 
+       unlock_kernel();
        return 0;
 }
 
index 7863fd4efc2bfc5837980ac8f6444f401921b42f..fe1fde893887ea76f90c699dd180c94625a704b2 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 #include <asm/etraxgpio.h>
 #include <hwregs/reg_map.h>
@@ -426,9 +427,10 @@ gpio_open(struct inode *inode, struct file *filp)
                return -EINVAL;
 
        priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL);
-
        if (!priv)
                return -ENOMEM;
+
+       lock_kernel();
        memset(priv, 0, sizeof(*priv));
 
        priv->minor = p;
@@ -449,6 +451,7 @@ gpio_open(struct inode *inode, struct file *filp)
        alarmlist = priv;
        spin_unlock_irq(&alarm_lock);
 
+       unlock_kernel();
        return 0;
 }
 
index 47c377df6fb361e7342d2e8a537c463b3bbd8962..d2a0fbf5341fc1870e8bf9d245acb980d3f95f6c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/major.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -429,23 +430,26 @@ static inline int sync_data_avail_to_end(struct sync_port *port)
 static int sync_serial_open(struct inode *inode, struct file *file)
 {
        int dev = iminor(inode);
+       int ret = -EBUSY;
        sync_port *port;
        reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
        reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes};
 
+       lock_kernel();
        DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
 
        if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
        {
                DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
-               return -ENODEV;
+               ret = -ENODEV;
+               goto out;
        }
        port = &ports[dev];
        /* Allow open this device twice (assuming one reader and one writer) */
        if (port->busy == 2)
        {
                DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
-               return -EBUSY;
+               goto out;
        }
 
 
@@ -459,7 +463,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                "synchronous serial 0 dma tr",
                                                &ports[0])) {
                                        printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (request_irq(DMA_IN_INTR_VECT,
                                                rx_interrupt,
                                                0,
@@ -467,7 +471,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                &ports[0])) {
                                        free_irq(DMA_OUT_INTR_VECT, &port[0]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (crisv32_request_dma(OUT_DMA_NBR,
                                                "synchronous serial 0 dma tr",
                                                DMA_VERBOSE_ON_ERROR,
@@ -476,7 +480,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        free_irq(DMA_OUT_INTR_VECT, &port[0]);
                                        free_irq(DMA_IN_INTR_VECT, &port[0]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (crisv32_request_dma(IN_DMA_NBR,
                                                "synchronous serial 0 dma rec",
                                                DMA_VERBOSE_ON_ERROR,
@@ -486,7 +490,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        free_irq(DMA_OUT_INTR_VECT, &port[0]);
                                        free_irq(DMA_IN_INTR_VECT, &port[0]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                }
 #endif
                        }
@@ -499,7 +503,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                "synchronous serial 1 dma tr",
                                                &ports[1])) {
                                        printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (request_irq(DMA7_INTR_VECT,
                                                       rx_interrupt,
                                                       0,
@@ -507,7 +511,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                       &ports[1])) {
                                        free_irq(DMA6_INTR_VECT, &ports[1]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (crisv32_request_dma(
                                                SYNC_SER1_TX_DMA_NBR,
                                                "synchronous serial 1 dma tr",
@@ -517,7 +521,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        free_irq(DMA6_INTR_VECT, &ports[1]);
                                        free_irq(DMA7_INTR_VECT, &ports[1]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                } else if (crisv32_request_dma(
                                                SYNC_SER1_RX_DMA_NBR,
                                                "synchronous serial 3 dma rec",
@@ -528,7 +532,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                        free_irq(DMA6_INTR_VECT, &ports[1]);
                                        free_irq(DMA7_INTR_VECT, &ports[1]);
                                        printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel");
-                                       return -EBUSY;
+                                       goto out;
                                }
 #endif
                        }
@@ -554,7 +558,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                "synchronous serial manual irq",
                                                &ports[0])) {
                                        printk("Can't allocate sync serial manual irq");
-                                       return -EBUSY;
+                                       goto out;
                                }
                        }
 #ifdef CONFIG_ETRAXFS
@@ -565,7 +569,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
                                                "synchronous serial manual irq",
                                                &ports[1])) {
                                        printk(KERN_CRIT "Can't allocate sync serial manual irq");
-                                       return -EBUSY;
+                                       goto out;
                                }
                        }
 #endif
@@ -578,7 +582,10 @@ static int sync_serial_open(struct inode *inode, struct file *file)
        } /* port->init_irqs */
 
        port->busy++;
-       return 0;
+       ret = 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int sync_serial_release(struct inode *inode, struct file *file)
index a812d03879f891b8e69501f13b2c410ae7241b01..e8ac3f7d72df6dd457aded95444e69655d16f7c1 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
 #include <linux/fcntl.h>
@@ -140,10 +141,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
 static int rtc_open(struct inode *inode, struct file *file)
 {
-       if(rtc_status)
+       lock_kernel();
+       if(rtc_status) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
        rtc_status = 1;
+       unlock_kernel();
        return 0;
 }
 
index e341387787ab8b048e14ad9575fa96e889acc611..432a9f13b2ed6bc6955908096740c1154e3d4ee5 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
 #include <linux/fcntl.h>
@@ -127,11 +128,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
 static int rtc_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        if( !atomic_dec_and_test(&rtc_ready) )
        {
                atomic_inc( &rtc_ready );
+               unlock_kernel();
                return -EBUSY;
        }
+       unlock_kernel();
 
        return 0;
 }
index 476d20e08d0e4ceb2251b745ad3e81620f77589e..a1e3526b4a94dd31d4013ccbc88d0a0e3857b3b2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 
 #include "excite_iodev.h"
 
@@ -110,8 +111,14 @@ static int __exit iodev_remove(struct device *dev)
 
 static int iodev_open(struct inode *i, struct file *f)
 {
-       return request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED,
+       int ret;
+
+       lock_kernel();
+       ret = request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED,
                           iodev_name, &miscdev);
+       unlock_kernel();
+
+       return ret;
 }
 
 static int iodev_release(struct inode *i, struct file *f)
index b88f1c18ff4dc2fe7b5877972ec39314e0d5639d..b556419612329a26fdf4493b8d4c1ee43073d4a7 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
 #include <linux/interrupt.h>
@@ -392,8 +393,12 @@ out:
 static int file_open(struct inode *inode, struct file *filp)
 {
        int minor = iminor(inode);
+       int err;
 
-       return rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1);
+       lock_kernel();
+       err = rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1);
+       unlock_kernel();
+       return err;
 }
 
 static int file_release(struct inode *inode, struct file *filp)
index 2794501ff302923b38afe00c3e90531379307bf2..972b2d2b8401b6dd7bd4922690205c6b8f3a5cdf 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
 #include <linux/interrupt.h>
@@ -1050,17 +1051,20 @@ static int vpe_open(struct inode *inode, struct file *filp)
        enum vpe_state state;
        struct vpe_notifications *not;
        struct vpe *v;
-       int ret;
+       int ret, err = 0;
 
+       lock_kernel();
        if (minor != iminor(inode)) {
                /* assume only 1 device at the moment. */
                printk(KERN_WARNING "VPE loader: only vpe1 is supported\n");
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
 
        if ((v = get_vpe(tclimit)) == NULL) {
                printk(KERN_WARNING "VPE loader: unable to get vpe\n");
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
 
        state = xchg(&v->state, VPE_STATE_INUSE);
@@ -1100,6 +1104,8 @@ static int vpe_open(struct inode *inode, struct file *filp)
        v->shared_ptr = NULL;
        v->__start = 0;
 
+out:
+       unlock_kernel();
        return 0;
 }
 
index 63b444eaf01eb3dc169676cf18ba3c8ba13b3574..28b012ab8dcb7ae6c06eaac75789cbf08d861a4c 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/errno.h>
@@ -402,18 +403,26 @@ static int sbprof_zbprof_stop(void)
 static int sbprof_tb_open(struct inode *inode, struct file *filp)
 {
        int minor;
+       int err = 0;
 
+       lock_kernel();
        minor = iminor(inode);
-       if (minor != 0)
-               return -ENODEV;
+       if (minor != 0) {
+               err = -ENODEV;
+               goto out;
+       }
 
-       if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED)
-               return -EBUSY;
+       if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) {
+               err = -EBUSY;
+               goto out;
+       }
 
        memset(&sbp, 0, sizeof(struct sbprof_tb));
        sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
-       if (!sbp.sbprof_tbbuf)
-               return -ENOMEM;
+       if (!sbp.sbprof_tbbuf) {
+               err = -ENOMEM;
+               goto out;
+       }
        memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
        init_waitqueue_head(&sbp.tb_sync);
        init_waitqueue_head(&sbp.tb_read);
@@ -421,7 +430,9 @@ static int sbprof_tb_open(struct inode *inode, struct file *filp)
 
        sbp.open = SB_OPEN;
 
-       return 0;
+  out:
+       unlock_kernel();
+       return err;
 }
 
 static int sbprof_tb_release(struct inode *inode, struct file *filp)
index 89d6d5ad44b5258f4ff61ae487c8ed1020bf115b..f696f57faa15b58dfd32e2101379f32e27ce70c0 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 
 #include <asm/uaccess.h>
@@ -260,13 +261,16 @@ printk("Preparing to start counters\n");
  */
 static int perf_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock(&perf_lock);
        if (perf_enabled) {
                spin_unlock(&perf_lock);
+               unlock_kernel();
                return -EBUSY;
        }
        perf_enabled = 1;
        spin_unlock(&perf_lock);
+       unlock_kernel();
 
        return 0;
 }
index 0cfefddd83755366fee0dae7634ccca6342b21dd..c238ee4aa038d79757012a4ff01bb4b2397546f4 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -48,6 +49,7 @@ static unsigned char parm_block[32] = {
 
 static int prng_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        return nonseekable_open(inode, file);
 }
 
index 17025080db35ea279903e36910294ceb6b48767b..0c15b0a50b99a2460011801fa37411acd5e217e7 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/kdev_t.h>
 #include <linux/cdev.h>
 #include <linux/fs.h>
@@ -32,17 +33,20 @@ static int openCnt;
 static int gio_open(struct inode *inode, struct file *filp)
 {
        int minor;
+       int ret = -ENOENT;
 
+       lock_kernel();
        minor = MINOR(inode->i_rdev);
        if (minor < DEVCOUNT) {
                if (openCnt > 0) {
-                       return -EALREADY;
+                       ret = -EALREADY;
                } else {
                        openCnt++;
-                       return 0;
+                       ret = 0;
                }
        }
-       return -ENOENT;
+       unlock_kernel();
+       return ret;
 }
 
 static int gio_close(struct inode *inode, struct file *filp)
index d06a405ca718eb6f0067c9d80ca16d606486d4a3..6707422c98479547dc8901cac04acf698d6ca503 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 #include <linux/pm.h>
 
 #include <asm/io.h>
@@ -75,6 +76,7 @@ static inline void apc_free(void)
 
 static int apc_open(struct inode *inode, struct file *f)
 {
+       cycle_kernel_lock();
        return 0;
 }
 
index e5d238970c7ec60e7d52a04495ffb7eb725340c5..bedc4c159b1c8e29cee6d346619d66c389d9a5f3 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/string.h>
@@ -1659,10 +1660,14 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file,
 
 static int mini_rtc_open(struct inode *inode, struct file *file)
 {
-       if (mini_rtc_status & RTC_IS_OPEN)
+       lock_kernel();
+       if (mini_rtc_status & RTC_IS_OPEN) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
        mini_rtc_status |= RTC_IS_OPEN;
+       unlock_kernel();
 
        return 0;
 }
index a9ad4bd6d953d2255d82e3776b816165e50a94aa..d332503fa1beae1f54a53fbbb62356ea2113cfb1 100644 (file)
@@ -66,6 +66,7 @@ static int harddog_open(struct inode *inode, struct file *file)
        int err = -EBUSY;
        char *sock = NULL;
 
+       lock_kernel();
        spin_lock(&lock);
        if(timer_alive)
                goto err;
@@ -82,9 +83,11 @@ static int harddog_open(struct inode *inode, struct file *file)
 
        timer_alive = 1;
        spin_unlock(&lock);
+       unlock_kernel();
        return nonseekable_open(inode, file);
 err:
        spin_unlock(&lock);
+       unlock_kernel();
        return err;
 }
 
index 67b2f55a602f6db174f95f4e0b843f4adda97d2e..eb240323c40ad6a52883b079f2324c57ae9eb09f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include "mem_user.h"
 
@@ -77,6 +78,7 @@ out:
 
 static int mmapper_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        return 0;
 }
 
index 4949044773ba78b93797d43701ab751b0a1bce23..6eabb7022a2d6c1c45a7f62327a50c4b1c88d734 100644 (file)
@@ -7,6 +7,7 @@
  * of the GNU General Public License, incorporated herein by reference.
  */
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
@@ -33,6 +34,8 @@ static DECLARE_WAIT_QUEUE_HEAD(host_read_wait);
 
 static int rng_dev_open (struct inode *inode, struct file *filp)
 {
+       cycle_kernel_lock();
+
        /* enforce read-only access to this chrdev */
        if ((filp->f_mode & FMODE_READ) == 0)
                return -EINVAL;
index bf9290e290136a36d6006d032c1ca4fe392f84bd..82222366477f4e35715ab995b2dcc55bd3b853fc 100644 (file)
 #include <linux/module.h>
 
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/timer.h>
@@ -1544,10 +1545,12 @@ static int do_open(struct inode *inode, struct file *filp)
 {
        struct apm_user *as;
 
+       lock_kernel();
        as = kmalloc(sizeof(*as), GFP_KERNEL);
        if (as == NULL) {
                printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
                       sizeof(*as));
+                      unlock_kernel();
                return -ENOMEM;
        }
        as->magic = APM_BIOS_MAGIC;
@@ -1569,6 +1572,7 @@ static int do_open(struct inode *inode, struct file *filp)
        user_list = as;
        spin_unlock(&user_list_lock);
        filp->private_data = as;
+       unlock_kernel();
        return 0;
 }
 
index e07e8c068ae00c464cdbf828cfbc8c67aaf76202..4ef151633e8bf9a002b051a7e38473b1a9f3885d 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/rcupdate.h>
 #include <linux/kallsyms.h>
@@ -527,10 +528,12 @@ static int open_exclu;    /* already open exclusive? */
 
 static int mce_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock(&mce_state_lock);
 
        if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
                spin_unlock(&mce_state_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
@@ -539,6 +542,7 @@ static int mce_open(struct inode *inode, struct file *file)
        open_count++;
 
        spin_unlock(&mce_state_lock);
+       unlock_kernel();
 
        return nonseekable_open(inode, file);
 }
index daff52a6224857f79985d20c96b0661922c88504..71f1c2654bec27096042a66d2e5f1dfe7729a4b5 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/smp.h>
+#include <linux/smp_lock.h>
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
@@ -107,15 +108,23 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
 
 static int cpuid_open(struct inode *inode, struct file *file)
 {
-       unsigned int cpu = iminor(file->f_path.dentry->d_inode);
-       struct cpuinfo_x86 *c = &cpu_data(cpu);
-
-       if (cpu >= NR_CPUS || !cpu_online(cpu))
-               return -ENXIO;  /* No such CPU */
+       unsigned int cpu;
+       struct cpuinfo_x86 *c;
+       int ret = 0;
+       
+       lock_kernel();
+
+       cpu = iminor(file->f_path.dentry->d_inode);
+       if (cpu >= NR_CPUS || !cpu_online(cpu)) {
+               ret = -ENXIO;   /* No such CPU */
+               goto out;
+       }
+       c = &cpu_data(cpu);
        if (c->cpuid_level < 0)
-               return -EIO;    /* CPUID not supported */
-
-       return 0;
+               ret = -EIO;     /* CPUID not supported */
+out:
+       unlock_kernel();
+       return ret;
 }
 
 /*
index 69729e38b78a2d83e7f7e799bd2ea37730305d18..9f0a994eef9b1f0ba209cc1b3c4cd62e492d3097 100644 (file)
@@ -75,6 +75,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/cpumask.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -422,6 +423,7 @@ out:
 
 static int microcode_open (struct inode *unused1, struct file *unused2)
 {
+       cycle_kernel_lock();
        return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 }
 
index 1f3abe048e93ea3dd0aaa06225deb8a577904fc6..a153b3905f60591cb6fb627cad9dcc6e529e25cb 100644 (file)
@@ -117,12 +117,20 @@ static int msr_open(struct inode *inode, struct file *file)
 {
        unsigned int cpu = iminor(file->f_path.dentry->d_inode);
        struct cpuinfo_x86 *c = &cpu_data(cpu);
+       int ret = 0;
 
-       if (cpu >= NR_CPUS || !cpu_online(cpu))
-               return -ENXIO;  /* No such CPU */
-       if (!cpu_has(c, X86_FEATURE_MSR))
-               return -EIO;    /* MSR not supported */
+       lock_kernel();
+       cpu = iminor(file->f_path.dentry->d_inode);
 
+       if (cpu >= NR_CPUS || !cpu_online(cpu)) {
+               ret = -ENXIO;   /* No such CPU */
+               goto out;
+       }
+       c = &cpu_data(cpu);
+       if (!cpu_has(c, X86_FEATURE_MSR))
+               ret = -EIO;     /* MSR not supported */
+out:
+       unlock_kernel();
        return 0;
 }
 
index 54d617f7df3e03b3aa02def2473b03ad66a5d39b..7c59ffaedfe0860ffc55c8f9519a991e79688514 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/uio.h>
 #include <linux/idr.h>
 #include <linux/bsg.h>
+#include <linux/smp_lock.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_ioctl.h>
@@ -835,7 +836,11 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
 
 static int bsg_open(struct inode *inode, struct file *file)
 {
-       struct bsg_device *bd = bsg_get_device(inode, file);
+       struct bsg_device *bd;
+
+       lock_kernel();
+       bd = bsg_get_device(inode, file);
+       unlock_kernel();
 
        if (IS_ERR(bd))
                return PTR_ERR(bd);
index e8e60e7a2e70eb31b17670537dc3291283d9f408..d1de68a3192088b11f20317d5405d05c35cd5071 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/hdreg.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/smp_lock.h>
 #include "aoe.h"
 
 enum {
@@ -174,12 +175,16 @@ aoechr_open(struct inode *inode, struct file *filp)
 {
        int n, i;
 
+       lock_kernel();
        n = iminor(inode);
        filp->private_data = (void *) (unsigned long) n;
 
        for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-               if (chardevs[i].minor == n)
+               if (chardevs[i].minor == n) {
+                       unlock_kernel();
                        return 0;
+               }
+       unlock_kernel();
        return -EINVAL;
 }
 
index ab86e23ddc69dc36272c6bf60ebe915168177b58..9d92636350e5f67f1d2ebd7b60466859b4e301f9 100644 (file)
@@ -162,6 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
 #include <linux/pg.h>
 #include <linux/device.h>
 #include <linux/sched.h>       /* current, TASK_* */
+#include <linux/smp_lock.h>
 #include <linux/jiffies.h>
 
 #include <asm/uaccess.h>
@@ -515,12 +516,18 @@ static int pg_open(struct inode *inode, struct file *file)
 {
        int unit = iminor(inode) & 0x7f;
        struct pg *dev = &devices[unit];
+       int ret = 0;
 
-       if ((unit >= PG_UNITS) || (!dev->present))
-               return -ENODEV;
+       lock_kernel();
+       if ((unit >= PG_UNITS) || (!dev->present)) {
+               ret = -ENODEV;
+               goto out;
+       }
 
-       if (test_and_set_bit(0, &dev->access))
-               return -EBUSY;
+       if (test_and_set_bit(0, &dev->access)) {
+               ret = -EBUSY;
+               goto out;
+       }
 
        if (dev->busy) {
                pg_reset(dev);
@@ -533,12 +540,15 @@ static int pg_open(struct inode *inode, struct file *file)
        if (dev->bufptr == NULL) {
                clear_bit(0, &dev->access);
                printk("%s: buffer allocation failed\n", dev->name);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out;
        }
 
        file->private_data = dev;
 
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int pg_release(struct inode *inode, struct file *file)
index 8b9549ab4a4e6eafd21b2e38b835618448cf31d9..314333db16eee8c31869181c207e8c4737129a5c 100644 (file)
@@ -146,6 +146,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
 #include <linux/mtio.h>
 #include <linux/device.h>
 #include <linux/sched.h>       /* current, TASK_*, schedule_timeout() */
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -650,8 +651,11 @@ static int pt_open(struct inode *inode, struct file *file)
        struct pt_unit *tape = pt + unit;
        int err;
 
-       if (unit >= PT_UNITS || (!tape->present))
+       lock_kernel();
+       if (unit >= PT_UNITS || (!tape->present)) {
+               unlock_kernel();
                return -ENODEV;
+       }
 
        err = -EBUSY;
        if (!atomic_dec_and_test(&tape->available))
@@ -678,10 +682,12 @@ static int pt_open(struct inode *inode, struct file *file)
        }
 
        file->private_data = tape;
+       unlock_kernel();
        return 0;
 
 out:
        atomic_inc(&tape->available);
+       unlock_kernel();
        return err;
 }
 
index 0638730a4a19636b7e9db504959725ada6f29895..d97700aa54a9b63edf66507e7592fdc9e6ca3937 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
@@ -263,9 +264,11 @@ static int vhci_open(struct inode *inode, struct file *file)
        skb_queue_head_init(&data->readq);
        init_waitqueue_head(&data->read_wait);
 
+       lock_kernel();
        hdev = hci_alloc_dev();
        if (!hdev) {
                kfree(data);
+               unlock_kernel();
                return -ENOMEM;
        }
 
@@ -286,10 +289,12 @@ static int vhci_open(struct inode *inode, struct file *file)
                BT_ERR("Can't register HCI device");
                kfree(data);
                hci_free_dev(hdev);
+               unlock_kernel();
                return -EBUSY;
        }
 
        file->private_data = data;
+       unlock_kernel();
 
        return nonseekable_open(inode, file);
 }
@@ -313,18 +318,21 @@ static int vhci_release(struct inode *inode, struct file *file)
 static int vhci_fasync(int fd, struct file *file, int on)
 {
        struct vhci_data *data = file->private_data;
-       int err;
+       int err = 0;
 
+       lock_kernel();
        err = fasync_helper(fd, file, on, &data->fasync);
        if (err < 0)
-               return err;
+               goto out;
 
        if (on)
                data->flags |= VHCI_FASYNC;
        else
                data->flags &= ~VHCI_FASYNC;
 
-       return 0;
+out:
+       unlock_kernel();
+       return err;
 }
 
 static const struct file_operations vhci_fops = {
index e6cb1ab03e06fb115d532de211d584eff2b539f5..a96f3197e60fedd503fbd64ba090d8f9d575dd94 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include "agp.h"
@@ -677,6 +678,7 @@ static int agp_open(struct inode *inode, struct file *file)
        struct agp_client *client;
        int rc = -ENXIO;
 
+       lock_kernel();
        mutex_lock(&(agp_fe.agp_mutex));
 
        if (minor != AGPGART_MINOR)
@@ -703,12 +705,14 @@ static int agp_open(struct inode *inode, struct file *file)
        agp_insert_file_private(priv);
        DBG("private=%p, client=%p", priv, client);
        mutex_unlock(&(agp_fe.agp_mutex));
+       unlock_kernel();
        return 0;
 
 err_out_nomem:
        rc = -ENOMEM;
 err_out:
        mutex_unlock(&(agp_fe.agp_mutex));
+       unlock_kernel();
        return rc;
 }
 
index cdd876dbb2b0f77ab05e27c37f0671724743537c..da8a1658a273b6253172b0622631796c4af137f0 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/miscdevice.h>
@@ -416,6 +417,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 {
        struct apm_user *as;
 
+       lock_kernel();
        as = kzalloc(sizeof(*as), GFP_KERNEL);
        if (as) {
                /*
@@ -435,6 +437,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 
                filp->private_data = as;
        }
+       unlock_kernel();
 
        return as ? 0 : -ENOMEM;
 }
index b6f2639f903d344754f211f12e7e630759e2861a..d8cff909001c1e4cbd68c8aa22f08eb70d08bbdb 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/module.h>
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
@@ -67,11 +68,15 @@ static void set_led(char state)
 
 static int briq_panel_open(struct inode *ino, struct file *filep)
 {
-       /* enforce single access */
-       if (vfd_is_open)
+       lock_kernel();
+       /* enforce single access, vfd_is_open is protected by BKL */
+       if (vfd_is_open) {
+               unlock_kernel();
                return -EBUSY;
+       }
        vfd_is_open = 1;
 
+       unlock_kernel();
        return 0;
 }
 
index c0a4a0bb509e77397875b023bc4ad4f1324946bf..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>
 
@@ -157,6 +158,7 @@ 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 d2e6da85f58ac262b2297b6e8281c943aa009cf1..851a53f1accefa0ee1d84772a6ec5a182d609969 100644 (file)
@@ -37,6 +37,7 @@
 #include "drmP.h"
 #include "drm_sarea.h"
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 
 static int drm_open_helper(struct inode *inode, struct file *filp,
                           struct drm_device * dev);
@@ -174,12 +175,14 @@ int drm_stub_open(struct inode *inode, struct file *filp)
 
        DRM_DEBUG("\n");
 
+       /* BKL pushdown: note that nothing else serializes idr_find() */
+       lock_kernel();
        minor = idr_find(&drm_minors_idr, minor_id);
        if (!minor)
-               return -ENODEV;
+               goto out;
 
        if (!(dev = minor->dev))
-               return -ENODEV;
+               goto out;
 
        old_fops = filp->f_op;
        filp->f_op = fops_get(&dev->driver->fops);
@@ -189,6 +192,8 @@ int drm_stub_open(struct inode *inode, struct file *filp)
        }
        fops_put(old_fops);
 
+out:
+       unlock_kernel();
        return err;
 }
 
index ea35ab2c9909490bb490bb51eae47d39c31661b3..fb584938c9c3b2eb81bb954a8a8af41fa40fbf00 100644 (file)
@@ -27,6 +27,7 @@
  * option) any later version.
  */
 #include <linux/ds1286.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -252,6 +253,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file,
 
 static int ds1286_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock_irq(&ds1286_lock);
 
        if (ds1286_status & RTC_IS_OPEN)
@@ -260,10 +262,12 @@ static int ds1286_open(struct inode *inode, struct file *file)
        ds1286_status |= RTC_IS_OPEN;
 
        spin_unlock_irq(&ds1286_lock);
+       unlock_kernel();
        return 0;
 
 out_busy:
        spin_lock_irq(&ds1286_lock);
+       unlock_kernel();
        return -EBUSY;
 }
 
index 334ad5bbe6b62a244eed91b9731d121244ea4780..34275c6f1da282f14de6a2b3bb9c874b87586de6 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/proc_fs.h>
 #include <linux/capability.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -208,6 +209,12 @@ static void ds1620_read_state(struct therm *therm)
        therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9));
 }
 
+static int ds1620_open(struct inode *inode, struct file *file)
+{
+       cycle_kernel_lock();
+       return nonseekable_open(inode, file);
+}
+
 static ssize_t
 ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
 {
@@ -336,7 +343,7 @@ static struct proc_dir_entry *proc_therm_ds1620;
 
 static const struct file_operations ds1620_fops = {
        .owner          = THIS_MODULE,
-       .open           = nonseekable_open,
+       .open           = ds1620_open,
        .read           = ds1620_read,
        .ioctl          = ds1620_ioctl,
 };
index a69c6528326005694809005a546436a1af5cd5d1..7bf7485377e60e471442374edb3fcfd001cb62b5 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 #include <asm/atarihw.h>
 #include <asm/traps.h>
@@ -436,13 +437,17 @@ static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
 static int dsp56k_open(struct inode *inode, struct file *file)
 {
        int dev = iminor(inode) & 0x0f;
+       int ret = 0;
 
+       lock_kernel();
        switch(dev)
        {
        case DSP56K_DEV_56001:
 
-               if (test_and_set_bit(0, &dsp56k.in_use))
-                       return -EBUSY;
+               if (test_and_set_bit(0, &dsp56k.in_use)) {
+                       ret = -EBUSY;
+                       goto out;
+               }
 
                dsp56k.timeout = TIMEOUT;
                dsp56k.maxio = MAXIO;
@@ -458,10 +463,11 @@ static int dsp56k_open(struct inode *inode, struct file *file)
                break;
 
        default:
-               return -ENODEV;
+               ret = -ENODEV;
        }
-
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int dsp56k_release(struct inode *inode, struct file *file)
index abde6ddefe696e7e0af352e918085c68a83f4d89..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,10 +289,12 @@ static int dtlk_ioctl(struct inode *inode,
        }
 }
 
+/* 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 49233f5898742040339b5a1d31c4ce7fd74d9960..d57ca3e4e5343311f43acbf8b35021ed16ee3fe4 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -272,6 +273,7 @@ efi_rtc_open(struct inode *inode, struct file *file)
         * We do accept multiple open files at the same time as we
         * synchronize on the per call operation.
         */
+       cycle_kernel_lock();
        return 0;
 }
 
index 69f0a2993af0f7456b118bcaa0931e7730751067..aac0985a572b86811bae33317d7d4176e924d317 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
+#include <linux/smp_lock.h>
 #include <linux/workqueue.h>
 
 #include <asm/uaccess.h>
@@ -338,12 +339,16 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
 
 static int gen_rtc_open(struct inode *inode, struct file *file)
 {
-       if (gen_rtc_status & RTC_IS_OPEN)
+       lock_kernel();
+       if (gen_rtc_status & RTC_IS_OPEN) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
        gen_rtc_status |= RTC_IS_OPEN;
        gen_rtc_irq_data = 0;
        irq_active = 0;
+       unlock_kernel();
 
        return 0;
 }
index e7fb0bca3667670f27ae781893bab44b6f51d006..fb0a85a1eb36a71abcb9455048fb502c0b0d52ed 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/major.h>
@@ -193,6 +194,7 @@ static int hpet_open(struct inode *inode, struct file *file)
        if (file->f_mode & FMODE_WRITE)
                return -EINVAL;
 
+       lock_kernel();
        spin_lock_irq(&hpet_lock);
 
        for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
@@ -207,6 +209,7 @@ static int hpet_open(struct inode *inode, struct file *file)
 
        if (!devp) {
                spin_unlock_irq(&hpet_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
@@ -214,6 +217,7 @@ static int hpet_open(struct inode *inode, struct file *file)
        devp->hd_irqdata = 0;
        devp->hd_flags |= HPET_OPEN;
        spin_unlock_irq(&hpet_lock);
+       unlock_kernel();
 
        return 0;
 }
index 662d60e44e9a02924888d74499fbe91b268423f5..e5d583c84e4f864ae31cb95534bd5befe6291ed6 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/delay.h>
@@ -86,6 +87,7 @@ static int rng_dev_open(struct inode *inode, struct file *filp)
                return -EINVAL;
        if (filp->f_mode & FMODE_WRITE)
                return -EINVAL;
+       cycle_kernel_lock();
        return 0;
 }
 
index c12cf8fc4be0c1817a448300847fcc3a3a48b31d..61b6fe4156bb3627b7855373e78f8af295b238e2 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>
@@ -2908,42 +2909,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 86e6538a77b05835b352001d170dba5335be284b..ec9d0443d92c7a3f77b67832d064111119dfdead 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/bcd.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/ioport.h>
@@ -163,15 +164,18 @@ static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 static int rtc_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock_irq(&rtc_lock);
 
        if (rtc_status & RTC_IS_OPEN) {
                spin_unlock_irq(&rtc_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
        rtc_status |= RTC_IS_OPEN;
        spin_unlock_irq(&rtc_lock);
+       unlock_kernel();
 
        return 0;
 }
index 0246a2b8ce4848ad918f24506623dd58d830df5a..c11a40483459f3bd581dd5429f65606b1d882f67 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/compat.h>
+#include <linux/smp_lock.h>
 
 struct ipmi_file_private
 {
@@ -100,7 +101,9 @@ static int ipmi_fasync(int fd, struct file *file, int on)
        struct ipmi_file_private *priv = file->private_data;
        int                      result;
 
+       lock_kernel(); /* could race against open() otherwise */
        result = fasync_helper(fd, file, on, &priv->fasync_queue);
+       unlock_kernel();
 
        return (result);
 }
@@ -121,6 +124,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
        if (!priv)
                return -ENOMEM;
 
+       lock_kernel();
        priv->file = file;
 
        rv = ipmi_create_user(if_num,
@@ -129,7 +133,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
                              &(priv->user));
        if (rv) {
                kfree(priv);
-               return rv;
+               goto out;
        }
 
        file->private_data = priv;
@@ -144,7 +148,9 @@ static int ipmi_open(struct inode *inode, struct file *file)
        priv->default_retries = -1;
        priv->default_retry_time_ms = 0;
 
-       return 0;
+out:
+       unlock_kernel();
+       return rv;
 }
 
 static int ipmi_release(struct inode *inode, struct file *file)
index 0e6df289cb46e8202df710903278ebe6c1fb2a0c..235fab0bdf79d99e3bd4328c8d3a6ee42c0fb7f9 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/moduleparam.h>
 #include <linux/ipmi.h>
 #include <linux/ipmi_smi.h>
+#include <linux/smp_lock.h>
 #include <linux/watchdog.h>
 #include <linux/miscdevice.h>
 #include <linux/init.h>
@@ -818,6 +819,8 @@ static int ipmi_open(struct inode *ino, struct file *filep)
                if (test_and_set_bit(0, &ipmi_wdog_open))
                        return -EBUSY;
 
+               cycle_kernel_lock();
+
                /*
                 * Don't start the timer now, let it start on the
                 * first heartbeat.
index 4fe9206f84deaffcdb5ea044f918c3f710f5f25e..1c29b20e4f4cc0afb017f947221db84d2f378e70 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/netdevice.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/delay.h>
 
 #include <asm/io.h>
@@ -414,6 +415,8 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
 
 static int lcd_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
+
        if (!lcd_present)
                return -ENXIO;
        else
index 60ac642752bea4441604515513efa160d6e8c73f..71abb4c33aa249d748826a317be08a3b8a4f7cd9 100644 (file)
 #include <linux/device.h>
 #include <linux/wait.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 
 #include <linux/parport.h>
 #undef LP_STATS
@@ -489,14 +490,21 @@ static ssize_t lp_read(struct file * file, char __user * buf,
 static int lp_open(struct inode * inode, struct file * file)
 {
        unsigned int minor = iminor(inode);
+       int ret = 0;
 
-       if (minor >= LP_NO)
-               return -ENXIO;
-       if ((LP_F(minor) & LP_EXIST) == 0)
-               return -ENXIO;
-       if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor)))
-               return -EBUSY;
-
+       lock_kernel();
+       if (minor >= LP_NO) {
+               ret = -ENXIO;
+               goto out;
+       }
+       if ((LP_F(minor) & LP_EXIST) == 0) {
+               ret = -ENXIO;
+               goto out;
+       }
+       if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) {
+               ret = -EBUSY;
+               goto out;
+       }
        /* If ABORTOPEN is set and the printer is offline or out of paper,
           we may still want to open it to perform ioctl()s.  Therefore we
           have commandeered O_NONBLOCK, even though it is being used in
@@ -510,21 +518,25 @@ static int lp_open(struct inode * inode, struct file * file)
                if (status & LP_POUTPA) {
                        printk(KERN_INFO "lp%d out of paper\n", minor);
                        LP_F(minor) &= ~LP_BUSY;
-                       return -ENOSPC;
+                       ret = -ENOSPC;
+                       goto out;
                } else if (!(status & LP_PSELECD)) {
                        printk(KERN_INFO "lp%d off-line\n", minor);
                        LP_F(minor) &= ~LP_BUSY;
-                       return -EIO;
+                       ret = -EIO;
+                       goto out;
                } else if (!(status & LP_PERRORP)) {
                        printk(KERN_ERR "lp%d printer error\n", minor);
                        LP_F(minor) &= ~LP_BUSY;
-                       return -EIO;
+                       ret = -EIO;
+                       goto out;
                }
        }
        lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
        if (!lp_table[minor].lp_buffer) {
                LP_F(minor) &= ~LP_BUSY;
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out;
        }
        /* Determine if the peripheral supports ECP mode */
        lp_claim_parport_or_block (&lp_table[minor]);
@@ -540,7 +552,9 @@ static int lp_open(struct inode * inode, struct file * file)
        parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT);
        lp_release_parport (&lp_table[minor]);
        lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int lp_release(struct inode * inode, struct file * file)
index f4716ad7348ae7185bdba2a35379b9a68fd37a63..acd8e9ed474ae74e6b53fd58539ec3efaf5f2b26 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/uio.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -382,15 +383,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
        struct mbcs_soft *soft;
        int minor;
 
+       lock_kernel();
        minor = iminor(ip);
 
+       /* Nothing protects access to this list... */
        list_for_each_entry(soft, &soft_list, list) {
                if (soft->nasid == minor) {
                        fp->private_data = soft->cxdev;
+                       unlock_kernel();
                        return 0;
                }
        }
 
+       unlock_kernel();
        return -ENODEV;
 }
 
index 934ffafedaea207131f7d193bed9e75c929f4db9..070e22e8ea9efb43a180149caa5a47d70faf471f 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/bootmem.h>
 #include <linux/splice.h>
 #include <linux/pfn.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -889,6 +890,9 @@ static const struct file_operations kmsg_fops = {
 
 static int memory_open(struct inode * inode, struct file * filp)
 {
+       int ret = 0;
+
+       lock_kernel();
        switch (iminor(inode)) {
                case 1:
                        filp->f_op = &mem_fops;
@@ -932,11 +936,13 @@ static int memory_open(struct inode * inode, struct file * filp)
                        break;
 #endif
                default:
+                       unlock_kernel();
                        return -ENXIO;
        }
        if (filp->f_op && filp->f_op->open)
-               return filp->f_op->open(inode,filp);
-       return 0;
+               ret = filp->f_op->open(inode,filp);
+       unlock_kernel();
+       return ret;
 }
 
 static const struct file_operations memory_fops = {
index eaace0db0ff4b65d61418e17db6b401c37fc3507..6e1563c3d30aea0da63650ea8a3a64daaf6727be 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 /*
  * Head entry for the doubly linked miscdevice list
@@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file)
        int err = -ENODEV;
        const struct file_operations *old_fops, *new_fops = NULL;
        
+       lock_kernel();
        mutex_lock(&misc_mtx);
        
        list_for_each_entry(c, &misc_list, list) {
@@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file)
        fops_put(old_fops);
 fail:
        mutex_unlock(&misc_mtx);
+       unlock_kernel();
        return err;
 }
 
index 8d14823b0514ef3b58a4e775aa33cfa72009a4e8..50243fcd87e882656069cce5492b92b53469d4f7 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/serial.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/serial_8250.h>
 #include "smapi.h"
@@ -100,6 +101,7 @@ static int mwave_open(struct inode *inode, struct file *file)
        PRINTK_2(TRACE_MWAVE,
                "mwavedd::mwave_open, exit return retval %x\n", retval);
 
+       cycle_kernel_lock();
        return retval;
 }
 
index 98dec380af495607a0ce360720134234671347e4..197cd7a0c33267d9f1becd4b61b8724ac728e804 100644 (file)
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -333,12 +334,14 @@ nvram_ioctl(struct inode *inode, struct file *file,
 static int
 nvram_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock(&nvram_state_lock);
 
        if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
            (nvram_open_mode & NVRAM_EXCL) ||
            ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
                spin_unlock(&nvram_state_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
@@ -349,6 +352,7 @@ nvram_open(struct inode *inode, struct file *file)
        nvram_open_cnt++;
 
        spin_unlock(&nvram_state_lock);
+       unlock_kernel();
 
        return 0;
 }
index ecfaf180e5bd8b106ee12e06da33fc0c1a88f702..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"
@@ -217,6 +218,7 @@ 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 3aab837d9480ae57e66fb9f438e76efd263fea95..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"
@@ -638,6 +639,7 @@ 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 bbfa0e241cba38928c8a5b5157a7a2a3ac178d2a..505fcbe884a4aad394ae212396677d258b3d25fb 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/cdev.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -53,6 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
                return 0;
        }
 
+       lock_kernel();
        mutex_lock(&raw_mutex);
 
        /*
@@ -79,6 +81,7 @@ static int raw_open(struct inode *inode, struct file *filp)
                        bdev->bd_inode->i_mapping;
        filp->private_data = bdev;
        mutex_unlock(&raw_mutex);
+       unlock_kernel();
        return 0;
 
 out2:
index 909cac93fa2ad408caf695e253a4a4820cef659e..fa92a8af5a5a05fe62a98aadd327177006f52c16 100644 (file)
@@ -73,6 +73,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/sysctl.h>
 #include <linux/wait.h>
 #include <linux/bcd.h>
@@ -734,6 +735,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
  * needed here. Or anywhere else in this driver. */
 static int rtc_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        spin_lock_irq(&rtc_lock);
 
        if (rtc_status & RTC_IS_OPEN)
@@ -743,10 +745,12 @@ static int rtc_open(struct inode *inode, struct file *file)
 
        rtc_irq_data = 0;
        spin_unlock_irq(&rtc_lock);
+       unlock_kernel();
        return 0;
 
 out_busy:
        spin_unlock_irq(&rtc_lock);
+       unlock_kernel();
        return -EBUSY;
 }
 
index 99e5272e3c53e1ef1aa32f0733b1bbf0e9f2487e..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>
 
@@ -51,6 +52,7 @@ 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 8fe099a410654ffb35c5e9c0a3e8c42c8acbcb59..0b799ac1b04957f501d4c50539f58e7ee28199cd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <asm/sn/io.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/module.h>
@@ -104,6 +105,7 @@ scdrv_open(struct inode *inode, struct file *file)
        file->private_data = sd;
 
        /* hook this subchannel up to the system controller interrupt */
+       lock_kernel();
        rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt,
                         IRQF_SHARED | IRQF_DISABLED,
                         SYSCTL_BASENAME, sd);
@@ -111,9 +113,10 @@ scdrv_open(struct inode *inode, struct file *file)
                ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch);
                kfree(sd);
                printk("%s: irq request failed (%d)\n", __func__, rv);
+               unlock_kernel();
                return -EBUSY;
        }
-
+       unlock_kernel();
        return 0;
 }
 
index 58533de59027806360ffe816e5b5571becf966b8..85e0eb76eeab92ca751ce59acfcacc38a39f61a5 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/err.h>
 #include <linux/kfifo.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -906,12 +907,14 @@ static int sonypi_misc_release(struct inode *inode, struct file *file)
 
 static int sonypi_misc_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        mutex_lock(&sonypi_device.lock);
        /* Flush input queue on first open */
        if (!sonypi_device.open_count)
                kfifo_reset(sonypi_device.fifo);
        sonypi_device.open_count++;
        mutex_unlock(&sonypi_device.lock);
+       unlock_kernel();
        return 0;
 }
 
index 4c431cb7cf1b1f21f1c32389d738c005c0df7a9d..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>
@@ -236,6 +237,7 @@ 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 35e58030d2968d38e7a039ef36a58bdf9fd4b3df..8f2284be68e192201a069886ff3d0a1209553955 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <linux/sysfs.h>
 #include <linux/device.h>
@@ -204,11 +205,14 @@ static int tlclk_open(struct inode *inode, struct file *filp)
 {
        int result;
 
-       if (test_and_set_bit(0, &useflags))
-               return -EBUSY;
+       lock_kernel();
+       if (test_and_set_bit(0, &useflags)) {
+               result = -EBUSY;
                /* this legacy device is always one per system and it doesn't
                 * know how to handle multiple concurrent clients.
                 */
+               goto out;
+       }
 
        /* Make sure there is no interrupt pending while
         * initialising interrupt handler */
@@ -218,13 +222,14 @@ static int tlclk_open(struct inode *inode, struct file *filp)
         * we can't share this IRQ */
        result = request_irq(telclk_interrupt, &tlclk_interrupt,
                             IRQF_DISABLED, "telco_clock", tlclk_interrupt);
-       if (result == -EBUSY) {
+       if (result == -EBUSY)
                printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n");
-               return -EBUSY;
-       }
-       inb(TLCLK_REG6);        /* Clear interrupt events */
+       else
+               inb(TLCLK_REG6);        /* Clear interrupt events */
 
-       return 0;
+out:
+       unlock_kernel();
+       return result;
 }
 
 static int tlclk_release(struct inode *inode, struct file *filp)
index a5d8bcb40000df912d43cb9ad4a8cc9c7453642c..e1fc193d9396fc69c41ecd868fd2bd2d60ff73b7 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/poll.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 #include "tpm.h"
 
@@ -897,6 +898,7 @@ int tpm_open(struct inode *inode, struct file *file)
        int rc = 0, minor = iminor(inode);
        struct tpm_chip *chip = NULL, *pos;
 
+       lock_kernel();
        spin_lock(&driver_lock);
 
        list_for_each_entry(pos, &tpm_chip_list, list) {
@@ -926,16 +928,19 @@ int tpm_open(struct inode *inode, struct file *file)
        if (chip->data_buffer == NULL) {
                chip->num_opens--;
                put_device(chip->dev);
+               unlock_kernel();
                return -ENOMEM;
        }
 
        atomic_set(&chip->data_pending, 0);
 
        file->private_data = chip;
+       unlock_kernel();
        return 0;
 
 err_out:
        spin_unlock(&driver_lock);
+       unlock_kernel();
        return rc;
 }
 EXPORT_SYMBOL_GPL(tpm_open);
index 750131010af01875d06d1c5e11818112c02ecbd2..047a17339f835f1891dbd3db58371a9e25975f91 100644 (file)
@@ -2665,7 +2665,7 @@ static void release_dev(struct file *filp)
  *              ->siglock protects ->signal/->sighand
  */
 
-static int tty_open(struct inode *inode, struct file *filp)
+static int __tty_open(struct inode *inode, struct file *filp)
 {
        struct tty_struct *tty;
        int noctty, retval;
@@ -2779,6 +2779,19 @@ got_driver:
        return 0;
 }
 
+/* BKL pushdown: scary code avoidance wrapper */
+static int tty_open(struct inode *inode, struct file *filp)
+{
+       int ret;
+
+       lock_kernel();
+       ret = __tty_open(inode, filp);
+       unlock_kernel();
+       return ret;
+}
+
+
+
 #ifdef CONFIG_UNIX98_PTYS
 /**
  *     ptmx_open               -       open a unix 98 pty master
@@ -2792,7 +2805,7 @@ got_driver:
  *             allocated_ptys_lock handles the list of free pty numbers
  */
 
-static int ptmx_open(struct inode *inode, struct file *filp)
+static int __ptmx_open(struct inode *inode, struct file *filp)
 {
        struct tty_struct *tty;
        int retval;
@@ -2831,6 +2844,16 @@ out:
        devpts_kill_index(index);
        return retval;
 }
+
+static int ptmx_open(struct inode *inode, struct file *filp)
+{
+       int ret;
+
+       lock_kernel();
+       ret = __ptmx_open(inode, filp);
+       unlock_kernel();
+       return ret;
+}
 #endif
 
 /**
@@ -2886,15 +2909,16 @@ static int tty_fasync(int fd, struct file *filp, int on)
 {
        struct tty_struct *tty;
        unsigned long flags;
-       int retval;
+       int retval = 0;
 
+       lock_kernel();
        tty = (struct tty_struct *)filp->private_data;
        if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync"))
-               return 0;
+               goto out;
 
        retval = fasync_helper(fd, filp, on, &tty->fasync);
        if (retval <= 0)
-               return retval;
+               goto out;
 
        if (on) {
                enum pid_type type;
@@ -2912,12 +2936,15 @@ static int tty_fasync(int fd, struct file *filp, int on)
                spin_unlock_irqrestore(&tty->ctrl_lock, flags);
                retval = __f_setown(filp, pid, type, 0);
                if (retval)
-                       return retval;
+                       goto out;
        } else {
                if (!tty->fasync && !waitqueue_active(&tty->read_wait))
                        tty->minimum_to_wake = N_TTY_BUF_SIZE;
        }
-       return 0;
+       retval = 0;
+out:
+       unlock_kernel();
+       return retval;
 }
 
 /**
index 83aeedda200cfccc6724be4eaf8ce3c715b1c2d7..eebfad2777d29ac9bfd7134eab259c11c7bd5a79 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/kbd_kern.h>
 #include <linux/console.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
@@ -460,9 +461,13 @@ static int
 vcs_open(struct inode *inode, struct file *filp)
 {
        unsigned int currcons = iminor(inode) & 127;
+       int ret = 0;
+       
+       lock_kernel();
        if(currcons && !vc_cons_allocated(currcons-1))
-               return -ENXIO;
-       return 0;
+               ret = -ENXIO;
+       unlock_kernel();
+       return ret;
 }
 
 static const struct file_operations vcs_fops = {
index c39ddaff5e8f18e230ed8ea8e4f1d3c4c2f4533e..977f7d35e76916cc774ff4bf72c9f67e3ecd3eca 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/completion.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
@@ -687,6 +688,7 @@ static int viotap_open(struct inode *inode, struct file *file)
        if (op == NULL)
                return -ENOMEM;
 
+       lock_kernel();
        get_dev_info(file->f_path.dentry->d_inode, &devi);
 
        /* Note: We currently only support one mode! */
@@ -717,6 +719,7 @@ static int viotap_open(struct inode *inode, struct file *file)
 
 free_op:
        free_op_struct(op);
+       unlock_kernel();
        return ret;
 }
 
index e5ed09192be8675b615f6978dcf92f41a3dcf316..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>
 
@@ -547,6 +548,7 @@ 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 3edf1fc1296312e09670427b6500a442d50a7c5f..1e1b81e57cdcf7060739a42bd6862d2d5a2caab7 100644 (file)
@@ -85,6 +85,7 @@
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <linux/sysctl.h>
 #include <linux/version.h>
 #include <linux/fs.h>
@@ -504,11 +505,12 @@ static int hwicap_open(struct inode *inode, struct file *file)
        struct hwicap_drvdata *drvdata;
        int status;
 
+       lock_kernel();
        drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
 
        status = mutex_lock_interruptible(&drvdata->sem);
        if (status)
-               return status;
+               goto out;
 
        if (drvdata->is_open) {
                status = -EBUSY;
@@ -528,6 +530,8 @@ static int hwicap_open(struct inode *inode, struct file *file)
 
  error:
        mutex_unlock(&drvdata->sem);
+ out:
+       unlock_kernel();
        return status;
 }
 
index 1ca6f4635eeb3e0474abada594892ac5683ce7ba..2fde6c63f47dffa2d89c224cd15c1be215d4d20e 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/major.h>
 #include <linux/hid.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <linux/hidraw.h>
 
@@ -157,6 +158,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
        struct hidraw_list *list;
        int err = 0;
 
+       lock_kernel();
        if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) {
                err = -ENOMEM;
                goto out;
@@ -183,6 +185,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
 out_unlock:
        spin_unlock(&minors_lock);
 out:
+       unlock_kernel();
        return err;
 
 }
index d34c14c81c291e9beabf7100530307b8a42e8914..006a5857256a15b9cebab931d5c9489a62ed891d 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
 static struct i2c_driver i2cdev_driver;
@@ -441,14 +442,20 @@ static int i2cdev_open(struct inode *inode, struct file *file)
        struct i2c_client *client;
        struct i2c_adapter *adap;
        struct i2c_dev *i2c_dev;
+       int ret = 0;
 
+       lock_kernel();
        i2c_dev = i2c_dev_get_by_minor(minor);
-       if (!i2c_dev)
-               return -ENODEV;
+       if (!i2c_dev) {
+               ret = -ENODEV;
+               goto out;
+       }
 
        adap = i2c_get_adapter(i2c_dev->adap->nr);
-       if (!adap)
-               return -ENODEV;
+       if (!adap) {
+               ret = -ENODEV;
+               goto out;
+       }
 
        /* This creates an anonymous i2c_client, which may later be
         * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
@@ -460,7 +467,8 @@ static int i2cdev_open(struct inode *inode, struct file *file)
        client = kzalloc(sizeof(*client), GFP_KERNEL);
        if (!client) {
                i2c_put_adapter(adap);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out;
        }
        snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
        client->driver = &i2cdev_driver;
@@ -468,7 +476,9 @@ static int i2cdev_open(struct inode *inode, struct file *file)
        client->adapter = adap;
        file->private_data = client;
 
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int i2cdev_release(struct inode *inode, struct file *file)
index 1e1f26331a24dd2c4aa3bc0028c216cd6f1c2c40..a3d228302d2019ece45d2b4253cffafab226dd90 100644 (file)
@@ -2421,9 +2421,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
        if (i >= MAX_HWIFS * MAX_DRIVES)
                return -ENXIO;
 
+       lock_kernel();
        tape = ide_tape_chrdev_get(i);
-       if (!tape)
+       if (!tape) {
+               unlock_kernel();
                return -ENXIO;
+       }
 
        debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
 
@@ -2482,10 +2485,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
                        }
                }
        }
+       unlock_kernel();
        return 0;
 
 out_put_tape:
        ide_tape_put(tape);
+       unlock_kernel();
        return retval;
 }
 
index d7a6881b571d990ec1fd47ba959126ac68a64b7e..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>
 
@@ -1159,6 +1160,7 @@ 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 ca4cf3a511abd81cdbdc02dcd3546a85e9d71201..195f97302fe5243575d42abe3c990bdb4fa7d106 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 
 #include <rdma/rdma_user_cm.h>
 #include <rdma/ib_marshall.h>
@@ -1156,6 +1157,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
        if (!file)
                return -ENOMEM;
 
+       lock_kernel();
        INIT_LIST_HEAD(&file->event_list);
        INIT_LIST_HEAD(&file->ctx_list);
        init_waitqueue_head(&file->poll_wait);
@@ -1163,6 +1165,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
 
        filp->private_data = file;
        file->filp = filp;
+       unlock_kernel();
        return 0;
 }
 
index 840ede9ae965e2cfafd9766a91292e60910b2f1c..208c7f34323ccc372c4618dac9808badff6151b2 100644 (file)
@@ -777,6 +777,19 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
 }
 #endif
 
+/*
+ * ib_umad_open() does not need the BKL:
+ *
+ *  - umad_port[] accesses are protected by port_lock, the
+ *    ib_umad_port structures are properly reference counted, and
+ *    everything else is purely local to the file being created, so
+ *    races against other open calls are not a problem;
+ *  - the ioctl method does not affect any global state outside of the
+ *    file structure being operated on;
+ *  - the port is added to umad_port[] as the last part of module
+ *    initialization so the open method will either immediately run
+ *    -ENXIO, or all required initialization will be done.
+ */
 static int ib_umad_open(struct inode *inode, struct file *filp)
 {
        struct ib_umad_port *port;
index caed42bf7ef57b3adcdc5e7ec158361d37d78860..0f34858e31e717ac676ce3f19f121f614a8b9e2c 100644 (file)
@@ -610,6 +610,18 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
                return file->device->ib_dev->mmap(file->ucontext, vma);
 }
 
+/*
+ * ib_uverbs_open() does not need the BKL:
+ *
+ *  - dev_table[] accesses are protected by map_lock, the
+ *    ib_uverbs_device structures are properly reference counted, and
+ *    everything else is purely local to the file being created, so
+ *    races against other open calls are not a problem;
+ *  - there is no ioctl method to race against;
+ *  - the device is added to dev_table[] as the last part of module
+ *    initialization, the open method will either immediately run
+ *    -ENXIO, or all required initialization will be done.
+ */
 static int ib_uverbs_open(struct inode *inode, struct file *filp)
 {
        struct ib_uverbs_device *dev;
@@ -651,7 +663,6 @@ err_module:
 
 err:
        kref_put(&dev->ref, ib_uverbs_release_dev);
-
        return ret;
 }
 
index b472b15637f003da8b1a980a2d62206fb9c51eb3..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"
@@ -1815,6 +1816,7 @@ done:
 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 27006fc1830567f30c87bc16a323cd826bd0ab46..408df0bd6be50a0b17798b189506c266d0ba34bf 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
+#include <linux/smp_lock.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input core");
@@ -1588,13 +1589,17 @@ EXPORT_SYMBOL(input_unregister_handle);
 
 static int input_open_file(struct inode *inode, struct file *file)
 {
-       struct input_handler *handler = input_table[iminor(inode) >> 5];
+       struct input_handler *handler;
        const struct file_operations *old_fops, *new_fops = NULL;
        int err;
 
+       lock_kernel();
        /* No load-on-demand here? */
-       if (!handler || !(new_fops = fops_get(handler->fops)))
-               return -ENODEV;
+       handler = input_table[iminor(inode) >> 5];
+       if (!handler || !(new_fops = fops_get(handler->fops))) {
+               err = -ENODEV;
+               goto out;
+       }
 
        /*
         * That's _really_ odd. Usually NULL ->open means "nothing special",
@@ -1602,7 +1607,8 @@ static int input_open_file(struct inode *inode, struct file *file)
         */
        if (!new_fops->open) {
                fops_put(new_fops);
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
        old_fops = file->f_op;
        file->f_op = new_fops;
@@ -1614,6 +1620,8 @@ static int input_open_file(struct inode *inode, struct file *file)
                file->f_op = fops_get(old_fops);
        }
        fops_put(old_fops);
+out:
+       unlock_kernel();
        return err;
 }
 
index 45e5d05b01dee4cfd674bf9beae2c5b55cf48808..49d8abfe38fe01c3db1fe0702d125daaf4605e00 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/hp_sdc.h>
 #include <linux/errno.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -408,6 +409,7 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait)
 
 static int hp_sdc_rtc_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
         return 0;
 }
 
index a56ad4ba8fe2eb482ee4a26f1f36baa56753e1c5..2bcfa0b3506145951f9fb53d85cf0bcaea739e94 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/uinput.h>
+#include <linux/smp_lock.h>
 
 static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
@@ -222,6 +223,7 @@ static int uinput_open(struct inode *inode, struct file *file)
        if (!newdev)
                return -ENOMEM;
 
+       lock_kernel();
        mutex_init(&newdev->mutex);
        spin_lock_init(&newdev->requests_lock);
        init_waitqueue_head(&newdev->requests_waitq);
@@ -229,6 +231,7 @@ static int uinput_open(struct inode *inode, struct file *file)
        newdev->state = UIST_NEW_DEVICE;
 
        file->private_data = newdev;
+       unlock_kernel();
 
        return 0;
 }
index b989748598ae2191cc58f806eb11a19290b847fe..8137e50ded87de13d31d378557a68ba58d3cedb5 100644 (file)
@@ -14,6 +14,7 @@
 #define MOUSEDEV_MIX           31
 
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -545,16 +546,21 @@ static int mousedev_open(struct inode *inode, struct file *file)
        if (i >= MOUSEDEV_MINORS)
                return -ENODEV;
 
+       lock_kernel();
        error = mutex_lock_interruptible(&mousedev_table_mutex);
-       if (error)
+       if (error) {
+               unlock_kernel();
                return error;
+       }
        mousedev = mousedev_table[i];
        if (mousedev)
                get_device(&mousedev->dev);
        mutex_unlock(&mousedev_table_mutex);
 
-       if (!mousedev)
+       if (!mousedev) {
+               unlock_kernel();
                return -ENODEV;
+       }
 
        client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
        if (!client) {
@@ -573,6 +579,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
                goto err_free_client;
 
        file->private_data = client;
+       unlock_kernel();
        return 0;
 
  err_free_client:
@@ -580,6 +587,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
        kfree(client);
  err_put_mousedev:
        put_device(&mousedev->dev);
+       unlock_kernel();
        return error;
 }
 
index 0403622ae26752976327823802861b321b521d69..c9397c8ee97e8ea44c4f0edc4a6172bd022178ac 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/serio.h>
@@ -81,9 +82,10 @@ static int serio_raw_open(struct inode *inode, struct file *file)
        struct serio_raw_list *list;
        int retval = 0;
 
+       lock_kernel();
        retval = mutex_lock_interruptible(&serio_raw_mutex);
        if (retval)
-               return retval;
+               goto out_bkl;
 
        if (!(serio_raw = serio_raw_locate(iminor(inode)))) {
                retval = -ENODEV;
@@ -108,6 +110,8 @@ static int serio_raw_open(struct inode *inode, struct file *file)
 
 out:
        mutex_unlock(&serio_raw_mutex);
+out_bkl:
+       unlock_kernel();
        return retval;
 }
 
index 6ca0bb949ad301a0ba109a73b342a1cb7833075f..2095153582f13a639ac6feeb19a8fe2a247a7ad1 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/signal.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <linux/wait.h>
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -983,13 +984,17 @@ capi_ioctl(struct inode *inode, struct file *file,
 static int
 capi_open(struct inode *inode, struct file *file)
 {
+       int ret;
+       
+       lock_kernel();
        if (file->private_data)
-               return -EEXIST;
-
-       if ((file->private_data = capidev_alloc()) == NULL)
-               return -ENOMEM;
-
-       return nonseekable_open(inode, file);
+               ret = -EEXIST;
+       else if ((file->private_data = capidev_alloc()) == NULL)
+               ret = -ENOMEM;
+       else
+               ret = nonseekable_open(inode, file);
+       unlock_kernel();
+       return ret;
 }
 
 static int
index c90928974249b6acf52996e8929a202d0ad6571f..1e85f743214e3507a03eabd05a829539d86e300d 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
 #include "platform.h"
@@ -127,14 +128,19 @@ static unsigned int maint_poll(struct file *file, poll_table * wait)
 
 static int maint_open(struct inode *ino, struct file *filep)
 {
+       int ret;
+
+       lock_kernel();
        /* only one open is allowed, so we test
           it atomically */
        if (test_and_set_bit(0, &opened))
-               return (-EBUSY);
-
-       filep->private_data = NULL;
-
-       return nonseekable_open(ino, filep);
+               ret = -EBUSY;
+       else {
+               filep->private_data = NULL;
+               ret = nonseekable_open(ino, filep);
+       }
+       unlock_kernel();
+       return ret;
 }
 
 static int maint_close(struct inode *ino, struct file *filep)
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 16a874bb15614bcd0a0bd58b27ecc3dd7edb7d15..fbbcb27fb6819bcda103ba9e1d5697e6e89bb8c7 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 8d8c6b736167c63427e5c013c6ae81aae3744589..7188c59a76ff7eda195059786bd4ea7e48a200f5 100644 (file)
@@ -1732,7 +1732,7 @@ isdn_open(struct inode *ino, struct file *filep)
        int chidx;
        int retval = -ENODEV;
 
-
+       lock_kernel();
        if (minor == ISDN_MINOR_STATUS) {
                infostruct *p;
 
@@ -1783,6 +1783,7 @@ isdn_open(struct inode *ino, struct file *filep)
 #endif
  out:
        nonseekable_open(ino, filep);
+       unlock_kernel();
        return retval;
 }
 
index dbaad39020a1bc75b5ef48bc3c837d9c45431c2b..40c70ba62bf0eff36362cf7cb5c4129afb2436d0 100644 (file)
@@ -644,12 +644,18 @@ do_adb_query(struct adb_request *req)
 static int adb_open(struct inode *inode, struct file *file)
 {
        struct adbdev_state *state;
+       int ret = 0;
 
-       if (iminor(inode) > 0 || adb_controller == NULL)
-               return -ENXIO;
+       lock_kernel();
+       if (iminor(inode) > 0 || adb_controller == NULL) {
+               ret = -ENXIO;
+               goto out;
+       }
        state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
-       if (state == 0)
-               return -ENOMEM;
+       if (state == 0) {
+               ret = -ENOMEM;
+               goto out;
+       }
        file->private_data = state;
        spin_lock_init(&state->lock);
        atomic_set(&state->n_pending, 0);
@@ -657,7 +663,9 @@ static int adb_open(struct inode *inode, struct file *file)
        init_waitqueue_head(&state->wait_queue);
        state->inuse = 1;
 
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int adb_release(struct inode *inode, struct file *file)
index 73c50bc02095e26b31ec61d76ee81f7f46e4e36d..6a8221893256f55f79bf24cd5fcdcca72cfe3d6a 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
@@ -119,6 +120,7 @@ anslcd_ioctl( struct inode * inode, struct file * file,
 static int
 anslcd_open( struct inode * inode, struct file * file )
 {
+       cycle_kernel_lock();
        return 0;
 }
 
index d86d57af282abde6bca52d369e480ca543651746..32cb0298f88e8b2b3f1def71e83f0e801fd1a159 100644 (file)
@@ -19,6 +19,7 @@
  *    the userland interface
  */
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -1086,10 +1087,12 @@ static int smu_open(struct inode *inode, struct file *file)
        pp->mode = smu_file_commands;
        init_waitqueue_head(&pp->wait);
 
+       lock_kernel();
        spin_lock_irqsave(&smu_clist_lock, flags);
        list_add(&pp->list, &smu_clist);
        spin_unlock_irqrestore(&smu_clist_lock, flags);
        file->private_data = pp;
+       unlock_kernel();
 
        return 0;
 }
index d6365a9f0637407f020b901423dd1d06d851edeb..d524dc245a2c18af982e661970ff255199f85a60 100644 (file)
@@ -18,6 +18,7 @@
  *
  */
 #include <stdarg.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -2047,6 +2048,7 @@ pmu_open(struct inode *inode, struct file *file)
        pp->rb_get = pp->rb_put = 0;
        spin_lock_init(&pp->lock);
        init_waitqueue_head(&pp->wait);
+       lock_kernel();
        spin_lock_irqsave(&all_pvt_lock, flags);
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
        pp->backlight_locker = 0;
@@ -2054,6 +2056,7 @@ pmu_open(struct inode *inode, struct file *file)
        list_add(&pp->list, &all_pmu_pvt);
        spin_unlock_irqrestore(&all_pvt_lock, flags);
        file->private_data = pp;
+       unlock_kernel();
        return 0;
 }
 
index 8b56d929f7fd52c63f1fbda3165bcce33d0aa11d..e208a60c048ad930ebdade3ff274efdbf039fb1f 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include "dvbdev.h"
 
 static int dvbdev_debug;
@@ -74,6 +75,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
 {
        struct dvb_device *dvbdev;
 
+       lock_kernel();
        dvbdev = dvbdev_find_device (iminor(inode));
 
        if (dvbdev && dvbdev->fops) {
@@ -90,8 +92,10 @@ static int dvb_device_open(struct inode *inode, struct file *file)
                        file->f_op = fops_get(old_fops);
                }
                fops_put(old_fops);
+               unlock_kernel();
                return err;
        }
+       unlock_kernel();
        return -ENODEV;
 }
 
index 06dfed9ef4c7194d043999d23ed7eda35e9025c4..3e840f74d45cc217f3443b43df248904cb650b61 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/delay.h>
@@ -27,13 +28,16 @@ static int rds_f_open(struct inode *in, struct file *fi)
        if (rds_users)
                return -EBUSY;
 
+       lock_kernel();
        rds_users++;
        if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) {
                rds_users--;
                printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n");
+               unlock_kernel();
                return -ENOMEM;
        }
 
+       unlock_kernel();
        return 0;
 }
 
index 67a661cf5219bc65e225f304d5872579c034313b..7649860a388d0da519dbbb4d0def8238e3b80ac6 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
@@ -442,6 +443,7 @@ static int video_open(struct inode *inode, struct file *file)
 
        if(minor>=VIDEO_NUM_DEVICES)
                return -ENODEV;
+       lock_kernel();
        mutex_lock(&videodev_lock);
        vfl=video_device[minor];
        if(vfl==NULL) {
@@ -451,6 +453,7 @@ static int video_open(struct inode *inode, struct file *file)
                vfl=video_device[minor];
                if (vfl==NULL) {
                        mutex_unlock(&videodev_lock);
+                       unlock_kernel();
                        return -ENODEV;
                }
        }
@@ -464,6 +467,7 @@ static int video_open(struct inode *inode, struct file *file)
        }
        fops_put(old_fops);
        mutex_unlock(&videodev_lock);
+       unlock_kernel();
        return err;
 }
 
index e630b50966ec5ba0192a36acb9e22a328e9b5675..c5946560c4e222a48b26e23cc275d78691cee1eb 100644 (file)
@@ -548,11 +548,15 @@ static int
 mptctl_fasync(int fd, struct file *filep, int mode)
 {
        MPT_ADAPTER     *ioc;
+       int ret;
 
+       lock_kernel();
        list_for_each_entry(ioc, &ioc_list, list)
                ioc->aen_event_read_flag=0;
 
-       return fasync_helper(fd, filep, mode, &async_queue);
+       ret = fasync_helper(fd, filep, mode, &async_queue);
+       unlock_kernel();
+       return ret;
 }
 
 static int
index c0fb77dc19bb1da39d4c969d60691fc634a63235..4238de98d4a68e9c9ab45b62d6d9fc0c6c73963b 100644 (file)
@@ -1061,6 +1061,7 @@ static int cfg_open(struct inode *inode, struct file *file)
        if (!tmp)
                return -ENOMEM;
 
+       lock_kernel();
        file->private_data = (void *)(i2o_cfg_info_id++);
        tmp->fp = file;
        tmp->fasync = NULL;
@@ -1074,6 +1075,7 @@ static int cfg_open(struct inode *inode, struct file *file)
        spin_lock_irqsave(&i2o_config_lock, flags);
        open_files = tmp;
        spin_unlock_irqrestore(&i2o_config_lock, flags);
+       unlock_kernel();
 
        return 0;
 }
@@ -1082,15 +1084,17 @@ static int cfg_fasync(int fd, struct file *fp, int on)
 {
        ulong id = (ulong) fp->private_data;
        struct i2o_cfg_info *p;
+       int ret = -EBADF;
 
+       lock_kernel();
        for (p = open_files; p; p = p->next)
                if (p->q_id == id)
                        break;
 
-       if (!p)
-               return -EBADF;
-
-       return fasync_helper(fd, fp, on, &p->fasync);
+       if (p)
+               ret = fasync_helper(fd, fp, on, &p->fasync);
+       unlock_kernel();
+       return ret;
 }
 
 static int cfg_release(struct inode *inode, struct file *file)
index ff51ab67231c95a9605496ced2ab104cd9ed5105..176fe4e09d3f0f4401085849cb7fdf47d91bc67a 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/miscdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/hdpu_features.h>
@@ -151,7 +152,13 @@ static ssize_t cpustate_write(struct file *file, const char *buf,
 
 static int cpustate_open(struct inode *inode, struct file *file)
 {
-       return cpustate_get_ref((file->f_flags & O_EXCL));
+       int ret;
+
+       lock_kernel();
+       ret = cpustate_get_ref((file->f_flags & O_EXCL));
+       unlock_kernel();
+
+       return ret;
 }
 
 static int cpustate_release(struct inode *inode, struct file *file)
index 71d1c84e2fa8e4ed918461a702d2e50e2d4b3ccd..1861624700905571ca777937ba005f64bcce3a89 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/cdev.h>
 #include <linux/phantom.h>
+#include <linux/smp_lock.h>
 
 #include <asm/atomic.h>
 #include <asm/io.h>
@@ -212,13 +213,17 @@ static int phantom_open(struct inode *inode, struct file *file)
        struct phantom_device *dev = container_of(inode->i_cdev,
                        struct phantom_device, cdev);
 
+       lock_kernel();
        nonseekable_open(inode, file);
 
-       if (mutex_lock_interruptible(&dev->open_lock))
+       if (mutex_lock_interruptible(&dev->open_lock)) {
+               unlock_kernel();
                return -ERESTARTSYS;
+       }
 
        if (dev->opened) {
                mutex_unlock(&dev->open_lock);
+               unlock_kernel();
                return -EINVAL;
        }
 
@@ -229,7 +234,7 @@ static int phantom_open(struct inode *inode, struct file *file)
        atomic_set(&dev->counter, 0);
        dev->opened++;
        mutex_unlock(&dev->open_lock);
-
+       unlock_kernel();
        return 0;
 }
 
index 00e48e2a9c11229da5576897d566fead0ac2a8f4..60775be22822901f0a67e70878eceac666ab1afa 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/backlight.h>
 #include <linux/platform_device.h>
@@ -1927,8 +1928,10 @@ static int sonypi_misc_release(struct inode *inode, struct file *file)
 static int sonypi_misc_open(struct inode *inode, struct file *file)
 {
        /* Flush input queue on first open */
+       lock_kernel();
        if (atomic_inc_return(&sonypi_compat.open_count) == 1)
                kfifo_reset(sonypi_compat.fifo);
+       unlock_kernel();
        return 0;
 }
 
index 5d3ac512ce169f1f4efc8de2cde7ae6ca21c6148..129d429cd2da5abc55ea1aa9c97a21041a5c85ff 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/compatmac.h>
@@ -86,6 +87,7 @@ static int mtd_open(struct inode *inode, struct file *file)
 {
        int minor = iminor(inode);
        int devnum = minor >> 1;
+       int ret = 0;
        struct mtd_info *mtd;
        struct mtd_file_info *mfi;
 
@@ -98,31 +100,39 @@ static int mtd_open(struct inode *inode, struct file *file)
        if ((file->f_mode & 2) && (minor & 1))
                return -EACCES;
 
+       lock_kernel();
        mtd = get_mtd_device(NULL, devnum);
 
-       if (IS_ERR(mtd))
-               return PTR_ERR(mtd);
+       if (IS_ERR(mtd)) {
+               ret = PTR_ERR(mtd);
+               goto out;
+       }
 
        if (MTD_ABSENT == mtd->type) {
                put_mtd_device(mtd);
-               return -ENODEV;
+               ret = -ENODEV;
+               goto out;
        }
 
        /* You can't open it RW if it's not a writeable device */
        if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
                put_mtd_device(mtd);
-               return -EACCES;
+               ret = -EACCES;
+               goto out;
        }
 
        mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
        if (!mfi) {
                put_mtd_device(mtd);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out;
        }
        mfi->mtd = mtd;
        file->private_data = mfi;
 
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 } /* mtd_open */
 
 /*====================================================================*/
index 9d6aae5449b67010e0ba80e247aab81e3b030ce9..89193ba9451e78e771740724fbb98ff04135aeb7 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/stat.h>
 #include <linux/ioctl.h>
 #include <linux/capability.h>
+#include <linux/smp_lock.h>
 #include <mtd/ubi-user.h>
 #include <asm/uaccess.h>
 #include <asm/div64.h>
@@ -103,9 +104,12 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
        struct ubi_volume_desc *desc;
        int vol_id = iminor(inode) - 1, mode, ubi_num;
 
+       lock_kernel();
        ubi_num = ubi_major2num(imajor(inode));
-       if (ubi_num < 0)
+       if (ubi_num < 0) {
+               unlock_kernel();
                return ubi_num;
+       }
 
        if (file->f_mode & FMODE_WRITE)
                mode = UBI_READWRITE;
@@ -115,6 +119,7 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
        dbg_msg("open volume %d, mode %d", vol_id, mode);
 
        desc = ubi_open_volume(ubi_num, vol_id, mode);
+       unlock_kernel();
        if (IS_ERR(desc))
                return PTR_ERR(desc);
 
index 1f4ca2b54a73370213d1ce162c5c048e00bfc732..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>
@@ -353,6 +354,7 @@ static const int npindex_to_ethertype[NUM_NP] = {
  */
 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 b9018bfa0a9724d2a28ee54d9f9af50429c55da0..eba1271b9735cec24b5a9b986b9958ee95337332 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/kernel.h>
 #include <linux/major.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
@@ -802,22 +803,26 @@ static int tun_chr_fasync(int fd, struct file *file, int on)
 
        DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on);
 
+       lock_kernel();
        if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0)
-               return ret;
+               goto out;
 
        if (on) {
                ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0);
                if (ret)
-                       return ret;
+                       goto out;
                tun->flags |= TUN_FASYNC;
        } else
                tun->flags &= ~TUN_FASYNC;
-
-       return 0;
+       ret = 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int tun_chr_open(struct inode *inode, struct file * file)
 {
+       cycle_kernel_lock();
        DBG1(KERN_INFO "tunX: tun_chr_open\n");
        file->private_data = NULL;
        return 0;
index b0fce1387eaf2555a3d43fe89ccabf801d2a9891..5827324e9d9f94a2abde26a450c1b4be90c941cf 100644 (file)
@@ -92,6 +92,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 #undef COSA_SLOW_IO    /* for testing purposes only */
 
@@ -970,15 +971,21 @@ static int cosa_open(struct inode *inode, struct file *file)
        struct channel_data *chan;
        unsigned long flags;
        int n;
+       int ret = 0;
 
+       lock_kernel();
        if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
-               >= nr_cards)
-               return -ENODEV;
+               >= nr_cards) {
+               ret = -ENODEV;
+               goto out;
+       }
        cosa = cosa_cards+n;
 
        if ((n=iminor(file->f_path.dentry->d_inode)
-               & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
-               return -ENODEV;
+               & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) {
+               ret = -ENODEV;
+               goto out;
+       }
        chan = cosa->chan + n;
        
        file->private_data = chan;
@@ -987,7 +994,8 @@ static int cosa_open(struct inode *inode, struct file *file)
 
        if (chan->usage < 0) { /* in netdev mode */
                spin_unlock_irqrestore(&cosa->lock, flags);
-               return -EBUSY;
+               ret = -EBUSY;
+               goto out;
        }
        cosa->usage++;
        chan->usage++;
@@ -996,7 +1004,9 @@ static int cosa_open(struct inode *inode, struct file *file)
        chan->setup_rx = chrdev_setup_rx;
        chan->rx_done = chrdev_rx_done;
        spin_unlock_irqrestore(&cosa->lock, flags);
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int cosa_release(struct inode *inode, struct file *file)
index 86e9c84a965e3e4f815266734c1c030078a3d0c6..5ac207932fd7b755fa56418ec8745be6c9afd093 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -83,6 +84,8 @@ static int eisa_eeprom_ioctl(struct inode *inode, struct file *file,
 
 static int eisa_eeprom_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
+
        if (file->f_mode & 2)
                return -EINVAL;
    
index 5f186abca1082843a7b12e30865b3bb7c8b83f34..138396ef5be9c38886a6c9a856dff081b681a636 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/proc_fs.h>
 #include <linux/poll.h>
 #include <linux/pci.h>
+#include <linux/smp_lock.h>
 #include <linux/workqueue.h>
 
 #define IN_CARD_SERVICES
@@ -397,20 +398,27 @@ static int ds_open(struct inode *inode, struct file *file)
     struct pcmcia_socket *s;
     user_info_t *user;
     static int warning_printed = 0;
+    int ret = 0;
 
     ds_dbg(0, "ds_open(socket %d)\n", i);
 
+    lock_kernel();
     s = pcmcia_get_socket_by_nr(i);
-    if (!s)
-           return -ENODEV;
+    if (!s) {
+           ret = -ENODEV;
+           goto out;
+    }
     s = pcmcia_get_socket(s);
-    if (!s)
-           return -ENODEV;
+    if (!s) {
+           ret = -ENODEV;
+           goto out;
+    }
 
     if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
            if (s->pcmcia_state.busy) {
                    pcmcia_put_socket(s);
-                   return -EBUSY;
+                   ret = -EBUSY;
+                   goto out;
            }
        else
            s->pcmcia_state.busy = 1;
@@ -419,7 +427,8 @@ static int ds_open(struct inode *inode, struct file *file)
     user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
     if (!user) {
            pcmcia_put_socket(s);
-           return -ENOMEM;
+           ret = -ENOMEM;
+           goto out;
     }
     user->event_tail = user->event_head = 0;
     user->next = s->user;
@@ -441,7 +450,9 @@ static int ds_open(struct inode *inode, struct file *file)
 
     if (s->pcmcia_state.present)
        queue_event(user, CS_EVENT_CARD_INSERTION);
-    return 0;
+out:
+    unlock_kernel();
+    return ret;
 } /* ds_open */
 
 /*====================================================================*/
index 90dfa0df747acb9314b4ed115c2eec0dee1eae0d..0114a78b7cbbe6687892cca1fad58dc76d8883f9 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/rtc.h>
+#include <linux/smp_lock.h>
 #include "rtc-core.h"
 
 static dev_t rtc_devt;
@@ -26,8 +27,11 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
                                        struct rtc_device, char_dev);
        const struct rtc_class_ops *ops = rtc->ops;
 
-       if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
-               return -EBUSY;
+       lock_kernel();
+       if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) {
+               err = -EBUSY;
+               goto out;
+       }
 
        file->private_data = rtc;
 
@@ -37,11 +41,13 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
                rtc->irq_data = 0;
                spin_unlock_irq(&rtc->irq_lock);
 
-               return 0;
+               goto out;
        }
 
        /* something has gone wrong */
        clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
+out:
+       unlock_kernel();
        return err;
 }
 
index a3e0880b38fb2cdb0116b4168664566fdab84ab4..0a19c06019be6c32ea71ccc3849cd7d108040385 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/i2c.h>
 #include <linux/rtc.h>
@@ -655,12 +656,16 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 static int wdt_open(struct inode *inode, struct file *file)
 {
        if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
-               if (test_and_set_bit(0, &wdt_is_open))
+               lock_kernel();
+               if (test_and_set_bit(0, &wdt_is_open)) {
+                       unlock_kernel();
                        return -EBUSY;
+               }
                /*
                 *      Activate
                 */
                wdt_is_open = 1;
+               unlock_kernel();
                return 0;
        }
        return -ENODEV;
index 6e53ab606e9720f531ba8ad218fb0a7524cf212a..29da4413ad437b789dd78f104f894b396f99e386 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/poll.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
@@ -525,6 +526,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
        eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL);
        if (!eerb)
                return -ENOMEM;
+       lock_kernel();
        eerb->buffer_page_count = eer_pages;
        if (eerb->buffer_page_count < 1 ||
            eerb->buffer_page_count > INT_MAX / PAGE_SIZE) {
@@ -532,6 +534,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
                MESSAGE(KERN_WARNING, "can't open device since module "
                        "parameter eer_pages is smaller then 1 or"
                        " bigger then %d", (int)(INT_MAX / PAGE_SIZE));
+               unlock_kernel();
                return -EINVAL;
        }
        eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
@@ -539,12 +542,14 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
                               GFP_KERNEL);
         if (!eerb->buffer) {
                kfree(eerb);
+               unlock_kernel();
                 return -ENOMEM;
        }
        if (dasd_eer_allocate_buffer_pages(eerb->buffer,
                                           eerb->buffer_page_count)) {
                kfree(eerb->buffer);
                kfree(eerb);
+               unlock_kernel();
                return -ENOMEM;
        }
        filp->private_data = eerb;
@@ -552,6 +557,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
        list_add(&eerb->list, &bufferlist);
        spin_unlock_irqrestore(&bufferlock, flags);
 
+       unlock_kernel();
        return nonseekable_open(inp,filp);
 }
 
index ef36f2132aa43fb994ee878a46022f5776c64ed0..b5ecd59676c4a3fce494da28c5c4197b4d4e84f3 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/types.h>
+#include <linux/smp_lock.h>
 
 #include <asm/ccwdev.h>
 #include <asm/cio.h>
@@ -421,6 +422,7 @@ fs3270_open(struct inode *inode, struct file *filp)
 
        if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
                return -ENODEV;
+       lock_kernel();
        minor = iminor(filp->f_path.dentry->d_inode);
        /* Check for minor 0 multiplexer. */
        if (minor == 0) {
@@ -429,7 +431,8 @@ fs3270_open(struct inode *inode, struct file *filp)
                tty = get_current_tty();
                if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) {
                        mutex_unlock(&tty_mutex);
-                       return -ENODEV;
+                       rc = -ENODEV;
+                       goto out;
                }
                minor = tty->index + RAW3270_FIRSTMINOR;
                mutex_unlock(&tty_mutex);
@@ -438,19 +441,22 @@ fs3270_open(struct inode *inode, struct file *filp)
        fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
        if (!IS_ERR(fp)) {
                raw3270_put_view(&fp->view);
-               return -EBUSY;
+               rc = -EBUSY;
+               goto out;
        }
        /* Allocate fullscreen view structure. */
        fp = fs3270_alloc_view();
-       if (IS_ERR(fp))
-               return PTR_ERR(fp);
+       if (IS_ERR(fp)) {
+               rc = PTR_ERR(fp);
+               goto out;
+       }
 
        init_waitqueue_head(&fp->wait);
        fp->fs_pid = get_pid(task_pid(current));
        rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
        if (rc) {
                fs3270_free_view(&fp->view);
-               return rc;
+               goto out;
        }
 
        /* Allocate idal-buffer. */
@@ -458,7 +464,8 @@ fs3270_open(struct inode *inode, struct file *filp)
        if (IS_ERR(ib)) {
                raw3270_put_view(&fp->view);
                raw3270_del_view(&fp->view);
-               return PTR_ERR(fp);
+               rc = PTR_ERR(fp);
+               goto out;
        }
        fp->rdbuf = ib;
 
@@ -466,9 +473,11 @@ fs3270_open(struct inode *inode, struct file *filp)
        if (rc) {
                raw3270_put_view(&fp->view);
                raw3270_del_view(&fp->view);
-               return rc;
+               goto out;
        }
        filp->private_data = fp;
+out:
+       unlock_kernel();
        return 0;
 }
 
index 1e1f50655bbfb8f01a4896dd830a09ff23f98f99..dc4710e64e0c61134aa1766bf755aecfc7425541 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -340,6 +341,7 @@ static int mon_open(struct inode *inode, struct file *filp)
        /*
         * only one user allowed
         */
+       lock_kernel();
        rc = -EBUSY;
        if (test_and_set_bit(MON_IN_USE, &mon_in_use))
                goto out;
@@ -377,6 +379,7 @@ static int mon_open(struct inode *inode, struct file *filp)
        }
        P_INFO("open, established connection to *MONITOR service\n\n");
        filp->private_data = monpriv;
+       unlock_kernel();
        return nonseekable_open(inode, filp);
 
 out_path:
@@ -386,6 +389,7 @@ out_priv:
 out_use:
        clear_bit(MON_IN_USE, &mon_in_use);
 out:
+       unlock_kernel();
        return rc;
 }
 
index a86c0534cd49f337dbceb8ef2dab3ac2e0115688..4d71aa8c1a7956928e1354cd82f56a70d145c1e2 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/errno.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
@@ -179,10 +180,12 @@ static int monwrite_open(struct inode *inode, struct file *filp)
        monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
        if (!monpriv)
                return -ENOMEM;
+       lock_kernel();
        INIT_LIST_HEAD(&monpriv->list);
        monpriv->hdr_to_read = sizeof(monpriv->hdr);
        mutex_init(&monpriv->thread_mutex);
        filp->private_data = monpriv;
+       unlock_kernel();
        return nonseekable_open(inode, filp);
 }
 
index ebe84067bae928bddf9b9770e8eb994a9f6ceb76..687720b552d1c460019c8aa40a758294538195dd 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/mtio.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -289,21 +290,26 @@ tapechar_open (struct inode *inode, struct file *filp)
        if (imajor(filp->f_path.dentry->d_inode) != tapechar_major)
                return -ENODEV;
 
+       lock_kernel();
        minor = iminor(filp->f_path.dentry->d_inode);
        device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
        if (IS_ERR(device)) {
                DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n");
-               return PTR_ERR(device);
+               rc = PTR_ERR(device);
+               goto out;
        }
 
 
        rc = tape_open(device);
        if (rc == 0) {
                filp->private_data = device;
-               return nonseekable_open(inode, filp);
+               rc = nonseekable_open(inode, filp);
        }
-       tape_put_device(device);
+       else
+               tape_put_device(device);
 
+out:
+       unlock_kernel();
        return rc;
 }
 
index 2f419b0ea628bf1dd47ca0385f54f95bbf808235..bf3dc6e0e33af13f1468dfe3fe26e89b67d13dff 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
 #include <asm/uaccess.h>
@@ -39,11 +40,14 @@ static int vmcp_open(struct inode *inode, struct file *file)
        session = kmalloc(sizeof(*session), GFP_KERNEL);
        if (!session)
                return -ENOMEM;
+
+       lock_kernel();
        session->bufsize = PAGE_SIZE;
        session->response = NULL;
        session->resp_size = 0;
        mutex_init(&session->mutex);
        file->private_data = session;
+       unlock_kernel();
        return nonseekable_open(inode, file);
 }
 
index 2c2428cc05d866efe26b9c288331ab6459afdeb0..6f852fdb6d705432a02394b9ed735c4a22e59d37 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kmod.h>
 #include <linux/cdev.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 
 
@@ -319,9 +320,11 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
                return -ENOSYS;
 
        /* Besure this device hasn't already been opened */
+       lock_kernel();
        spin_lock_bh(&logptr->priv_lock);
        if (logptr->dev_in_use) {
                spin_unlock_bh(&logptr->priv_lock);
+               unlock_kernel();
                return -EBUSY;
        }
        logptr->dev_in_use = 1;
@@ -365,7 +368,9 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
                   || (logptr->iucv_path_severed));
        if (logptr->iucv_path_severed)
                goto out_record;
-       return nonseekable_open(inode, filp);
+       ret = nonseekable_open(inode, filp);
+       unlock_kernel();
+       return ret;
 
 out_record:
        if (logptr->autorecording)
@@ -375,6 +380,7 @@ out_path:
        logptr->path = NULL;
 out_dev:
        logptr->dev_in_use = 0;
+       unlock_kernel();
        return -EIO;
 }
 
index 83ae9a852f00c2dc5c4e2fc9be7eb81e974770de..61549987ed70b0b6967923639b3230ee8332d465 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/cdev.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/cio.h>
@@ -668,7 +669,7 @@ static int ur_open(struct inode *inode, struct file *file)
 
        if (accmode == O_RDWR)
                return -EACCES;
-
+       lock_kernel();
        /*
         * We treat the minor number as the devno of the ur device
         * to find in the driver tree.
@@ -676,8 +677,10 @@ static int ur_open(struct inode *inode, struct file *file)
        devno = MINOR(file->f_dentry->d_inode->i_rdev);
 
        urd = urdev_get_from_devno(devno);
-       if (!urd)
-               return -ENXIO;
+       if (!urd) {
+               rc = -ENXIO;
+               goto out;
+       }
 
        spin_lock(&urd->open_lock);
        while (urd->open_flag) {
@@ -720,6 +723,7 @@ static int ur_open(struct inode *inode, struct file *file)
                goto fail_urfile_free;
        urf->file_reclen = rc;
        file->private_data = urf;
+       unlock_kernel();
        return 0;
 
 fail_urfile_free:
@@ -730,6 +734,8 @@ fail_unlock:
        spin_unlock(&urd->open_lock);
 fail_put:
        urdev_put(urd);
+out:
+       unlock_kernel();
        return rc;
 }
 
index 19f8389291b62c3f13b76eafde98ae03f1677666..ee80e936d5145e142bf0baa9d7519168b8c2a5c2 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/watchdog.h>
+#include <linux/smp_lock.h>
 
 #include <asm/ebcdic.h>
 #include <asm/io.h>
@@ -131,11 +132,15 @@ static int __init vmwdt_probe(void)
 static int vmwdt_open(struct inode *i, struct file *f)
 {
        int ret;
-       if (test_and_set_bit(0, &vmwdt_is_open))
+       lock_kernel();
+       if (test_and_set_bit(0, &vmwdt_is_open)) {
+               unlock_kernel();
                return -EBUSY;
+       }
        ret = vmwdt_keepalive();
        if (ret)
                clear_bit(0, &vmwdt_is_open);
+       unlock_kernel();
        return ret ? ret : nonseekable_open(i, f);
 }
 
index 4d36e805a2348b40995c76625986559f735c5978..e41c2fa86d8b4455fd19c82c4034cc00a44012fe 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/compat.h>
+#include <linux/smp_lock.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 #include <linux/hw_random.h>
@@ -300,7 +301,9 @@ static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
  */
 static int zcrypt_open(struct inode *inode, struct file *filp)
 {
+       lock_kernel();
        atomic_inc(&zcrypt_open_count);
+       unlock_kernel();
        return 0;
 }
 
index 03c966059471d12938f41ddf876f97a22d1343b4..bba21e053a1bfd4d237ec873efa1ef74acc655a1 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/timer.h>
 #include <linux/ioport.h>
 #include <linux/major.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -429,6 +430,7 @@ static int bpp_open(struct inode *inode, struct file *f)
       unsigned minor = iminor(inode);
       int ret;
 
+      lock_kernel();
       spin_lock(&bpp_open_lock);
       ret = 0;
       if (minor >= BPP_NO) {
@@ -444,6 +446,7 @@ static int bpp_open(struct inode *inode, struct file *f)
              }
       }
       spin_unlock(&bpp_open_lock);
+      unlock_kernel();
 
       return ret;
 }
index 235703414370b8aac9329e783319dc92f49b7546..23abfdfb44f1c113b2ddd86cc0c0bd9e747e60cc 100644 (file)
@@ -279,6 +279,7 @@ static inline int wd_opt_timeout(void)
 
 static int wd_open(struct inode *inode, struct file *f)
 {
+       lock_kernel();
        switch(iminor(inode))
        {
                case WD0_MINOR:
@@ -291,6 +292,7 @@ static int wd_open(struct inode *inode, struct file *f)
                        f->private_data = &wd_dev.watchdog[WD2_ID];
                        break;
                default:
+                       unlock_kernel();
                        return(-ENODEV);
        }
 
@@ -304,11 +306,13 @@ static int wd_open(struct inode *inode, struct file *f)
                                                (void *)wd_dev.regs)) {
                        printk("%s: Cannot register IRQ %d\n", 
                                WD_OBPNAME, wd_dev.irq);
+                       unlock_kernel();
                        return(-EBUSY);
                }
                wd_dev.initialized = 1;
        }
 
+       unlock_kernel();
        return(nonseekable_open(inode, f));
 }
 
index 3279a1b6501d6b2f5c108ecfbc73c91bd293f0f6..d8f5c0ca236d7f21b14a21a9b73e1b4483d3984b 100644 (file)
@@ -94,6 +94,7 @@ static int d7s_open(struct inode *inode, struct file *f)
 {
        if (D7S_MINOR != iminor(inode))
                return -ENODEV;
+       cycle_kernel_lock();
        atomic_inc(&d7s_users);
        return 0;
 }
index dadabef116b60ea75d935b37254ca53eeff2e09a..a408402426f853bf78a21406c975fbf484c0ca8a 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/miscdevice.h>
 #include <linux/kmod.h>
 #include <linux/reboot.h>
+#include <linux/smp_lock.h>
 
 #include <asm/ebus.h>
 #include <asm/uaccess.h>
@@ -694,6 +695,7 @@ envctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static int
 envctrl_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        file->private_data = NULL;
        return 0;
 }
index 44e039865aa99714d4184e033a2d5bce65d94532..7d95e151513a0a5446e07ef6da24d9605334af53 100644 (file)
@@ -127,9 +127,13 @@ flash_read(struct file * file, char __user * buf,
 static int
 flash_open(struct inode *inode, struct file *file)
 {
-       if (test_and_set_bit(0, (void *)&flash.busy) != 0)
+       lock_kernel();
+       if (test_and_set_bit(0, (void *)&flash.busy) != 0) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
+       unlock_kernel();
        return 0;
 }
 
index 4b7079fdc10c8cfa322083894f0d3fdf28e534a2..2bec9ccc02938d25ae9b366ad4c05e1889fe52c5 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -417,11 +418,17 @@ static int jsf_mmap(struct file * file, struct vm_area_struct * vma)
 
 static int jsf_open(struct inode * inode, struct file * filp)
 {
-
-       if (jsf0.base == 0) return -ENXIO;
-       if (test_and_set_bit(0, (void *)&jsf0.busy) != 0)
+       lock_kernel();
+       if (jsf0.base == 0) {
+               unlock_kernel();
+               return -ENXIO;
+       }
+       if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
+       unlock_kernel();
        return 0;       /* XXX What security? */
 }
 
index fbfeb89a6f32d148abbbe9b9c0137d5a7f0fdb10..29dc735e1a20503a69968714c16a43428f1ff7cd 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/miscdevice.h>
 #include <linux/init.h>
@@ -689,9 +690,11 @@ static int openprom_open(struct inode * inode, struct file * file)
        if (!data)
                return -ENOMEM;
 
+       lock_kernel();
        data->current_node = of_find_node_by_path("/");
        data->lastnode = data->current_node;
        file->private_data = (void *) data;
+       unlock_kernel();
 
        return 0;
 }
index a2fc6b8c1334a830dc2808cdc32b8beefd42fbe2..88c0fc6395e140acae5f610cd3126d6449af1572 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 
 #include <asm/io.h>
 #include <asm/ebus.h>
@@ -116,6 +117,7 @@ static void riowd_starttimer(void)
 
 static int riowd_open(struct inode *inode, struct file *filp)
 {
+       cycle_kernel_lock();
        nonseekable_open(inode, filp);
        return 0;
 }
index 18d18f1a114ec9cdf8d4443bb236d0cb9b8e0208..b0429917154da55c4f6cfea7abda0366718ac8af 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -213,6 +214,7 @@ static int rtc_open(struct inode *inode, struct file *file)
 {
        int ret;
 
+       lock_kernel();
        spin_lock_irq(&mostek_lock);
        if (rtc_busy) {
                ret = -EBUSY;
@@ -221,6 +223,7 @@ static int rtc_open(struct inode *inode, struct file *file)
                ret = 0;
        }
        spin_unlock_irq(&mostek_lock);
+       unlock_kernel();
 
        return ret;
 }
index 383f32c1d347c33b9ed63bf9e479b8ae237a94e7..513ba61ae966b53e0edc20bf6501a018ac79be6e 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
@@ -211,8 +212,10 @@ uctrl_ioctl(struct inode *inode, struct file *file,
 static int
 uctrl_open(struct inode *inode, struct file *file)
 {
+       lock_kernel();
        uctrl_get_event_status();
        uctrl_get_external_status();
+       unlock_kernel();
        return 0;
 }
 
index d4f8fcded51d8615e1da7cd5996ac715b0defd9e..1f6cb8ae2784cddaf76aa949033381b271126037 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
@@ -178,14 +179,17 @@ static int vfc_open(struct inode *inode, struct file *file)
 {
        struct vfc_dev *dev;
 
+       lock_kernel();
        spin_lock(&vfc_dev_lock);
        dev = vfc_get_dev_ptr(iminor(inode));
        if (dev == NULL) {
                spin_unlock(&vfc_dev_lock);
+               unlock_kernel();
                return -ENODEV;
        }
        if (dev->busy) {
                spin_unlock(&vfc_dev_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
@@ -202,6 +206,7 @@ static int vfc_open(struct inode *inode, struct file *file)
        vfc_captstat_reset(dev);
        
        vfc_unlock_device(dev);
+       unlock_kernel();
        return 0;
 }
 
index 867f6fd5c2c019e51e310e7cb04de44e098f00d3..7045511f9ad2be543f9c4d5940b67d9a28bb0a09 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,11 +863,13 @@ out:
 } /* End twa_chrdev_ioctl() */
 
 /* This function handles open for the character device */
+/* 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 8c22329aa85e1585035127185c0597cb51a95827..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,10 +1028,12 @@ out:
 } /* End tw_chrdev_ioctl() */
 
 /* This function handles open for the character device */
+/* 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 1f7c83607f84729a918c640e83a67daf9e45643e..68c140e826735287f007f91da091de3e17899a48 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/syscalls.h>
 #include <linux/delay.h>
@@ -667,6 +668,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
        unsigned minor_number = iminor(inode);
        int err = -ENODEV;
 
+       lock_kernel();  /* BKL pushdown: nothing else protects this list */
        list_for_each_entry(aac, &aac_devices, entry) {
                if (aac->id == minor_number) {
                        file->private_data = aac;
@@ -674,6 +676,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
                        break;
                }
        }
+       unlock_kernel();
 
        return err;
 }
index c4b938bc30d393f92eebaaf9c506009885f50176..aa2011b6468387609993e2ab7643b8e40740c403 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/chio.h>                        /* here are all the ioctls */
 #include <linux/mutex.h>
 #include <linux/idr.h>
+#include <linux/smp_lock.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -571,16 +572,19 @@ ch_open(struct inode *inode, struct file *file)
        scsi_changer *ch;
        int minor = iminor(inode);
 
+       lock_kernel();
        spin_lock(&ch_index_lock);
        ch = idr_find(&ch_index_idr, minor);
 
        if (NULL == ch || scsi_device_get(ch->device)) {
                spin_unlock(&ch_index_lock);
+               unlock_kernel();
                return -ENXIO;
        }
        spin_unlock(&ch_index_lock);
 
        file->private_data = ch;
+       unlock_kernel();
        return 0;
 }
 
index 8508816f303d08144fb8377da3c5c780ae7c5a9e..2bc30e32b67a691823568025e802c52cd3f27a7a 100644 (file)
@@ -49,6 +49,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
 #include <linux/kernel.h>      /* for printk */
 #include <linux/sched.h>
 #include <linux/reboot.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/dma-mapping.h>
 
@@ -1727,10 +1728,12 @@ static int adpt_open(struct inode *inode, struct file *file)
        int minor;
        adpt_hba* pHba;
 
+       lock_kernel();
        //TODO check for root access
        //
        minor = iminor(inode);
        if (minor >= hba_count) {
+               unlock_kernel();
                return -ENXIO;
        }
        mutex_lock(&adpt_configuration_lock);
@@ -1741,6 +1744,7 @@ static int adpt_open(struct inode *inode, struct file *file)
        }
        if (pHba == NULL) {
                mutex_unlock(&adpt_configuration_lock);
+               unlock_kernel();
                return -ENXIO;
        }
 
@@ -1751,6 +1755,7 @@ static int adpt_open(struct inode *inode, struct file *file)
 
        pHba->in_use = 1;
        mutex_unlock(&adpt_configuration_lock);
+       unlock_kernel();
 
        return 0;
 }
index 46771d4c81bdcd8abeb8bad9b81bdd6430f5dfff..822d5214692bfe3663b5acb8987ffec5a0ec0cd5 100644 (file)
 #include <linux/timer.h>
 #include <linux/dma-mapping.h>
 #include <linux/list.h>
+#include <linux/smp_lock.h>
 
 #ifdef GDTH_RTC
 #include <linux/mc146818rtc.h>
@@ -4019,10 +4020,12 @@ static int gdth_open(struct inode *inode, struct file *filep)
 {
     gdth_ha_str *ha;
 
+    lock_kernel();
     list_for_each_entry(ha, &gdth_instances, list) {
         if (!ha->sdev)
             ha->sdev = scsi_get_host_dev(ha->shost);
     }
+    unlock_kernel();
 
     TRACE(("gdth_open()\n"));
     return 0;
index 18551aaf5e094e07612ddf028df0dc7f2a05d344..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"
@@ -3272,12 +3273,12 @@ mega_init_scb(adapter_t *adapter)
  * @filep - unused
  *
  * Routines for the character/ioctl interface to the driver. Find out if this
- * is a valid open. If yes, increment the module use count so that it cannot
- * be unloaded.
+ * is a valid open. 
  */
 static int
 megadev_open (struct inode *inode, struct file *filep)
 {
+       cycle_kernel_lock();
        /*
         * Only allow superuser to access private ioctl interface
         */
index 0ad215e27b83358a55f61f9b8a5b00f6e4f6b154..ac3b280c2a72abb7a310834b4ae45a924327db32 100644 (file)
@@ -15,6 +15,7 @@
  * Common management module
  */
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include "megaraid_mm.h"
 
 
@@ -96,6 +97,7 @@ mraid_mm_open(struct inode *inode, struct file *filep)
         */
        if (!capable(CAP_SYS_ADMIN)) return (-EACCES);
 
+       cycle_kernel_lock();
        return 0;
 }
 
index 7d84c8bbcf3fc1a55b8a9c04cbc65e2e05b33902..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>
@@ -2863,6 +2864,7 @@ static void megasas_shutdown(struct pci_dev *pdev)
  */
 static int megasas_mgmt_open(struct inode *inode, struct file *filep)
 {
+       cycle_kernel_lock();
        /*
         * Allow only those users with admin rights
         */
index 243d8becd30fbb9047b49b29a89a2bcb5167c1e1..1c79f9794f4e82bf1e5f30da63bda2b9ace3418b 100644 (file)
@@ -50,6 +50,7 @@ static const char * osst_version = "0.99.4";
 #include <linux/moduleparam.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -4359,7 +4360,7 @@ os_bypass:
 
 
 /* Open the device */
-static int os_scsi_tape_open(struct inode * inode, struct file * filp)
+static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 {
        unsigned short        flags;
        int                   i, b_size, new_session = 0, retval = 0;
@@ -4725,6 +4726,18 @@ err_out:
        return retval;
 }
 
+/* BKL pushdown: spaghetti avoidance wrapper */
+static int os_scsi_tape_open(struct inode * inode, struct file * filp)
+{
+       int ret;
+
+       lock_kernel();
+       ret = __os_scsi_tape_open(inode, filp);
+       unlock_kernel();
+       return ret;
+}
+
+
 
 /* Flush the tape buffer before close */
 static int os_scsi_tape_flush(struct file * filp, fl_owner_t id)
index d2557dbc2dc156014b011609408b32d7dfcd70fc..0e9533f7aabc4bcd38befa28c1727db45cd41a1e 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include <linux/miscdevice.h>
 #include <linux/file.h>
+#include <linux/smp_lock.h>
 #include <net/tcp.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -321,6 +322,7 @@ static int tgt_open(struct inode *inode, struct file *file)
 {
        tx_ring.tr_idx = rx_ring.tr_idx = 0;
 
+       cycle_kernel_lock();
        return 0;
 }
 
index ea0edd1b2e76692ce520a56bbcc5d62666f75fff..cee1e4c6d83cb16bc769e028e9c47189b695adb9 100644 (file)
@@ -49,6 +49,7 @@ static int sg_version_num = 30534;    /* 2 digits for each component */
 #include <linux/delay.h>
 #include <linux/scatterlist.h>
 #include <linux/blktrace_api.h>
+#include <linux/smp_lock.h>
 
 #include "scsi.h"
 #include <scsi/scsi_dbg.h>
@@ -227,19 +228,26 @@ sg_open(struct inode *inode, struct file *filp)
        int res;
        int retval;
 
+       lock_kernel();
        nonseekable_open(inode, filp);
        SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags));
        sdp = sg_get_dev(dev);
-       if ((!sdp) || (!sdp->device))
+       if ((!sdp) || (!sdp->device)) {
+               unlock_kernel();
                return -ENXIO;
-       if (sdp->detached)
+       }
+       if (sdp->detached) {
+               unlock_kernel();
                return -ENODEV;
+       }
 
        /* This driver's module count bumped by fops_get in <linux/fs.h> */
        /* Prevent the device driver from vanishing while we sleep */
        retval = scsi_device_get(sdp->device);
-       if (retval)
+       if (retval) {
+               unlock_kernel();
                return retval;
+       }
 
        if (!((flags & O_NONBLOCK) ||
              scsi_block_when_processing_errors(sdp->device))) {
@@ -295,10 +303,12 @@ sg_open(struct inode *inode, struct file *filp)
                retval = -ENOMEM;
                goto error_out;
        }
+       unlock_kernel();
        return 0;
 
       error_out:
        scsi_device_put(sdp->device);
+       unlock_kernel();
        return retval;
 }
 
index 6e5a5bb3131150012d24c3a8ac0fab668af289ef..4684cc716aa4033575b7738ded7ca3196cadd850 100644 (file)
@@ -38,6 +38,7 @@ static const char *verstr = "20080224";
 #include <linux/cdev.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 #include <asm/dma.h>
@@ -1113,7 +1114,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
 }
 
 
-\f/* Open the device. Needs to be called with BKL only because of incrementing the SCSI host
+\f/* Open the device. Needs to take the BKL only because of incrementing the SCSI host
    module count. */
 static int st_open(struct inode *inode, struct file *filp)
 {
@@ -1123,6 +1124,7 @@ static int st_open(struct inode *inode, struct file *filp)
        int dev = TAPE_NR(inode);
        char *name;
 
+       lock_kernel();
        /*
         * We really want to do nonseekable_open(inode, filp); here, but some
         * versions of tar incorrectly call lseek on tapes and bail out if that
@@ -1130,8 +1132,10 @@ static int st_open(struct inode *inode, struct file *filp)
         */
        filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
 
-       if (!(STp = scsi_tape_get(dev)))
+       if (!(STp = scsi_tape_get(dev))) {
+               unlock_kernel();
                return -ENXIO;
+       }
 
        write_lock(&st_dev_arr_lock);
        filp->private_data = STp;
@@ -1140,6 +1144,7 @@ static int st_open(struct inode *inode, struct file *filp)
        if (STp->in_use) {
                write_unlock(&st_dev_arr_lock);
                scsi_tape_put(STp);
+               unlock_kernel();
                DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
                return (-EBUSY);
        }
@@ -1188,12 +1193,14 @@ static int st_open(struct inode *inode, struct file *filp)
                        retval = (-EIO);
                goto err_out;
        }
+       unlock_kernel();
        return 0;
 
  err_out:
        normalize_buffer(STp->buffer);
        STp->in_use = 0;
        scsi_tape_put(STp);
+       unlock_kernel();
        return retval;
 
 }
index f5b60c70389b771bc752be6178ed38cfed2730f9..ddbe1a5e970e1b017b46e629100af8848c292427 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/errno.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spidev.h>
@@ -464,6 +465,7 @@ static int spidev_open(struct inode *inode, struct file *filp)
        struct spidev_data      *spidev;
        int                     status = -ENXIO;
 
+       lock_kernel();
        mutex_lock(&device_list_lock);
 
        list_for_each_entry(spidev, &device_list, device_entry) {
@@ -489,6 +491,7 @@ static int spidev_open(struct inode *inode, struct file *filp)
                pr_debug("spidev: nothing for minor %d\n", iminor(inode));
 
        mutex_unlock(&device_list_lock);
+       unlock_kernel();
        return status;
 }
 
index bcea8d9b718ce782da7f1e3fdb20d4d278d9d00e..4d74ba36c3a12b0d8acd19cd7115b154522f862b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/errno.h>
 #include <linux/phonedev.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
@@ -53,6 +54,7 @@ static int phone_open(struct inode *inode, struct file *file)
        if (minor >= PHONE_NUM_DEVICES)
                return -ENODEV;
 
+       lock_kernel();
        mutex_lock(&phone_lock);
        p = phone_device[minor];
        if (p)
@@ -79,6 +81,7 @@ static int phone_open(struct inode *inode, struct file *file)
        fops_put(old_fops);
 end:
        mutex_unlock(&phone_lock);
+       unlock_kernel();
        return err;
 }
 
index 0a12e90ad41640d15c584cfd313fa9746563c2b3..5a7ca2e6094dc4d2ea0f6fb95f2315b11373be13 100644 (file)
@@ -297,12 +297,17 @@ static int uio_open(struct inode *inode, struct file *filep)
        struct uio_listener *listener;
        int ret = 0;
 
+       lock_kernel();
        idev = idr_find(&uio_idr, iminor(inode));
-       if (!idev)
-               return -ENODEV;
+       if (!idev) {
+               ret = -ENODEV;
+               goto out;
+       }
 
-       if (!try_module_get(idev->owner))
-               return -ENODEV;
+       if (!try_module_get(idev->owner)) {
+               ret = -ENODEV;
+               goto out;
+       }
 
        listener = kmalloc(sizeof(*listener), GFP_KERNEL);
        if (!listener) {
@@ -319,7 +324,7 @@ static int uio_open(struct inode *inode, struct file *filep)
                if (ret)
                        goto err_infoopen;
        }
-
+       unlock_kernel();
        return 0;
 
 err_infoopen:
@@ -329,6 +334,8 @@ err_alloc_listener:
 
        module_put(idev->owner);
 
+out:
+       unlock_kernel();
        return ret;
 }
 
index de17738f3acbab5c69066a81a31b041d25c5bf38..9218cca210431dea3b840e85b4fa9a0f0653a3fd 100644 (file)
@@ -565,6 +565,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
        struct dev_state *ps;
        int ret;
 
+       lock_kernel();
        /* Protect against simultaneous removal or release */
        mutex_lock(&usbfs_mutex);
 
@@ -611,6 +612,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
        if (ret)
                kfree(ps);
        mutex_unlock(&usbfs_mutex);
+       unlock_kernel();
        return ret;
 }
 
index 8133c99c6c5caf7cb1f384c71360f15e6c4fbf54..c6a95395e52a29f19a4a8d53045bb458a5f8001d 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/rwsem.h>
+#include <linux/smp_lock.h>
 #include <linux/usb.h>
 
 #include "usb.h"
@@ -33,6 +34,7 @@ static int usb_open(struct inode * inode, struct file * file)
        int err = -ENODEV;
        const struct file_operations *old_fops, *new_fops = NULL;
 
+       lock_kernel();
        down_read(&minor_rwsem);
        c = usb_minors[minor];
 
@@ -51,6 +53,7 @@ static int usb_open(struct inode * inode, struct file * file)
        fops_put(old_fops);
  done:
        up_read(&minor_rwsem);
+       unlock_kernel();
        return err;
 }
 
index 76be75e3ab8fe4a051240b8c37e7f15c8558edba..ec8f2eb041ca97b258e4ae3a45700b0305f6caf1 100644 (file)
@@ -462,6 +462,7 @@ printer_open(struct inode *inode, struct file *fd)
        unsigned long           flags;
        int                     ret = -EBUSY;
 
+       lock_kernel();
        dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev);
 
        spin_lock_irqsave(&dev->lock, flags);
@@ -477,7 +478,7 @@ printer_open(struct inode *inode, struct file *fd)
        spin_unlock_irqrestore(&dev->lock, flags);
 
        DBG(dev, "printer_open returned %x\n", ret);
-
+       unlock_kernel();
        return ret;
 }
 
index 49145534e06ee5c92ed41934429942e3e34e819a..293a46247c3b3bc8e4c731ca45fac0493d526778 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/poll.h>
 #include <linux/compat.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -527,14 +528,17 @@ static int mon_bin_open(struct inode *inode, struct file *file)
        size_t size;
        int rc;
 
+       lock_kernel();
        mutex_lock(&mon_lock);
        if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) {
                mutex_unlock(&mon_lock);
+               unlock_kernel();
                return -ENODEV;
        }
        if (mbus != &mon_bus0 && mbus->u_bus == NULL) {
                printk(KERN_ERR TAG ": consistency error on open\n");
                mutex_unlock(&mon_lock);
+               unlock_kernel();
                return -ENODEV;
        }
 
@@ -568,6 +572,7 @@ static int mon_bin_open(struct inode *inode, struct file *file)
 
        file->private_data = rp;
        mutex_unlock(&mon_lock);
+       unlock_kernel();
        return 0;
 
 err_allocbuff:
@@ -576,6 +581,7 @@ err_allocvec:
        kfree(rp);
 err_alloc:
        mutex_unlock(&mon_lock);
+       unlock_kernel();
        return rc;
 }
 
index 776f7fcd2fbf4f508a0bb72398391aeb8f5a32d0..33ebdb198dafbf5776ff5a5ac4a39c35fecf1464 100644 (file)
@@ -1326,20 +1326,27 @@ fb_open(struct inode *inode, struct file *file)
 
        if (fbidx >= FB_MAX)
                return -ENODEV;
+       lock_kernel();
 #ifdef CONFIG_KMOD
        if (!(info = registered_fb[fbidx]))
                try_to_load(fbidx);
 #endif /* CONFIG_KMOD */
-       if (!(info = registered_fb[fbidx]))
-               return -ENODEV;
-       if (!try_module_get(info->fbops->owner))
-               return -ENODEV;
+       if (!(info = registered_fb[fbidx])) {
+               res = -ENODEV;
+               goto out;
+       }
+       if (!try_module_get(info->fbops->owner)) {
+               res = -ENODEV;
+               goto out;
+       }
        file->private_data = info;
        if (info->fbops->fb_open) {
                res = info->fbops->fb_open(info,1);
                if (res)
                        module_put(info->fbops->owner);
        }
+out:
+       unlock_kernel();
        return res;
 }
 
index 68e510b88457e85d8831aa0b48a0479c137d3cb3..3cb7cda3d780e95026142398f4c52cdf565d93b6 100644 (file)
@@ -373,6 +373,8 @@ static int chrdev_open(struct inode *inode, struct file *filp)
                        return -ENXIO;
                new = container_of(kobj, struct cdev, kobj);
                spin_lock(&cdev_lock);
+               /* Check i_cdev again in case somebody beat us to it while
+                  we dropped the lock. */
                p = inode->i_cdev;
                if (!p) {
                        inode->i_cdev = p = new;
@@ -392,11 +394,8 @@ static int chrdev_open(struct inode *inode, struct file *filp)
                cdev_put(p);
                return -ENXIO;
        }
-       if (filp->f_op->open) {
-               lock_kernel();
+       if (filp->f_op->open)
                ret = filp->f_op->open(inode,filp);
-               unlock_kernel();
-       }
        if (ret)
                cdev_put(p);
        return ret;
index 86b4d5f405ae6f935a6bb22d5e90dd36ed9d225a..22857c639df55d59e13bd1ae01d70ee3153312a0 100644 (file)
@@ -612,7 +612,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
                if (retval < 0)
                        return (loff_t)retval;
        }
-       return remote_llseek(file, offset, origin);
+       return generic_file_llseek_unlocked(file, offset, origin);
 }
 
 struct file_system_type cifs_fs_type = {
index ebbcf38fd33b098143d04e0b575b7028905fd45e..f976f303c196284e2426167611325772c84d4cde 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/poll.h>
 #include <linux/signal.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/dlm.h>
 #include <linux/dlm_device.h>
 
@@ -618,13 +619,17 @@ static int device_open(struct inode *inode, struct file *file)
        struct dlm_user_proc *proc;
        struct dlm_ls *ls;
 
+       lock_kernel();
        ls = dlm_find_lockspace_device(iminor(inode));
-       if (!ls)
+       if (!ls) {
+               unlock_kernel();
                return -ENOENT;
+       }
 
        proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL);
        if (!proc) {
                dlm_put_lockspace(ls);
+               unlock_kernel();
                return -ENOMEM;
        }
 
@@ -636,6 +641,7 @@ static int device_open(struct inode *inode, struct file *file)
        spin_lock_init(&proc->locks_spin);
        init_waitqueue_head(&proc->wait);
        file->private_data = proc;
+       unlock_kernel();
 
        return 0;
 }
@@ -870,6 +876,7 @@ static unsigned int device_poll(struct file *file, poll_table *wait)
 
 static int ctl_device_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        file->private_data = NULL;
        return 0;
 }
index 2258b8f654a62ff7f45e6df55cd3a501d1c5dc25..24749bf0668f0c8d82a887e2b857c347a86a40f5 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/security.h>
 #include <linux/compat.h>
 #include <linux/fs_stack.h>
+#include <linux/smp_lock.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -277,9 +278,11 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag)
        int rc = 0;
        struct file *lower_file = NULL;
 
+       lock_kernel();
        lower_file = ecryptfs_file_to_lower(file);
        if (lower_file->f_op && lower_file->f_op->fasync)
                rc = lower_file->f_op->fasync(fd, lower_file, flag);
+       unlock_kernel();
        return rc;
 }
 
index fda25479af26720690969dde01f444d8bc730f07..3a9ecac8d61f081e295655822d311dc27f51f02f 100644 (file)
@@ -61,7 +61,7 @@ void fat_cache_destroy(void)
 
 static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
 {
-       return kmem_cache_alloc(fat_cache_cachep, GFP_KERNEL);
+       return kmem_cache_alloc(fat_cache_cachep, GFP_NOFS);
 }
 
 static inline void fat_cache_free(struct fat_cache *cache)
index 486725ee99ae68a977bc9ca2d8e8cd47990ed579..34541d06e6263b1817d96ee4d640f2cc8aa35eb7 100644 (file)
@@ -472,7 +472,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
        loff_t cpos;
        int ret = 0;
 
-       lock_kernel();
+       lock_super(sb);
 
        cpos = filp->f_pos;
        /* Fake . and .. for the root directory. */
@@ -654,7 +654,7 @@ FillFailed:
        if (unicode)
                __putname(unicode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        return ret;
 }
 
index 771326b8047e0ff5e3483f885c1edc30a604471a..c672df4036e94cc59aed3c1c59b4fdeb8882fe7a 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/mount.h>
 #include <linux/time.h>
 #include <linux/msdos_fs.h>
-#include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
@@ -242,9 +241,7 @@ void fat_truncate(struct inode *inode)
 
        nr_clusters = (inode->i_size + (cluster_size - 1)) >> sbi->cluster_bits;
 
-       lock_kernel();
        fat_free(inode, nr_clusters);
-       unlock_kernel();
        fat_flush_inodes(inode->i_sb, inode, NULL);
 }
 
@@ -310,8 +307,6 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
        int error = 0;
        unsigned int ia_valid;
 
-       lock_kernel();
-
        /*
         * Expand the file. Since inode_setattr() updates ->i_size
         * before calling the ->truncate(), but FAT needs to fill the
@@ -366,7 +361,6 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
 
        error = inode_setattr(inode, attr);
 out:
-       unlock_kernel();
        return error;
 }
 EXPORT_SYMBOL_GPL(fat_setattr);
index 4e0a3dd9d6779a1d9101704d470b1263b194d7d5..46a4508ffd2eba5cbf10be8122d60f721883f934 100644 (file)
@@ -440,14 +440,13 @@ static void fat_delete_inode(struct inode *inode)
 
 static void fat_clear_inode(struct inode *inode)
 {
-       struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+       struct super_block *sb = inode->i_sb;
+       struct msdos_sb_info *sbi = MSDOS_SB(sb);
 
-       lock_kernel();
        spin_lock(&sbi->inode_hash_lock);
        fat_cache_inval_inode(inode);
        hlist_del_init(&MSDOS_I(inode)->i_fat_hash);
        spin_unlock(&sbi->inode_hash_lock);
-       unlock_kernel();
 }
 
 static void fat_write_super(struct super_block *sb)
@@ -485,7 +484,7 @@ static struct kmem_cache *fat_inode_cachep;
 static struct inode *fat_alloc_inode(struct super_block *sb)
 {
        struct msdos_inode_info *ei;
-       ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL);
+       ei = kmem_cache_alloc(fat_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -567,7 +566,7 @@ retry:
        if (inode->i_ino == MSDOS_ROOT_INO || !i_pos)
                return 0;
 
-       lock_kernel();
+       lock_super(sb);
        bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits);
        if (!bh) {
                printk(KERN_ERR "FAT: unable to read inode block "
@@ -579,7 +578,7 @@ retry:
        if (i_pos != MSDOS_I(inode)->i_pos) {
                spin_unlock(&sbi->inode_hash_lock);
                brelse(bh);
-               unlock_kernel();
+               unlock_super(sb);
                goto retry;
        }
 
@@ -606,7 +605,7 @@ retry:
                err = sync_dirty_buffer(bh);
        brelse(bh);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        return err;
 }
 
@@ -736,6 +735,7 @@ fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable)
 
 static struct dentry *fat_get_parent(struct dentry *child)
 {
+       struct super_block *sb = child->d_sb;
        struct buffer_head *bh;
        struct msdos_dir_entry *de;
        loff_t i_pos;
@@ -743,14 +743,14 @@ static struct dentry *fat_get_parent(struct dentry *child)
        struct inode *inode;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = fat_get_dotdot_entry(child->d_inode, &bh, &de, &i_pos);
        if (err) {
                parent = ERR_PTR(err);
                goto out;
        }
-       inode = fat_build_inode(child->d_sb, de, i_pos);
+       inode = fat_build_inode(sb, de, i_pos);
        brelse(bh);
        if (IS_ERR(inode)) {
                parent = ERR_CAST(inode);
@@ -762,7 +762,7 @@ static struct dentry *fat_get_parent(struct dentry *child)
                parent = ERR_PTR(-ENOMEM);
        }
 out:
-       unlock_kernel();
+       unlock_super(sb);
 
        return parent;
 }
@@ -1172,6 +1172,12 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
        long error;
        char buf[50];
 
+       /*
+        * GFP_KERNEL is ok here, because while we do hold the
+        * supeblock lock, memory pressure can't call back into
+        * the filesystem, since we're only just about to mount
+        * it and have no inodes etc active!
+        */
        sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
index bfd776509a7271e324c5559397542c36c4564a34..330a7d7825915f591fa89ca74d8e63fa4efe07f4 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/fdtable.h>
 #include <linux/capability.h>
 #include <linux/dnotify.h>
-#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/security.h>
@@ -227,7 +226,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
        if (error)
                return error;
 
-       lock_kernel();
        if ((arg ^ filp->f_flags) & FASYNC) {
                if (filp->f_op && filp->f_op->fasync) {
                        error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
@@ -238,7 +236,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
 
        filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
  out:
-       unlock_kernel();
        return error;
 }
 
index e1b7d525a06613f83abb239478cd0d8b8e09bb18..24dd59450088bd9ca949dd9c9e8c4770bb6223fc 100644 (file)
@@ -62,11 +62,11 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
                error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
                                           &i_gh);
                if (!error) {
-                       error = remote_llseek(file, offset, origin);
+                       error = generic_file_llseek_unlocked(file, offset, origin);
                        gfs2_glock_dq_uninit(&i_gh);
                }
        } else
-               error = remote_llseek(file, offset, origin);
+               error = generic_file_llseek_unlocked(file, offset, origin);
 
        return error;
 }
index 05ff4f1d7026f4fbed45d09208c4b8cda3a0a72e..1f7f2956412ac9527be5867aa5c5bca8ecc81db6 100644 (file)
@@ -214,7 +214,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
 
        dentry->d_op = &msdos_dentry_operations;
 
-       lock_kernel();
+       lock_super(sb);
        res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
        if (res == -ENOENT)
                goto add;
@@ -232,7 +232,7 @@ add:
        if (dentry)
                dentry->d_op = &msdos_dentry_operations;
 out:
-       unlock_kernel();
+       unlock_super(sb);
        if (!res)
                return dentry;
        return ERR_PTR(res);
@@ -286,7 +286,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode,
        unsigned char msdos_name[MSDOS_NAME];
        int err, is_hid;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
                                msdos_name, &MSDOS_SB(sb)->options);
@@ -315,7 +315,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode,
 
        d_instantiate(dentry, inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        if (!err)
                err = fat_flush_inodes(sb, dir, inode);
        return err;
@@ -324,11 +324,12 @@ out:
 /***** Remove a directory */
 static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
 {
+       struct super_block *sb = dir->i_sb;
        struct inode *inode = dentry->d_inode;
        struct fat_slot_info sinfo;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
        /*
         * Check whether the directory is not in use, then check
         * whether it is empty.
@@ -349,9 +350,9 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
        inode->i_ctime = CURRENT_TIME_SEC;
        fat_detach(inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        if (!err)
-               err = fat_flush_inodes(inode->i_sb, dir, inode);
+               err = fat_flush_inodes(sb, dir, inode);
 
        return err;
 }
@@ -366,7 +367,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        struct timespec ts;
        int err, is_hid, cluster;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
                                msdos_name, &MSDOS_SB(sb)->options);
@@ -404,14 +405,14 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        d_instantiate(dentry, inode);
 
-       unlock_kernel();
+       unlock_super(sb);
        fat_flush_inodes(sb, dir, inode);
        return 0;
 
 out_free:
        fat_free_clusters(dir, cluster);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        return err;
 }
 
@@ -419,10 +420,11 @@ out:
 static int msdos_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct inode *inode = dentry->d_inode;
+       struct super_block *sb= inode->i_sb;
        struct fat_slot_info sinfo;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
        err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
        if (err)
                goto out;
@@ -434,9 +436,9 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
        inode->i_ctime = CURRENT_TIME_SEC;
        fat_detach(inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        if (!err)
-               err = fat_flush_inodes(inode->i_sb, dir, inode);
+               err = fat_flush_inodes(sb, dir, inode);
 
        return err;
 }
@@ -618,10 +620,11 @@ error_inode:
 static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry)
 {
+       struct super_block *sb = old_dir->i_sb;
        unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
        int err, is_hid;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = msdos_format_name(old_dentry->d_name.name,
                                old_dentry->d_name.len, old_msdos_name,
@@ -640,9 +643,9 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
        err = do_msdos_rename(old_dir, old_msdos_name, old_dentry,
                              new_dir, new_msdos_name, new_dentry, is_hid);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        if (!err)
-               err = fat_flush_inodes(old_dir->i_sb, old_dir, new_dir);
+               err = fat_flush_inodes(sb, old_dir, new_dir);
        return err;
 }
 
index 2b145de45b39147ce8e4ab9a53fd709c614050de..6a7d901f1936e555a530981c6fc6e53bab000f00 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 
 #include <linux/ncp_fs.h>
 #include "ncplib_kernel.h"
@@ -281,9 +282,18 @@ static int ncp_release(struct inode *inode, struct file *file) {
        return 0;
 }
 
+static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin)
+{
+       loff_t ret;
+       lock_kernel();
+       ret = generic_file_llseek_unlocked(file, offset, origin);
+       unlock_kernel();
+       return ret;
+}
+
 const struct file_operations ncp_file_operations =
 {
-       .llseek         = remote_llseek,
+       .llseek         = ncp_remote_llseek,
        .read           = ncp_file_read,
        .write          = ncp_file_write,
        .ioctl          = ncp_ioctl,
index d84a3d8f32af395f8109b58dcdd232fc3d0ddaa3..4e98a56a17776cc1ea484db0c5d24f9e2a7490a0 100644 (file)
@@ -170,6 +170,7 @@ force_reval:
 
 static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
 {
+       loff_t loff;
        /* origin == SEEK_END => we must revalidate the cached file length */
        if (origin == SEEK_END) {
                struct inode *inode = filp->f_mapping->host;
@@ -177,7 +178,10 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
                if (retval < 0)
                        return (loff_t)retval;
        }
-       return remote_llseek(filp, offset, origin);
+       lock_kernel();  /* BKL needed? */
+       loff = generic_file_llseek_unlocked(filp, offset, origin);
+       unlock_kernel();
+       return loff;
 }
 
 /*
index c021280dd462bc1303b89fd5d1806c8cf994d528..bd7e0f3acfc77901135ef24bea97e92fbf17156e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <linux/reboot.h>
 #include <asm/uaccess.h>
 
@@ -619,10 +620,12 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
                return -ENOMEM;
        p->op_this_node = -1;
 
+       lock_kernel();
        mutex_lock(&ocfs2_control_lock);
        file->private_data = p;
        list_add(&p->op_list, &ocfs2_control_private_list);
        mutex_unlock(&ocfs2_control_lock);
+       unlock_kernel();
 
        return 0;
 }
index f0d1240a5c6990c7639948fd9e2ce56f613cda2f..9ba495d5a29b26d9493eea556ccd0992deb68829 100644 (file)
@@ -31,12 +31,12 @@ const struct file_operations generic_ro_fops = {
 
 EXPORT_SYMBOL(generic_ro_fops);
 
-loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
+loff_t
+generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
 {
        loff_t retval;
        struct inode *inode = file->f_mapping->host;
 
-       mutex_lock(&inode->i_mutex);
        switch (origin) {
                case SEEK_END:
                        offset += inode->i_size;
@@ -46,42 +46,26 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
        }
        retval = -EINVAL;
        if (offset>=0 && offset<=inode->i_sb->s_maxbytes) {
+               /* Special lock needed here? */
                if (offset != file->f_pos) {
                        file->f_pos = offset;
                        file->f_version = 0;
                }
                retval = offset;
        }
-       mutex_unlock(&inode->i_mutex);
        return retval;
 }
+EXPORT_SYMBOL(generic_file_llseek_unlocked);
 
-EXPORT_SYMBOL(generic_file_llseek);
-
-loff_t remote_llseek(struct file *file, loff_t offset, int origin)
+loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
 {
-       loff_t retval;
-
-       lock_kernel();
-       switch (origin) {
-               case SEEK_END:
-                       offset += i_size_read(file->f_path.dentry->d_inode);
-                       break;
-               case SEEK_CUR:
-                       offset += file->f_pos;
-       }
-       retval = -EINVAL;
-       if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) {
-               if (offset != file->f_pos) {
-                       file->f_pos = offset;
-                       file->f_version = 0;
-               }
-               retval = offset;
-       }
-       unlock_kernel();
-       return retval;
+       loff_t n;
+       mutex_lock(&file->f_dentry->d_inode->i_mutex);
+       n = generic_file_llseek_unlocked(file, offset, origin);
+       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+       return n;
 }
-EXPORT_SYMBOL(remote_llseek);
+EXPORT_SYMBOL(generic_file_llseek);
 
 loff_t no_llseek(struct file *file, loff_t offset, int origin)
 {
index efbe29af3d7a030bbd531786edbeb15a107eaf48..2294783320cbd14a1b88cd2822122bed664e42cf 100644 (file)
@@ -422,9 +422,18 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
        return error;
 }
 
+static loff_t smb_remote_llseek(struct file *file, loff_t offset, int origin)
+{
+       loff_t ret;
+       lock_kernel();
+       ret = generic_file_llseek_unlocked(file, offset, origin);
+       unlock_kernel();
+       return ret;
+}
+
 const struct file_operations smb_file_operations =
 {
-       .llseek         = remote_llseek,
+       .llseek         = smb_remote_llseek,
        .read           = do_sync_read,
        .aio_read       = smb_file_aio_read,
        .write          = do_sync_write,
index a3522727ea5b090ea4ee02d925e7327cde21fe7b..b546ba69be8224f79253e75770a93ff2fdb8a621 100644 (file)
@@ -645,7 +645,7 @@ static int vfat_add_entry(struct inode *dir, struct qstr *qname, int is_dir,
        if (len == 0)
                return -ENOENT;
 
-       slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_KERNEL);
+       slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS);
        if (slots == NULL)
                return -ENOMEM;
 
@@ -687,7 +687,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
        struct dentry *alias;
        int err, table;
 
-       lock_kernel();
+       lock_super(sb);
        table = (MSDOS_SB(sb)->options.name_check == 's') ? 2 : 0;
        dentry->d_op = &vfat_dentry_ops[table];
 
@@ -699,7 +699,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
        inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
        brelse(sinfo.bh);
        if (IS_ERR(inode)) {
-               unlock_kernel();
+               unlock_super(sb);
                return ERR_CAST(inode);
        }
        alias = d_find_alias(inode);
@@ -708,13 +708,13 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
                        dput(alias);
                else {
                        iput(inode);
-                       unlock_kernel();
+                       unlock_super(sb);
                        return alias;
                }
 
        }
 error:
-       unlock_kernel();
+       unlock_super(sb);
        dentry->d_op = &vfat_dentry_ops[table];
        dentry->d_time = dentry->d_parent->d_inode->i_version;
        dentry = d_splice_alias(inode, dentry);
@@ -734,7 +734,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,
        struct timespec ts;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
 
        ts = CURRENT_TIME_SEC;
        err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
@@ -755,17 +755,18 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,
        dentry->d_time = dentry->d_parent->d_inode->i_version;
        d_instantiate(dentry, inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        return err;
 }
 
 static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
 {
        struct inode *inode = dentry->d_inode;
+       struct super_block *sb = dir->i_sb;
        struct fat_slot_info sinfo;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = fat_dir_empty(inode);
        if (err)
@@ -783,7 +784,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
        inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
        fat_detach(inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
 
        return err;
 }
@@ -791,10 +792,11 @@ out:
 static int vfat_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct inode *inode = dentry->d_inode;
+       struct super_block *sb = dir->i_sb;
        struct fat_slot_info sinfo;
        int err;
 
-       lock_kernel();
+       lock_super(sb);
 
        err = vfat_find(dir, &dentry->d_name, &sinfo);
        if (err)
@@ -807,7 +809,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
        inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
        fat_detach(inode);
 out:
-       unlock_kernel();
+       unlock_super(sb);
 
        return err;
 }
@@ -820,7 +822,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        struct timespec ts;
        int err, cluster;
 
-       lock_kernel();
+       lock_super(sb);
 
        ts = CURRENT_TIME_SEC;
        cluster = fat_alloc_new_dir(dir, &ts);
@@ -849,13 +851,13 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        dentry->d_time = dentry->d_parent->d_inode->i_version;
        d_instantiate(dentry, inode);
 
-       unlock_kernel();
+       unlock_super(sb);
        return 0;
 
 out_free:
        fat_free_clusters(dir, cluster);
 out:
-       unlock_kernel();
+       unlock_super(sb);
        return err;
 }
 
@@ -869,11 +871,12 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct timespec ts;
        loff_t dotdot_i_pos, new_i_pos;
        int err, is_dir, update_dotdot, corrupt = 0;
+       struct super_block *sb = old_dir->i_sb;
 
        old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
        old_inode = old_dentry->d_inode;
        new_inode = new_dentry->d_inode;
-       lock_kernel();
+       lock_super(sb);
        err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo);
        if (err)
                goto out;
@@ -951,7 +954,7 @@ out:
        brelse(sinfo.bh);
        brelse(dotdot_bh);
        brelse(old_sinfo.bh);
-       unlock_kernel();
+       unlock_super(sb);
 
        return err;
 
index d8e2762ed14df21bb05c50fde55158d6ec42bd5e..faac13e2cc5c75b0afe4c940cc54151d11b614d3 100644 (file)
@@ -1870,7 +1870,8 @@ extern void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
 extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
-extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
+extern loff_t generic_file_llseek_unlocked(struct file *file, loff_t offset,
+                       int origin);
 extern int generic_file_open(struct inode * inode, struct file * filp);
 extern int nonseekable_open(struct inode * inode, struct file * filp);
 
index aab3a4cff4e13da65a50ec50531ccfd8ed19444d..813be59bf3458785c00b3042645adb8a68a6b558 100644 (file)
@@ -27,11 +27,24 @@ static inline int reacquire_kernel_lock(struct task_struct *task)
 extern void __lockfunc lock_kernel(void)       __acquires(kernel_lock);
 extern void __lockfunc unlock_kernel(void)     __releases(kernel_lock);
 
+/*
+ * Various legacy drivers don't really need the BKL in a specific
+ * function, but they *do* need to know that the BKL became available.
+ * This function just avoids wrapping a bunch of lock/unlock pairs
+ * around code which doesn't really need it.
+ */
+static inline void cycle_kernel_lock(void)
+{
+       lock_kernel();
+       unlock_kernel();
+}
+
 #else
 
 #define lock_kernel()                          do { } while(0)
 #define unlock_kernel()                                do { } while(0)
 #define release_kernel_lock(task)              do { } while(0)
+#define cycle_kernel_lock()                    do { } while(0)
 #define reacquire_kernel_lock(task)            0
 #define kernel_locked()                                1
 
index 0afe32be4c8530851a912dde00a6ed5c0f24cf49..8cb757026386f35f7f12e78cc0caef204ea93cb0 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/pm_qos_params.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
@@ -358,15 +359,19 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
        int ret;
        long pm_qos_class;
 
+       lock_kernel();
        pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
        if (pm_qos_class >= 0) {
                filp->private_data = (void *)pm_qos_class;
                sprintf(name, "process_%d", current->pid);
                ret = pm_qos_add_requirement(pm_qos_class, name,
                                        PM_QOS_DEFAULT_VALUE);
-               if (ret >= 0)
+               if (ret >= 0) {
+                       unlock_kernel();
                        return 0;
+               }
        }
+       unlock_kernel();
 
        return -EPERM;
 }
index b001c361ad30976ff3a1de5bfe80fe2f0142b6f9..bccf4d0059f0a6a629bbd5913015b0453caaa5e9 100644 (file)
 #include <linux/module.h>
 
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/skbuff.h>
 #include <linux/tty.h>
 #include <linux/proc_fs.h>
index e0eab5927c4f434d6210711525ac9b14ba34599e..e84a70dd346b7e48a350502699238286d6cf2f21 100644 (file)
@@ -479,6 +479,7 @@ dev_irnet_open(struct inode *       inode,
   ap = kzalloc(sizeof(*ap), GFP_KERNEL);
   DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n");
 
+  lock_kernel();
   /* initialize the irnet structure */
   ap->file = file;
 
@@ -500,6 +501,7 @@ dev_irnet_open(struct inode *       inode,
     {
       DERROR(FS_ERROR, "Can't setup IrDA link...\n");
       kfree(ap);
+      unlock_kernel();
       return err;
     }
 
@@ -510,6 +512,7 @@ dev_irnet_open(struct inode *       inode,
   file->private_data = ap;
 
   DEXIT(FS_TRACE, " - ap=0x%p\n", ap);
+  unlock_kernel();
   return 0;
 }
 
index 61f5d425b6305660e8cd3bf514664c1f9b225c58..c49b9d9e303c76d6495943b5b99fb02eff710e1f 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/file.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/time.h>
 #include <linux/pm_qos_params.h>
 #include <linux/uio.h>
@@ -3249,14 +3250,17 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
        struct snd_pcm_file * pcm_file;
        struct snd_pcm_substream *substream;
        struct snd_pcm_runtime *runtime;
-       int err;
+       int err = -ENXIO;
 
+       lock_kernel();
        pcm_file = file->private_data;
        substream = pcm_file->substream;
-       snd_assert(substream != NULL, return -ENXIO);
+       snd_assert(substream != NULL, goto out);
        runtime = substream->runtime;
 
        err = fasync_helper(fd, file, on, &runtime->fasync);
+out:
+       unlock_kernel();
        if (err < 0)
                return err;
        return 0;
index 6c8ab48c689a6bb17a6b4dd490ba26c1204e32fd..62e057a94653500f30533cc3c0098d2bd13d2624 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/time.h>
 #include <linux/device.h>
 #include <linux/moduleparam.h>
@@ -121,7 +122,7 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
 
 EXPORT_SYMBOL(snd_lookup_minor_data);
 
-static int snd_open(struct inode *inode, struct file *file)
+static int __snd_open(struct inode *inode, struct file *file)
 {
        unsigned int minor = iminor(inode);
        struct snd_minor *mptr = NULL;
@@ -163,6 +164,18 @@ static int snd_open(struct inode *inode, struct file *file)
        return err;
 }
 
+
+/* BKL pushdown: nasty #ifdef avoidance wrapper */
+static int snd_open(struct inode *inode, struct file *file)
+{
+       int ret;
+
+       lock_kernel();
+       ret = __snd_open(inode, file);
+       unlock_kernel();
+       return ret;
+}
+
 static const struct file_operations snd_fops =
 {
        .owner =        THIS_MODULE,
index 46daca1755028d9ac73a4270deda963a11ef6cc9..dcfc1d5ce63173e5c636cc344d391889a1236611 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -464,6 +465,8 @@ int soundcore_open(struct inode *inode, struct file *file)
        struct sound_unit *s;
        const struct file_operations *new_fops = NULL;
 
+       lock_kernel ();
+
        chain=unit&0x0F;
        if(chain==4 || chain==5)        /* dsp/audio/dsp16 */
        {
@@ -511,9 +514,11 @@ int soundcore_open(struct inode *inode, struct file *file)
                        file->f_op = fops_get(old_fops);
                }
                fops_put(old_fops);
+               unlock_kernel();
                return err;
        }
        spin_unlock(&sound_loader_lock);
+       unlock_kernel();
        return -ENODEV;
 }