Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 366556
b: refs/heads/master
c: c6c1d50
h: refs/heads/master
v: v3
  • Loading branch information
Sakari Ailus authored and Mauro Carvalho Chehab committed Mar 18, 2013
1 parent 74bd6ce commit c22f911
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cab3e1ffbe1b9c7a607506338f590dc1e6ca9909
refs/heads/master: c6c1d50b51e76b57fbf0651d38a7ae0c3fb9d5cc
31 changes: 28 additions & 3 deletions trunk/drivers/media/media-devnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,41 @@ static unsigned int media_poll(struct file *filp,
return mdev->fops->poll(filp, poll);
}

static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
static long
__media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg,
long (*ioctl_func)(struct file *filp, unsigned int cmd,
unsigned long arg))
{
struct media_devnode *mdev = media_devnode_data(filp);

if (!mdev->fops->ioctl)
if (!ioctl_func)
return -ENOTTY;

if (!media_devnode_is_registered(mdev))
return -EIO;

return mdev->fops->ioctl(filp, cmd, arg);
return ioctl_func(filp, cmd, arg);
}

static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct media_devnode *mdev = media_devnode_data(filp);

return __media_ioctl(filp, cmd, arg, mdev->fops->ioctl);
}

#ifdef CONFIG_COMPAT

static long media_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{
struct media_devnode *mdev = media_devnode_data(filp);

return __media_ioctl(filp, cmd, arg, mdev->fops->compat_ioctl);
}

#endif /* CONFIG_COMPAT */

/* Override for the open function */
static int media_open(struct inode *inode, struct file *filp)
{
Expand Down Expand Up @@ -188,6 +210,9 @@ static const struct file_operations media_devnode_fops = {
.write = media_write,
.open = media_open,
.unlocked_ioctl = media_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = media_compat_ioctl,
#endif /* CONFIG_COMPAT */
.release = media_release,
.poll = media_poll,
.llseek = no_llseek,
Expand Down
1 change: 1 addition & 0 deletions trunk/include/media/media-devnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct media_file_operations {
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 (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*open) (struct file *);
int (*release) (struct file *);
};
Expand Down

0 comments on commit c22f911

Please sign in to comment.