media: allegro: Access v4l2_fh from file
The v4l2_fh associated with an open file handle is now guaranteed to be available in file->private_data, initialised by v4l2_fh_add(). Access the v4l2_fh, and from there the driver-specific structure, from the file * in all ioctl handlers. While at it remove the only left user of fh_to_channel() and remove the macro completely. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Michael Tretter <m.tretter@pengutronix.de> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
ae76d82230
commit
334f228752
@@ -197,8 +197,6 @@ static const struct regmap_config allegro_sram_config = {
|
||||
.cache_type = REGCACHE_NONE,
|
||||
};
|
||||
|
||||
#define fh_to_channel(__fh) container_of(__fh, struct allegro_channel, fh)
|
||||
|
||||
struct allegro_channel {
|
||||
struct allegro_dev *dev;
|
||||
struct v4l2_fh fh;
|
||||
@@ -3284,7 +3282,7 @@ static int allegro_enum_fmt_vid(struct file *file, void *fh,
|
||||
static int allegro_g_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
|
||||
f->fmt.pix.field = V4L2_FIELD_NONE;
|
||||
f->fmt.pix.width = channel->width;
|
||||
@@ -3326,7 +3324,7 @@ static int allegro_try_fmt_vid_cap(struct file *file, void *fh,
|
||||
static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
struct vb2_queue *vq;
|
||||
int err;
|
||||
|
||||
@@ -3350,7 +3348,7 @@ static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
|
||||
static int allegro_g_fmt_vid_out(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
|
||||
f->fmt.pix.field = V4L2_FIELD_NONE;
|
||||
|
||||
@@ -3397,7 +3395,7 @@ static int allegro_try_fmt_vid_out(struct file *file, void *fh,
|
||||
static int allegro_s_fmt_vid_out(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
int err;
|
||||
|
||||
err = allegro_try_fmt_vid_out(file, fh, f);
|
||||
@@ -3438,7 +3436,7 @@ static int allegro_channel_cmd_start(struct allegro_channel *channel)
|
||||
static int allegro_encoder_cmd(struct file *file, void *fh,
|
||||
struct v4l2_encoder_cmd *cmd)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
int err;
|
||||
|
||||
err = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, cmd);
|
||||
@@ -3487,8 +3485,7 @@ static int allegro_enum_framesizes(struct file *file, void *fh,
|
||||
static int allegro_ioctl_streamon(struct file *file, void *priv,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
struct v4l2_fh *fh = file_to_v4l2_fh(file);
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
int err;
|
||||
|
||||
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
||||
@@ -3497,13 +3494,13 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
|
||||
return err;
|
||||
}
|
||||
|
||||
return v4l2_m2m_streamon(file, fh->m2m_ctx, type);
|
||||
return v4l2_m2m_streamon(file, channel->fh.m2m_ctx, type);
|
||||
}
|
||||
|
||||
static int allegro_g_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *a)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
struct v4l2_fract *timeperframe;
|
||||
|
||||
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
|
||||
@@ -3520,7 +3517,7 @@ static int allegro_g_parm(struct file *file, void *fh,
|
||||
static int allegro_s_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *a)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(fh);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
struct v4l2_fract *timeperframe;
|
||||
int div;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user