Skip to content

Commit 45b6f5b

Browse files
deborahbrouwermchehab
authored andcommitted
media: bttv: radio use v4l2_fh instead of bttv_fh
Use a v4l2_fh when opening a radio device instead of a bttv_fh and manage it with v4l2_fh_open() and v4l2_fh_release() and v4l2_ctrl_poll(). This eliminates bttv_fh from the radio in preparation for vb2 conversion which stops using separate bttv file handles altogether. Signed-off-by: Deborah Brouwer <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 615c545 commit 45b6f5b

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

drivers/media/pci/bt8xx/bttv-driver.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,45 +2740,34 @@ static int radio_open(struct file *file)
27402740
{
27412741
struct video_device *vdev = video_devdata(file);
27422742
struct bttv *btv = video_drvdata(file);
2743-
struct bttv_fh *fh;
2743+
int ret = v4l2_fh_open(file);
27442744

2745-
dprintk("open dev=%s\n", video_device_node_name(vdev));
2745+
if (ret)
2746+
return ret;
27462747

2748+
dprintk("open dev=%s\n", video_device_node_name(vdev));
27472749
dprintk("%d: open called (radio)\n", btv->c.nr);
27482750

2749-
/* allocate per filehandle data */
2750-
fh = kmalloc(sizeof(*fh), GFP_KERNEL);
2751-
if (unlikely(!fh))
2752-
return -ENOMEM;
2753-
file->private_data = fh;
2754-
*fh = btv->init;
2755-
v4l2_fh_init(&fh->fh, vdev);
2756-
27572751
btv->radio_user++;
27582752
audio_mute(btv, btv->mute);
27592753

2760-
v4l2_fh_add(&fh->fh);
2761-
27622754
return 0;
27632755
}
27642756

27652757
static int radio_release(struct file *file)
27662758
{
2767-
struct bttv_fh *fh = file->private_data;
27682759
struct bttv *btv = video_drvdata(file);
27692760
struct saa6588_command cmd;
27702761

2771-
file->private_data = NULL;
2772-
v4l2_fh_del(&fh->fh);
2773-
v4l2_fh_exit(&fh->fh);
2774-
kfree(fh);
2775-
27762762
btv->radio_user--;
27772763

27782764
bttv_call_all(btv, core, command, SAA6588_CMD_CLOSE, &cmd);
27792765

27802766
if (btv->radio_user == 0)
27812767
btv->has_radio_tuner = 0;
2768+
2769+
v4l2_fh_release(file);
2770+
27822771
return 0;
27832772
}
27842773

@@ -2858,23 +2847,17 @@ static ssize_t radio_read(struct file *file, char __user *data,
28582847

28592848
static __poll_t radio_poll(struct file *file, poll_table *wait)
28602849
{
2861-
struct bttv_fh *fh = file->private_data;
28622850
struct bttv *btv = video_drvdata(file);
2863-
__poll_t req_events = poll_requested_events(wait);
28642851
struct saa6588_command cmd;
2865-
__poll_t res = 0;
2852+
__poll_t rc = v4l2_ctrl_poll(file, wait);
28662853

2867-
if (v4l2_event_pending(&fh->fh))
2868-
res = EPOLLPRI;
2869-
else if (req_events & EPOLLPRI)
2870-
poll_wait(file, &fh->fh.wait, wait);
28712854
radio_enable(btv);
28722855
cmd.instance = file;
28732856
cmd.event_list = wait;
2874-
cmd.poll_mask = res;
2857+
cmd.poll_mask = 0;
28752858
bttv_call_all(btv, core, command, SAA6588_CMD_POLL, &cmd);
28762859

2877-
return cmd.poll_mask;
2860+
return rc | cmd.poll_mask;
28782861
}
28792862

28802863
static const struct v4l2_file_operations radio_fops =

0 commit comments

Comments
 (0)