mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: John Kacur <jkacur@redhat.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jan Blunck <jblunck@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 3/7] cris: push down BKL into some device drivers
Date: Tue, 27 Apr 2010 16:24:21 +0200	[thread overview]
Message-ID: <1272378265-10909-4-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <alpine.LFD.2.00.1004271359180.3318@localhost>

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>
---
 arch/cris/arch-v10/drivers/ds1302.c  |   20 +++++++++++++++-----
 arch/cris/arch-v10/drivers/pcf8563.c |   19 +++++++++++++++----
 arch/cris/arch-v32/drivers/i2c.c     |   22 ++++++++++++++--------
 arch/cris/arch-v32/drivers/pcf8563.c |   21 ++++++++++++++++-----
 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 77630df..ffbf4d8 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -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)
 {
@@ -375,8 +385,8 @@ print_rtc_status(void)
 /* The various file operations we support. */
 
 static const struct file_operations rtc_fops = {
-	.owner =	THIS_MODULE,
-	.ioctl =	rtc_ioctl,
+	.owner		= THIS_MODULE,
+	.unlocked_ioctl = rtc_unlocked_ioctl,
 }; 
 
 /* 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 1e90c1a..7dcb1f8 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -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) {
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 5068263..2fd6a74 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)
 /* 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;
 		}
@@ -688,10 +694,10 @@ i2c_ioctl(struct inode *inode, struct file *file,
 }
 
 static const struct file_operations i2c_fops = {
-	.owner =    THIS_MODULE,
-	.ioctl =    i2c_ioctl,
-	.open =     i2c_open,
-	.release =  i2c_release,
+	.owner		= THIS_MODULE,
+	.unlocked_ioctl = i2c_ioctl,
+	.open		= i2c_open,
+	.release	= i2c_release,
 };
 
 static int __init i2c_init(void)
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index f447850..bef6eb5 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -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.
@@ -57,8 +58,8 @@ int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
 static int voltage_low;
 
 static const struct file_operations pcf8563_fops = {
-	.owner =	THIS_MODULE,
-	.ioctl =	pcf8563_ioctl
+	.owner		= THIS_MODULE,
+	.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) {
-- 
1.6.3.3


  parent reply	other threads:[~2010-04-27 14:25 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27  9:18 [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes John Kacur
2010-04-27  9:18 ` [PATCH 01/10] dvb: push down BKL into ioctl functions John Kacur
2010-04-27  9:18 ` [PATCH 02/10] scsi: " John Kacur
2010-04-27  9:18 ` [PATCH 03/10] bkl: Fix up compile problems in megaraid from bkl push-down John Kacur
2010-04-27  9:18 ` [PATCH 04/10] bkl: Fix missing inode tw_chrdev_ioctl due to bkl pushdown John Kacur
2010-04-27  9:18 ` [PATCH 05/10] bkl: Fix missing inode in twl_chrdev_ioctl resulting from " John Kacur
2010-04-27  9:18 ` [PATCH 06/10] isdn: push down BKL into ioctl functions John Kacur
2010-04-27  9:18 ` [PATCH 07/10] staging: " John Kacur
2010-04-27  9:18 ` [PATCH 08/10] v4l: always use unlocked_ioctl John Kacur
2010-04-27  9:18 ` [PATCH 09/10] drivers: push down BKL into various drivers John Kacur
2010-04-27  9:18 ` [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown John Kacur
2010-04-27 11:17   ` Arnd Bergmann
2010-04-27 11:54     ` John Kacur
2010-04-27 13:03       ` Arnd Bergmann
2010-04-28 12:24         ` Mauro Carvalho Chehab
2010-04-28 12:37           ` Hans Verkuil
2010-04-28 13:02             ` Laurent Pinchart
2010-04-28 14:46               ` Mauro Carvalho Chehab
2010-04-28 14:55         ` Linus Torvalds
2010-04-28 21:52           ` Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 0/5] Pushdown bkl from v4l ioctls Frederic Weisbecker
2010-04-29  6:44             ` Hans Verkuil
2010-04-29  7:10               ` Laurent Pinchart
2010-04-29  7:38                 ` Arnd Bergmann
2010-05-01  9:55                 ` Hans Verkuil
2010-05-01 10:47                   ` Arnd Bergmann
2010-05-01 14:58                   ` Frederic Weisbecker
2010-05-01 11:11               ` Alan Cox
2010-04-29  3:42           ` [PATCH 1/5] v4l: Pushdown bkl into video_ioctl2 Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 2/5] v4l: Use video_ioctl2_unlocked from drivers that don't want the bkl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 3/5] v4l: Change users of video_ioctl2 to use unlocked_ioctl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 4/5] v4l: Pushdown bkl to drivers that implement their own ioctl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 5/5] v4l: Remove struct v4l2_file_operations::ioctl Frederic Weisbecker
2010-04-27 11:31 ` [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes Arnd Bergmann
2010-04-27 12:19   ` John Kacur
2010-04-27 12:41     ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 0/6] BKL pushdown into ioctl, continued Arnd Bergmann
2010-04-27 14:24     ` [PATCH 1/7] logfs: push down BKL into ioctl function Arnd Bergmann
2010-04-27 14:32       ` Arnd Bergmann
2010-04-27 14:58       ` Jörn Engel
2010-04-27 15:05         ` Arnd Bergmann
2010-04-27 15:09           ` Jörn Engel
2010-04-27 15:27             ` John Kacur
2010-04-27 15:32               ` Jörn Engel
2010-04-27 15:38                 ` Arnd Bergmann
2010-04-27 20:12                   ` Frederic Weisbecker
2010-04-27 20:30                     ` [PATCH] logfs: kill BKL Arnd Bergmann
2010-05-19 12:51                       ` Frederic Weisbecker
2010-04-27 15:36               ` [PATCH 1/7] logfs: push down BKL into ioctl function Linus Torvalds
2010-04-27 16:29                 ` John Kacur
2010-04-27 19:59       ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 2/7] hfsplus: " Arnd Bergmann
2010-04-27 14:24     ` Arnd Bergmann [this message]
2010-04-27 17:22       ` [PATCH 3/7] cris: push down BKL into some device drivers Frederic Weisbecker
2010-04-30  7:53       ` Jesper Nilsson
2010-05-17  2:51         ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 4/7] sn_hwperf: kill BKL usage Arnd Bergmann
2010-04-27 14:24     ` [PATCH 5/7] um/mmapper: remove " Arnd Bergmann
2010-04-27 14:24     ` [PATCH 6/7] coda/psdev: remove BKL from ioctl function Arnd Bergmann
2010-04-27 14:24     ` [PATCH 7/7] smbfs: push down BKL into " Arnd Bergmann
2010-04-27 12:40   ` [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes Frederic Weisbecker
2010-04-27 12:51   ` Geert Uytterhoeven
2010-04-28 21:18 ` Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1272378265-10909-4-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=fweisbec@gmail.com \
    --cc=jblunck@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®