media: bttv: use video_drvdata to get bttv

Use video_drvdata(file) instead of fh->btv to get the bttv pointer
wherever the bttv pointer will still be needed after the vb2 conversion.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Deborah Brouwer 2023-07-14 19:15:57 -07:00 committed by Mauro Carvalho Chehab
parent 33c7ae8f49
commit d1846d7258
2 changed files with 32 additions and 53 deletions

View File

@ -1654,8 +1654,7 @@ static void radio_enable(struct bttv *btv)
static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id) static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
unsigned int i; unsigned int i;
for (i = 0; i < BTTV_TVNORMS; i++) for (i = 0; i < BTTV_TVNORMS; i++)
@ -1670,8 +1669,7 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id) static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
*id = btv->std; *id = btv->std;
return 0; return 0;
@ -1679,8 +1677,7 @@ static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id) static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
{ {
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML) if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML)
*id &= V4L2_STD_625_50; *id &= V4L2_STD_625_50;
@ -1692,8 +1689,7 @@ static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
static int bttv_enum_input(struct file *file, void *priv, static int bttv_enum_input(struct file *file, void *priv,
struct v4l2_input *i) struct v4l2_input *i)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (i->index >= bttv_tvcards[btv->c.type].video_inputs) if (i->index >= bttv_tvcards[btv->c.type].video_inputs)
return -EINVAL; return -EINVAL;
@ -1725,8 +1721,7 @@ static int bttv_enum_input(struct file *file, void *priv,
static int bttv_g_input(struct file *file, void *priv, unsigned int *i) static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
*i = btv->input; *i = btv->input;
@ -1735,8 +1730,7 @@ static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
static int bttv_s_input(struct file *file, void *priv, unsigned int i) static int bttv_s_input(struct file *file, void *priv, unsigned int i)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (i >= bttv_tvcards[btv->c.type].video_inputs) if (i >= bttv_tvcards[btv->c.type].video_inputs)
return -EINVAL; return -EINVAL;
@ -1748,8 +1742,7 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
static int bttv_s_tuner(struct file *file, void *priv, static int bttv_s_tuner(struct file *file, void *priv,
const struct v4l2_tuner *t) const struct v4l2_tuner *t)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (t->index) if (t->index)
return -EINVAL; return -EINVAL;
@ -1767,8 +1760,7 @@ static int bttv_s_tuner(struct file *file, void *priv,
static int bttv_g_frequency(struct file *file, void *priv, static int bttv_g_frequency(struct file *file, void *priv,
struct v4l2_frequency *f) struct v4l2_frequency *f)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (f->tuner) if (f->tuner)
return -EINVAL; return -EINVAL;
@ -1804,8 +1796,7 @@ static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f)
static int bttv_s_frequency(struct file *file, void *priv, static int bttv_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f) const struct v4l2_frequency *f)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (f->tuner) if (f->tuner)
return -EINVAL; return -EINVAL;
@ -1817,8 +1808,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
static int bttv_log_status(struct file *file, void *f) static int bttv_log_status(struct file *file, void *f)
{ {
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name); v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name);
bttv_call_all(btv, core, log_status); bttv_call_all(btv, core, log_status);
@ -1829,8 +1819,7 @@ static int bttv_log_status(struct file *file, void *f)
static int bttv_g_register(struct file *file, void *f, static int bttv_g_register(struct file *file, void *f,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
/* bt848 has a 12-bit register space */ /* bt848 has a 12-bit register space */
reg->reg &= 0xfff; reg->reg &= 0xfff;
@ -1843,8 +1832,7 @@ static int bttv_g_register(struct file *file, void *f,
static int bttv_s_register(struct file *file, void *f, static int bttv_s_register(struct file *file, void *f,
const struct v4l2_dbg_register *reg) const struct v4l2_dbg_register *reg)
{ {
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
/* bt848 has a 12-bit register space */ /* bt848 has a 12-bit register space */
btwrite(reg->val, reg->reg & 0xfff); btwrite(reg->val, reg->reg & 0xfff);
@ -2106,7 +2094,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
{ {
const struct bttv_format *fmt; const struct bttv_format *fmt;
struct bttv_fh *fh = priv; struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
enum v4l2_field field; enum v4l2_field field;
__s32 width, height; __s32 width, height;
__s32 height2; __s32 height2;
@ -2165,7 +2153,7 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
int retval; int retval;
const struct bttv_format *fmt; const struct bttv_format *fmt;
struct bttv_fh *fh = priv; struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
__s32 width, height; __s32 width, height;
unsigned int width_mask, width_bias; unsigned int width_mask, width_bias;
enum v4l2_field field; enum v4l2_field field;
@ -2209,8 +2197,7 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
static int bttv_querycap(struct file *file, void *priv, static int bttv_querycap(struct file *file, void *priv,
struct v4l2_capability *cap) struct v4l2_capability *cap)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (0 == v4l2) if (0 == v4l2)
return -EINVAL; return -EINVAL;
@ -2274,7 +2261,7 @@ static int bttv_querybuf(struct file *file, void *priv,
static int bttv_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) static int bttv_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
{ {
struct bttv_fh *fh = priv; struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
int res = bttv_resource(fh); int res = bttv_resource(fh);
if (!check_alloc_btres_lock(btv, fh, res)) if (!check_alloc_btres_lock(btv, fh, res))
@ -2322,8 +2309,7 @@ static int bttv_streamoff(struct file *file, void *priv,
static int bttv_g_parm(struct file *file, void *f, static int bttv_g_parm(struct file *file, void *f,
struct v4l2_streamparm *parm) struct v4l2_streamparm *parm)
{ {
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
@ -2337,8 +2323,7 @@ static int bttv_g_parm(struct file *file, void *f,
static int bttv_g_tuner(struct file *file, void *priv, static int bttv_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *t) struct v4l2_tuner *t)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
@ -2360,8 +2345,7 @@ static int bttv_g_tuner(struct file *file, void *priv,
static int bttv_g_pixelaspect(struct file *file, void *priv, static int bttv_g_pixelaspect(struct file *file, void *priv,
int type, struct v4l2_fract *f) int type, struct v4l2_fract *f)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
@ -2374,7 +2358,7 @@ static int bttv_g_pixelaspect(struct file *file, void *priv,
static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel) static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
{ {
struct bttv_fh *fh = f; struct bttv_fh *fh = f;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
@ -2404,7 +2388,7 @@ static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *s
static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel) static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
{ {
struct bttv_fh *fh = f; struct bttv_fh *fh = f;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
const struct v4l2_rect *b; const struct v4l2_rect *b;
int retval; int retval;
struct bttv_crop c; struct bttv_crop c;
@ -2781,7 +2765,7 @@ static int radio_open(struct file *file)
static int radio_release(struct file *file) static int radio_release(struct file *file)
{ {
struct bttv_fh *fh = file->private_data; struct bttv_fh *fh = file->private_data;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
struct saa6588_command cmd; struct saa6588_command cmd;
file->private_data = NULL; file->private_data = NULL;
@ -2800,8 +2784,7 @@ static int radio_release(struct file *file)
static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
@ -2823,8 +2806,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
static int radio_s_tuner(struct file *file, void *priv, static int radio_s_tuner(struct file *file, void *priv,
const struct v4l2_tuner *t) const struct v4l2_tuner *t)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
@ -2837,8 +2819,7 @@ static int radio_s_tuner(struct file *file, void *priv,
static int radio_s_hw_freq_seek(struct file *file, void *priv, static int radio_s_hw_freq_seek(struct file *file, void *priv,
const struct v4l2_hw_freq_seek *a) const struct v4l2_hw_freq_seek *a)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (btv->has_tea575x) if (btv->has_tea575x)
return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a); return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a);
@ -2849,8 +2830,7 @@ static int radio_s_hw_freq_seek(struct file *file, void *priv,
static int radio_enum_freq_bands(struct file *file, void *priv, static int radio_enum_freq_bands(struct file *file, void *priv,
struct v4l2_frequency_band *band) struct v4l2_frequency_band *band)
{ {
struct bttv_fh *fh = priv; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
if (btv->has_tea575x) if (btv->has_tea575x)
return snd_tea575x_enum_freq_bands(&btv->tea, band); return snd_tea575x_enum_freq_bands(&btv->tea, band);
@ -2861,8 +2841,7 @@ static int radio_enum_freq_bands(struct file *file, void *priv,
static ssize_t radio_read(struct file *file, char __user *data, static ssize_t radio_read(struct file *file, char __user *data,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct bttv_fh *fh = file->private_data; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
struct saa6588_command cmd; struct saa6588_command cmd;
cmd.block_count = count / 3; cmd.block_count = count / 3;
@ -2880,7 +2859,7 @@ static ssize_t radio_read(struct file *file, char __user *data,
static __poll_t radio_poll(struct file *file, poll_table *wait) static __poll_t radio_poll(struct file *file, poll_table *wait)
{ {
struct bttv_fh *fh = file->private_data; struct bttv_fh *fh = file->private_data;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
__poll_t req_events = poll_requested_events(wait); __poll_t req_events = poll_requested_events(wait);
struct saa6588_command cmd; struct saa6588_command cmd;
__poll_t res = 0; __poll_t res = 0;

View File

@ -299,8 +299,7 @@ static int try_fmt(struct v4l2_vbi_format *f, const struct bttv_tvnorm *tvnorm,
int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt) int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
{ {
struct bttv_fh *fh = f; struct bttv *btv = video_drvdata(file);
struct bttv *btv = fh->btv;
const struct bttv_tvnorm *tvnorm; const struct bttv_tvnorm *tvnorm;
__s32 crop_start; __s32 crop_start;
@ -318,7 +317,7 @@ int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt) int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
{ {
struct bttv_fh *fh = f; struct bttv_fh *fh = f;
struct bttv *btv = fh->btv; struct bttv *btv = video_drvdata(file);
const struct bttv_tvnorm *tvnorm; const struct bttv_tvnorm *tvnorm;
__s32 start1, end; __s32 start1, end;
int rc; int rc;
@ -367,10 +366,11 @@ int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
{ {
struct bttv_fh *fh = f; struct bttv_fh *fh = f;
const struct bttv_tvnorm *tvnorm; const struct bttv_tvnorm *tvnorm;
struct bttv *btv = video_drvdata(file);
frt->fmt.vbi = fh->vbi_fmt.fmt; frt->fmt.vbi = fh->vbi_fmt.fmt;
tvnorm = &bttv_tvnorms[fh->btv->tvnorm]; tvnorm = &bttv_tvnorms[btv->tvnorm];
if (tvnorm != fh->vbi_fmt.tvnorm) { if (tvnorm != fh->vbi_fmt.tvnorm) {
__s32 max_end; __s32 max_end;