2010-04-27 09:18:32

by John Kacur

[permalink] [raw]
Subject: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

These are bkl pushdowns from Arnd that conflicted with
Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
conflicts. In addition - during allyesconfig compile testing on x86_64 I found
a number of issues that I fixed-up

I pushed these to my own new linus-bkl tree.
git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl

Frederic, if you want to grab those, pls do so. also, we might want to combine
my compile fixes with Arnd's push-down patches, for better git bisectability.

Presented separately here for everyone's easy perusal.

Arnd Bergmann (6):
dvb: push down BKL into ioctl functions
scsi: push down BKL into ioctl functions
isdn: push down BKL into ioctl functions
staging: push down BKL into ioctl functions
v4l: always use unlocked_ioctl
drivers: push down BKL into various drivers

John Kacur (4):
bkl: Fix up compile problems in megaraid from bkl push-down
bkl: Fix missing inode tw_chrdev_ioctl due to bkl pushdown
bkl: Fix missing inode in twl_chrdev_ioctl resulting from bkl
pushdown
bkl: Fix-up compile problems as a result of the bkl-pushdown.

drivers/block/pktcdvd.c | 13 ++++++--
drivers/char/apm-emulation.c | 8 +++--
drivers/char/applicom.c | 13 +++++---
drivers/char/ds1620.c | 16 ++++++++-
drivers/char/dtlk.c | 15 +++++----
drivers/char/generic_nvram.c | 17 ++++++++--
drivers/char/genrtc.c | 16 ++++++++-
drivers/char/hpet.c | 14 +++++---
drivers/char/i8k.c | 21 ++++++++++--
drivers/char/ipmi/ipmi_devintf.c | 26 +++++++++++++---
drivers/char/ipmi/ipmi_watchdog.c | 17 +++++++++-
drivers/char/nvram.c | 10 ++++--
drivers/char/nwflash.c | 7 +++-
drivers/char/raw.c | 42 ++++++++++++++-----------
drivers/hwmon/fschmd.c | 9 +++--
drivers/hwmon/w83793.c | 10 ++++--
drivers/input/misc/hp_sdc_rtc.c | 34 ++++++++++++++------
drivers/isdn/capi/capi.c | 17 ++++++++--
drivers/isdn/divert/divert_procfs.c | 19 ++++++++++--
drivers/isdn/i4l/isdn_common.c | 18 +++++++++--
drivers/isdn/mISDN/timerdev.c | 10 ++++--
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 17 ++++++++--
drivers/media/dvb/dvb-core/dmxdev.c | 31 +++++++++++++-----
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 17 +++++++---
drivers/media/dvb/dvb-core/dvb_frontend.c | 30 +++++++++---------
drivers/media/dvb/dvb-core/dvb_net.c | 15 +++++++--
drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++----
drivers/media/dvb/dvb-core/dvbdev.h | 11 ++----
drivers/media/dvb/firewire/firedtv-ci.c | 5 +--
drivers/media/dvb/ttpci/av7110.c | 4 +-
drivers/media/dvb/ttpci/av7110_av.c | 8 ++--
drivers/media/dvb/ttpci/av7110_ca.c | 5 +--
drivers/media/video/v4l2-dev.c | 19 +++++++++--
drivers/mtd/mtdchar.c | 19 ++++++++---
drivers/pcmcia/pcmcia_ioctl.c | 17 ++++++++--
drivers/rtc/rtc-m41t80.c | 16 ++++++++-
drivers/sbus/char/openprom.c | 44 +++++++++++++++-----------
drivers/scsi/3w-9xxx.c | 10 ++++--
drivers/scsi/3w-sas.c | 8 ++++-
drivers/scsi/3w-xxxx.c | 11 +++++--
drivers/scsi/aacraid/linit.c | 11 +++++--
drivers/scsi/dpt_i2o.c | 20 ++++++++++--
drivers/scsi/gdth.c | 20 +++++++++---
drivers/scsi/megaraid.c | 20 ++++++++++--
drivers/scsi/megaraid.h | 4 +-
drivers/scsi/megaraid/megaraid_mm.c | 22 ++++++++++---
drivers/scsi/osst.c | 14 ++++++--
drivers/scsi/sg.c | 17 ++++++++--
drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++--
drivers/staging/dt3155/dt3155_drv.c | 24 +++++++++++----
drivers/staging/poch/poch.c | 17 +++++++++-
drivers/staging/vme/devices/vme_user.c | 18 +++++++++--
drivers/usb/mon/mon_bin.c | 23 ++++++++++----
drivers/usb/mon/mon_stat.c | 3 +-
55 files changed, 636 insertions(+), 248 deletions(-)


2010-04-27 09:18:36

by John Kacur

[permalink] [raw]
Subject: [PATCH 01/10] dvb: push down BKL into ioctl functions

From: Arnd Bergmann <[email protected]>

This requires changing all users of dvb_usercopy to
omit the inode argument.

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/media/dvb/dvb-core/dmxdev.c | 31 +++++++++++++++++++-------
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 17 ++++++++++----
drivers/media/dvb/dvb-core/dvb_frontend.c | 30 +++++++++++++-------------
drivers/media/dvb/dvb-core/dvb_net.c | 15 +++++++++---
drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++++-----
drivers/media/dvb/dvb-core/dvbdev.h | 11 +++------
drivers/media/dvb/firewire/firedtv-ci.c | 5 +--
drivers/media/dvb/ttpci/av7110.c | 4 +-
drivers/media/dvb/ttpci/av7110_av.c | 8 +++---
drivers/media/dvb/ttpci/av7110_ca.c | 5 +--
10 files changed, 85 insertions(+), 58 deletions(-)

diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index a6c4f2f..425862f 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
+#include <linux/smp_lock.h>
#include <linux/poll.h>
#include <linux/ioctl.h>
#include <linux/wait.h>
@@ -963,7 +964,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count,
return ret;
}

-static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_demux_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
@@ -1084,10 +1085,16 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_demux_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
@@ -1139,7 +1146,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_demux_fops = {
.owner = THIS_MODULE,
.read = dvb_demux_read,
- .bkl_ioctl = dvb_demux_ioctl,
+ .unlocked_ioctl = dvb_demux_ioctl,
.open = dvb_demux_open,
.release = dvb_demux_release,
.poll = dvb_demux_poll,
@@ -1152,7 +1159,7 @@ static struct dvb_device dvbdev_demux = {
.fops = &dvb_demux_fops
};

-static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_dvr_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1176,10 +1183,16 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
+static long dvb_dvr_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
@@ -1208,7 +1221,7 @@ static const struct file_operations dvb_dvr_fops = {
.owner = THIS_MODULE,
.read = dvb_dvr_read,
.write = dvb_dvr_write,
- .bkl_ioctl = dvb_dvr_ioctl,
+ .unlocked_ioctl = dvb_dvr_ioctl,
.open = dvb_dvr_open,
.release = dvb_dvr_release,
.poll = dvb_dvr_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 4609c7e..ef259a0 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -36,6 +36,7 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/kthread.h>

#include "dvb_ca_en50221.h"
@@ -1181,7 +1182,7 @@ static int dvb_ca_en50221_thread(void *data)
*
* @return 0 on success, <0 on error.
*/
-static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_ca_en50221_io_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1255,10 +1256,16 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
*
* @return 0 on success, <0 on error.
*/
-static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long dvb_ca_en50221_io_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}


@@ -1611,7 +1618,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_en50221_io_read,
.write = dvb_ca_en50221_io_write,
- .bkl_ioctl = dvb_ca_en50221_io_ioctl,
+ .unlocked_ioctl = dvb_ca_en50221_io_ioctl,
.open = dvb_ca_en50221_io_open,
.release = dvb_ca_en50221_io_release,
.poll = dvb_ca_en50221_io_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 5ebf731..5450d1f 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -36,6 +36,7 @@
#include <linux/list.h>
#include <linux/freezer.h>
#include <linux/jiffies.h>
+#include <linux/smp_lock.h>
#include <linux/kthread.h>
#include <asm/processor.h>

@@ -1188,14 +1189,14 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe)
}
}

-static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_legacy(struct file *file,
unsigned int cmd, void *parg);
-static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_properties(struct file *file,
unsigned int cmd, void *parg);

static int dtv_property_process_get(struct dvb_frontend *fe,
struct dtv_property *tvp,
- struct inode *inode, struct file *file)
+ struct file *file)
{
int r = 0;

@@ -1328,7 +1329,6 @@ static int dtv_property_process_get(struct dvb_frontend *fe,

static int dtv_property_process_set(struct dvb_frontend *fe,
struct dtv_property *tvp,
- struct inode *inode,
struct file *file)
{
int r = 0;
@@ -1359,7 +1359,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
dprintk("%s() Finalised property cache\n", __func__);
dtv_property_cache_submit(fe);

- r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND,
+ r |= dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND,
&fepriv->parameters);
break;
case DTV_FREQUENCY:
@@ -1391,12 +1391,12 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
break;
case DTV_VOLTAGE:
fe->dtv_property_cache.voltage = tvp->u.data;
- r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_VOLTAGE,
+ r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE,
(void *)fe->dtv_property_cache.voltage);
break;
case DTV_TONE:
fe->dtv_property_cache.sectone = tvp->u.data;
- r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_TONE,
+ r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE,
(void *)fe->dtv_property_cache.sectone);
break;
case DTV_CODE_RATE_HP:
@@ -1480,7 +1480,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
return r;
}

-static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1502,17 +1502,17 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
return -ERESTARTSYS;

if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY))
- err = dvb_frontend_ioctl_properties(inode, file, cmd, parg);
+ err = dvb_frontend_ioctl_properties(file, cmd, parg);
else {
fe->dtv_property_cache.state = DTV_UNDEFINED;
- err = dvb_frontend_ioctl_legacy(inode, file, cmd, parg);
+ err = dvb_frontend_ioctl_legacy(file, cmd, parg);
}

up(&fepriv->sem);
return err;
}

-static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_properties(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1548,7 +1548,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
}

for (i = 0; i < tvps->num; i++) {
- (tvp + i)->result = dtv_property_process_set(fe, tvp + i, inode, file);
+ (tvp + i)->result = dtv_property_process_set(fe, tvp + i, file);
err |= (tvp + i)->result;
}

@@ -1580,7 +1580,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
}

for (i = 0; i < tvps->num; i++) {
- (tvp + i)->result = dtv_property_process_get(fe, tvp + i, inode, file);
+ (tvp + i)->result = dtv_property_process_get(fe, tvp + i, file);
err |= (tvp + i)->result;
}

@@ -1597,7 +1597,7 @@ out:
return err;
}

-static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_legacy(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -2022,7 +2022,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)

static const struct file_operations dvb_frontend_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.poll = dvb_frontend_poll,
.open = dvb_frontend_open,
.release = dvb_frontend_release
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 7ae8ef1..a96eee3 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -59,6 +59,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/dvb/net.h>
+#include <linux/smp_lock.h>
#include <linux/uio.h>
#include <asm/uaccess.h>
#include <linux/crc32.h>
@@ -1333,7 +1334,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
return 0;
}

-static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_net_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1435,10 +1436,16 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
return 0;
}

-static int dvb_net_ioctl(struct inode *inode, struct file *file,
+static long dvb_net_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static int dvb_net_close(struct inode *inode, struct file *file)
@@ -1459,7 +1466,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)

static const struct file_operations dvb_net_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = dvb_net_ioctl,
+ .unlocked_ioctl = dvb_net_ioctl,
.open = dvb_generic_open,
.release = dvb_net_close,
};
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..b915c39 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -154,10 +154,11 @@ int dvb_generic_release(struct inode *inode, struct file *file)
EXPORT_SYMBOL(dvb_generic_release);


-int dvb_generic_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+long dvb_generic_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
{
struct dvb_device *dvbdev = file->private_data;
+ int ret;

if (!dvbdev)
return -ENODEV;
@@ -165,7 +166,11 @@ int dvb_generic_ioctl(struct inode *inode, struct file *file,
if (!dvbdev->kernel_ioctl)
return -EINVAL;

- return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl);
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
+ unlock_kernel();
+
+ return ret;
}
EXPORT_SYMBOL(dvb_generic_ioctl);

@@ -377,9 +382,9 @@ EXPORT_SYMBOL(dvb_unregister_adapter);
define this as video_usercopy(). this will introduce a dependecy
to the v4l "videodev.o" module, which is unnecessary for some
cards (ie. the budget dvb-cards don't need the v4l module...) */
-int dvb_usercopy(struct inode *inode, struct file *file,
+int dvb_usercopy(struct file *file,
unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
+ int (*func)(struct file *file,
unsigned int cmd, void *arg))
{
char sbuf[128];
@@ -416,7 +421,7 @@ int dvb_usercopy(struct inode *inode, struct file *file,
}

/* call driver */
- if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
+ if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
err = -EINVAL;

if (err < 0)
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index f7b499d..fcc6ae9 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -116,8 +116,7 @@ struct dvb_device {

wait_queue_head_t wait_queue;
/* don't really need those !? -- FIXME: use video_usercopy */
- int (*kernel_ioctl)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg);
+ int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);

void *priv;
};
@@ -138,17 +137,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);

extern int dvb_generic_open (struct inode *inode, struct file *file);
extern int dvb_generic_release (struct inode *inode, struct file *file);
-extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
+extern long dvb_generic_ioctl (struct file *file,
unsigned int cmd, unsigned long arg);

/* we don't mess with video_usercopy() any more,
we simply define out own dvb_usercopy(), which will hopefully become
generic_usercopy() someday... */

-extern int dvb_usercopy(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg));
+extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
+ int (*func)(struct file *file, unsigned int cmd, void *arg));

/** generic DVB attach function. */
#ifdef CONFIG_MEDIA_ATTACH
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 9378618..d3c2cf6 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -175,8 +175,7 @@ static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg)
return err;
}

-static int fdtv_ca_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg)
+static int fdtv_ca_ioctl(struct file *file, unsigned int cmd, void *arg)
{
struct dvb_device *dvbdev = file->private_data;
struct firedtv *fdtv = dvbdev->priv;
@@ -217,7 +216,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)

static const struct file_operations fdtv_ca_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
.poll = fdtv_ca_io_poll,
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 0e606af..a6be529 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -708,7 +708,7 @@ static void gpioirq(unsigned long cookie)


#ifdef CONFIG_DVB_AV7110_OSD
-static int dvb_osd_ioctl(struct inode *inode, struct file *file,
+static int dvb_osd_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -727,7 +727,7 @@ static int dvb_osd_ioctl(struct inode *inode, struct file *file,

static const struct file_operations dvb_osd_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
};
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 62d3b1f..13efba9 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1089,7 +1089,7 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len
}


-static int dvb_video_ioctl(struct inode *inode, struct file *file,
+static int dvb_video_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1297,7 +1297,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_audio_ioctl(struct inode *inode, struct file *file,
+static int dvb_audio_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1517,7 +1517,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_video_fops = {
.owner = THIS_MODULE,
.write = dvb_video_write,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_video_open,
.release = dvb_video_release,
.poll = dvb_video_poll,
@@ -1535,7 +1535,7 @@ static struct dvb_device dvbdev_video = {
static const struct file_operations dvb_audio_fops = {
.owner = THIS_MODULE,
.write = dvb_audio_write,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_audio_open,
.release = dvb_audio_release,
.poll = dvb_audio_poll,
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 94e0668..4eba35a 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -248,8 +248,7 @@ static unsigned int dvb_ca_poll (struct file *file, poll_table *wait)
return mask;
}

-static int dvb_ca_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
+static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
struct av7110 *av7110 = dvbdev->priv;
@@ -350,7 +349,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_read,
.write = dvb_ca_write,
- .bkl_ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_ca_open,
.release = dvb_generic_release,
.poll = dvb_ca_poll,
--
1.6.6.1

2010-04-27 09:18:42

by John Kacur

[permalink] [raw]
Subject: [PATCH 02/10] scsi: push down BKL into ioctl functions

From: Arnd Bergmann <[email protected]>

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/scsi/3w-9xxx.c | 10 +++++++---
drivers/scsi/3w-sas.c | 7 +++++--
drivers/scsi/3w-xxxx.c | 10 +++++++---
drivers/scsi/aacraid/linit.c | 11 ++++++++---
drivers/scsi/dpt_i2o.c | 20 +++++++++++++++++---
drivers/scsi/gdth.c | 20 +++++++++++++++-----
drivers/scsi/megaraid.c | 20 +++++++++++++++++---
drivers/scsi/megaraid/megaraid_mm.c | 22 +++++++++++++++++-----
drivers/scsi/osst.c | 14 ++++++++++----
drivers/scsi/sg.c | 17 ++++++++++++++---
10 files changed, 117 insertions(+), 34 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 32da0ef..4f74850 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -123,7 +123,7 @@ static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_H
static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
static char *twa_aen_severity_lookup(unsigned char severity_code);
static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
+static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static int twa_chrdev_open(struct inode *inode, struct file *file);
static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host);
static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
@@ -218,7 +218,7 @@ static struct device_attribute *twa_host_attrs[] = {
/* File operations struct for character device */
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = twa_chrdev_ioctl,
+ .unlocked_ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
.release = NULL
};
@@ -635,8 +635,9 @@ out:
} /* End twa_check_srl() */

/* This function handles ioctl for the character device */
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
+ struct inode *inode = file->f_path.dentry->d_inode;
long timeout;
unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
dma_addr_t dma_handle;
@@ -655,6 +656,8 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
int retval = TW_IOCTL_ERROR_OS_EFAULT;
void __user *argp = (void __user *)arg;

+ lock_kernel();
+
/* Only let one of these through at a time */
if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
retval = TW_IOCTL_ERROR_OS_EINTR;
@@ -874,6 +877,7 @@ out3:
out2:
mutex_unlock(&tw_dev->ioctl_lock);
out:
+ unlock_kernel();
return retval;
} /* End twa_chrdev_ioctl() */

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 3cac9e4..ab4ad09 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -750,7 +750,7 @@ static void twl_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_comm

/* This function handles ioctl for the character device
This interface is used by smartmontools open source software */
-static int twl_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
long timeout;
unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
@@ -763,6 +763,8 @@ static int twl_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
int retval = -EFAULT;
void __user *argp = (void __user *)arg;

+ lock_kernel();
+
/* Only let one of these through at a time */
if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
retval = -EINTR;
@@ -858,6 +860,7 @@ out3:
out2:
mutex_unlock(&tw_dev->ioctl_lock);
out:
+ unlock_kernel();
return retval;
} /* End twl_chrdev_ioctl() */

@@ -884,7 +887,7 @@ out:
/* File operations struct for character device */
static const struct file_operations twl_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = twl_chrdev_ioctl,
+ .unlocked_ioctl = twl_chrdev_ioctl,
.open = twl_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 2713dd5..45a737c 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -880,7 +880,7 @@ static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
} /* End tw_allocate_memory() */

/* This function handles ioctl for the character device */
-static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int request_id;
dma_addr_t dma_handle;
@@ -898,9 +898,12 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int

dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");

+ lock_kernel();
/* Only let one of these through at a time */
- if (mutex_lock_interruptible(&tw_dev->ioctl_lock))
+ if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
+ unlock_kernel();
return -EINTR;
+ }

/* First copy down the buffer length */
if (copy_from_user(&data_buffer_length, argp, sizeof(unsigned int)))
@@ -1029,6 +1032,7 @@ out2:
dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
out:
mutex_unlock(&tw_dev->ioctl_lock);
+ unlock_kernel();
return retval;
} /* End tw_chrdev_ioctl() */

@@ -1051,7 +1055,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
/* File operations struct for character device */
static const struct file_operations tw_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = tw_chrdev_ioctl,
+ .unlocked_ioctl = tw_chrdev_ioctl,
.open = tw_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index c2b037d..33898b6 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -705,12 +705,17 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
* Bugs: Needs to handle hot plugging
*/

-static int aac_cfg_ioctl(struct inode *inode, struct file *file,
+static long aac_cfg_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
+ int ret;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
- return aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
+ lock_kernel();
+ ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
+ unlock_kernel();
+
+ return ret;
}

#ifdef CONFIG_COMPAT
@@ -1029,7 +1034,7 @@ ssize_t aac_get_serial_number(struct device *device, char *buf)

static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = aac_cfg_ioctl,
+ .unlocked_ioctl = aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = aac_compat_cfg_ioctl,
#endif
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 6ec5682..b0c576f 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -114,12 +114,13 @@ static int hba_count = 0;

static struct class *adpt_sysfs_class;

+static long adpt_unlocked_ioctl(struct file *, unsigned int, unsigned long);
#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);
#endif

static const struct file_operations adpt_fops = {
- .bkl_ioctl = adpt_ioctl,
+ .unlocked_ioctl = adpt_unlocked_ioctl,
.open = adpt_open,
.release = adpt_close,
#ifdef CONFIG_COMPAT
@@ -2069,8 +2070,7 @@ static int adpt_system_info(void __user *buffer)
return 0;
}

-static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
- ulong arg)
+static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
{
int minor;
int error = 0;
@@ -2153,6 +2153,20 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
return error;
}

+static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
+{
+ struct inode *inode;
+ long ret;
+
+ inode = file->f_dentry->d_inode;
+
+ lock_kernel();
+ ret = adpt_ioctl(inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 69c1629..d3f335d 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -180,8 +180,8 @@ static const char *gdth_ctr_name(gdth_ha_str *ha);

static int gdth_open(struct inode *inode, struct file *filep);
static int gdth_close(struct inode *inode, struct file *filep);
-static int gdth_ioctl(struct inode *inode, struct file *filep,
- unsigned int cmd, unsigned long arg);
+static long gdth_unlocked_ioctl(struct file *filep, unsigned int cmd,
+ unsigned long arg);

static void gdth_flush(gdth_ha_str *ha);
static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *));
@@ -369,7 +369,7 @@ MODULE_LICENSE("GPL");

/* ioctl interface */
static const struct file_operations gdth_fops = {
- .bkl_ioctl = gdth_ioctl,
+ .unlocked_ioctl = gdth_unlocked_ioctl,
.open = gdth_open,
.release = gdth_close,
};
@@ -4462,8 +4462,7 @@ free_fail:
return rc;
}

-static int gdth_ioctl(struct inode *inode, struct file *filep,
- unsigned int cmd, unsigned long arg)
+static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
gdth_ha_str *ha;
Scsi_Cmnd *scp;
@@ -4611,6 +4610,17 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
return 0;
}

+static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = gdth_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}

/* flush routine */
static void gdth_flush(gdth_ha_str *ha)
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 49a3501..c20b621 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -91,12 +91,15 @@ static struct proc_dir_entry *mega_proc_dir_entry;
/* For controller re-ordering */
static struct mega_hbas mega_hbas[MAX_CONTROLLERS];

+static long
+megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+
/*
* The File Operations structure for the serial/ioctl interface of the driver
*/
static const struct file_operations megadev_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = megadev_ioctl,
+ .unlocked_ioctl = megadev_unlocked_ioctl,
.open = megadev_open,
};

@@ -3302,8 +3305,7 @@ megadev_open (struct inode *inode, struct file *filep)
* controller.
*/
static int
-megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
adapter_t *adapter;
nitioctl_t uioc;
@@ -3694,6 +3696,18 @@ freemem_and_return:
return 0;
}

+static long
+megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = megadev_ioctl(filep, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/**
* mega_m_to_n()
* @arg - user address
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 9bd7787..41f82f7 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -22,7 +22,7 @@

// Entry points for char node driver
static int mraid_mm_open(struct inode *, struct file *);
-static int mraid_mm_ioctl(struct inode *, struct file *, uint, unsigned long);
+static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long);


// routines to convert to and from the old the format
@@ -70,7 +70,7 @@ static wait_queue_head_t wait_q;

static const struct file_operations lsi_fops = {
.open = mraid_mm_open,
- .bkl_ioctl = mraid_mm_ioctl,
+ .unlocked_ioctl = mraid_mm_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mraid_mm_compat_ioctl,
#endif
@@ -110,8 +110,7 @@ mraid_mm_open(struct inode *inode, struct file *filep)
* @arg : user ioctl packet
*/
static int
-mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+mraid_mm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
uioc_t *kioc;
char signature[EXT_IOCTL_SIGN_SZ] = {0};
@@ -218,6 +217,19 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
return rval;
}

+static long
+mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd,
+ unsigned long arg)
+{
+ int err;
+
+ /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */
+ lock_kernel();
+ err = mraid_mm_ioctl(filep, cmd, arg);
+ unlock_kernel();
+
+ return err;
+}

/**
* mraid_mm_get_adapter - Returns corresponding adapters for the mimd packet
@@ -1225,7 +1237,7 @@ mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd,
{
int err;

- err = mraid_mm_ioctl(NULL, filep, cmd, arg);
+ err = mraid_mm_ioctl(filep, cmd, arg);

return err;
}
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index a1a78bb..8dbf1c3 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -4932,7 +4932,7 @@ static int os_scsi_tape_close(struct inode * inode, struct file * filp)


/* The ioctl command */
-static int osst_ioctl(struct inode * inode,struct file * file,
+static long osst_ioctl(struct file * file,
unsigned int cmd_in, unsigned long arg)
{
int i, cmd_nr, cmd_type, blk, retval = 0;
@@ -4943,8 +4943,11 @@ static int osst_ioctl(struct inode * inode,struct file * file,
char * name = tape_name(STp);
void __user * p = (void __user *)arg;

- if (mutex_lock_interruptible(&STp->lock))
+ lock_kernel();
+ if (mutex_lock_interruptible(&STp->lock)) {
+ unlock_kernel();
return -ERESTARTSYS;
+ }

#if DEBUG
if (debugging && !STp->in_use) {
@@ -5256,12 +5259,15 @@ static int osst_ioctl(struct inode * inode,struct file * file,

mutex_unlock(&STp->lock);

- return scsi_ioctl(STp->device, cmd_in, p);
+ retval = scsi_ioctl(STp->device, cmd_in, p);
+ unlock_kernel();
+ return retval;

out:
if (SRpnt) osst_release_request(SRpnt);

mutex_unlock(&STp->lock);
+ unlock_kernel();

return retval;
}
@@ -5613,7 +5619,7 @@ static const struct file_operations osst_fops = {
.owner = THIS_MODULE,
.read = osst_read,
.write = osst_write,
- .bkl_ioctl = osst_ioctl,
+ .unlocked_ioctl = osst_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = osst_compat_ioctl,
#endif
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 93d043e..ef752b2 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -758,8 +758,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
}

static int
-sg_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd_in, unsigned long arg)
+sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
{
void __user *p = (void __user *)arg;
int __user *ip = p;
@@ -1078,6 +1077,18 @@ sg_ioctl(struct inode *inode, struct file *filp,
}
}

+static long
+sg_unlocked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = sg_ioctl(filp, cmd_in, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT
static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
{
@@ -1322,7 +1333,7 @@ static const struct file_operations sg_fops = {
.read = sg_read,
.write = sg_write,
.poll = sg_poll,
- .bkl_ioctl = sg_ioctl,
+ .unlocked_ioctl = sg_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = sg_compat_ioctl,
#endif
--
1.6.6.1

2010-04-27 09:18:46

by John Kacur

[permalink] [raw]
Subject: [PATCH 04/10] bkl: Fix missing inode tw_chrdev_ioctl due to bkl pushdown

Signed-off-by: John Kacur <[email protected]>
---
drivers/scsi/3w-xxxx.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 45a737c..2957691 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -890,6 +890,7 @@ static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long a
unsigned long data_buffer_length_adjusted = 0;
unsigned long *cpu_addr;
long timeout;
+ struct inode *inode = file->f_dentry->d_inode;
TW_New_Ioctl *tw_ioctl;
TW_Passthru *passthru;
TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)];
--
1.6.6.1

2010-04-27 09:18:50

by John Kacur

[permalink] [raw]
Subject: [PATCH 05/10] bkl: Fix missing inode in twl_chrdev_ioctl resulting from bkl pushdown

Fix missing inode in twl_chrdev_ioctl resulting from bkl pushdown, because
the ioctl is now an unlocked ioctl.

Signed-off-by: John Kacur <[email protected]>
---
drivers/scsi/3w-sas.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index ab4ad09..216af13 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -756,6 +756,7 @@ static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long
unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
dma_addr_t dma_handle;
int request_id = 0;
+ struct inode *inode = file->f_dentry->d_inode;
TW_Ioctl_Driver_Command driver_command;
TW_Ioctl_Buf_Apache *tw_ioctl;
TW_Command_Full *full_command_packet;
--
1.6.6.1

2010-04-27 09:18:55

by John Kacur

[permalink] [raw]
Subject: [PATCH 06/10] isdn: push down BKL into ioctl functions

From: Arnd Bergmann <[email protected]>

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/isdn/capi/capi.c | 17 ++++++++++++++---
drivers/isdn/divert/divert_procfs.c | 19 ++++++++++++++++---
drivers/isdn/i4l/isdn_common.c | 18 +++++++++++++++---
drivers/isdn/mISDN/timerdev.c | 10 ++++++----
4 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 6bc9766..0cabe31 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -787,8 +787,7 @@ capi_poll(struct file *file, poll_table * wait)
}

static int
-capi_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+capi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct capidev *cdev = file->private_data;
capi_ioctl_struct data;
@@ -981,6 +980,18 @@ register_out:
}
}

+static long
+capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = capi_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static int capi_open(struct inode *inode, struct file *file)
{
struct capidev *cdev;
@@ -1026,7 +1037,7 @@ static const struct file_operations capi_fops =
.read = capi_read,
.write = capi_write,
.poll = capi_poll,
- .bkl_ioctl = capi_ioctl,
+ .unlocked_ioctl = capi_unlocked_ioctl,
.open = capi_open,
.release = capi_release,
};
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index ae0244f..8084557 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -11,6 +11,7 @@

#include <linux/module.h>
#include <linux/poll.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
@@ -178,8 +179,7 @@ isdn_divert_close(struct inode *ino, struct file *filep)
/* IOCTL */
/*********/
static int
-isdn_divert_ioctl(struct inode *inode, struct file *file,
- uint cmd, ulong arg)
+isdn_divert_ioctl(struct file *file, uint cmd, ulong arg)
{
divert_ioctl dioctl;
int i;
@@ -258,6 +258,19 @@ isdn_divert_ioctl(struct inode *inode, struct file *file,
return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
} /* isdn_divert_ioctl */

+static long
+isdn_divert_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = isdn_divert_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
+
static const struct file_operations isdn_fops =
{
.owner = THIS_MODULE,
@@ -265,7 +278,7 @@ static const struct file_operations isdn_fops =
.read = isdn_divert_read,
.write = isdn_divert_write,
.poll = isdn_divert_poll,
- .bkl_ioctl = isdn_divert_ioctl,
+ .unlocked_ioctl = isdn_divert_unlocked_ioctl,
.open = isdn_divert_open,
.release = isdn_divert_close,
};
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 08ba72d..a44cdb4 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1272,9 +1272,9 @@ isdn_poll(struct file *file, poll_table * wait)


static int
-isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+isdn_ioctl(struct file *file, uint cmd, ulong arg)
{
- uint minor = iminor(inode);
+ uint minor = iminor(file->f_path.dentry->d_inode);
isdn_ctrl c;
int drvidx;
int chidx;
@@ -1722,6 +1722,18 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
#undef cfg
}

+static long
+isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = isdn_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*
* Open the device code.
*/
@@ -1838,7 +1850,7 @@ static const struct file_operations isdn_fops =
.read = isdn_read,
.write = isdn_write,
.poll = isdn_poll,
- .bkl_ioctl = isdn_ioctl,
+ .unlocked_ioctl = isdn_unlocked_ioctl,
.open = isdn_open,
.release = isdn_close,
};
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index fc7d777..c3243c9 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -24,6 +24,7 @@
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mISDNif.h>
+#include <linux/smp_lock.h>
#include "core.h"

static u_int *debug;
@@ -215,9 +216,8 @@ unlock:
return ret;
}

-static int
-mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+static long
+mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
struct mISDNtimerdev *dev = filep->private_data;
int id, tout, ret = 0;
@@ -226,6 +226,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
if (*debug & DEBUG_TIMER)
printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__,
filep, cmd, arg);
+ lock_kernel();
switch (cmd) {
case IMADDTIMER:
if (get_user(tout, (int __user *)arg)) {
@@ -257,13 +258,14 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
default:
ret = -EINVAL;
}
+ unlock_kernel();
return ret;
}

static const struct file_operations mISDN_fops = {
.read = mISDN_read,
.poll = mISDN_poll,
- .bkl_ioctl = mISDN_ioctl,
+ .unlocked_ioctl = mISDN_ioctl,
.open = mISDN_open,
.release = mISDN_close,
};
--
1.6.6.1

2010-04-27 09:19:05

by John Kacur

[permalink] [raw]
Subject: [PATCH 08/10] v4l: always use unlocked_ioctl

From: Arnd Bergmann <[email protected]>

v4l drivers may still use a locked ioctl method,
but we now always export an unlocked_ioctl and
lock ourselves, so that the ->ioctl file operation
can get removed.

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/media/video/v4l2-dev.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index c48143a..3606694 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
+#include <linux/smp_lock.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/slab.h>
@@ -215,16 +216,21 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
return vdev->fops->poll(filp, poll);
}

-static int v4l2_ioctl(struct inode *inode, struct file *filp,
+static long v4l2_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct video_device *vdev = video_devdata(filp);
+ int ret;

if (!vdev->fops->ioctl)
return -ENOTTY;
/* Allow ioctl to continue even if the device was unregistered.
Things like dequeueing buffers might still be useful. */
- return vdev->fops->ioctl(filp, cmd, arg);
+ lock_kernel();
+ ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
}

static long v4l2_unlocked_ioctl(struct file *filp,
@@ -323,6 +329,11 @@ static const struct file_operations v4l2_unlocked_fops = {
.llseek = no_llseek,
};

+/*
+ * Note: this should not be needed, just check
+ * both pointers in v4l2_ioctl, or kill
+ * fops->ioctl. -arnd
+ */
static const struct file_operations v4l2_fops = {
.owner = THIS_MODULE,
.read = v4l2_read,
@@ -330,7 +341,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .bkl_ioctl = v4l2_ioctl,
+ .unlocked_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
--
1.6.6.1

2010-04-27 09:19:08

by John Kacur

[permalink] [raw]
Subject: [PATCH 07/10] staging: push down BKL into ioctl functions

From: Arnd Bergmann <[email protected]>

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++++++----
drivers/staging/dt3155/dt3155_drv.c | 24 ++++++++++++++++++------
drivers/staging/poch/poch.c | 17 +++++++++++++++--
drivers/staging/vme/devices/vme_user.c | 18 +++++++++++++++---
4 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 3d6b773..3291e14 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -16,6 +16,7 @@
***************************************************************************/

#include <linux/version.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>

#include "crystalhd_lnx.h"
@@ -261,12 +262,12 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
}

/* API interfaces */
-static int chd_dec_ioctl(struct inode *in, struct file *fd,
- unsigned int cmd, unsigned long ua)
+static long chd_dec_ioctl(struct file *fd, unsigned int cmd, unsigned long ua)
{
struct crystalhd_adp *adp = chd_get_adp();
crystalhd_cmd_proc cproc;
struct crystalhd_user *uc;
+ int ret;

if (!adp || !fd) {
BCMLOG_ERR("Invalid adp\n");
@@ -279,13 +280,17 @@ static int chd_dec_ioctl(struct inode *in, struct file *fd,
return -ENODATA;
}

+ lock_kernel();
cproc = crystalhd_get_cmd_proc(&adp->cmds, cmd, uc);
if (!cproc) {
BCMLOG_ERR("Unhandled command: %d\n", cmd);
+ unlock_kernel();
return -EINVAL;
}

- return chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
+ ret = chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
+ unlock_kernel();
+ return ret;
}

static int chd_dec_open(struct inode *in, struct file *fd)
@@ -345,7 +350,7 @@ static int chd_dec_close(struct inode *in, struct file *fd)

static const struct file_operations chd_dec_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = chd_dec_ioctl,
+ .unlocked_ioctl = chd_dec_ioctl,
.open = chd_dec_open,
.release = chd_dec_close,
};
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index 09fb197..7e6095f 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -63,6 +63,7 @@ extern void printques(int);
#include <linux/types.h>
#include <linux/poll.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>

#include <asm/io.h>
#include <asm/uaccess.h>
@@ -835,6 +836,17 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
return 0;
}

+static long
+dt3155_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = dt3155_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}

/*****************************************************
* file operations supported by DT3155 driver
@@ -842,12 +854,12 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
* register_chrdev
*****************************************************/
static struct file_operations dt3155_fops = {
- read: dt3155_read,
- bkl_ioctl: dt3155_ioctl,
- mmap: dt3155_mmap,
- poll: dt3155_poll,
- open: dt3155_open,
- release: dt3155_close
+ .read = dt3155_read,
+ .unlocked_ioctl = dt3155_unlocked_ioctl,
+ .mmap = dt3155_mmap,
+ .poll = dt3155_poll,
+ .open = dt3155_open,
+ .release = dt3155_close
};


diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index edc8c58..bf46e29 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -16,6 +16,7 @@
#include <linux/sysfs.h>
#include <linux/poll.h>
#include <linux/idr.h>
+#include <linux/smp_lock.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/ioctl.h>
@@ -911,7 +912,7 @@ static unsigned int poch_poll(struct file *filp, poll_table *pt)
return ret;
}

-static int poch_ioctl(struct inode *inode, struct file *filp,
+static int poch_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct channel_info *channel = filp->private_data;
@@ -1033,11 +1034,23 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
return 0;
}

+static long
+poch_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = poch_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
- .bkl_ioctl = poch_ioctl,
+ .poch_ioctl = poch_unlocked_ioctl,
.poll = poch_poll,
.mmap = poch_mmap
};
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 7ba7149..bc16fc0 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/syscalls.h>
+#include <linux/smp_lock.h>
#include <linux/types.h>

#include <asm/io.h>
@@ -130,8 +131,7 @@ static int vme_user_release(struct inode *, struct file *);
static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *);
static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *);
static loff_t vme_user_llseek(struct file *, loff_t, int);
-static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);

static int __init vme_user_probe(struct device *, int, int);
static int __exit vme_user_remove(struct device *, int, int);
@@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = {
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
- .bkl_ioctl = vme_user_ioctl,
+ .unlocked_ioctl = vme_user_unlocked_ioctl,
};


@@ -555,6 +555,18 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
}

+static long
+vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = vme_user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+

/*
* Unallocate a previously allocated buffer
--
1.6.6.1

2010-04-27 09:19:21

by John Kacur

[permalink] [raw]
Subject: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

Fix-up compile problems as a result of the bkl-pushdown.
In particular, the v4l2_ioctl should call an unlocked_ioctl

Signed-off-by: John Kacur <[email protected]>
---
drivers/media/video/v4l2-dev.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 3606694..8fbfa61 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -222,12 +222,12 @@ static long v4l2_ioctl(struct file *filp,
struct video_device *vdev = video_devdata(filp);
int ret;

- if (!vdev->fops->ioctl)
+ if (!vdev->fops->unlocked_ioctl)
return -ENOTTY;
/* Allow ioctl to continue even if the device was unregistered.
Things like dequeueing buffers might still be useful. */
lock_kernel();
- ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
+ ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
unlock_kernel();

return ret;
--
1.6.6.1

2010-04-27 09:19:37

by John Kacur

[permalink] [raw]
Subject: [PATCH 09/10] drivers: push down BKL into various drivers

From: Arnd Bergmann <[email protected]>

These are the last remaining device drivers using
the ->ioctl file operation in the drivers directory.

Signed-off-by: Arnd Bergmann <[email protected]>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <[email protected]>
---
drivers/block/pktcdvd.c | 13 ++++++++--
drivers/char/apm-emulation.c | 8 ++++--
drivers/char/applicom.c | 13 ++++++----
drivers/char/ds1620.c | 16 +++++++++++-
drivers/char/dtlk.c | 15 ++++++------
drivers/char/generic_nvram.c | 17 +++++++++++--
drivers/char/genrtc.c | 16 +++++++++++-
drivers/char/hpet.c | 14 +++++++----
drivers/char/i8k.c | 21 ++++++++++++++---
drivers/char/ipmi/ipmi_devintf.c | 26 +++++++++++++++++----
drivers/char/ipmi/ipmi_watchdog.c | 17 ++++++++++++-
drivers/char/nvram.c | 10 ++++++--
drivers/char/nwflash.c | 7 ++++-
drivers/char/raw.c | 42 ++++++++++++++++++++---------------
drivers/hwmon/fschmd.c | 9 ++++---
drivers/hwmon/w83793.c | 10 +++++---
drivers/input/misc/hp_sdc_rtc.c | 34 ++++++++++++++++++++--------
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 17 +++++++++++--
drivers/mtd/mtdchar.c | 19 +++++++++++----
drivers/pcmcia/pcmcia_ioctl.c | 17 +++++++++++--
drivers/rtc/rtc-m41t80.c | 16 +++++++++++-
drivers/sbus/char/openprom.c | 44 +++++++++++++++++++++----------------
drivers/usb/mon/mon_bin.c | 23 ++++++++++++++-----
drivers/usb/mon/mon_stat.c | 3 +-
25 files changed, 307 insertions(+), 122 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index d0bb5c7..84a5658 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -55,6 +55,7 @@
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
#include <linux/freezer.h>
#include <linux/mutex.h>
#include <linux/slab.h>
@@ -2984,7 +2985,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
mutex_unlock(&ctl_mutex);
}

-static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
struct pkt_ctrl_command ctrl_cmd;
@@ -3001,16 +3002,22 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
case PKT_CTRL_CMD_SETUP:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ lock_kernel();
ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev);
+ unlock_kernel();
ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev);
break;
case PKT_CTRL_CMD_TEARDOWN:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ lock_kernel();
ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev));
+ unlock_kernel();
break;
case PKT_CTRL_CMD_STATUS:
+ lock_kernel();
pkt_get_status(&ctrl_cmd);
+ unlock_kernel();
break;
default:
return -ENOTTY;
@@ -3023,8 +3030,8 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm


static const struct file_operations pkt_ctl_fops = {
- .bkl_ioctl = pkt_ctl_ioctl,
- .owner = THIS_MODULE,
+ .unlocked_ioctl = pkt_ctl_ioctl,
+ .owner = THIS_MODULE,
};

static struct miscdevice pkt_misc = {
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index a7d3df3..033e150 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -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
* has acknowledge does the actual suspend happen.
*/
-static int
-apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
+static long
+apm_ioctl(struct file *filp, u_int cmd, u_long arg)
{
struct apm_user *as = filp->private_data;
int err = -EINVAL;
@@ -274,6 +274,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
if (!as->suser || !as->writer)
return -EPERM;

+ lock_kernel();
switch (cmd) {
case APM_IOC_SUSPEND:
mutex_lock(&state_lock);
@@ -334,6 +335,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
mutex_unlock(&state_lock);
break;
}
+ unlock_kernel();

return err;
}
@@ -397,7 +399,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = apm_read,
.poll = apm_poll,
- .bkl_ioctl = apm_ioctl,
+ .unlocked_ioctl = apm_ioctl,
.open = apm_open,
.release = apm_release,
};
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index 8a845bd..63313a3 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -26,6 +26,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
+#include <linux/smp_lock.h>
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/wait.h>
@@ -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_write (struct file *, const char __user *, size_t, loff_t *);
-static int ac_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long ac_ioctl(struct file *, unsigned int, unsigned long);
static irqreturn_t ac_interrupt(int, void *);

static const struct file_operations ac_fops = {
@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
.llseek = no_llseek,
.read = ac_read,
.write = ac_write,
- .bkl_ioctl = ac_ioctl,
+ .unlocked_ioctl = ac_ioctl,
};

static struct miscdevice ac_miscdev = {
@@ -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 */
int i;
@@ -711,7 +711,8 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
kfree(adgl);
return -EFAULT;
}
-
+
+ lock_kernel();
IndexCard = adgl->num_card-1;

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
warncount--;
}
kfree(adgl);
+ unlock_kernel();
return -EINVAL;
}

@@ -838,6 +840,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
}
Dummy = readb(apbs[IndexCard].RamIO + VERS);
kfree(adgl);
+ unlock_kernel();
return 0;
}

diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index de8f7ba..dbee868 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -232,7 +232,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
}

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;
union {
@@ -316,6 +316,18 @@ ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
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
static int
proc_therm_ds1620_read(char *buf, char **start, off_t offset,
@@ -344,7 +356,7 @@ static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
.open = ds1620_open,
.read = ds1620_read,
- .bkl_ioctl = ds1620_ioctl,
+ .unlocked_ioctl = ds1620_unlocked_ioctl,
};

static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index da15fb9..e3859d4 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -93,8 +93,8 @@ static ssize_t dtlk_write(struct file *, const char __user *,
static unsigned int dtlk_poll(struct file *, poll_table *);
static int dtlk_open(struct inode *, struct file *);
static int dtlk_release(struct inode *, struct file *);
-static int dtlk_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long dtlk_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg);

static const struct file_operations dtlk_fops =
{
@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
.read = dtlk_read,
.write = dtlk_write,
.poll = dtlk_poll,
- .bkl_ioctl = dtlk_ioctl,
+ .unlocked_ioctl = dtlk_ioctl,
.open = dtlk_open,
.release = dtlk_release,
};
@@ -263,10 +263,9 @@ static void dtlk_timer_tick(unsigned long data)
wake_up_interruptible(&dtlk_process_list);
}

-static int dtlk_ioctl(struct inode *inode,
- struct file *file,
- unsigned int cmd,
- unsigned long arg)
+static long dtlk_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long arg)
{
char __user *argp = (char __user *)arg;
struct dtlk_settings *sp;
@@ -276,7 +275,9 @@ static int dtlk_ioctl(struct inode *inode,
switch (cmd) {

case DTLK_INTERROGATE:
+ lock_kernel();
sp = dtlk_interrogate();
+ unlock_kernel();
if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
return -EINVAL;
return 0;
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index 0947ad9..82b5a88 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -19,6 +19,7 @@
#include <linux/miscdevice.h>
#include <linux/fcntl.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/nvram.h>
#ifdef CONFIG_PPC_PMAC
@@ -84,8 +85,7 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,
return p - buf;
}

-static int nvram_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int nvram_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
switch(cmd) {
#ifdef CONFIG_PPC_PMAC
@@ -116,12 +116,23 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
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 = {
.owner = THIS_MODULE,
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .bkl_ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_unlocked_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 414ca68..b6c2cc1 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -262,7 +262,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
#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)
{
struct rtc_time wtime;
@@ -332,6 +332,18 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
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.
* Also clear the previous interrupt data on an open, and clean
@@ -482,7 +494,7 @@ static const struct file_operations gen_rtc_fops = {
.read = gen_rtc_read,
.poll = gen_rtc_poll,
#endif
- .bkl_ioctl = gen_rtc_ioctl,
+ .unlocked_ioctl = gen_rtc_unlocked_ioctl,
.open = gen_rtc_open,
.release = gen_rtc_release,
};
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 09c33d1..a0a1829 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -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(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
+static long hpet_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
struct hpet_dev *devp;
+ int ret;

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)
@@ -654,7 +658,7 @@ static const struct file_operations hpet_fops = {
.llseek = no_llseek,
.read = hpet_read,
.poll = hpet_poll,
- .bkl_ioctl = hpet_ioctl,
+ .unlocked_ioctl = hpet_ioctl,
.open = hpet_open,
.release = hpet_release,
.fasync = hpet_fasync,
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 2a211d5..3dc67ae 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -21,6 +21,7 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/smp_lock.h>
#include <linux/dmi.h>
#include <linux/capability.h>
#include <asm/uaccess.h>
@@ -82,8 +83,8 @@ module_param(fan_mult, int, 0);
MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with");

static int i8k_open_fs(struct inode *inode, struct file *file);
-static int i8k_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long i8k_unlocked_ioctl(struct file *, unsigned int,
+ unsigned long);

static const struct file_operations i8k_fops = {
.owner = THIS_MODULE,
@@ -91,7 +92,7 @@ static const struct file_operations i8k_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
- .bkl_ioctl = i8k_ioctl,
+ .unlocked_ioctl = i8k_unlocked_ioctl,
};

struct smm_regs {
@@ -307,7 +308,7 @@ static int i8k_get_dell_signature(int req_fn)
return regs.eax == 1145651527 && regs.edx == 1145392204 ? 0 : -1;
}

-static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
+static int i8k_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg)
{
int val = 0;
@@ -395,6 +396,18 @@ static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
return 0;
}

+static long
+i8k_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = i8k_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*
* Print the information for /proc/i8k.
*/
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 57b2990..d8ec92a 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -228,8 +228,7 @@ static int handle_send_req(ipmi_user_t user,
return rv;
}

-static int ipmi_ioctl(struct inode *inode,
- struct file *file,
+static int ipmi_ioctl(struct file *file,
unsigned int cmd,
unsigned long data)
{
@@ -630,6 +629,23 @@ static int ipmi_ioctl(struct inode *inode,
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

/*
@@ -802,7 +818,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
if (copy_to_user(precv64, &recv64, sizeof(recv64)))
return -EFAULT;

- rc = ipmi_ioctl(filep->f_path.dentry->d_inode, filep,
+ rc = ipmi_ioctl(filep,
((cmd == COMPAT_IPMICTL_RECEIVE_MSG)
? IPMICTL_RECEIVE_MSG
: IPMICTL_RECEIVE_MSG_TRUNC),
@@ -819,14 +835,14 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
return rc;
}
default:
- return ipmi_ioctl(filep->f_path.dentry->d_inode, filep, cmd, arg);
+ return ipmi_ioctl(filep, cmd, arg);
}
}
#endif

static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
- .bkl_ioctl = ipmi_ioctl,
+ .unlocked_ioctl = ipmi_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
#endif
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index e8d478e..82bcdb2 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -659,7 +659,7 @@ static struct watchdog_info ident = {
.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)
{
void __user *argp = (void __user *)arg;
@@ -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,
const char __user *buf,
size_t len,
@@ -880,7 +893,7 @@ static const struct file_operations ipmi_wdog_fops = {
.read = ipmi_read,
.poll = ipmi_poll,
.write = ipmi_write,
- .bkl_ioctl = ipmi_ioctl,
+ .unlocked_ioctl = ipmi_unlocked_ioctl,
.open = ipmi_open,
.release = ipmi_close,
.fasync = ipmi_fasync,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 2688c4e..66d2917 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -296,8 +296,8 @@ checksum_err:
return -EIO;
}

-static int nvram_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long nvram_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
int i;

@@ -308,6 +308,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

+ lock_kernel();
spin_lock_irq(&rtc_lock);

for (i = 0; i < NVRAM_BYTES; ++i)
@@ -315,6 +316,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
__nvram_set_checksum();

spin_unlock_irq(&rtc_lock);
+ unlock_kernel();
return 0;

case NVRAM_SETCKS:
@@ -323,9 +325,11 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

+ lock_kernel();
spin_lock_irq(&rtc_lock);
__nvram_set_checksum();
spin_unlock_irq(&rtc_lock);
+ unlock_kernel();
return 0;

default:
@@ -422,7 +426,7 @@ static const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = nvram_read,
.write = nvram_write,
- .bkl_ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_ioctl,
.open = nvram_open,
.release = nvram_release,
};
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index 636b9f8..043a1c7 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -94,8 +94,9 @@ static int get_flash_id(void)
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) {
case CMD_WRITE_DISABLE:
gbWriteBase64Enable = 0;
@@ -113,8 +114,10 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm
default:
gbWriteBase64Enable = 0;
gbWriteEnable = 0;
+ unlock_kernel();
return -EINVAL;
}
+ unlock_kernel();
return 0;
}

@@ -631,7 +634,7 @@ static const struct file_operations flash_fops =
.llseek = flash_llseek,
.read = flash_read,
.write = flash_write,
- .bkl_ioctl = flash_ioctl,
+ .unlocked_ioctl = flash_ioctl,
};

static struct miscdevice flash_miscdev =
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index e0ece78..b38942f 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -121,13 +121,17 @@ static int raw_release(struct inode *inode, struct file *filp)
/*
* Forward ioctls to the underlying block device.
*/
-static int
-raw_ioctl(struct inode *inode, struct file *filp,
- unsigned int command, unsigned long arg)
+static long
+raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
{
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)
@@ -141,13 +145,14 @@ static void bind_device(struct raw_config_request *rq)
* Deal with ioctls against the raw-device control interface, to bind
* and unbind other raw devices.
*/
-static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
- unsigned int command, unsigned long arg)
+static long raw_ctl_ioctl(struct file *filp, unsigned int command,
+ unsigned long arg)
{
struct raw_config_request rq;
struct raw_device_data *rawdev;
int err = 0;

+ lock_kernel();
switch (command) {
case RAW_SETBIND:
case RAW_GETBIND:
@@ -240,25 +245,26 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
break;
}
out:
+ unlock_kernel();
return err;
}

static const struct file_operations raw_fops = {
- .read = do_sync_read,
- .aio_read = generic_file_aio_read,
- .write = do_sync_write,
- .aio_write = blkdev_aio_write,
- .fsync = blkdev_fsync,
- .open = raw_open,
- .release= raw_release,
- .bkl_ioctl = raw_ioctl,
- .owner = THIS_MODULE,
+ .read = do_sync_read,
+ .aio_read = generic_file_aio_read,
+ .write = do_sync_write,
+ .aio_write = blkdev_aio_write,
+ .fsync = blkdev_fsync,
+ .open = raw_open,
+ .release = raw_release,
+ .unlocked_ioctl = raw_ioctl,
+ .owner = THIS_MODULE,
};

static const struct file_operations raw_ctl_fops = {
- .bkl_ioctl = raw_ctl_ioctl,
- .open = raw_open,
- .owner = THIS_MODULE,
+ .unlocked_ioctl = raw_ctl_ioctl,
+ .open = raw_open,
+ .owner = THIS_MODULE,
};

static struct cdev raw_cdev;
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index fa60ff2..b7ca2a9 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -38,6 +38,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
+#include <linux/smp_lock.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
@@ -847,8 +848,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count;
}

-static int watchdog_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
@@ -858,6 +858,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int i, ret = 0;
struct fschmd_data *data = filp->private_data;

+ lock_kernel();
switch (cmd) {
case WDIOC_GETSUPPORT:
ident.firmware_version = data->revision;
@@ -914,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default:
ret = -ENOTTY;
}
-
+ unlock_kernel();
return ret;
}

@@ -924,7 +925,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_release,
.write = watchdog_write,
- .bkl_ioctl = watchdog_ioctl,
+ .unlocked_ioctl = watchdog_ioctl,
};


diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 6f63623..697202e 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
+#include <linux/smp_lock.h>
#include <linux/hwmon-vid.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
@@ -1319,8 +1320,8 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count;
}

-static int watchdog_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long watchdog_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
{
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING |
@@ -1332,6 +1333,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int val, ret = 0;
struct w83793_data *data = filp->private_data;

+ lock_kernel();
switch (cmd) {
case WDIOC_GETSUPPORT:
if (!nowayout)
@@ -1385,7 +1387,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default:
ret = -ENOTTY;
}
-
+ unlock_kernel();
return ret;
}

@@ -1395,7 +1397,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_close,
.write = watchdog_write,
- .bkl_ioctl = watchdog_ioctl,
+ .unlocked_ioctl = watchdog_ioctl,
};

/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 0fdfd20..e00a1cc 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -43,6 +43,7 @@
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/rtc.h>
+#include <linux/smp_lock.h>
#include <linux/semaphore.h>

MODULE_AUTHOR("Brian S. Julin <[email protected]>");
@@ -64,8 +65,8 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos);

-static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg);

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,
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)
{
#if 1
@@ -659,14 +660,27 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
#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 = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .read = hp_sdc_rtc_read,
- .poll = hp_sdc_rtc_poll,
- .bkl_ioctl = hp_sdc_rtc_ioctl,
- .open = hp_sdc_rtc_open,
- .fasync = hp_sdc_rtc_fasync,
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = hp_sdc_rtc_read,
+ .poll = hp_sdc_rtc_poll,
+ .unlocked_ioctl = hp_sdc_rtc_ioctl,
+ .open = hp_sdc_rtc_open,
+ .fasync = hp_sdc_rtc_fasync,
};

static struct miscdevice hp_sdc_rtc_dev = {
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
index 6a3115f..a271c82 100644
--- a/drivers/macintosh/nvram.c
+++ b/drivers/macintosh/nvram.c
@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .bkl_ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 1cac03c..3d4fc0f 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2273,8 +2273,7 @@ static int register_pmu_pm_ops(void)
device_initcall(register_pmu_pm_ops);
#endif

-static int
-pmu_ioctl(struct inode * inode, struct file *filp,
+static int pmu_ioctl(struct file *filp,
u_int cmd, u_long arg)
{
__u32 __user *argp = (__u32 __user *)arg;
@@ -2337,11 +2336,23 @@ pmu_ioctl(struct inode * inode, struct file *filp,
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 = {
.read = pmu_read,
.write = pmu_write,
.poll = pmu_fpoll,
- .bkl_ioctl = pmu_ioctl,
+ .unlocked_ioctl = pmu_unlocked_ioctl,
.open = pmu_open,
.release = pmu_release,
};
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 57b48c4..6749c2f 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -450,8 +450,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
return ret;
}

-static int mtd_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg)
+static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
{
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
@@ -822,6 +821,17 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
return ret;
} /* 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

struct mtd_oob_buf32 {
@@ -836,7 +846,6 @@ struct mtd_oob_buf32 {
static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
- struct inode *inode = file->f_path.dentry->d_inode;
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
void __user *argp = compat_ptr(arg);
@@ -874,7 +883,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
break;
}
default:
- ret = mtd_ioctl(inode, file, cmd, (unsigned long)argp);
+ ret = mtd_ioctl(file, cmd, (unsigned long)argp);
}

unlock_kernel();
@@ -942,7 +951,7 @@ static const struct file_operations mtd_fops = {
.llseek = mtd_lseek,
.read = mtd_read,
.write = mtd_write,
- .bkl_ioctl = mtd_ioctl,
+ .unlocked_ioctl = mtd_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl,
#endif
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index ca84016..a3b1b5b 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -821,8 +821,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)

/*====================================================================*/

-static int ds_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg)
+static int ds_ioctl(struct file *file, u_int cmd, u_long arg)
{
struct pcmcia_socket *s;
void __user *uarg = (char __user *)arg;
@@ -1031,13 +1030,25 @@ free_out:
return err;
} /* 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 = {
.owner = THIS_MODULE,
.open = ds_open,
.release = ds_release,
- .bkl_ioctl = ds_ioctl,
+ .unlocked_ioctl = ds_unlocked_ioctl,
.read = ds_read,
.write = ds_write,
.poll = ds_poll,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index e662d61..038095d 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -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
* 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)
{
int new_margin, rv;
@@ -676,6 +676,18 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
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:
* @inode: inode of device
@@ -736,7 +748,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
.read = wdt_read,
- .bkl_ioctl = wdt_ioctl,
+ .unlocked_ioctl = wdt_unlocked_ioctl,
.write = wdt_write,
.open = wdt_open,
.release = wdt_release,
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 1fdc1a9..d53e62a 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -298,9 +298,9 @@ static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsiz
/*
* SunOS and Solaris /dev/openprom ioctl calls.
*/
-static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg,
- struct device_node *dp)
+static long openprom_sunos_ioctl(struct file * file,
+ unsigned int cmd, unsigned long arg,
+ struct device_node *dp)
{
DATA *data = file->private_data;
struct openpromio *opp = NULL;
@@ -316,6 +316,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
if (bufsize < 0)
return bufsize;

+ lock_kernel();
+
switch (cmd) {
case OPROMGETOPT:
case OPROMGETPROP:
@@ -365,6 +367,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
}

kfree(opp);
+ unlock_kernel();
+
return error;
}

@@ -547,13 +551,14 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
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)
{
DATA *data = (DATA *) file->private_data;
void __user *argp = (void __user *)arg;
int err;

+ lock_kernel();
switch (cmd) {
case OPIOCGET:
err = opiocget(argp, data);
@@ -570,10 +575,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
case OPIOCGETOPTNODE:
BUILD_BUG_ON(sizeof(phandle) != sizeof(int));

+ err = 0;
if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
- return -EFAULT;
-
- return 0;
+ err = -EFAULT;
+ break;

case OPIOCGETNEXT:
case OPIOCGETCHILD:
@@ -581,9 +586,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
break;

default:
- return -EINVAL;
-
+ err = -EINVAL;
+ break;
};
+ unlock_kernel();

return err;
}
@@ -592,8 +598,8 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
/*
* Handoff control to the correct ioctl handler.
*/
-static int openprom_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg)
+static long openprom_ioctl(struct file * file,
+ unsigned int cmd, unsigned long arg)
{
DATA *data = (DATA *) file->private_data;

@@ -602,14 +608,14 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTOPT:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
options_node);

case OPROMSETOPT:
case OPROMSETOPT2:
if ((file->f_mode & FMODE_WRITE) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
options_node);

case OPROMNEXT:
@@ -618,7 +624,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTPROP:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
data->current_node);

case OPROMU2P:
@@ -630,7 +636,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMPATH2NODE:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg, NULL);
+ return openprom_sunos_ioctl(file, cmd, arg, NULL);

case OPIOCGET:
case OPIOCNEXTPROP:
@@ -639,12 +645,12 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPIOCGETCHILD:
if ((file->f_mode & FMODE_READ) == 0)
return -EBADF;
- return openprom_bsd_ioctl(inode,file,cmd,arg);
+ return openprom_bsd_ioctl(file,cmd,arg);

case OPIOCSET:
if ((file->f_mode & FMODE_WRITE) == 0)
return -EBADF;
- return openprom_bsd_ioctl(inode,file,cmd,arg);
+ return openprom_bsd_ioctl(file,cmd,arg);

default:
return -EINVAL;
@@ -676,7 +682,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
case OPROMSETCUR:
case OPROMPCI2NODE:
case OPROMPATH2NODE:
- rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ rval = openprom_ioctl(file, cmd, arg);
break;
}

@@ -709,7 +715,7 @@ static int openprom_release(struct inode * inode, struct file * file)
static const struct file_operations openprom_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .bkl_ioctl = openprom_ioctl,
+ .unlocked_ioctl = openprom_ioctl,
.compat_ioctl = openprom_compat_ioctl,
.open = openprom_open,
.release = openprom_release,
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 9ce7c74..5594772 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -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,
- unsigned int cmd, unsigned long arg)
+static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct mon_reader_bin *rp = file->private_data;
// struct mon_bus* mbus = rp->r.m_bus;
@@ -1095,6 +1094,19 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
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
static long mon_bin_compat_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
@@ -1148,14 +1160,13 @@ static long mon_bin_compat_ioctl(struct file *file,
return 0;

case MON_IOCG_STATS:
- return mon_bin_ioctl(NULL, file, cmd,
- (unsigned long) compat_ptr(arg));
+ return mon_bin_ioctl(file, cmd, (unsigned long) compat_ptr(arg));

case MON_IOCQ_URB_LEN:
case MON_IOCQ_RING_SIZE:
case MON_IOCT_RING_SIZE:
case MON_IOCH_MFLUSH:
- return mon_bin_ioctl(NULL, file, cmd, arg);
+ return mon_bin_ioctl(file, cmd, arg);

default:
;
@@ -1239,7 +1250,7 @@ static const struct file_operations mon_fops_binary = {
.read = mon_bin_read,
/* .write = mon_text_write, */
.poll = mon_bin_poll,
- .bkl_ioctl = mon_bin_ioctl,
+ .unlocked_ioctl = mon_bin_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mon_bin_compat_ioctl,
#endif
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 091e7fb..8ec94f1 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -11,6 +11,7 @@
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/fs.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>

#include "usb_mon.h"
@@ -63,6 +64,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read,
/* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */
- /* .bkl_ioctl = mon_stat_ioctl, */
+ /* .unlocked_ioctl = mon_stat_ioctl, */
.release = mon_stat_release,
};
--
1.6.6.1

2010-04-27 09:20:12

by John Kacur

[permalink] [raw]
Subject: [PATCH 03/10] bkl: Fix up compile problems in megaraid from bkl push-down

- Forward declaration missing ';'
- Conflicting declaraction in megaraid.h changed

Signed-off-by: John Kacur <[email protected]>
---
drivers/scsi/megaraid.c | 2 +-
drivers/scsi/megaraid.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index c20b621..0b6e322 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -92,7 +92,7 @@ static struct proc_dir_entry *mega_proc_dir_entry;
static struct mega_hbas mega_hbas[MAX_CONTROLLERS];

static long
-megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);

/*
* The File Operations structure for the serial/ioctl interface of the driver
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index d310f49..b3d2949 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -1013,8 +1013,8 @@ static void mega_8_to_40ld (mraid_inquiry *inquiry,
mega_inquiry3 *enquiry3, mega_product_info *);

static int megadev_open (struct inode *, struct file *);
-static int megadev_ioctl (struct inode *, struct file *, unsigned int,
- unsigned long);
+static int
+megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
static int mega_m_to_n(void __user *, nitioctl_t *);
static int mega_n_to_m(void __user *, megacmd_t *);

--
1.6.6.1

2010-04-27 11:18:33

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

On Tuesday 27 April 2010, John Kacur wrote:
> Fix-up compile problems as a result of the bkl-pushdown.
> In particular, the v4l2_ioctl should call an unlocked_ioctl
>
> Signed-off-by: John Kacur <[email protected]>
> ---
> drivers/media/video/v4l2-dev.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index 3606694..8fbfa61 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -222,12 +222,12 @@ static long v4l2_ioctl(struct file *filp,
> struct video_device *vdev = video_devdata(filp);
> int ret;
>
> - if (!vdev->fops->ioctl)
> + if (!vdev->fops->unlocked_ioctl)
> return -ENOTTY;
> /* Allow ioctl to continue even if the device was unregistered.
> Things like dequeueing buffers might still be useful. */
> lock_kernel();
> - ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
> + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> unlock_kernel();
>
> return ret;

No, this is what I thought as well, at first, but the version I posted is
actually correct.

vdev->fops is not struct file_operations but struct v4l2_file_operations,
and the v4l2_ioctl function is used only when fops->ioctl is set, see
__video_register_device.

The v4l2 ioctl stuff probably can use a lot of cleanup itself, but so
far I think we're not making it worse with my patch.

Arnd

2010-04-27 11:32:17

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

On Tuesday 27 April 2010, John Kacur wrote:
> These are bkl pushdowns from Arnd that conflicted with
> Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
> conflicts. In addition - during allyesconfig compile testing on x86_64 I found
> a number of issues that I fixed-up

Thanks for catching the scsi bugs! It was getting late yesterday night, so
I didn't go through a full allyesconfig then.

> I pushed these to my own new linus-bkl tree.
> git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl
>
> Frederic, if you want to grab those, pls do so. also, we might want to combine
> my compile fixes with Arnd's push-down patches, for better git bisectability.

Yes, your fixes (except the v4l2 patch, see comment there) should best be
merged into the main patches.

The idea was that if we manage to kill all fops->ioctl users right away,
we wouldn't even need Linus' patch and move to dungeon level 2 directly.
Either way works for me though.

Should we just split up the rest? If you, Frederic and me each take one
of these chunks, we're done. According to the diffstat from Linus' patch,
this is what's left:

a) arch specific drivers
arch/cris/arch-v10/drivers/ds1302.c | 2 +-
arch/cris/arch-v10/drivers/gpio.c | 2 +-
arch/cris/arch-v10/drivers/i2c.c | 2 +-
arch/cris/arch-v10/drivers/pcf8563.c | 2 +-
arch/cris/arch-v10/drivers/sync_serial.c | 2 +-
arch/cris/arch-v32/drivers/cryptocop.c | 2 +-
arch/cris/arch-v32/drivers/i2c.c | 2 +-
arch/cris/arch-v32/drivers/mach-a3/gpio.c | 2 +-
arch/cris/arch-v32/drivers/mach-fs/gpio.c | 2 +-
arch/cris/arch-v32/drivers/pcf8563.c | 2 +-
arch/cris/arch-v32/drivers/sync_serial.c | 2 +-
arch/ia64/kernel/perfmon.c | 2 +-
arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +-
arch/m68k/bvme6000/rtc.c | 2 +-
arch/m68k/mvme16x/rtc.c | 2 +-
arch/um/drivers/harddog_kern.c | 2 +-
arch/um/drivers/hostaudio_kern.c | 4 +-
arch/um/drivers/mmapper_kern.c | 2 +-

b) file systems (my other series has patches for some of these already)
fs/autofs/root.c | 2 +-
fs/autofs4/root.c | 2 +-
fs/coda/pioctl.c | 2 +-
fs/coda/psdev.c | 2 +-
fs/fat/dir.c | 2 +-
fs/fat/file.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/logfs/dir.c | 2 +-
fs/logfs/file.c | 2 +-
fs/ncpfs/dir.c | 2 +-
fs/ncpfs/file.c | 2 +-
fs/ntfs/dir.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/smbfs/dir.c | 2 +-
fs/smbfs/file.c | 2 +-
fs/udf/dir.c | 2 +-
fs/udf/file.c | 2 +-

c) special stuff (this should go last)
Documentation/filesystems/vfs.txt | 2 +-
fs/bad_inode.c | 2 +-
fs/ioctl.c | 4 +-
fs/compat_ioctl.c | 2 +-
fs/ecryptfs/file.c | 9 ++++---
fs/proc/inode.c | 8 +++---
include/linux/fs.h | 2 -

Arnd

2010-04-27 11:54:45

by John Kacur

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.



On Tue, 27 Apr 2010, Arnd Bergmann wrote:

> On Tuesday 27 April 2010, John Kacur wrote:
> > Fix-up compile problems as a result of the bkl-pushdown.
> > In particular, the v4l2_ioctl should call an unlocked_ioctl
> >
> > Signed-off-by: John Kacur <[email protected]>
> > ---
> > drivers/media/video/v4l2-dev.c | 4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> > index 3606694..8fbfa61 100644
> > --- a/drivers/media/video/v4l2-dev.c
> > +++ b/drivers/media/video/v4l2-dev.c
> > @@ -222,12 +222,12 @@ static long v4l2_ioctl(struct file *filp,
> > struct video_device *vdev = video_devdata(filp);
> > int ret;
> >
> > - if (!vdev->fops->ioctl)
> > + if (!vdev->fops->unlocked_ioctl)
> > return -ENOTTY;
> > /* Allow ioctl to continue even if the device was unregistered.
> > Things like dequeueing buffers might still be useful. */
> > lock_kernel();
> > - ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
> > + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> > unlock_kernel();
> >
> > return ret;
>
> No, this is what I thought as well, at first, but the version I posted is
> actually correct.
>
> vdev->fops is not struct file_operations but struct v4l2_file_operations,
> and the v4l2_ioctl function is used only when fops->ioctl is set, see
> __video_register_device.
>
> The v4l2 ioctl stuff probably can use a lot of cleanup itself, but so
> far I think we're not making it worse with my patch.
>

Hi Arnd

Well it is certainly possible that my fixup is not correct too - your
patch cannot be correct, because it doesn't compile! Here is what I get
when I apply your patch to a recent linus/master

make O=/bld/arnd/ drivers/media/video/v4l2-dev.o
-----CUT A BUNCH OF STUFF OUT ---
CC drivers/media/video/v4l2-dev.o
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c: In function
?v4l2_ioctl?:
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning: passing
argument 1 of ?vdev->fops->ioctl? from incompatible pointer type
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected
?struct file *? but argument is of type ?struct inode *?
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning: passing
argument 2 of ?vdev->fops->ioctl? makes integer from pointer without a
cast
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected
?unsigned int? but argument is of type ?struct file *?
/home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: error: too many
arguments to function ?vdev->fops->ioctl?
make[2]: *** [drivers/media/video/v4l2-dev.o] Error 1
make[1]: *** [drivers/media/video/v4l2-dev.o] Error 2
make: *** [sub-make] Error 2


Thanks

2010-04-27 12:20:08

by John Kacur

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes



On Tue, 27 Apr 2010, Arnd Bergmann wrote:

> On Tuesday 27 April 2010, John Kacur wrote:
> > These are bkl pushdowns from Arnd that conflicted with
> > Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
> > conflicts. In addition - during allyesconfig compile testing on x86_64 I found
> > a number of issues that I fixed-up
>
> Thanks for catching the scsi bugs! It was getting late yesterday night, so
> I didn't go through a full allyesconfig then.
>
> > I pushed these to my own new linus-bkl tree.
> > git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl
> >
> > Frederic, if you want to grab those, pls do so. also, we might want to combine
> > my compile fixes with Arnd's push-down patches, for better git bisectability.
>
> Yes, your fixes (except the v4l2 patch, see comment there) should best be
> merged into the main patches.
>
> The idea was that if we manage to kill all fops->ioctl users right away,
> we wouldn't even need Linus' patch and move to dungeon level 2 directly.
> Either way works for me though.
>
> Should we just split up the rest? If you, Frederic and me each take one
> of these chunks, we're done. According to the diffstat from Linus' patch,
> this is what's left:

Okay - good plan. I AM trying to balance doing my own day-to-day work,
and writing slides for a conference but I'm sure you and Frederic are
just as pressed for time as me, so lets go-ahead and divide it up!
That will prevent us from doing redundant work.
I assume the target is 2.6.35 so, we have a little bit of time anyway.

I suggest we divide up a) and b) first and postone c) until the first
parts are done.

Arranging our names by alphabetical order and shuffling the files
off one at a time (for variety), I get this. Is everybody happy with that?
36 files / 3 = 12 files each.
Jan - speak up if you want in.

Arnd
----
arch/cris/arch-v10/drivers/ds1302.c
arch/cris/arch-v10/drivers/pcf8563.c
arch/cris/arch-v32/drivers/i2c.c
arch/cris/arch-v32/drivers/pcf8563.c
arch/ia64/sn/kernel/sn2/sn_hwperf.c
arch/m68k/mvme16x/rtc.c
arch/um/drivers/mmapper_kern.c
fs/coda/psdev.c
fs/hfsplus/dir.c
fs/logfs/file.c
fs/ntfs/dir.c
fs/smbfs/file.c

Frederic
--------
arch/cris/arch-v10/drivers/gpio.c
arch/cris/arch-v10/drivers/sync_serial.c
arch/cris/arch-v32/drivers/mach-a3/gpio.c
arch/cris/arch-v32/drivers/sync_serial.c
arch/m68k/bvme6000/rtc.c
arch/um/drivers/harddog_kern.c
fs/autofs/root.c
fs/fat/dir.c
fs/hfsplus/inode.c
fs/ncpfs/dir.c
fs/ntfs/file.c
fs/udf/dir.c

John
----
arch/cris/arch-v10/drivers/i2c.c
arch/cris/arch-v32/drivers/cryptocop.c
arch/cris/arch-v32/drivers/mach-fs/gpio.c
arch/ia64/kernel/perfmon.c
arch/m68k/bvme6000/rtc.c
arch/um/drivers/hostaudio_kern.c
fs/coda/pioctl.c
fs/fat/file.c
fs/logfs/dir.c
fs/ncpfs/file.c
fs/smbfs/dir.c
fs/udf/file.c

>
> a) arch specific drivers
> arch/cris/arch-v10/drivers/ds1302.c | 2 +-
> arch/cris/arch-v10/drivers/gpio.c | 2 +-
> arch/cris/arch-v10/drivers/i2c.c | 2 +-
> arch/cris/arch-v10/drivers/pcf8563.c | 2 +-
> arch/cris/arch-v10/drivers/sync_serial.c | 2 +-
> arch/cris/arch-v32/drivers/cryptocop.c | 2 +-
> arch/cris/arch-v32/drivers/i2c.c | 2 +-
> arch/cris/arch-v32/drivers/mach-a3/gpio.c | 2 +-
> arch/cris/arch-v32/drivers/mach-fs/gpio.c | 2 +-
> arch/cris/arch-v32/drivers/pcf8563.c | 2 +-
> arch/cris/arch-v32/drivers/sync_serial.c | 2 +-
> arch/ia64/kernel/perfmon.c | 2 +-
> arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +-
> arch/m68k/bvme6000/rtc.c | 2 +-
> arch/m68k/mvme16x/rtc.c | 2 +-
> arch/um/drivers/harddog_kern.c | 2 +-
> arch/um/drivers/hostaudio_kern.c | 4 +-
> arch/um/drivers/mmapper_kern.c | 2 +-
>
> b) file systems (my other series has patches for some of these already)
> fs/autofs/root.c | 2 +-
> fs/autofs4/root.c | 2 +-
> fs/coda/pioctl.c | 2 +-
> fs/coda/psdev.c | 2 +-
> fs/fat/dir.c | 2 +-
> fs/fat/file.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/logfs/dir.c | 2 +-
> fs/logfs/file.c | 2 +-
> fs/ncpfs/dir.c | 2 +-
> fs/ncpfs/file.c | 2 +-
> fs/ntfs/dir.c | 2 +-
> fs/ntfs/file.c | 2 +-
> fs/smbfs/dir.c | 2 +-
> fs/smbfs/file.c | 2 +-
> fs/udf/dir.c | 2 +-
> fs/udf/file.c | 2 +-
>
> c) special stuff (this should go last)
> Documentation/filesystems/vfs.txt | 2 +-
> fs/bad_inode.c | 2 +-
> fs/ioctl.c | 4 +-
> fs/compat_ioctl.c | 2 +-
> fs/ecryptfs/file.c | 9 ++++---
> fs/proc/inode.c | 8 +++---
> include/linux/fs.h | 2 -
>
> Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2010-04-27 12:41:39

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

2010/4/27 John Kacur <[email protected]>:
>
>
> On Tue, 27 Apr 2010, Arnd Bergmann wrote:
>
>> On Tuesday 27 April 2010, John Kacur wrote:
>> > These are bkl pushdowns from Arnd that conflicted with
>> > Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
>> > conflicts. In addition - during allyesconfig compile testing on x86_64 I found
>> > a number of issues that I fixed-up
>>
>> Thanks for catching the scsi bugs! It was getting late yesterday night, so
>> I didn't go through a full allyesconfig then.
>>
>> > I pushed these to my own new linus-bkl tree.
>> > git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl
>> >
>> > Frederic, if you want to grab those, pls do so. also, we might want to combine
>> > my compile fixes with Arnd's push-down patches, for better git bisectability.
>>
>> Yes, your fixes (except the v4l2 patch, see comment there) should best be
>> merged into the main patches.
>>
>> The idea was that if we manage to kill all fops->ioctl users right away,
>> we wouldn't even need Linus' patch and move to dungeon level 2 directly.
>> Either way works for me though.
>>
>> Should we just split up the rest? If you, Frederic and me each take one
>> of these chunks, we're done. According to the diffstat from Linus' patch,
>> this is what's left:
>
> Okay - good plan. I AM trying to balance doing my own day-to-day work,
> and writing slides for a conference but I'm sure you and Frederic are
> just as pressed for time as me, so lets go-ahead and divide it up!
> That will prevent us from doing redundant work.
> I assume the target is 2.6.35 so, we have a little bit of time anyway.
>
> I suggest we divide up a) and b) first and postone c) until the first
> parts are done.
>
> Arranging our names by alphabetical order and shuffling the files
> off one at a time (for variety), I get this. Is everybody happy with that?
> 36 files / 3 = 12 files each.
> Jan - speak up if you want in.
>
> Arnd
> ----
> arch/cris/arch-v10/drivers/ds1302.c
> arch/cris/arch-v10/drivers/pcf8563.c
> arch/cris/arch-v32/drivers/i2c.c
> arch/cris/arch-v32/drivers/pcf8563.c
> arch/ia64/sn/kernel/sn2/sn_hwperf.c
> arch/m68k/mvme16x/rtc.c
> arch/um/drivers/mmapper_kern.c
> fs/coda/psdev.c
> fs/hfsplus/dir.c
> fs/logfs/file.c
> fs/ntfs/dir.c
> fs/smbfs/file.c
>
> Frederic
> --------
> arch/cris/arch-v10/drivers/gpio.c
> arch/cris/arch-v10/drivers/sync_serial.c
> arch/cris/arch-v32/drivers/mach-a3/gpio.c
> arch/cris/arch-v32/drivers/sync_serial.c
> arch/m68k/bvme6000/rtc.c
> arch/um/drivers/harddog_kern.c
> fs/autofs/root.c
> fs/fat/dir.c
> fs/hfsplus/inode.c
> fs/ncpfs/dir.c
> fs/ntfs/file.c
> fs/udf/dir.c



Ok :)

2010-04-27 12:48:14

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

2010/4/27 Arnd Bergmann <[email protected]>:
> On Tuesday 27 April 2010, John Kacur wrote:
>> These are bkl pushdowns from Arnd that conflicted with
>> Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
>> conflicts. In addition - during allyesconfig compile testing on x86_64 I found
>> a number of issues that I fixed-up
>
> Thanks for catching the scsi bugs! It was getting late yesterday night, so
> I didn't go through a full allyesconfig then.
>
>> I pushed these to my own new linus-bkl tree.
>> git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl
>>
>> Frederic, if you want to grab those, pls do so. also, we might want to combine
>> my compile fixes with Arnd's push-down patches, for better git bisectability.
>
> Yes, your fixes (except the v4l2 patch, see comment there) should best be
> merged into the main patches.
>
> The idea was that if we manage to kill all fops->ioctl users right away,
> we wouldn't even need Linus' patch and move to dungeon level 2 directly.
> Either way works for me though.



Yeah. Since we are motivated enough to do the whole pushdown, I think we
should forget the .bkl_ioctl renaming.

This will let Greg take the staging part for example. I can take all
the unmainted rest
(basically most of the rest I guess).

2010-04-27 12:51:20

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

On Tue, Apr 27, 2010 at 13:31, Arnd Bergmann <[email protected]> wrote:
> a) arch specific drivers
>  arch/m68k/bvme6000/rtc.c                    |    2 +-
>  arch/m68k/mvme16x/rtc.c                     |    2 +-

Don't waste your time on these:
http://git.kernel.org/?p=linux/kernel/git/geert/linux-m68k.git;a=commit;h=ce266e954a1bc7cef51115faacaf3d390b534755

Gr{oetje,eeting}s,

Geert (still has to update his for-next branch for 2.6.35).

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2010-04-27 13:03:43

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

On Tuesday 27 April 2010, John Kacur wrote:
> Well it is certainly possible that my fixup is not correct too - your
> patch cannot be correct, because it doesn't compile! Here is what I get
> when I apply your patch to a recent linus/master

Ah, I see.

> make O=/bld/arnd/ drivers/media/video/v4l2-dev.o
> -----CUT A BUNCH OF STUFF OUT ---
> CC drivers/media/video/v4l2-dev.o
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c: In function
> ‘v4l2_ioctl’:
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning: passing
> argument 1 of ‘vdev->fops->ioctl’ from incompatible pointer type
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected
> ‘struct file *’ but argument is of type ‘struct inode *’

I didn't realize that the prototype for the locked ->ioctl function in
v4l2 does not take the inode argument, so that needs to be dropped from
my patch (i.e. not added).

Or we do it slightly better and clean up the code a bit in the process.

Mauro, does this patch make sense to you? It would be good to have your
Ack so we can queue this in the series leading to the removal of the
->ioctl file operation. We can also do the minimal change and let you
take care of fixing this up in a different way in your own tree.

---
Subject: v4l: convert v4l2-dev to unlocked_ioctl

v4l2 implements two separate file operations for drivers that use locked
and unlocked ioctl callbacks. Since we want to remove the ioctl file operation
in favor of the unlocked variant, this separation no longer seems helpful.

Unfortunately, there are still 77 drivers with locked ioctl functions in
their v4l2_file_operations, which need to be taken care of separately.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/media/video/v4l2-dev.c | 52 +++++++++++----------------------------
1 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..ab198ba 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -25,6 +25,7 @@
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/slab.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/system.h>

@@ -215,28 +216,24 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
return vdev->fops->poll(filp, poll);
}

-static int v4l2_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct video_device *vdev = video_devdata(filp);
+ int ret;

- if (!vdev->fops->ioctl)
- return -ENOTTY;
/* Allow ioctl to continue even if the device was unregistered.
Things like dequeueing buffers might still be useful. */
- return vdev->fops->ioctl(filp, cmd, arg);
-}
-
-static long v4l2_unlocked_ioctl(struct file *filp,
- unsigned int cmd, unsigned long arg)
-{
- struct video_device *vdev = video_devdata(filp);
+ if (vdev->fops->unlocked_ioctl) {
+ ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
+ } else if (vdev->fops->ioctl) {
+ /* TODO: convert all drivers to unlocked_ioctl */
+ lock_kernel();
+ ret = vdev->fops->ioctl(filp, cmd, arg);
+ unlock_kernel();
+ } else
+ ret = -ENOTTY;

- if (!vdev->fops->unlocked_ioctl)
- return -ENOTTY;
- /* Allow ioctl to continue even if the device was unregistered.
- Things like dequeueing buffers might still be useful. */
- return vdev->fops->unlocked_ioctl(filp, cmd, arg);
+ return ret;
}

#ifdef CONFIG_MMU
@@ -307,22 +304,6 @@ static int v4l2_release(struct inode *inode, struct file *filp)
return ret;
}

-static const struct file_operations v4l2_unlocked_fops = {
- .owner = THIS_MODULE,
- .read = v4l2_read,
- .write = v4l2_write,
- .open = v4l2_open,
- .get_unmapped_area = v4l2_get_unmapped_area,
- .mmap = v4l2_mmap,
- .unlocked_ioctl = v4l2_unlocked_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = v4l2_compat_ioctl32,
-#endif
- .release = v4l2_release,
- .poll = v4l2_poll,
- .llseek = no_llseek,
-};
-
static const struct file_operations v4l2_fops = {
.owner = THIS_MODULE,
.read = v4l2_read,
@@ -330,7 +311,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .ioctl = v4l2_ioctl,
+ .unlocked_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
@@ -517,10 +498,7 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
ret = -ENOMEM;
goto cleanup;
}
- if (vdev->fops->unlocked_ioctl)
- vdev->cdev->ops = &v4l2_unlocked_fops;
- else
- vdev->cdev->ops = &v4l2_fops;
+ vdev->cdev->ops = &v4l2_fops;
vdev->cdev->owner = vdev->fops->owner;
ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
if (ret < 0) {

2010-04-27 14:24:42

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 0/6] BKL pushdown into ioctl, continued

Here comes my share of the remaining code.

> Arnd
> ----
> arch/cris/arch-v10/drivers/ds1302.c
> arch/cris/arch-v10/drivers/pcf8563.c
> arch/cris/arch-v32/drivers/i2c.c
> arch/cris/arch-v32/drivers/pcf8563.c
> arch/ia64/sn/kernel/sn2/sn_hwperf.c

done

> arch/m68k/mvme16x/rtc.c

dropped, as suggested by Geert

> arch/um/drivers/mmapper_kern.c
> fs/coda/psdev.c
> fs/hfsplus/dir.c
> fs/logfs/file.c

done

> fs/ntfs/dir.c

Nothing to see here

> fs/smbfs/file.c

done


Arnd Bergmann (6):
logfs: push down BKL into ioctl function
hfsplus: push down BKL into ioctl function
cris: push down BKL into some device drivers
sn_hwperf: kill BKL usage
um/mmapper: remove BKL usage
coda/psdev: remove BKL from ioctl function

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 ++++++++++++++++-----
arch/ia64/sn/kernel/sn2/sn_hwperf.c | 9 ++-------
arch/um/drivers/mmapper_kern.c | 5 ++---
fs/coda/psdev.c | 5 ++---
fs/hfsplus/dir.c | 2 +-
fs/hfsplus/hfsplus_fs.h | 3 +--
fs/hfsplus/ioctl.c | 11 ++++++++---
fs/logfs/dir.c | 2 +-
fs/logfs/file.c | 19 +++++++++++++++----
fs/logfs/logfs.h | 4 ++--
13 files changed, 94 insertions(+), 48 deletions(-)

2010-04-27 14:24:59

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 2/7] hfsplus: push down BKL into ioctl function

HFS is one of the remaining users of the ->ioctl function, convert it
blindly to unlocked_ioctl by pushing down the BKL.

Signed-off-by: Arnd Bergmann <[email protected]>
---
fs/hfsplus/dir.c | 2 +-
fs/hfsplus/hfsplus_fs.h | 3 +--
fs/hfsplus/inode.c | 2 +-
fs/hfsplus/ioctl.c | 12 +++++++++---
4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 5f40236..764fd1b 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -494,7 +494,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
const struct file_operations hfsplus_dir_operations = {
.read = generic_read_dir,
.readdir = hfsplus_readdir,
- .ioctl = hfsplus_ioctl,
+ .unlocked_ioctl = hfsplus_ioctl,
.llseek = generic_file_llseek,
.release = hfsplus_dir_release,
};
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 5c10d80..6505c30 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -337,8 +337,7 @@ struct inode *hfsplus_new_inode(struct super_block *, int);
void hfsplus_delete_inode(struct inode *);

/* ioctl.c */
-int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg);
+long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
int hfsplus_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 1bcf597..9bbb829 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -285,7 +285,7 @@ static const struct file_operations hfsplus_file_operations = {
.fsync = file_fsync,
.open = hfsplus_file_open,
.release = hfsplus_file_release,
- .ioctl = hfsplus_ioctl,
+ .unlocked_ioctl = hfsplus_ioctl,
};

struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index f457d2c..ac405f0 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -17,14 +17,16 @@
#include <linux/mount.h>
#include <linux/sched.h>
#include <linux/xattr.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include "hfsplus_fs.h"

-int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
+long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
+ struct inode *inode = filp->f_path.dentry->d_inode;
unsigned int flags;

+ lock_kernel();
switch (cmd) {
case HFSPLUS_IOC_EXT2_GETFLAGS:
flags = 0;
@@ -38,8 +40,10 @@ int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
case HFSPLUS_IOC_EXT2_SETFLAGS: {
int err = 0;
err = mnt_want_write(filp->f_path.mnt);
- if (err)
+ if (err) {
+ unlock_kernel();
return err;
+ }

if (!is_owner_or_cap(inode)) {
err = -EACCES;
@@ -85,9 +89,11 @@ int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
mark_inode_dirty(inode);
setflags_out:
mnt_drop_write(filp->f_path.mnt);
+ unlock_kernel();
return err;
}
default:
+ unlock_kernel();
return -ENOTTY;
}
}
--
1.6.3.3

2010-04-27 14:25:20

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 1/7] logfs: push down BKL into ioctl function

I'm sure that logfs doesn't rely on the BKL, but right now,
we're just pushing it down.

Signed-off-by: Arnd Bergmann <[email protected]>
Cc: Jörn Engel <[email protected]>
---
fs/logfs/dir.c | 2 +-
fs/logfs/file.c | 18 +++++++++++++++---
fs/logfs/logfs.h | 4 ++--
fs/smbfs/ioctl.c | 2 +-
4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 2396a85..a801b5e 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -821,7 +821,7 @@ const struct inode_operations logfs_dir_iops = {
};
const struct file_operations logfs_dir_fops = {
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .unlocked_ioctl = logfs_unlocked_ioctl,
.readdir = logfs_readdir,
.read = generic_read_dir,
};
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 370f367..1dbc342 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -8,6 +8,7 @@
#include "logfs.h"
#include <linux/sched.h>
#include <linux/writeback.h>
+#include <linux/smp_lock.h>

static int logfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
@@ -171,9 +172,9 @@ static int logfs_releasepage(struct page *page, gfp_t only_xfs_uses_this)
}


-int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
+static long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
+ struct inode *inode = file->f_path.dentry->d_inode;
struct logfs_inode *li = logfs_inode(inode);
unsigned int oldflags, flags;
int err;
@@ -209,6 +210,17 @@ int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
}
}

+long logfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = logfs_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
int logfs_fsync(struct file *file, struct dentry *dentry, int datasync)
{
struct super_block *sb = dentry->d_inode->i_sb;
@@ -243,7 +255,7 @@ const struct file_operations logfs_reg_fops = {
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .unlocked_ioctl = logfs_unlocked_ioctl,
.llseek = generic_file_llseek,
.mmap = generic_file_readonly_mmap,
.open = generic_file_open,
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 0a3df1a..8432c51 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -501,8 +501,8 @@ extern const struct inode_operations logfs_reg_iops;
extern const struct file_operations logfs_reg_fops;
extern const struct address_space_operations logfs_reg_aops;
int logfs_readpage(struct file *file, struct page *page);
-int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg);
+long logfs_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg);
int logfs_fsync(struct file *file, struct dentry *dentry, int datasync);

/* gc.c */
diff --git a/fs/smbfs/ioctl.c b/fs/smbfs/ioctl.c
index dbae1f8..910215b 100644
--- a/fs/smbfs/ioctl.c
+++ b/fs/smbfs/ioctl.c
@@ -26,7 +26,7 @@ int
smb_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
- struct smb_sb_info *server = server_from_inode(inode);
+ struct smb_sb_info *server = server_from_inode(filp->f_path.dentry->d_inode);
struct smb_conn_opt opt;
int result = -EINVAL;

--
1.6.3.3

2010-04-27 14:25:11

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 4/7] sn_hwperf: kill BKL usage

This driver always gave up the BKL in its ioctl function, so just
convert it to unlocked_ioctl and remove the BKL here.

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/ia64/sn/kernel/sn2/sn_hwperf.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 55ac3c4..d68fe0f 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -30,7 +30,6 @@
#include <linux/miscdevice.h>
#include <linux/utsname.h>
#include <linux/cpumask.h>
-#include <linux/smp_lock.h>
#include <linux/nodemask.h>
#include <linux/smp.h>
#include <linux/mutex.h>
@@ -682,8 +681,7 @@ static int sn_hwperf_map_err(int hwperf_err)
/*
* ioctl for "sn_hwperf" misc device
*/
-static int
-sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
+static long sn_hwperf_ioctl(struct file *fp, u32 op, unsigned long arg)
{
struct sn_hwperf_ioctl_args a;
struct cpuinfo_ia64 *cdata;
@@ -699,8 +697,6 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
int i;
int j;

- unlock_kernel();
-
/* only user requests are allowed here */
if ((op & SN_HWPERF_OP_MASK) < 10) {
r = -EINVAL;
@@ -859,12 +855,11 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
error:
vfree(p);

- lock_kernel();
return r;
}

static const struct file_operations sn_hwperf_fops = {
- .ioctl = sn_hwperf_ioctl,
+ .unlocked_ioctl = sn_hwperf_ioctl,
};

static struct miscdevice sn_hwperf_dev = {
--
1.6.3.3

2010-04-27 14:25:07

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 5/7] um/mmapper: remove BKL usage

An empty function does not need the BKL, so just remove it.

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/um/drivers/mmapper_kern.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index d22f9e5..7158393 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -46,8 +46,7 @@ static ssize_t mmapper_write(struct file *file, const char __user *buf,
return count;
}

-static int mmapper_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
return -ENOIOCTLCMD;
}
@@ -90,7 +89,7 @@ static const struct file_operations mmapper_fops = {
.owner = THIS_MODULE,
.read = mmapper_read,
.write = mmapper_write,
- .ioctl = mmapper_ioctl,
+ .unlocked_ioctl = mmapper_ioctl,
.mmap = mmapper_mmap,
.open = mmapper_open,
.release = mmapper_release,
--
1.6.3.3

2010-04-27 14:26:02

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 7/7] smbfs: push down BKL into ioctl function

Converting from ->ioctl to ->unlocked_ioctl with explicit
lock_kernel lets us kill the ioctl operation.

Signed-off-by: Arnd Bergmann <[email protected]>
---
fs/smbfs/dir.c | 2 +-
fs/smbfs/file.c | 2 +-
fs/smbfs/ioctl.c | 8 +++++---
fs/smbfs/proto.h | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 3e4803b..6c97842 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -39,7 +39,7 @@ const struct file_operations smb_dir_operations =
{
.read = generic_read_dir,
.readdir = smb_readdir,
- .ioctl = smb_ioctl,
+ .unlocked_ioctl = smb_ioctl,
.open = smb_dir_open,
};

diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index dbf6548..84ecf0e 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -437,7 +437,7 @@ const struct file_operations smb_file_operations =
.aio_read = smb_file_aio_read,
.write = do_sync_write,
.aio_write = smb_file_aio_write,
- .ioctl = smb_ioctl,
+ .unlocked_ioctl = smb_ioctl,
.mmap = smb_file_mmap,
.open = smb_file_open,
.release = smb_file_release,
diff --git a/fs/smbfs/ioctl.c b/fs/smbfs/ioctl.c
index 910215b..0721531 100644
--- a/fs/smbfs/ioctl.c
+++ b/fs/smbfs/ioctl.c
@@ -13,6 +13,7 @@
#include <linux/time.h>
#include <linux/mm.h>
#include <linux/highuid.h>
+#include <linux/smp_lock.h>
#include <linux/net.h>

#include <linux/smb_fs.h>
@@ -22,14 +23,14 @@

#include "proto.h"

-int
-smb_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+long
+smb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct smb_sb_info *server = server_from_inode(filp->f_path.dentry->d_inode);
struct smb_conn_opt opt;
int result = -EINVAL;

+ lock_kernel();
switch (cmd) {
uid16_t uid16;
uid_t uid32;
@@ -62,6 +63,7 @@ smb_ioctl(struct inode *inode, struct file *filp,
default:
break;
}
+ unlock_kernel();

return result;
}
diff --git a/fs/smbfs/proto.h b/fs/smbfs/proto.h
index 03f456c..05939a6 100644
--- a/fs/smbfs/proto.h
+++ b/fs/smbfs/proto.h
@@ -67,7 +67,7 @@ extern const struct address_space_operations smb_file_aops;
extern const struct file_operations smb_file_operations;
extern const struct inode_operations smb_file_inode_operations;
/* ioctl.c */
-extern int smb_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
+extern long smb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
/* smbiod.c */
extern void smbiod_wake_up(void);
extern int smbiod_register_server(struct smb_sb_info *server);
--
1.6.3.3

2010-04-27 14:25:13

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 6/7] coda/psdev: remove BKL from ioctl function

The ioctl function returns constant results, so it obviously
does not need the BKL and can be converted to unlocked_ioctl.

Signed-off-by: Arnd Bergmann <[email protected]>
---
fs/coda/psdev.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index be4392c..66b9cf7 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -73,8 +73,7 @@ static unsigned int coda_psdev_poll(struct file *file, poll_table * wait)
return mask;
}

-static int coda_psdev_ioctl(struct inode * inode, struct file * filp,
- unsigned int cmd, unsigned long arg)
+static long coda_psdev_ioctl(struct file * filp, unsigned int cmd, unsigned long arg)
{
unsigned int data;

@@ -344,7 +343,7 @@ static const struct file_operations coda_psdev_fops = {
.read = coda_psdev_read,
.write = coda_psdev_write,
.poll = coda_psdev_poll,
- .ioctl = coda_psdev_ioctl,
+ .unlocked_ioctl = coda_psdev_ioctl,
.open = coda_psdev_open,
.release = coda_psdev_release,
};
--
1.6.3.3

2010-04-27 14:25:17

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 3/7] 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 <[email protected]>
---
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

2010-04-27 14:33:15

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tuesday 27 April 2010, Arnd Bergmann wrote:
> diff --git a/fs/smbfs/ioctl.c b/fs/smbfs/ioctl.c
> index dbae1f8..910215b 100644
> --- a/fs/smbfs/ioctl.c
> +++ b/fs/smbfs/ioctl.c
> @@ -26,7 +26,7 @@ int
> smb_ioctl(struct inode *inode, struct file *filp,
> unsigned int cmd, unsigned long arg)
> {
> - struct smb_sb_info *server = server_from_inode(inode);
> + struct smb_sb_info *server = server_from_inode(filp->f_path.dentry->d_inode);
> struct smb_conn_opt opt;
> int result = -EINVAL;

This hunk obviously belongs to the smbfs patch, not the logfs patch. Sorry about that.

Arnd

2010-04-27 14:58:19

by Jörn Engel

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tue, 27 April 2010 16:24:19 +0200, Arnd Bergmann wrote:
>
> I'm sure that logfs doesn't rely on the BKL, but right now,
> we're just pushing it down.

So why do you create logfs_unlocked_ioctl in the first place? ;)

Jörn

--
Measure. Don't tune for speed until you've measured, and even then
don't unless one part of the code overwhelms the rest.
-- Rob Pike

2010-04-27 15:06:21

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tuesday 27 April 2010, Jörn Engel wrote:
> On Tue, 27 April 2010 16:24:19 +0200, Arnd Bergmann wrote:
> >
> > I'm sure that logfs doesn't rely on the BKL, but right now,
> > we're just pushing it down.
>
> So why do you create logfs_unlocked_ioctl in the first place? ;)

I don't want to get caught in discussions on whether any of my patches
might introduce silent bugs in something I'm not maintaining. Also
to put pressure on maintainers by threatening them to make their code
ugly.

If you just add a patch to convert to ->unlocked_ioctl without
the BKL, we can drop this patch ;-)

Arnd

2010-04-27 15:09:31

by Jörn Engel

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tue, 27 April 2010 17:05:50 +0200, Arnd Bergmann wrote:
> On Tuesday 27 April 2010, Jörn Engel wrote:
> > On Tue, 27 April 2010 16:24:19 +0200, Arnd Bergmann wrote:
> > >
> > > I'm sure that logfs doesn't rely on the BKL, but right now,
> > > we're just pushing it down.
> >
> > So why do you create logfs_unlocked_ioctl in the first place? ;)
>
> I don't want to get caught in discussions on whether any of my patches
> might introduce silent bugs in something I'm not maintaining. Also
> to put pressure on maintainers by threatening them to make their code
> ugly.
>
> If you just add a patch to convert to ->unlocked_ioctl without
> the BKL, we can drop this patch ;-)

I guess that's threatening enough. Is this for the next merge window or
still the current one?

Jörn

--
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein

2010-04-27 15:27:40

by John Kacur

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function



On Tue, 27 Apr 2010, Jörn Engel wrote:

> On Tue, 27 April 2010 17:05:50 +0200, Arnd Bergmann wrote:
> > On Tuesday 27 April 2010, Jörn Engel wrote:
> > > On Tue, 27 April 2010 16:24:19 +0200, Arnd Bergmann wrote:
> > > >
> > > > I'm sure that logfs doesn't rely on the BKL, but right now,
> > > > we're just pushing it down.
> > >
> > > So why do you create logfs_unlocked_ioctl in the first place? ;)
> >
> > I don't want to get caught in discussions on whether any of my patches
> > might introduce silent bugs in something I'm not maintaining. Also
> > to put pressure on maintainers by threatening them to make their code
> > ugly.
> >
> > If you just add a patch to convert to ->unlocked_ioctl without
> > the BKL, we can drop this patch ;-)
>
> I guess that's threatening enough. Is this for the next merge window or
> still the current one?
>

Hasn't the "current" merge window been over with for weeks? I was assuming
that bkl push down, or other bkl patches are for the next merge window.

You can ask Linus whether he'll take a convert unlocked_ioctl now or not.

John

2010-04-27 15:32:21

by Jörn Engel

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tue, 27 April 2010 17:27:19 +0200, John Kacur wrote:
>
> Hasn't the "current" merge window been over with for weeks? I was assuming
> that bkl push down, or other bkl patches are for the next merge window.

That's what I was thinking. But some of the bkl related discussion gave
me the impression that such patches were still being merged. So I
wanted to be sure.

Jörn

--
It is better to die of hunger having lived without grief and fear,
than to live with a troubled spirit amid abundance.
-- Epictetus

2010-04-27 15:37:36

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function



On Tue, 27 Apr 2010, John Kacur wrote:
>
> You can ask Linus whether he'll take a convert unlocked_ioctl now or not.

Absolutely not.

I could imagine merging something like just the bkl_ioctl rename: if it
breaks, it won't compile, so there is little risk, and _if_ it helps the
next merge window I could merge it early.

But it looks like people are trying to avoid it entirely, and there is not
a way in *hell* I will take some big and scary "push BKL down" patch that
is clearly _not_ 99% mechanical and clearly _can_ introduce major and
subtle bugs while compiling.

Linus

2010-04-27 15:39:58

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tuesday 27 April 2010, Jörn Engel wrote:
> On Tue, 27 April 2010 17:27:19 +0200, John Kacur wrote:
> >
> > Hasn't the "current" merge window been over with for weeks? I was assuming
> > that bkl push down, or other bkl patches are for the next merge window.
>
> That's what I was thinking. But some of the bkl related discussion gave
> me the impression that such patches were still being merged. So I
> wanted to be sure.

Yes, just queue it for the 2.6.35-rc1 window and make sure it shows up in
linux-next, or send a replacement patch with your Ack or S-o-b so we can
put it into the BKL queue.

Arnd

2010-04-27 16:29:11

by John Kacur

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function



On Tue, 27 Apr 2010, Linus Torvalds wrote:

>
>
> On Tue, 27 Apr 2010, John Kacur wrote:
> >
> > You can ask Linus whether he'll take a convert unlocked_ioctl now or not.
>
> Absolutely not.
>
> I could imagine merging something like just the bkl_ioctl rename: if it
> breaks, it won't compile, so there is little risk, and _if_ it helps the
> next merge window I could merge it early.
>
> But it looks like people are trying to avoid it entirely, and there is not
> a way in *hell* I will take some big and scary "push BKL down" patch that
> is clearly _not_ 99% mechanical and clearly _can_ introduce major and
> subtle bugs while compiling.
>

Heh, that's exactly what I thought you would say, but still good to
clarify it for everyone.

John

2010-04-27 17:22:43

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 3/7] cris: push down BKL into some device drivers

On Tue, Apr 27, 2010 at 04:24:21PM +0200, Arnd Bergmann wrote:
> 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 <[email protected]>


(Adding some more cris related Cc on this one)

2010-04-27 19:59:26

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tue, Apr 27, 2010 at 04:24:19PM +0200, Arnd Bergmann wrote:
> --- a/fs/smbfs/ioctl.c
> +++ b/fs/smbfs/ioctl.c
> @@ -26,7 +26,7 @@ int
> smb_ioctl(struct inode *inode, struct file *filp,
> unsigned int cmd, unsigned long arg)
> {
> - struct smb_sb_info *server = server_from_inode(inode);
> + struct smb_sb_info *server = server_from_inode(filp->f_path.dentry->d_inode);
> struct smb_conn_opt opt;
> int result = -EINVAL;


I've included this part in the smbfs pushdown patch.

Thanks.

2010-04-27 20:19:05

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 1/7] logfs: push down BKL into ioctl function

On Tue, Apr 27, 2010 at 05:38:50PM +0200, Arnd Bergmann wrote:
> On Tuesday 27 April 2010, J?rn Engel wrote:
> > On Tue, 27 April 2010 17:27:19 +0200, John Kacur wrote:
> > >
> > > Hasn't the "current" merge window been over with for weeks? I was assuming
> > > that bkl push down, or other bkl patches are for the next merge window.
> >
> > That's what I was thinking. But some of the bkl related discussion gave
> > me the impression that such patches were still being merged. So I
> > wanted to be sure.
>
> Yes, just queue it for the 2.6.35-rc1 window and make sure it shows up in
> linux-next, or send a replacement patch with your Ack or S-o-b so we can
> put it into the BKL queue.
>
> Arnd


I've applied this series in bkl/ioctl, it passed allyesconfig in sparc.
I will apply the others from you and John tomorrow or so (and will enjoy
my part as well). J?rn, please queue this patch if you want to, as you prefer,
we can host it as well if necessary.

Linus I hope you don't mind but I've dropped the .bkl_ioctl renaming.
In fact it had conflicts with several trees in Linux-next and now that
we are about to pushdown in every ioctl users, this would be an
unnecessary step I think.

Thanks.

2010-04-27 20:30:38

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] logfs: kill BKL

logfs does not need the BKL, so use ->unlocked_ioctl instead
of ->ioctl in file operations.
---
On Tuesday 27 April 2010 22:12:52 Frederic Weisbecker wrote:
>
> I've applied this series in bkl/ioctl, it passed allyesconfig in sparc.
> I will apply the others from you and John tomorrow or so (and will enjoy
> my part as well). J?rn, please queue this patch if you want to, as you prefer,
> we can host it as well if necessary.

I believe that this is the one that J?rn would prefer to go in. I hope I
got it right by editing the patch.

diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 2396a85..a801b5e 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -821,7 +821,7 @@ const struct inode_operations logfs_dir_iops = {
};
const struct file_operations logfs_dir_fops = {
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .unlocked_ioctl = logfs_ioctl,
.readdir = logfs_readdir,
.read = generic_read_dir,
};
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 370f367..1dbc342 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -171,9 +172,9 @@ static int logfs_releasepage(struct page *page, gfp_t only_xfs_uses_this)
}


-int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
+long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
+ struct inode *inode = file->f_path.dentry->d_inode;
struct logfs_inode *li = logfs_inode(inode);
unsigned int oldflags, flags;
int err;
@@ -243,7 +255,7 @@ const struct file_operations logfs_reg_fops = {
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .unlocked_ioctl = logfs_ioctl,
.llseek = generic_file_llseek,
.mmap = generic_file_readonly_mmap,
.open = generic_file_open,
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 0a3df1a..8432c51 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -501,8 +501,8 @@ extern const struct inode_operations logfs_reg_iops;
extern const struct file_operations logfs_reg_fops;
extern const struct address_space_operations logfs_reg_aops;
int logfs_readpage(struct file *file, struct page *page);
-int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg);
+long logfs_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg);
int logfs_fsync(struct file *file, struct dentry *dentry, int datasync);

/* gc.c */

2010-04-28 14:47:06

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

Laurent Pinchart wrote:
> Hi Hans,
>
> On Wednesday 28 April 2010 14:37:10 Hans Verkuil wrote:
>>> Arnd Bergmann wrote:
>
> [snip]
>
>>>> Mauro, does this patch make sense to you? It would be good to have your
>>>> Ack so we can queue this in the series leading to the removal of the
>>>> ->ioctl file operation. We can also do the minimal change and let you
>>>> take care of fixing this up in a different way in your own tree.
>>> We had a similar discussion a while ago at linux-media. The idea is to do
>>> it on a deeper level, changing the drivers to not need to use KBL.
>>> Hans is working on those patches. Not sure about the current status.
>> I'm waiting for the event patch series from Sakari to go in before I can
>> continue working on this.
>>
>>> Anyway, I think that the better is to apply first your patch, to avoid
>>> breaking your patch series, and then ours, as we may otherwise have some
>>> conflicts between your tree and drivers/media git tree.
>> I have no real problem with this patch, as long as people realize that
>> this only moves the BKL from one place to another and does not really fix
>> any drivers.
>
> Seems that Arnd was more convincing than me. I've submitted the exact same
> patch a while ago :-)

Same patch, different situation ;)

> Of course this doesn't solve the BKL issue, but it pushes it one level down,
> closer to the drivers. Higher levels can then stop caring about it. Of course
> lower levels will still need to remove the BKL.

Yes. This patch doesn't change anything in practice, but it allows RT people
to keep working on their series of changes, giving us a little more time to
work on a definitive solution. If nacked, we would need to send an alternative
patch for them, and, as this is not ready (and such patch applied via RT tree would
likely cause merge conflicts with our patches), the better is to just ack and keep
writing the patch that will solve the issue.

Your patch were very useful, as it started the discussions for the BKL removal
on drivers/media drivers.

--

Cheers,
Mauro

2010-04-28 14:56:28

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.



On Tue, 27 Apr 2010, Arnd Bergmann wrote:
> +static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> struct video_device *vdev = video_devdata(filp);
> + int ret;
>
> /* Allow ioctl to continue even if the device was unregistered.
> Things like dequeueing buffers might still be useful. */
> + if (vdev->fops->unlocked_ioctl) {
> + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> + } else if (vdev->fops->ioctl) {
> + /* TODO: convert all drivers to unlocked_ioctl */
> + lock_kernel();
> + ret = vdev->fops->ioctl(filp, cmd, arg);
> + unlock_kernel();
> + } else
> + ret = -ENOTTY;
>
> + return ret;

[ Removed the '-' lines so you can see what the end result ends up being ]

Please, if you do this for the V4L2 layer, then DO NOT make the same
mistake we did with the vasic VFS layer.

In other words, DO NOT keep the "bkl" version named just "ioctl". It was a
horrible horrible mistake, and it has resulted in problems years
afterwards.

I realize that it's so easy to just add a new ".unlocked_ioctl" member,
and then as people start using it, they get rid of the BKL. But it's a
mistake. It was a mistake for the VFS layer, it would be a mistake for the
V4L2 layer.

Instead, spend the 15 minutes just renaming every current 'ioctl' user in
the V4L2 layer. It's not that much work, the scripts I documented in my
renaming patch do 95% of the work (you just need to change
"file_operations" to "v4l2_file_operations"). It's not that painful. And
then you don't just push the BKL down, you actually annotate the remaining
users so that they can be grepped for.

So please please please, don't make the same mistake we did long ago.

Linus

2010-04-28 12:45:49

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.


> Hi Arnd,
>
> Arnd Bergmann wrote:
>> On Tuesday 27 April 2010, John Kacur wrote:
>>> Well it is certainly possible that my fixup is not correct too - your
>>> patch cannot be correct, because it doesn't compile! Here is what I get
>>> when I apply your patch to a recent linus/master
>>
>> Ah, I see.
>>
>>> make O=/bld/arnd/ drivers/media/video/v4l2-dev.o
>>> -----CUT A BUNCH OF STUFF OUT ---
>>> CC drivers/media/video/v4l2-dev.o
>>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c: In function
>>> ‘v4l2_ioctl’:
>>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning:
>>> passing
>>> argument 1 of ‘vdev->fops->ioctl’ from incompatible pointer type
>>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected
>>> ‘struct file *’ but argument is of type ‘struct inode *’
>>
>> I didn't realize that the prototype for the locked ->ioctl function in
>> v4l2 does not take the inode argument, so that needs to be dropped from
>> my patch (i.e. not added).
>>
>> Or we do it slightly better and clean up the code a bit in the process.
>>
>> Mauro, does this patch make sense to you? It would be good to have your
>> Ack so we can queue this in the series leading to the removal of the
>> ->ioctl file operation. We can also do the minimal change and let you
>> take care of fixing this up in a different way in your own tree.
>
> We had a similar discussion a while ago at linux-media. The idea is to do
> it on a deeper level, changing the drivers to not need to use KBL.
> Hans is working on those patches. Not sure about the current status.

I'm waiting for the event patch series from Sakari to go in before I can
continue working on this.

> Anyway, I think that the better is to apply first your patch, to avoid
> breaking your patch series, and then ours, as we may otherwise have some
> conflicts between your tree and drivers/media git tree.

I have no real problem with this patch, as long as people realize that
this only moves the BKL from one place to another and does not really fix
any drivers.

Acked-by: Hans Verkuil <[email protected]>

Regards,

Hans

>
> So,
>
> Acked-by: Mauro Carvalho Chehab <[email protected]>
>
>>
>> ---
>> Subject: v4l: convert v4l2-dev to unlocked_ioctl
>>
>> v4l2 implements two separate file operations for drivers that use locked
>> and unlocked ioctl callbacks. Since we want to remove the ioctl file
>> operation
>> in favor of the unlocked variant, this separation no longer seems
>> helpful.
>>
>> Unfortunately, there are still 77 drivers with locked ioctl functions in
>> their v4l2_file_operations, which need to be taken care of separately.
>>
>> Signed-off-by: Arnd Bergmann <[email protected]>
>> ---
>> drivers/media/video/v4l2-dev.c | 52
>> +++++++++++----------------------------
>> 1 files changed, 15 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/media/video/v4l2-dev.c
>> b/drivers/media/video/v4l2-dev.c
>> index 7090699..ab198ba 100644
>> --- a/drivers/media/video/v4l2-dev.c
>> +++ b/drivers/media/video/v4l2-dev.c
>> @@ -25,6 +25,7 @@
>> #include <linux/init.h>
>> #include <linux/kmod.h>
>> #include <linux/slab.h>
>> +#include <linux/smp_lock.h>
>> #include <asm/uaccess.h>
>> #include <asm/system.h>
>>
>> @@ -215,28 +216,24 @@ static unsigned int v4l2_poll(struct file *filp,
>> struct poll_table_struct *poll)
>> return vdev->fops->poll(filp, poll);
>> }
>>
>> -static int v4l2_ioctl(struct inode *inode, struct file *filp,
>> - unsigned int cmd, unsigned long arg)
>> +static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned
>> long arg)
>> {
>> struct video_device *vdev = video_devdata(filp);
>> + int ret;
>>
>> - if (!vdev->fops->ioctl)
>> - return -ENOTTY;
>> /* Allow ioctl to continue even if the device was unregistered.
>> Things like dequeueing buffers might still be useful. */
>> - return vdev->fops->ioctl(filp, cmd, arg);
>> -}
>> -
>> -static long v4l2_unlocked_ioctl(struct file *filp,
>> - unsigned int cmd, unsigned long arg)
>> -{
>> - struct video_device *vdev = video_devdata(filp);
>> + if (vdev->fops->unlocked_ioctl) {
>> + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
>> + } else if (vdev->fops->ioctl) {
>> + /* TODO: convert all drivers to unlocked_ioctl */
>> + lock_kernel();
>> + ret = vdev->fops->ioctl(filp, cmd, arg);
>> + unlock_kernel();
>> + } else
>> + ret = -ENOTTY;
>>
>> - if (!vdev->fops->unlocked_ioctl)
>> - return -ENOTTY;
>> - /* Allow ioctl to continue even if the device was unregistered.
>> - Things like dequeueing buffers might still be useful. */
>> - return vdev->fops->unlocked_ioctl(filp, cmd, arg);
>> + return ret;
>> }
>>
>> #ifdef CONFIG_MMU
>> @@ -307,22 +304,6 @@ static int v4l2_release(struct inode *inode, struct
>> file *filp)
>> return ret;
>> }
>>
>> -static const struct file_operations v4l2_unlocked_fops = {
>> - .owner = THIS_MODULE,
>> - .read = v4l2_read,
>> - .write = v4l2_write,
>> - .open = v4l2_open,
>> - .get_unmapped_area = v4l2_get_unmapped_area,
>> - .mmap = v4l2_mmap,
>> - .unlocked_ioctl = v4l2_unlocked_ioctl,
>> -#ifdef CONFIG_COMPAT
>> - .compat_ioctl = v4l2_compat_ioctl32,
>> -#endif
>> - .release = v4l2_release,
>> - .poll = v4l2_poll,
>> - .llseek = no_llseek,
>> -};
>> -
>> static const struct file_operations v4l2_fops = {
>> .owner = THIS_MODULE,
>> .read = v4l2_read,
>> @@ -330,7 +311,7 @@ static const struct file_operations v4l2_fops = {
>> .open = v4l2_open,
>> .get_unmapped_area = v4l2_get_unmapped_area,
>> .mmap = v4l2_mmap,
>> - .ioctl = v4l2_ioctl,
>> + .unlocked_ioctl = v4l2_ioctl,
>> #ifdef CONFIG_COMPAT
>> .compat_ioctl = v4l2_compat_ioctl32,
>> #endif
>> @@ -517,10 +498,7 @@ static int __video_register_device(struct
>> video_device *vdev, int type, int nr,
>> ret = -ENOMEM;
>> goto cleanup;
>> }
>> - if (vdev->fops->unlocked_ioctl)
>> - vdev->cdev->ops = &v4l2_unlocked_fops;
>> - else
>> - vdev->cdev->ops = &v4l2_fops;
>> + vdev->cdev->ops = &v4l2_fops;
>> vdev->cdev->owner = vdev->fops->owner;
>> ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
>> if (ret < 0) {
>
>
> --
>
> Cheers,
> Mauro
>


--
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco

2010-04-28 12:24:51

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

Hi Arnd,

Arnd Bergmann wrote:
> On Tuesday 27 April 2010, John Kacur wrote:
>> Well it is certainly possible that my fixup is not correct too - your
>> patch cannot be correct, because it doesn't compile! Here is what I get
>> when I apply your patch to a recent linus/master
>
> Ah, I see.
>
>> make O=/bld/arnd/ drivers/media/video/v4l2-dev.o
>> -----CUT A BUNCH OF STUFF OUT ---
>> CC drivers/media/video/v4l2-dev.o
>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c: In function
>> ‘v4l2_ioctl’:
>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning: passing
>> argument 1 of ‘vdev->fops->ioctl’ from incompatible pointer type
>> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected
>> ‘struct file *’ but argument is of type ‘struct inode *’
>
> I didn't realize that the prototype for the locked ->ioctl function in
> v4l2 does not take the inode argument, so that needs to be dropped from
> my patch (i.e. not added).
>
> Or we do it slightly better and clean up the code a bit in the process.
>
> Mauro, does this patch make sense to you? It would be good to have your
> Ack so we can queue this in the series leading to the removal of the
> ->ioctl file operation. We can also do the minimal change and let you
> take care of fixing this up in a different way in your own tree.

We had a similar discussion a while ago at linux-media. The idea is to do
it on a deeper level, changing the drivers to not need to use KBL.
Hans is working on those patches. Not sure about the current status.

Anyway, I think that the better is to apply first your patch, to avoid
breaking your patch series, and then ours, as we may otherwise have some
conflicts between your tree and drivers/media git tree.

So,

Acked-by: Mauro Carvalho Chehab <[email protected]>

>
> ---
> Subject: v4l: convert v4l2-dev to unlocked_ioctl
>
> v4l2 implements two separate file operations for drivers that use locked
> and unlocked ioctl callbacks. Since we want to remove the ioctl file operation
> in favor of the unlocked variant, this separation no longer seems helpful.
>
> Unfortunately, there are still 77 drivers with locked ioctl functions in
> their v4l2_file_operations, which need to be taken care of separately.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> drivers/media/video/v4l2-dev.c | 52 +++++++++++----------------------------
> 1 files changed, 15 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index 7090699..ab198ba 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -25,6 +25,7 @@
> #include <linux/init.h>
> #include <linux/kmod.h>
> #include <linux/slab.h>
> +#include <linux/smp_lock.h>
> #include <asm/uaccess.h>
> #include <asm/system.h>
>
> @@ -215,28 +216,24 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
> return vdev->fops->poll(filp, poll);
> }
>
> -static int v4l2_ioctl(struct inode *inode, struct file *filp,
> - unsigned int cmd, unsigned long arg)
> +static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> struct video_device *vdev = video_devdata(filp);
> + int ret;
>
> - if (!vdev->fops->ioctl)
> - return -ENOTTY;
> /* Allow ioctl to continue even if the device was unregistered.
> Things like dequeueing buffers might still be useful. */
> - return vdev->fops->ioctl(filp, cmd, arg);
> -}
> -
> -static long v4l2_unlocked_ioctl(struct file *filp,
> - unsigned int cmd, unsigned long arg)
> -{
> - struct video_device *vdev = video_devdata(filp);
> + if (vdev->fops->unlocked_ioctl) {
> + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> + } else if (vdev->fops->ioctl) {
> + /* TODO: convert all drivers to unlocked_ioctl */
> + lock_kernel();
> + ret = vdev->fops->ioctl(filp, cmd, arg);
> + unlock_kernel();
> + } else
> + ret = -ENOTTY;
>
> - if (!vdev->fops->unlocked_ioctl)
> - return -ENOTTY;
> - /* Allow ioctl to continue even if the device was unregistered.
> - Things like dequeueing buffers might still be useful. */
> - return vdev->fops->unlocked_ioctl(filp, cmd, arg);
> + return ret;
> }
>
> #ifdef CONFIG_MMU
> @@ -307,22 +304,6 @@ static int v4l2_release(struct inode *inode, struct file *filp)
> return ret;
> }
>
> -static const struct file_operations v4l2_unlocked_fops = {
> - .owner = THIS_MODULE,
> - .read = v4l2_read,
> - .write = v4l2_write,
> - .open = v4l2_open,
> - .get_unmapped_area = v4l2_get_unmapped_area,
> - .mmap = v4l2_mmap,
> - .unlocked_ioctl = v4l2_unlocked_ioctl,
> -#ifdef CONFIG_COMPAT
> - .compat_ioctl = v4l2_compat_ioctl32,
> -#endif
> - .release = v4l2_release,
> - .poll = v4l2_poll,
> - .llseek = no_llseek,
> -};
> -
> static const struct file_operations v4l2_fops = {
> .owner = THIS_MODULE,
> .read = v4l2_read,
> @@ -330,7 +311,7 @@ static const struct file_operations v4l2_fops = {
> .open = v4l2_open,
> .get_unmapped_area = v4l2_get_unmapped_area,
> .mmap = v4l2_mmap,
> - .ioctl = v4l2_ioctl,
> + .unlocked_ioctl = v4l2_ioctl,
> #ifdef CONFIG_COMPAT
> .compat_ioctl = v4l2_compat_ioctl32,
> #endif
> @@ -517,10 +498,7 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
> ret = -ENOMEM;
> goto cleanup;
> }
> - if (vdev->fops->unlocked_ioctl)
> - vdev->cdev->ops = &v4l2_unlocked_fops;
> - else
> - vdev->cdev->ops = &v4l2_fops;
> + vdev->cdev->ops = &v4l2_fops;
> vdev->cdev->owner = vdev->fops->owner;
> ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
> if (ret < 0) {


--

Cheers,
Mauro

2010-04-28 13:02:37

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

Hi Hans,

On Wednesday 28 April 2010 14:37:10 Hans Verkuil wrote:
> > Arnd Bergmann wrote:

[snip]

> >> Mauro, does this patch make sense to you? It would be good to have your
> >> Ack so we can queue this in the series leading to the removal of the
> >> ->ioctl file operation. We can also do the minimal change and let you
> >> take care of fixing this up in a different way in your own tree.
> >
> > We had a similar discussion a while ago at linux-media. The idea is to do
> > it on a deeper level, changing the drivers to not need to use KBL.
> > Hans is working on those patches. Not sure about the current status.
>
> I'm waiting for the event patch series from Sakari to go in before I can
> continue working on this.
>
> > Anyway, I think that the better is to apply first your patch, to avoid
> > breaking your patch series, and then ours, as we may otherwise have some
> > conflicts between your tree and drivers/media git tree.
>
> I have no real problem with this patch, as long as people realize that
> this only moves the BKL from one place to another and does not really fix
> any drivers.

Seems that Arnd was more convincing than me. I've submitted the exact same
patch a while ago :-)

Of course this doesn't solve the BKL issue, but it pushes it one level down,
closer to the drivers. Higher levels can then stop caring about it. Of course
lower levels will still need to remove the BKL.

--
Regards,

Laurent Pinchart

2010-04-28 21:18:58

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes

On Tue, Apr 27, 2010 at 11:18:08AM +0200, John Kacur wrote:
> These are bkl pushdowns from Arnd that conflicted with
> Linus's "Preparation for BKL'ed ioctl removal patch". I fixed-up the merge
> conflicts. In addition - during allyesconfig compile testing on x86_64 I found
> a number of issues that I fixed-up
>
> I pushed these to my own new linus-bkl tree.
> git://http://www.kernel.org/pub/scm/linux/kernel/git/jkacur/jk-2.6.git linux-bkl
>
> Frederic, if you want to grab those, pls do so. also, we might want to combine
> my compile fixes with Arnd's push-down patches, for better git bisectability.
>
> Presented separately here for everyone's easy perusal.
>
> Arnd Bergmann (6):
> dvb: push down BKL into ioctl functions
> scsi: push down BKL into ioctl functions
> isdn: push down BKL into ioctl functions
> staging: push down BKL into ioctl functions
> v4l: always use unlocked_ioctl
> drivers: push down BKL into various drivers
>
> John Kacur (4):
> bkl: Fix up compile problems in megaraid from bkl push-down
> bkl: Fix missing inode tw_chrdev_ioctl due to bkl pushdown
> bkl: Fix missing inode in twl_chrdev_ioctl resulting from bkl
> pushdown
> bkl: Fix-up compile problems as a result of the bkl-pushdown.


Applied the series in bkl/ioctl, except the staging part that went
to Greg's tree and the v4l part for which Linus had concerns.

I haven't pushed your fixes separately but merged them into
the concerned arnd's patches with your SOB added.

It passed allyesconfig in sparc.

Thanks.

2010-04-28 21:52:19

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.

On Wed, Apr 28, 2010 at 07:55:02AM -0700, Linus Torvalds wrote:
>
>
> On Tue, 27 Apr 2010, Arnd Bergmann wrote:
> > +static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> > {
> > struct video_device *vdev = video_devdata(filp);
> > + int ret;
> >
> > /* Allow ioctl to continue even if the device was unregistered.
> > Things like dequeueing buffers might still be useful. */
> > + if (vdev->fops->unlocked_ioctl) {
> > + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> > + } else if (vdev->fops->ioctl) {
> > + /* TODO: convert all drivers to unlocked_ioctl */
> > + lock_kernel();
> > + ret = vdev->fops->ioctl(filp, cmd, arg);
> > + unlock_kernel();
> > + } else
> > + ret = -ENOTTY;
> >
> > + return ret;
>
> [ Removed the '-' lines so you can see what the end result ends up being ]
>
> Please, if you do this for the V4L2 layer, then DO NOT make the same
> mistake we did with the vasic VFS layer.
>
> In other words, DO NOT keep the "bkl" version named just "ioctl". It was a
> horrible horrible mistake, and it has resulted in problems years
> afterwards.
>
> I realize that it's so easy to just add a new ".unlocked_ioctl" member,
> and then as people start using it, they get rid of the BKL. But it's a
> mistake. It was a mistake for the VFS layer, it would be a mistake for the
> V4L2 layer.
>
> Instead, spend the 15 minutes just renaming every current 'ioctl' user in
> the V4L2 layer. It's not that much work, the scripts I documented in my
> renaming patch do 95% of the work (you just need to change
> "file_operations" to "v4l2_file_operations"). It's not that painful. And
> then you don't just push the BKL down, you actually annotate the remaining
> users so that they can be grepped for.
>
> So please please please, don't make the same mistake we did long ago.
>
> Linus


Hmm, there are 92 struct v4l2_file_operations::ioctl but actually a lot
of duplicates ioctl. In fact there are just 26 ioctl functions.

It's probably worth the whole pushdown instead of the rename.

I'm going to do this.

2010-04-29 03:42:50

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 1/5] v4l: Pushdown bkl into video_ioctl2

video_ioctl2 is a generic ioctl helper used by a lot of drivers.
Most of them put it as their bkl'ed .ioctl callback, then let's
pushdown the bkl inside but also provide an unlocked version for
those that use it as an unlocked ioctl.

Signed-off-by: Frederic Weisbecker <[email protected]>
---
drivers/media/video/v4l2-ioctl.c | 17 +++++++++++++++--
include/media/v4l2-ioctl.h | 2 ++
2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 3da8d8f..0ff2595 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/smp_lock.h>

#define __OLD_VIDIOC_ /* To allow fixing old calls */
#include <linux/videodev.h>
@@ -2007,8 +2008,8 @@ static unsigned long cmd_input_size(unsigned int cmd)
}
}

-long video_ioctl2(struct file *file,
- unsigned int cmd, unsigned long arg)
+long video_ioctl2_unlocked(struct file *file,
+ unsigned int cmd, unsigned long arg)
{
char sbuf[128];
void *mbuf = NULL;
@@ -2102,4 +2103,16 @@ out:
kfree(mbuf);
return err;
}
+EXPORT_SYMBOL(video_ioctl2_unlocked);
+
+long video_ioctl2(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = video_ioctl2_unlocked(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
EXPORT_SYMBOL(video_ioctl2);
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e8ba0f2..08b3e42 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -316,5 +316,7 @@ extern long video_usercopy(struct file *file, unsigned int cmd,
/* Standard handlers for V4L ioctl's */
extern long video_ioctl2(struct file *file,
unsigned int cmd, unsigned long arg);
+extern long video_ioctl2_unlocked(struct file *file,
+ unsigned int cmd, unsigned long arg);

#endif /* _V4L2_IOCTL_H */
--
1.6.2.3

2010-04-29 03:42:55

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 3/5] v4l: Change users of video_ioctl2 to use unlocked_ioctl

Now that video_ioctl2() got the bkl pushed down, update its users
to use .unlocked_ioctl instead of ioctl.

Signed-off-by: Frederic Weisbecker <[email protected]>
---
drivers/media/common/saa7146_fops.c | 2 +-
drivers/media/radio/dsbr100.c | 2 +-
drivers/media/radio/radio-aimslab.c | 2 +-
drivers/media/radio/radio-aztech.c | 2 +-
drivers/media/radio/radio-cadet.c | 2 +-
drivers/media/radio/radio-gemtek-pci.c | 2 +-
drivers/media/radio/radio-gemtek.c | 2 +-
drivers/media/radio/radio-maestro.c | 2 +-
drivers/media/radio/radio-maxiradio.c | 2 +-
drivers/media/radio/radio-miropcm20.c | 2 +-
drivers/media/radio/radio-mr800.c | 2 +-
drivers/media/radio/radio-rtrack2.c | 2 +-
drivers/media/radio/radio-sf16fmi.c | 2 +-
drivers/media/radio/radio-sf16fmr2.c | 2 +-
drivers/media/radio/radio-si4713.c | 2 +-
drivers/media/radio/radio-tea5764.c | 2 +-
drivers/media/radio/radio-terratec.c | 2 +-
drivers/media/radio/radio-timb.c | 2 +-
drivers/media/radio/radio-trust.c | 2 +-
drivers/media/radio/radio-typhoon.c | 2 +-
drivers/media/radio/radio-zoltrix.c | 2 +-
drivers/media/radio/si470x/radio-si470x-common.c | 2 +-
drivers/media/video/arv.c | 2 +-
drivers/media/video/au0828/au0828-video.c | 14 ++++++------
drivers/media/video/bt8xx/bttv-driver.c | 26 +++++++++++-----------
drivers/media/video/cafe_ccic.c | 14 ++++++------
drivers/media/video/cx18/cx18-streams.c | 12 +++++-----
drivers/media/video/cx231xx/cx231xx-video.c | 4 +-
drivers/media/video/cx23885/cx23885-417.c | 2 +-
drivers/media/video/cx23885/cx23885-video.c | 4 +-
drivers/media/video/cx88/cx88-blackbird.c | 2 +-
drivers/media/video/cx88/cx88-video.c | 4 +-
drivers/media/video/davinci/vpif_capture.c | 2 +-
drivers/media/video/davinci/vpif_display.c | 2 +-
drivers/media/video/em28xx/em28xx-video.c | 4 +-
drivers/media/video/meye.c | 2 +-
drivers/media/video/omap24xxcam.c | 10 ++++----
drivers/media/video/pms.c | 2 +-
drivers/media/video/s2255drv.c | 12 +++++-----
drivers/media/video/saa7134/saa7134-empress.c | 14 ++++++------
drivers/media/video/saa7134/saa7134-video.c | 26 +++++++++++-----------
drivers/media/video/soc_camera.c | 2 +-
drivers/media/video/stk-webcam.c | 14 ++++++------
drivers/media/video/tlg2300/pd-radio.c | 8 +++---
drivers/media/video/tlg2300/pd-video.c | 2 +-
drivers/media/video/usbvision/usbvision-video.c | 4 +-
drivers/media/video/w9966.c | 2 +-
drivers/media/video/zoran/zoran_driver.c | 16 ++++++------
drivers/media/video/zr364xx.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video0.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video1.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video2.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video3.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video4.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video5.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video6.c | 14 ++++++------
drivers/staging/cx25821/cx25821-video7.c | 14 ++++++------
drivers/staging/go7007/go7007-v4l2.c | 2 +-
drivers/staging/tm6000/tm6000-video.c | 2 +-
sound/i2c/other/tea575x-tuner.c | 2 +-
60 files changed, 191 insertions(+), 191 deletions(-)

diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index fd8e1f4..2e76112 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -396,7 +396,7 @@ static const struct v4l2_file_operations video_fops =
.write = fops_write,
.poll = fops_poll,
.mmap = fops_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static void vv_callback(struct saa7146_dev *dev, unsigned long status)
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index ed9cd7a..c3e952f 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -605,7 +605,7 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev)
/* File system interface */
static const struct v4l2_file_operations usb_dsbr100_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = {
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 5bf4985..39a647e 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -361,7 +361,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations rtrack_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index c223113..53d48bb 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -324,7 +324,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

static const struct v4l2_file_operations aztech_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 482d0f3..bf1656e 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -558,7 +558,7 @@ static const struct v4l2_file_operations cadet_fops = {
.open = cadet_open,
.release = cadet_release,
.read = cadet_read,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.poll = cadet_poll,
};

diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 7903967..7ab33e0 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(pci, gemtek_pci_id);

static const struct v4l2_file_operations gemtek_pci_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 73985f6..43d5466 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -378,7 +378,7 @@ static int gemtek_probe(struct gemtek *gt)

static const struct v4l2_file_operations gemtek_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static int vidioc_querycap(struct file *file, void *priv,
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 08f1051..0ad65ef 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -299,7 +299,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations maestro_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops maestro_ioctl_ops = {
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 4349213..2975f1c 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -346,7 +346,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

static const struct v4l2_file_operations maxiradio_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c
index 4ff8854..df4869f 100644
--- a/drivers/media/radio/radio-miropcm20.c
+++ b/drivers/media/radio/radio-miropcm20.c
@@ -72,7 +72,7 @@ static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq)

static const struct v4l2_file_operations pcm20_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static int vidioc_querycap(struct file *file, void *priv,
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 02a9cef..8de8b2f 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -613,7 +613,7 @@ static const struct v4l2_file_operations usb_amradio_fops = {
.owner = THIS_MODULE,
.open = usb_amradio_open,
.release = usb_amradio_close,
- .ioctl = usb_amradio_ioctl,
+ .unlocked_ioctl = usb_amradio_ioctl,
};

static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = {
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index a79296a..12f4c1a 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -266,7 +266,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations rtrack2_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 985359d..c3d1415 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -260,7 +260,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations fmi_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 52c7bbb..5a63e5c 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -376,7 +376,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations fmr2_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 13554ab..9b6264d 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -53,7 +53,7 @@ struct radio_si4713_device {
/* radio_si4713_fops - file operations interface */
static const struct v4l2_file_operations radio_si4713_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

/* Video4Linux Interface */
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 789d2ec..9d24996 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -492,7 +492,7 @@ static const struct v4l2_file_operations tea5764_fops = {
.owner = THIS_MODULE,
.open = tea5764_open,
.release = tea5764_close,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index fc1c860..e9f89e5 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -338,7 +338,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations terratec_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index b8bb3ef..083609d 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -142,7 +142,7 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = {

static const struct v4l2_file_operations timbradio_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static int __devinit timbradio_probe(struct platform_device *pdev)
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 9d6dcf8..c5813ff 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -344,7 +344,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations trust_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops trust_ioctl_ops = {
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 0343928..6c0431d 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -320,7 +320,7 @@ static int vidioc_log_status(struct file *file, void *priv)

static const struct v4l2_file_operations typhoon_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index f31eab9..72e4ecf 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -377,7 +377,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
static const struct v4l2_file_operations zoltrix_fops =
{
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = {
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index 47075fc..293f30a 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -516,7 +516,7 @@ static const struct v4l2_file_operations si470x_fops = {
.owner = THIS_MODULE,
.read = si470x_fops_read,
.poll = si470x_fops_poll,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.open = si470x_fops_open,
.release = si470x_fops_release,
};
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 31e7a12..f989f28 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -712,7 +712,7 @@ static int ar_initialize(struct ar *ar)
static const struct v4l2_file_operations ar_fops = {
.owner = THIS_MODULE,
.read = ar_read,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops ar_ioctl_ops = {
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
index 6615021..206b31b 100644
--- a/drivers/media/video/au0828/au0828-video.c
+++ b/drivers/media/video/au0828/au0828-video.c
@@ -1512,13 +1512,13 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
#endif

static struct v4l2_file_operations au0828_v4l_fops = {
- .owner = THIS_MODULE,
- .open = au0828_v4l2_open,
- .release = au0828_v4l2_close,
- .read = au0828_v4l2_read,
- .poll = au0828_v4l2_poll,
- .mmap = au0828_v4l2_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = au0828_v4l2_open,
+ .release = au0828_v4l2_close,
+ .read = au0828_v4l2_read,
+ .poll = au0828_v4l2_poll,
+ .mmap = au0828_v4l2_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 350e7af..a40f76b 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -3338,13 +3338,13 @@ bttv_mmap(struct file *file, struct vm_area_struct *vma)

static const struct v4l2_file_operations bttv_fops =
{
- .owner = THIS_MODULE,
- .open = bttv_open,
- .release = bttv_release,
- .ioctl = video_ioctl2,
- .read = bttv_read,
- .mmap = bttv_mmap,
- .poll = bttv_poll,
+ .owner = THIS_MODULE,
+ .open = bttv_open,
+ .release = bttv_release,
+ .unlocked_ioctl = video_ioctl2,
+ .read = bttv_read,
+ .mmap = bttv_mmap,
+ .poll = bttv_poll,
};

static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
@@ -3611,12 +3611,12 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)

static const struct v4l2_file_operations radio_fops =
{
- .owner = THIS_MODULE,
- .open = radio_open,
- .read = radio_read,
- .release = radio_release,
- .ioctl = video_ioctl2,
- .poll = radio_poll,
+ .owner = THIS_MODULE,
+ .open = radio_open,
+ .read = radio_read,
+ .release = radio_release,
+ .unlocked_ioctl = video_ioctl2,
+ .poll = radio_poll,
};

static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index be35e69..8182477 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -1685,13 +1685,13 @@ static int cafe_vidioc_s_register(struct file *file, void *priv,
*/

static const struct v4l2_file_operations cafe_v4l_fops = {
- .owner = THIS_MODULE,
- .open = cafe_v4l_open,
- .release = cafe_v4l_release,
- .read = cafe_v4l_read,
- .poll = cafe_v4l_poll,
- .mmap = cafe_v4l_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = cafe_v4l_open,
+ .release = cafe_v4l_release,
+ .read = cafe_v4l_read,
+ .poll = cafe_v4l_poll,
+ .mmap = cafe_v4l_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 054450f..85e4b73 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -37,13 +37,13 @@
#define CX18_DSP0_INTERRUPT_MASK 0xd0004C

static struct v4l2_file_operations cx18_v4l2_enc_fops = {
- .owner = THIS_MODULE,
- .read = cx18_v4l2_read,
- .open = cx18_v4l2_open,
+ .owner = THIS_MODULE,
+ .read = cx18_v4l2_read,
+ .open = cx18_v4l2_open,
/* FIXME change to video_ioctl2 if serialization lock can be removed */
- .ioctl = cx18_v4l2_ioctl,
- .release = cx18_v4l2_close,
- .poll = cx18_v4l2_enc_poll,
+ .unlocked_ioctl = cx18_v4l2_ioctl,
+ .release = cx18_v4l2_close,
+ .poll = cx18_v4l2_enc_poll,
};

/* offset from 0 to register ts v4l2 minors on */
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 597c416..148e17a 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -2231,7 +2231,7 @@ static const struct v4l2_file_operations cx231xx_v4l_fops = {
.read = cx231xx_v4l2_read,
.poll = cx231xx_v4l2_poll,
.mmap = cx231xx_v4l2_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -2289,7 +2289,7 @@ static const struct v4l2_file_operations radio_fops = {
.owner = THIS_MODULE,
.open = cx231xx_v4l2_open,
.release = cx231xx_v4l2_close,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index abd64e8..568f4d6 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1681,7 +1681,7 @@ static struct v4l2_file_operations mpeg_fops = {
.read = mpeg_read,
.poll = mpeg_poll,
.mmap = mpeg_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 543b854..e3bed13 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -1387,7 +1387,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -1439,7 +1439,7 @@ static const struct v4l2_file_operations radio_fops = {
.owner = THIS_MODULE,
.open = video_open,
.release = video_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};


diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index e46e1ce..ca63ce2 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1174,7 +1174,7 @@ static const struct v4l2_file_operations mpeg_fops =
.read = mpeg_read,
.poll = mpeg_poll,
.mmap = mpeg_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 0fab65c..25b19dd 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1683,7 +1683,7 @@ static const struct v4l2_file_operations video_fops =
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -1736,7 +1736,7 @@ static const struct v4l2_file_operations radio_fops =
.owner = THIS_MODULE,
.open = video_open,
.release = video_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 2e5a7fb..408ecdf 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -1836,7 +1836,7 @@ static struct v4l2_file_operations vpif_fops = {
.owner = THIS_MODULE,
.open = vpif_open,
.release = vpif_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.mmap = vpif_mmap,
.poll = vpif_poll
};
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index e5bab3d..1adfc36 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -1340,7 +1340,7 @@ static const struct v4l2_file_operations vpif_fops = {
.owner = THIS_MODULE,
.open = vpif_open,
.release = vpif_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.mmap = vpif_mmap,
.poll = vpif_poll
};
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index b6ac99d..dc4bb70 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -2387,7 +2387,7 @@ static const struct v4l2_file_operations em28xx_v4l_fops = {
.read = em28xx_v4l2_read,
.poll = em28xx_v4l2_poll,
.mmap = em28xx_v4l2_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -2449,7 +2449,7 @@ static const struct v4l2_file_operations radio_fops = {
.owner = THIS_MODULE,
.open = em28xx_v4l2_open,
.release = em28xx_v4l2_close,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index bb9fdb7..b581a3d 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1659,7 +1659,7 @@ static const struct v4l2_file_operations meye_fops = {
.open = meye_open,
.release = meye_release,
.mmap = meye_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.poll = meye_poll,
};

diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 1c05017..6f15bd1 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1554,11 +1554,11 @@ static int omap24xxcam_release(struct file *file)
}

static struct v4l2_file_operations omap24xxcam_fops = {
- .ioctl = video_ioctl2,
- .poll = omap24xxcam_poll,
- .mmap = omap24xxcam_mmap,
- .open = omap24xxcam_open,
- .release = omap24xxcam_release,
+ .unlocked_ioctl = video_ioctl2,
+ .poll = omap24xxcam_poll,
+ .mmap = omap24xxcam_mmap,
+ .open = omap24xxcam_open,
+ .release = omap24xxcam_release,
};

/*
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 7129b50..7551907 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -932,7 +932,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,

static const struct v4l2_file_operations pms_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.read = pms_read,
};

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 4dc001b..9db5968 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -1890,12 +1890,12 @@ static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma)
}

static const struct v4l2_file_operations s2255_fops_v4l = {
- .owner = THIS_MODULE,
- .open = s2255_open,
- .release = s2255_release,
- .poll = s2255_poll,
- .ioctl = video_ioctl2, /* V4L2 ioctl handler */
- .mmap = s2255_mmap_v4l,
+ .owner = THIS_MODULE,
+ .open = s2255_open,
+ .release = s2255_release,
+ .poll = s2255_poll,
+ .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
+ .mmap = s2255_mmap_v4l,
};

static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index ea877a5..d503aae 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -438,13 +438,13 @@ static int empress_g_std(struct file *file, void *priv, v4l2_std_id *id)

static const struct v4l2_file_operations ts_fops =
{
- .owner = THIS_MODULE,
- .open = ts_open,
- .release = ts_release,
- .read = ts_read,
- .poll = ts_poll,
- .mmap = ts_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = ts_open,
+ .release = ts_release,
+ .read = ts_read,
+ .poll = ts_poll,
+ .mmap = ts_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops ts_ioctl_ops = {
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 7806fb1..c142071 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -2409,13 +2409,13 @@ static int radio_queryctrl(struct file *file, void *priv,

static const struct v4l2_file_operations video_fops =
{
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -2470,12 +2470,12 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
};

static const struct v4l2_file_operations radio_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .read = radio_read,
- .release = video_release,
- .ioctl = video_ioctl2,
- .poll = radio_poll,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .read = radio_read,
+ .release = video_release,
+ .unlocked_ioctl = video_ioctl2,
+ .poll = radio_poll,
};

static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 30f5c41..04fb6cf 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -513,7 +513,7 @@ static struct v4l2_file_operations soc_camera_fops = {
.owner = THIS_MODULE,
.open = soc_camera_open,
.release = soc_camera_close,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.read = soc_camera_read,
.mmap = soc_camera_mmap,
.poll = soc_camera_poll,
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index f07a0f6..fb993c8 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1263,13 +1263,13 @@ static int stk_vidioc_enum_framesizes(struct file *filp,
}

static struct v4l2_file_operations v4l_stk_fops = {
- .owner = THIS_MODULE,
- .open = v4l_stk_open,
- .release = v4l_stk_release,
- .read = v4l_stk_read,
- .poll = v4l_stk_poll,
- .mmap = v4l_stk_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = v4l_stk_open,
+ .release = v4l_stk_release,
+ .read = v4l_stk_read,
+ .poll = v4l_stk_poll,
+ .mmap = v4l_stk_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
diff --git a/drivers/media/video/tlg2300/pd-radio.c b/drivers/media/video/tlg2300/pd-radio.c
index fae84c2..29a4d7f 100644
--- a/drivers/media/video/tlg2300/pd-radio.c
+++ b/drivers/media/video/tlg2300/pd-radio.c
@@ -155,10 +155,10 @@ static int vidioc_querycap(struct file *file, void *priv,
}

static const struct v4l2_file_operations poseidon_fm_fops = {
- .owner = THIS_MODULE,
- .open = poseidon_fm_open,
- .release = poseidon_fm_close,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = poseidon_fm_open,
+ .release = poseidon_fm_close,
+ .unlocked_ioctl = video_ioctl2,
};

static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
diff --git a/drivers/media/video/tlg2300/pd-video.c b/drivers/media/video/tlg2300/pd-video.c
index c750fd1..0e95a3d 100644
--- a/drivers/media/video/tlg2300/pd-video.c
+++ b/drivers/media/video/tlg2300/pd-video.c
@@ -1542,7 +1542,7 @@ static const struct v4l2_file_operations pd_video_fops = {
.read = pd_video_read,
.poll = pd_video_poll,
.mmap = pd_video_mmap,
- .ioctl = video_ioctl2, /* maybe changed in future */
+ .unlocked_ioctl = video_ioctl2, /* maybe changed in future */
};

static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index d91f016..0f47f4a 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1251,7 +1251,7 @@ static const struct v4l2_file_operations usbvision_fops = {
.release = usbvision_v4l2_close,
.read = usbvision_v4l2_read,
.mmap = usbvision_v4l2_mmap,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
/* .poll = video_poll, */
};

@@ -1304,7 +1304,7 @@ static const struct v4l2_file_operations usbvision_radio_fops = {
.owner = THIS_MODULE,
.open = usbvision_radio_open,
.release = usbvision_radio_close,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = {
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 635420d..42d5661 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -815,7 +815,7 @@ out:

static const struct v4l2_file_operations w9966_fops = {
.owner = THIS_MODULE,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.read = w9966_v4l_read,
};

diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index 6f89d0a..85bbf58 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -3371,14 +3371,14 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
};

static const struct v4l2_file_operations zoran_fops = {
- .owner = THIS_MODULE,
- .open = zoran_open,
- .release = zoran_close,
- .ioctl = video_ioctl2,
- .read = zoran_read,
- .write = zoran_write,
- .mmap = zoran_mmap,
- .poll = zoran_poll,
+ .owner = THIS_MODULE,
+ .open = zoran_open,
+ .release = zoran_close,
+ .unlocked_ioctl = video_ioctl2,
+ .read = zoran_read,
+ .write = zoran_write,
+ .mmap = zoran_mmap,
+ .poll = zoran_poll,
};

struct video_device zoran_template __devinitdata = {
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index a82b5bd..35a53e0 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -1438,13 +1438,13 @@ static unsigned int zr364xx_poll(struct file *file,
}

static const struct v4l2_file_operations zr364xx_fops = {
- .owner = THIS_MODULE,
- .open = zr364xx_open,
- .release = zr364xx_release,
- .read = zr364xx_read,
- .mmap = zr364xx_mmap,
- .ioctl = video_ioctl2,
- .poll = zr364xx_poll,
+ .owner = THIS_MODULE,
+ .open = zr364xx_open,
+ .release = zr364xx_release,
+ .read = zr364xx_read,
+ .mmap = zr364xx_mmap,
+ .unlocked_ioctl = video_ioctl2,
+ .poll = zr364xx_poll,
};

static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video0.c b/drivers/staging/cx25821/cx25821-video0.c
index 1f95ddb..c8727db 100644
--- a/drivers/staging/cx25821/cx25821-video0.c
+++ b/drivers/staging/cx25821/cx25821-video0.c
@@ -373,13 +373,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video1.c b/drivers/staging/cx25821/cx25821-video1.c
index 9b94462..2fd02d7 100644
--- a/drivers/staging/cx25821/cx25821-video1.c
+++ b/drivers/staging/cx25821/cx25821-video1.c
@@ -373,13 +373,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

//exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video2.c b/drivers/staging/cx25821/cx25821-video2.c
index 31c46aa..bdcca2b 100644
--- a/drivers/staging/cx25821/cx25821-video2.c
+++ b/drivers/staging/cx25821/cx25821-video2.c
@@ -375,13 +375,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video3.c b/drivers/staging/cx25821/cx25821-video3.c
index cbc5cad..48e54af 100644
--- a/drivers/staging/cx25821/cx25821-video3.c
+++ b/drivers/staging/cx25821/cx25821-video3.c
@@ -374,13 +374,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video4.c b/drivers/staging/cx25821/cx25821-video4.c
index 101074a..abd8bda 100644
--- a/drivers/staging/cx25821/cx25821-video4.c
+++ b/drivers/staging/cx25821/cx25821-video4.c
@@ -373,13 +373,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video5.c b/drivers/staging/cx25821/cx25821-video5.c
index 2019c5e..003266e 100644
--- a/drivers/staging/cx25821/cx25821-video5.c
+++ b/drivers/staging/cx25821/cx25821-video5.c
@@ -373,13 +373,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video6.c b/drivers/staging/cx25821/cx25821-video6.c
index d19c786..a838251 100644
--- a/drivers/staging/cx25821/cx25821-video6.c
+++ b/drivers/staging/cx25821/cx25821-video6.c
@@ -373,13 +373,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-video7.c b/drivers/staging/cx25821/cx25821-video7.c
index 8a7c854..6fd6115 100644
--- a/drivers/staging/cx25821/cx25821-video7.c
+++ b/drivers/staging/cx25821/cx25821-video7.c
@@ -372,13 +372,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl2,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c
index 723c1a6..b71fb3f 100644
--- a/drivers/staging/go7007/go7007-v4l2.c
+++ b/drivers/staging/go7007/go7007-v4l2.c
@@ -1743,7 +1743,7 @@ static struct v4l2_file_operations go7007_fops = {
.owner = THIS_MODULE,
.open = go7007_open,
.release = go7007_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
.read = go7007_read,
.mmap = go7007_mmap,
.poll = go7007_poll,
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c53de47..b2db64b 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1455,7 +1455,7 @@ static struct v4l2_file_operations tm6000_fops = {
.owner = THIS_MODULE,
.open = tm6000_open,
.release = tm6000_release,
- .ioctl = video_ioctl2, /* V4L2 ioctl handler */
+ .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
.read = tm6000_read,
.poll = tm6000_poll,
.mmap = tm6000_mmap,
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index ee538f1..aad79f4 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -265,7 +265,7 @@ static const struct v4l2_file_operations tea575x_fops = {
.owner = THIS_MODULE,
.open = snd_tea575x_exclusive_open,
.release = snd_tea575x_exclusive_release,
- .ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
--
1.6.2.3

2010-04-29 03:43:08

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 5/5] v4l: Remove struct v4l2_file_operations::ioctl

No more drivers use the bkl'ed callback, now drop it for good.

Signed-off-by: Frederic Weisbecker <[email protected]>
---
drivers/media/video/v4l2-dev.c | 38 ++++----------------------------------
include/media/v4l2-dev.h | 1 -
2 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..702a026 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -215,19 +215,7 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
return vdev->fops->poll(filp, poll);
}

-static int v4l2_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
-{
- struct video_device *vdev = video_devdata(filp);
-
- if (!vdev->fops->ioctl)
- return -ENOTTY;
- /* Allow ioctl to continue even if the device was unregistered.
- Things like dequeueing buffers might still be useful. */
- return vdev->fops->ioctl(filp, cmd, arg);
-}
-
-static long v4l2_unlocked_ioctl(struct file *filp,
+static long v4l2_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct video_device *vdev = video_devdata(filp);
@@ -307,22 +295,6 @@ static int v4l2_release(struct inode *inode, struct file *filp)
return ret;
}

-static const struct file_operations v4l2_unlocked_fops = {
- .owner = THIS_MODULE,
- .read = v4l2_read,
- .write = v4l2_write,
- .open = v4l2_open,
- .get_unmapped_area = v4l2_get_unmapped_area,
- .mmap = v4l2_mmap,
- .unlocked_ioctl = v4l2_unlocked_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = v4l2_compat_ioctl32,
-#endif
- .release = v4l2_release,
- .poll = v4l2_poll,
- .llseek = no_llseek,
-};
-
static const struct file_operations v4l2_fops = {
.owner = THIS_MODULE,
.read = v4l2_read,
@@ -330,7 +302,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .ioctl = v4l2_ioctl,
+ .unlocked_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
@@ -517,10 +489,8 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
ret = -ENOMEM;
goto cleanup;
}
- if (vdev->fops->unlocked_ioctl)
- vdev->cdev->ops = &v4l2_unlocked_fops;
- else
- vdev->cdev->ops = &v4l2_fops;
+
+ vdev->cdev->ops = &v4l2_fops;
vdev->cdev->owner = vdev->fops->owner;
ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
if (ret < 0) {
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 2dee938..9a05e85 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -38,7 +38,6 @@ struct v4l2_file_operations {
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
- long (*ioctl) (struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
unsigned long (*get_unmapped_area) (struct file *, unsigned long,
unsigned long, unsigned long, unsigned long);
--
1.6.2.3

2010-04-29 03:42:49

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 0/5] Pushdown bkl from v4l ioctls

Hi,

Linus suggested to rename struct v4l2_file_operations::ioctl
into bkl_ioctl to eventually get something greppable and make
its background explicit.

While at it I thought it could be a good idea to just pushdown
the bkl to every v4l drivers that have an .ioctl, so that we
actually remove struct v4l2_file_operations::ioctl for good.

It passed make allyesconfig on sparc.
Please tell me what you think.

Thanks.

Frederic Weisbecker (5):
v4l: Pushdown bkl into video_ioctl2
v4l: Use video_ioctl2_unlocked from drivers that don't want the bkl
v4l: Change users of video_ioctl2 to use unlocked_ioctl
v4l: Pushdown bkl to drivers that implement their own ioctl
v4l: Remove struct v4l2_file_operations::ioctl

drivers/media/common/saa7146_fops.c | 2 +-
drivers/media/radio/dsbr100.c | 2 +-
drivers/media/radio/radio-aimslab.c | 2 +-
drivers/media/radio/radio-aztech.c | 2 +-
drivers/media/radio/radio-cadet.c | 2 +-
drivers/media/radio/radio-gemtek-pci.c | 2 +-
drivers/media/radio/radio-gemtek.c | 2 +-
drivers/media/radio/radio-maestro.c | 2 +-
drivers/media/radio/radio-maxiradio.c | 2 +-
drivers/media/radio/radio-miropcm20.c | 2 +-
drivers/media/radio/radio-mr800.c | 2 +-
drivers/media/radio/radio-rtrack2.c | 2 +-
drivers/media/radio/radio-sf16fmi.c | 2 +-
drivers/media/radio/radio-sf16fmr2.c | 2 +-
drivers/media/radio/radio-si4713.c | 2 +-
drivers/media/radio/radio-tea5764.c | 2 +-
drivers/media/radio/radio-terratec.c | 2 +-
drivers/media/radio/radio-timb.c | 2 +-
drivers/media/radio/radio-trust.c | 2 +-
drivers/media/radio/radio-typhoon.c | 2 +-
drivers/media/radio/radio-zoltrix.c | 2 +-
drivers/media/radio/si470x/radio-si470x-common.c | 2 +-
drivers/media/video/arv.c | 2 +-
drivers/media/video/au0828/au0828-video.c | 14 ++++----
drivers/media/video/bt8xx/bttv-driver.c | 26 +++++++-------
drivers/media/video/bw-qcam.c | 11 +++++-
drivers/media/video/c-qcam.c | 11 +++++-
drivers/media/video/cafe_ccic.c | 14 ++++----
drivers/media/video/cpia.c | 11 +++++-
drivers/media/video/cpia2/cpia2_v4l.c | 11 +++++-
drivers/media/video/cx18/cx18-streams.c | 12 +++---
drivers/media/video/cx231xx/cx231xx-video.c | 4 +-
drivers/media/video/cx23885/cx23885-417.c | 2 +-
drivers/media/video/cx23885/cx23885-video.c | 4 +-
drivers/media/video/cx88/cx88-blackbird.c | 2 +-
drivers/media/video/cx88/cx88-video.c | 4 +-
drivers/media/video/davinci/vpfe_capture.c | 2 +-
drivers/media/video/davinci/vpif_capture.c | 2 +-
drivers/media/video/davinci/vpif_display.c | 2 +-
drivers/media/video/em28xx/em28xx-video.c | 4 +-
drivers/media/video/et61x251/et61x251_core.c | 27 +++++++++++----
drivers/media/video/gspca/gspca.c | 2 +-
drivers/media/video/hdpvr/hdpvr-video.c | 2 +-
drivers/media/video/meye.c | 2 +-
drivers/media/video/omap24xxcam.c | 10 +++---
drivers/media/video/ov511.c | 15 +++++---
drivers/media/video/pms.c | 2 +-
drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 20 +++++++----
drivers/media/video/pwc/pwc-if.c | 19 ++++++----
drivers/media/video/s2255drv.c | 12 +++---
drivers/media/video/saa5246a.c | 11 ++++--
drivers/media/video/saa5249.c | 6 +++-
drivers/media/video/saa7134/saa7134-empress.c | 14 ++++----
drivers/media/video/saa7134/saa7134-video.c | 26 +++++++-------
drivers/media/video/se401.c | 20 +++++++----
drivers/media/video/sn9c102/sn9c102_core.c | 27 +++++++++++----
drivers/media/video/soc_camera.c | 2 +-
drivers/media/video/stk-webcam.c | 14 ++++----
drivers/media/video/stradis.c | 26 +++++++++++----
drivers/media/video/stv680.c | 20 +++++++----
drivers/media/video/tlg2300/pd-radio.c | 8 ++--
drivers/media/video/tlg2300/pd-video.c | 2 +-
drivers/media/video/usbvideo/usbvideo.c | 21 ++++++++----
drivers/media/video/usbvideo/vicam.c | 14 +++++++-
drivers/media/video/usbvision/usbvision-video.c | 4 +-
drivers/media/video/uvc/uvc_v4l2.c | 11 +++++-
drivers/media/video/v4l2-dev.c | 38 ++-------------------
drivers/media/video/v4l2-ioctl.c | 17 ++++++++-
drivers/media/video/vivi.c | 2 +-
drivers/media/video/w9966.c | 2 +-
drivers/media/video/w9968cf.c | 25 +++++++++++---
drivers/media/video/zc0301/zc0301_core.c | 27 +++++++++++----
drivers/media/video/zoran/zoran_driver.c | 16 ++++----
drivers/media/video/zr364xx.c | 14 ++++----
drivers/staging/cx25821/cx25821-audups11.c | 18 ++++++----
drivers/staging/cx25821/cx25821-video0.c | 14 ++++----
drivers/staging/cx25821/cx25821-video1.c | 14 ++++----
drivers/staging/cx25821/cx25821-video2.c | 14 ++++----
drivers/staging/cx25821/cx25821-video3.c | 14 ++++----
drivers/staging/cx25821/cx25821-video4.c | 14 ++++----
drivers/staging/cx25821/cx25821-video5.c | 14 ++++----
drivers/staging/cx25821/cx25821-video6.c | 14 ++++----
drivers/staging/cx25821/cx25821-video7.c | 14 ++++----
drivers/staging/cx25821/cx25821-videoioctl.c | 27 +++++++++++----
drivers/staging/cx25821/cx25821-vidups10.c | 19 +++++++----
drivers/staging/cx25821/cx25821-vidups9.c | 18 ++++++----
drivers/staging/dream/camera/msm_v4l2.c | 27 +++++++++++----
drivers/staging/go7007/go7007-v4l2.c | 2 +-
drivers/staging/tm6000/tm6000-video.c | 2 +-
include/media/v4l2-dev.h | 1 -
include/media/v4l2-ioctl.h | 2 +
sound/i2c/other/tea575x-tuner.c | 2 +-
92 files changed, 530 insertions(+), 360 deletions(-)

2010-04-29 03:43:27

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 4/5] v4l: Pushdown bkl to drivers that implement their own ioctl

These are the last remaining v4l drivers that implement the ioctl
callback.

Signed-off-by: Frederic Weisbecker <[email protected]>
---
drivers/media/video/bw-qcam.c | 11 ++++++++-
drivers/media/video/c-qcam.c | 11 ++++++++-
drivers/media/video/cpia.c | 11 ++++++++-
drivers/media/video/cpia2/cpia2_v4l.c | 11 ++++++++-
drivers/media/video/et61x251/et61x251_core.c | 27 +++++++++++++++++++------
drivers/media/video/ov511.c | 15 ++++++++-----
drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 20 ++++++++++++------
drivers/media/video/pwc/pwc-if.c | 19 ++++++++++-------
drivers/media/video/saa5246a.c | 11 ++++++---
drivers/media/video/saa5249.c | 6 ++++-
drivers/media/video/se401.c | 20 ++++++++++++------
drivers/media/video/sn9c102/sn9c102_core.c | 27 +++++++++++++++++++------
drivers/media/video/stradis.c | 26 ++++++++++++++++++------
drivers/media/video/stv680.c | 20 ++++++++++++------
drivers/media/video/usbvideo/usbvideo.c | 21 +++++++++++++------
drivers/media/video/usbvideo/vicam.c | 14 ++++++++++++-
drivers/media/video/uvc/uvc_v4l2.c | 11 ++++++++-
drivers/media/video/vivi.c | 2 +-
drivers/media/video/w9968cf.c | 25 ++++++++++++++++++-----
drivers/media/video/zc0301/zc0301_core.c | 27 +++++++++++++++++++------
drivers/staging/cx25821/cx25821-audups11.c | 18 ++++++++++------
drivers/staging/cx25821/cx25821-videoioctl.c | 27 +++++++++++++++++++------
drivers/staging/cx25821/cx25821-vidups10.c | 19 +++++++++++------
drivers/staging/cx25821/cx25821-vidups9.c | 18 ++++++++++------
drivers/staging/dream/camera/msm_v4l2.c | 27 ++++++++++++++++++-------
25 files changed, 315 insertions(+), 129 deletions(-)

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 3c9e754..11367b0 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -76,6 +76,7 @@ OTHER DEALINGS IN THE SOFTWARE.
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <linux/mutex.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>

#include "bw-qcam.h"
@@ -831,7 +832,13 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long qcam_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, qcam_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, qcam_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static ssize_t qcam_read(struct file *file, char __user *buf,
@@ -879,7 +886,7 @@ static const struct v4l2_file_operations qcam_fops = {
.owner = THIS_MODULE,
.open = qcam_exclusive_open,
.release = qcam_exclusive_release,
- .ioctl = qcam_ioctl,
+ .unlocked_ioctl = qcam_ioctl,
.read = qcam_read,
};
static struct video_device qcam_template = {
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 8f1dd88..0eb42fd 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -38,6 +38,7 @@
#include <media/v4l2-ioctl.h>
#include <linux/mutex.h>
#include <linux/jiffies.h>
+#include <linux/smp_lock.h>

#include <asm/uaccess.h>

@@ -663,7 +664,13 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long qcam_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, qcam_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, qcam_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static ssize_t qcam_read(struct file *file, char __user *buf,
@@ -704,7 +711,7 @@ static const struct v4l2_file_operations qcam_fops = {
.owner = THIS_MODULE,
.open = qcam_exclusive_open,
.release = qcam_exclusive_release,
- .ioctl = qcam_ioctl,
+ .unlocked_ioctl = qcam_ioctl,
.read = qcam_read,
};

diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 933ae4c..f3f08cc 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -38,6 +38,7 @@
#include <linux/ctype.h>
#include <linux/pagemap.h>
#include <linux/delay.h>
+#include <linux/smp_lock.h>
#include <asm/io.h>
#include <linux/mutex.h>

@@ -3715,7 +3716,13 @@ static long cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long cpia_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, cpia_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, cpia_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}


@@ -3775,7 +3782,7 @@ static const struct v4l2_file_operations cpia_fops = {
.release = cpia_close,
.read = cpia_read,
.mmap = cpia_mmap,
- .ioctl = cpia_ioctl,
+ .unlocked_ioctl = cpia_ioctl,
};

static struct video_device cpia_template = {
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 6f91415..835172d 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -39,6 +39,7 @@
#include <linux/init.h>
#include <linux/videodev.h>
#include <linux/stringify.h>
+#include <linux/smp_lock.h>
#include <media/v4l2-ioctl.h>

#include "cpia2.h"
@@ -1840,7 +1841,13 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long cpia2_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, cpia2_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, cpia2_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

/******************************************************************************
@@ -1914,7 +1921,7 @@ static const struct v4l2_file_operations fops_template = {
.release = cpia2_close,
.read = cpia2_v4l_read,
.poll = cpia2_v4l_poll,
- .ioctl = cpia2_ioctl,
+ .unlocked_ioctl = cpia2_ioctl,
.mmap = cpia2_mmap,
};

diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index a5cfc76..2f64a24 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -34,6 +34,7 @@
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/page-flags.h>
+#include <linux/smp_lock.h>
#include <media/v4l2-ioctl.h>
#include <asm/byteorder.h>
#include <asm/page.h>
@@ -2525,15 +2526,27 @@ static long et61x251_ioctl(struct file *filp,
return err;
}

+static long
+et61x251_locked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = et61x251_ioctl(filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+

static const struct v4l2_file_operations et61x251_fops = {
- .owner = THIS_MODULE,
- .open = et61x251_open,
- .release = et61x251_release,
- .ioctl = et61x251_ioctl,
- .read = et61x251_read,
- .poll = et61x251_poll,
- .mmap = et61x251_mmap,
+ .owner = THIS_MODULE,
+ .open = et61x251_open,
+ .release = et61x251_release,
+ .unlocked_ioctl = et61x251_locked_ioctl,
+ .read = et61x251_read,
+ .poll = et61x251_poll,
+ .mmap = et61x251_mmap,
};

/*****************************************************************************/
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index 6085d55..51ff18f 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -44,6 +44,7 @@
#include <asm/processor.h>
#include <linux/mm.h>
#include <linux/device.h>
+#include <linux/smp_lock.h>

#if defined (__i386__)
#include <asm/cpufeature.h>
@@ -4460,7 +4461,9 @@ ov51x_v4l1_ioctl(struct file *file,
if (mutex_lock_interruptible(&ov->lock))
return -EINTR;

+ lock_kernel();
rc = video_usercopy(file, cmd, arg, ov51x_v4l1_ioctl_internal);
+ unlock_kernel();

mutex_unlock(&ov->lock);
return rc;
@@ -4662,12 +4665,12 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
}

static const struct v4l2_file_operations ov511_fops = {
- .owner = THIS_MODULE,
- .open = ov51x_v4l1_open,
- .release = ov51x_v4l1_close,
- .read = ov51x_v4l1_read,
- .mmap = ov51x_v4l1_mmap,
- .ioctl = ov51x_v4l1_ioctl,
+ .owner = THIS_MODULE,
+ .open = ov51x_v4l1_open,
+ .release = ov51x_v4l1_close,
+ .read = ov51x_v4l1_read,
+ .mmap = ov51x_v4l1_mmap,
+ .unlocked_ioctl = ov51x_v4l1_ioctl,
};

static struct video_device vdev_template = {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index fe4159d..0cbc84a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -22,6 +22,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/version.h>
+#include <linux/smp_lock.h>
#include "pvrusb2-context.h"
#include "pvrusb2-hdw.h"
#include "pvrusb2.h"
@@ -950,8 +951,13 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
static long pvr2_v4l2_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
+ long ret;

- return video_usercopy(file, cmd, arg, pvr2_v4l2_do_ioctl);
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, pvr2_v4l2_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}


@@ -1231,12 +1237,12 @@ static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait)


static const struct v4l2_file_operations vdev_fops = {
- .owner = THIS_MODULE,
- .open = pvr2_v4l2_open,
- .release = pvr2_v4l2_release,
- .read = pvr2_v4l2_read,
- .ioctl = pvr2_v4l2_ioctl,
- .poll = pvr2_v4l2_poll,
+ .owner = THIS_MODULE,
+ .open = pvr2_v4l2_open,
+ .release = pvr2_v4l2_release,
+ .read = pvr2_v4l2_read,
+ .unlocked_ioctl = pvr2_v4l2_ioctl,
+ .poll = pvr2_v4l2_poll,
};


diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index aea7e22..cb9c93d 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -157,13 +157,13 @@ static long pwc_video_ioctl(struct file *file,
static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma);

static const struct v4l2_file_operations pwc_fops = {
- .owner = THIS_MODULE,
- .open = pwc_video_open,
- .release = pwc_video_close,
- .read = pwc_video_read,
- .poll = pwc_video_poll,
- .mmap = pwc_video_mmap,
- .ioctl = pwc_video_ioctl,
+ .owner = THIS_MODULE,
+ .open = pwc_video_open,
+ .release = pwc_video_close,
+ .read = pwc_video_read,
+ .poll = pwc_video_poll,
+ .mmap = pwc_video_mmap,
+ .unlocked_ioctl = pwc_video_ioctl,
};
static struct video_device pwc_template = {
.name = "Philips Webcam", /* Filled in later */
@@ -1424,8 +1424,11 @@ static long pwc_video_ioctl(struct file *file,
pdev = video_get_drvdata(vdev);

mutex_lock(&pdev->modlock);
- if (!pdev->unplugged)
+ if (!pdev->unplugged) {
+ lock_kernel();
r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl);
+ unlock_kernel();
+ }
mutex_unlock(&pdev->modlock);
out:
return r;
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 6b3b09e..095ce9c 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -47,6 +47,7 @@
#include <linux/mutex.h>
#include <linux/videotext.h>
#include <linux/videodev2.h>
+#include <linux/smp_lock.h>
#include <media/v4l2-device.h>
#include <media/v4l2-chip-ident.h>
#include <media/v4l2-ioctl.h>
@@ -962,7 +963,9 @@ static long saa5246a_ioctl(struct file *file,

cmd = vtx_fix_command(cmd);
mutex_lock(&t->lock);
+ lock_kernel();
err = video_usercopy(file, cmd, arg, do_saa5246a_ioctl);
+ lock_kernel();
mutex_unlock(&t->lock);
return err;
}
@@ -1026,10 +1029,10 @@ static int saa5246a_release(struct file *file)
}

static const struct v4l2_file_operations saa_fops = {
- .owner = THIS_MODULE,
- .open = saa5246a_open,
- .release = saa5246a_release,
- .ioctl = saa5246a_ioctl,
+ .owner = THIS_MODULE,
+ .open = saa5246a_open,
+ .release = saa5246a_release,
+ .unlocked_ioctl = saa5246a_ioctl,
};

static struct video_device saa_template =
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 31ff27d..279c204 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -51,6 +51,7 @@
#include <linux/videotext.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
+#include <linux/smp_lock.h>
#include <media/v4l2-device.h>
#include <media/v4l2-chip-ident.h>
#include <media/v4l2-ioctl.h>
@@ -498,8 +499,11 @@ static long saa5249_ioctl(struct file *file,

cmd = vtx_fix_command(cmd);
mutex_lock(&t->lock);
+ lock_kernel();
err = video_usercopy(file, cmd, arg, do_saa5249_ioctl);
+ unlock_kernel();
mutex_unlock(&t->lock);
+
return err;
}

@@ -551,7 +555,7 @@ static const struct v4l2_file_operations saa_fops = {
.owner = THIS_MODULE,
.open = saa5249_open,
.release = saa5249_release,
- .ioctl = saa5249_ioctl,
+ .unlocked_ioctl = saa5249_ioctl,
};

static struct video_device saa_template =
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index 41d0166..285e31a 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -1154,7 +1154,13 @@ static long se401_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long se401_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, se401_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, se401_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static ssize_t se401_read(struct file *file, char __user *buf,
@@ -1237,12 +1243,12 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
}

static const struct v4l2_file_operations se401_fops = {
- .owner = THIS_MODULE,
- .open = se401_open,
- .release = se401_close,
- .read = se401_read,
- .mmap = se401_mmap,
- .ioctl = se401_ioctl,
+ .owner = THIS_MODULE,
+ .open = se401_open,
+ .release = se401_close,
+ .read = se401_read,
+ .mmap = se401_mmap,
+ .unlocked_ioctl = se401_ioctl,
};
static struct video_device se401_template = {
.name = "se401 USB camera",
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 28e19da..843b56a 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -34,6 +34,7 @@
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/page-flags.h>
+#include <linux/smp_lock.h>
#include <asm/byteorder.h>
#include <asm/page.h>
#include <asm/uaccess.h>
@@ -3232,16 +3233,28 @@ static long sn9c102_ioctl(struct file *filp,
return err;
}

+static long
+sn9c102_locked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = sn9c102_ioctl(filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*****************************************************************************/

static const struct v4l2_file_operations sn9c102_fops = {
- .owner = THIS_MODULE,
- .open = sn9c102_open,
- .release = sn9c102_release,
- .ioctl = sn9c102_ioctl,
- .read = sn9c102_read,
- .poll = sn9c102_poll,
- .mmap = sn9c102_mmap,
+ .owner = THIS_MODULE,
+ .open = sn9c102_open,
+ .release = sn9c102_release,
+ .unlocked_ioctl = sn9c102_locked_ioctl,
+ .read = sn9c102_read,
+ .poll = sn9c102_poll,
+ .mmap = sn9c102_mmap,
};

/*****************************************************************************/
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index a057824..51e4d9b 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1739,6 +1739,18 @@ static long saa_ioctl(struct file *file,
return 0;
}

+static long saa_locked_ioctl(struct file *file,
+ unsigned int cmd, unsigned long argl)
+{
+ long ret;
+
+ lock_kernel();
+ ret = saa_ioctl(file, cmd, argl);
+ unlock_kernel();
+
+ return ret;
+}
+
static int saa_mmap(struct file *file, struct vm_area_struct *vma)
{
struct saa7146 *saa = file->private_data;
@@ -1908,13 +1920,13 @@ static int saa_release(struct file *file)
}

static const struct v4l2_file_operations saa_fops = {
- .owner = THIS_MODULE,
- .open = saa_open,
- .release = saa_release,
- .ioctl = saa_ioctl,
- .read = saa_read,
- .write = saa_write,
- .mmap = saa_mmap,
+ .owner = THIS_MODULE,
+ .open = saa_open,
+ .release = saa_release,
+ .unlocked_ioctl = saa_locked_ioctl,
+ .read = saa_read,
+ .write = saa_write,
+ .mmap = saa_mmap,
};

/* template for video_device-structure */
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 5938ad8..675ae58 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1304,7 +1304,13 @@ static long stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long stv680_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, stv680_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, stv680_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
@@ -1394,12 +1400,12 @@ static ssize_t stv680_read (struct file *file, char __user *buf,
} /* stv680_read */

static const struct v4l2_file_operations stv680_fops = {
- .owner = THIS_MODULE,
- .open = stv_open,
- .release = stv_close,
- .read = stv680_read,
- .mmap = stv680_mmap,
- .ioctl = stv680_ioctl,
+ .owner = THIS_MODULE,
+ .open = stv_open,
+ .release = stv_close,
+ .read = stv680_read,
+ .mmap = stv680_mmap,
+ .unlocked_ioctl = stv680_ioctl,
};
static struct video_device stv680_template = {
.name = "STV0680 USB camera",
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 5ac37c6..b7865d8 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -23,6 +23,7 @@
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/spinlock.h>
+#include <linux/smp_lock.h>

#include <asm/io.h>

@@ -943,12 +944,12 @@ static int usbvideo_find_struct(struct usbvideo *cams)
}

static const struct v4l2_file_operations usbvideo_fops = {
- .owner = THIS_MODULE,
- .open = usbvideo_v4l_open,
- .release =usbvideo_v4l_close,
- .read = usbvideo_v4l_read,
- .mmap = usbvideo_v4l_mmap,
- .ioctl = usbvideo_v4l_ioctl,
+ .owner = THIS_MODULE,
+ .open = usbvideo_v4l_open,
+ .release = usbvideo_v4l_close,
+ .read = usbvideo_v4l_read,
+ .mmap = usbvideo_v4l_mmap,
+ .unlocked_ioctl = usbvideo_v4l_ioctl,
};
static const struct video_device usbvideo_template = {
.fops = &usbvideo_fops,
@@ -1500,7 +1501,13 @@ static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg
static long usbvideo_v4l_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl);
+ long ret;
+
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

/*
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 6030410..575a783 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -470,6 +470,18 @@ vicam_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg)
return retval;
}

+static long
+vicam_locked_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = vicam_ioctl(file, ioctlnr, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static int
vicam_open(struct file *file)
{
@@ -790,7 +802,7 @@ static const struct v4l2_file_operations vicam_fops = {
.release = vicam_close,
.read = vicam_read,
.mmap = vicam_mmap,
- .ioctl = vicam_ioctl,
+ .unlocked_ioctl = vicam_locked_ioctl,
};

static struct video_device vicam_template = {
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 7c9ab29..3971fa3 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -21,6 +21,7 @@
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/wait.h>
+#include <linux/smp_lock.h>
#include <asm/atomic.h>

#include <media/v4l2-common.h>
@@ -1029,13 +1030,19 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
static long uvc_v4l2_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
+ long ret;
+
if (uvc_trace_param & UVC_TRACE_IOCTL) {
uvc_printk(KERN_DEBUG, "uvc_v4l2_ioctl(");
v4l_printk_ioctl(cmd);
printk(")\n");
}

- return video_usercopy(file, cmd, arg, uvc_v4l2_do_ioctl);
+ lock_kernel();
+ ret = video_usercopy(file, cmd, arg, uvc_v4l2_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static ssize_t uvc_v4l2_read(struct file *file, char __user *data,
@@ -1134,7 +1141,7 @@ const struct v4l2_file_operations uvc_fops = {
.owner = THIS_MODULE,
.open = uvc_v4l2_open,
.release = uvc_v4l2_release,
- .ioctl = uvc_v4l2_ioctl,
+ .unlocked_ioctl = uvc_v4l2_ioctl,
.read = uvc_v4l2_read,
.mmap = uvc_v4l2_mmap,
.poll = uvc_v4l2_poll,
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 5a736b8..4e119a4 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -1264,7 +1264,7 @@ static const struct v4l2_file_operations vivi_fops = {
.release = vivi_close,
.read = vivi_read,
.poll = vivi_poll,
- .ioctl = video_ioctl2, /* V4L2 ioctl handler */
+ .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
.mmap = vivi_mmap,
};

diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index d807eea..149a192 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -39,6 +39,7 @@
#include <linux/ioctl.h>
#include <linux/delay.h>
#include <linux/stddef.h>
+#include <linux/smp_lock.h>
#include <asm/page.h>
#include <asm/uaccess.h>
#include <linux/page-flags.h>
@@ -2846,6 +2847,18 @@ w9968cf_ioctl(struct file *filp,
return err;
}

+static long
+w9968cf_locked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = w9968cf_ioctl(filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+

static long w9968cf_v4l_ioctl(struct file *filp,
unsigned int cmd, void __user *arg)
@@ -3390,12 +3403,12 @@ ioctl_fail:


static const struct v4l2_file_operations w9968cf_fops = {
- .owner = THIS_MODULE,
- .open = w9968cf_open,
- .release = w9968cf_release,
- .read = w9968cf_read,
- .ioctl = w9968cf_ioctl,
- .mmap = w9968cf_mmap,
+ .owner = THIS_MODULE,
+ .open = w9968cf_open,
+ .release = w9968cf_release,
+ .read = w9968cf_read,
+ .unlocked_ioctl = w9968cf_locked_ioctl,
+ .mmap = w9968cf_mmap,
};


diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index bb51cfb..b7c839b 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -38,6 +38,7 @@
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/page-flags.h>
+#include <linux/smp_lock.h>
#include <asm/byteorder.h>
#include <asm/page.h>
#include <asm/uaccess.h>
@@ -1927,15 +1928,27 @@ static long zc0301_ioctl(struct file *filp,
return err;
}

+static long
+zc0301_locked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = zc0301_ioctl(filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+

static const struct v4l2_file_operations zc0301_fops = {
- .owner = THIS_MODULE,
- .open = zc0301_open,
- .release = zc0301_release,
- .ioctl = zc0301_ioctl,
- .read = zc0301_read,
- .poll = zc0301_poll,
- .mmap = zc0301_mmap,
+ .owner = THIS_MODULE,
+ .open = zc0301_open,
+ .release = zc0301_release,
+ .unlocked_ioctl = zc0301_locked_ioctl,
+ .read = zc0301_read,
+ .poll = zc0301_poll,
+ .mmap = zc0301_mmap,
};

/*****************************************************************************/
diff --git a/drivers/staging/cx25821/cx25821-audups11.c b/drivers/staging/cx25821/cx25821-audups11.c
index 9193a6e..3b9a7ae 100644
--- a/drivers/staging/cx25821/cx25821-audups11.c
+++ b/drivers/staging/cx25821/cx25821-audups11.c
@@ -22,6 +22,7 @@
*/

#include <linux/slab.h>
+#include <linux/smp_lock.h>

#include "cx25821-video.h"

@@ -301,6 +302,7 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd,
return 0;
}

+ lock_kernel();
dev->input_filename = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname = data_from_user->vid_stdname;
@@ -318,6 +320,8 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd,
break;
}

+ unlock_kernel();
+
return 0;
}

@@ -359,13 +363,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl_upstream11,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl_upstream11,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-videoioctl.c b/drivers/staging/cx25821/cx25821-videoioctl.c
index 840714a..b84ef90 100644
--- a/drivers/staging/cx25821/cx25821-videoioctl.c
+++ b/drivers/staging/cx25821/cx25821-videoioctl.c
@@ -21,6 +21,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

+#include <linux/smp_lock.h>
#include "cx25821-video.h"

static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
@@ -387,6 +388,18 @@ static long video_ioctl_set(struct file *file, unsigned int cmd,
return 0;
}

+static long video_locked_ioctl_set(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ long ret;
+
+ lock_kernel();
+ ret = video_ioctl_set(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static int vidioc_log_status(struct file *file, void *priv)
{
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
@@ -419,13 +432,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl_set,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_locked_ioctl_set,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-vidups10.c b/drivers/staging/cx25821/cx25821-vidups10.c
index 89c8592..52faff4 100644
--- a/drivers/staging/cx25821/cx25821-vidups10.c
+++ b/drivers/staging/cx25821/cx25821-vidups10.c
@@ -21,6 +21,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

+#include <linux/smp_lock.h>
#include "cx25821-video.h"

static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
@@ -271,6 +272,8 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd,
return 0;
}

+ lock_kernel();
+
dev->input_filename_ch2 = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname_ch2 = data_from_user->vid_stdname;
@@ -288,6 +291,8 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd,
break;
}

+ unlock_kernel();
+
return 0;
}

@@ -357,13 +362,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

//exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl_upstream10,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl_upstream10,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c
index c8e8083..d30f906 100644
--- a/drivers/staging/cx25821/cx25821-vidups9.c
+++ b/drivers/staging/cx25821/cx25821-vidups9.c
@@ -271,6 +271,8 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd,
return 0;
}

+ lock_kernel();
+
dev->input_filename = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname = data_from_user->vid_stdname;
@@ -288,6 +290,8 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd,
break;
}

+ unlock_kernel();
+
return 0;
}

@@ -355,13 +359,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

// exported stuff
static const struct v4l2_file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = cx25821_video_mmap,
- .ioctl = video_ioctl_upstream9,
+ .owner = THIS_MODULE,
+ .open = video_open,
+ .release = video_release,
+ .read = video_read,
+ .poll = video_poll,
+ .mmap = cx25821_video_mmap,
+ .unlocked_ioctl = video_ioctl_upstream9,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
diff --git a/drivers/staging/dream/camera/msm_v4l2.c b/drivers/staging/dream/camera/msm_v4l2.c
index c276f2f..7744287 100644
--- a/drivers/staging/dream/camera/msm_v4l2.c
+++ b/drivers/staging/dream/camera/msm_v4l2.c
@@ -12,6 +12,7 @@
#include <linux/spinlock.h>
#include <linux/videodev2.h>
#include <linux/proc_fs.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <media/v4l2-dev.h>
#include <media/msm_camera.h>
@@ -99,6 +100,7 @@ static unsigned int msm_v4l2_poll(struct file *f, struct poll_table_struct *w)
static long msm_v4l2_ioctl(struct file *filep,
unsigned int cmd, unsigned long arg)
{
+ long ret;
struct msm_ctrl_cmd *ctrlcmd;

D("msm_v4l2_ioctl, cmd = %d, %d\n", cmd, __LINE__);
@@ -119,18 +121,27 @@ static long msm_v4l2_ioctl(struct file *filep,
D("msm_v4l2_ioctl, MSM_V4L2_START_SNAPSHOT v4l2 ioctl %d\n",
cmd);
ctrlcmd->type = MSM_V4L2_SNAPSHOT;
- return g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync,
+ lock_kernel();
+ ret = g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync,
ctrlcmd);
+ unlock_kernel();
+ return ret;

case MSM_V4L2_GET_PICTURE:
D("msm_v4l2_ioctl, MSM_V4L2_GET_PICTURE v4l2 ioctl %d\n", cmd);
ctrlcmd = (struct msm_ctrl_cmd *)arg;
- return g_pmsm_v4l2_dev->drv->get_pict(
+ lock_kernel();
+ ret = g_pmsm_v4l2_dev->drv->get_pict(
g_pmsm_v4l2_dev->drv->sync, ctrlcmd);
+ unlock_kernel();
+ return ret;

default:
D("msm_v4l2_ioctl, standard v4l2 ioctl %d\n", cmd);
- return video_ioctl2(filep, cmd, arg);
+ lock_kernel();
+ ret = video_ioctl2(filep, cmd, arg);
+ unlock_kernel();
+ return ret;
}
}

@@ -640,11 +651,11 @@ int msm_v4l2_read_proc(char *pbuf, char **start, off_t offset,
#endif

static const struct v4l2_file_operations msm_v4l2_fops = {
- .owner = THIS_MODULE,
- .open = msm_v4l2_open,
- .poll = msm_v4l2_poll,
- .release = msm_v4l2_release,
- .ioctl = msm_v4l2_ioctl,
+ .owner = THIS_MODULE,
+ .open = msm_v4l2_open,
+ .poll = msm_v4l2_poll,
+ .release = msm_v4l2_release,
+ .unlocked_ioctl = msm_v4l2_ioctl,
};

static void msm_v4l2_dev_init(struct msm_v4l2_device *pmsm_v4l2_dev)
--
1.6.2.3

2010-04-29 03:43:51

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 2/5] v4l: Use video_ioctl2_unlocked from drivers that don't want the bkl

There are three drivers that use video_ioctl2() as an unlocked_ioctl,
let them use the new video_ioctl2_unlocked.

Signed-off-by: Frederic Weisbecker <[email protected]>
---
drivers/media/video/davinci/vpfe_capture.c | 2 +-
drivers/media/video/gspca/gspca.c | 2 +-
drivers/media/video/hdpvr/hdpvr-video.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index aa1411f..61a3514 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -786,7 +786,7 @@ static const struct v4l2_file_operations vpfe_fops = {
.owner = THIS_MODULE,
.open = vpfe_open,
.release = vpfe_release,
- .unlocked_ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2_unlocked,
.mmap = vpfe_mmap,
.poll = vpfe_poll
};
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 68a8431..a424c1d 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -2184,7 +2184,7 @@ static struct v4l2_file_operations dev_fops = {
.release = dev_close,
.read = dev_read,
.mmap = dev_mmap,
- .unlocked_ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2_unlocked,
.poll = dev_poll,
};

diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 196f82d..01b8a34 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -559,7 +559,7 @@ static const struct v4l2_file_operations hdpvr_fops = {
.release = hdpvr_release,
.read = hdpvr_read,
.poll = hdpvr_poll,
- .unlocked_ioctl = video_ioctl2,
+ .unlocked_ioctl = video_ioctl2_unlocked,
};

/*=======================================================================*/
--
1.6.2.3

2010-04-30 16:49:17

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 3/7] cris: push down BKL into some device drivers

On Tue, Apr 27, 2010 at 04:24:21PM +0200, Arnd Bergmann wrote:
> A number of cris specific device drivers still use the
> locked ->ioctl operation. Convert them to unlocked_ioctl
> with explicit lock_kernel calls.

Looks good, I've added this to the cris tree.

> Signed-off-by: Arnd Bergmann <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2010-04-30 17:46:24

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 0/5] Pushdown bkl from v4l ioctls

Hi Hans,

On Thursday 29 April 2010 08:44:29 Hans Verkuil wrote:
> On Thursday 29 April 2010 05:42:39 Frederic Weisbecker wrote:
> > Hi,
> >
> > Linus suggested to rename struct v4l2_file_operations::ioctl
> > into bkl_ioctl to eventually get something greppable and make
> > its background explicit.
> >
> > While at it I thought it could be a good idea to just pushdown
> > the bkl to every v4l drivers that have an .ioctl, so that we
> > actually remove struct v4l2_file_operations::ioctl for good.
> >
> > It passed make allyesconfig on sparc.
> > Please tell me what you think.
>
> I much prefer to keep the bkl inside the v4l2 core. One reason is that I
> think that we can replace the bkl in the core with a mutex. Still not
> ideal of course, so the next step will be to implement proper locking in
> each driver. For this some additional v4l infrastructure work needs to be
> done. I couldn't proceed with that until the v4l events API patches went
> in, and that happened yesterday.
>
> So from my point of view the timeline is this:
>
> 1) I do the infrastructure work this weekend. This will make it much easier
> to convert drivers to do proper locking. And it will also simplify
> v4l2_priority handling, so I'm killing two birds with one stone :-)
>
> 2) Wait until Arnd's patch gets merged that pushes the bkl down to
> v4l2-dev.c
>
> 3) Investigate what needs to be done to replace the bkl with a v4l2-dev.c
> global mutex. Those drivers that call the bkl themselves should probably be
> converted to do proper locking, but there are only about 14 drivers that do
> this. The other 60 or so drivers should work fine if a v4l2-dev global lock
> is used. At this point the bkl is effectively removed from the v4l
> subsystem.
>
> 4) Work on the remaining 60 drivers to do proper locking and get rid of the
> v4l2-dev global lock. This is probably less work than it sounds.
>
> Since your patch moves everything down to the driver level it will actually
> make this work harder rather than easier. And it touches almost all drivers
> as well.

Every driver will need to be carefully checked to make sure the BKL can be
replaced by a v4l2-dev global mutex. Why would it be more difficult to do so
if the BKL is pushed down to the drivers ?

--
Regards,

Laurent Pinchart

2010-04-30 20:32:41

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 0/5] Pushdown bkl from v4l ioctls

On Thursday 29 April 2010 09:10:42 Laurent Pinchart wrote:
> On Thursday 29 April 2010 08:44:29 Hans Verkuil wrote:
> >
> > 3) Investigate what needs to be done to replace the bkl with a v4l2-dev.c
> > global mutex. Those drivers that call the bkl themselves should probably be
> > converted to do proper locking, but there are only about 14 drivers that do
> > this. The other 60 or so drivers should work fine if a v4l2-dev global lock
> > is used. At this point the bkl is effectively removed from the v4l
> > subsystem.
> >
> > 4) Work on the remaining 60 drivers to do proper locking and get rid of the
> > v4l2-dev global lock. This is probably less work than it sounds.
> >
> > Since your patch moves everything down to the driver level it will actually
> > make this work harder rather than easier. And it touches almost all drivers
> > as well.
>
> Every driver will need to be carefully checked to make sure the BKL can be
> replaced by a v4l2-dev global mutex. Why would it be more difficult to do so
> if the BKL is pushed down to the drivers ?

Note that you can completely skip the step of a v4l2-dev global mutex with
Frederic's patch. This is the only use of the BKL in the common v4l2
code as far as I can tell, so instead of introducing yet another global
lock, you can go straight to stage 4 and look at each driver separately,
possibly introducing a per driver lock.

Arnd

2010-05-01 01:03:11

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 0/5] Pushdown bkl from v4l ioctls

On Thursday 29 April 2010 05:42:39 Frederic Weisbecker wrote:
> Hi,
>
> Linus suggested to rename struct v4l2_file_operations::ioctl
> into bkl_ioctl to eventually get something greppable and make
> its background explicit.
>
> While at it I thought it could be a good idea to just pushdown
> the bkl to every v4l drivers that have an .ioctl, so that we
> actually remove struct v4l2_file_operations::ioctl for good.
>
> It passed make allyesconfig on sparc.
> Please tell me what you think.

I much prefer to keep the bkl inside the v4l2 core. One reason is that I
think that we can replace the bkl in the core with a mutex. Still not
ideal of course, so the next step will be to implement proper locking in
each driver. For this some additional v4l infrastructure work needs to be
done. I couldn't proceed with that until the v4l events API patches went in,
and that happened yesterday.

So from my point of view the timeline is this:

1) I do the infrastructure work this weekend. This will make it much easier to
convert drivers to do proper locking. And it will also simplify v4l2_priority
handling, so I'm killing two birds with one stone :-)

2) Wait until Arnd's patch gets merged that pushes the bkl down to v4l2-dev.c

3) Investigate what needs to be done to replace the bkl with a v4l2-dev.c
global mutex. Those drivers that call the bkl themselves should probably be
converted to do proper locking, but there are only about 14 drivers that do
this. The other 60 or so drivers should work fine if a v4l2-dev global lock
is used. At this point the bkl is effectively removed from the v4l subsystem.

4) Work on the remaining 60 drivers to do proper locking and get rid of the
v4l2-dev global lock. This is probably less work than it sounds.

Since your patch moves everything down to the driver level it will actually
make this work harder rather than easier. And it touches almost all drivers
as well.

Regards,

Hans

>
> Thanks.
>
> Frederic Weisbecker (5):
> v4l: Pushdown bkl into video_ioctl2
> v4l: Use video_ioctl2_unlocked from drivers that don't want the bkl
> v4l: Change users of video_ioctl2 to use unlocked_ioctl
> v4l: Pushdown bkl to drivers that implement their own ioctl
> v4l: Remove struct v4l2_file_operations::ioctl
>
> drivers/media/common/saa7146_fops.c | 2 +-
> drivers/media/radio/dsbr100.c | 2 +-
> drivers/media/radio/radio-aimslab.c | 2 +-
> drivers/media/radio/radio-aztech.c | 2 +-
> drivers/media/radio/radio-cadet.c | 2 +-
> drivers/media/radio/radio-gemtek-pci.c | 2 +-
> drivers/media/radio/radio-gemtek.c | 2 +-
> drivers/media/radio/radio-maestro.c | 2 +-
> drivers/media/radio/radio-maxiradio.c | 2 +-
> drivers/media/radio/radio-miropcm20.c | 2 +-
> drivers/media/radio/radio-mr800.c | 2 +-
> drivers/media/radio/radio-rtrack2.c | 2 +-
> drivers/media/radio/radio-sf16fmi.c | 2 +-
> drivers/media/radio/radio-sf16fmr2.c | 2 +-
> drivers/media/radio/radio-si4713.c | 2 +-
> drivers/media/radio/radio-tea5764.c | 2 +-
> drivers/media/radio/radio-terratec.c | 2 +-
> drivers/media/radio/radio-timb.c | 2 +-
> drivers/media/radio/radio-trust.c | 2 +-
> drivers/media/radio/radio-typhoon.c | 2 +-
> drivers/media/radio/radio-zoltrix.c | 2 +-
> drivers/media/radio/si470x/radio-si470x-common.c | 2 +-
> drivers/media/video/arv.c | 2 +-
> drivers/media/video/au0828/au0828-video.c | 14 ++++----
> drivers/media/video/bt8xx/bttv-driver.c | 26 +++++++-------
> drivers/media/video/bw-qcam.c | 11 +++++-
> drivers/media/video/c-qcam.c | 11 +++++-
> drivers/media/video/cafe_ccic.c | 14 ++++----
> drivers/media/video/cpia.c | 11 +++++-
> drivers/media/video/cpia2/cpia2_v4l.c | 11 +++++-
> drivers/media/video/cx18/cx18-streams.c | 12 +++---
> drivers/media/video/cx231xx/cx231xx-video.c | 4 +-
> drivers/media/video/cx23885/cx23885-417.c | 2 +-
> drivers/media/video/cx23885/cx23885-video.c | 4 +-
> drivers/media/video/cx88/cx88-blackbird.c | 2 +-
> drivers/media/video/cx88/cx88-video.c | 4 +-
> drivers/media/video/davinci/vpfe_capture.c | 2 +-
> drivers/media/video/davinci/vpif_capture.c | 2 +-
> drivers/media/video/davinci/vpif_display.c | 2 +-
> drivers/media/video/em28xx/em28xx-video.c | 4 +-
> drivers/media/video/et61x251/et61x251_core.c | 27 +++++++++++----
> drivers/media/video/gspca/gspca.c | 2 +-
> drivers/media/video/hdpvr/hdpvr-video.c | 2 +-
> drivers/media/video/meye.c | 2 +-
> drivers/media/video/omap24xxcam.c | 10 +++---
> drivers/media/video/ov511.c | 15 +++++---
> drivers/media/video/pms.c | 2 +-
> drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 20 +++++++----
> drivers/media/video/pwc/pwc-if.c | 19 ++++++----
> drivers/media/video/s2255drv.c | 12 +++---
> drivers/media/video/saa5246a.c | 11 ++++--
> drivers/media/video/saa5249.c | 6 +++-
> drivers/media/video/saa7134/saa7134-empress.c | 14 ++++----
> drivers/media/video/saa7134/saa7134-video.c | 26 +++++++-------
> drivers/media/video/se401.c | 20 +++++++----
> drivers/media/video/sn9c102/sn9c102_core.c | 27 +++++++++++----
> drivers/media/video/soc_camera.c | 2 +-
> drivers/media/video/stk-webcam.c | 14 ++++----
> drivers/media/video/stradis.c | 26 +++++++++++----
> drivers/media/video/stv680.c | 20 +++++++----
> drivers/media/video/tlg2300/pd-radio.c | 8 ++--
> drivers/media/video/tlg2300/pd-video.c | 2 +-
> drivers/media/video/usbvideo/usbvideo.c | 21 ++++++++----
> drivers/media/video/usbvideo/vicam.c | 14 +++++++-
> drivers/media/video/usbvision/usbvision-video.c | 4 +-
> drivers/media/video/uvc/uvc_v4l2.c | 11 +++++-
> drivers/media/video/v4l2-dev.c | 38 ++-------------------
> drivers/media/video/v4l2-ioctl.c | 17 ++++++++-
> drivers/media/video/vivi.c | 2 +-
> drivers/media/video/w9966.c | 2 +-
> drivers/media/video/w9968cf.c | 25 +++++++++++---
> drivers/media/video/zc0301/zc0301_core.c | 27 +++++++++++----
> drivers/media/video/zoran/zoran_driver.c | 16 ++++----
> drivers/media/video/zr364xx.c | 14 ++++----
> drivers/staging/cx25821/cx25821-audups11.c | 18 ++++++----
> drivers/staging/cx25821/cx25821-video0.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video1.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video2.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video3.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video4.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video5.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video6.c | 14 ++++----
> drivers/staging/cx25821/cx25821-video7.c | 14 ++++----
> drivers/staging/cx25821/cx25821-videoioctl.c | 27 +++++++++++----
> drivers/staging/cx25821/cx25821-vidups10.c | 19 +++++++----
> drivers/staging/cx25821/cx25821-vidups9.c | 18 ++++++----
> drivers/staging/dream/camera/msm_v4l2.c | 27 +++++++++++----
> drivers/staging/go7007/go7007-v4l2.c | 2 +-
> drivers/staging/tm6000/tm6000-video.c | 2 +-
> include/media/v4l2-dev.h | 1 -
> include/media/v4l2-ioctl.h | 2 +
> sound/i2c/other/tea575x-tuner.c | 2 +-
> 92 files changed, 530 insertions(+), 360 deletions(-)
>

--
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco