Explorar o código

Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6

* 'bkl-removal' of git://git.lwn.net/linux-2.6: (146 commits)
  IB/umad: BKL is not needed for ib_umad_open()
  IB/uverbs: BKL is not needed for ib_uverbs_open()
  bf561-coreb: BKL unneeded for open()
  Call fasync() functions without the BKL
  snd/PCM: fasync BKL pushdown
  ipmi: fasync BKL pushdown
  ecryptfs: fasync BKL pushdown
  Bluetooth VHCI: fasync BKL pushdown
  tty_io: fasync BKL pushdown
  tun: fasync BKL pushdown
  i2o: fasync BKL pushdown
  mpt: fasync BKL pushdown
  Remove BKL from remote_llseek v2
  Make FAT users happier by not deadlocking
  x86-mce: BKL pushdown
  vmwatchdog: BKL pushdown
  vmcp: BKL pushdown
  via-pmu: BKL pushdown
  uml-random: BKL pushdown
  uml-mmapper: BKL pushdown
  ...
Linus Torvalds %!s(int64=17) %!d(string=hai) anos
pai
achega
d1794f2c5b
Modificáronse 100 ficheiros con 609 adicións e 185 borrados
  1. 1 0
      arch/blackfin/mach-bf561/coreb.c
  2. 2 2
      arch/cris/arch-v10/drivers/eeprom.c
  3. 3 0
      arch/cris/arch-v10/drivers/gpio.c
  4. 2 0
      arch/cris/arch-v10/drivers/i2c.c
  5. 21 13
      arch/cris/arch-v10/drivers/sync_serial.c
  6. 2 1
      arch/cris/arch-v32/drivers/cryptocop.c
  7. 2 0
      arch/cris/arch-v32/drivers/i2c.c
  8. 4 0
      arch/cris/arch-v32/drivers/mach-a3/gpio.c
  9. 4 1
      arch/cris/arch-v32/drivers/mach-fs/gpio.c
  10. 20 13
      arch/cris/arch-v32/drivers/sync_serial.c
  11. 6 1
      arch/m68k/bvme6000/rtc.c
  12. 4 0
      arch/m68k/mvme16x/rtc.c
  13. 8 1
      arch/mips/basler/excite/excite_iodev.c
  14. 6 1
      arch/mips/kernel/rtlx.c
  15. 9 3
      arch/mips/kernel/vpe.c
  16. 18 7
      arch/mips/sibyte/common/sb_tbprof.c
  17. 4 0
      arch/parisc/kernel/perf.c
  18. 2 0
      arch/s390/crypto/prng.c
  19. 7 3
      arch/sh/boards/landisk/gio.c
  20. 2 0
      arch/sparc/kernel/apc.c
  21. 6 1
      arch/sparc64/kernel/time.c
  22. 3 0
      arch/um/drivers/harddog_kern.c
  23. 2 0
      arch/um/drivers/mmapper_kern.c
  24. 3 0
      arch/um/drivers/random.c
  25. 4 0
      arch/x86/kernel/apm_32.c
  26. 4 0
      arch/x86/kernel/cpu/mcheck/mce_64.c
  27. 17 8
      arch/x86/kernel/cpuid.c
  28. 2 0
      arch/x86/kernel/microcode.c
  29. 12 4
      arch/x86/kernel/msr.c
  30. 6 1
      block/bsg.c
  31. 6 1
      drivers/block/aoe/aoechr.c
  32. 16 6
      drivers/block/paride/pg.c
  33. 6 1
      drivers/block/paride/pt.c
  34. 11 3
      drivers/bluetooth/hci_vhci.c
  35. 4 0
      drivers/char/agp/frontend.c
  36. 3 0
      drivers/char/apm-emulation.c
  37. 7 2
      drivers/char/briq_panel.c
  38. 2 0
      drivers/char/cs5535_gpio.c
  39. 4 0
      drivers/char/ds1286.c
  40. 8 1
      drivers/char/ds1620.c
  41. 11 5
      drivers/char/dsp56k.c
  42. 3 0
      drivers/char/dtlk.c
  43. 2 0
      drivers/char/efirtc.c
  44. 6 1
      drivers/char/genrtc.c
  45. 4 0
      drivers/char/hpet.c
  46. 2 0
      drivers/char/hw_random/core.c
  47. 2 32
      drivers/char/ip2/ip2main.c
  48. 4 0
      drivers/char/ip27-rtc.c
  49. 8 2
      drivers/char/ipmi/ipmi_devintf.c
  50. 3 0
      drivers/char/ipmi/ipmi_watchdog.c
  51. 3 0
      drivers/char/lcd.c
  52. 26 12
      drivers/char/lp.c
  53. 5 0
      drivers/char/mbcs.c
  54. 8 2
      drivers/char/mem.c
  55. 3 0
      drivers/char/misc.c
  56. 2 0
      drivers/char/mwave/mwavedd.c
  57. 4 0
      drivers/char/nvram.c
  58. 2 0
      drivers/char/pc8736x_gpio.c
  59. 2 0
      drivers/char/ppdev.c
  60. 3 0
      drivers/char/raw.c
  61. 4 0
      drivers/char/rtc.c
  62. 2 0
      drivers/char/scx200_gpio.c
  63. 4 1
      drivers/char/snsc.c
  64. 3 0
      drivers/char/sonypi.c
  65. 2 0
      drivers/char/tb0219.c
  66. 12 7
      drivers/char/tlclk.c
  67. 5 0
      drivers/char/tpm/tpm.c
  68. 34 7
      drivers/char/tty_io.c
  69. 7 2
      drivers/char/vc_screen.c
  70. 3 0
      drivers/char/viotape.c
  71. 2 0
      drivers/char/vr41xx_giu.c
  72. 5 1
      drivers/char/xilinx_hwicap/xilinx_hwicap.c
  73. 7 2
      drivers/gpu/drm/drm_fops.c
  74. 3 0
      drivers/hid/hidraw.c
  75. 16 6
      drivers/i2c/i2c-dev.c
  76. 6 1
      drivers/ide/ide-tape.c
  77. 2 0
      drivers/infiniband/core/ucm.c
  78. 3 0
      drivers/infiniband/core/ucma.c
  79. 13 0
      drivers/infiniband/core/user_mad.c
  80. 12 1
      drivers/infiniband/core/uverbs_main.c
  81. 2 0
      drivers/infiniband/hw/ipath/ipath_file_ops.c
  82. 12 4
      drivers/input/input.c
  83. 2 0
      drivers/input/misc/hp_sdc_rtc.c
  84. 3 0
      drivers/input/misc/uinput.c
  85. 10 2
      drivers/input/mousedev.c
  86. 5 1
      drivers/input/serio/serio_raw.c
  87. 11 6
      drivers/isdn/capi/capi.c
  88. 11 5
      drivers/isdn/hardware/eicon/divamnt.c
  89. 2 0
      drivers/isdn/hardware/eicon/divasi.c
  90. 2 0
      drivers/isdn/hardware/eicon/divasmain.c
  91. 2 1
      drivers/isdn/i4l/isdn_common.c
  92. 13 5
      drivers/macintosh/adb.c
  93. 2 0
      drivers/macintosh/ans-lcd.c
  94. 3 0
      drivers/macintosh/smu.c
  95. 3 0
      drivers/macintosh/via-pmu.c
  96. 4 0
      drivers/media/dvb/dvb-core/dvbdev.c
  97. 4 0
      drivers/media/radio/miropcm20-rds.c
  98. 4 0
      drivers/media/video/videodev.c
  99. 5 1
      drivers/message/fusion/mptctl.c
  100. 8 4
      drivers/message/i2o/i2o_config.c

+ 1 - 0
arch/blackfin/mach-bf561/coreb.c

@@ -194,6 +194,7 @@ static loff_t coreb_lseek(struct file *file, loff_t offset, int origin)
 	return ret;
 	return ret;
 }
 }
 
 
+/* No BKL needed here */
 static int coreb_open(struct inode *inode, struct file *file)
 static int coreb_open(struct inode *inode, struct file *file)
 {
 {
 	spin_lock_irq(&coreb_lock);
 	spin_lock_irq(&coreb_lock);

+ 2 - 2
arch/cris/arch-v10/drivers/eeprom.c

@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
+#include <linux/smp_lock.h>
 #include <linux/wait.h>
 #include <linux/wait.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include "i2c.h"
 #include "i2c.h"
@@ -375,10 +376,9 @@ int __init eeprom_init(void)
 }
 }
 
 
 /* Opens the device. */
 /* Opens the device. */
-
 static int eeprom_open(struct inode * inode, struct file * file)
 static int eeprom_open(struct inode * inode, struct file * file)
 {
 {
-
+  cycle_kernel_lock();
   if(iminor(inode) != EEPROM_MINOR_NR)
   if(iminor(inode) != EEPROM_MINOR_NR)
      return -ENXIO;
      return -ENXIO;
   if(imajor(inode) != EEPROM_MAJOR_NR)
   if(imajor(inode) != EEPROM_MAJOR_NR)

+ 3 - 0
arch/cris/arch-v10/drivers/gpio.c

@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/string.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/init.h>
@@ -323,6 +324,7 @@ gpio_open(struct inode *inode, struct file *filp)
 	if (!priv)
 	if (!priv)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	priv->minor = p;
 	priv->minor = p;
 
 
 	/* initialize the io/alarm struct */
 	/* initialize the io/alarm struct */
@@ -357,6 +359,7 @@ gpio_open(struct inode *inode, struct file *filp)
 	alarmlist = priv;
 	alarmlist = priv;
 	spin_unlock_irqrestore(&gpio_lock, flags);
 	spin_unlock_irqrestore(&gpio_lock, flags);
 
 
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 2 - 0
arch/cris/arch-v10/drivers/i2c.c

@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
@@ -566,6 +567,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
 static int
 static int
 i2c_open(struct inode *inode, struct file *filp)
 i2c_open(struct inode *inode, struct file *filp)
 {
 {
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 21 - 13
arch/cris/arch-v10/drivers/sync_serial.c

@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <linux/timer.h>
 #include <asm/irq.h>
 #include <asm/irq.h>
 #include <asm/dma.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);
 	int dev = MINOR(inode->i_rdev);
 	struct sync_port *port;
 	struct sync_port *port;
 	int mode;
 	int mode;
+	int err = -EBUSY;
 
 
+	lock_kernel();
 	DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
 	DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
 
 
 	if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
 	if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
 		DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
 		DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 	}
 	port = &ports[dev];
 	port = &ports[dev];
 	/* Allow open this device twice (assuming one reader and one writer) */
 	/* Allow open this device twice (assuming one reader and one writer) */
 	if (port->busy == 2) {
 	if (port->busy == 2) {
 		DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
 		DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
-		return -EBUSY;
+		goto out;
 	}
 	}
 	if (port->init_irqs) {
 	if (port->init_irqs) {
 		if (port->use_dma) {
 		if (port->use_dma) {
@@ -465,14 +469,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						&ports[0])) {
 						&ports[0])) {
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 1 IRQ");
 						"sync serial port 1 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (request_irq(25, rx_interrupt, 0,
 				} else if (request_irq(25, rx_interrupt, 0,
 						"synchronous serial 1 dma rx",
 						"synchronous serial 1 dma rx",
 						&ports[0])) {
 						&ports[0])) {
 					free_irq(24, &port[0]);
 					free_irq(24, &port[0]);
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 1 IRQ");
 						"sync serial port 1 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (cris_request_dma(8,
 				} else if (cris_request_dma(8,
 						"synchronous serial 1 dma tr",
 						"synchronous serial 1 dma tr",
 						DMA_VERBOSE_ON_ERROR,
 						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 "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 1 "
 						"sync serial port 1 "
 						"TX DMA channel");
 						"TX DMA channel");
-					return -EBUSY;
+					goto out;
 				} else if (cris_request_dma(9,
 				} else if (cris_request_dma(9,
 						"synchronous serial 1 dma rec",
 						"synchronous serial 1 dma rec",
 						DMA_VERBOSE_ON_ERROR,
 						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 "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 1 "
 						"sync serial port 1 "
 						"RX DMA channel");
 						"RX DMA channel");
-					return -EBUSY;
+					goto out;
 				}
 				}
 #endif
 #endif
 				RESET_DMA(8); WAIT_DMA(8);
 				RESET_DMA(8); WAIT_DMA(8);
@@ -520,14 +524,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						&ports[1])) {
 						&ports[1])) {
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 3 IRQ");
 						"sync serial port 3 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (request_irq(21, rx_interrupt, 0,
 				} else if (request_irq(21, rx_interrupt, 0,
 						"synchronous serial 3 dma rx",
 						"synchronous serial 3 dma rx",
 						&ports[1])) {
 						&ports[1])) {
 					free_irq(20, &ports[1]);
 					free_irq(20, &ports[1]);
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 3 IRQ");
 						"sync serial port 3 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (cris_request_dma(4,
 				} else if (cris_request_dma(4,
 						"synchronous serial 3 dma tr",
 						"synchronous serial 3 dma tr",
 						DMA_VERBOSE_ON_ERROR,
 						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 "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 3 "
 						"sync serial port 3 "
 						"TX DMA channel");
 						"TX DMA channel");
-					return -EBUSY;
+					goto out;
 				} else if (cris_request_dma(5,
 				} else if (cris_request_dma(5,
 						"synchronous serial 3 dma rec",
 						"synchronous serial 3 dma rec",
 						DMA_VERBOSE_ON_ERROR,
 						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 "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial port 3 "
 						"sync serial port 3 "
 						"RX DMA channel");
 						"RX DMA channel");
-					return -EBUSY;
+					goto out;
 				}
 				}
 #endif
 #endif
 				RESET_DMA(4); WAIT_DMA(4);
 				RESET_DMA(4); WAIT_DMA(4);
@@ -581,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						&ports[0])) {
 						&ports[0])) {
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial manual irq");
 						"sync serial manual irq");
-					return -EBUSY;
+					goto out;
 				}
 				}
 			} else if (port == &ports[1]) {
 			} else if (port == &ports[1]) {
 				if (request_irq(8,
 				if (request_irq(8,
@@ -591,7 +595,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						&ports[1])) {
 						&ports[1])) {
 					printk(KERN_CRIT "Can't alloc "
 					printk(KERN_CRIT "Can't alloc "
 						"sync serial manual irq");
 						"sync serial manual irq");
-					return -EBUSY;
+					goto out;
 				}
 				}
 			}
 			}
 			port->init_irqs = 0;
 			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;
 			*R_IRQ_MASK1_SET = 1 << port->data_avail_bit;
 		DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev));
 		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)
 static int sync_serial_release(struct inode *inode, struct file *file)

+ 2 - 1
arch/cris/arch-v32/drivers/cryptocop.c

@@ -11,6 +11,7 @@
 #include <linux/string.h>
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 #include <linux/stddef.h>
 
 
@@ -2302,11 +2303,11 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
 	return 0;
 	return 0;
 }
 }
 
 
-
 static int cryptocop_open(struct inode *inode, struct file *filp)
 static int cryptocop_open(struct inode *inode, struct file *filp)
 {
 {
 	int p = iminor(inode);
 	int p = iminor(inode);
 
 
+	cycle_kernel_lock();
 	if (p != CRYPTOCOP_MINOR) return -EINVAL;
 	if (p != CRYPTOCOP_MINOR) return -EINVAL;
 
 
 	filp->private_data = NULL;
 	filp->private_data = NULL;

+ 2 - 0
arch/cris/arch-v32/drivers/i2c.c

@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/etraxi2c.h>
 #include <asm/etraxi2c.h>
 
 
@@ -636,6 +637,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
 static int
 static int
 i2c_open(struct inode *inode, struct file *filp)
 i2c_open(struct inode *inode, struct file *filp)
 {
 {
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 0
arch/cris/arch-v32/drivers/mach-a3/gpio.c

@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/etraxgpio.h>
 #include <asm/etraxgpio.h>
 #include <hwregs/reg_map.h>
 #include <hwregs/reg_map.h>
@@ -390,6 +391,8 @@ static int gpio_open(struct inode *inode, struct file *filp)
 
 
 	if (!priv)
 	if (!priv)
 		return -ENOMEM;
 		return -ENOMEM;
+
+	lock_kernel();
 	memset(priv, 0, sizeof(*priv));
 	memset(priv, 0, sizeof(*priv));
 
 
 	priv->minor = p;
 	priv->minor = p;
@@ -412,6 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
 		spin_unlock_irq(&gpio_lock);
 		spin_unlock_irq(&gpio_lock);
 	}
 	}
 
 
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 1
arch/cris/arch-v32/drivers/mach-fs/gpio.c

@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/etraxgpio.h>
 #include <asm/etraxgpio.h>
 #include <hwregs/reg_map.h>
 #include <hwregs/reg_map.h>
@@ -426,9 +427,10 @@ gpio_open(struct inode *inode, struct file *filp)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL);
 	priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL);
-
 	if (!priv)
 	if (!priv)
 		return -ENOMEM;
 		return -ENOMEM;
+
+	lock_kernel();
 	memset(priv, 0, sizeof(*priv));
 	memset(priv, 0, sizeof(*priv));
 
 
 	priv->minor = p;
 	priv->minor = p;
@@ -449,6 +451,7 @@ gpio_open(struct inode *inode, struct file *filp)
 	alarmlist = priv;
 	alarmlist = priv;
 	spin_unlock_irq(&alarm_lock);
 	spin_unlock_irq(&alarm_lock);
 
 
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 20 - 13
arch/cris/arch-v32/drivers/sync_serial.c

@@ -14,6 +14,7 @@
 #include <linux/major.h>
 #include <linux/major.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/init.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)
 static int sync_serial_open(struct inode *inode, struct file *file)
 {
 {
 	int dev = iminor(inode);
 	int dev = iminor(inode);
+	int ret = -EBUSY;
 	sync_port *port;
 	sync_port *port;
 	reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
 	reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
 	reg_dma_rw_intr_mask intr_mask = {.data = 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));
 	DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
 
 
 	if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
 	if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
 	{
 	{
 		DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
 		DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
-		return -ENODEV;
+		ret = -ENODEV;
+		goto out;
 	}
 	}
 	port = &ports[dev];
 	port = &ports[dev];
 	/* Allow open this device twice (assuming one reader and one writer) */
 	/* Allow open this device twice (assuming one reader and one writer) */
 	if (port->busy == 2)
 	if (port->busy == 2)
 	{
 	{
 		DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
 		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",
 						"synchronous serial 0 dma tr",
 						&ports[0])) {
 						&ports[0])) {
 					printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
 					printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (request_irq(DMA_IN_INTR_VECT,
 				} else if (request_irq(DMA_IN_INTR_VECT,
 						rx_interrupt,
 						rx_interrupt,
 						0,
 						0,
@@ -467,7 +471,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						&ports[0])) {
 						&ports[0])) {
 					free_irq(DMA_OUT_INTR_VECT, &port[0]);
 					free_irq(DMA_OUT_INTR_VECT, &port[0]);
 					printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
 					printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (crisv32_request_dma(OUT_DMA_NBR,
 				} else if (crisv32_request_dma(OUT_DMA_NBR,
 						"synchronous serial 0 dma tr",
 						"synchronous serial 0 dma tr",
 						DMA_VERBOSE_ON_ERROR,
 						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_OUT_INTR_VECT, &port[0]);
 					free_irq(DMA_IN_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");
 					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,
 				} else if (crisv32_request_dma(IN_DMA_NBR,
 						"synchronous serial 0 dma rec",
 						"synchronous serial 0 dma rec",
 						DMA_VERBOSE_ON_ERROR,
 						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_OUT_INTR_VECT, &port[0]);
 					free_irq(DMA_IN_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");
 					printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel");
-					return -EBUSY;
+					goto out;
 				}
 				}
 #endif
 #endif
 			}
 			}
@@ -499,7 +503,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						"synchronous serial 1 dma tr",
 						"synchronous serial 1 dma tr",
 						&ports[1])) {
 						&ports[1])) {
 					printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ");
 					printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (request_irq(DMA7_INTR_VECT,
 				} else if (request_irq(DMA7_INTR_VECT,
 						       rx_interrupt,
 						       rx_interrupt,
 						       0,
 						       0,
@@ -507,7 +511,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						       &ports[1])) {
 						       &ports[1])) {
 					free_irq(DMA6_INTR_VECT, &ports[1]);
 					free_irq(DMA6_INTR_VECT, &ports[1]);
 					printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ");
 					printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ");
-					return -EBUSY;
+					goto out;
 				} else if (crisv32_request_dma(
 				} else if (crisv32_request_dma(
 						SYNC_SER1_TX_DMA_NBR,
 						SYNC_SER1_TX_DMA_NBR,
 						"synchronous serial 1 dma tr",
 						"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(DMA6_INTR_VECT, &ports[1]);
 					free_irq(DMA7_INTR_VECT, &ports[1]);
 					free_irq(DMA7_INTR_VECT, &ports[1]);
 					printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel");
 					printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel");
-					return -EBUSY;
+					goto out;
 				} else if (crisv32_request_dma(
 				} else if (crisv32_request_dma(
 						SYNC_SER1_RX_DMA_NBR,
 						SYNC_SER1_RX_DMA_NBR,
 						"synchronous serial 3 dma rec",
 						"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(DMA6_INTR_VECT, &ports[1]);
 					free_irq(DMA7_INTR_VECT, &ports[1]);
 					free_irq(DMA7_INTR_VECT, &ports[1]);
 					printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel");
 					printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel");
-					return -EBUSY;
+					goto out;
 				}
 				}
 #endif
 #endif
 			}
 			}
@@ -554,7 +558,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						"synchronous serial manual irq",
 						"synchronous serial manual irq",
 						&ports[0])) {
 						&ports[0])) {
 					printk("Can't allocate sync serial manual irq");
 					printk("Can't allocate sync serial manual irq");
-					return -EBUSY;
+					goto out;
 				}
 				}
 			}
 			}
 #ifdef CONFIG_ETRAXFS
 #ifdef CONFIG_ETRAXFS
@@ -565,7 +569,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 						"synchronous serial manual irq",
 						"synchronous serial manual irq",
 						&ports[1])) {
 						&ports[1])) {
 					printk(KERN_CRIT "Can't allocate sync serial manual irq");
 					printk(KERN_CRIT "Can't allocate sync serial manual irq");
-					return -EBUSY;
+					goto out;
 				}
 				}
 			}
 			}
 #endif
 #endif
@@ -578,7 +582,10 @@ static int sync_serial_open(struct inode *inode, struct file *file)
 	} /* port->init_irqs */
 	} /* port->init_irqs */
 
 
 	port->busy++;
 	port->busy++;
-	return 0;
+	ret = 0;
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int sync_serial_release(struct inode *inode, struct file *file)
 static int sync_serial_release(struct inode *inode, struct file *file)

+ 6 - 1
arch/m68k/bvme6000/rtc.c

@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
 #include <linux/capability.h>
 #include <linux/fcntl.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)
 static int rtc_open(struct inode *inode, struct file *file)
 {
 {
-	if(rtc_status)
+	lock_kernel();
+	if(rtc_status) {
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
+	}
 
 
 	rtc_status = 1;
 	rtc_status = 1;
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 0
arch/m68k/mvme16x/rtc.c

@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
 #include <linux/capability.h>
 #include <linux/fcntl.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)
 static int rtc_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	if( !atomic_dec_and_test(&rtc_ready) )
 	if( !atomic_dec_and_test(&rtc_ready) )
 	{
 	{
 		atomic_inc( &rtc_ready );
 		atomic_inc( &rtc_ready );
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 8 - 1
arch/mips/basler/excite/excite_iodev.c

@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 
 
 #include "excite_iodev.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)
 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);
 			   iodev_name, &miscdev);
+	unlock_kernel();
+
+	return ret;
 }
 }
 
 
 static int iodev_release(struct inode *i, struct file *f)
 static int iodev_release(struct inode *i, struct file *f)

+ 6 - 1
arch/mips/kernel/rtlx.c

@@ -28,6 +28,7 @@
 #include <linux/vmalloc.h>
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
 #include <linux/elf.h>
 #include <linux/seq_file.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 #include <linux/syscalls.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
 #include <linux/moduleloader.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
@@ -392,8 +393,12 @@ out:
 static int file_open(struct inode *inode, struct file *filp)
 static int file_open(struct inode *inode, struct file *filp)
 {
 {
 	int minor = iminor(inode);
 	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)
 static int file_release(struct inode *inode, struct file *filp)

+ 9 - 3
arch/mips/kernel/vpe.c

@@ -38,6 +38,7 @@
 #include <linux/vmalloc.h>
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
 #include <linux/elf.h>
 #include <linux/seq_file.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 #include <linux/syscalls.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
 #include <linux/moduleloader.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
@@ -1050,17 +1051,20 @@ static int vpe_open(struct inode *inode, struct file *filp)
 	enum vpe_state state;
 	enum vpe_state state;
 	struct vpe_notifications *not;
 	struct vpe_notifications *not;
 	struct vpe *v;
 	struct vpe *v;
-	int ret;
+	int ret, err = 0;
 
 
+	lock_kernel();
 	if (minor != iminor(inode)) {
 	if (minor != iminor(inode)) {
 		/* assume only 1 device at the moment. */
 		/* assume only 1 device at the moment. */
 		printk(KERN_WARNING "VPE loader: only vpe1 is supported\n");
 		printk(KERN_WARNING "VPE loader: only vpe1 is supported\n");
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 	}
 
 
 	if ((v = get_vpe(tclimit)) == NULL) {
 	if ((v = get_vpe(tclimit)) == NULL) {
 		printk(KERN_WARNING "VPE loader: unable to get vpe\n");
 		printk(KERN_WARNING "VPE loader: unable to get vpe\n");
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 	}
 
 
 	state = xchg(&v->state, VPE_STATE_INUSE);
 	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->shared_ptr = NULL;
 	v->__start = 0;
 	v->__start = 0;
 
 
+out:
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 18 - 7
arch/mips/sibyte/common/sb_tbprof.c

@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/errno.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)
 static int sbprof_tb_open(struct inode *inode, struct file *filp)
 {
 {
 	int minor;
 	int minor;
+	int err = 0;
 
 
+	lock_kernel();
 	minor = iminor(inode);
 	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));
 	memset(&sbp, 0, sizeof(struct sbprof_tb));
 	sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
 	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);
 	memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
 	init_waitqueue_head(&sbp.tb_sync);
 	init_waitqueue_head(&sbp.tb_sync);
 	init_waitqueue_head(&sbp.tb_read);
 	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;
 	sbp.open = SB_OPEN;
 
 
-	return 0;
+  out:
+	unlock_kernel();
+	return err;
 }
 }
 
 
 static int sbprof_tb_release(struct inode *inode, struct file *filp)
 static int sbprof_tb_release(struct inode *inode, struct file *filp)

+ 4 - 0
arch/parisc/kernel/perf.c

@@ -46,6 +46,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
 
 
 #include <asm/uaccess.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)
 static int perf_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock(&perf_lock);
 	spin_lock(&perf_lock);
 	if (perf_enabled) {
 	if (perf_enabled) {
 		spin_unlock(&perf_lock);
 		spin_unlock(&perf_lock);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 	perf_enabled = 1;
 	perf_enabled = 1;
  	spin_unlock(&perf_lock);
  	spin_unlock(&perf_lock);
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 2 - 0
arch/s390/crypto/prng.c

@@ -6,6 +6,7 @@
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/moduleparam.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)
 static int prng_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
 	return nonseekable_open(inode, file);
 	return nonseekable_open(inode, file);
 }
 }
 
 

+ 7 - 3
arch/sh/boards/landisk/gio.c

@@ -14,6 +14,7 @@
  */
  */
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/kdev_t.h>
 #include <linux/kdev_t.h>
 #include <linux/cdev.h>
 #include <linux/cdev.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
@@ -32,17 +33,20 @@ static int openCnt;
 static int gio_open(struct inode *inode, struct file *filp)
 static int gio_open(struct inode *inode, struct file *filp)
 {
 {
 	int minor;
 	int minor;
+	int ret = -ENOENT;
 
 
+	lock_kernel();
 	minor = MINOR(inode->i_rdev);
 	minor = MINOR(inode->i_rdev);
 	if (minor < DEVCOUNT) {
 	if (minor < DEVCOUNT) {
 		if (openCnt > 0) {
 		if (openCnt > 0) {
-			return -EALREADY;
+			ret = -EALREADY;
 		} else {
 		} else {
 			openCnt++;
 			openCnt++;
-			return 0;
+			ret = 0;
 		}
 		}
 	}
 	}
-	return -ENOENT;
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int gio_close(struct inode *inode, struct file *filp)
 static int gio_close(struct inode *inode, struct file *filp)

+ 2 - 0
arch/sparc/kernel/apc.c

@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 #include <linux/pm.h>
 #include <linux/pm.h>
 
 
 #include <asm/io.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)
 static int apc_open(struct inode *inode, struct file *f)
 {
 {
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 6 - 1
arch/sparc64/kernel/time.c

@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/param.h>
 #include <linux/string.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)
 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;
 		return -EBUSY;
+	}
 
 
 	mini_rtc_status |= RTC_IS_OPEN;
 	mini_rtc_status |= RTC_IS_OPEN;
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 3 - 0
arch/um/drivers/harddog_kern.c

@@ -66,6 +66,7 @@ static int harddog_open(struct inode *inode, struct file *file)
 	int err = -EBUSY;
 	int err = -EBUSY;
 	char *sock = NULL;
 	char *sock = NULL;
 
 
+	lock_kernel();
 	spin_lock(&lock);
 	spin_lock(&lock);
 	if(timer_alive)
 	if(timer_alive)
 		goto err;
 		goto err;
@@ -82,9 +83,11 @@ static int harddog_open(struct inode *inode, struct file *file)
 
 
 	timer_alive = 1;
 	timer_alive = 1;
 	spin_unlock(&lock);
 	spin_unlock(&lock);
+	unlock_kernel();
 	return nonseekable_open(inode, file);
 	return nonseekable_open(inode, file);
 err:
 err:
 	spin_unlock(&lock);
 	spin_unlock(&lock);
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 2 - 0
arch/um/drivers/mmapper_kern.c

@@ -16,6 +16,7 @@
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include "mem_user.h"
 #include "mem_user.h"
 
 
@@ -77,6 +78,7 @@ out:
 
 
 static int mmapper_open(struct inode *inode, struct file *file)
 static int mmapper_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 0
arch/um/drivers/random.c

@@ -7,6 +7,7 @@
  * of the GNU General Public License, incorporated herein by reference.
  * of the GNU General Public License, incorporated herein by reference.
  */
  */
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/interrupt.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)
 static int rng_dev_open (struct inode *inode, struct file *filp)
 {
 {
+	cycle_kernel_lock();
+
 	/* enforce read-only access to this chrdev */
 	/* enforce read-only access to this chrdev */
 	if ((filp->f_mode & FMODE_READ) == 0)
 	if ((filp->f_mode & FMODE_READ) == 0)
 		return -EINVAL;
 		return -EINVAL;

+ 4 - 0
arch/x86/kernel/apm_32.c

@@ -204,6 +204,7 @@
 #include <linux/module.h>
 #include <linux/module.h>
 
 
 #include <linux/poll.h>
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/stddef.h>
 #include <linux/timer.h>
 #include <linux/timer.h>
@@ -1549,10 +1550,12 @@ static int do_open(struct inode *inode, struct file *filp)
 {
 {
 	struct apm_user *as;
 	struct apm_user *as;
 
 
+	lock_kernel();
 	as = kmalloc(sizeof(*as), GFP_KERNEL);
 	as = kmalloc(sizeof(*as), GFP_KERNEL);
 	if (as == NULL) {
 	if (as == NULL) {
 		printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
 		printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
 		       sizeof(*as));
 		       sizeof(*as));
+		       unlock_kernel();
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 	as->magic = APM_BIOS_MAGIC;
 	as->magic = APM_BIOS_MAGIC;
@@ -1574,6 +1577,7 @@ static int do_open(struct inode *inode, struct file *filp)
 	user_list = as;
 	user_list = as;
 	spin_unlock(&user_list_lock);
 	spin_unlock(&user_list_lock);
 	filp->private_data = as;
 	filp->private_data = as;
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 0
arch/x86/kernel/cpu/mcheck/mce_64.c

@@ -9,6 +9,7 @@
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <linux/string.h>
 #include <linux/rcupdate.h>
 #include <linux/rcupdate.h>
 #include <linux/kallsyms.h>
 #include <linux/kallsyms.h>
@@ -532,10 +533,12 @@ static int open_exclu;	/* already open exclusive? */
 
 
 static int mce_open(struct inode *inode, struct file *file)
 static int mce_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock(&mce_state_lock);
 	spin_lock(&mce_state_lock);
 
 
 	if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
 	if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
 		spin_unlock(&mce_state_lock);
 		spin_unlock(&mce_state_lock);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 
@@ -544,6 +547,7 @@ static int mce_open(struct inode *inode, struct file *file)
 	open_count++;
 	open_count++;
 
 
 	spin_unlock(&mce_state_lock);
 	spin_unlock(&mce_state_lock);
+	unlock_kernel();
 
 
 	return nonseekable_open(inode, file);
 	return nonseekable_open(inode, file);
 }
 }

+ 17 - 8
arch/x86/kernel/cpuid.c

@@ -33,6 +33,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/smp.h>
 #include <linux/smp.h>
+#include <linux/smp_lock.h>
 #include <linux/major.h>
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.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)
 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)
 	if (c->cpuid_level < 0)
-		return -EIO;	/* CPUID not supported */
-
-	return 0;
+		ret = -EIO;	/* CPUID not supported */
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 /*
 /*

+ 2 - 0
arch/x86/kernel/microcode.c

@@ -76,6 +76,7 @@
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/cpumask.h>
 #include <linux/cpumask.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
@@ -423,6 +424,7 @@ out:
 
 
 static int microcode_open (struct inode *unused1, struct file *unused2)
 static int microcode_open (struct inode *unused1, struct file *unused2)
 {
 {
+	cycle_kernel_lock();
 	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 }
 }
 
 

+ 12 - 4
arch/x86/kernel/msr.c

@@ -117,12 +117,20 @@ static int msr_open(struct inode *inode, struct file *file)
 {
 {
 	unsigned int cpu = iminor(file->f_path.dentry->d_inode);
 	unsigned int cpu = iminor(file->f_path.dentry->d_inode);
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
 	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;
 	return 0;
 }
 }
 
 

+ 6 - 1
block/bsg.c

@@ -19,6 +19,7 @@
 #include <linux/uio.h>
 #include <linux/uio.h>
 #include <linux/idr.h>
 #include <linux/idr.h>
 #include <linux/bsg.h>
 #include <linux/bsg.h>
+#include <linux/smp_lock.h>
 
 
 #include <scsi/scsi.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsi_ioctl.h>
@@ -851,7 +852,11 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
 
 
 static int bsg_open(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))
 	if (IS_ERR(bd))
 		return PTR_ERR(bd);
 		return PTR_ERR(bd);

+ 6 - 1
drivers/block/aoe/aoechr.c

@@ -7,6 +7,7 @@
 #include <linux/hdreg.h>
 #include <linux/hdreg.h>
 #include <linux/blkdev.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
+#include <linux/smp_lock.h>
 #include "aoe.h"
 #include "aoe.h"
 
 
 enum {
 enum {
@@ -174,12 +175,16 @@ aoechr_open(struct inode *inode, struct file *filp)
 {
 {
 	int n, i;
 	int n, i;
 
 
+	lock_kernel();
 	n = iminor(inode);
 	n = iminor(inode);
 	filp->private_data = (void *) (unsigned long) n;
 	filp->private_data = (void *) (unsigned long) n;
 
 
 	for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
 	for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-		if (chardevs[i].minor == n)
+		if (chardevs[i].minor == n) {
+			unlock_kernel();
 			return 0;
 			return 0;
+		}
+	unlock_kernel();
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 

+ 16 - 6
drivers/block/paride/pg.c

@@ -162,6 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
 #include <linux/pg.h>
 #include <linux/pg.h>
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/sched.h>	/* current, TASK_* */
 #include <linux/sched.h>	/* current, TASK_* */
+#include <linux/smp_lock.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
@@ -515,12 +516,18 @@ static int pg_open(struct inode *inode, struct file *file)
 {
 {
 	int unit = iminor(inode) & 0x7f;
 	int unit = iminor(inode) & 0x7f;
 	struct pg *dev = &devices[unit];
 	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) {
 	if (dev->busy) {
 		pg_reset(dev);
 		pg_reset(dev);
@@ -533,12 +540,15 @@ static int pg_open(struct inode *inode, struct file *file)
 	if (dev->bufptr == NULL) {
 	if (dev->bufptr == NULL) {
 		clear_bit(0, &dev->access);
 		clear_bit(0, &dev->access);
 		printk("%s: buffer allocation failed\n", dev->name);
 		printk("%s: buffer allocation failed\n", dev->name);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out;
 	}
 	}
 
 
 	file->private_data = dev;
 	file->private_data = dev;
 
 
-	return 0;
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int pg_release(struct inode *inode, struct file *file)
 static int pg_release(struct inode *inode, struct file *file)

+ 6 - 1
drivers/block/paride/pt.c

@@ -650,8 +650,11 @@ static int pt_open(struct inode *inode, struct file *file)
 	struct pt_unit *tape = pt + unit;
 	struct pt_unit *tape = pt + unit;
 	int err;
 	int err;
 
 
-	if (unit >= PT_UNITS || (!tape->present))
+	lock_kernel();
+	if (unit >= PT_UNITS || (!tape->present)) {
+		unlock_kernel();
 		return -ENODEV;
 		return -ENODEV;
+	}
 
 
 	err = -EBUSY;
 	err = -EBUSY;
 	if (!atomic_dec_and_test(&tape->available))
 	if (!atomic_dec_and_test(&tape->available))
@@ -678,10 +681,12 @@ static int pt_open(struct inode *inode, struct file *file)
 	}
 	}
 
 
 	file->private_data = tape;
 	file->private_data = tape;
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 out:
 out:
 	atomic_inc(&tape->available);
 	atomic_inc(&tape->available);
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 11 - 3
drivers/bluetooth/hci_vhci.c

@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/sched.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);
 	skb_queue_head_init(&data->readq);
 	init_waitqueue_head(&data->read_wait);
 	init_waitqueue_head(&data->read_wait);
 
 
+	lock_kernel();
 	hdev = hci_alloc_dev();
 	hdev = hci_alloc_dev();
 	if (!hdev) {
 	if (!hdev) {
 		kfree(data);
 		kfree(data);
+		unlock_kernel();
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
@@ -286,10 +289,12 @@ static int vhci_open(struct inode *inode, struct file *file)
 		BT_ERR("Can't register HCI device");
 		BT_ERR("Can't register HCI device");
 		kfree(data);
 		kfree(data);
 		hci_free_dev(hdev);
 		hci_free_dev(hdev);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 
 	file->private_data = data;
 	file->private_data = data;
+	unlock_kernel();
 
 
 	return nonseekable_open(inode, file);
 	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)
 static int vhci_fasync(int fd, struct file *file, int on)
 {
 {
 	struct vhci_data *data = file->private_data;
 	struct vhci_data *data = file->private_data;
-	int err;
+	int err = 0;
 
 
+	lock_kernel();
 	err = fasync_helper(fd, file, on, &data->fasync);
 	err = fasync_helper(fd, file, on, &data->fasync);
 	if (err < 0)
 	if (err < 0)
-		return err;
+		goto out;
 
 
 	if (on)
 	if (on)
 		data->flags |= VHCI_FASYNC;
 		data->flags |= VHCI_FASYNC;
 	else
 	else
 		data->flags &= ~VHCI_FASYNC;
 		data->flags &= ~VHCI_FASYNC;
 
 
-	return 0;
+out:
+	unlock_kernel();
+	return err;
 }
 }
 
 
 static const struct file_operations vhci_fops = {
 static const struct file_operations vhci_fops = {

+ 4 - 0
drivers/char/agp/frontend.c

@@ -39,6 +39,7 @@
 #include <linux/mm.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/pgtable.h>
 #include "agp.h"
 #include "agp.h"
@@ -677,6 +678,7 @@ static int agp_open(struct inode *inode, struct file *file)
 	struct agp_client *client;
 	struct agp_client *client;
 	int rc = -ENXIO;
 	int rc = -ENXIO;
 
 
+	lock_kernel();
 	mutex_lock(&(agp_fe.agp_mutex));
 	mutex_lock(&(agp_fe.agp_mutex));
 
 
 	if (minor != AGPGART_MINOR)
 	if (minor != AGPGART_MINOR)
@@ -703,12 +705,14 @@ static int agp_open(struct inode *inode, struct file *file)
 	agp_insert_file_private(priv);
 	agp_insert_file_private(priv);
 	DBG("private=%p, client=%p", priv, client);
 	DBG("private=%p, client=%p", priv, client);
 	mutex_unlock(&(agp_fe.agp_mutex));
 	mutex_unlock(&(agp_fe.agp_mutex));
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 err_out_nomem:
 err_out_nomem:
 	rc = -ENOMEM;
 	rc = -ENOMEM;
 err_out:
 err_out:
 	mutex_unlock(&(agp_fe.agp_mutex));
 	mutex_unlock(&(agp_fe.agp_mutex));
+	unlock_kernel();
 	return rc;
 	return rc;
 }
 }
 
 

+ 3 - 0
drivers/char/apm-emulation.c

@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/seq_file.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
@@ -416,6 +417,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 {
 {
 	struct apm_user *as;
 	struct apm_user *as;
 
 
+	lock_kernel();
 	as = kzalloc(sizeof(*as), GFP_KERNEL);
 	as = kzalloc(sizeof(*as), GFP_KERNEL);
 	if (as) {
 	if (as) {
 		/*
 		/*
@@ -435,6 +437,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 
 
 		filp->private_data = as;
 		filp->private_data = as;
 	}
 	}
+	unlock_kernel();
 
 
 	return as ? 0 : -ENOMEM;
 	return as ? 0 : -ENOMEM;
 }
 }

+ 7 - 2
drivers/char/briq_panel.c

@@ -6,6 +6,7 @@
 
 
 #include <linux/module.h>
 #include <linux/module.h>
 
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/tty.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)
 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;
 		return -EBUSY;
+	}
 	vfd_is_open = 1;
 	vfd_is_open = 1;
 
 
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 2 - 0
drivers/char/cs5535_gpio.c

@@ -17,6 +17,7 @@
 #include <linux/cdev.h>
 #include <linux/cdev.h>
 #include <linux/ioport.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
 #include <linux/pci.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/io.h>
 
 
@@ -157,6 +158,7 @@ static int cs5535_gpio_open(struct inode *inode, struct file *file)
 {
 {
 	u32 m = iminor(inode);
 	u32 m = iminor(inode);
 
 
+	cycle_kernel_lock();
 	/* the mask says which pins are usable by this driver */
 	/* the mask says which pins are usable by this driver */
 	if ((mask & (1 << m)) == 0)
 	if ((mask & (1 << m)) == 0)
 		return -EINVAL;
 		return -EINVAL;

+ 4 - 0
drivers/char/ds1286.c

@@ -27,6 +27,7 @@
  * option) any later version.
  * option) any later version.
  */
  */
 #include <linux/ds1286.h>
 #include <linux/ds1286.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.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)
 static int ds1286_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock_irq(&ds1286_lock);
 	spin_lock_irq(&ds1286_lock);
 
 
 	if (ds1286_status & RTC_IS_OPEN)
 	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;
 	ds1286_status |= RTC_IS_OPEN;
 
 
 	spin_unlock_irq(&ds1286_lock);
 	spin_unlock_irq(&ds1286_lock);
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 out_busy:
 out_busy:
 	spin_lock_irq(&ds1286_lock);
 	spin_lock_irq(&ds1286_lock);
+	unlock_kernel();
 	return -EBUSY;
 	return -EBUSY;
 }
 }
 
 

+ 8 - 1
drivers/char/ds1620.c

@@ -8,6 +8,7 @@
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/capability.h>
 #include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/hardware.h>
 #include <asm/hardware.h>
 #include <asm/mach-types.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));
 	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
 static ssize_t
 ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
 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 = {
 static const struct file_operations ds1620_fops = {
 	.owner		= THIS_MODULE,
 	.owner		= THIS_MODULE,
-	.open		= nonseekable_open,
+	.open		= ds1620_open,
 	.read		= ds1620_read,
 	.read		= ds1620_read,
 	.ioctl		= ds1620_ioctl,
 	.ioctl		= ds1620_ioctl,
 };
 };

+ 11 - 5
drivers/char/dsp56k.c

@@ -33,6 +33,7 @@
 #include <linux/mm.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/atarihw.h>
 #include <asm/atarihw.h>
 #include <asm/traps.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)
 static int dsp56k_open(struct inode *inode, struct file *file)
 {
 {
 	int dev = iminor(inode) & 0x0f;
 	int dev = iminor(inode) & 0x0f;
+	int ret = 0;
 
 
+	lock_kernel();
 	switch(dev)
 	switch(dev)
 	{
 	{
 	case DSP56K_DEV_56001:
 	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.timeout = TIMEOUT;
 		dsp56k.maxio = MAXIO;
 		dsp56k.maxio = MAXIO;
@@ -458,10 +463,11 @@ static int dsp56k_open(struct inode *inode, struct file *file)
 		break;
 		break;
 
 
 	default:
 	default:
-		return -ENODEV;
+		ret = -ENODEV;
 	}
 	}
-
-	return 0;
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int dsp56k_release(struct inode *inode, struct file *file)
 static int dsp56k_release(struct inode *inode, struct file *file)

+ 3 - 0
drivers/char/dtlk.c

@@ -56,6 +56,7 @@
 #include <linux/errno.h>	/* for -EBUSY */
 #include <linux/errno.h>	/* for -EBUSY */
 #include <linux/ioport.h>	/* for request_region */
 #include <linux/ioport.h>	/* for request_region */
 #include <linux/delay.h>	/* for loops_per_jiffy */
 #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/io.h>		/* for inb_p, outb_p, inb, outb, etc. */
 #include <asm/uaccess.h>	/* for get_user, etc. */
 #include <asm/uaccess.h>	/* for get_user, etc. */
 #include <linux/wait.h>		/* for wait_queue */
 #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)
 static int dtlk_open(struct inode *inode, struct file *file)
 {
 {
 	TRACE_TEXT("(dtlk_open");
 	TRACE_TEXT("(dtlk_open");
 
 
+	cycle_kernel_lock();
 	nonseekable_open(inode, file);
 	nonseekable_open(inode, file);
 	switch (iminor(inode)) {
 	switch (iminor(inode)) {
 	case DTLK_MINOR:
 	case DTLK_MINOR:

+ 2 - 0
drivers/char/efirtc.c

@@ -28,6 +28,7 @@
  */
  */
 
 
 
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.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
 	 * We do accept multiple open files at the same time as we
 	 * synchronize on the per call operation.
 	 * synchronize on the per call operation.
 	 */
 	 */
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 6 - 1
drivers/char/genrtc.c

@@ -51,6 +51,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
+#include <linux/smp_lock.h>
 #include <linux/workqueue.h>
 #include <linux/workqueue.h>
 
 
 #include <asm/uaccess.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)
 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;
 		return -EBUSY;
+	}
 
 
 	gen_rtc_status |= RTC_IS_OPEN;
 	gen_rtc_status |= RTC_IS_OPEN;
 	gen_rtc_irq_data = 0;
 	gen_rtc_irq_data = 0;
 	irq_active = 0;
 	irq_active = 0;
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 4 - 0
drivers/char/hpet.c

@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/major.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)
 	if (file->f_mode & FMODE_WRITE)
 		return -EINVAL;
 		return -EINVAL;
 
 
+	lock_kernel();
 	spin_lock_irq(&hpet_lock);
 	spin_lock_irq(&hpet_lock);
 
 
 	for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
 	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) {
 	if (!devp) {
 		spin_unlock_irq(&hpet_lock);
 		spin_unlock_irq(&hpet_lock);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 
@@ -214,6 +217,7 @@ static int hpet_open(struct inode *inode, struct file *file)
 	devp->hd_irqdata = 0;
 	devp->hd_irqdata = 0;
 	devp->hd_flags |= HPET_OPEN;
 	devp->hd_flags |= HPET_OPEN;
 	spin_unlock_irq(&hpet_lock);
 	spin_unlock_irq(&hpet_lock);
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 2 - 0
drivers/char/hw_random/core.c

@@ -37,6 +37,7 @@
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
@@ -86,6 +87,7 @@ static int rng_dev_open(struct inode *inode, struct file *filp)
 		return -EINVAL;
 		return -EINVAL;
 	if (filp->f_mode & FMODE_WRITE)
 	if (filp->f_mode & FMODE_WRITE)
 		return -EINVAL;
 		return -EINVAL;
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 2 - 32
drivers/char/ip2/ip2main.c

@@ -98,6 +98,7 @@
 #include <linux/major.h>
 #include <linux/major.h>
 #include <linux/wait.h>
 #include <linux/wait.h>
 #include <linux/device.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 
 #include <linux/tty.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.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
 static int
 ip2_ipl_open( struct inode *pInode, struct file *pFile )
 ip2_ipl_open( struct inode *pInode, struct file *pFile )
 {
 {
-	unsigned int iplminor = iminor(pInode);
-	i2eBordStrPtr pB;
-	i2ChanStrPtr  pCh;
 
 
 #ifdef IP2DEBUG_IPL
 #ifdef IP2DEBUG_IPL
 	printk (KERN_DEBUG "IP2IPL: open\n" );
 	printk (KERN_DEBUG "IP2IPL: open\n" );
 #endif
 #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;
 	return 0;
 }
 }
 
 

+ 4 - 0
drivers/char/ip27-rtc.c

@@ -27,6 +27,7 @@
 #include <linux/bcd.h>
 #include <linux/bcd.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/ioport.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)
 static int rtc_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock_irq(&rtc_lock);
 	spin_lock_irq(&rtc_lock);
 
 
 	if (rtc_status & RTC_IS_OPEN) {
 	if (rtc_status & RTC_IS_OPEN) {
 		spin_unlock_irq(&rtc_lock);
 		spin_unlock_irq(&rtc_lock);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 
 	rtc_status |= RTC_IS_OPEN;
 	rtc_status |= RTC_IS_OPEN;
 	spin_unlock_irq(&rtc_lock);
 	spin_unlock_irq(&rtc_lock);
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 8 - 2
drivers/char/ipmi/ipmi_devintf.c

@@ -43,6 +43,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/compat.h>
 #include <linux/compat.h>
+#include <linux/smp_lock.h>
 
 
 struct ipmi_file_private
 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;
 	struct ipmi_file_private *priv = file->private_data;
 	int                      result;
 	int                      result;
 
 
+	lock_kernel(); /* could race against open() otherwise */
 	result = fasync_helper(fd, file, on, &priv->fasync_queue);
 	result = fasync_helper(fd, file, on, &priv->fasync_queue);
+	unlock_kernel();
 
 
 	return (result);
 	return (result);
 }
 }
@@ -121,6 +124,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
 	if (!priv)
 	if (!priv)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	priv->file = file;
 	priv->file = file;
 
 
 	rv = ipmi_create_user(if_num,
 	rv = ipmi_create_user(if_num,
@@ -129,7 +133,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
 			      &(priv->user));
 			      &(priv->user));
 	if (rv) {
 	if (rv) {
 		kfree(priv);
 		kfree(priv);
-		return rv;
+		goto out;
 	}
 	}
 
 
 	file->private_data = priv;
 	file->private_data = priv;
@@ -144,7 +148,9 @@ static int ipmi_open(struct inode *inode, struct file *file)
 	priv->default_retries = -1;
 	priv->default_retries = -1;
 	priv->default_retry_time_ms = 0;
 	priv->default_retry_time_ms = 0;
 
 
-	return 0;
+out:
+	unlock_kernel();
+	return rv;
 }
 }
 
 
 static int ipmi_release(struct inode *inode, struct file *file)
 static int ipmi_release(struct inode *inode, struct file *file)

+ 3 - 0
drivers/char/ipmi/ipmi_watchdog.c

@@ -35,6 +35,7 @@
 #include <linux/moduleparam.h>
 #include <linux/moduleparam.h>
 #include <linux/ipmi.h>
 #include <linux/ipmi.h>
 #include <linux/ipmi_smi.h>
 #include <linux/ipmi_smi.h>
+#include <linux/smp_lock.h>
 #include <linux/watchdog.h>
 #include <linux/watchdog.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/init.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))
 		if (test_and_set_bit(0, &ipmi_wdog_open))
 			return -EBUSY;
 			return -EBUSY;
 
 
+		cycle_kernel_lock();
+
 		/*
 		/*
 		 * Don't start the timer now, let it start on the
 		 * Don't start the timer now, let it start on the
 		 * first heartbeat.
 		 * first heartbeat.

+ 3 - 0
drivers/char/lcd.c

@@ -20,6 +20,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/mc146818rtc.h>
 #include <linux/netdevice.h>
 #include <linux/netdevice.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
 
 
 #include <asm/io.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)
 static int lcd_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
+
 	if (!lcd_present)
 	if (!lcd_present)
 		return -ENXIO;
 		return -ENXIO;
 	else
 	else

+ 26 - 12
drivers/char/lp.c

@@ -126,6 +126,7 @@
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/wait.h>
 #include <linux/wait.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 
 
 #include <linux/parport.h>
 #include <linux/parport.h>
 #undef LP_STATS
 #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)
 static int lp_open(struct inode * inode, struct file * file)
 {
 {
 	unsigned int minor = iminor(inode);
 	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,
 	/* 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
 	   we may still want to open it to perform ioctl()s.  Therefore we
 	   have commandeered O_NONBLOCK, even though it is being used in
 	   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) {
 		if (status & LP_POUTPA) {
 			printk(KERN_INFO "lp%d out of paper\n", minor);
 			printk(KERN_INFO "lp%d out of paper\n", minor);
 			LP_F(minor) &= ~LP_BUSY;
 			LP_F(minor) &= ~LP_BUSY;
-			return -ENOSPC;
+			ret = -ENOSPC;
+			goto out;
 		} else if (!(status & LP_PSELECD)) {
 		} else if (!(status & LP_PSELECD)) {
 			printk(KERN_INFO "lp%d off-line\n", minor);
 			printk(KERN_INFO "lp%d off-line\n", minor);
 			LP_F(minor) &= ~LP_BUSY;
 			LP_F(minor) &= ~LP_BUSY;
-			return -EIO;
+			ret = -EIO;
+			goto out;
 		} else if (!(status & LP_PERRORP)) {
 		} else if (!(status & LP_PERRORP)) {
 			printk(KERN_ERR "lp%d printer error\n", minor);
 			printk(KERN_ERR "lp%d printer error\n", minor);
 			LP_F(minor) &= ~LP_BUSY;
 			LP_F(minor) &= ~LP_BUSY;
-			return -EIO;
+			ret = -EIO;
+			goto out;
 		}
 		}
 	}
 	}
 	lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
 	lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
 	if (!lp_table[minor].lp_buffer) {
 	if (!lp_table[minor].lp_buffer) {
 		LP_F(minor) &= ~LP_BUSY;
 		LP_F(minor) &= ~LP_BUSY;
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out;
 	}
 	}
 	/* Determine if the peripheral supports ECP mode */
 	/* Determine if the peripheral supports ECP mode */
 	lp_claim_parport_or_block (&lp_table[minor]);
 	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);
 	parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT);
 	lp_release_parport (&lp_table[minor]);
 	lp_release_parport (&lp_table[minor]);
 	lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
 	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)
 static int lp_release(struct inode * inode, struct file * file)

+ 5 - 0
drivers/char/mbcs.c

@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/mm.h>
 #include <linux/uio.h>
 #include <linux/uio.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <asm/io.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/system.h>
@@ -382,15 +383,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
 	struct mbcs_soft *soft;
 	struct mbcs_soft *soft;
 	int minor;
 	int minor;
 
 
+	lock_kernel();
 	minor = iminor(ip);
 	minor = iminor(ip);
 
 
+	/* Nothing protects access to this list... */
 	list_for_each_entry(soft, &soft_list, list) {
 	list_for_each_entry(soft, &soft_list, list) {
 		if (soft->nasid == minor) {
 		if (soft->nasid == minor) {
 			fp->private_data = soft->cxdev;
 			fp->private_data = soft->cxdev;
+			unlock_kernel();
 			return 0;
 			return 0;
 		}
 		}
 	}
 	}
 
 
+	unlock_kernel();
 	return -ENODEV;
 	return -ENODEV;
 }
 }
 
 

+ 8 - 2
drivers/char/mem.c

@@ -26,6 +26,7 @@
 #include <linux/bootmem.h>
 #include <linux/bootmem.h>
 #include <linux/splice.h>
 #include <linux/splice.h>
 #include <linux/pfn.h>
 #include <linux/pfn.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/io.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)
 static int memory_open(struct inode * inode, struct file * filp)
 {
 {
+	int ret = 0;
+
+	lock_kernel();
 	switch (iminor(inode)) {
 	switch (iminor(inode)) {
 		case 1:
 		case 1:
 			filp->f_op = &mem_fops;
 			filp->f_op = &mem_fops;
@@ -932,11 +936,13 @@ static int memory_open(struct inode * inode, struct file * filp)
 			break;
 			break;
 #endif
 #endif
 		default:
 		default:
+			unlock_kernel();
 			return -ENXIO;
 			return -ENXIO;
 	}
 	}
 	if (filp->f_op && filp->f_op->open)
 	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 = {
 static const struct file_operations memory_fops = {

+ 3 - 0
drivers/char/misc.c

@@ -49,6 +49,7 @@
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 
 /*
 /*
  * Head entry for the doubly linked miscdevice list
  * 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;
 	int err = -ENODEV;
 	const struct file_operations *old_fops, *new_fops = NULL;
 	const struct file_operations *old_fops, *new_fops = NULL;
 	
 	
+	lock_kernel();
 	mutex_lock(&misc_mtx);
 	mutex_lock(&misc_mtx);
 	
 	
 	list_for_each_entry(c, &misc_list, list) {
 	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);
 	fops_put(old_fops);
 fail:
 fail:
 	mutex_unlock(&misc_mtx);
 	mutex_unlock(&misc_mtx);
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 2 - 0
drivers/char/mwave/mwavedd.c

@@ -56,6 +56,7 @@
 #include <linux/serial.h>
 #include <linux/serial.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_8250.h>
 #include "smapi.h"
 #include "smapi.h"
@@ -100,6 +101,7 @@ static int mwave_open(struct inode *inode, struct file *file)
 	PRINTK_2(TRACE_MWAVE,
 	PRINTK_2(TRACE_MWAVE,
 		"mwavedd::mwave_open, exit return retval %x\n", retval);
 		"mwavedd::mwave_open, exit return retval %x\n", retval);
 
 
+	cycle_kernel_lock();
 	return retval;
 	return retval;
 }
 }
 
 

+ 4 - 0
drivers/char/nvram.c

@@ -107,6 +107,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/io.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
@@ -333,12 +334,14 @@ nvram_ioctl(struct inode *inode, struct file *file,
 static int
 static int
 nvram_open(struct inode *inode, struct file *file)
 nvram_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock(&nvram_state_lock);
 	spin_lock(&nvram_state_lock);
 
 
 	if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
 	if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
 	    (nvram_open_mode & NVRAM_EXCL) ||
 	    (nvram_open_mode & NVRAM_EXCL) ||
 	    ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
 	    ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
 		spin_unlock(&nvram_state_lock);
 		spin_unlock(&nvram_state_lock);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 
@@ -349,6 +352,7 @@ nvram_open(struct inode *inode, struct file *file)
 	nvram_open_cnt++;
 	nvram_open_cnt++;
 
 
 	spin_unlock(&nvram_state_lock);
 	spin_unlock(&nvram_state_lock);
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 2 - 0
drivers/char/pc8736x_gpio.c

@@ -20,6 +20,7 @@
 #include <linux/mutex.h>
 #include <linux/mutex.h>
 #include <linux/nsc_gpio.h>
 #include <linux/nsc_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
 #define DEVNAME "pc8736x_gpio"
 #define DEVNAME "pc8736x_gpio"
@@ -217,6 +218,7 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file)
 	unsigned m = iminor(inode);
 	unsigned m = iminor(inode);
 	file->private_data = &pc8736x_gpio_ops;
 	file->private_data = &pc8736x_gpio_ops;
 
 
+	cycle_kernel_lock();
 	dev_dbg(&pdev->dev, "open %d\n", m);
 	dev_dbg(&pdev->dev, "open %d\n", m);
 
 
 	if (m >= PC8736X_GPIO_CT)
 	if (m >= PC8736X_GPIO_CT)

+ 2 - 0
drivers/char/ppdev.c

@@ -66,6 +66,7 @@
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/major.h>
 #include <linux/major.h>
 #include <linux/ppdev.h>
 #include <linux/ppdev.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
 #define PP_VERSION "ppdev: user-space parallel port driver"
 #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);
 	unsigned int minor = iminor(inode);
 	struct pp_struct *pp;
 	struct pp_struct *pp;
 
 
+	cycle_kernel_lock();
 	if (minor >= PARPORT_MAX)
 	if (minor >= PARPORT_MAX)
 		return -ENXIO;
 		return -ENXIO;
 
 

+ 3 - 0
drivers/char/raw.c

@@ -19,6 +19,7 @@
 #include <linux/cdev.h>
 #include <linux/cdev.h>
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
@@ -53,6 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
 		return 0;
 		return 0;
 	}
 	}
 
 
+	lock_kernel();
 	mutex_lock(&raw_mutex);
 	mutex_lock(&raw_mutex);
 
 
 	/*
 	/*
@@ -79,6 +81,7 @@ static int raw_open(struct inode *inode, struct file *filp)
 			bdev->bd_inode->i_mapping;
 			bdev->bd_inode->i_mapping;
 	filp->private_data = bdev;
 	filp->private_data = bdev;
 	mutex_unlock(&raw_mutex);
 	mutex_unlock(&raw_mutex);
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 out2:
 out2:

+ 4 - 0
drivers/char/rtc.c

@@ -73,6 +73,7 @@
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/sysctl.h>
 #include <linux/sysctl.h>
 #include <linux/wait.h>
 #include <linux/wait.h>
 #include <linux/bcd.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. */
  * needed here. Or anywhere else in this driver. */
 static int rtc_open(struct inode *inode, struct file *file)
 static int rtc_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	spin_lock_irq(&rtc_lock);
 	spin_lock_irq(&rtc_lock);
 
 
 	if (rtc_status & RTC_IS_OPEN)
 	if (rtc_status & RTC_IS_OPEN)
@@ -743,10 +745,12 @@ static int rtc_open(struct inode *inode, struct file *file)
 
 
 	rtc_irq_data = 0;
 	rtc_irq_data = 0;
 	spin_unlock_irq(&rtc_lock);
 	spin_unlock_irq(&rtc_lock);
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 out_busy:
 out_busy:
 	spin_unlock_irq(&rtc_lock);
 	spin_unlock_irq(&rtc_lock);
+	unlock_kernel();
 	return -EBUSY;
 	return -EBUSY;
 }
 }
 
 

+ 2 - 0
drivers/char/scx200_gpio.c

@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/io.h>
 
 
@@ -51,6 +52,7 @@ static int scx200_gpio_open(struct inode *inode, struct file *file)
 	unsigned m = iminor(inode);
 	unsigned m = iminor(inode);
 	file->private_data = &scx200_gpio_ops;
 	file->private_data = &scx200_gpio_ops;
 
 
+	cycle_kernel_lock();
 	if (m >= MAX_PINS)
 	if (m >= MAX_PINS)
 		return -EINVAL;
 		return -EINVAL;
 	return nonseekable_open(inode, file);
 	return nonseekable_open(inode, file);

+ 4 - 1
drivers/char/snsc.c

@@ -21,6 +21,7 @@
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <asm/sn/io.h>
 #include <asm/sn/io.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/module.h>
 #include <asm/sn/module.h>
@@ -104,6 +105,7 @@ scdrv_open(struct inode *inode, struct file *file)
 	file->private_data = sd;
 	file->private_data = sd;
 
 
 	/* hook this subchannel up to the system controller interrupt */
 	/* hook this subchannel up to the system controller interrupt */
+	lock_kernel();
 	rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt,
 	rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt,
 			 IRQF_SHARED | IRQF_DISABLED,
 			 IRQF_SHARED | IRQF_DISABLED,
 			 SYSCTL_BASENAME, sd);
 			 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);
 		ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch);
 		kfree(sd);
 		kfree(sd);
 		printk("%s: irq request failed (%d)\n", __func__, rv);
 		printk("%s: irq request failed (%d)\n", __func__, rv);
+		unlock_kernel();
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
-
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 0
drivers/char/sonypi.c

@@ -49,6 +49,7 @@
 #include <linux/err.h>
 #include <linux/err.h>
 #include <linux/kfifo.h>
 #include <linux/kfifo.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/io.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)
 static int sonypi_misc_open(struct inode *inode, struct file *file)
 {
 {
+	lock_kernel();
 	mutex_lock(&sonypi_device.lock);
 	mutex_lock(&sonypi_device.lock);
 	/* Flush input queue on first open */
 	/* Flush input queue on first open */
 	if (!sonypi_device.open_count)
 	if (!sonypi_device.open_count)
 		kfifo_reset(sonypi_device.fifo);
 		kfifo_reset(sonypi_device.fifo);
 	sonypi_device.open_count++;
 	sonypi_device.open_count++;
 	mutex_unlock(&sonypi_device.lock);
 	mutex_unlock(&sonypi_device.lock);
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 2 - 0
drivers/char/tb0219.c

@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/io.h>
 #include <asm/io.h>
 #include <asm/reboot.h>
 #include <asm/reboot.h>
@@ -236,6 +237,7 @@ static int tanbac_tb0219_open(struct inode *inode, struct file *file)
 {
 {
 	unsigned int minor;
 	unsigned int minor;
 
 
+	cycle_kernel_lock();
 	minor = iminor(inode);
 	minor = iminor(inode);
 	switch (minor) {
 	switch (minor) {
 	case 0:
 	case 0:

+ 12 - 7
drivers/char/tlclk.c

@@ -36,6 +36,7 @@
 #include <linux/ioport.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <linux/timer.h>
 #include <linux/sysfs.h>
 #include <linux/sysfs.h>
 #include <linux/device.h>
 #include <linux/device.h>
@@ -204,11 +205,14 @@ static int tlclk_open(struct inode *inode, struct file *filp)
 {
 {
 	int result;
 	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
 		/* this legacy device is always one per system and it doesn't
 		 * know how to handle multiple concurrent clients.
 		 * know how to handle multiple concurrent clients.
 		 */
 		 */
+		goto out;
+	}
 
 
 	/* Make sure there is no interrupt pending while
 	/* Make sure there is no interrupt pending while
 	 * initialising interrupt handler */
 	 * initialising interrupt handler */
@@ -218,13 +222,14 @@ static int tlclk_open(struct inode *inode, struct file *filp)
 	 * we can't share this IRQ */
 	 * we can't share this IRQ */
 	result = request_irq(telclk_interrupt, &tlclk_interrupt,
 	result = request_irq(telclk_interrupt, &tlclk_interrupt,
 			     IRQF_DISABLED, "telco_clock", tlclk_interrupt);
 			     IRQF_DISABLED, "telco_clock", tlclk_interrupt);
-	if (result == -EBUSY) {
+	if (result == -EBUSY)
 		printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n");
 		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)
 static int tlclk_release(struct inode *inode, struct file *filp)

+ 5 - 0
drivers/char/tpm/tpm.c

@@ -26,6 +26,7 @@
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 
 
 #include "tpm.h"
 #include "tpm.h"
 
 
@@ -897,6 +898,7 @@ int tpm_open(struct inode *inode, struct file *file)
 	int rc = 0, minor = iminor(inode);
 	int rc = 0, minor = iminor(inode);
 	struct tpm_chip *chip = NULL, *pos;
 	struct tpm_chip *chip = NULL, *pos;
 
 
+	lock_kernel();
 	spin_lock(&driver_lock);
 	spin_lock(&driver_lock);
 
 
 	list_for_each_entry(pos, &tpm_chip_list, list) {
 	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) {
 	if (chip->data_buffer == NULL) {
 		chip->num_opens--;
 		chip->num_opens--;
 		put_device(chip->dev);
 		put_device(chip->dev);
+		unlock_kernel();
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
 	atomic_set(&chip->data_pending, 0);
 	atomic_set(&chip->data_pending, 0);
 
 
 	file->private_data = chip;
 	file->private_data = chip;
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
 err_out:
 err_out:
 	spin_unlock(&driver_lock);
 	spin_unlock(&driver_lock);
+	unlock_kernel();
 	return rc;
 	return rc;
 }
 }
 EXPORT_SYMBOL_GPL(tpm_open);
 EXPORT_SYMBOL_GPL(tpm_open);

+ 34 - 7
drivers/char/tty_io.c

@@ -2665,7 +2665,7 @@ static void release_dev(struct file *filp)
  *		 ->siglock protects ->signal/->sighand
  *		 ->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;
 	struct tty_struct *tty;
 	int noctty, retval;
 	int noctty, retval;
@@ -2779,6 +2779,19 @@ got_driver:
 	return 0;
 	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
 #ifdef CONFIG_UNIX98_PTYS
 /**
 /**
  *	ptmx_open		-	open a unix 98 pty master
  *	ptmx_open		-	open a unix 98 pty master
@@ -2792,7 +2805,7 @@ got_driver:
  *		allocated_ptys_lock handles the list of free pty numbers
  *		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;
 	struct tty_struct *tty;
 	int retval;
 	int retval;
@@ -2831,6 +2844,16 @@ out:
 	devpts_kill_index(index);
 	devpts_kill_index(index);
 	return retval;
 	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
 #endif
 
 
 /**
 /**
@@ -2886,15 +2909,16 @@ static int tty_fasync(int fd, struct file *filp, int on)
 {
 {
 	struct tty_struct *tty;
 	struct tty_struct *tty;
 	unsigned long flags;
 	unsigned long flags;
-	int retval;
+	int retval = 0;
 
 
+	lock_kernel();
 	tty = (struct tty_struct *)filp->private_data;
 	tty = (struct tty_struct *)filp->private_data;
 	if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync"))
 	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);
 	retval = fasync_helper(fd, filp, on, &tty->fasync);
 	if (retval <= 0)
 	if (retval <= 0)
-		return retval;
+		goto out;
 
 
 	if (on) {
 	if (on) {
 		enum pid_type type;
 		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);
 		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 		retval = __f_setown(filp, pid, type, 0);
 		retval = __f_setown(filp, pid, type, 0);
 		if (retval)
 		if (retval)
-			return retval;
+			goto out;
 	} else {
 	} else {
 		if (!tty->fasync && !waitqueue_active(&tty->read_wait))
 		if (!tty->fasync && !waitqueue_active(&tty->read_wait))
 			tty->minimum_to_wake = N_TTY_BUF_SIZE;
 			tty->minimum_to_wake = N_TTY_BUF_SIZE;
 	}
 	}
-	return 0;
+	retval = 0;
+out:
+	unlock_kernel();
+	return retval;
 }
 }
 
 
 /**
 /**

+ 7 - 2
drivers/char/vc_screen.c

@@ -34,6 +34,7 @@
 #include <linux/kbd_kern.h>
 #include <linux/kbd_kern.h>
 #include <linux/console.h>
 #include <linux/console.h>
 #include <linux/device.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <asm/byteorder.h>
@@ -460,9 +461,13 @@ static int
 vcs_open(struct inode *inode, struct file *filp)
 vcs_open(struct inode *inode, struct file *filp)
 {
 {
 	unsigned int currcons = iminor(inode) & 127;
 	unsigned int currcons = iminor(inode) & 127;
+	int ret = 0;
+	
+	lock_kernel();
 	if(currcons && !vc_cons_allocated(currcons-1))
 	if(currcons && !vc_cons_allocated(currcons-1))
-		return -ENXIO;
-	return 0;
+		ret = -ENXIO;
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static const struct file_operations vcs_fops = {
 static const struct file_operations vcs_fops = {

+ 3 - 0
drivers/char/viotape.c

@@ -46,6 +46,7 @@
 #include <linux/completion.h>
 #include <linux/completion.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 #include <asm/ioctls.h>
@@ -687,6 +688,7 @@ static int viotap_open(struct inode *inode, struct file *file)
 	if (op == NULL)
 	if (op == NULL)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	get_dev_info(file->f_path.dentry->d_inode, &devi);
 	get_dev_info(file->f_path.dentry->d_inode, &devi);
 
 
 	/* Note: We currently only support one mode! */
 	/* 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:
 	free_op_struct(op);
 	free_op_struct(op);
+	unlock_kernel();
 	return ret;
 	return ret;
 }
 }
 
 

+ 2 - 0
drivers/char/vr41xx_giu.c

@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
+#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 
 
@@ -547,6 +548,7 @@ static int gpio_open(struct inode *inode, struct file *file)
 {
 {
 	unsigned int pin;
 	unsigned int pin;
 
 
+	cycle_kernel_lock();
 	pin = iminor(inode);
 	pin = iminor(inode);
 	if (pin >= giu_nr_pins)
 	if (pin >= giu_nr_pins)
 		return -EBADF;
 		return -EBADF;

+ 5 - 1
drivers/char/xilinx_hwicap/xilinx_hwicap.c

@@ -85,6 +85,7 @@
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <linux/sysctl.h>
 #include <linux/sysctl.h>
 #include <linux/version.h>
 #include <linux/version.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
@@ -504,11 +505,12 @@ static int hwicap_open(struct inode *inode, struct file *file)
 	struct hwicap_drvdata *drvdata;
 	struct hwicap_drvdata *drvdata;
 	int status;
 	int status;
 
 
+	lock_kernel();
 	drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
 	drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
 
 
 	status = mutex_lock_interruptible(&drvdata->sem);
 	status = mutex_lock_interruptible(&drvdata->sem);
 	if (status)
 	if (status)
-		return status;
+		goto out;
 
 
 	if (drvdata->is_open) {
 	if (drvdata->is_open) {
 		status = -EBUSY;
 		status = -EBUSY;
@@ -528,6 +530,8 @@ static int hwicap_open(struct inode *inode, struct file *file)
 
 
  error:
  error:
 	mutex_unlock(&drvdata->sem);
 	mutex_unlock(&drvdata->sem);
+ out:
+	unlock_kernel();
 	return status;
 	return status;
 }
 }
 
 

+ 7 - 2
drivers/gpu/drm/drm_fops.c

@@ -37,6 +37,7 @@
 #include "drmP.h"
 #include "drmP.h"
 #include "drm_sarea.h"
 #include "drm_sarea.h"
 #include <linux/poll.h>
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 
 
 static int drm_open_helper(struct inode *inode, struct file *filp,
 static int drm_open_helper(struct inode *inode, struct file *filp,
 			   struct drm_device * dev);
 			   struct drm_device * dev);
@@ -174,12 +175,14 @@ int drm_stub_open(struct inode *inode, struct file *filp)
 
 
 	DRM_DEBUG("\n");
 	DRM_DEBUG("\n");
 
 
+	/* BKL pushdown: note that nothing else serializes idr_find() */
+	lock_kernel();
 	minor = idr_find(&drm_minors_idr, minor_id);
 	minor = idr_find(&drm_minors_idr, minor_id);
 	if (!minor)
 	if (!minor)
-		return -ENODEV;
+		goto out;
 
 
 	if (!(dev = minor->dev))
 	if (!(dev = minor->dev))
-		return -ENODEV;
+		goto out;
 
 
 	old_fops = filp->f_op;
 	old_fops = filp->f_op;
 	filp->f_op = fops_get(&dev->driver->fops);
 	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);
 	fops_put(old_fops);
 
 
+out:
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 3 - 0
drivers/hid/hidraw.c

@@ -30,6 +30,7 @@
 #include <linux/major.h>
 #include <linux/major.h>
 #include <linux/hid.h>
 #include <linux/hid.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 
 #include <linux/hidraw.h>
 #include <linux/hidraw.h>
 
 
@@ -157,6 +158,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
 	struct hidraw_list *list;
 	struct hidraw_list *list;
 	int err = 0;
 	int err = 0;
 
 
+	lock_kernel();
 	if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) {
 	if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) {
 		err = -ENOMEM;
 		err = -ENOMEM;
 		goto out;
 		goto out;
@@ -183,6 +185,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
 out_unlock:
 out_unlock:
 	spin_unlock(&minors_lock);
 	spin_unlock(&minors_lock);
 out:
 out:
+	unlock_kernel();
 	return err;
 	return err;
 
 
 }
 }

+ 16 - 6
drivers/i2c/i2c-dev.c

@@ -34,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/list.h>
 #include <linux/i2c.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 #include <linux/i2c-dev.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
 static struct i2c_driver i2cdev_driver;
 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_client *client;
 	struct i2c_adapter *adap;
 	struct i2c_adapter *adap;
 	struct i2c_dev *i2c_dev;
 	struct i2c_dev *i2c_dev;
+	int ret = 0;
 
 
+	lock_kernel();
 	i2c_dev = i2c_dev_get_by_minor(minor);
 	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);
 	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
 	/* This creates an anonymous i2c_client, which may later be
 	 * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
 	 * 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);
 	client = kzalloc(sizeof(*client), GFP_KERNEL);
 	if (!client) {
 	if (!client) {
 		i2c_put_adapter(adap);
 		i2c_put_adapter(adap);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out;
 	}
 	}
 	snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
 	snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
 	client->driver = &i2cdev_driver;
 	client->driver = &i2cdev_driver;
@@ -468,7 +476,9 @@ static int i2cdev_open(struct inode *inode, struct file *file)
 	client->adapter = adap;
 	client->adapter = adap;
 	file->private_data = client;
 	file->private_data = client;
 
 
-	return 0;
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int i2cdev_release(struct inode *inode, struct file *file)
 static int i2cdev_release(struct inode *inode, struct file *file)

+ 6 - 1
drivers/ide/ide-tape.c

@@ -2421,9 +2421,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
 	if (i >= MAX_HWIFS * MAX_DRIVES)
 	if (i >= MAX_HWIFS * MAX_DRIVES)
 		return -ENXIO;
 		return -ENXIO;
 
 
+	lock_kernel();
 	tape = ide_tape_chrdev_get(i);
 	tape = ide_tape_chrdev_get(i);
-	if (!tape)
+	if (!tape) {
+		unlock_kernel();
 		return -ENXIO;
 		return -ENXIO;
+	}
 
 
 	debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
 	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;
 	return 0;
 
 
 out_put_tape:
 out_put_tape:
 	ide_tape_put(tape);
 	ide_tape_put(tape);
+	unlock_kernel();
 	return retval;
 	return retval;
 }
 }
 
 

+ 2 - 0
drivers/infiniband/core/ucm.c

@@ -45,6 +45,7 @@
 #include <linux/cdev.h>
 #include <linux/cdev.h>
 #include <linux/idr.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/uaccess.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;
 	struct ib_ucm_file *file;
 
 
+	cycle_kernel_lock();
 	file = kmalloc(sizeof(*file), GFP_KERNEL);
 	file = kmalloc(sizeof(*file), GFP_KERNEL);
 	if (!file)
 	if (!file)
 		return -ENOMEM;
 		return -ENOMEM;

+ 3 - 0
drivers/infiniband/core/ucma.c

@@ -38,6 +38,7 @@
 #include <linux/in.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/in6.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 
 
 #include <rdma/rdma_user_cm.h>
 #include <rdma/rdma_user_cm.h>
 #include <rdma/ib_marshall.h>
 #include <rdma/ib_marshall.h>
@@ -1156,6 +1157,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
 	if (!file)
 	if (!file)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	INIT_LIST_HEAD(&file->event_list);
 	INIT_LIST_HEAD(&file->event_list);
 	INIT_LIST_HEAD(&file->ctx_list);
 	INIT_LIST_HEAD(&file->ctx_list);
 	init_waitqueue_head(&file->poll_wait);
 	init_waitqueue_head(&file->poll_wait);
@@ -1163,6 +1165,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
 
 
 	filp->private_data = file;
 	filp->private_data = file;
 	file->filp = filp;
 	file->filp = filp;
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 13 - 0
drivers/infiniband/core/user_mad.c

@@ -777,6 +777,19 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
 }
 }
 #endif
 #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)
 static int ib_umad_open(struct inode *inode, struct file *filp)
 {
 {
 	struct ib_umad_port *port;
 	struct ib_umad_port *port;

+ 12 - 1
drivers/infiniband/core/uverbs_main.c

@@ -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);
 		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)
 static int ib_uverbs_open(struct inode *inode, struct file *filp)
 {
 {
 	struct ib_uverbs_device *dev;
 	struct ib_uverbs_device *dev;
@@ -651,7 +663,6 @@ err_module:
 
 
 err:
 err:
 	kref_put(&dev->ref, ib_uverbs_release_dev);
 	kref_put(&dev->ref, ib_uverbs_release_dev);
-
 	return ret;
 	return ret;
 }
 }
 
 

+ 2 - 0
drivers/infiniband/hw/ipath/ipath_file_ops.c

@@ -39,6 +39,7 @@
 #include <linux/highmem.h>
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/io.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 #include <asm/pgtable.h>
 #include <asm/pgtable.h>
 
 
 #include "ipath_kernel.h"
 #include "ipath_kernel.h"
@@ -1815,6 +1816,7 @@ done:
 static int ipath_open(struct inode *in, struct file *fp)
 static int ipath_open(struct inode *in, struct file *fp)
 {
 {
 	/* The real work is performed later in ipath_assign_port() */
 	/* The real work is performed later in ipath_assign_port() */
+	cycle_kernel_lock();
 	fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL);
 	fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL);
 	return fp->private_data ? 0 : -ENOMEM;
 	return fp->private_data ? 0 : -ENOMEM;
 }
 }

+ 12 - 4
drivers/input/input.c

@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
 #include <linux/rcupdate.h>
+#include <linux/smp_lock.h>
 
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input core");
 MODULE_DESCRIPTION("Input core");
@@ -1588,13 +1589,17 @@ EXPORT_SYMBOL(input_unregister_handle);
 
 
 static int input_open_file(struct inode *inode, struct file *file)
 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;
 	const struct file_operations *old_fops, *new_fops = NULL;
 	int err;
 	int err;
 
 
+	lock_kernel();
 	/* No load-on-demand here? */
 	/* 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",
 	 * 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) {
 	if (!new_fops->open) {
 		fops_put(new_fops);
 		fops_put(new_fops);
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 	}
 	old_fops = file->f_op;
 	old_fops = file->f_op;
 	file->f_op = new_fops;
 	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);
 		file->f_op = fops_get(old_fops);
 	}
 	}
 	fops_put(old_fops);
 	fops_put(old_fops);
+out:
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 2 - 0
drivers/input/misc/hp_sdc_rtc.c

@@ -35,6 +35,7 @@
 
 
 #include <linux/hp_sdc.h>
 #include <linux/hp_sdc.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/module.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)
 static int hp_sdc_rtc_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
         return 0;
         return 0;
 }
 }
 
 

+ 3 - 0
drivers/input/misc/uinput.c

@@ -37,6 +37,7 @@
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/uinput.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)
 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)
 	if (!newdev)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	mutex_init(&newdev->mutex);
 	mutex_init(&newdev->mutex);
 	spin_lock_init(&newdev->requests_lock);
 	spin_lock_init(&newdev->requests_lock);
 	init_waitqueue_head(&newdev->requests_waitq);
 	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;
 	newdev->state = UIST_NEW_DEVICE;
 
 
 	file->private_data = newdev;
 	file->private_data = newdev;
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 10 - 2
drivers/input/mousedev.c

@@ -14,6 +14,7 @@
 #define MOUSEDEV_MIX		31
 #define MOUSEDEV_MIX		31
 
 
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/init.h>
@@ -545,16 +546,21 @@ static int mousedev_open(struct inode *inode, struct file *file)
 	if (i >= MOUSEDEV_MINORS)
 	if (i >= MOUSEDEV_MINORS)
 		return -ENODEV;
 		return -ENODEV;
 
 
+	lock_kernel();
 	error = mutex_lock_interruptible(&mousedev_table_mutex);
 	error = mutex_lock_interruptible(&mousedev_table_mutex);
-	if (error)
+	if (error) {
+		unlock_kernel();
 		return error;
 		return error;
+	}
 	mousedev = mousedev_table[i];
 	mousedev = mousedev_table[i];
 	if (mousedev)
 	if (mousedev)
 		get_device(&mousedev->dev);
 		get_device(&mousedev->dev);
 	mutex_unlock(&mousedev_table_mutex);
 	mutex_unlock(&mousedev_table_mutex);
 
 
-	if (!mousedev)
+	if (!mousedev) {
+		unlock_kernel();
 		return -ENODEV;
 		return -ENODEV;
+	}
 
 
 	client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
 	client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
 	if (!client) {
 	if (!client) {
@@ -573,6 +579,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
 		goto err_free_client;
 		goto err_free_client;
 
 
 	file->private_data = client;
 	file->private_data = client;
+	unlock_kernel();
 	return 0;
 	return 0;
 
 
  err_free_client:
  err_free_client:
@@ -580,6 +587,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
 	kfree(client);
 	kfree(client);
  err_put_mousedev:
  err_put_mousedev:
 	put_device(&mousedev->dev);
 	put_device(&mousedev->dev);
+	unlock_kernel();
 	return error;
 	return error;
 }
 }
 
 

+ 5 - 1
drivers/input/serio/serio_raw.c

@@ -10,6 +10,7 @@
  */
  */
 
 
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/serio.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;
 	struct serio_raw_list *list;
 	int retval = 0;
 	int retval = 0;
 
 
+	lock_kernel();
 	retval = mutex_lock_interruptible(&serio_raw_mutex);
 	retval = mutex_lock_interruptible(&serio_raw_mutex);
 	if (retval)
 	if (retval)
-		return retval;
+		goto out_bkl;
 
 
 	if (!(serio_raw = serio_raw_locate(iminor(inode)))) {
 	if (!(serio_raw = serio_raw_locate(iminor(inode)))) {
 		retval = -ENODEV;
 		retval = -ENODEV;
@@ -108,6 +110,8 @@ static int serio_raw_open(struct inode *inode, struct file *file)
 
 
 out:
 out:
 	mutex_unlock(&serio_raw_mutex);
 	mutex_unlock(&serio_raw_mutex);
+out_bkl:
+	unlock_kernel();
 	return retval;
 	return retval;
 }
 }
 
 

+ 11 - 6
drivers/isdn/capi/capi.c

@@ -20,6 +20,7 @@
 #include <linux/signal.h>
 #include <linux/signal.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <linux/timer.h>
 #include <linux/timer.h>
 #include <linux/wait.h>
 #include <linux/wait.h>
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -983,13 +984,17 @@ capi_ioctl(struct inode *inode, struct file *file,
 static int
 static int
 capi_open(struct inode *inode, struct file *file)
 capi_open(struct inode *inode, struct file *file)
 {
 {
+	int ret;
+	
+	lock_kernel();
 	if (file->private_data)
 	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
 static int

+ 11 - 5
drivers/isdn/hardware/eicon/divamnt.c

@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
 #include "platform.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)
 static int maint_open(struct inode *ino, struct file *filep)
 {
 {
+	int ret;
+
+	lock_kernel();
 	/* only one open is allowed, so we test
 	/* only one open is allowed, so we test
 	   it atomically */
 	   it atomically */
 	if (test_and_set_bit(0, &opened))
 	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)
 static int maint_close(struct inode *ino, struct file *filep)

+ 2 - 0
drivers/isdn/hardware/eicon/divasi.c

@@ -17,6 +17,7 @@
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/skbuff.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
 #include "platform.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)
 static int um_idi_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
 	return (0);
 	return (0);
 }
 }
 
 

+ 2 - 0
drivers/isdn/hardware/eicon/divasmain.c

@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/list.h>
 #include <linux/poll.h>
 #include <linux/poll.h>
 #include <linux/kmod.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 
 #include "platform.h"
 #include "platform.h"
 #undef ID_MASK
 #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)
 static int divas_open(struct inode *inode, struct file *file)
 {
 {
+	cycle_kernel_lock();
 	return (0);
 	return (0);
 }
 }
 
 

+ 2 - 1
drivers/isdn/i4l/isdn_common.c

@@ -1732,7 +1732,7 @@ isdn_open(struct inode *ino, struct file *filep)
 	int chidx;
 	int chidx;
 	int retval = -ENODEV;
 	int retval = -ENODEV;
 
 
-
+	lock_kernel();
 	if (minor == ISDN_MINOR_STATUS) {
 	if (minor == ISDN_MINOR_STATUS) {
 		infostruct *p;
 		infostruct *p;
 
 
@@ -1783,6 +1783,7 @@ isdn_open(struct inode *ino, struct file *filep)
 #endif
 #endif
  out:
  out:
 	nonseekable_open(ino, filep);
 	nonseekable_open(ino, filep);
+	unlock_kernel();
 	return retval;
 	return retval;
 }
 }
 
 

+ 13 - 5
drivers/macintosh/adb.c

@@ -644,12 +644,18 @@ do_adb_query(struct adb_request *req)
 static int adb_open(struct inode *inode, struct file *file)
 static int adb_open(struct inode *inode, struct file *file)
 {
 {
 	struct adbdev_state *state;
 	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);
 	state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
-	if (state == 0)
-		return -ENOMEM;
+	if (state == 0) {
+		ret = -ENOMEM;
+		goto out;
+	}
 	file->private_data = state;
 	file->private_data = state;
 	spin_lock_init(&state->lock);
 	spin_lock_init(&state->lock);
 	atomic_set(&state->n_pending, 0);
 	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);
 	init_waitqueue_head(&state->wait_queue);
 	state->inuse = 1;
 	state->inuse = 1;
 
 
-	return 0;
+out:
+	unlock_kernel();
+	return ret;
 }
 }
 
 
 static int adb_release(struct inode *inode, struct file *file)
 static int adb_release(struct inode *inode, struct file *file)

+ 2 - 0
drivers/macintosh/ans-lcd.c

@@ -3,6 +3,7 @@
  */
  */
 
 
 #include <linux/types.h>
 #include <linux/types.h>
+#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
@@ -119,6 +120,7 @@ anslcd_ioctl( struct inode * inode, struct file * file,
 static int
 static int
 anslcd_open( struct inode * inode, struct file * file )
 anslcd_open( struct inode * inode, struct file * file )
 {
 {
+	cycle_kernel_lock();
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 0
drivers/macintosh/smu.c

@@ -19,6 +19,7 @@
  *    the userland interface
  *    the userland interface
  */
  */
 
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/device.h>
@@ -1086,10 +1087,12 @@ static int smu_open(struct inode *inode, struct file *file)
 	pp->mode = smu_file_commands;
 	pp->mode = smu_file_commands;
 	init_waitqueue_head(&pp->wait);
 	init_waitqueue_head(&pp->wait);
 
 
+	lock_kernel();
 	spin_lock_irqsave(&smu_clist_lock, flags);
 	spin_lock_irqsave(&smu_clist_lock, flags);
 	list_add(&pp->list, &smu_clist);
 	list_add(&pp->list, &smu_clist);
 	spin_unlock_irqrestore(&smu_clist_lock, flags);
 	spin_unlock_irqrestore(&smu_clist_lock, flags);
 	file->private_data = pp;
 	file->private_data = pp;
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }

+ 3 - 0
drivers/macintosh/via-pmu.c

@@ -18,6 +18,7 @@
  *
  *
  */
  */
 #include <stdarg.h>
 #include <stdarg.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
@@ -2047,6 +2048,7 @@ pmu_open(struct inode *inode, struct file *file)
 	pp->rb_get = pp->rb_put = 0;
 	pp->rb_get = pp->rb_put = 0;
 	spin_lock_init(&pp->lock);
 	spin_lock_init(&pp->lock);
 	init_waitqueue_head(&pp->wait);
 	init_waitqueue_head(&pp->wait);
+	lock_kernel();
 	spin_lock_irqsave(&all_pvt_lock, flags);
 	spin_lock_irqsave(&all_pvt_lock, flags);
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
 	pp->backlight_locker = 0;
 	pp->backlight_locker = 0;
@@ -2054,6 +2056,7 @@ pmu_open(struct inode *inode, struct file *file)
 	list_add(&pp->list, &all_pmu_pvt);
 	list_add(&pp->list, &all_pmu_pvt);
 	spin_unlock_irqrestore(&all_pvt_lock, flags);
 	spin_unlock_irqrestore(&all_pvt_lock, flags);
 	file->private_data = pp;
 	file->private_data = pp;
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 0
drivers/media/dvb/dvb-core/dvbdev.c

@@ -32,6 +32,7 @@
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/cdev.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include "dvbdev.h"
 #include "dvbdev.h"
 
 
 static int dvbdev_debug;
 static int dvbdev_debug;
@@ -74,6 +75,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
 {
 {
 	struct dvb_device *dvbdev;
 	struct dvb_device *dvbdev;
 
 
+	lock_kernel();
 	dvbdev = dvbdev_find_device (iminor(inode));
 	dvbdev = dvbdev_find_device (iminor(inode));
 
 
 	if (dvbdev && dvbdev->fops) {
 	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);
 			file->f_op = fops_get(old_fops);
 		}
 		}
 		fops_put(old_fops);
 		fops_put(old_fops);
+		unlock_kernel();
 		return err;
 		return err;
 	}
 	}
+	unlock_kernel();
 	return -ENODEV;
 	return -ENODEV;
 }
 }
 
 

+ 4 - 0
drivers/media/radio/miropcm20-rds.c

@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/delay.h>
 #include <linux/delay.h>
@@ -27,13 +28,16 @@ static int rds_f_open(struct inode *in, struct file *fi)
 	if (rds_users)
 	if (rds_users)
 		return -EBUSY;
 		return -EBUSY;
 
 
+	lock_kernel();
 	rds_users++;
 	rds_users++;
 	if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) {
 	if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) {
 		rds_users--;
 		rds_users--;
 		printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n");
 		printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n");
+		unlock_kernel();
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
+	unlock_kernel();
 	return 0;
 	return 0;
 }
 }
 
 

+ 4 - 0
drivers/media/video/videodev.c

@@ -36,6 +36,7 @@
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/system.h>
 
 
@@ -442,6 +443,7 @@ static int video_open(struct inode *inode, struct file *file)
 
 
 	if(minor>=VIDEO_NUM_DEVICES)
 	if(minor>=VIDEO_NUM_DEVICES)
 		return -ENODEV;
 		return -ENODEV;
+	lock_kernel();
 	mutex_lock(&videodev_lock);
 	mutex_lock(&videodev_lock);
 	vfl=video_device[minor];
 	vfl=video_device[minor];
 	if(vfl==NULL) {
 	if(vfl==NULL) {
@@ -451,6 +453,7 @@ static int video_open(struct inode *inode, struct file *file)
 		vfl=video_device[minor];
 		vfl=video_device[minor];
 		if (vfl==NULL) {
 		if (vfl==NULL) {
 			mutex_unlock(&videodev_lock);
 			mutex_unlock(&videodev_lock);
+			unlock_kernel();
 			return -ENODEV;
 			return -ENODEV;
 		}
 		}
 	}
 	}
@@ -464,6 +467,7 @@ static int video_open(struct inode *inode, struct file *file)
 	}
 	}
 	fops_put(old_fops);
 	fops_put(old_fops);
 	mutex_unlock(&videodev_lock);
 	mutex_unlock(&videodev_lock);
+	unlock_kernel();
 	return err;
 	return err;
 }
 }
 
 

+ 5 - 1
drivers/message/fusion/mptctl.c

@@ -548,11 +548,15 @@ static int
 mptctl_fasync(int fd, struct file *filep, int mode)
 mptctl_fasync(int fd, struct file *filep, int mode)
 {
 {
 	MPT_ADAPTER	*ioc;
 	MPT_ADAPTER	*ioc;
+	int ret;
 
 
+	lock_kernel();
 	list_for_each_entry(ioc, &ioc_list, list)
 	list_for_each_entry(ioc, &ioc_list, list)
 		ioc->aen_event_read_flag=0;
 		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
 static int

+ 8 - 4
drivers/message/i2o/i2o_config.c

@@ -1061,6 +1061,7 @@ static int cfg_open(struct inode *inode, struct file *file)
 	if (!tmp)
 	if (!tmp)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	lock_kernel();
 	file->private_data = (void *)(i2o_cfg_info_id++);
 	file->private_data = (void *)(i2o_cfg_info_id++);
 	tmp->fp = file;
 	tmp->fp = file;
 	tmp->fasync = NULL;
 	tmp->fasync = NULL;
@@ -1074,6 +1075,7 @@ static int cfg_open(struct inode *inode, struct file *file)
 	spin_lock_irqsave(&i2o_config_lock, flags);
 	spin_lock_irqsave(&i2o_config_lock, flags);
 	open_files = tmp;
 	open_files = tmp;
 	spin_unlock_irqrestore(&i2o_config_lock, flags);
 	spin_unlock_irqrestore(&i2o_config_lock, flags);
+	unlock_kernel();
 
 
 	return 0;
 	return 0;
 }
 }
@@ -1082,15 +1084,17 @@ static int cfg_fasync(int fd, struct file *fp, int on)
 {
 {
 	ulong id = (ulong) fp->private_data;
 	ulong id = (ulong) fp->private_data;
 	struct i2o_cfg_info *p;
 	struct i2o_cfg_info *p;
+	int ret = -EBADF;
 
 
+	lock_kernel();
 	for (p = open_files; p; p = p->next)
 	for (p = open_files; p; p = p->next)
 		if (p->q_id == id)
 		if (p->q_id == id)
 			break;
 			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)
 static int cfg_release(struct inode *inode, struct file *file)

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio