aboutsummaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-05-18 15:32:43 -0600
committerJonathan Corbet <corbet@lwn.net>2008-06-20 14:05:53 -0600
commitf2b9857eee17797541b845782ade4d7a9d50f843 (patch)
tree914a00afee2ff953199f99f7cf869e3fd83b36bd /drivers/char
parent0b2806768899dba5967bcd4a3b93eaed9a1dc4f3 (diff)
Add a bunch of cycle_kernel_lock() calls
All of the open() functions which don't need the BKL on their face may still depend on its acquisition to serialize opens against driver initialization. So make those functions acquire then release the BKL to be on the safe side. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/cs5535_gpio.c4
-rw-r--r--drivers/char/dtlk.c5
-rw-r--r--drivers/char/ip2/ip2main.c34
-rw-r--r--drivers/char/pc8736x_gpio.c3
-rw-r--r--drivers/char/ppdev.c3
-rw-r--r--drivers/char/scx200_gpio.c3
-rw-r--r--drivers/char/tb0219.c3
-rw-r--r--drivers/char/vr41xx_giu.c4
8 files changed, 17 insertions, 42 deletions
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c
index 628e3d3249d..04ba906b488 100644
--- a/drivers/char/cs5535_gpio.c
+++ b/drivers/char/cs5535_gpio.c
@@ -17,6 +17,7 @@
#include <linux/cdev.h>
#include <linux/ioport.h>
#include <linux/pci.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -153,12 +154,11 @@ static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
return count;
}
-/* No BKL needed here - "mask" is the only global resource used
- here and it's a boot-time parameter */
static int cs5535_gpio_open(struct inode *inode, struct file *file)
{
u32 m = iminor(inode);
+ cycle_kernel_lock();
/* the mask says which pins are usable by this driver */
if ((mask & (1 << m)) == 0)
return -EINVAL;
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 433388c6023..6b900b297cc 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -56,6 +56,7 @@
#include <linux/errno.h> /* for -EBUSY */
#include <linux/ioport.h> /* for request_region */
#include <linux/delay.h> /* for loops_per_jiffy */
+#include <linux/smp_lock.h> /* cycle_kernel_lock() */
#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */
#include <asm/uaccess.h> /* for get_user, etc. */
#include <linux/wait.h> /* for wait_queue */
@@ -288,12 +289,12 @@ static int dtlk_ioctl(struct inode *inode,
}
}
-/* No BKL needed here; "dtlk_busy" is the only global resource,
- and it is not ever set by anybody (test is broken) */
+/* Note that nobody ever sets dtlk_busy... */
static int dtlk_open(struct inode *inode, struct file *file)
{
TRACE_TEXT("(dtlk_open");
+ cycle_kernel_lock();
nonseekable_open(inode, file);
switch (iminor(inode)) {
case DTLK_MINOR:
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 70957acaa96..a978c57b6b2 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -98,6 +98,7 @@
#include <linux/major.h>
#include <linux/wait.h>
#include <linux/device.h>
+#include <linux/smp_lock.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
@@ -2931,42 +2932,11 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
static int
ip2_ipl_open( struct inode *pInode, struct file *pFile )
{
- unsigned int iplminor = iminor(pInode);
- i2eBordStrPtr pB;
- i2ChanStrPtr pCh;
#ifdef IP2DEBUG_IPL
printk (KERN_DEBUG "IP2IPL: open\n" );
#endif
-
- switch(iplminor) {
- // These are the IPL devices
- case 0:
- case 4:
- case 8:
- case 12:
- break;
-
- // These are the status devices
- case 1:
- case 5:
- case 9:
- case 13:
- break;
-
- // These are the debug devices
- case 2:
- case 6:
- case 10:
- case 14:
- pB = i2BoardPtrTable[iplminor / 4];
- pCh = (i2ChanStrPtr) pB->i2eChannelPtr;
- break;
-
- // This is the trace device
- case 3:
- break;
- }
+ cycle_kernel_lock();
return 0;
}
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 8715dc9f4a5..b930de50407 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -20,6 +20,7 @@
#include <linux/mutex.h>
#include <linux/nsc_gpio.h>
#include <linux/platform_device.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#define DEVNAME "pc8736x_gpio"
@@ -212,12 +213,12 @@ static struct nsc_gpio_ops pc8736x_gpio_ops = {
.gpio_current = pc8736x_gpio_current
};
-/* No BKL needed here; no global resources accessed */
static int pc8736x_gpio_open(struct inode *inode, struct file *file)
{
unsigned m = iminor(inode);
file->private_data = &pc8736x_gpio_ops;
+ cycle_kernel_lock();
dev_dbg(&pdev->dev, "open %d\n", m);
if (m >= PC8736X_GPIO_CT)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index ce198757488..f6e6acadd9a 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -66,6 +66,7 @@
#include <linux/poll.h>
#include <linux/major.h>
#include <linux/ppdev.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#define PP_VERSION "ppdev: user-space parallel port driver"
@@ -633,12 +634,12 @@ static int pp_ioctl(struct inode *inode, struct file *file,
return 0;
}
-/* No BKL needed here: only local resources used */
static int pp_open (struct inode * inode, struct file * file)
{
unsigned int minor = iminor(inode);
struct pp_struct *pp;
+ cycle_kernel_lock();
if (minor >= PARPORT_MAX)
return -ENXIO;
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index be2c623a986..1d9100561c8 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -12,6 +12,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -46,12 +47,12 @@ struct nsc_gpio_ops scx200_gpio_ops = {
};
EXPORT_SYMBOL_GPL(scx200_gpio_ops);
-/* No BKL needed here: no global resources used */
static int scx200_gpio_open(struct inode *inode, struct file *file)
{
unsigned m = iminor(inode);
file->private_data = &scx200_gpio_ops;
+ cycle_kernel_lock();
if (m >= MAX_PINS)
return -EINVAL;
return nonseekable_open(inode, file);
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index db8c2ca2ce4..6062b62800f 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -21,6 +21,7 @@
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/reboot.h>
@@ -232,11 +233,11 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data,
return i;
}
-/* No BKL needed here; no global resources accessed */
static int tanbac_tb0219_open(struct inode *inode, struct file *file)
{
unsigned int minor;
+ cycle_kernel_lock();
minor = iminor(inode);
switch (minor) {
case 0:
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 412937fdb95..ffe9b4e3072 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/smp_lock.h>
#include <linux/spinlock.h>
#include <linux/types.h>
@@ -543,12 +544,11 @@ static ssize_t gpio_write(struct file *file, const char __user *data,
return i;
}
-/* No BKL needed here; only global (giu_nr_pins) is only set
- at probe time */
static int gpio_open(struct inode *inode, struct file *file)
{
unsigned int pin;
+ cycle_kernel_lock();
pin = iminor(inode);
if (pin >= giu_nr_pins)
return -EBADF;