Skip to content

Commit

Permalink
V4L/DVB (10135): v4l2: introduce v4l2_file_operations.
Browse files Browse the repository at this point in the history
Introduce a struct v4l2_file_operations for v4l2 drivers.

Remove the unnecessary inode argument.

Move compat32 handling (and llseek) into the v4l2-dev core: this is now
handled in the v4l2 core and no longer in the drivers themselves.

Note that this changeset reverts an earlier patch that changed the return
type of__video_ioctl2 from int to long. This change will be reinstated
later in a much improved version.

Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
hverkuil authored and Mauro Carvalho Chehab committed Jan 2, 2009
1 parent dfa9a5a commit bec4366
Show file tree
Hide file tree
Showing 83 changed files with 331 additions and 572 deletions.
21 changes: 10 additions & 11 deletions drivers/media/common/saa7146_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ void saa7146_buffer_timeout(unsigned long data)
/********************************************************************************/
/* file operations */

static int fops_open(struct inode *inode, struct file *file)
static int fops_open(struct file *file)
{
unsigned int minor = iminor(inode);
unsigned int minor = video_devdata(file)->minor;
struct saa7146_dev *h = NULL, *dev = NULL;
struct list_head *list;
struct saa7146_fh *fh = NULL;
int result = 0;

enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor));
DEB_EE(("file:%p, minor:%d\n", file, minor));

if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;
Expand Down Expand Up @@ -255,7 +255,7 @@ static int fops_open(struct inode *inode, struct file *file)
if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
result = saa7146_vbi_uops.open(dev,file);
if (dev->ext_vv_data->vbi_fops.open)
dev->ext_vv_data->vbi_fops.open(inode, file);
dev->ext_vv_data->vbi_fops.open(file);
} else {
DEB_S(("initializing video...\n"));
result = saa7146_video_uops.open(dev,file);
Expand All @@ -280,12 +280,12 @@ static int fops_open(struct inode *inode, struct file *file)
return result;
}

static int fops_release(struct inode *inode, struct file *file)
static int fops_release(struct file *file)
{
struct saa7146_fh *fh = file->private_data;
struct saa7146_dev *dev = fh->dev;

DEB_EE(("inode:%p, file:%p\n",inode,file));
DEB_EE(("file:%p\n", file));

if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;
Expand All @@ -294,7 +294,7 @@ static int fops_release(struct inode *inode, struct file *file)
if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
saa7146_vbi_uops.release(dev,file);
if (dev->ext_vv_data->vbi_fops.release)
dev->ext_vv_data->vbi_fops.release(inode, file);
dev->ext_vv_data->vbi_fops.release(file);
} else {
saa7146_video_uops.release(dev,file);
}
Expand All @@ -308,10 +308,10 @@ static int fops_release(struct inode *inode, struct file *file)
return 0;
}

static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static int fops_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
/*
DEB_EE(("inode:%p, file:%p, cmd:%d, arg:%li\n",inode, file, cmd, arg));
DEB_EE(("file:%p, cmd:%d, arg:%li\n", file, cmd, arg));
*/
return video_usercopy(file, cmd, arg, saa7146_video_do_ioctl);
}
Expand Down Expand Up @@ -416,7 +416,7 @@ static ssize_t fops_write(struct file *file, const char __user *data, size_t cou
}
}

static const struct file_operations video_fops =
static const struct v4l2_file_operations video_fops =
{
.owner = THIS_MODULE,
.open = fops_open,
Expand All @@ -426,7 +426,6 @@ static const struct file_operations video_fops =
.poll = fops_poll,
.mmap = fops_mmap,
.ioctl = fops_ioctl,
.llseek = no_llseek,
};

static void vv_callback(struct saa7146_dev *dev, unsigned long status)
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/ttpci/av7110_v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
return 0;
}

static int av7110_vbi_reset(struct inode *inode, struct file *file)
static int av7110_vbi_reset(struct file *file)
{
struct saa7146_fh *fh = file->private_data;
struct saa7146_dev *dev = fh->dev;
Expand Down
14 changes: 5 additions & 9 deletions drivers/media/radio/dsbr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ devices, that would be 76 and 91. */
static int usb_dsbr100_probe(struct usb_interface *intf,
const struct usb_device_id *id);
static void usb_dsbr100_disconnect(struct usb_interface *intf);
static int usb_dsbr100_open(struct inode *inode, struct file *file);
static int usb_dsbr100_close(struct inode *inode, struct file *file);
static int usb_dsbr100_open(struct file *file);
static int usb_dsbr100_close(struct file *file);
static int usb_dsbr100_suspend(struct usb_interface *intf,
pm_message_t message);
static int usb_dsbr100_resume(struct usb_interface *intf);
Expand Down Expand Up @@ -566,7 +566,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
return 0;
}

static int usb_dsbr100_open(struct inode *inode, struct file *file)
static int usb_dsbr100_open(struct file *file)
{
struct dsbr100_device *radio = video_drvdata(file);
int retval;
Expand All @@ -593,7 +593,7 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file)
return 0;
}

static int usb_dsbr100_close(struct inode *inode, struct file *file)
static int usb_dsbr100_close(struct file *file)
{
struct dsbr100_device *radio = video_drvdata(file);
int retval;
Expand Down Expand Up @@ -653,15 +653,11 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev)
}

/* File system interface */
static const struct file_operations usb_dsbr100_fops = {
static const struct v4l2_file_operations usb_dsbr100_fops = {
.owner = THIS_MODULE,
.open = usb_dsbr100_open,
.release = usb_dsbr100_close,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-aimslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,26 +374,22 @@ static int vidioc_s_audio(struct file *file, void *priv,

static struct rt_device rtrack_unit;

static int rtrack_exclusive_open(struct inode *inode, struct file *file)
static int rtrack_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0;
}

static int rtrack_exclusive_release(struct inode *inode, struct file *file)
static int rtrack_exclusive_release(struct file *file)
{
clear_bit(0, &rtrack_unit.in_use);
return 0;
}

static const struct file_operations rtrack_fops = {
static const struct v4l2_file_operations rtrack_fops = {
.owner = THIS_MODULE,
.open = rtrack_exclusive_open,
.release = rtrack_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-aztech.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,26 +338,22 @@ static int vidioc_s_ctrl (struct file *file, void *priv,

static struct az_device aztech_unit;

static int aztech_exclusive_open(struct inode *inode, struct file *file)
static int aztech_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0;
}

static int aztech_exclusive_release(struct inode *inode, struct file *file)
static int aztech_exclusive_release(struct file *file)
{
clear_bit(0, &aztech_unit.in_use);
return 0;
}

static const struct file_operations aztech_fops = {
static const struct v4l2_file_operations aztech_fops = {
.owner = THIS_MODULE,
.open = aztech_exclusive_open,
.release = aztech_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@ static int vidioc_s_audio(struct file *file, void *priv,
}

static int
cadet_open(struct inode *inode, struct file *file)
cadet_open(struct file *file)
{
users++;
if (1 == users) init_waitqueue_head(&read_queue);
return 0;
}

static int
cadet_release(struct inode *inode, struct file *file)
cadet_release(struct file *file)
{
users--;
if (0 == users){
Expand All @@ -557,17 +557,13 @@ cadet_poll(struct file *file, struct poll_table_struct *wait)
}


static const struct file_operations cadet_fops = {
static const struct v4l2_file_operations cadet_fops = {
.owner = THIS_MODULE,
.open = cadet_open,
.release = cadet_release,
.read = cadet_read,
.ioctl = video_ioctl2,
.poll = cadet_poll,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static const struct v4l2_ioctl_ops cadet_ioctl_ops = {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-gemtek-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,22 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id );

static int mx = 1;

static int gemtek_pci_exclusive_open(struct inode *inode, struct file *file)
static int gemtek_pci_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
}

static int gemtek_pci_exclusive_release(struct inode *inode, struct file *file)
static int gemtek_pci_exclusive_release(struct file *file)
{
clear_bit(0, &in_use);
return 0;
}

static const struct file_operations gemtek_pci_fops = {
static const struct v4l2_file_operations gemtek_pci_fops = {
.owner = THIS_MODULE,
.open = gemtek_pci_exclusive_open,
.release = gemtek_pci_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-gemtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,26 +394,22 @@ static struct v4l2_queryctrl radio_qctrl[] = {
}
};

static int gemtek_exclusive_open(struct inode *inode, struct file *file)
static int gemtek_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
}

static int gemtek_exclusive_release(struct inode *inode, struct file *file)
static int gemtek_exclusive_release(struct file *file)
{
clear_bit(0, &in_use);
return 0;
}

static const struct file_operations gemtek_fops = {
static const struct v4l2_file_operations gemtek_fops = {
.owner = THIS_MODULE,
.open = gemtek_exclusive_open,
.release = gemtek_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek
};

static int vidioc_querycap(struct file *file, void *priv,
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-maestro.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ static unsigned long in_use;

static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent);

static int maestro_exclusive_open(struct inode *inode, struct file *file)
static int maestro_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
}

static int maestro_exclusive_release(struct inode *inode, struct file *file)
static int maestro_exclusive_release(struct file *file)
{
clear_bit(0, &in_use);
return 0;
Expand All @@ -110,15 +110,11 @@ static struct pci_driver maestro_r_driver = {
.remove = __devexit_p(maestro_remove),
};

static const struct file_operations maestro_fops = {
static const struct v4l2_file_operations maestro_fops = {
.owner = THIS_MODULE,
.open = maestro_exclusive_open,
.release = maestro_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

struct radio_device {
Expand Down
10 changes: 3 additions & 7 deletions drivers/media/radio/radio-maxiradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,22 @@ static unsigned long in_use;
#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)


static int maxiradio_exclusive_open(struct inode *inode, struct file *file)
static int maxiradio_exclusive_open(struct file *file)
{
return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
}

static int maxiradio_exclusive_release(struct inode *inode, struct file *file)
static int maxiradio_exclusive_release(struct file *file)
{
clear_bit(0, &in_use);
return 0;
}

static const struct file_operations maxiradio_fops = {
static const struct v4l2_file_operations maxiradio_fops = {
.owner = THIS_MODULE,
.open = maxiradio_exclusive_open,
.release = maxiradio_exclusive_release,
.ioctl = video_ioctl2,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32,
#endif
.llseek = no_llseek,
};

static struct radio_device
Expand Down
Loading

0 comments on commit bec4366

Please sign in to comment.