aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-05-18 17:32:43 -0400
committerJonathan Corbet <corbet@lwn.net>2008-06-20 16:05:53 -0400
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 628e3d3249d2..04ba906b4880 100644
--- a/drivers/char/cs5535_gpio.c
+++ b/drivers/char/cs5535_gpio.c
@@ -17,6 +17,7 @@
17#include <linux/cdev.h> 17#include <linux/cdev.h>
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/smp_lock.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include <asm/io.h> 22#include <asm/io.h>
22 23
@@ -153,12 +154,11 @@ static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
153 return count; 154 return count;
154} 155}
155 156
156/* No BKL needed here - "mask" is the only global resource used
157 here and it's a boot-time parameter */
158static int cs5535_gpio_open(struct inode *inode, struct file *file) 157static int cs5535_gpio_open(struct inode *inode, struct file *file)
159{ 158{
160 u32 m = iminor(inode); 159 u32 m = iminor(inode);
161 160
161 cycle_kernel_lock();
162 /* the mask says which pins are usable by this driver */ 162 /* the mask says which pins are usable by this driver */
163 if ((mask & (1 << m)) == 0) 163 if ((mask & (1 << m)) == 0)
164 return -EINVAL; 164 return -EINVAL;
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 433388c60235..6b900b297cc6 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -56,6 +56,7 @@
56#include <linux/errno.h> /* for -EBUSY */ 56#include <linux/errno.h> /* for -EBUSY */
57#include <linux/ioport.h> /* for request_region */ 57#include <linux/ioport.h> /* for request_region */
58#include <linux/delay.h> /* for loops_per_jiffy */ 58#include <linux/delay.h> /* for loops_per_jiffy */
59#include <linux/smp_lock.h> /* cycle_kernel_lock() */
59#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 60#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */
60#include <asm/uaccess.h> /* for get_user, etc. */ 61#include <asm/uaccess.h> /* for get_user, etc. */
61#include <linux/wait.h> /* for wait_queue */ 62#include <linux/wait.h> /* for wait_queue */
@@ -288,12 +289,12 @@ static int dtlk_ioctl(struct inode *inode,
288 } 289 }
289} 290}
290 291
291/* No BKL needed here; "dtlk_busy" is the only global resource, 292/* Note that nobody ever sets dtlk_busy... */
292 and it is not ever set by anybody (test is broken) */
293static int dtlk_open(struct inode *inode, struct file *file) 293static int dtlk_open(struct inode *inode, struct file *file)
294{ 294{
295 TRACE_TEXT("(dtlk_open"); 295 TRACE_TEXT("(dtlk_open");
296 296
297 cycle_kernel_lock();
297 nonseekable_open(inode, file); 298 nonseekable_open(inode, file);
298 switch (iminor(inode)) { 299 switch (iminor(inode)) {
299 case DTLK_MINOR: 300 case DTLK_MINOR:
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 70957acaa960..a978c57b6b2b 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -98,6 +98,7 @@
98#include <linux/major.h> 98#include <linux/major.h>
99#include <linux/wait.h> 99#include <linux/wait.h>
100#include <linux/device.h> 100#include <linux/device.h>
101#include <linux/smp_lock.h>
101 102
102#include <linux/tty.h> 103#include <linux/tty.h>
103#include <linux/tty_flip.h> 104#include <linux/tty_flip.h>
@@ -2931,42 +2932,11 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
2931static int 2932static int
2932ip2_ipl_open( struct inode *pInode, struct file *pFile ) 2933ip2_ipl_open( struct inode *pInode, struct file *pFile )
2933{ 2934{
2934 unsigned int iplminor = iminor(pInode);
2935 i2eBordStrPtr pB;
2936 i2ChanStrPtr pCh;
2937 2935
2938#ifdef IP2DEBUG_IPL 2936#ifdef IP2DEBUG_IPL
2939 printk (KERN_DEBUG "IP2IPL: open\n" ); 2937 printk (KERN_DEBUG "IP2IPL: open\n" );
2940#endif 2938#endif
2941 2939 cycle_kernel_lock();
2942 switch(iplminor) {
2943 // These are the IPL devices
2944 case 0:
2945 case 4:
2946 case 8:
2947 case 12:
2948 break;
2949
2950 // These are the status devices
2951 case 1:
2952 case 5:
2953 case 9:
2954 case 13:
2955 break;
2956
2957 // These are the debug devices
2958 case 2:
2959 case 6:
2960 case 10:
2961 case 14:
2962 pB = i2BoardPtrTable[iplminor / 4];
2963 pCh = (i2ChanStrPtr) pB->i2eChannelPtr;
2964 break;
2965
2966 // This is the trace device
2967 case 3:
2968 break;
2969 }
2970 return 0; 2940 return 0;
2971} 2941}
2972 2942
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 8715dc9f4a53..b930de50407a 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -20,6 +20,7 @@
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#include <linux/nsc_gpio.h> 21#include <linux/nsc_gpio.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/smp_lock.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
25#define DEVNAME "pc8736x_gpio" 26#define DEVNAME "pc8736x_gpio"
@@ -212,12 +213,12 @@ static struct nsc_gpio_ops pc8736x_gpio_ops = {
212 .gpio_current = pc8736x_gpio_current 213 .gpio_current = pc8736x_gpio_current
213}; 214};
214 215
215/* No BKL needed here; no global resources accessed */
216static int pc8736x_gpio_open(struct inode *inode, struct file *file) 216static int pc8736x_gpio_open(struct inode *inode, struct file *file)
217{ 217{
218 unsigned m = iminor(inode); 218 unsigned m = iminor(inode);
219 file->private_data = &pc8736x_gpio_ops; 219 file->private_data = &pc8736x_gpio_ops;
220 220
221 cycle_kernel_lock();
221 dev_dbg(&pdev->dev, "open %d\n", m); 222 dev_dbg(&pdev->dev, "open %d\n", m);
222 223
223 if (m >= PC8736X_GPIO_CT) 224 if (m >= PC8736X_GPIO_CT)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index ce1987574888..f6e6acadd9a0 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -66,6 +66,7 @@
66#include <linux/poll.h> 66#include <linux/poll.h>
67#include <linux/major.h> 67#include <linux/major.h>
68#include <linux/ppdev.h> 68#include <linux/ppdev.h>
69#include <linux/smp_lock.h>
69#include <asm/uaccess.h> 70#include <asm/uaccess.h>
70 71
71#define PP_VERSION "ppdev: user-space parallel port driver" 72#define PP_VERSION "ppdev: user-space parallel port driver"
@@ -633,12 +634,12 @@ static int pp_ioctl(struct inode *inode, struct file *file,
633 return 0; 634 return 0;
634} 635}
635 636
636/* No BKL needed here: only local resources used */
637static int pp_open (struct inode * inode, struct file * file) 637static int pp_open (struct inode * inode, struct file * file)
638{ 638{
639 unsigned int minor = iminor(inode); 639 unsigned int minor = iminor(inode);
640 struct pp_struct *pp; 640 struct pp_struct *pp;
641 641
642 cycle_kernel_lock();
642 if (minor >= PARPORT_MAX) 643 if (minor >= PARPORT_MAX)
643 return -ENXIO; 644 return -ENXIO;
644 645
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index be2c623a9862..1d9100561c8a 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/smp_lock.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/io.h> 17#include <asm/io.h>
17 18
@@ -46,12 +47,12 @@ struct nsc_gpio_ops scx200_gpio_ops = {
46}; 47};
47EXPORT_SYMBOL_GPL(scx200_gpio_ops); 48EXPORT_SYMBOL_GPL(scx200_gpio_ops);
48 49
49/* No BKL needed here: no global resources used */
50static int scx200_gpio_open(struct inode *inode, struct file *file) 50static int scx200_gpio_open(struct inode *inode, struct file *file)
51{ 51{
52 unsigned m = iminor(inode); 52 unsigned m = iminor(inode);
53 file->private_data = &scx200_gpio_ops; 53 file->private_data = &scx200_gpio_ops;
54 54
55 cycle_kernel_lock();
55 if (m >= MAX_PINS) 56 if (m >= MAX_PINS)
56 return -EINVAL; 57 return -EINVAL;
57 return nonseekable_open(inode, file); 58 return nonseekable_open(inode, file);
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index db8c2ca2ce4c..6062b62800fd 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -21,6 +21,7 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/smp_lock.h>
24 25
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/reboot.h> 27#include <asm/reboot.h>
@@ -232,11 +233,11 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data,
232 return i; 233 return i;
233} 234}
234 235
235/* No BKL needed here; no global resources accessed */
236static int tanbac_tb0219_open(struct inode *inode, struct file *file) 236static int tanbac_tb0219_open(struct inode *inode, struct file *file)
237{ 237{
238 unsigned int minor; 238 unsigned int minor;
239 239
240 cycle_kernel_lock();
240 minor = iminor(inode); 241 minor = iminor(inode);
241 switch (minor) { 242 switch (minor) {
242 case 0: 243 case 0:
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 412937fdb958..ffe9b4e3072e 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/smp_lock.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
31#include <linux/types.h> 32#include <linux/types.h>
32 33
@@ -543,12 +544,11 @@ static ssize_t gpio_write(struct file *file, const char __user *data,
543 return i; 544 return i;
544} 545}
545 546
546/* No BKL needed here; only global (giu_nr_pins) is only set
547 at probe time */
548static int gpio_open(struct inode *inode, struct file *file) 547static int gpio_open(struct inode *inode, struct file *file)
549{ 548{
550 unsigned int pin; 549 unsigned int pin;
551 550
551 cycle_kernel_lock();
552 pin = iminor(inode); 552 pin = iminor(inode);
553 if (pin >= giu_nr_pins) 553 if (pin >= giu_nr_pins)
554 return -EBADF; 554 return -EBADF;