Skip to content

Commit

Permalink
Merge branch 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/frederic/random-tracing

* 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing:
  staging: Pushdown bkl to easycap ioctl handlers
  autofs/autofs4: Move compat_ioctl handling into fs
  v4l: Convert v4l2-dev to unlocked_ioctl
  ia64/perfmon: Convert to unlocked_ioctl
  sunrpc: Remove duplicated #include
  ncpfs: Remove duplicated #include
  • Loading branch information
Linus Torvalds committed Aug 10, 2010
2 parents 4c61940 + 5ef0683 commit 7233e39
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 124 deletions.
52 changes: 15 additions & 37 deletions drivers/media/video/v4l2-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -307,30 +304,14 @@ 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,
.write = v4l2_write,
.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
Expand Down Expand Up @@ -521,10 +502,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) {
Expand Down
8 changes: 2 additions & 6 deletions drivers/staging/easycap/easycap.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,12 @@ struct data_buffer audio_buffer[];
void easycap_complete(struct urb *);
int easycap_open(struct inode *, struct file *);
int easycap_release(struct inode *, struct file *);
int easycap_ioctl(struct inode *, struct file *, \
unsigned int, unsigned long);
long easycap_ioctl(struct file *, unsigned int, unsigned long);

/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
int easycap_open_noinode(struct file *);
int easycap_release_noinode(struct file *);
long easycap_ioctl_noinode(struct file *, \
unsigned int, unsigned long);
int videodev_release(struct video_device *);
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Expand Down Expand Up @@ -515,8 +512,7 @@ void easysnd_complete(struct urb *);
ssize_t easysnd_read(struct file *, char __user *, size_t, loff_t *);
int easysnd_open(struct inode *, struct file *);
int easysnd_release(struct inode *, struct file *);
int easysnd_ioctl(struct inode *, struct file *, \
unsigned int, unsigned long);
long easysnd_ioctl(struct file *, unsigned int, unsigned long);
unsigned int easysnd_poll(struct file *, poll_table *);
void easysnd_delete(struct kref *);
int submit_audio_urbs(struct easycap *);
Expand Down
52 changes: 30 additions & 22 deletions drivers/staging/easycap/easycap_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
/*****************************************************************************/

#include <linux/smp_lock.h>
#include "easycap.h"
#include "easycap_debug.h"
#include "easycap_standard.h"
Expand Down Expand Up @@ -773,19 +774,10 @@ while (0xFFFFFFFF != easycap_control[i1].id) {
SAY("WARNING: failed to adjust mute: control not found\n");
return -ENOENT;
}
/****************************************************************************/
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
long
easycap_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg)\
{
return easycap_ioctl((struct inode *)NULL, file, cmd, arg);
}
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

/*--------------------------------------------------------------------------*/
int easycap_ioctl(struct inode *inode, struct file *file, \
unsigned int cmd, unsigned long arg)
static int easycap_ioctl_bkl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
static struct easycap *peasycap;
static struct usb_device *p;
Expand Down Expand Up @@ -1956,19 +1948,22 @@ default: {
}
return 0;
}
/****************************************************************************/
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
long
easysnd_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg)

long easycap_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
return easysnd_ioctl((struct inode *)NULL, file, cmd, arg);
struct inode *inode = file->f_dentry->d_inode;
long ret;

lock_kernel();
ret = easycap_ioctl_bkl(inode, file, cmd, arg);
unlock_kernel();

return ret;
}
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

/*--------------------------------------------------------------------------*/
int easysnd_ioctl(struct inode *inode, struct file *file, \
unsigned int cmd, unsigned long arg)
static int easysnd_ioctl_bkl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct easycap *peasycap;
struct usb_device *p;
Expand Down Expand Up @@ -2158,6 +2153,19 @@ default: {
}
return 0;
}

long easysnd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file->f_dentry->d_inode;
long ret;

lock_kernel();
ret = easysnd_ioctl_bkl(inode, file, cmd, arg);
unlock_kernel();

return ret;
}

/*****************************************************************************/
int explain_ioctl(__u32 wot)
{
Expand Down
38 changes: 19 additions & 19 deletions drivers/staging/easycap/easycap_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ struct usb_driver easycap_usb_driver = {
*/
/*---------------------------------------------------------------------------*/
const struct file_operations easycap_fops = {
.owner = THIS_MODULE,
.open = easycap_open,
.release = easycap_release,
.ioctl = easycap_ioctl,
.poll = easycap_poll,
.mmap = easycap_mmap,
.llseek = no_llseek,
.owner = THIS_MODULE,
.open = easycap_open,
.release = easycap_release,
.unlocked_ioctl = easycap_ioctl,
.poll = easycap_poll,
.mmap = easycap_mmap,
.llseek = no_llseek,
};
struct vm_operations_struct easycap_vm_ops = {
.open = easycap_vma_open,
Expand All @@ -83,12 +83,12 @@ struct usb_class_driver easycap_class = {
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
#if defined(EASYCAP_NEEDS_V4L2_FOPS)
const struct v4l2_file_operations v4l2_fops = {
.owner = THIS_MODULE,
.open = easycap_open_noinode,
.release = easycap_release_noinode,
.ioctl = easycap_ioctl_noinode,
.poll = easycap_poll,
.mmap = easycap_mmap,
.owner = THIS_MODULE,
.open = easycap_open_noinode,
.release = easycap_release_noinode,
.unlocked_ioctl = easycap_ioctl,
.poll = easycap_poll,
.mmap = easycap_mmap,
};
#endif /*EASYCAP_NEEDS_V4L2_FOPS*/
int video_device_many /*=0*/;
Expand All @@ -102,12 +102,12 @@ struct video_device *pvideo_array[VIDEO_DEVICE_MANY], *pvideo_device;
*/
/*--------------------------------------------------------------------------*/
const struct file_operations easysnd_fops = {
.owner = THIS_MODULE,
.open = easysnd_open,
.release = easysnd_release,
.ioctl = easysnd_ioctl,
.read = easysnd_read,
.llseek = no_llseek,
.owner = THIS_MODULE,
.open = easysnd_open,
.release = easysnd_release,
.unlocked_ioctl = easysnd_ioctl,
.read = easysnd_read,
.llseek = no_llseek,
};
struct usb_class_driver easysnd_class = {
.name = "usb/easysnd%d",
Expand Down
67 changes: 64 additions & 3 deletions fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/param.h>
#include <linux/time.h>
#include <linux/compat.h>
#include <linux/smp_lock.h>
#include "autofs_i.h"

Expand All @@ -25,13 +26,17 @@ static int autofs_root_symlink(struct inode *,struct dentry *,const char *);
static int autofs_root_unlink(struct inode *,struct dentry *);
static int autofs_root_rmdir(struct inode *,struct dentry *);
static int autofs_root_mkdir(struct inode *,struct dentry *,int);
static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
static long autofs_root_ioctl(struct file *,unsigned int,unsigned long);
static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long);

const struct file_operations autofs_root_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = autofs_root_readdir,
.ioctl = autofs_root_ioctl,
.unlocked_ioctl = autofs_root_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = autofs_root_compat_ioctl,
#endif
};

const struct inode_operations autofs_root_inode_operations = {
Expand Down Expand Up @@ -492,6 +497,25 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
}

/* Get/set timeout ioctl() operation */
#ifdef CONFIG_COMPAT
static inline int autofs_compat_get_set_timeout(struct autofs_sb_info *sbi,
unsigned int __user *p)
{
unsigned long ntimeout;

if (get_user(ntimeout, p) ||
put_user(sbi->exp_timeout / HZ, p))
return -EFAULT;

if (ntimeout > UINT_MAX/HZ)
sbi->exp_timeout = 0;
else
sbi->exp_timeout = ntimeout * HZ;

return 0;
}
#endif

static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
unsigned long __user *p)
{
Expand Down Expand Up @@ -546,7 +570,7 @@ static inline int autofs_expire_run(struct super_block *sb,
* ioctl()'s on the root directory is the chief method for the daemon to
* generate kernel reactions
*/
static int autofs_root_ioctl(struct inode *inode, struct file *filp,
static int autofs_do_root_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
Expand All @@ -571,6 +595,10 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
return 0;
case AUTOFS_IOC_PROTOVER: /* Get protocol version */
return autofs_get_protover(argp);
#ifdef CONFIG_COMPAT
case AUTOFS_IOC_SETTIMEOUT32:
return autofs_compat_get_set_timeout(sbi, argp);
#endif
case AUTOFS_IOC_SETTIMEOUT:
return autofs_get_set_timeout(sbi, argp);
case AUTOFS_IOC_EXPIRE:
Expand All @@ -579,4 +607,37 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
default:
return -ENOSYS;
}

}

static long autofs_root_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
int ret;

lock_kernel();
ret = autofs_do_root_ioctl(filp->f_path.dentry->d_inode,
filp, cmd, arg);
unlock_kernel();

return ret;
}

#ifdef CONFIG_COMPAT
static long autofs_root_compat_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct inode *inode = filp->f_path.dentry->d_inode;
int ret;

lock_kernel();
if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
ret = autofs_do_root_ioctl(inode, filp, cmd, arg);
else
ret = autofs_do_root_ioctl(inode, filp, cmd,
(unsigned long)compat_ptr(arg));
unlock_kernel();

return ret;
}
#endif
Loading

0 comments on commit 7233e39

Please sign in to comment.