Commit ffb4877b authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: v4l2-common: simplify prio utility functions

v4l2_prio_init/open/close returned an int when in fact they would
always return 0. Make these void functions.

v4l2_prio_close and v4l2_prio_check pass an enum v4l2_priority as a
pointer for no good reason. Replace with a normal enum v4l2_priority
argument.

These changes will simplify the work of moving priority handling into
the v4l core.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 530d2d32
...@@ -1525,7 +1525,7 @@ static int bttv_s_ctrl(struct file *file, void *f, ...@@ -1525,7 +1525,7 @@ static int bttv_s_ctrl(struct file *file, void *f,
struct bttv_fh *fh = f; struct bttv_fh *fh = f;
struct bttv *btv = fh->btv; struct bttv *btv = fh->btv;
err = v4l2_prio_check(&btv->prio, &fh->prio); err = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -1859,7 +1859,7 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id) ...@@ -1859,7 +1859,7 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id)
unsigned int i; unsigned int i;
int err; int err;
err = v4l2_prio_check(&btv->prio, &fh->prio); err = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -1941,7 +1941,7 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i) ...@@ -1941,7 +1941,7 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
int err; int err;
err = v4l2_prio_check(&btv->prio, &fh->prio); err = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -1961,7 +1961,7 @@ static int bttv_s_tuner(struct file *file, void *priv, ...@@ -1961,7 +1961,7 @@ static int bttv_s_tuner(struct file *file, void *priv,
struct bttv *btv = fh->btv; struct bttv *btv = fh->btv;
int err; int err;
err = v4l2_prio_check(&btv->prio, &fh->prio); err = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -2001,7 +2001,7 @@ static int bttv_s_frequency(struct file *file, void *priv, ...@@ -2001,7 +2001,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
struct bttv *btv = fh->btv; struct bttv *btv = fh->btv;
int err; int err;
err = v4l2_prio_check(&btv->prio, &fh->prio); err = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -3024,7 +3024,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) ...@@ -3024,7 +3024,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
return -EINVAL; return -EINVAL;
retval = v4l2_prio_check(&btv->prio, &fh->prio); retval = v4l2_prio_check(&btv->prio, fh->prio);
if (0 != retval) if (0 != retval)
return retval; return retval;
...@@ -3236,7 +3236,7 @@ static int bttv_open(struct file *file) ...@@ -3236,7 +3236,7 @@ static int bttv_open(struct file *file)
*fh = btv->init; *fh = btv->init;
fh->type = type; fh->type = type;
fh->ov.setup_ok = 0; fh->ov.setup_ok = 0;
v4l2_prio_open(&btv->prio,&fh->prio); v4l2_prio_open(&btv->prio, &fh->prio);
videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
&btv->c.pci->dev, &btv->s_lock, &btv->c.pci->dev, &btv->s_lock,
...@@ -3307,7 +3307,7 @@ static int bttv_release(struct file *file) ...@@ -3307,7 +3307,7 @@ static int bttv_release(struct file *file)
/* free stuff */ /* free stuff */
videobuf_mmap_free(&fh->cap); videobuf_mmap_free(&fh->cap);
videobuf_mmap_free(&fh->vbi); videobuf_mmap_free(&fh->vbi);
v4l2_prio_close(&btv->prio,&fh->prio); v4l2_prio_close(&btv->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -3444,7 +3444,7 @@ static int radio_release(struct file *file) ...@@ -3444,7 +3444,7 @@ static int radio_release(struct file *file)
struct bttv *btv = fh->btv; struct bttv *btv = fh->btv;
struct rds_command cmd; struct rds_command cmd;
v4l2_prio_close(&btv->prio,&fh->prio); v4l2_prio_close(&btv->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
......
...@@ -324,7 +324,7 @@ static int cpia2_close(struct file *file) ...@@ -324,7 +324,7 @@ static int cpia2_close(struct file *file)
{ {
if(fh->mmapped) if(fh->mmapped)
cam->mmapped = 0; cam->mmapped = 0;
v4l2_prio_close(&cam->prio,&fh->prio); v4l2_prio_close(&cam->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
} }
...@@ -1592,7 +1592,7 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) ...@@ -1592,7 +1592,7 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
case VIDIOC_S_FMT: case VIDIOC_S_FMT:
{ {
struct cpia2_fh *fh = file->private_data; struct cpia2_fh *fh = file->private_data;
retval = v4l2_prio_check(&cam->prio, &fh->prio); retval = v4l2_prio_check(&cam->prio, fh->prio);
if(retval) { if(retval) {
mutex_unlock(&cam->busy_lock); mutex_unlock(&cam->busy_lock);
return retval; return retval;
......
...@@ -263,7 +263,7 @@ int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) ...@@ -263,7 +263,7 @@ int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
int ret; int ret;
struct v4l2_control ctrl; struct v4l2_control ctrl;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
......
...@@ -700,7 +700,7 @@ int cx18_v4l2_close(struct file *filp) ...@@ -700,7 +700,7 @@ int cx18_v4l2_close(struct file *filp)
CX18_DEBUG_IOCTL("close() of %s\n", s->name); CX18_DEBUG_IOCTL("close() of %s\n", s->name);
v4l2_prio_close(&cx->prio, &id->prio); v4l2_prio_close(&cx->prio, id->prio);
/* Easy case first: this stream was never claimed by us */ /* Easy case first: this stream was never claimed by us */
if (s->id != id->open_id) { if (s->id != id->open_id) {
......
...@@ -277,7 +277,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh, ...@@ -277,7 +277,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
int ret; int ret;
int w, h; int w, h;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -306,7 +306,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh, ...@@ -306,7 +306,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -341,7 +341,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, ...@@ -341,7 +341,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
int ret; int ret;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -549,7 +549,7 @@ static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop) ...@@ -549,7 +549,7 @@ static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -601,7 +601,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp) ...@@ -601,7 +601,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -647,7 +647,7 @@ int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf) ...@@ -647,7 +647,7 @@ int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -675,7 +675,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std) ...@@ -675,7 +675,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std)
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
...@@ -715,7 +715,7 @@ static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ...@@ -715,7 +715,7 @@ static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
ret = v4l2_prio_check(&cx->prio, &id->prio); ret = v4l2_prio_check(&cx->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
......
...@@ -736,7 +736,7 @@ static int vpfe_release(struct file *file) ...@@ -736,7 +736,7 @@ static int vpfe_release(struct file *file)
/* Decrement device usrs counter */ /* Decrement device usrs counter */
vpfe_dev->usrs--; vpfe_dev->usrs--;
/* Close the priority */ /* Close the priority */
v4l2_prio_close(&vpfe_dev->prio, &fh->prio); v4l2_prio_close(&vpfe_dev->prio, fh->prio);
/* If this is the last file handle */ /* If this is the last file handle */
if (!vpfe_dev->usrs) { if (!vpfe_dev->usrs) {
vpfe_dev->initialized = 0; vpfe_dev->initialized = 0;
......
...@@ -869,7 +869,7 @@ static int vpif_release(struct file *filep) ...@@ -869,7 +869,7 @@ static int vpif_release(struct file *filep)
mutex_unlock(&common->lock); mutex_unlock(&common->lock);
/* Close the priority */ /* Close the priority */
v4l2_prio_close(&ch->prio, &fh->prio); v4l2_prio_close(&ch->prio, fh->prio);
if (fh->initialized) if (fh->initialized)
ch->initialized = 0; ch->initialized = 0;
...@@ -1444,7 +1444,7 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id) ...@@ -1444,7 +1444,7 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
} }
} }
ret = v4l2_prio_check(&ch->prio, &fh->prio); ret = v4l2_prio_check(&ch->prio, fh->prio);
if (0 != ret) if (0 != ret)
return ret; return ret;
...@@ -1554,7 +1554,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index) ...@@ -1554,7 +1554,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
} }
} }
ret = v4l2_prio_check(&ch->prio, &fh->prio); ret = v4l2_prio_check(&ch->prio, fh->prio);
if (0 != ret) if (0 != ret)
return ret; return ret;
...@@ -1710,7 +1710,7 @@ static int vpif_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1710,7 +1710,7 @@ static int vpif_s_fmt_vid_cap(struct file *file, void *priv,
} }
} }
ret = v4l2_prio_check(&ch->prio, &fh->prio); ret = v4l2_prio_check(&ch->prio, fh->prio);
if (0 != ret) if (0 != ret)
return ret; return ret;
......
...@@ -671,7 +671,7 @@ static int vpif_release(struct file *filep) ...@@ -671,7 +671,7 @@ static int vpif_release(struct file *filep)
ch->initialized = 0; ch->initialized = 0;
/* Close the priority */ /* Close the priority */
v4l2_prio_close(&ch->prio, &fh->prio); v4l2_prio_close(&ch->prio, fh->prio);
filep->private_data = NULL; filep->private_data = NULL;
fh->initialized = 0; fh->initialized = 0;
kfree(fh); kfree(fh);
...@@ -753,7 +753,7 @@ static int vpif_s_fmt_vid_out(struct file *file, void *priv, ...@@ -753,7 +753,7 @@ static int vpif_s_fmt_vid_out(struct file *file, void *priv,
} }
/* Check for the priority */ /* Check for the priority */
ret = v4l2_prio_check(&ch->prio, &fh->prio); ret = v4l2_prio_check(&ch->prio, fh->prio);
if (0 != ret) if (0 != ret)
return ret; return ret;
fh->initialized = 1; fh->initialized = 1;
......
...@@ -853,7 +853,7 @@ int ivtv_v4l2_close(struct file *filp) ...@@ -853,7 +853,7 @@ int ivtv_v4l2_close(struct file *filp)
IVTV_DEBUG_FILE("close %s\n", s->name); IVTV_DEBUG_FILE("close %s\n", s->name);
v4l2_prio_close(&itv->prio, &id->prio); v4l2_prio_close(&itv->prio, id->prio);
v4l2_fh_del(fh); v4l2_fh_del(fh);
v4l2_fh_exit(fh); v4l2_fh_exit(fh);
......
...@@ -1851,7 +1851,7 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp, ...@@ -1851,7 +1851,7 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
case VIDIOC_S_EXT_CTRLS: case VIDIOC_S_EXT_CTRLS:
case VIDIOC_S_FBUF: case VIDIOC_S_FBUF:
case VIDIOC_OVERLAY: case VIDIOC_OVERLAY:
ret = v4l2_prio_check(&itv->prio, &id->prio); ret = v4l2_prio_check(&itv->prio, id->prio);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -183,7 +183,7 @@ static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) ...@@ -183,7 +183,7 @@ static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
case VIDIOC_S_INPUT: case VIDIOC_S_INPUT:
case VIDIOC_S_TUNER: case VIDIOC_S_TUNER:
case VIDIOC_S_FREQUENCY: case VIDIOC_S_FREQUENCY:
ret = v4l2_prio_check(&vp->prio, &fh->prio); ret = v4l2_prio_check(&vp->prio, fh->prio);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -972,7 +972,7 @@ static int pvr2_v4l2_release(struct file *file) ...@@ -972,7 +972,7 @@ static int pvr2_v4l2_release(struct file *file)
fhp->rhp = NULL; fhp->rhp = NULL;
} }
v4l2_prio_close(&vp->prio, &fhp->prio); v4l2_prio_close(&vp->prio, fhp->prio);
file->private_data = NULL; file->private_data = NULL;
if (fhp->vnext) { if (fhp->vnext) {
...@@ -1093,7 +1093,7 @@ static int pvr2_v4l2_open(struct file *file) ...@@ -1093,7 +1093,7 @@ static int pvr2_v4l2_open(struct file *file)
fhp->file = file; fhp->file = file;
file->private_data = fhp; file->private_data = fhp;
v4l2_prio_open(&vp->prio,&fhp->prio); v4l2_prio_open(&vp->prio, &fhp->prio);
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw); fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
......
...@@ -1180,7 +1180,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str ...@@ -1180,7 +1180,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str
That needs to be fixed somehow, but for now this is That needs to be fixed somehow, but for now this is
good enough. */ good enough. */
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -1359,7 +1359,7 @@ static int video_open(struct file *file) ...@@ -1359,7 +1359,7 @@ static int video_open(struct file *file)
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
fh->width = 720; fh->width = 720;
fh->height = 576; fh->height = 576;
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio, &fh->prio);
videobuf_queue_sg_init(&fh->cap, &video_qops, videobuf_queue_sg_init(&fh->cap, &video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
...@@ -1502,7 +1502,7 @@ static int video_release(struct file *file) ...@@ -1502,7 +1502,7 @@ static int video_release(struct file *file)
saa7134_pgtable_free(dev->pci,&fh->pt_cap); saa7134_pgtable_free(dev->pci,&fh->pt_cap);
saa7134_pgtable_free(dev->pci,&fh->pt_vbi); saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
v4l2_prio_close(&dev->prio,&fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
return 0; return 0;
...@@ -1785,7 +1785,7 @@ static int saa7134_s_input(struct file *file, void *priv, unsigned int i) ...@@ -1785,7 +1785,7 @@ static int saa7134_s_input(struct file *file, void *priv, unsigned int i)
struct saa7134_dev *dev = fh->dev; struct saa7134_dev *dev = fh->dev;
int err; int err;
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -1839,7 +1839,7 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_ ...@@ -1839,7 +1839,7 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
That needs to be fixed somehow, but for now this is That needs to be fixed somehow, but for now this is
good enough. */ good enough. */
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} else if (res_locked(dev, RESOURCE_OVERLAY)) { } else if (res_locked(dev, RESOURCE_OVERLAY)) {
...@@ -2023,7 +2023,7 @@ static int saa7134_s_tuner(struct file *file, void *priv, ...@@ -2023,7 +2023,7 @@ static int saa7134_s_tuner(struct file *file, void *priv,
struct saa7134_dev *dev = fh->dev; struct saa7134_dev *dev = fh->dev;
int rx, mode, err; int rx, mode, err;
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
...@@ -2057,7 +2057,7 @@ static int saa7134_s_frequency(struct file *file, void *priv, ...@@ -2057,7 +2057,7 @@ static int saa7134_s_frequency(struct file *file, void *priv,
struct saa7134_dev *dev = fh->dev; struct saa7134_dev *dev = fh->dev;
int err; int err;
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
......
...@@ -88,10 +88,9 @@ MODULE_LICENSE("GPL"); ...@@ -88,10 +88,9 @@ MODULE_LICENSE("GPL");
val == V4L2_PRIORITY_INTERACTIVE || \ val == V4L2_PRIORITY_INTERACTIVE || \
val == V4L2_PRIORITY_RECORD) val == V4L2_PRIORITY_RECORD)
int v4l2_prio_init(struct v4l2_prio_state *global) void v4l2_prio_init(struct v4l2_prio_state *global)
{ {
memset(global,0,sizeof(*global)); memset(global, 0, sizeof(*global));
return 0;
} }
EXPORT_SYMBOL(v4l2_prio_init); EXPORT_SYMBOL(v4l2_prio_init);
...@@ -111,17 +110,16 @@ int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, ...@@ -111,17 +110,16 @@ int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
} }
EXPORT_SYMBOL(v4l2_prio_change); EXPORT_SYMBOL(v4l2_prio_change);
int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
{ {
return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); v4l2_prio_change(global, local, V4L2_PRIORITY_DEFAULT);
} }
EXPORT_SYMBOL(v4l2_prio_open); EXPORT_SYMBOL(v4l2_prio_open);
int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local)
{ {
if (V4L2_PRIO_VALID(*local)) if (V4L2_PRIO_VALID(local))
atomic_dec(&global->prios[*local]); atomic_dec(&global->prios[local]);
return 0;
} }
EXPORT_SYMBOL(v4l2_prio_close); EXPORT_SYMBOL(v4l2_prio_close);
...@@ -137,11 +135,9 @@ enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) ...@@ -137,11 +135,9 @@ enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
} }
EXPORT_SYMBOL(v4l2_prio_max); EXPORT_SYMBOL(v4l2_prio_max);
int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local)
{ {
if (*local < v4l2_prio_max(global)) return (local < v4l2_prio_max(global)) ? -EBUSY : 0;
return -EBUSY;
return 0;
} }
EXPORT_SYMBOL(v4l2_prio_check); EXPORT_SYMBOL(v4l2_prio_check);
......
...@@ -203,7 +203,7 @@ static int video_release(struct file *file) ...@@ -203,7 +203,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -258,7 +258,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -258,7 +258,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -350,7 +350,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -350,7 +350,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
if (fh) { if (fh) {
dev = fh->dev; dev = fh->dev;
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -846,7 +846,7 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms) ...@@ -846,7 +846,7 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms)
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -916,7 +916,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i) ...@@ -916,7 +916,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
dprintk(1, "%s(%d)\n", __func__, i); dprintk(1, "%s(%d)\n", __func__, i);
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -967,8 +967,7 @@ int cx25821_vidioc_s_frequency(struct file *file, void *priv, struct v4l2_freque ...@@ -967,8 +967,7 @@ int cx25821_vidioc_s_frequency(struct file *file, void *priv, struct v4l2_freque
int err; int err;
if (fh) { if (fh) {
dev = fh->dev; err = v4l2_prio_check(&dev->prio, fh->prio);
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -1032,7 +1031,7 @@ int cx25821_vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) ...@@ -1032,7 +1031,7 @@ int cx25821_vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -1240,7 +1239,7 @@ int cx25821_vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop) ...@@ -1240,7 +1239,7 @@ int cx25821_vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop)
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -219,7 +219,7 @@ static int video_release(struct file *file) ...@@ -219,7 +219,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = PIXEL_FRMT_422; int pix_format = PIXEL_FRMT_422;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -219,7 +219,7 @@ static int video_release(struct file *file) ...@@ -219,7 +219,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -219,7 +219,7 @@ static int video_release(struct file *file) ...@@ -219,7 +219,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -365,7 +365,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -365,7 +365,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -219,7 +219,7 @@ static int video_release(struct file *file) ...@@ -219,7 +219,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -364,7 +364,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -364,7 +364,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -218,7 +218,7 @@ static int video_release(struct file *file) ...@@ -218,7 +218,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
// check priority // check priority
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -219,7 +219,7 @@ static int video_release(struct file *file) ...@@ -219,7 +219,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -274,7 +274,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -218,7 +218,7 @@ static int video_release(struct file *file) ...@@ -218,7 +218,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -273,7 +273,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -273,7 +273,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -363,7 +363,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -218,7 +218,7 @@ static int video_release(struct file *file) ...@@ -218,7 +218,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -273,7 +273,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -273,7 +273,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int pix_format = 0; int pix_format = 0;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -362,7 +362,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -362,7 +362,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -201,7 +201,7 @@ static int video_release(struct file *file) ...@@ -201,7 +201,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -256,7 +256,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -256,7 +256,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -409,7 +409,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -409,7 +409,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -201,7 +201,7 @@ static int video_release(struct file *file) ...@@ -201,7 +201,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -299,7 +299,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -299,7 +299,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -347,7 +347,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -347,7 +347,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -201,7 +201,7 @@ static int video_release(struct file *file) ...@@ -201,7 +201,7 @@ static int video_release(struct file *file)
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
v4l2_prio_close(&dev->prio, &fh->prio); v4l2_prio_close(&dev->prio, fh->prio);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -299,7 +299,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -299,7 +299,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
...@@ -345,7 +345,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -345,7 +345,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
......
...@@ -85,13 +85,13 @@ ...@@ -85,13 +85,13 @@
struct v4l2_prio_state { struct v4l2_prio_state {
atomic_t prios[4]; atomic_t prios[4];
}; };
int v4l2_prio_init(struct v4l2_prio_state *global); void v4l2_prio_init(struct v4l2_prio_state *global);
int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
enum v4l2_priority new); enum v4l2_priority new);
int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local); void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local); int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
......
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