]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
v4l: subdev: Warn if disabling streaming failed, return success
authorSakari Ailus <sakari.ailus@linux.intel.com>
Mon, 17 Oct 2022 07:04:32 +0000 (10:04 +0300)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 27 Oct 2022 11:38:03 +0000 (14:38 +0300)
Complain in the newly added s_stream video op wrapper if disabling
streaming failed. Also return zero in this case as there's nothing the
caller can do to return the error.

This way drivers also won't need to bother with printing error messages.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
drivers/media/v4l2-core/v4l2-subdev.c
include/media/v4l2-subdev.h

index 5c27bac772ea4330f6e25f5bde6dbc9fd58bf218..8a4ca2bd1584dc4aa2cc66d429ac04f3c75442a4 100644 (file)
@@ -318,6 +318,20 @@ static int call_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
               sd->ops->pad->get_mbus_config(sd, pad, config);
 }
 
+static int call_s_stream(struct v4l2_subdev *sd, int enable)
+{
+       int ret;
+
+       ret = sd->ops->video->s_stream(sd, enable);
+
+       if (!enable && ret < 0) {
+               dev_warn(sd->dev, "disabling streaming failed (%d)\n", ret);
+               return 0;
+       }
+
+       return ret;
+}
+
 #ifdef CONFIG_MEDIA_CONTROLLER
 /*
  * Create state-management wrapper for pad ops dealing with subdev state. The
@@ -377,6 +391,7 @@ static const struct v4l2_subdev_pad_ops v4l2_subdev_call_pad_wrappers = {
 static const struct v4l2_subdev_video_ops v4l2_subdev_call_video_wrappers = {
        .g_frame_interval       = call_g_frame_interval,
        .s_frame_interval       = call_s_frame_interval,
+       .s_stream               = call_s_stream,
 };
 
 const struct v4l2_subdev_ops v4l2_subdev_call_wrappers = {
index 54566d139da7934778a96dc305b6e7ae5b346f2f..b15fa9930f30c16e5512fb8544c2cce9691c8bbe 100644 (file)
@@ -440,8 +440,10 @@ enum v4l2_subdev_pre_streamon_flags {
  * @g_input_status: get input status. Same as the status field in the
  *     &struct v4l2_input
  *
- * @s_stream: used to notify the driver that a video stream will start or has
- *     stopped.
+ * @s_stream: start (enabled == 1) or stop (enabled == 0) streaming on the
+ *     sub-device. Failure on stop will remove any resources acquired in
+ *     streaming start, while the error code is still returned by the driver.
+ *     Also see call_s_stream wrapper in v4l2-subdev.c.
  *
  * @g_pixelaspect: callback to return the pixelaspect ratio.
  *