Re: [PATCH v7 08/18] media: sony-starvis2: Put module into standby after identify

From: Laurent Pinchart

Date: Sun Nov 29 2026 - 22:31:22 EST


On Thu, Oct 29, 2026 at 02:18:29PM +0000, Dave Stevenson wrote:
> The module has to be brought out of standby in order to read
> some of the identification registers. Whilst it would be
> powered down via pm_runtime, should that be disabled it would
> be left in streaming mode.
>
> Restore standby mode after identify.
>
> Signed-off-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
> ---
> drivers/media/i2c/sony-starvis2.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/i2c/sony-starvis2.c b/drivers/media/i2c/sony-starvis2.c
> index 84f3978e1eda..95da8a9e671e 100644
> --- a/drivers/media/i2c/sony-starvis2.c
> +++ b/drivers/media/i2c/sony-starvis2.c
> @@ -1162,7 +1162,8 @@ static int starvis2_identify_model(struct starvis2 *starvis2)
> * This sensor's ID registers become accessible 80ms after coming out
> * of STANDBY mode.
> */
> - cci_write(starvis2->cci, STARVIS2_REG_MODE_SELECT, 0, &ret);
> + cci_write(starvis2->cci, STARVIS2_REG_MODE_SELECT,
> + STARVIS2_MODE_STREAMING, &ret);
> fsleep(STARVIS2_MODULE_ID_DELAY);
>
> cci_read(starvis2->cci, variant->id_reg, &val, &ret);
> @@ -1170,14 +1171,15 @@ static int starvis2_identify_model(struct starvis2 *starvis2)
> if (ret) {
> dev_err(&client->dev,
> "I2C transaction failed ret = %d\n", ret);
> - return ret;
> + goto err_standby;
> }
>
> val &= variant->id_mask;
> if (val != variant->id_value) {
> dev_err(&client->dev, "Chip ID mismatch: %x!=%llx\n",
> variant->id_value, val);
> - return -ENXIO;
> + ret = -ENXIO;
> + goto err_standby;
> }
>
> cci_read(starvis2->cci, STARVIS2_REG_MONOCHROME, &val, &ret);
> @@ -1185,7 +1187,7 @@ static int starvis2_identify_model(struct starvis2 *starvis2)
> if (ret) {
> dev_err(&client->dev,
> "I2C transaction failed ret = %d\n", ret);
> - return ret;
> + goto err_standby;
> }
>
> detected = val & STARVIS2_TYPE;
> @@ -1207,7 +1209,10 @@ static int starvis2_identify_model(struct starvis2 *starvis2)
> }
> starvis2->variant = starvis2->info->variant;
>
> - return 0;
> +err_standby:

As the label is also reached in the non-error path, it shouldn't be
named 'err'. 'done' or 'out' are common options for this kind of cases.

> + cci_write(starvis2->cci, STARVIS2_REG_MODE_SELECT,
> + STARVIS2_MODE_STANDBY, NULL);
> + return ret;
> }
>
> static const struct v4l2_subdev_video_ops starvis2_video_ops = {

--
Regards,

Laurent Pinchart