From: Laurent Pinchart Date: Sun, 10 Aug 2025 01:29:49 +0000 (+0300) Subject: media: staging: most: Store v4l2_fh pointer in file->private_data X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0fd7155307bebb7daf946abae0ee8e50d20819ed;p=users%2Fhch%2Fmisc.git media: staging: most: Store v4l2_fh pointer in file->private_data Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The most driver instead stores the pointer to the driver-specific structure that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer itself to standardize behaviour across drivers. This also prepares for future refactoring that depends on v4l2_fh being stored in private_data. Signed-off-by: Laurent Pinchart Signed-off-by: Hans Verkuil --- diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 2b3cdb1ce140..bce7ffeac8fe 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -52,6 +52,11 @@ struct comp_fh { u32 offs; }; +static inline struct comp_fh *to_comp_fh(struct file *filp) +{ + return container_of(filp->private_data, struct comp_fh, fh); +} + static LIST_HEAD(video_devices); static DEFINE_SPINLOCK(list_lock); @@ -91,7 +96,7 @@ static int comp_vdev_open(struct file *filp) fh->mdev = mdev; v4l2_fh_init(&fh->fh, vdev); - filp->private_data = fh; + filp->private_data = &fh->fh; v4l2_fh_add(&fh->fh); @@ -115,7 +120,7 @@ err_dec: static int comp_vdev_close(struct file *filp) { - struct comp_fh *fh = filp->private_data; + struct comp_fh *fh = to_comp_fh(filp); struct most_video_dev *mdev = fh->mdev; struct mbo *mbo, *tmp; @@ -151,7 +156,7 @@ static int comp_vdev_close(struct file *filp) static ssize_t comp_vdev_read(struct file *filp, char __user *buf, size_t count, loff_t *pos) { - struct comp_fh *fh = filp->private_data; + struct comp_fh *fh = to_comp_fh(filp); struct most_video_dev *mdev = fh->mdev; int ret = 0; @@ -200,7 +205,7 @@ static ssize_t comp_vdev_read(struct file *filp, char __user *buf, static __poll_t comp_vdev_poll(struct file *filp, poll_table *wait) { - struct comp_fh *fh = filp->private_data; + struct comp_fh *fh = to_comp_fh(filp); struct most_video_dev *mdev = fh->mdev; __poll_t mask = 0;