aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-04-26 18:24:05 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-05-16 23:27:41 -0400
commit55929332c92e5d34d65a8f784604c92677ea3e15 (patch)
tree555e922d470336d07ace32bb564ac5358379a3c4
parent703c631ebbcadcfd861d01e697fdda7c388fec9a (diff)
drivers: Push down BKL into various drivers
These are the last remaining device drivers using the ->ioctl file operation in the drivers directory (except from v4l drivers). [fweisbec: drop i8k pushdown as it has been done from procfs pushdown branch already] Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r--drivers/char/apm-emulation.c8
-rw-r--r--drivers/char/applicom.c13
-rw-r--r--drivers/char/ds1620.c16
-rw-r--r--drivers/char/dtlk.c15
-rw-r--r--drivers/char/generic_nvram.c17
-rw-r--r--drivers/char/genrtc.c16
-rw-r--r--drivers/char/hpet.c14
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c26
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c17
-rw-r--r--drivers/char/nvram.c10
-rw-r--r--drivers/char/nwflash.c7
-rw-r--r--drivers/char/raw.c42
-rw-r--r--drivers/hwmon/fschmd.c9
-rw-r--r--drivers/hwmon/w83793.c10
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c34
-rw-r--r--drivers/macintosh/nvram.c2
-rw-r--r--drivers/macintosh/via-pmu.c17
-rw-r--r--drivers/mtd/mtdchar.c19
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c17
-rw-r--r--drivers/rtc/rtc-m41t80.c16
-rw-r--r--drivers/sbus/char/openprom.c44
-rw-r--r--drivers/usb/mon/mon_bin.c23
-rw-r--r--drivers/usb/mon/mon_stat.c3
23 files changed, 280 insertions, 115 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 4f568cb9af3f..033e1505fca9 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -265,8 +265,8 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait)
265 * Only when everyone who has opened /dev/apm_bios with write permission 265 * Only when everyone who has opened /dev/apm_bios with write permission
266 * has acknowledge does the actual suspend happen. 266 * has acknowledge does the actual suspend happen.
267 */ 267 */
268static int 268static long
269apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) 269apm_ioctl(struct file *filp, u_int cmd, u_long arg)
270{ 270{
271 struct apm_user *as = filp->private_data; 271 struct apm_user *as = filp->private_data;
272 int err = -EINVAL; 272 int err = -EINVAL;
@@ -274,6 +274,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
274 if (!as->suser || !as->writer) 274 if (!as->suser || !as->writer)
275 return -EPERM; 275 return -EPERM;
276 276
277 lock_kernel();
277 switch (cmd) { 278 switch (cmd) {
278 case APM_IOC_SUSPEND: 279 case APM_IOC_SUSPEND:
279 mutex_lock(&state_lock); 280 mutex_lock(&state_lock);
@@ -334,6 +335,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
334 mutex_unlock(&state_lock); 335 mutex_unlock(&state_lock);
335 break; 336 break;
336 } 337 }
338 unlock_kernel();
337 339
338 return err; 340 return err;
339} 341}
@@ -397,7 +399,7 @@ static const struct file_operations apm_bios_fops = {
397 .owner = THIS_MODULE, 399 .owner = THIS_MODULE,
398 .read = apm_read, 400 .read = apm_read,
399 .poll = apm_poll, 401 .poll = apm_poll,
400 .ioctl = apm_ioctl, 402 .unlocked_ioctl = apm_ioctl,
401 .open = apm_open, 403 .open = apm_open,
402 .release = apm_release, 404 .release = apm_release,
403}; 405};
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a7424bf7eacf..63313a33ba5f 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -26,6 +26,7 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/smp_lock.h>
29#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/wait.h> 32#include <linux/wait.h>
@@ -106,8 +107,7 @@ static unsigned int DeviceErrorCount; /* number of device error */
106 107
107static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *); 108static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *);
108static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *); 109static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *);
109static int ac_ioctl(struct inode *, struct file *, unsigned int, 110static long ac_ioctl(struct file *, unsigned int, unsigned long);
110 unsigned long);
111static irqreturn_t ac_interrupt(int, void *); 111static irqreturn_t ac_interrupt(int, void *);
112 112
113static const struct file_operations ac_fops = { 113static const struct file_operations ac_fops = {
@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
115 .llseek = no_llseek, 115 .llseek = no_llseek,
116 .read = ac_read, 116 .read = ac_read,
117 .write = ac_write, 117 .write = ac_write,
118 .ioctl = ac_ioctl, 118 .unlocked_ioctl = ac_ioctl,
119}; 119};
120 120
121static struct miscdevice ac_miscdev = { 121static struct miscdevice ac_miscdev = {
@@ -689,7 +689,7 @@ static irqreturn_t ac_interrupt(int vec, void *dev_instance)
689 689
690 690
691 691
692static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 692static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
693 693
694{ /* @ ADG ou ATO selon le cas */ 694{ /* @ ADG ou ATO selon le cas */
695 int i; 695 int i;
@@ -711,7 +711,8 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
711 kfree(adgl); 711 kfree(adgl);
712 return -EFAULT; 712 return -EFAULT;
713 } 713 }
714 714
715 lock_kernel();
715 IndexCard = adgl->num_card-1; 716 IndexCard = adgl->num_card-1;
716 717
717 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { 718 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
@@ -721,6 +722,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
721 warncount--; 722 warncount--;
722 } 723 }
723 kfree(adgl); 724 kfree(adgl);
725 unlock_kernel();
724 return -EINVAL; 726 return -EINVAL;
725 } 727 }
726 728
@@ -838,6 +840,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
838 } 840 }
839 Dummy = readb(apbs[IndexCard].RamIO + VERS); 841 Dummy = readb(apbs[IndexCard].RamIO + VERS);
840 kfree(adgl); 842 kfree(adgl);
843 unlock_kernel();
841 return 0; 844 return 0;
842} 845}
843 846
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 61f0146e215d..dbee8688f75c 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -232,7 +232,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
232} 232}
233 233
234static int 234static int
235ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 235ds1620_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
236{ 236{
237 struct therm therm; 237 struct therm therm;
238 union { 238 union {
@@ -316,6 +316,18 @@ ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
316 return 0; 316 return 0;
317} 317}
318 318
319static long
320ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
321{
322 int ret;
323
324 lock_kernel();
325 ret = ds1620_ioctl(file, cmd, arg);
326 unlock_kernel();
327
328 return ret;
329}
330
319#ifdef THERM_USE_PROC 331#ifdef THERM_USE_PROC
320static int 332static int
321proc_therm_ds1620_read(char *buf, char **start, off_t offset, 333proc_therm_ds1620_read(char *buf, char **start, off_t offset,
@@ -344,7 +356,7 @@ static const struct file_operations ds1620_fops = {
344 .owner = THIS_MODULE, 356 .owner = THIS_MODULE,
345 .open = ds1620_open, 357 .open = ds1620_open,
346 .read = ds1620_read, 358 .read = ds1620_read,
347 .ioctl = ds1620_ioctl, 359 .unlocked_ioctl = ds1620_unlocked_ioctl,
348}; 360};
349 361
350static struct miscdevice ds1620_miscdev = { 362static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 045c930e6320..e3859d4eaead 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -93,8 +93,8 @@ static ssize_t dtlk_write(struct file *, const char __user *,
93static unsigned int dtlk_poll(struct file *, poll_table *); 93static unsigned int dtlk_poll(struct file *, poll_table *);
94static int dtlk_open(struct inode *, struct file *); 94static int dtlk_open(struct inode *, struct file *);
95static int dtlk_release(struct inode *, struct file *); 95static int dtlk_release(struct inode *, struct file *);
96static int dtlk_ioctl(struct inode *inode, struct file *file, 96static long dtlk_ioctl(struct file *file,
97 unsigned int cmd, unsigned long arg); 97 unsigned int cmd, unsigned long arg);
98 98
99static const struct file_operations dtlk_fops = 99static const struct file_operations dtlk_fops =
100{ 100{
@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
102 .read = dtlk_read, 102 .read = dtlk_read,
103 .write = dtlk_write, 103 .write = dtlk_write,
104 .poll = dtlk_poll, 104 .poll = dtlk_poll,
105 .ioctl = dtlk_ioctl, 105 .unlocked_ioctl = dtlk_ioctl,
106 .open = dtlk_open, 106 .open = dtlk_open,
107 .release = dtlk_release, 107 .release = dtlk_release,
108}; 108};
@@ -263,10 +263,9 @@ static void dtlk_timer_tick(unsigned long data)
263 wake_up_interruptible(&dtlk_process_list); 263 wake_up_interruptible(&dtlk_process_list);
264} 264}
265 265
266static int dtlk_ioctl(struct inode *inode, 266static long dtlk_ioctl(struct file *file,
267 struct file *file, 267 unsigned int cmd,
268 unsigned int cmd, 268 unsigned long arg)
269 unsigned long arg)
270{ 269{
271 char __user *argp = (char __user *)arg; 270 char __user *argp = (char __user *)arg;
272 struct dtlk_settings *sp; 271 struct dtlk_settings *sp;
@@ -276,7 +275,9 @@ static int dtlk_ioctl(struct inode *inode,
276 switch (cmd) { 275 switch (cmd) {
277 276
278 case DTLK_INTERROGATE: 277 case DTLK_INTERROGATE:
278 lock_kernel();
279 sp = dtlk_interrogate(); 279 sp = dtlk_interrogate();
280 unlock_kernel();
280 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) 281 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
281 return -EINVAL; 282 return -EINVAL;
282 return 0; 283 return 0;
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index fda4181b5e67..82b5a88a82d7 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -19,6 +19,7 @@
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/fcntl.h> 20#include <linux/fcntl.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/smp_lock.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/nvram.h> 24#include <asm/nvram.h>
24#ifdef CONFIG_PPC_PMAC 25#ifdef CONFIG_PPC_PMAC
@@ -84,8 +85,7 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,
84 return p - buf; 85 return p - buf;
85} 86}
86 87
87static int nvram_ioctl(struct inode *inode, struct file *file, 88static int nvram_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
88 unsigned int cmd, unsigned long arg)
89{ 89{
90 switch(cmd) { 90 switch(cmd) {
91#ifdef CONFIG_PPC_PMAC 91#ifdef CONFIG_PPC_PMAC
@@ -116,12 +116,23 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
116 return 0; 116 return 0;
117} 117}
118 118
119static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
120{
121 int ret;
122
123 lock_kernel();
124 ret = nvram_ioctl(file, cmd, arg);
125 unlock_kernel();
126
127 return ret;
128}
129
119const struct file_operations nvram_fops = { 130const struct file_operations nvram_fops = {
120 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
121 .llseek = nvram_llseek, 132 .llseek = nvram_llseek,
122 .read = read_nvram, 133 .read = read_nvram,
123 .write = write_nvram, 134 .write = write_nvram,
124 .ioctl = nvram_ioctl, 135 .unlocked_ioctl = nvram_unlocked_ioctl,
125}; 136};
126 137
127static struct miscdevice nvram_dev = { 138static struct miscdevice nvram_dev = {
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 31e7c91c2d9d..b6c2cc167c11 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -262,7 +262,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
262#endif 262#endif
263} 263}
264 264
265static int gen_rtc_ioctl(struct inode *inode, struct file *file, 265static int gen_rtc_ioctl(struct file *file,
266 unsigned int cmd, unsigned long arg) 266 unsigned int cmd, unsigned long arg)
267{ 267{
268 struct rtc_time wtime; 268 struct rtc_time wtime;
@@ -332,6 +332,18 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
332 return -EINVAL; 332 return -EINVAL;
333} 333}
334 334
335static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
336 unsigned long arg)
337{
338 int ret;
339
340 lock_kernel();
341 ret = gen_rtc_ioctl(file, cmd, arg);
342 unlock_kernel();
343
344 return ret;
345}
346
335/* 347/*
336 * We enforce only one user at a time here with the open/close. 348 * We enforce only one user at a time here with the open/close.
337 * Also clear the previous interrupt data on an open, and clean 349 * Also clear the previous interrupt data on an open, and clean
@@ -482,7 +494,7 @@ static const struct file_operations gen_rtc_fops = {
482 .read = gen_rtc_read, 494 .read = gen_rtc_read,
483 .poll = gen_rtc_poll, 495 .poll = gen_rtc_poll,
484#endif 496#endif
485 .ioctl = gen_rtc_ioctl, 497 .unlocked_ioctl = gen_rtc_unlocked_ioctl,
486 .open = gen_rtc_open, 498 .open = gen_rtc_open,
487 .release = gen_rtc_release, 499 .release = gen_rtc_release,
488}; 500};
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 9ded667625ac..a0a1829d3198 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -431,14 +431,18 @@ static int hpet_release(struct inode *inode, struct file *file)
431 431
432static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int); 432static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
433 433
434static int 434static long hpet_ioctl(struct file *file, unsigned int cmd,
435hpet_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 435 unsigned long arg)
436 unsigned long arg)
437{ 436{
438 struct hpet_dev *devp; 437 struct hpet_dev *devp;
438 int ret;
439 439
440 devp = file->private_data; 440 devp = file->private_data;
441 return hpet_ioctl_common(devp, cmd, arg, 0); 441 lock_kernel();
442 ret = hpet_ioctl_common(devp, cmd, arg, 0);
443 unlock_kernel();
444
445 return ret;
442} 446}
443 447
444static int hpet_ioctl_ieon(struct hpet_dev *devp) 448static int hpet_ioctl_ieon(struct hpet_dev *devp)
@@ -654,7 +658,7 @@ static const struct file_operations hpet_fops = {
654 .llseek = no_llseek, 658 .llseek = no_llseek,
655 .read = hpet_read, 659 .read = hpet_read,
656 .poll = hpet_poll, 660 .poll = hpet_poll,
657 .ioctl = hpet_ioctl, 661 .unlocked_ioctl = hpet_ioctl,
658 .open = hpet_open, 662 .open = hpet_open,
659 .release = hpet_release, 663 .release = hpet_release,
660 .fasync = hpet_fasync, 664 .fasync = hpet_fasync,
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 65545de3dbf4..d8ec92a38980 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -228,8 +228,7 @@ static int handle_send_req(ipmi_user_t user,
228 return rv; 228 return rv;
229} 229}
230 230
231static int ipmi_ioctl(struct inode *inode, 231static int ipmi_ioctl(struct file *file,
232 struct file *file,
233 unsigned int cmd, 232 unsigned int cmd,
234 unsigned long data) 233 unsigned long data)
235{ 234{
@@ -630,6 +629,23 @@ static int ipmi_ioctl(struct inode *inode,
630 return rv; 629 return rv;
631} 630}
632 631
632/*
633 * Note: it doesn't make sense to take the BKL here but
634 * not in compat_ipmi_ioctl. -arnd
635 */
636static long ipmi_unlocked_ioctl(struct file *file,
637 unsigned int cmd,
638 unsigned long data)
639{
640 int ret;
641
642 lock_kernel();
643 ret = ipmi_ioctl(file, cmd, data);
644 unlock_kernel();
645
646 return ret;
647}
648
633#ifdef CONFIG_COMPAT 649#ifdef CONFIG_COMPAT
634 650
635/* 651/*
@@ -802,7 +818,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
802 if (copy_to_user(precv64, &recv64, sizeof(recv64))) 818 if (copy_to_user(precv64, &recv64, sizeof(recv64)))
803 return -EFAULT; 819 return -EFAULT;
804 820
805 rc = ipmi_ioctl(filep->f_path.dentry->d_inode, filep, 821 rc = ipmi_ioctl(filep,
806 ((cmd == COMPAT_IPMICTL_RECEIVE_MSG) 822 ((cmd == COMPAT_IPMICTL_RECEIVE_MSG)
807 ? IPMICTL_RECEIVE_MSG 823 ? IPMICTL_RECEIVE_MSG
808 : IPMICTL_RECEIVE_MSG_TRUNC), 824 : IPMICTL_RECEIVE_MSG_TRUNC),
@@ -819,14 +835,14 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
819 return rc; 835 return rc;
820 } 836 }
821 default: 837 default:
822 return ipmi_ioctl(filep->f_path.dentry->d_inode, filep, cmd, arg); 838 return ipmi_ioctl(filep, cmd, arg);
823 } 839 }
824} 840}
825#endif 841#endif
826 842
827static const struct file_operations ipmi_fops = { 843static const struct file_operations ipmi_fops = {
828 .owner = THIS_MODULE, 844 .owner = THIS_MODULE,
829 .ioctl = ipmi_ioctl, 845 .unlocked_ioctl = ipmi_unlocked_ioctl,
830#ifdef CONFIG_COMPAT 846#ifdef CONFIG_COMPAT
831 .compat_ioctl = compat_ipmi_ioctl, 847 .compat_ioctl = compat_ipmi_ioctl,
832#endif 848#endif
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index a4d57e31f713..82bcdb262a3a 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -659,7 +659,7 @@ static struct watchdog_info ident = {
659 .identity = "IPMI" 659 .identity = "IPMI"
660}; 660};
661 661
662static int ipmi_ioctl(struct inode *inode, struct file *file, 662static int ipmi_ioctl(struct file *file,
663 unsigned int cmd, unsigned long arg) 663 unsigned int cmd, unsigned long arg)
664{ 664{
665 void __user *argp = (void __user *)arg; 665 void __user *argp = (void __user *)arg;
@@ -730,6 +730,19 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
730 } 730 }
731} 731}
732 732
733static long ipmi_unlocked_ioctl(struct file *file,
734 unsigned int cmd,
735 unsigned long arg)
736{
737 int ret;
738
739 lock_kernel();
740 ret = ipmi_ioctl(file, cmd, arg);
741 unlock_kernel();
742
743 return ret;
744}
745
733static ssize_t ipmi_write(struct file *file, 746static ssize_t ipmi_write(struct file *file,
734 const char __user *buf, 747 const char __user *buf,
735 size_t len, 748 size_t len,
@@ -880,7 +893,7 @@ static const struct file_operations ipmi_wdog_fops = {
880 .read = ipmi_read, 893 .read = ipmi_read,
881 .poll = ipmi_poll, 894 .poll = ipmi_poll,
882 .write = ipmi_write, 895 .write = ipmi_write,
883 .ioctl = ipmi_ioctl, 896 .unlocked_ioctl = ipmi_unlocked_ioctl,
884 .open = ipmi_open, 897 .open = ipmi_open,
885 .release = ipmi_close, 898 .release = ipmi_close,
886 .fasync = ipmi_fasync, 899 .fasync = ipmi_fasync,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 47e8f7b0e4c1..66d2917b003f 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -296,8 +296,8 @@ checksum_err:
296 return -EIO; 296 return -EIO;
297} 297}
298 298
299static int nvram_ioctl(struct inode *inode, struct file *file, 299static long nvram_ioctl(struct file *file, unsigned int cmd,
300 unsigned int cmd, unsigned long arg) 300 unsigned long arg)
301{ 301{
302 int i; 302 int i;
303 303
@@ -308,6 +308,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
308 if (!capable(CAP_SYS_ADMIN)) 308 if (!capable(CAP_SYS_ADMIN))
309 return -EACCES; 309 return -EACCES;
310 310
311 lock_kernel();
311 spin_lock_irq(&rtc_lock); 312 spin_lock_irq(&rtc_lock);
312 313
313 for (i = 0; i < NVRAM_BYTES; ++i) 314 for (i = 0; i < NVRAM_BYTES; ++i)
@@ -315,6 +316,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
315 __nvram_set_checksum(); 316 __nvram_set_checksum();
316 317
317 spin_unlock_irq(&rtc_lock); 318 spin_unlock_irq(&rtc_lock);
319 unlock_kernel();
318 return 0; 320 return 0;
319 321
320 case NVRAM_SETCKS: 322 case NVRAM_SETCKS:
@@ -323,9 +325,11 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
323 if (!capable(CAP_SYS_ADMIN)) 325 if (!capable(CAP_SYS_ADMIN))
324 return -EACCES; 326 return -EACCES;
325 327
328 lock_kernel();
326 spin_lock_irq(&rtc_lock); 329 spin_lock_irq(&rtc_lock);
327 __nvram_set_checksum(); 330 __nvram_set_checksum();
328 spin_unlock_irq(&rtc_lock); 331 spin_unlock_irq(&rtc_lock);
332 unlock_kernel();
329 return 0; 333 return 0;
330 334
331 default: 335 default:
@@ -422,7 +426,7 @@ static const struct file_operations nvram_fops = {
422 .llseek = nvram_llseek, 426 .llseek = nvram_llseek,
423 .read = nvram_read, 427 .read = nvram_read,
424 .write = nvram_write, 428 .write = nvram_write,
425 .ioctl = nvram_ioctl, 429 .unlocked_ioctl = nvram_ioctl,
426 .open = nvram_open, 430 .open = nvram_open,
427 .release = nvram_release, 431 .release = nvram_release,
428}; 432};
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index f80810901db6..043a1c7b86be 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -94,8 +94,9 @@ static int get_flash_id(void)
94 return c2; 94 return c2;
95} 95}
96 96
97static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cmd, unsigned long arg) 97static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
98{ 98{
99 lock_kernel();
99 switch (cmd) { 100 switch (cmd) {
100 case CMD_WRITE_DISABLE: 101 case CMD_WRITE_DISABLE:
101 gbWriteBase64Enable = 0; 102 gbWriteBase64Enable = 0;
@@ -113,8 +114,10 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm
113 default: 114 default:
114 gbWriteBase64Enable = 0; 115 gbWriteBase64Enable = 0;
115 gbWriteEnable = 0; 116 gbWriteEnable = 0;
117 unlock_kernel();
116 return -EINVAL; 118 return -EINVAL;
117 } 119 }
120 unlock_kernel();
118 return 0; 121 return 0;
119} 122}
120 123
@@ -631,7 +634,7 @@ static const struct file_operations flash_fops =
631 .llseek = flash_llseek, 634 .llseek = flash_llseek,
632 .read = flash_read, 635 .read = flash_read,
633 .write = flash_write, 636 .write = flash_write,
634 .ioctl = flash_ioctl, 637 .unlocked_ioctl = flash_ioctl,
635}; 638};
636 639
637static struct miscdevice flash_miscdev = 640static struct miscdevice flash_miscdev =
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 8756ab0daa8b..b38942f6bf31 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -121,13 +121,17 @@ static int raw_release(struct inode *inode, struct file *filp)
121/* 121/*
122 * Forward ioctls to the underlying block device. 122 * Forward ioctls to the underlying block device.
123 */ 123 */
124static int 124static long
125raw_ioctl(struct inode *inode, struct file *filp, 125raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
126 unsigned int command, unsigned long arg)
127{ 126{
128 struct block_device *bdev = filp->private_data; 127 struct block_device *bdev = filp->private_data;
128 int ret;
129
130 lock_kernel();
131 ret = blkdev_ioctl(bdev, 0, command, arg);
132 unlock_kernel();
129 133
130 return blkdev_ioctl(bdev, 0, command, arg); 134 return ret;
131} 135}
132 136
133static void bind_device(struct raw_config_request *rq) 137static void bind_device(struct raw_config_request *rq)
@@ -141,13 +145,14 @@ static void bind_device(struct raw_config_request *rq)
141 * Deal with ioctls against the raw-device control interface, to bind 145 * Deal with ioctls against the raw-device control interface, to bind
142 * and unbind other raw devices. 146 * and unbind other raw devices.
143 */ 147 */
144static int raw_ctl_ioctl(struct inode *inode, struct file *filp, 148static long raw_ctl_ioctl(struct file *filp, unsigned int command,
145 unsigned int command, unsigned long arg) 149 unsigned long arg)
146{ 150{
147 struct raw_config_request rq; 151 struct raw_config_request rq;
148 struct raw_device_data *rawdev; 152 struct raw_device_data *rawdev;
149 int err = 0; 153 int err = 0;
150 154
155 lock_kernel();
151 switch (command) { 156 switch (command) {
152 case RAW_SETBIND: 157 case RAW_SETBIND:
153 case RAW_GETBIND: 158 case RAW_GETBIND:
@@ -240,25 +245,26 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
240 break; 245 break;
241 } 246 }
242out: 247out:
248 unlock_kernel();
243 return err; 249 return err;
244} 250}
245 251
246static const struct file_operations raw_fops = { 252static const struct file_operations raw_fops = {
247 .read = do_sync_read, 253 .read = do_sync_read,
248 .aio_read = generic_file_aio_read, 254 .aio_read = generic_file_aio_read,
249 .write = do_sync_write, 255 .write = do_sync_write,
250 .aio_write = blkdev_aio_write, 256 .aio_write = blkdev_aio_write,
251 .fsync = blkdev_fsync, 257 .fsync = blkdev_fsync,
252 .open = raw_open, 258 .open = raw_open,
253 .release= raw_release, 259 .release = raw_release,
254 .ioctl = raw_ioctl, 260 .unlocked_ioctl = raw_ioctl,
255 .owner = THIS_MODULE, 261 .owner = THIS_MODULE,
256}; 262};
257 263
258static const struct file_operations raw_ctl_fops = { 264static const struct file_operations raw_ctl_fops = {
259 .ioctl = raw_ctl_ioctl, 265 .unlocked_ioctl = raw_ctl_ioctl,
260 .open = raw_open, 266 .open = raw_open,
261 .owner = THIS_MODULE, 267 .owner = THIS_MODULE,
262}; 268};
263 269
264static struct cdev raw_cdev; 270static struct cdev raw_cdev;
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 0627f7a5b9b8..b7ca2a9676cf 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -38,6 +38,7 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h> 40#include <linux/hwmon-sysfs.h>
41#include <linux/smp_lock.h>
41#include <linux/err.h> 42#include <linux/err.h>
42#include <linux/mutex.h> 43#include <linux/mutex.h>
43#include <linux/sysfs.h> 44#include <linux/sysfs.h>
@@ -847,8 +848,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
847 return count; 848 return count;
848} 849}
849 850
850static int watchdog_ioctl(struct inode *inode, struct file *filp, 851static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
851 unsigned int cmd, unsigned long arg)
852{ 852{
853 static struct watchdog_info ident = { 853 static struct watchdog_info ident = {
854 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | 854 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
@@ -858,6 +858,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
858 int i, ret = 0; 858 int i, ret = 0;
859 struct fschmd_data *data = filp->private_data; 859 struct fschmd_data *data = filp->private_data;
860 860
861 lock_kernel();
861 switch (cmd) { 862 switch (cmd) {
862 case WDIOC_GETSUPPORT: 863 case WDIOC_GETSUPPORT:
863 ident.firmware_version = data->revision; 864 ident.firmware_version = data->revision;
@@ -914,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
914 default: 915 default:
915 ret = -ENOTTY; 916 ret = -ENOTTY;
916 } 917 }
917 918 unlock_kernel();
918 return ret; 919 return ret;
919} 920}
920 921
@@ -924,7 +925,7 @@ static const struct file_operations watchdog_fops = {
924 .open = watchdog_open, 925 .open = watchdog_open,
925 .release = watchdog_release, 926 .release = watchdog_release,
926 .write = watchdog_write, 927 .write = watchdog_write,
927 .ioctl = watchdog_ioctl, 928 .unlocked_ioctl = watchdog_ioctl,
928}; 929};
929 930
930 931
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 612807d97155..697202e27891 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -35,6 +35,7 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/hwmon.h> 37#include <linux/hwmon.h>
38#include <linux/smp_lock.h>
38#include <linux/hwmon-vid.h> 39#include <linux/hwmon-vid.h>
39#include <linux/hwmon-sysfs.h> 40#include <linux/hwmon-sysfs.h>
40#include <linux/err.h> 41#include <linux/err.h>
@@ -1319,8 +1320,8 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
1319 return count; 1320 return count;
1320} 1321}
1321 1322
1322static int watchdog_ioctl(struct inode *inode, struct file *filp, 1323static long watchdog_ioctl(struct file *filp, unsigned int cmd,
1323 unsigned int cmd, unsigned long arg) 1324 unsigned long arg)
1324{ 1325{
1325 static struct watchdog_info ident = { 1326 static struct watchdog_info ident = {
1326 .options = WDIOF_KEEPALIVEPING | 1327 .options = WDIOF_KEEPALIVEPING |
@@ -1332,6 +1333,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
1332 int val, ret = 0; 1333 int val, ret = 0;
1333 struct w83793_data *data = filp->private_data; 1334 struct w83793_data *data = filp->private_data;
1334 1335
1336 lock_kernel();
1335 switch (cmd) { 1337 switch (cmd) {
1336 case WDIOC_GETSUPPORT: 1338 case WDIOC_GETSUPPORT:
1337 if (!nowayout) 1339 if (!nowayout)
@@ -1385,7 +1387,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
1385 default: 1387 default:
1386 ret = -ENOTTY; 1388 ret = -ENOTTY;
1387 } 1389 }
1388 1390 unlock_kernel();
1389 return ret; 1391 return ret;
1390} 1392}
1391 1393
@@ -1395,7 +1397,7 @@ static const struct file_operations watchdog_fops = {
1395 .open = watchdog_open, 1397 .open = watchdog_open,
1396 .release = watchdog_close, 1398 .release = watchdog_close,
1397 .write = watchdog_write, 1399 .write = watchdog_write,
1398 .ioctl = watchdog_ioctl, 1400 .unlocked_ioctl = watchdog_ioctl,
1399}; 1401};
1400 1402
1401/* 1403/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ad730e15afc0..e00a1cc79c0a 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -43,6 +43,7 @@
43#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
44#include <linux/poll.h> 44#include <linux/poll.h>
45#include <linux/rtc.h> 45#include <linux/rtc.h>
46#include <linux/smp_lock.h>
46#include <linux/semaphore.h> 47#include <linux/semaphore.h>
47 48
48MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); 49MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
@@ -64,8 +65,8 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
64static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf, 65static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
65 size_t count, loff_t *ppos); 66 size_t count, loff_t *ppos);
66 67
67static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, 68static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
68 unsigned int cmd, unsigned long arg); 69 unsigned int cmd, unsigned long arg);
69 70
70static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait); 71static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
71 72
@@ -512,7 +513,7 @@ static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
512 return len; 513 return len;
513} 514}
514 515
515static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, 516static int hp_sdc_rtc_ioctl(struct file *file,
516 unsigned int cmd, unsigned long arg) 517 unsigned int cmd, unsigned long arg)
517{ 518{
518#if 1 519#if 1
@@ -659,14 +660,27 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
659#endif 660#endif
660} 661}
661 662
663static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
664 unsigned int cmd, unsigned long arg)
665{
666 int ret;
667
668 lock_kernel();
669 ret = hp_sdc_rtc_ioctl(file, cmd, arg);
670 unlock_kernel();
671
672 return ret;
673}
674
675
662static const struct file_operations hp_sdc_rtc_fops = { 676static const struct file_operations hp_sdc_rtc_fops = {
663 .owner = THIS_MODULE, 677 .owner = THIS_MODULE,
664 .llseek = no_llseek, 678 .llseek = no_llseek,
665 .read = hp_sdc_rtc_read, 679 .read = hp_sdc_rtc_read,
666 .poll = hp_sdc_rtc_poll, 680 .poll = hp_sdc_rtc_poll,
667 .ioctl = hp_sdc_rtc_ioctl, 681 .unlocked_ioctl = hp_sdc_rtc_ioctl,
668 .open = hp_sdc_rtc_open, 682 .open = hp_sdc_rtc_open,
669 .fasync = hp_sdc_rtc_fasync, 683 .fasync = hp_sdc_rtc_fasync,
670}; 684};
671 685
672static struct miscdevice hp_sdc_rtc_dev = { 686static struct miscdevice hp_sdc_rtc_dev = {
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
index c876349c32de..a271c8218d82 100644
--- a/drivers/macintosh/nvram.c
+++ b/drivers/macintosh/nvram.c
@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
100 .llseek = nvram_llseek, 100 .llseek = nvram_llseek,
101 .read = read_nvram, 101 .read = read_nvram,
102 .write = write_nvram, 102 .write = write_nvram,
103 .ioctl = nvram_ioctl, 103 .unlocked_ioctl = nvram_ioctl,
104}; 104};
105 105
106static struct miscdevice nvram_dev = { 106static struct miscdevice nvram_dev = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 42764849eb78..3d4fc0f7b00b 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2273,8 +2273,7 @@ static int register_pmu_pm_ops(void)
2273device_initcall(register_pmu_pm_ops); 2273device_initcall(register_pmu_pm_ops);
2274#endif 2274#endif
2275 2275
2276static int 2276static int pmu_ioctl(struct file *filp,
2277pmu_ioctl(struct inode * inode, struct file *filp,
2278 u_int cmd, u_long arg) 2277 u_int cmd, u_long arg)
2279{ 2278{
2280 __u32 __user *argp = (__u32 __user *)arg; 2279 __u32 __user *argp = (__u32 __user *)arg;
@@ -2337,11 +2336,23 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2337 return error; 2336 return error;
2338} 2337}
2339 2338
2339static long pmu_unlocked_ioctl(struct file *filp,
2340 u_int cmd, u_long arg)
2341{
2342 int ret;
2343
2344 lock_kernel();
2345 ret = pmu_ioctl(filp, cmd, arg);
2346 unlock_kernel();
2347
2348 return ret;
2349}
2350
2340static const struct file_operations pmu_device_fops = { 2351static const struct file_operations pmu_device_fops = {
2341 .read = pmu_read, 2352 .read = pmu_read,
2342 .write = pmu_write, 2353 .write = pmu_write,
2343 .poll = pmu_fpoll, 2354 .poll = pmu_fpoll,
2344 .ioctl = pmu_ioctl, 2355 .unlocked_ioctl = pmu_unlocked_ioctl,
2345 .open = pmu_open, 2356 .open = pmu_open,
2346 .release = pmu_release, 2357 .release = pmu_release,
2347}; 2358};
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5b081cb84351..6749c2f96342 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -450,8 +450,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
450 return ret; 450 return ret;
451} 451}
452 452
453static int mtd_ioctl(struct inode *inode, struct file *file, 453static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
454 u_int cmd, u_long arg)
455{ 454{
456 struct mtd_file_info *mfi = file->private_data; 455 struct mtd_file_info *mfi = file->private_data;
457 struct mtd_info *mtd = mfi->mtd; 456 struct mtd_info *mtd = mfi->mtd;
@@ -822,6 +821,17 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
822 return ret; 821 return ret;
823} /* memory_ioctl */ 822} /* memory_ioctl */
824 823
824static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
825{
826 int ret;
827
828 lock_kernel();
829 ret = mtd_ioctl(file, cmd, arg);
830 unlock_kernel();
831
832 return ret;
833}
834
825#ifdef CONFIG_COMPAT 835#ifdef CONFIG_COMPAT
826 836
827struct mtd_oob_buf32 { 837struct mtd_oob_buf32 {
@@ -836,7 +846,6 @@ struct mtd_oob_buf32 {
836static long mtd_compat_ioctl(struct file *file, unsigned int cmd, 846static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
837 unsigned long arg) 847 unsigned long arg)
838{ 848{
839 struct inode *inode = file->f_path.dentry->d_inode;
840 struct mtd_file_info *mfi = file->private_data; 849 struct mtd_file_info *mfi = file->private_data;
841 struct mtd_info *mtd = mfi->mtd; 850 struct mtd_info *mtd = mfi->mtd;
842 void __user *argp = compat_ptr(arg); 851 void __user *argp = compat_ptr(arg);
@@ -874,7 +883,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
874 break; 883 break;
875 } 884 }
876 default: 885 default:
877 ret = mtd_ioctl(inode, file, cmd, (unsigned long)argp); 886 ret = mtd_ioctl(file, cmd, (unsigned long)argp);
878 } 887 }
879 888
880 unlock_kernel(); 889 unlock_kernel();
@@ -942,7 +951,7 @@ static const struct file_operations mtd_fops = {
942 .llseek = mtd_lseek, 951 .llseek = mtd_lseek,
943 .read = mtd_read, 952 .read = mtd_read,
944 .write = mtd_write, 953 .write = mtd_write,
945 .ioctl = mtd_ioctl, 954 .unlocked_ioctl = mtd_unlocked_ioctl,
946#ifdef CONFIG_COMPAT 955#ifdef CONFIG_COMPAT
947 .compat_ioctl = mtd_compat_ioctl, 956 .compat_ioctl = mtd_compat_ioctl,
948#endif 957#endif
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 7631faa0cadd..838bbf6bca83 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -818,8 +818,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)
818 818
819/*====================================================================*/ 819/*====================================================================*/
820 820
821static int ds_ioctl(struct inode *inode, struct file *file, 821static int ds_ioctl(struct file *file, u_int cmd, u_long arg)
822 u_int cmd, u_long arg)
823{ 822{
824 struct pcmcia_socket *s; 823 struct pcmcia_socket *s;
825 void __user *uarg = (char __user *)arg; 824 void __user *uarg = (char __user *)arg;
@@ -1026,13 +1025,25 @@ free_out:
1026 return err; 1025 return err;
1027} /* ds_ioctl */ 1026} /* ds_ioctl */
1028 1027
1028static long ds_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1029{
1030 int ret;
1031
1032 lock_kernel();
1033 ret = ds_ioctl(file, cmd, arg);
1034 unlock_kernel();
1035
1036 return ret;
1037}
1038
1039
1029/*====================================================================*/ 1040/*====================================================================*/
1030 1041
1031static const struct file_operations ds_fops = { 1042static const struct file_operations ds_fops = {
1032 .owner = THIS_MODULE, 1043 .owner = THIS_MODULE,
1033 .open = ds_open, 1044 .open = ds_open,
1034 .release = ds_release, 1045 .release = ds_release,
1035 .ioctl = ds_ioctl, 1046 .unlocked_ioctl = ds_unlocked_ioctl,
1036 .read = ds_read, 1047 .read = ds_read,
1037 .write = ds_write, 1048 .write = ds_write,
1038 .poll = ds_poll, 1049 .poll = ds_poll,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 60fe266f0f49..038095d99976 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -623,7 +623,7 @@ static ssize_t wdt_read(struct file *file, char __user *buf,
623 * according to their available features. We only actually usefully support 623 * according to their available features. We only actually usefully support
624 * querying capabilities and current status. 624 * querying capabilities and current status.
625 */ 625 */
626static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 626static int wdt_ioctl(struct file *file, unsigned int cmd,
627 unsigned long arg) 627 unsigned long arg)
628{ 628{
629 int new_margin, rv; 629 int new_margin, rv;
@@ -676,6 +676,18 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
676 return -ENOTTY; 676 return -ENOTTY;
677} 677}
678 678
679static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
680 unsigned long arg)
681{
682 int ret;
683
684 lock_kernel();
685 ret = wdt_ioctl(file, cmd, arg);
686 unlock_kernel();
687
688 return ret;
689}
690
679/** 691/**
680 * wdt_open: 692 * wdt_open:
681 * @inode: inode of device 693 * @inode: inode of device
@@ -736,7 +748,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
736static const struct file_operations wdt_fops = { 748static const struct file_operations wdt_fops = {
737 .owner = THIS_MODULE, 749 .owner = THIS_MODULE,
738 .read = wdt_read, 750 .read = wdt_read,
739 .ioctl = wdt_ioctl, 751 .unlocked_ioctl = wdt_unlocked_ioctl,
740 .write = wdt_write, 752 .write = wdt_write,
741 .open = wdt_open, 753 .open = wdt_open,
742 .release = wdt_release, 754 .release = wdt_release,
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index fc2f676e984d..d53e62ab09da 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -298,9 +298,9 @@ static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsiz
298/* 298/*
299 * SunOS and Solaris /dev/openprom ioctl calls. 299 * SunOS and Solaris /dev/openprom ioctl calls.
300 */ 300 */
301static int openprom_sunos_ioctl(struct inode * inode, struct file * file, 301static long openprom_sunos_ioctl(struct file * file,
302 unsigned int cmd, unsigned long arg, 302 unsigned int cmd, unsigned long arg,
303 struct device_node *dp) 303 struct device_node *dp)
304{ 304{
305 DATA *data = file->private_data; 305 DATA *data = file->private_data;
306 struct openpromio *opp = NULL; 306 struct openpromio *opp = NULL;
@@ -316,6 +316,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
316 if (bufsize < 0) 316 if (bufsize < 0)
317 return bufsize; 317 return bufsize;
318 318
319 lock_kernel();
320
319 switch (cmd) { 321 switch (cmd) {
320 case OPROMGETOPT: 322 case OPROMGETOPT:
321 case OPROMGETPROP: 323 case OPROMGETPROP:
@@ -365,6 +367,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
365 } 367 }
366 368
367 kfree(opp); 369 kfree(opp);
370 unlock_kernel();
371
368 return error; 372 return error;
369} 373}
370 374
@@ -547,13 +551,14 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
547 return 0; 551 return 0;
548} 552}
549 553
550static int openprom_bsd_ioctl(struct inode * inode, struct file * file, 554static int openprom_bsd_ioctl(struct file * file,
551 unsigned int cmd, unsigned long arg) 555 unsigned int cmd, unsigned long arg)
552{ 556{
553 DATA *data = (DATA *) file->private_data; 557 DATA *data = (DATA *) file->private_data;
554 void __user *argp = (void __user *)arg; 558 void __user *argp = (void __user *)arg;
555 int err; 559 int err;
556 560
561 lock_kernel();
557 switch (cmd) { 562 switch (cmd) {
558 case OPIOCGET: 563 case OPIOCGET:
559 err = opiocget(argp, data); 564 err = opiocget(argp, data);
@@ -570,10 +575,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
570 case OPIOCGETOPTNODE: 575 case OPIOCGETOPTNODE:
571 BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); 576 BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
572 577
578 err = 0;
573 if (copy_to_user(argp, &options_node->phandle, sizeof(phandle))) 579 if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
574 return -EFAULT; 580 err = -EFAULT;
575 581 break;
576 return 0;
577 582
578 case OPIOCGETNEXT: 583 case OPIOCGETNEXT:
579 case OPIOCGETCHILD: 584 case OPIOCGETCHILD:
@@ -581,9 +586,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
581 break; 586 break;
582 587
583 default: 588 default:
584 return -EINVAL; 589 err = -EINVAL;
585 590 break;
586 }; 591 };
592 unlock_kernel();
587 593
588 return err; 594 return err;
589} 595}
@@ -592,8 +598,8 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
592/* 598/*
593 * Handoff control to the correct ioctl handler. 599 * Handoff control to the correct ioctl handler.
594 */ 600 */
595static int openprom_ioctl(struct inode * inode, struct file * file, 601static long openprom_ioctl(struct file * file,
596 unsigned int cmd, unsigned long arg) 602 unsigned int cmd, unsigned long arg)
597{ 603{
598 DATA *data = (DATA *) file->private_data; 604 DATA *data = (DATA *) file->private_data;
599 605
@@ -602,14 +608,14 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
602 case OPROMNXTOPT: 608 case OPROMNXTOPT:
603 if ((file->f_mode & FMODE_READ) == 0) 609 if ((file->f_mode & FMODE_READ) == 0)
604 return -EPERM; 610 return -EPERM;
605 return openprom_sunos_ioctl(inode, file, cmd, arg, 611 return openprom_sunos_ioctl(file, cmd, arg,
606 options_node); 612 options_node);
607 613
608 case OPROMSETOPT: 614 case OPROMSETOPT:
609 case OPROMSETOPT2: 615 case OPROMSETOPT2:
610 if ((file->f_mode & FMODE_WRITE) == 0) 616 if ((file->f_mode & FMODE_WRITE) == 0)
611 return -EPERM; 617 return -EPERM;
612 return openprom_sunos_ioctl(inode, file, cmd, arg, 618 return openprom_sunos_ioctl(file, cmd, arg,
613 options_node); 619 options_node);
614 620
615 case OPROMNEXT: 621 case OPROMNEXT:
@@ -618,7 +624,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
618 case OPROMNXTPROP: 624 case OPROMNXTPROP:
619 if ((file->f_mode & FMODE_READ) == 0) 625 if ((file->f_mode & FMODE_READ) == 0)
620 return -EPERM; 626 return -EPERM;
621 return openprom_sunos_ioctl(inode, file, cmd, arg, 627 return openprom_sunos_ioctl(file, cmd, arg,
622 data->current_node); 628 data->current_node);
623 629
624 case OPROMU2P: 630 case OPROMU2P:
@@ -630,7 +636,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
630 case OPROMPATH2NODE: 636 case OPROMPATH2NODE:
631 if ((file->f_mode & FMODE_READ) == 0) 637 if ((file->f_mode & FMODE_READ) == 0)
632 return -EPERM; 638 return -EPERM;
633 return openprom_sunos_ioctl(inode, file, cmd, arg, NULL); 639 return openprom_sunos_ioctl(file, cmd, arg, NULL);
634 640
635 case OPIOCGET: 641 case OPIOCGET:
636 case OPIOCNEXTPROP: 642 case OPIOCNEXTPROP:
@@ -639,12 +645,12 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
639 case OPIOCGETCHILD: 645 case OPIOCGETCHILD:
640 if ((file->f_mode & FMODE_READ) == 0) 646 if ((file->f_mode & FMODE_READ) == 0)
641 return -EBADF; 647 return -EBADF;
642 return openprom_bsd_ioctl(inode,file,cmd,arg); 648 return openprom_bsd_ioctl(file,cmd,arg);
643 649
644 case OPIOCSET: 650 case OPIOCSET:
645 if ((file->f_mode & FMODE_WRITE) == 0) 651 if ((file->f_mode & FMODE_WRITE) == 0)
646 return -EBADF; 652 return -EBADF;
647 return openprom_bsd_ioctl(inode,file,cmd,arg); 653 return openprom_bsd_ioctl(file,cmd,arg);
648 654
649 default: 655 default:
650 return -EINVAL; 656 return -EINVAL;
@@ -676,7 +682,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
676 case OPROMSETCUR: 682 case OPROMSETCUR:
677 case OPROMPCI2NODE: 683 case OPROMPCI2NODE:
678 case OPROMPATH2NODE: 684 case OPROMPATH2NODE:
679 rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 685 rval = openprom_ioctl(file, cmd, arg);
680 break; 686 break;
681 } 687 }
682 688
@@ -709,7 +715,7 @@ static int openprom_release(struct inode * inode, struct file * file)
709static const struct file_operations openprom_fops = { 715static const struct file_operations openprom_fops = {
710 .owner = THIS_MODULE, 716 .owner = THIS_MODULE,
711 .llseek = no_llseek, 717 .llseek = no_llseek,
712 .ioctl = openprom_ioctl, 718 .unlocked_ioctl = openprom_ioctl,
713 .compat_ioctl = openprom_compat_ioctl, 719 .compat_ioctl = openprom_compat_ioctl,
714 .open = openprom_open, 720 .open = openprom_open,
715 .release = openprom_release, 721 .release = openprom_release,
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index ddf7f9a1b336..55947725f609 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -954,8 +954,7 @@ static int mon_bin_queued(struct mon_reader_bin *rp)
954 954
955/* 955/*
956 */ 956 */
957static int mon_bin_ioctl(struct inode *inode, struct file *file, 957static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
958 unsigned int cmd, unsigned long arg)
959{ 958{
960 struct mon_reader_bin *rp = file->private_data; 959 struct mon_reader_bin *rp = file->private_data;
961 // struct mon_bus* mbus = rp->r.m_bus; 960 // struct mon_bus* mbus = rp->r.m_bus;
@@ -1095,6 +1094,19 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
1095 return ret; 1094 return ret;
1096} 1095}
1097 1096
1097static long mon_bin_unlocked_ioctl(struct file *file, unsigned int cmd,
1098 unsigned long arg)
1099{
1100 int ret;
1101
1102 lock_kernel();
1103 ret = mon_bin_ioctl(file, cmd, arg);
1104 unlock_kernel();
1105
1106 return ret;
1107}
1108
1109
1098#ifdef CONFIG_COMPAT 1110#ifdef CONFIG_COMPAT
1099static long mon_bin_compat_ioctl(struct file *file, 1111static long mon_bin_compat_ioctl(struct file *file,
1100 unsigned int cmd, unsigned long arg) 1112 unsigned int cmd, unsigned long arg)
@@ -1148,14 +1160,13 @@ static long mon_bin_compat_ioctl(struct file *file,
1148 return 0; 1160 return 0;
1149 1161
1150 case MON_IOCG_STATS: 1162 case MON_IOCG_STATS:
1151 return mon_bin_ioctl(NULL, file, cmd, 1163 return mon_bin_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
1152 (unsigned long) compat_ptr(arg));
1153 1164
1154 case MON_IOCQ_URB_LEN: 1165 case MON_IOCQ_URB_LEN:
1155 case MON_IOCQ_RING_SIZE: 1166 case MON_IOCQ_RING_SIZE:
1156 case MON_IOCT_RING_SIZE: 1167 case MON_IOCT_RING_SIZE:
1157 case MON_IOCH_MFLUSH: 1168 case MON_IOCH_MFLUSH:
1158 return mon_bin_ioctl(NULL, file, cmd, arg); 1169 return mon_bin_ioctl(file, cmd, arg);
1159 1170
1160 default: 1171 default:
1161 ; 1172 ;
@@ -1239,7 +1250,7 @@ static const struct file_operations mon_fops_binary = {
1239 .read = mon_bin_read, 1250 .read = mon_bin_read,
1240 /* .write = mon_text_write, */ 1251 /* .write = mon_text_write, */
1241 .poll = mon_bin_poll, 1252 .poll = mon_bin_poll,
1242 .ioctl = mon_bin_ioctl, 1253 .unlocked_ioctl = mon_bin_unlocked_ioctl,
1243#ifdef CONFIG_COMPAT 1254#ifdef CONFIG_COMPAT
1244 .compat_ioctl = mon_bin_compat_ioctl, 1255 .compat_ioctl = mon_bin_compat_ioctl,
1245#endif 1256#endif
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 1becdc3837e6..8ec94f15a738 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -11,6 +11,7 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/usb.h> 12#include <linux/usb.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/smp_lock.h>
14#include <asm/uaccess.h> 15#include <asm/uaccess.h>
15 16
16#include "usb_mon.h" 17#include "usb_mon.h"
@@ -63,6 +64,6 @@ const struct file_operations mon_fops_stat = {
63 .read = mon_stat_read, 64 .read = mon_stat_read,
64 /* .write = mon_stat_write, */ 65 /* .write = mon_stat_write, */
65 /* .poll = mon_stat_poll, */ 66 /* .poll = mon_stat_poll, */
66 /* .ioctl = mon_stat_ioctl, */ 67 /* .unlocked_ioctl = mon_stat_ioctl, */
67 .release = mon_stat_release, 68 .release = mon_stat_release,
68}; 69};