aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-04-27 10:24:21 -0400
committerJesper Nilsson <jesper.nilsson@axis.com>2010-04-29 10:36:40 -0400
commitf35d77645808d1b890abb1a36260bf228854259e (patch)
tree6453ad50414f3e09c6a62ca1bacab0353bbdf551
parent1d16b0f2f3edf05f12a9e3960588e0d4854157bb (diff)
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: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
-rw-r--r--arch/cris/arch-v10/drivers/ds1302.c20
-rw-r--r--arch/cris/arch-v10/drivers/pcf8563.c19
-rw-r--r--arch/cris/arch-v32/drivers/i2c.c22
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c21
4 files changed, 60 insertions, 22 deletions
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 77630df9434..884275629ef 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/smp_lock.h>
22#include <linux/bcd.h> 23#include <linux/bcd.h>
23#include <linux/capability.h> 24#include <linux/capability.h>
24 25
@@ -238,9 +239,7 @@ static unsigned char days_in_mo[] =
238 239
239/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */ 240/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */
240 241
241static int 242static int rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
242rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
243 unsigned long arg)
244{ 243{
245 unsigned long flags; 244 unsigned long flags;
246 245
@@ -354,6 +353,17 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
354 } 353 }
355} 354}
356 355
356static long rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
357{
358 int ret;
359
360 lock_kernel();
361 ret = rtc_ioctl(file, cmd, arg);
362 unlock_kernel();
363
364 return ret;
365}
366
357static void 367static void
358print_rtc_status(void) 368print_rtc_status(void)
359{ 369{
@@ -375,8 +385,8 @@ print_rtc_status(void)
375/* The various file operations we support. */ 385/* The various file operations we support. */
376 386
377static const struct file_operations rtc_fops = { 387static const struct file_operations rtc_fops = {
378 .owner = THIS_MODULE, 388 .owner = THIS_MODULE,
379 .ioctl = rtc_ioctl, 389 .unlocked_ioctl = rtc_unlocked_ioctl,
380}; 390};
381 391
382/* Probe for the chip by writing something to its RAM and try reading it back. */ 392/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 1e90c1a9c84..7dcb1f85f42 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -27,6 +27,7 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/bcd.h> 28#include <linux/bcd.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/smp_lock.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/system.h> 33#include <asm/system.h>
@@ -53,7 +54,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
53static const unsigned char days_in_month[] = 54static const unsigned char days_in_month[] =
54 { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 55 { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
55 56
56int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 57static long pcf8563_unlocked_ioctl(struct file *, unsigned int, unsigned long);
57 58
58/* Cache VL bit value read at driver init since writing the RTC_SECOND 59/* Cache VL bit value read at driver init since writing the RTC_SECOND
59 * register clears the VL status. 60 * register clears the VL status.
@@ -62,7 +63,7 @@ static int voltage_low;
62 63
63static const struct file_operations pcf8563_fops = { 64static const struct file_operations pcf8563_fops = {
64 .owner = THIS_MODULE, 65 .owner = THIS_MODULE,
65 .ioctl = pcf8563_ioctl, 66 .unlocked_ioctl = pcf8563_unlocked_ioctl,
66}; 67};
67 68
68unsigned char 69unsigned char
@@ -212,8 +213,7 @@ pcf8563_exit(void)
212 * ioctl calls for this driver. Why return -ENOTTY upon error? Because 213 * ioctl calls for this driver. Why return -ENOTTY upon error? Because
213 * POSIX says so! 214 * POSIX says so!
214 */ 215 */
215int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 216static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
216 unsigned long arg)
217{ 217{
218 /* Some sanity checks. */ 218 /* Some sanity checks. */
219 if (_IOC_TYPE(cmd) != RTC_MAGIC) 219 if (_IOC_TYPE(cmd) != RTC_MAGIC)
@@ -339,6 +339,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
339 return 0; 339 return 0;
340} 340}
341 341
342static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
343{
344 int ret;
345
346 lock_kernel();
347 return pcf8563_ioctl(filp, cmd, arg);
348 unlock_kernel();
349
350 return ret;
351}
352
342static int __init pcf8563_register(void) 353static int __init pcf8563_register(void)
343{ 354{
344 if (pcf8563_init() < 0) { 355 if (pcf8563_init() < 0) {
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 506826399ae..2fd6a740d89 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -649,10 +649,10 @@ i2c_release(struct inode *inode, struct file *filp)
649/* Main device API. ioctl's to write or read to/from i2c registers. 649/* Main device API. ioctl's to write or read to/from i2c registers.
650 */ 650 */
651 651
652static int 652static long
653i2c_ioctl(struct inode *inode, struct file *file, 653i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
654 unsigned int cmd, unsigned long arg)
655{ 654{
655 int ret;
656 if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { 656 if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) {
657 return -ENOTTY; 657 return -ENOTTY;
658 } 658 }
@@ -665,9 +665,13 @@ i2c_ioctl(struct inode *inode, struct file *file,
665 I2C_ARGREG(arg), 665 I2C_ARGREG(arg),
666 I2C_ARGVALUE(arg))); 666 I2C_ARGVALUE(arg)));
667 667
668 return i2c_writereg(I2C_ARGSLAVE(arg), 668 lock_kernel();
669 ret = i2c_writereg(I2C_ARGSLAVE(arg),
669 I2C_ARGREG(arg), 670 I2C_ARGREG(arg),
670 I2C_ARGVALUE(arg)); 671 I2C_ARGVALUE(arg));
672 unlock_kernel();
673 return ret;
674
671 case I2C_READREG: 675 case I2C_READREG:
672 { 676 {
673 unsigned char val; 677 unsigned char val;
@@ -675,7 +679,9 @@ i2c_ioctl(struct inode *inode, struct file *file,
675 D(printk("i2cr %d %d ", 679 D(printk("i2cr %d %d ",
676 I2C_ARGSLAVE(arg), 680 I2C_ARGSLAVE(arg),
677 I2C_ARGREG(arg))); 681 I2C_ARGREG(arg)));
682 lock_kernel();
678 val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); 683 val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg));
684 unlock_kernel();
679 D(printk("= %d\n", val)); 685 D(printk("= %d\n", val));
680 return val; 686 return val;
681 } 687 }
@@ -688,10 +694,10 @@ i2c_ioctl(struct inode *inode, struct file *file,
688} 694}
689 695
690static const struct file_operations i2c_fops = { 696static const struct file_operations i2c_fops = {
691 .owner = THIS_MODULE, 697 .owner = THIS_MODULE,
692 .ioctl = i2c_ioctl, 698 .unlocked_ioctl = i2c_ioctl,
693 .open = i2c_open, 699 .open = i2c_open,
694 .release = i2c_release, 700 .release = i2c_release,
695}; 701};
696 702
697static int __init i2c_init(void) 703static int __init i2c_init(void)
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index f4478506e52..bef6eb53b15 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/smp_lock.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/bcd.h> 29#include <linux/bcd.h>
29#include <linux/mutex.h> 30#include <linux/mutex.h>
@@ -49,7 +50,7 @@ static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
49static const unsigned char days_in_month[] = 50static const unsigned char days_in_month[] =
50 { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 51 { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
51 52
52int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 53static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
53 54
54/* Cache VL bit value read at driver init since writing the RTC_SECOND 55/* Cache VL bit value read at driver init since writing the RTC_SECOND
55 * register clears the VL status. 56 * register clears the VL status.
@@ -57,8 +58,8 @@ int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
57static int voltage_low; 58static int voltage_low;
58 59
59static const struct file_operations pcf8563_fops = { 60static const struct file_operations pcf8563_fops = {
60 .owner = THIS_MODULE, 61 .owner = THIS_MODULE,
61 .ioctl = pcf8563_ioctl 62 .unlocked_ioctl = pcf8563_unlocked_ioctl,
62}; 63};
63 64
64unsigned char 65unsigned char
@@ -208,8 +209,7 @@ pcf8563_exit(void)
208 * ioctl calls for this driver. Why return -ENOTTY upon error? Because 209 * ioctl calls for this driver. Why return -ENOTTY upon error? Because
209 * POSIX says so! 210 * POSIX says so!
210 */ 211 */
211int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 212static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
212 unsigned long arg)
213{ 213{
214 /* Some sanity checks. */ 214 /* Some sanity checks. */
215 if (_IOC_TYPE(cmd) != RTC_MAGIC) 215 if (_IOC_TYPE(cmd) != RTC_MAGIC)
@@ -335,6 +335,17 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
335 return 0; 335 return 0;
336} 336}
337 337
338static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
339{
340 int ret;
341
342 lock_kernel();
343 return pcf8563_ioctl(filp, cmd, arg);
344 unlock_kernel();
345
346 return ret;
347}
348
338static int __init pcf8563_register(void) 349static int __init pcf8563_register(void)
339{ 350{
340 if (pcf8563_init() < 0) { 351 if (pcf8563_init() < 0) {