diff mbox series

[42/57] media: i2c: imx219: Drop system suspend and resume handlers

Message ID 20230914181704.4811-43-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series media: i2c: Reduce cargo cult | expand

Commit Message

Laurent Pinchart Sept. 14, 2023, 6:16 p.m. UTC
Stopping streaming on a camera pipeline at system suspend time, and
restarting it at system resume time, requires coordinated action between
the bridge driver and the camera sensor driver. This is handled by the
bridge driver calling the sensor's .s_stream() handler at system suspend
and resume time. There is thus no need for the sensor to independently
implement system sleep PM operations. Drop them.

The streaming field of the driver's private structure is now unused,
drop it as well.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/i2c/imx219.c | 41 --------------------------------------
 1 file changed, 41 deletions(-)

Comments

Dave Stevenson Sept. 15, 2023, 10:53 a.m. UTC | #1
Hi Laurent

On Thu, 14 Sept 2023 at 19:17, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Stopping streaming on a camera pipeline at system suspend time, and
> restarting it at system resume time, requires coordinated action between
> the bridge driver and the camera sensor driver. This is handled by the
> bridge driver calling the sensor's .s_stream() handler at system suspend
> and resume time. There is thus no need for the sensor to independently
> implement system sleep PM operations. Drop them.
>
> The streaming field of the driver's private structure is now unused,
> drop it as well.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Presumably this is superseding effectively the same patch in your
other imx219 series [1]
That's fine by me, just an observation.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

[1] https://patchwork.linuxtv.org/project/linux-media/patch/20230913135638.26277-16-laurent.pinchart@ideasonboard.com/

> ---
>  drivers/media/i2c/imx219.c | 41 --------------------------------------
>  1 file changed, 41 deletions(-)
>
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 5715bbbc0820..a431dace0f33 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -479,9 +479,6 @@ struct imx219 {
>         /* Current mode */
>         const struct imx219_mode *mode;
>
> -       /* Streaming on/off */
> -       bool streaming;
> -
>         /* Two or Four lanes */
>         u8 lanes;
>  };
> @@ -991,8 +988,6 @@ static int imx219_set_stream(struct v4l2_subdev *sd, int enable)
>                 imx219_stop_streaming(imx219);
>         }
>
> -       imx219->streaming = enable;
> -
>  unlock:
>         v4l2_subdev_unlock_state(state);
>         return ret;
> @@ -1044,41 +1039,6 @@ static int imx219_power_off(struct device *dev)
>         return 0;
>  }
>
> -static int __maybe_unused imx219_suspend(struct device *dev)
> -{
> -       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> -       struct imx219 *imx219 = to_imx219(sd);
> -
> -       if (imx219->streaming)
> -               imx219_stop_streaming(imx219);
> -
> -       return 0;
> -}
> -
> -static int __maybe_unused imx219_resume(struct device *dev)
> -{
> -       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> -       struct imx219 *imx219 = to_imx219(sd);
> -       struct v4l2_subdev_state *state;
> -       int ret;
> -
> -       if (imx219->streaming) {
> -               state = v4l2_subdev_lock_and_get_active_state(sd);
> -               ret = imx219_start_streaming(imx219, state);
> -               v4l2_subdev_unlock_state(state);
> -               if (ret)
> -                       goto error;
> -       }
> -
> -       return 0;
> -
> -error:
> -       imx219_stop_streaming(imx219);
> -       imx219->streaming = false;
> -
> -       return ret;
> -}
> -
>  static int imx219_get_regulators(struct imx219 *imx219)
>  {
>         struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
> @@ -1464,7 +1424,6 @@ static const struct of_device_id imx219_dt_ids[] = {
>  MODULE_DEVICE_TABLE(of, imx219_dt_ids);
>
>  static const struct dev_pm_ops imx219_pm_ops = {
> -       SET_SYSTEM_SLEEP_PM_OPS(imx219_suspend, imx219_resume)
>         SET_RUNTIME_PM_OPS(imx219_power_off, imx219_power_on, NULL)
>  };
>
> --
> Regards,
>
> Laurent Pinchart
>
Laurent Pinchart Sept. 15, 2023, 11:35 a.m. UTC | #2
Hi Dave,

On Fri, Sep 15, 2023 at 11:53:53AM +0100, Dave Stevenson wrote:
> On Thu, 14 Sept 2023 at 19:17, Laurent Pinchart wrote:
> >
> > Stopping streaming on a camera pipeline at system suspend time, and
> > restarting it at system resume time, requires coordinated action between
> > the bridge driver and the camera sensor driver. This is handled by the
> > bridge driver calling the sensor's .s_stream() handler at system suspend
> > and resume time. There is thus no need for the sensor to independently
> > implement system sleep PM operations. Drop them.
> >
> > The streaming field of the driver's private structure is now unused,
> > drop it as well.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Presumably this is superseding effectively the same patch in your
> other imx219 series [1]
> That's fine by me, just an observation.

Good catch :-) The two series indeed fix the same issue. I have included
the imx219 changes in this series for completeness, I'll drop it from
one of the two series depending on which of them gets merged first.

Sorry for forgetting to mention this in the cover letter.

> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> 
> [1] https://patchwork.linuxtv.org/project/linux-media/patch/20230913135638.26277-16-laurent.pinchart@ideasonboard.com/
> 
> > ---
> >  drivers/media/i2c/imx219.c | 41 --------------------------------------
> >  1 file changed, 41 deletions(-)
> >
> > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> > index 5715bbbc0820..a431dace0f33 100644
> > --- a/drivers/media/i2c/imx219.c
> > +++ b/drivers/media/i2c/imx219.c
> > @@ -479,9 +479,6 @@ struct imx219 {
> >         /* Current mode */
> >         const struct imx219_mode *mode;
> >
> > -       /* Streaming on/off */
> > -       bool streaming;
> > -
> >         /* Two or Four lanes */
> >         u8 lanes;
> >  };
> > @@ -991,8 +988,6 @@ static int imx219_set_stream(struct v4l2_subdev *sd, int enable)
> >                 imx219_stop_streaming(imx219);
> >         }
> >
> > -       imx219->streaming = enable;
> > -
> >  unlock:
> >         v4l2_subdev_unlock_state(state);
> >         return ret;
> > @@ -1044,41 +1039,6 @@ static int imx219_power_off(struct device *dev)
> >         return 0;
> >  }
> >
> > -static int __maybe_unused imx219_suspend(struct device *dev)
> > -{
> > -       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> > -       struct imx219 *imx219 = to_imx219(sd);
> > -
> > -       if (imx219->streaming)
> > -               imx219_stop_streaming(imx219);
> > -
> > -       return 0;
> > -}
> > -
> > -static int __maybe_unused imx219_resume(struct device *dev)
> > -{
> > -       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> > -       struct imx219 *imx219 = to_imx219(sd);
> > -       struct v4l2_subdev_state *state;
> > -       int ret;
> > -
> > -       if (imx219->streaming) {
> > -               state = v4l2_subdev_lock_and_get_active_state(sd);
> > -               ret = imx219_start_streaming(imx219, state);
> > -               v4l2_subdev_unlock_state(state);
> > -               if (ret)
> > -                       goto error;
> > -       }
> > -
> > -       return 0;
> > -
> > -error:
> > -       imx219_stop_streaming(imx219);
> > -       imx219->streaming = false;
> > -
> > -       return ret;
> > -}
> > -
> >  static int imx219_get_regulators(struct imx219 *imx219)
> >  {
> >         struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
> > @@ -1464,7 +1424,6 @@ static const struct of_device_id imx219_dt_ids[] = {
> >  MODULE_DEVICE_TABLE(of, imx219_dt_ids);
> >
> >  static const struct dev_pm_ops imx219_pm_ops = {
> > -       SET_SYSTEM_SLEEP_PM_OPS(imx219_suspend, imx219_resume)
> >         SET_RUNTIME_PM_OPS(imx219_power_off, imx219_power_on, NULL)
> >  };
> >
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 5715bbbc0820..a431dace0f33 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -479,9 +479,6 @@  struct imx219 {
 	/* Current mode */
 	const struct imx219_mode *mode;
 
-	/* Streaming on/off */
-	bool streaming;
-
 	/* Two or Four lanes */
 	u8 lanes;
 };
@@ -991,8 +988,6 @@  static int imx219_set_stream(struct v4l2_subdev *sd, int enable)
 		imx219_stop_streaming(imx219);
 	}
 
-	imx219->streaming = enable;
-
 unlock:
 	v4l2_subdev_unlock_state(state);
 	return ret;
@@ -1044,41 +1039,6 @@  static int imx219_power_off(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused imx219_suspend(struct device *dev)
-{
-	struct v4l2_subdev *sd = dev_get_drvdata(dev);
-	struct imx219 *imx219 = to_imx219(sd);
-
-	if (imx219->streaming)
-		imx219_stop_streaming(imx219);
-
-	return 0;
-}
-
-static int __maybe_unused imx219_resume(struct device *dev)
-{
-	struct v4l2_subdev *sd = dev_get_drvdata(dev);
-	struct imx219 *imx219 = to_imx219(sd);
-	struct v4l2_subdev_state *state;
-	int ret;
-
-	if (imx219->streaming) {
-		state = v4l2_subdev_lock_and_get_active_state(sd);
-		ret = imx219_start_streaming(imx219, state);
-		v4l2_subdev_unlock_state(state);
-		if (ret)
-			goto error;
-	}
-
-	return 0;
-
-error:
-	imx219_stop_streaming(imx219);
-	imx219->streaming = false;
-
-	return ret;
-}
-
 static int imx219_get_regulators(struct imx219 *imx219)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
@@ -1464,7 +1424,6 @@  static const struct of_device_id imx219_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, imx219_dt_ids);
 
 static const struct dev_pm_ops imx219_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(imx219_suspend, imx219_resume)
 	SET_RUNTIME_PM_OPS(imx219_power_off, imx219_power_on, NULL)
 };