Commit 327ae597 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

V4L/DVB (13557): v4l: Remove unneeded video_device::minor usage in drivers

The video_device::minor field is used where it shouldn't, either to

- test for error conditions that can't happen anymore with the current
  v4l-dvb core,
- store the value in a driver private field that isn't used anymore,
- check the video device type where video_device::vfl_type should be
  used, or
- create the name of a kernel thread that should get a stable name.

Remove or fix those use cases.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 46b21094
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1)
/****************************************************************************/ /****************************************************************************/
/* resource management functions, shamelessly stolen from saa7134 driver */ /* resource management functions, shamelessly stolen from saa7134 driver */
...@@ -455,9 +453,6 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) ...@@ -455,9 +453,6 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
configuration data) */ configuration data) */
dev->ext_vv_data = ext_vv; dev->ext_vv_data = ext_vv;
vv->video_minor = -1;
vv->vbi_minor = -1;
vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle); vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
if( NULL == vv->d_clipping.cpu_addr ) { if( NULL == vv->d_clipping.cpu_addr ) {
ERR(("out of memory. aborting.\n")); ERR(("out of memory. aborting.\n"));
...@@ -496,7 +491,6 @@ EXPORT_SYMBOL_GPL(saa7146_vv_release); ...@@ -496,7 +491,6 @@ EXPORT_SYMBOL_GPL(saa7146_vv_release);
int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
char *name, int type) char *name, int type)
{ {
struct saa7146_vv *vv = dev->vv_data;
struct video_device *vfd; struct video_device *vfd;
int err; int err;
int i; int i;
...@@ -524,11 +518,6 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, ...@@ -524,11 +518,6 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
return err; return err;
} }
if (VFL_TYPE_GRABBER == type)
vv->video_minor = vfd->minor;
else
vv->vbi_minor = vfd->minor;
INFO(("%s: registered device %s [v4l2]\n", INFO(("%s: registered device %s [v4l2]\n",
dev->name, video_device_node_name(vfd))); dev->name, video_device_node_name(vfd)));
...@@ -539,16 +528,8 @@ EXPORT_SYMBOL_GPL(saa7146_register_device); ...@@ -539,16 +528,8 @@ EXPORT_SYMBOL_GPL(saa7146_register_device);
int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev) int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
{ {
struct saa7146_vv *vv = dev->vv_data;
DEB_EE(("dev:%p\n",dev)); DEB_EE(("dev:%p\n",dev));
if ((*vid)->vfl_type == VFL_TYPE_GRABBER) {
vv->video_minor = -1;
} else {
vv->vbi_minor = -1;
}
video_unregister_device(*vid); video_unregister_device(*vid);
*vid = NULL; *vid = NULL;
......
...@@ -460,12 +460,8 @@ static int vidioc_s_audio(struct file *file, void *priv, ...@@ -460,12 +460,8 @@ static int vidioc_s_audio(struct file *file, void *priv,
static int tea5764_open(struct file *file) static int tea5764_open(struct file *file)
{ {
/* Currently we support only one device */ /* Currently we support only one device */
int minor = video_devdata(file)->minor;
struct tea5764_device *radio = video_drvdata(file); struct tea5764_device *radio = video_drvdata(file);
if (radio->videodev->minor != minor)
return -ENODEV;
mutex_lock(&radio->mutex); mutex_lock(&radio->mutex);
/* Only exclusive access */ /* Only exclusive access */
if (radio->users) { if (radio->users) {
......
...@@ -3206,7 +3206,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) ...@@ -3206,7 +3206,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
static int bttv_open(struct file *file) static int bttv_open(struct file *file)
{ {
int minor = video_devdata(file)->minor;
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct bttv *btv = video_drvdata(file); struct bttv *btv = video_drvdata(file);
struct bttv_fh *fh; struct bttv_fh *fh;
...@@ -3214,17 +3213,17 @@ static int bttv_open(struct file *file) ...@@ -3214,17 +3213,17 @@ static int bttv_open(struct file *file)
dprintk(KERN_DEBUG "bttv: open dev=%s\n", video_device_node_name(vdev)); dprintk(KERN_DEBUG "bttv: open dev=%s\n", video_device_node_name(vdev));
lock_kernel(); if (vdev->vfl_type == VFL_TYPE_GRABBER) {
if (btv->video_dev->minor == minor) {
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} else if (btv->vbi_dev->minor == minor) { } else if (vdev->vfl_type == VFL_TYPE_VBI) {
type = V4L2_BUF_TYPE_VBI_CAPTURE; type = V4L2_BUF_TYPE_VBI_CAPTURE;
} else { } else {
WARN_ON(1); WARN_ON(1);
unlock_kernel();
return -ENODEV; return -ENODEV;
} }
lock_kernel();
dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n", dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
btv->c.nr,v4l2_type_names[type]); btv->c.nr,v4l2_type_names[type]);
...@@ -3408,7 +3407,6 @@ static struct video_device bttv_video_template = { ...@@ -3408,7 +3407,6 @@ static struct video_device bttv_video_template = {
static int radio_open(struct file *file) static int radio_open(struct file *file)
{ {
int minor = video_devdata(file)->minor;
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct bttv *btv = video_drvdata(file); struct bttv *btv = video_drvdata(file);
struct bttv_fh *fh; struct bttv_fh *fh;
...@@ -3416,11 +3414,6 @@ static int radio_open(struct file *file) ...@@ -3416,11 +3414,6 @@ static int radio_open(struct file *file)
dprintk("bttv: open dev=%s\n", video_device_node_name(vdev)); dprintk("bttv: open dev=%s\n", video_device_node_name(vdev));
lock_kernel(); lock_kernel();
WARN_ON(btv->radio_dev && btv->radio_dev->minor != minor);
if (!btv->radio_dev || btv->radio_dev->minor != minor) {
unlock_kernel();
return -ENODEV;
}
dprintk("bttv%d: open called (radio)\n",btv->c.nr); dprintk("bttv%d: open called (radio)\n",btv->c.nr);
......
...@@ -1476,8 +1476,9 @@ static int sn9c20x_input_init(struct gspca_dev *gspca_dev) ...@@ -1476,8 +1476,9 @@ static int sn9c20x_input_init(struct gspca_dev *gspca_dev)
if (input_register_device(sd->input_dev)) if (input_register_device(sd->input_dev))
return -EINVAL; return -EINVAL;
sd->input_task = kthread_run(input_kthread, gspca_dev, "sn9c20x/%d", sd->input_task = kthread_run(input_kthread, gspca_dev, "sn9c20x/%s-%s",
gspca_dev->vdev.minor); gspca_dev->dev->bus->bus_name,
gspca_dev->dev->devpath);
if (IS_ERR(sd->input_task)) if (IS_ERR(sd->input_task))
return -EINVAL; return -EINVAL;
......
...@@ -1450,12 +1450,11 @@ static int omap24xxcam_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1450,12 +1450,11 @@ static int omap24xxcam_mmap(struct file *file, struct vm_area_struct *vma)
static int omap24xxcam_open(struct file *file) static int omap24xxcam_open(struct file *file)
{ {
int minor = video_devdata(file)->minor;
struct omap24xxcam_device *cam = omap24xxcam.priv; struct omap24xxcam_device *cam = omap24xxcam.priv;
struct omap24xxcam_fh *fh; struct omap24xxcam_fh *fh;
struct v4l2_format format; struct v4l2_format format;
if (!cam || !cam->vfd || (cam->vfd->minor != minor)) if (!cam || !cam->vfd)
return -ENODEV; return -ENODEV;
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
......
...@@ -108,8 +108,6 @@ struct saa7146_fh { ...@@ -108,8 +108,6 @@ struct saa7146_fh {
struct saa7146_vv struct saa7146_vv
{ {
int vbi_minor;
/* vbi capture */ /* vbi capture */
struct saa7146_dmaqueue vbi_q; struct saa7146_dmaqueue vbi_q;
/* vbi workaround interrupt queue */ /* vbi workaround interrupt queue */
...@@ -117,8 +115,6 @@ struct saa7146_vv ...@@ -117,8 +115,6 @@ struct saa7146_vv
int vbi_fieldcount; int vbi_fieldcount;
struct saa7146_fh *vbi_streaming; struct saa7146_fh *vbi_streaming;
int video_minor;
int video_status; int video_status;
struct saa7146_fh *video_fh; struct saa7146_fh *video_fh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment