Message ID | 20240416193319.778192-20-sakari.ailus@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Generic line based metadata support, internal pads | expand |
Hi Sakari, Thank you for the patch. On Tue, Apr 16, 2024 at 10:32:52PM +0300, Sakari Ailus wrote: > 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> > --- > drivers/media/i2c/ccs/ccs-core.c | 73 ++++++++++++++++---------------- > 1 file changed, 37 insertions(+), 36 deletions(-) > > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c > index 7e5474e38732..d7bc9418eabb 100644 > --- a/drivers/media/i2c/ccs/ccs-core.c > +++ b/drivers/media/i2c/ccs/ccs-core.c > @@ -1718,6 +1718,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); > @@ -1872,42 +1909,6 @@ static int ccs_stop_streaming(struct ccs_sensor *sensor) > * 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);
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 7e5474e38732..d7bc9418eabb 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1718,6 +1718,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); @@ -1872,42 +1909,6 @@ static int ccs_stop_streaming(struct ccs_sensor *sensor) * 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);
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> --- drivers/media/i2c/ccs/ccs-core.c | 73 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 36 deletions(-)