All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, Rui Miguel Silva <rmfrfs@gmail.com>,
	kernel@pengutronix.de, linux-imx@nxp.com,
	Paul Elder <paul.elder@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCH 1/4] media: imx: imx-mipi-csis: Don't use .s_power()
Date: Fri, 11 Mar 2022 17:34:43 +0100	[thread overview]
Message-ID: <20220311163443.f6yxh23gqm7x5r3p@uno.localdomain> (raw)
In-Reply-To: <20220311135535.30108-2-laurent.pinchart@ideasonboard.com>

Hi Laurent

On Fri, Mar 11, 2022 at 03:55:32PM +0200, Laurent Pinchart wrote:
> The subdev .s_power() operation is deprecated. Drop it, requiring sensor
> drivers to correctly use runtime PM instead of relying on .s_power().
>
> As this driver has just been moved out of staging, and necessary drivers
> to implement a full camera pipeline are still in staging, no platform
> depends yet on this API being called. There is thus no risk of
> regression.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/media/platform/imx/imx-mipi-csis.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c
> index 7baedc854186..6e06d19c1334 100644
> --- a/drivers/media/platform/imx/imx-mipi-csis.c
> +++ b/drivers/media/platform/imx/imx-mipi-csis.c
> @@ -937,7 +937,7 @@ static struct mipi_csis_device *sd_to_mipi_csis_device(struct v4l2_subdev *sdev)
>  static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>  {
>  	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> -	int ret;
> +	int ret = 0;
>
>  	if (enable) {
>  		ret = mipi_csis_calculate_params(csis);
> @@ -949,10 +949,6 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>  		ret = pm_runtime_resume_and_get(csis->dev);
>  		if (ret < 0)
>  			return ret;
> -
> -		ret = v4l2_subdev_call(csis->src_sd, core, s_power, 1);
> -		if (ret < 0 && ret != -ENOIOCTLCMD)
> -			goto done;
>  	}
>
>  	mutex_lock(&csis->lock);
> @@ -973,9 +969,7 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>  		csis->state |= ST_STREAMING;
>  	} else {
>  		v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
> -		ret = v4l2_subdev_call(csis->src_sd, core, s_power, 0);
> -		if (ret == -ENOIOCTLCMD)
> -			ret = 0;
> +

I think mipi_csis_s_stream() could be simplified even more

Now it looks like

                if (enable) {
                        pm_resume_and_get();
                        ...
                }

                mutex_lock();

                if (enable) {

                } else {

                }

        out:
                mutex_unlock()
                if (ret < 0 || !enable)
                        pm_runtime_put()

                return ret;

Would it look better as

                if (!enable) {
                        lock();
                        ...
                        pm_runtime_put();
                        ...
                        unlock();
                        return;
                }

                /* non critical section stuff */
                pm_resume_and_get();

                lock();

                /* critical section stuff */
                if (ret)
                        goto out;

                unlock();

                return 0;

        out:
                pm_runtime_put();
                return ret;

This patch is good though, so the rework if desired can be done on top
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j
>  		mipi_csis_stop_stream(csis);
>  		csis->state &= ~ST_STREAMING;
>  		if (csis->debug.enable)
> @@ -985,7 +979,6 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>  unlock:
>  	mutex_unlock(&csis->lock);
>
> -done:
>  	if (!enable || ret < 0)
>  		pm_runtime_put(csis->dev);
>
> --
> Regards,
>
> Laurent Pinchart
>

  reply	other threads:[~2022-03-11 16:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 13:55 [PATCH 0/4] media: imx: imx-mipi-csis: Simplify PM support Laurent Pinchart
2022-03-11 13:55 ` [PATCH 1/4] media: imx: imx-mipi-csis: Don't use .s_power() Laurent Pinchart
2022-03-11 16:34   ` Jacopo Mondi [this message]
2022-03-11 17:05     ` Laurent Pinchart
2022-03-11 13:55 ` [PATCH 2/4] media: imx: imx-mipi-csis: Drop unneeded system PM implementation Laurent Pinchart
2022-03-11 16:53   ` Jacopo Mondi
2022-03-11 17:07     ` Laurent Pinchart
2022-03-11 17:19       ` Jacopo Mondi
2022-03-11 13:55 ` [PATCH 3/4] media: imx: imx-mipi-csis: Don't stop streaming at runtime suspend time Laurent Pinchart
2022-03-11 16:55   ` Jacopo Mondi
2022-03-11 13:55 ` [PATCH 4/4] media: imx: imx-mipi-csis: Simplify runtime PM implementation Laurent Pinchart
2022-03-11 17:00   ` Jacopo Mondi
2022-03-11 17:09     ` Laurent Pinchart
2022-03-12 15:30       ` Jacopo Mondi
2022-03-12 22:18   ` Sakari Ailus
2022-03-12 22:20     ` Sakari Ailus
2022-03-11 14:00 ` [PATCH 0/4] media: imx: imx-mipi-csis: Simplify PM support Laurent Pinchart
2022-03-12 15:25 ` [PATCH 1/2] media: imx: imx-mipi-csis: Simplify mipi_csis_s_stream() Jacopo Mondi
2022-03-12 20:17   ` Laurent Pinchart
2022-03-12 15:25 ` [PATCH 2/2] media: imx: imx-mipi-csis: Drop powered flag Jacopo Mondi
2022-03-12 18:50   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220311163443.f6yxh23gqm7x5r3p@uno.localdomain \
    --to=jacopo@jmondi.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-media@vger.kernel.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=rmfrfs@gmail.com \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.