Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <linux/smp_lock.h>
#include <linux/bcd.h>
#include <linux/capability.h>

@@ -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). */

static int
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
	  unsigned long arg) 
static int rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	unsigned long flags;

@@ -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
print_rtc_status(void)
{
@@ -376,7 +386,7 @@ print_rtc_status(void)

static const struct file_operations rtc_fops = {
	.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. */
+15 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <linux/delay.h>
#include <linux/bcd.h>
#include <linux/mutex.h>
#include <linux/smp_lock.h>

#include <asm/uaccess.h>
#include <asm/system.h>
@@ -53,7 +54,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
static const unsigned char days_in_month[] =
	{ 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
 * register clears the VL status.
@@ -62,7 +63,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
	.owner = THIS_MODULE,
	.ioctl = pcf8563_ioctl,
	.unlocked_ioctl = pcf8563_unlocked_ioctl,
};

unsigned char
@@ -212,8 +213,7 @@ pcf8563_exit(void)
 * ioctl calls for this driver. Why return -ENOTTY upon error? Because
 * POSIX says so!
 */
int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
	unsigned long arg)
static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	/* Some sanity checks. */
	if (_IOC_TYPE(cmd) != RTC_MAGIC)
@@ -339,6 +339,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
	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)
{
	if (pcf8563_init() < 0) {
+14 −8
Original line number Diff line number Diff line
@@ -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.
 */

static int
i2c_ioctl(struct inode *inode, struct file *file,
	  unsigned int cmd, unsigned long arg)
static long
i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret;
	if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) {
		return -ENOTTY;
	}
@@ -665,9 +665,13 @@ i2c_ioctl(struct inode *inode, struct file *file,
				 I2C_ARGREG(arg),
				 I2C_ARGVALUE(arg)));

			return i2c_writereg(I2C_ARGSLAVE(arg),
			lock_kernel();
			ret = i2c_writereg(I2C_ARGSLAVE(arg),
					    I2C_ARGREG(arg),
					    I2C_ARGVALUE(arg));
			unlock_kernel();
			return ret;

		case I2C_READREG:
		{
			unsigned char val;
@@ -675,7 +679,9 @@ i2c_ioctl(struct inode *inode, struct file *file,
			D(printk("i2cr %d %d ",
				I2C_ARGSLAVE(arg),
				I2C_ARGREG(arg)));
			lock_kernel();
			val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg));
			unlock_kernel();
			D(printk("= %d\n", val));
			return val;
		}
@@ -689,7 +695,7 @@ i2c_ioctl(struct inode *inode, struct file *file,

static const struct file_operations i2c_fops = {
	.owner		= THIS_MODULE,
	.ioctl =    i2c_ioctl,
	.unlocked_ioctl = i2c_ioctl,
	.open		= i2c_open,
	.release	= i2c_release,
};
+16 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/smp_lock.h>
#include <linux/delay.h>
#include <linux/bcd.h>
#include <linux/mutex.h>
@@ -49,7 +50,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
static const unsigned char days_in_month[] =
	{ 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
 * register clears the VL status.
@@ -58,7 +59,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
	.owner		= THIS_MODULE,
	.ioctl =	pcf8563_ioctl
	.unlocked_ioctl = pcf8563_unlocked_ioctl,
};

unsigned char
@@ -208,8 +209,7 @@ pcf8563_exit(void)
 * ioctl calls for this driver. Why return -ENOTTY upon error? Because
 * POSIX says so!
 */
int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
	unsigned long arg)
static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	/* Some sanity checks. */
	if (_IOC_TYPE(cmd) != RTC_MAGIC)
@@ -335,6 +335,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
	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)
{
	if (pcf8563_init() < 0) {