Commit f35d7764 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Jesper Nilsson

cris: push down BKL into some device drivers

A number of cris specific device drivers still use the
locked ->ioctl operation. Convert them to unlocked_ioctl
with explicit lock_kernel calls.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
parent 1d16b0f2
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/smp_lock.h>
#include <linux/bcd.h> #include <linux/bcd.h>
#include <linux/capability.h> #include <linux/capability.h>
...@@ -238,9 +239,7 @@ static unsigned char days_in_mo[] = ...@@ -238,9 +239,7 @@ static unsigned char days_in_mo[] =
/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */ /* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */
static int static int rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{ {
unsigned long flags; unsigned long flags;
...@@ -354,6 +353,17 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -354,6 +353,17 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
} }
} }
static long rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = rtc_ioctl(file, cmd, arg);
unlock_kernel();
return ret;
}
static void static void
print_rtc_status(void) print_rtc_status(void)
{ {
...@@ -375,8 +385,8 @@ print_rtc_status(void) ...@@ -375,8 +385,8 @@ print_rtc_status(void)
/* The various file operations we support. */ /* The various file operations we support. */
static const struct file_operations rtc_fops = { static const struct file_operations rtc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = rtc_ioctl, .unlocked_ioctl = rtc_unlocked_ioctl,
}; };
/* Probe for the chip by writing something to its RAM and try reading it back. */ /* Probe for the chip by writing something to its RAM and try reading it back. */
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/bcd.h> #include <linux/bcd.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -53,7 +54,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ ...@@ -53,7 +54,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
static const unsigned char days_in_month[] = static const unsigned char days_in_month[] =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); static long pcf8563_unlocked_ioctl(struct file *, unsigned int, unsigned long);
/* Cache VL bit value read at driver init since writing the RTC_SECOND /* Cache VL bit value read at driver init since writing the RTC_SECOND
* register clears the VL status. * register clears the VL status.
...@@ -62,7 +63,7 @@ static int voltage_low; ...@@ -62,7 +63,7 @@ static int voltage_low;
static const struct file_operations pcf8563_fops = { static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = pcf8563_ioctl, .unlocked_ioctl = pcf8563_unlocked_ioctl,
}; };
unsigned char unsigned char
...@@ -212,8 +213,7 @@ pcf8563_exit(void) ...@@ -212,8 +213,7 @@ pcf8563_exit(void)
* ioctl calls for this driver. Why return -ENOTTY upon error? Because * ioctl calls for this driver. Why return -ENOTTY upon error? Because
* POSIX says so! * POSIX says so!
*/ */
int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
unsigned long arg)
{ {
/* Some sanity checks. */ /* Some sanity checks. */
if (_IOC_TYPE(cmd) != RTC_MAGIC) if (_IOC_TYPE(cmd) != RTC_MAGIC)
...@@ -339,6 +339,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -339,6 +339,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
return pcf8563_ioctl(filp, cmd, arg);
unlock_kernel();
return ret;
}
static int __init pcf8563_register(void) static int __init pcf8563_register(void)
{ {
if (pcf8563_init() < 0) { if (pcf8563_init() < 0) {
......
...@@ -649,10 +649,10 @@ i2c_release(struct inode *inode, struct file *filp) ...@@ -649,10 +649,10 @@ i2c_release(struct inode *inode, struct file *filp)
/* Main device API. ioctl's to write or read to/from i2c registers. /* Main device API. ioctl's to write or read to/from i2c registers.
*/ */
static int static long
i2c_ioctl(struct inode *inode, struct file *file, i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
int ret;
if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) {
return -ENOTTY; return -ENOTTY;
} }
...@@ -665,9 +665,13 @@ i2c_ioctl(struct inode *inode, struct file *file, ...@@ -665,9 +665,13 @@ i2c_ioctl(struct inode *inode, struct file *file,
I2C_ARGREG(arg), I2C_ARGREG(arg),
I2C_ARGVALUE(arg))); I2C_ARGVALUE(arg)));
return i2c_writereg(I2C_ARGSLAVE(arg), lock_kernel();
ret = i2c_writereg(I2C_ARGSLAVE(arg),
I2C_ARGREG(arg), I2C_ARGREG(arg),
I2C_ARGVALUE(arg)); I2C_ARGVALUE(arg));
unlock_kernel();
return ret;
case I2C_READREG: case I2C_READREG:
{ {
unsigned char val; unsigned char val;
...@@ -675,7 +679,9 @@ i2c_ioctl(struct inode *inode, struct file *file, ...@@ -675,7 +679,9 @@ i2c_ioctl(struct inode *inode, struct file *file,
D(printk("i2cr %d %d ", D(printk("i2cr %d %d ",
I2C_ARGSLAVE(arg), I2C_ARGSLAVE(arg),
I2C_ARGREG(arg))); I2C_ARGREG(arg)));
lock_kernel();
val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg));
unlock_kernel();
D(printk("= %d\n", val)); D(printk("= %d\n", val));
return val; return val;
} }
...@@ -688,10 +694,10 @@ i2c_ioctl(struct inode *inode, struct file *file, ...@@ -688,10 +694,10 @@ i2c_ioctl(struct inode *inode, struct file *file,
} }
static const struct file_operations i2c_fops = { static const struct file_operations i2c_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = i2c_ioctl, .unlocked_ioctl = i2c_ioctl,
.open = i2c_open, .open = i2c_open,
.release = i2c_release, .release = i2c_release,
}; };
static int __init i2c_init(void) static int __init i2c_init(void)
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/smp_lock.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/bcd.h> #include <linux/bcd.h>
#include <linux/mutex.h> #include <linux/mutex.h>
...@@ -49,7 +50,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ ...@@ -49,7 +50,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
static const unsigned char days_in_month[] = static const unsigned char days_in_month[] =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
/* Cache VL bit value read at driver init since writing the RTC_SECOND /* Cache VL bit value read at driver init since writing the RTC_SECOND
* register clears the VL status. * register clears the VL status.
...@@ -57,8 +58,8 @@ int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); ...@@ -57,8 +58,8 @@ int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
static int voltage_low; static int voltage_low;
static const struct file_operations pcf8563_fops = { static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = pcf8563_ioctl .unlocked_ioctl = pcf8563_unlocked_ioctl,
}; };
unsigned char unsigned char
...@@ -208,8 +209,7 @@ pcf8563_exit(void) ...@@ -208,8 +209,7 @@ pcf8563_exit(void)
* ioctl calls for this driver. Why return -ENOTTY upon error? Because * ioctl calls for this driver. Why return -ENOTTY upon error? Because
* POSIX says so! * POSIX says so!
*/ */
int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
unsigned long arg)
{ {
/* Some sanity checks. */ /* Some sanity checks. */
if (_IOC_TYPE(cmd) != RTC_MAGIC) if (_IOC_TYPE(cmd) != RTC_MAGIC)
...@@ -335,6 +335,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -335,6 +335,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
return pcf8563_ioctl(filp, cmd, arg);
unlock_kernel();
return ret;
}
static int __init pcf8563_register(void) static int __init pcf8563_register(void)
{ {
if (pcf8563_init() < 0) { if (pcf8563_init() < 0) {
......
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