From: Laurent Pinchart <laurent.pinch...@ideasonboard.com>

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 <laurent.pinch...@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mo...@ideasonboard.com>
---
 drivers/staging/most/video/video.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index 
2b3cdb1ce1404cd13655c780f1215c364ce1a70f..bce7ffeac8fe50d3442f4993ae49ab5fc96ec3cd
 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 @@ static int comp_vdev_open(struct file *filp)
 
 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;
 

-- 
2.49.0



_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to