Commit 55929332 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Frederic Weisbecker

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent 703c631e
...@@ -265,8 +265,8 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait) ...@@ -265,8 +265,8 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait)
* Only when everyone who has opened /dev/apm_bios with write permission * Only when everyone who has opened /dev/apm_bios with write permission
* has acknowledge does the actual suspend happen. * has acknowledge does the actual suspend happen.
*/ */
static int static long
apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) apm_ioctl(struct file *filp, u_int cmd, u_long arg)
{ {
struct apm_user *as = filp->private_data; struct apm_user *as = filp->private_data;
int err = -EINVAL; int err = -EINVAL;
...@@ -274,6 +274,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) ...@@ -274,6 +274,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
if (!as->suser || !as->writer) if (!as->suser || !as->writer)
return -EPERM; return -EPERM;
lock_kernel();
switch (cmd) { switch (cmd) {
case APM_IOC_SUSPEND: case APM_IOC_SUSPEND:
mutex_lock(&state_lock); mutex_lock(&state_lock);
...@@ -334,6 +335,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) ...@@ -334,6 +335,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
mutex_unlock(&state_lock); mutex_unlock(&state_lock);
break; break;
} }
unlock_kernel();
return err; return err;
} }
...@@ -397,7 +399,7 @@ static const struct file_operations apm_bios_fops = { ...@@ -397,7 +399,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = apm_read, .read = apm_read,
.poll = apm_poll, .poll = apm_poll,
.ioctl = apm_ioctl, .unlocked_ioctl = apm_ioctl,
.open = apm_open, .open = apm_open,
.release = apm_release, .release = apm_release,
}; };
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -106,8 +107,7 @@ static unsigned int DeviceErrorCount; /* number of device error */ ...@@ -106,8 +107,7 @@ static unsigned int DeviceErrorCount; /* number of device error */
static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *); static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *);
static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *); static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *);
static int ac_ioctl(struct inode *, struct file *, unsigned int, static long ac_ioctl(struct file *, unsigned int, unsigned long);
unsigned long);
static irqreturn_t ac_interrupt(int, void *); static irqreturn_t ac_interrupt(int, void *);
static const struct file_operations ac_fops = { static const struct file_operations ac_fops = {
...@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = { ...@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
.llseek = no_llseek, .llseek = no_llseek,
.read = ac_read, .read = ac_read,
.write = ac_write, .write = ac_write,
.ioctl = ac_ioctl, .unlocked_ioctl = ac_ioctl,
}; };
static struct miscdevice ac_miscdev = { static struct miscdevice ac_miscdev = {
...@@ -689,7 +689,7 @@ static irqreturn_t ac_interrupt(int vec, void *dev_instance) ...@@ -689,7 +689,7 @@ static irqreturn_t ac_interrupt(int vec, void *dev_instance)
static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ /* @ ADG ou ATO selon le cas */ { /* @ ADG ou ATO selon le cas */
int i; int i;
...@@ -712,6 +712,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un ...@@ -712,6 +712,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return -EFAULT; return -EFAULT;
} }
lock_kernel();
IndexCard = adgl->num_card-1; IndexCard = adgl->num_card-1;
if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { 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,6 +722,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
warncount--; warncount--;
} }
kfree(adgl); kfree(adgl);
unlock_kernel();
return -EINVAL; return -EINVAL;
} }
...@@ -838,6 +840,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un ...@@ -838,6 +840,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
} }
Dummy = readb(apbs[IndexCard].RamIO + VERS); Dummy = readb(apbs[IndexCard].RamIO + VERS);
kfree(adgl); kfree(adgl);
unlock_kernel();
return 0; return 0;
} }
...@@ -232,7 +232,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) ...@@ -232,7 +232,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
} }
static int static int
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) ds1620_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ {
struct therm therm; struct therm therm;
union { union {
...@@ -316,6 +316,18 @@ ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned ...@@ -316,6 +316,18 @@ ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
return 0; return 0;
} }
static long
ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = ds1620_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
#ifdef THERM_USE_PROC #ifdef THERM_USE_PROC
static int static int
proc_therm_ds1620_read(char *buf, char **start, off_t offset, proc_therm_ds1620_read(char *buf, char **start, off_t offset,
...@@ -344,7 +356,7 @@ static const struct file_operations ds1620_fops = { ...@@ -344,7 +356,7 @@ static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = ds1620_open, .open = ds1620_open,
.read = ds1620_read, .read = ds1620_read,
.ioctl = ds1620_ioctl, .unlocked_ioctl = ds1620_unlocked_ioctl,
}; };
static struct miscdevice ds1620_miscdev = { static struct miscdevice ds1620_miscdev = {
......
...@@ -93,7 +93,7 @@ static ssize_t dtlk_write(struct file *, const char __user *, ...@@ -93,7 +93,7 @@ static ssize_t dtlk_write(struct file *, const char __user *,
static unsigned int dtlk_poll(struct file *, poll_table *); static unsigned int dtlk_poll(struct file *, poll_table *);
static int dtlk_open(struct inode *, struct file *); static int dtlk_open(struct inode *, struct file *);
static int dtlk_release(struct inode *, struct file *); static int dtlk_release(struct inode *, struct file *);
static int dtlk_ioctl(struct inode *inode, struct file *file, static long dtlk_ioctl(struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static const struct file_operations dtlk_fops = static const struct file_operations dtlk_fops =
...@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops = ...@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
.read = dtlk_read, .read = dtlk_read,
.write = dtlk_write, .write = dtlk_write,
.poll = dtlk_poll, .poll = dtlk_poll,
.ioctl = dtlk_ioctl, .unlocked_ioctl = dtlk_ioctl,
.open = dtlk_open, .open = dtlk_open,
.release = dtlk_release, .release = dtlk_release,
}; };
...@@ -263,8 +263,7 @@ static void dtlk_timer_tick(unsigned long data) ...@@ -263,8 +263,7 @@ static void dtlk_timer_tick(unsigned long data)
wake_up_interruptible(&dtlk_process_list); wake_up_interruptible(&dtlk_process_list);
} }
static int dtlk_ioctl(struct inode *inode, static long dtlk_ioctl(struct file *file,
struct file *file,
unsigned int cmd, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
...@@ -276,7 +275,9 @@ static int dtlk_ioctl(struct inode *inode, ...@@ -276,7 +275,9 @@ static int dtlk_ioctl(struct inode *inode,
switch (cmd) { switch (cmd) {
case DTLK_INTERROGATE: case DTLK_INTERROGATE:
lock_kernel();
sp = dtlk_interrogate(); sp = dtlk_interrogate();
unlock_kernel();
if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
return -EINVAL; return -EINVAL;
return 0; return 0;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/nvram.h> #include <asm/nvram.h>
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
...@@ -84,8 +85,7 @@ static ssize_t write_nvram(struct file *file, const char __user *buf, ...@@ -84,8 +85,7 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,
return p - buf; return p - buf;
} }
static int nvram_ioctl(struct inode *inode, struct file *file, static int nvram_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
switch(cmd) { switch(cmd) {
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
...@@ -116,12 +116,23 @@ static int nvram_ioctl(struct inode *inode, struct file *file, ...@@ -116,12 +116,23 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
return 0; return 0;
} }
static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = nvram_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
const struct file_operations nvram_fops = { const struct file_operations nvram_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = nvram_llseek, .llseek = nvram_llseek,
.read = read_nvram, .read = read_nvram,
.write = write_nvram, .write = write_nvram,
.ioctl = nvram_ioctl, .unlocked_ioctl = nvram_unlocked_ioctl,
}; };
static struct miscdevice nvram_dev = { static struct miscdevice nvram_dev = {
......
...@@ -262,7 +262,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit) ...@@ -262,7 +262,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
#endif #endif
} }
static int gen_rtc_ioctl(struct inode *inode, struct file *file, static int gen_rtc_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct rtc_time wtime; struct rtc_time wtime;
...@@ -332,6 +332,18 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file, ...@@ -332,6 +332,18 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
return -EINVAL; return -EINVAL;
} }
static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret;
lock_kernel();
ret = gen_rtc_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
/* /*
* We enforce only one user at a time here with the open/close. * We enforce only one user at a time here with the open/close.
* Also clear the previous interrupt data on an open, and clean * Also clear the previous interrupt data on an open, and clean
...@@ -482,7 +494,7 @@ static const struct file_operations gen_rtc_fops = { ...@@ -482,7 +494,7 @@ static const struct file_operations gen_rtc_fops = {
.read = gen_rtc_read, .read = gen_rtc_read,
.poll = gen_rtc_poll, .poll = gen_rtc_poll,
#endif #endif
.ioctl = gen_rtc_ioctl, .unlocked_ioctl = gen_rtc_unlocked_ioctl,
.open = gen_rtc_open, .open = gen_rtc_open,
.release = gen_rtc_release, .release = gen_rtc_release,
}; };
......
...@@ -431,14 +431,18 @@ static int hpet_release(struct inode *inode, struct file *file) ...@@ -431,14 +431,18 @@ static int hpet_release(struct inode *inode, struct file *file)
static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int); static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
static int static long hpet_ioctl(struct file *file, unsigned int cmd,
hpet_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct hpet_dev *devp; struct hpet_dev *devp;
int ret;
devp = file->private_data; devp = file->private_data;
return hpet_ioctl_common(devp, cmd, arg, 0); lock_kernel();
ret = hpet_ioctl_common(devp, cmd, arg, 0);
unlock_kernel();
return ret;
} }
static int hpet_ioctl_ieon(struct hpet_dev *devp) static int hpet_ioctl_ieon(struct hpet_dev *devp)
...@@ -654,7 +658,7 @@ static const struct file_operations hpet_fops = { ...@@ -654,7 +658,7 @@ static const struct file_operations hpet_fops = {
.llseek = no_llseek, .llseek = no_llseek,
.read = hpet_read, .read = hpet_read,
.poll = hpet_poll, .poll = hpet_poll,
.ioctl = hpet_ioctl, .unlocked_ioctl = hpet_ioctl,
.open = hpet_open, .open = hpet_open,
.release = hpet_release, .release = hpet_release,
.fasync = hpet_fasync, .fasync = hpet_fasync,
......
...@@ -228,8 +228,7 @@ static int handle_send_req(ipmi_user_t user, ...@@ -228,8 +228,7 @@ static int handle_send_req(ipmi_user_t user,
return rv; return rv;
} }
static int ipmi_ioctl(struct inode *inode, static int ipmi_ioctl(struct file *file,
struct file *file,
unsigned int cmd, unsigned int cmd,
unsigned long data) unsigned long data)
{ {
...@@ -630,6 +629,23 @@ static int ipmi_ioctl(struct inode *inode, ...@@ -630,6 +629,23 @@ static int ipmi_ioctl(struct inode *inode,
return rv; return rv;
} }
/*
* Note: it doesn't make sense to take the BKL here but
* not in compat_ipmi_ioctl. -arnd
*/
static long ipmi_unlocked_ioctl(struct file *file,
unsigned int cmd,
unsigned long data)
{
int ret;
lock_kernel();
ret = ipmi_ioctl(file, cmd, data);
unlock_kernel();
return ret;
}
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
/* /*
...@@ -802,7 +818,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, ...@@ -802,7 +818,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
if (copy_to_user(precv64, &recv64, sizeof(recv64))) if (copy_to_user(precv64, &recv64, sizeof(recv64)))
return -EFAULT; return -EFAULT;
rc = ipmi_ioctl(filep->f_path.dentry->d_inode, filep, rc = ipmi_ioctl(filep,
((cmd == COMPAT_IPMICTL_RECEIVE_MSG) ((cmd == COMPAT_IPMICTL_RECEIVE_MSG)
? IPMICTL_RECEIVE_MSG ? IPMICTL_RECEIVE_MSG
: IPMICTL_RECEIVE_MSG_TRUNC), : IPMICTL_RECEIVE_MSG_TRUNC),
...@@ -819,14 +835,14 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, ...@@ -819,14 +835,14 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
return rc; return rc;
} }
default: default:
return ipmi_ioctl(filep->f_path.dentry->d_inode, filep, cmd, arg); return ipmi_ioctl(filep, cmd, arg);
} }
} }
#endif #endif
static const struct file_operations ipmi_fops = { static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = ipmi_ioctl, .unlocked_ioctl = ipmi_unlocked_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl, .compat_ioctl = compat_ipmi_ioctl,
#endif #endif
......
...@@ -659,7 +659,7 @@ static struct watchdog_info ident = { ...@@ -659,7 +659,7 @@ static struct watchdog_info ident = {
.identity = "IPMI" .identity = "IPMI"
}; };
static int ipmi_ioctl(struct inode *inode, struct file *file, static int ipmi_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
...@@ -730,6 +730,19 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, ...@@ -730,6 +730,19 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
} }
} }
static long ipmi_unlocked_ioctl(struct file *file,
unsigned int cmd,
unsigned long arg)
{
int ret;
lock_kernel();
ret = ipmi_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
static ssize_t ipmi_write(struct file *file, static ssize_t ipmi_write(struct file *file,
const char __user *buf, const char __user *buf,
size_t len, size_t len,
...@@ -880,7 +893,7 @@ static const struct file_operations ipmi_wdog_fops = { ...@@ -880,7 +893,7 @@ static const struct file_operations ipmi_wdog_fops = {
.read = ipmi_read, .read = ipmi_read,
.poll = ipmi_poll, .poll = ipmi_poll,
.write = ipmi_write, .write = ipmi_write,
.ioctl = ipmi_ioctl, .unlocked_ioctl = ipmi_unlocked_ioctl,
.open = ipmi_open, .open = ipmi_open,
.release = ipmi_close, .release = ipmi_close,
.fasync = ipmi_fasync, .fasync = ipmi_fasync,
......
...@@ -296,8 +296,8 @@ static ssize_t nvram_write(struct file *file, const char __user *buf, ...@@ -296,8 +296,8 @@ static ssize_t nvram_write(struct file *file, const char __user *buf,
return -EIO; return -EIO;
} }
static int nvram_ioctl(struct inode *inode, struct file *file, static long nvram_ioctl(struct file *file, unsigned int cmd,
unsigned int cmd, unsigned long arg) unsigned long arg)
{ {
int i; int i;
...@@ -308,6 +308,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file, ...@@ -308,6 +308,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
lock_kernel();
spin_lock_irq(&rtc_lock); spin_lock_irq(&rtc_lock);
for (i = 0; i < NVRAM_BYTES; ++i) for (i = 0; i < NVRAM_BYTES; ++i)
...@@ -315,6 +316,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file, ...@@ -315,6 +316,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
__nvram_set_checksum(); __nvram_set_checksum();
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
unlock_kernel();
return 0; return 0;
case NVRAM_SETCKS: case NVRAM_SETCKS:
...@@ -323,9 +325,11 @@ static int nvram_ioctl(struct inode *inode, struct file *file, ...@@ -323,9 +325,11 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
lock_kernel();
spin_lock_irq(&rtc_lock); spin_lock_irq(&rtc_lock);
__nvram_set_checksum(); __nvram_set_checksum();
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
unlock_kernel();
return 0; return 0;
default: default:
...@@ -422,7 +426,7 @@ static const struct file_operations nvram_fops = { ...@@ -422,7 +426,7 @@ static const struct file_operations nvram_fops = {
.llseek = nvram_llseek, .llseek = nvram_llseek,
.read = nvram_read, .read = nvram_read,
.write = nvram_write, .write = nvram_write,
.ioctl = nvram_ioctl, .unlocked_ioctl = nvram_ioctl,
.open = nvram_open, .open = nvram_open,
.release = nvram_release, .release = nvram_release,
}; };
......
...@@ -94,8 +94,9 @@ static int get_flash_id(void) ...@@ -94,8 +94,9 @@ static int get_flash_id(void)
return c2; return c2;
} }
static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cmd, unsigned long arg) static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{ {
lock_kernel();
switch (cmd) { switch (cmd) {
case CMD_WRITE_DISABLE: case CMD_WRITE_DISABLE:
gbWriteBase64Enable = 0; gbWriteBase64Enable = 0;
...@@ -113,8 +114,10 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm ...@@ -113,8 +114,10 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm
default: default:
gbWriteBase64Enable = 0; gbWriteBase64Enable = 0;
gbWriteEnable = 0; gbWriteEnable = 0;
unlock_kernel();
return -EINVAL; return -EINVAL;
} }
unlock_kernel();
return 0; return 0;
} }
...@@ -631,7 +634,7 @@ static const struct file_operations flash_fops = ...@@ -631,7 +634,7 @@ static const struct file_operations flash_fops =
.llseek = flash_llseek, .llseek = flash_llseek,
.read = flash_read, .read = flash_read,
.write = flash_write, .write = flash_write,
.ioctl = flash_ioctl, .unlocked_ioctl = flash_ioctl,
}; };
static struct miscdevice flash_miscdev = static struct miscdevice flash_miscdev =
......
...@@ -121,13 +121,17 @@ static int raw_release(struct inode *inode, struct file *filp) ...@@ -121,13 +121,17 @@ static int raw_release(struct inode *inode, struct file *filp)
/* /*
* Forward ioctls to the underlying block device. * Forward ioctls to the underlying block device.
*/ */
static int static long
raw_ioctl(struct inode *inode, struct file *filp, raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
unsigned int command, unsigned long arg)
{ {
struct block_device *bdev = filp->private_data; struct block_device *bdev = filp->private_data;
int ret;
lock_kernel();
ret = blkdev_ioctl(bdev, 0, command, arg);
unlock_kernel();
return blkdev_ioctl(bdev, 0, command, arg); return ret;
} }
static void bind_device(struct raw_config_request *rq) static void bind_device(struct raw_config_request *rq)
...@@ -141,13 +145,14 @@ static void bind_device(struct raw_config_request *rq) ...@@ -141,13 +145,14 @@ static void bind_device(struct raw_config_request *rq)
* Deal with ioctls against the raw-device control interface, to bind * Deal with ioctls against the raw-device control interface, to bind
* and unbind other raw devices. * and unbind other raw devices.
*/ */
static int raw_ctl_ioctl(struct inode *inode, struct file *filp, static long raw_ctl_ioctl(struct file *filp, unsigned int command,
unsigned int command, unsigned long arg) unsigned long arg)
{ {
struct raw_config_request rq; struct raw_config_request rq;
struct raw_device_data *rawdev; struct raw_device_data *rawdev;
int err = 0; int err = 0;
lock_kernel();
switch (command) { switch (command) {
case RAW_SETBIND: case RAW_SETBIND:
case RAW_GETBIND: case RAW_GETBIND:
...@@ -240,6 +245,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, ...@@ -240,6 +245,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
break; break;
} }
out: out:
unlock_kernel();
return err; return err;
} }
...@@ -250,13 +256,13 @@ static const struct file_operations raw_fops = { ...@@ -250,13 +256,13 @@ static const struct file_operations raw_fops = {
.aio_write = blkdev_aio_write, .aio_write = blkdev_aio_write,
.fsync = blkdev_fsync, .fsync = blkdev_fsync,
.open = raw_open, .open = raw_open,
.release= raw_release, .release = raw_release,
.ioctl = raw_ioctl, .unlocked_ioctl = raw_ioctl,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static const struct file_operations raw_ctl_fops = { static const struct file_operations raw_ctl_fops = {
.ioctl = raw_ctl_ioctl, .unlocked_ioctl = raw_ctl_ioctl,
.open = raw_open, .open = raw_open,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h> #include <linux/hwmon-sysfs.h>
#include <linux/smp_lock.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
...@@ -847,8 +848,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf, ...@@ -847,8 +848,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count; return count;
} }
static int watchdog_ioctl(struct inode *inode, struct file *filp, static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
static struct watchdog_info ident = { static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
...@@ -858,6 +858,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp, ...@@ -858,6 +858,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int i, ret = 0; int i, ret = 0;
struct fschmd_data *data = filp->private_data; struct fschmd_data *data = filp->private_data;
lock_kernel();
switch (cmd) { switch (cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
ident.firmware_version = data->revision; ident.firmware_version = data->revision;
...@@ -914,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp, ...@@ -914,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default: default:
ret = -ENOTTY; ret = -ENOTTY;
} }
unlock_kernel();
return ret; return ret;
} }
...@@ -924,7 +925,7 @@ static const struct file_operations watchdog_fops = { ...@@ -924,7 +925,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open, .open = watchdog_open,
.release = watchdog_release, .release = watchdog_release,
.write = watchdog_write, .write = watchdog_write,
.ioctl = watchdog_ioctl, .unlocked_ioctl = watchdog_ioctl,
}; };
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/smp_lock.h>
#include <linux/hwmon-vid.h> #include <linux/hwmon-vid.h>
#include <linux/hwmon-sysfs.h> #include <linux/hwmon-sysfs.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -1319,8 +1320,8 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf, ...@@ -1319,8 +1320,8 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count; return count;
} }
static int watchdog_ioctl(struct inode *inode, struct file *filp, static long watchdog_ioctl(struct file *filp, unsigned int cmd,
unsigned int cmd, unsigned long arg) unsigned long arg)
{ {
static struct watchdog_info ident = { static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | .options = WDIOF_KEEPALIVEPING |
...@@ -1332,6 +1333,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp, ...@@ -1332,6 +1333,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int val, ret = 0; int val, ret = 0;
struct w83793_data *data = filp->private_data; struct w83793_data *data = filp->private_data;
lock_kernel();
switch (cmd) { switch (cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
if (!nowayout) if (!nowayout)
...@@ -1385,7 +1387,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp, ...@@ -1385,7 +1387,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default: default:
ret = -ENOTTY; ret = -ENOTTY;
} }
unlock_kernel();
return ret; return ret;
} }
...@@ -1395,7 +1397,7 @@ static const struct file_operations watchdog_fops = { ...@@ -1395,7 +1397,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open, .open = watchdog_open,
.release = watchdog_close, .release = watchdog_close,
.write = watchdog_write, .write = watchdog_write,
.ioctl = watchdog_ioctl, .unlocked_ioctl = watchdog_ioctl,
}; };
/* /*
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/smp_lock.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
...@@ -64,7 +65,7 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait); ...@@ -64,7 +65,7 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf, static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos); size_t count, loff_t *ppos);
static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait); static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
...@@ -512,7 +513,7 @@ static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, ...@@ -512,7 +513,7 @@ static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
return len; return len;
} }
static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, static int hp_sdc_rtc_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
#if 1 #if 1
...@@ -659,12 +660,25 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, ...@@ -659,12 +660,25 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
#endif #endif
} }
static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = hp_sdc_rtc_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
static const struct file_operations hp_sdc_rtc_fops = { static const struct file_operations hp_sdc_rtc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .llseek = no_llseek,
.read = hp_sdc_rtc_read, .read = hp_sdc_rtc_read,
.poll = hp_sdc_rtc_poll, .poll = hp_sdc_rtc_poll,
.ioctl = hp_sdc_rtc_ioctl, .unlocked_ioctl = hp_sdc_rtc_ioctl,
.open = hp_sdc_rtc_open, .open = hp_sdc_rtc_open,
.fasync = hp_sdc_rtc_fasync, .fasync = hp_sdc_rtc_fasync,
}; };
......
...@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = { ...@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek, .llseek = nvram_llseek,
.read = read_nvram, .read = read_nvram,
.write = write_nvram, .write = write_nvram,
.ioctl = nvram_ioctl, .unlocked_ioctl = nvram_ioctl,
}; };
static struct miscdevice nvram_dev = { static struct miscdevice nvram_dev = {
......
...@@ -2273,8 +2273,7 @@ static int register_pmu_pm_ops(void) ...@@ -2273,8 +2273,7 @@ static int register_pmu_pm_ops(void)
device_initcall(register_pmu_pm_ops); device_initcall(register_pmu_pm_ops);
#endif #endif
static int static int pmu_ioctl(struct file *filp,
pmu_ioctl(struct inode * inode, struct file *filp,
u_int cmd, u_long arg) u_int cmd, u_long arg)
{ {
__u32 __user *argp = (__u32 __user *)arg; __u32 __user *argp = (__u32 __user *)arg;
...@@ -2337,11 +2336,23 @@ pmu_ioctl(struct inode * inode, struct file *filp, ...@@ -2337,11 +2336,23 @@ pmu_ioctl(struct inode * inode, struct file *filp,
return error; return error;
} }
static long pmu_unlocked_ioctl(struct file *filp,
u_int cmd, u_long arg)
{
int ret;
lock_kernel();
ret = pmu_ioctl(filp, cmd, arg);
unlock_kernel();
return ret;
}
static const struct file_operations pmu_device_fops = { static const struct file_operations pmu_device_fops = {
.read = pmu_read, .read = pmu_read,
.write = pmu_write, .write = pmu_write,
.poll = pmu_fpoll, .poll = pmu_fpoll,
.ioctl = pmu_ioctl, .unlocked_ioctl = pmu_unlocked_ioctl,
.open = pmu_open, .open = pmu_open,
.release = pmu_release, .release = pmu_release,
}; };
......
...@@ -450,8 +450,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start, ...@@ -450,8 +450,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
return ret; return ret;
} }
static int mtd_ioctl(struct inode *inode, struct file *file, static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
u_int cmd, u_long arg)
{ {
struct mtd_file_info *mfi = file->private_data; struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd; struct mtd_info *mtd = mfi->mtd;
...@@ -822,6 +821,17 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -822,6 +821,17 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
return ret; return ret;
} /* memory_ioctl */ } /* memory_ioctl */
static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
{
int ret;
lock_kernel();
ret = mtd_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
struct mtd_oob_buf32 { struct mtd_oob_buf32 {
...@@ -836,7 +846,6 @@ struct mtd_oob_buf32 { ...@@ -836,7 +846,6 @@ struct mtd_oob_buf32 {
static long mtd_compat_ioctl(struct file *file, unsigned int cmd, static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct inode *inode = file->f_path.dentry->d_inode;
struct mtd_file_info *mfi = file->private_data; struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd; struct mtd_info *mtd = mfi->mtd;
void __user *argp = compat_ptr(arg); void __user *argp = compat_ptr(arg);
...@@ -874,7 +883,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd, ...@@ -874,7 +883,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
break; break;
} }
default: default:
ret = mtd_ioctl(inode, file, cmd, (unsigned long)argp); ret = mtd_ioctl(file, cmd, (unsigned long)argp);
} }
unlock_kernel(); unlock_kernel();
...@@ -942,7 +951,7 @@ static const struct file_operations mtd_fops = { ...@@ -942,7 +951,7 @@ static const struct file_operations mtd_fops = {
.llseek = mtd_lseek, .llseek = mtd_lseek,
.read = mtd_read, .read = mtd_read,
.write = mtd_write, .write = mtd_write,
.ioctl = mtd_ioctl, .unlocked_ioctl = mtd_unlocked_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl, .compat_ioctl = mtd_compat_ioctl,
#endif #endif
......
...@@ -818,8 +818,7 @@ static u_int ds_poll(struct file *file, poll_table *wait) ...@@ -818,8 +818,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)
/*====================================================================*/ /*====================================================================*/
static int ds_ioctl(struct inode *inode, struct file *file, static int ds_ioctl(struct file *file, u_int cmd, u_long arg)
u_int cmd, u_long arg)
{ {
struct pcmcia_socket *s; struct pcmcia_socket *s;
void __user *uarg = (char __user *)arg; void __user *uarg = (char __user *)arg;
...@@ -1026,13 +1025,25 @@ static int ds_ioctl(struct inode *inode, struct file *file, ...@@ -1026,13 +1025,25 @@ static int ds_ioctl(struct inode *inode, struct file *file,
return err; return err;
} /* ds_ioctl */ } /* ds_ioctl */
static long ds_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = ds_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
/*====================================================================*/ /*====================================================================*/
static const struct file_operations ds_fops = { static const struct file_operations ds_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = ds_open, .open = ds_open,
.release = ds_release, .release = ds_release,
.ioctl = ds_ioctl, .unlocked_ioctl = ds_unlocked_ioctl,
.read = ds_read, .read = ds_read,
.write = ds_write, .write = ds_write,
.poll = ds_poll, .poll = ds_poll,
......
...@@ -623,7 +623,7 @@ static ssize_t wdt_read(struct file *file, char __user *buf, ...@@ -623,7 +623,7 @@ static ssize_t wdt_read(struct file *file, char __user *buf,
* according to their available features. We only actually usefully support * according to their available features. We only actually usefully support
* querying capabilities and current status. * querying capabilities and current status.
*/ */
static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
int new_margin, rv; int new_margin, rv;
...@@ -676,6 +676,18 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -676,6 +676,18 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
return -ENOTTY; return -ENOTTY;
} }
static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret;
lock_kernel();
ret = wdt_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
/** /**
* wdt_open: * wdt_open:
* @inode: inode of device * @inode: inode of device
...@@ -736,7 +748,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code, ...@@ -736,7 +748,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = { static const struct file_operations wdt_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = wdt_read, .read = wdt_read,
.ioctl = wdt_ioctl, .unlocked_ioctl = wdt_unlocked_ioctl,
.write = wdt_write, .write = wdt_write,
.open = wdt_open, .open = wdt_open,
.release = wdt_release, .release = wdt_release,
......
...@@ -298,7 +298,7 @@ static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsiz ...@@ -298,7 +298,7 @@ static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsiz
/* /*
* SunOS and Solaris /dev/openprom ioctl calls. * SunOS and Solaris /dev/openprom ioctl calls.
*/ */
static int openprom_sunos_ioctl(struct inode * inode, struct file * file, static long openprom_sunos_ioctl(struct file * file,
unsigned int cmd, unsigned long arg, unsigned int cmd, unsigned long arg,
struct device_node *dp) struct device_node *dp)
{ {
...@@ -316,6 +316,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file, ...@@ -316,6 +316,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
if (bufsize < 0) if (bufsize < 0)
return bufsize; return bufsize;
lock_kernel();
switch (cmd) { switch (cmd) {
case OPROMGETOPT: case OPROMGETOPT:
case OPROMGETPROP: case OPROMGETPROP:
...@@ -365,6 +367,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file, ...@@ -365,6 +367,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
} }
kfree(opp); kfree(opp);
unlock_kernel();
return error; return error;
} }
...@@ -547,13 +551,14 @@ static int opiocgetnext(unsigned int cmd, void __user *argp) ...@@ -547,13 +551,14 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
return 0; return 0;
} }
static int openprom_bsd_ioctl(struct inode * inode, struct file * file, static int openprom_bsd_ioctl(struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
DATA *data = (DATA *) file->private_data; DATA *data = (DATA *) file->private_data;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int err; int err;
lock_kernel();
switch (cmd) { switch (cmd) {
case OPIOCGET: case OPIOCGET:
err = opiocget(argp, data); err = opiocget(argp, data);
...@@ -570,10 +575,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, ...@@ -570,10 +575,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
case OPIOCGETOPTNODE: case OPIOCGETOPTNODE:
BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
err = 0;
if (copy_to_user(argp, &options_node->phandle, sizeof(phandle))) if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
return -EFAULT; err = -EFAULT;
break;
return 0;
case OPIOCGETNEXT: case OPIOCGETNEXT:
case OPIOCGETCHILD: case OPIOCGETCHILD:
...@@ -581,9 +586,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, ...@@ -581,9 +586,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
break; break;
default: default:
return -EINVAL; err = -EINVAL;
break;
}; };
unlock_kernel();
return err; return err;
} }
...@@ -592,7 +598,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, ...@@ -592,7 +598,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
/* /*
* Handoff control to the correct ioctl handler. * Handoff control to the correct ioctl handler.
*/ */
static int openprom_ioctl(struct inode * inode, struct file * file, static long openprom_ioctl(struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
DATA *data = (DATA *) file->private_data; DATA *data = (DATA *) file->private_data;
...@@ -602,14 +608,14 @@ static int openprom_ioctl(struct inode * inode, struct file * file, ...@@ -602,14 +608,14 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTOPT: case OPROMNXTOPT:
if ((file->f_mode & FMODE_READ) == 0) if ((file->f_mode & FMODE_READ) == 0)
return -EPERM; return -EPERM;
return openprom_sunos_ioctl(inode, file, cmd, arg, return openprom_sunos_ioctl(file, cmd, arg,
options_node); options_node);
case OPROMSETOPT: case OPROMSETOPT:
case OPROMSETOPT2: case OPROMSETOPT2:
if ((file->f_mode & FMODE_WRITE) == 0) if ((file->f_mode & FMODE_WRITE) == 0)
return -EPERM; return -EPERM;
return openprom_sunos_ioctl(inode, file, cmd, arg, return openprom_sunos_ioctl(file, cmd, arg,
options_node); options_node);
case OPROMNEXT: case OPROMNEXT:
...@@ -618,7 +624,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file, ...@@ -618,7 +624,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTPROP: case OPROMNXTPROP:
if ((file->f_mode & FMODE_READ) == 0) if ((file->f_mode & FMODE_READ) == 0)
return -EPERM; return -EPERM;
return openprom_sunos_ioctl(inode, file, cmd, arg, return openprom_sunos_ioctl(file, cmd, arg,
data->current_node); data->current_node);
case OPROMU2P: case OPROMU2P:
...@@ -630,7 +636,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file, ...@@ -630,7 +636,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMPATH2NODE: case OPROMPATH2NODE:
if ((file->f_mode & FMODE_READ) == 0) if ((file->f_mode & FMODE_READ) == 0)
return -EPERM; return -EPERM;
return openprom_sunos_ioctl(inode, file, cmd, arg, NULL); return openprom_sunos_ioctl(file, cmd, arg, NULL);
case OPIOCGET: case OPIOCGET:
case OPIOCNEXTPROP: case OPIOCNEXTPROP:
...@@ -639,12 +645,12 @@ static int openprom_ioctl(struct inode * inode, struct file * file, ...@@ -639,12 +645,12 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPIOCGETCHILD: case OPIOCGETCHILD:
if ((file->f_mode & FMODE_READ) == 0) if ((file->f_mode & FMODE_READ) == 0)
return -EBADF; return -EBADF;
return openprom_bsd_ioctl(inode,file,cmd,arg); return openprom_bsd_ioctl(file,cmd,arg);
case OPIOCSET: case OPIOCSET:
if ((file->f_mode & FMODE_WRITE) == 0) if ((file->f_mode & FMODE_WRITE) == 0)
return -EBADF; return -EBADF;
return openprom_bsd_ioctl(inode,file,cmd,arg); return openprom_bsd_ioctl(file,cmd,arg);
default: default:
return -EINVAL; return -EINVAL;
...@@ -676,7 +682,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd, ...@@ -676,7 +682,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
case OPROMSETCUR: case OPROMSETCUR:
case OPROMPCI2NODE: case OPROMPCI2NODE:
case OPROMPATH2NODE: case OPROMPATH2NODE:
rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); rval = openprom_ioctl(file, cmd, arg);
break; break;
} }
...@@ -709,7 +715,7 @@ static int openprom_release(struct inode * inode, struct file * file) ...@@ -709,7 +715,7 @@ static int openprom_release(struct inode * inode, struct file * file)
static const struct file_operations openprom_fops = { static const struct file_operations openprom_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .llseek = no_llseek,
.ioctl = openprom_ioctl, .unlocked_ioctl = openprom_ioctl,
.compat_ioctl = openprom_compat_ioctl, .compat_ioctl = openprom_compat_ioctl,
.open = openprom_open, .open = openprom_open,
.release = openprom_release, .release = openprom_release,
......
...@@ -954,8 +954,7 @@ static int mon_bin_queued(struct mon_reader_bin *rp) ...@@ -954,8 +954,7 @@ static int mon_bin_queued(struct mon_reader_bin *rp)
/* /*
*/ */
static int mon_bin_ioctl(struct inode *inode, struct file *file, static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
struct mon_reader_bin *rp = file->private_data; struct mon_reader_bin *rp = file->private_data;
// struct mon_bus* mbus = rp->r.m_bus; // struct mon_bus* mbus = rp->r.m_bus;
...@@ -1095,6 +1094,19 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file, ...@@ -1095,6 +1094,19 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
return ret; return ret;
} }
static long mon_bin_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret;
lock_kernel();
ret = mon_bin_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
static long mon_bin_compat_ioctl(struct file *file, static long mon_bin_compat_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
...@@ -1148,14 +1160,13 @@ static long mon_bin_compat_ioctl(struct file *file, ...@@ -1148,14 +1160,13 @@ static long mon_bin_compat_ioctl(struct file *file,
return 0; return 0;
case MON_IOCG_STATS: case MON_IOCG_STATS:
return mon_bin_ioctl(NULL, file, cmd, return mon_bin_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
(unsigned long) compat_ptr(arg));
case MON_IOCQ_URB_LEN: case MON_IOCQ_URB_LEN:
case MON_IOCQ_RING_SIZE: case MON_IOCQ_RING_SIZE:
case MON_IOCT_RING_SIZE: case MON_IOCT_RING_SIZE:
case MON_IOCH_MFLUSH: case MON_IOCH_MFLUSH:
return mon_bin_ioctl(NULL, file, cmd, arg); return mon_bin_ioctl(file, cmd, arg);
default: default:
; ;
...@@ -1239,7 +1250,7 @@ static const struct file_operations mon_fops_binary = { ...@@ -1239,7 +1250,7 @@ static const struct file_operations mon_fops_binary = {
.read = mon_bin_read, .read = mon_bin_read,
/* .write = mon_text_write, */ /* .write = mon_text_write, */
.poll = mon_bin_poll, .poll = mon_bin_poll,
.ioctl = mon_bin_ioctl, .unlocked_ioctl = mon_bin_unlocked_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = mon_bin_compat_ioctl, .compat_ioctl = mon_bin_compat_ioctl,
#endif #endif
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "usb_mon.h" #include "usb_mon.h"
...@@ -63,6 +64,6 @@ const struct file_operations mon_fops_stat = { ...@@ -63,6 +64,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read, .read = mon_stat_read,
/* .write = mon_stat_write, */ /* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */ /* .poll = mon_stat_poll, */
/* .ioctl = mon_stat_ioctl, */ /* .unlocked_ioctl = mon_stat_ioctl, */
.release = mon_stat_release, .release = mon_stat_release,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment