]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: ccs: Move ccs_pm_get_init function up
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 16 Apr 2024 08:09:57 +0000 (11:09 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 14 Jan 2026 22:33:02 +0000 (23:33 +0100)
Prepare for using ccs_pm_get_init from locations earlier than its the
current place.

Also add a missing newline while at it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/ccs/ccs-core.c

index c7ed90d9473a6732d4379da3103d687567d494a4..6e102f48f135d2d14e456390fe46f1be2a7c3162 100644 (file)
@@ -1712,6 +1712,43 @@ static int ccs_power_off(struct device *dev)
  * Video stream management
  */
 
+static int ccs_pm_get_init(struct ccs_sensor *sensor)
+{
+       struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+       int rval;
+
+       /*
+        * It can't use pm_runtime_resume_and_get() here, as the driver
+        * relies at the returned value to detect if the device was already
+        * active or not.
+        */
+       rval = pm_runtime_get_sync(&client->dev);
+       if (rval < 0)
+               goto error;
+
+       /* Device was already active, so don't set controls */
+       if (rval == 1 && !sensor->handler_setup_needed)
+               return 0;
+
+       sensor->handler_setup_needed = false;
+
+       /* Restore V4L2 controls to the previously suspended device */
+       rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler);
+       if (rval)
+               goto error;
+
+       rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler);
+       if (rval)
+               goto error;
+
+       /* Keep PM runtime usage_count incremented on success */
+       return 0;
+
+error:
+       pm_runtime_put(&client->dev);
+       return rval;
+}
+
 static int ccs_start_streaming(struct ccs_sensor *sensor)
 {
        struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
@@ -1866,42 +1903,6 @@ out:
  * V4L2 subdev video operations
  */
 
-static int ccs_pm_get_init(struct ccs_sensor *sensor)
-{
-       struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
-       int rval;
-
-       /*
-        * It can't use pm_runtime_resume_and_get() here, as the driver
-        * relies at the returned value to detect if the device was already
-        * active or not.
-        */
-       rval = pm_runtime_get_sync(&client->dev);
-       if (rval < 0)
-               goto error;
-
-       /* Device was already active, so don't set controls */
-       if (rval == 1 && !sensor->handler_setup_needed)
-               return 0;
-
-       sensor->handler_setup_needed = false;
-
-       /* Restore V4L2 controls to the previously suspended device */
-       rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler);
-       if (rval)
-               goto error;
-
-       rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler);
-       if (rval)
-               goto error;
-
-       /* Keep PM runtime usage_count incremented on success */
-       return 0;
-error:
-       pm_runtime_put(&client->dev);
-       return rval;
-}
-
 static int ccs_set_stream(struct v4l2_subdev *subdev, int enable)
 {
        struct ccs_sensor *sensor = to_ccs_sensor(subdev);