drivers: media: remove V4L2_FL_USES_V4L2_FH
PATCH 1/1 drivers: media: remove V4L2_FL_USES_V4L2_FH
As usage of the feature is mandatory there is no point in keeping the flag for it.
--- drivers/media/v4l2-core/v4l2-dev.c | 8 -------- drivers/media/v4l2-core/v4l2-fh.c | 1 - include/media/v4l2-dev.h | 5 ----- 3 files changed, 14 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +0 -8
@@ -431,14 +431,6 @@ static int v4l2_open(struct inode *inode, struct file *filp) } ret = vdev->fops->open (filp); -if (ret) - goto done; - -/* All drivers must use v4l2_fh. */ -if (WARN_ON (!test_bit (V4L2_FL_USES_V4L2_FH , &vdev->flags))) { - vdev->fops->release (filp); - ret = -ENODEV ; - } done:if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP )
drivers/media/v4l2-core/v4l2-fh.c +0 -1
@@ -24,7 +24,6 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)/* Inherit from video_device. May be overridden by the driver. */ fh->ctrl_handler = vdev->ctrl_handler;INIT_LIST_HEAD (&fh->list); -set_bit (V4L2_FL_USES_V4L2_FH , &fh->vdev->flags);/* * determine_valid_ioctls() does not know if struct v4l2_fh * is used by this driver, but here we do. So enable the
include/media/v4l2-dev.h +0 -5
@@ -71,10 +71,6 @@ struct dentry;* indicates that a &struct video_device is registered. * Drivers can clear this flag if they want to block all future * device access. It is cleared by video_unregister_device. -* @V4L2_FL_USES_V4L2_FH: -* indicates that file->private_data points to &struct v4l2_fh. -* This flag is set by the core when v4l2_fh_init() is called. -* All drivers must use it. * @V4L2_FL_QUIRK_INVERTED_CROP: * some old M2M drivers use g/s_crop/cropcap incorrectly: crop and * compose are swapped. If this flag is set, then the selection
@@ -92,7 +88,6 @@ struct dentry;*/ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 , -V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , };
Signature · 1 line
2.53.0
Hi Oliver,
Thank you for the patch.
Quoted 2 lines · Oliver Neukum
As usage of the feature is mandatory there is no point in keeping the flag for it.
The point of the flag is to make sure all drivers call v4l2_fh_init() (directly our by using the v4l2_fh_open() helper), as part of the transition towards making this mandatory. This was merged in v6.18. As I haven't heard of any regression, I assume all commonly used drivers have been properly converted. Less commonly used drivers, however, may not have been tested correctly. If we drop this flag now we'll crash instead of returning an error. I feel we should keep the safeguard for a while still, ideally replacing it with a mechanism that ensures all drivers use the V4L2 fh API.
Quoted 61 lines
Signed-off-by Oliver Neukum <[email protected]>--- drivers/media/v4l2-core/v4l2-dev.c | 8 -------- drivers/media/v4l2-core/v4l2-fh.c | 1 - include/media/v4l2-dev.h | 5 ----- 3 files changed, 14 deletions(-)drivers/media/v4l2-core/v4l2-dev.c +0
-8@@ -431,14 +431,6 @@ static int v4l2_open(struct inode *inode, struct file *filp) } ret = vdev->fops->open (filp); -if (ret) - goto done; - -/* All drivers must use v4l2_fh. */ -if (WARN_ON (!test_bit (V4L2_FL_USES_V4L2_FH , &vdev->flags))) { - vdev->fops->release (filp); - ret = -ENODEV ; - } done:if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP )drivers/media/v4l2-core/v4l2-fh.c +0
-1@@ -24,7 +24,6 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)/* Inherit from video_device. May be overridden by the driver. */ fh->ctrl_handler = vdev->ctrl_handler;INIT_LIST_HEAD (&fh->list); -set_bit (V4L2_FL_USES_V4L2_FH , &fh->vdev->flags);/* * determine_valid_ioctls() does not know if struct v4l2_fh * is used by this driver, but here we do. So enable the include/media/v4l2-dev.h +0
-5@@ -71,10 +71,6 @@ struct dentry;* indicates that a &struct video_device is registered. * Drivers can clear this flag if they want to block all future * device access. It is cleared by video_unregister_device. -* @V4L2_FL_USES_V4L2_FH: -* indicates that file->private_data points to &struct v4l2_fh. -* This flag is set by the core when v4l2_fh_init() is called. -* All drivers must use it. * @V4L2_FL_QUIRK_INVERTED_CROP: * some old M2M drivers use g/s_crop/cropcap incorrectly: crop and * compose are swapped. If this flag is set, then the selection @@ -92,7 +88,6 @@ struct dentry;*/ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 , -V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , };
Signature · 3 lines
Regards, Laurent Pinchart