From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Jai Luthra <jai.luthra@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Tommaso Merciai <tomm.merciai@gmail.com>
Subject: Re: [PATCH v2 5/8] media: imx335: Handle runtime PM in leaf functions
Date: Thu, 11 Sep 2025 12:14:45 +0100 [thread overview]
Message-ID: <175758928516.1246375.13284167198046981915@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <20250911-imx335_binning-v2-5-30a28df74df6@ideasonboard.com>
Quoting Jai Luthra (2025-09-11 09:14:21)
> Simplify .s_stream callback implementation by moving the runtime PM
> calls to the leaf functions. This patch should not affect any
> functionality.
>
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Looks reasonable to me and although the stop_streaming function changes
to no longer return a value - it was previously unused so no functional
change indeed as far as I can see:
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> drivers/media/i2c/imx335.c | 51 ++++++++++++++++++++--------------------------
> 1 file changed, 22 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c
> index 62a76517ecb263a4fd7e7a593c02a3cdaf3da190..7631f41e6f1e65695fb76a66d9ac5a3588c69658 100644
> --- a/drivers/media/i2c/imx335.c
> +++ b/drivers/media/i2c/imx335.c
> @@ -919,13 +919,17 @@ static int imx335_start_streaming(struct imx335 *imx335)
> const struct imx335_reg_list *reg_list;
> int ret;
>
> + ret = pm_runtime_resume_and_get(imx335->dev);
> + if (ret < 0)
> + return ret;
> +
> /* Setup PLL */
> reg_list = &link_freq_reglist[__ffs(imx335->link_freq_bitmap)];
> ret = cci_multi_reg_write(imx335->cci, reg_list->regs,
> reg_list->num_of_regs, NULL);
> if (ret) {
> dev_err(imx335->dev, "%s failed to set plls\n", __func__);
> - return ret;
> + goto err_rpm_put;
> }
>
> /* Write sensor mode registers */
> @@ -934,27 +938,27 @@ static int imx335_start_streaming(struct imx335 *imx335)
> reg_list->num_of_regs, NULL);
> if (ret) {
> dev_err(imx335->dev, "fail to write initial registers\n");
> - return ret;
> + goto err_rpm_put;
> }
>
> ret = imx335_set_framefmt(imx335);
> if (ret) {
> dev_err(imx335->dev, "%s failed to set frame format: %d\n",
> __func__, ret);
> - return ret;
> + goto err_rpm_put;
> }
>
> /* Configure lanes */
> ret = cci_write(imx335->cci, IMX335_REG_LANEMODE,
> imx335->lane_mode, NULL);
> if (ret)
> - return ret;
> + goto err_rpm_put;
>
> /* Setup handler will write actual exposure and gain */
> ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler);
> if (ret) {
> dev_err(imx335->dev, "fail to setup handler\n");
> - return ret;
> + goto err_rpm_put;
> }
>
> /* Start streaming */
> @@ -962,25 +966,29 @@ static int imx335_start_streaming(struct imx335 *imx335)
> IMX335_MODE_STREAMING, NULL);
> if (ret) {
> dev_err(imx335->dev, "fail to start streaming\n");
> - return ret;
> + goto err_rpm_put;
> }
>
> /* Initial regulator stabilization period */
> usleep_range(18000, 20000);
>
> return 0;
> +
> +err_rpm_put:
> + pm_runtime_put(imx335->dev);
> +
> + return ret;
> }
>
> /**
> * imx335_stop_streaming() - Stop sensor stream
> * @imx335: pointer to imx335 device
> - *
> - * Return: 0 if successful, error code otherwise.
> */
> -static int imx335_stop_streaming(struct imx335 *imx335)
> +static void imx335_stop_streaming(struct imx335 *imx335)
> {
> - return cci_write(imx335->cci, IMX335_REG_MODE_SELECT,
> - IMX335_MODE_STANDBY, NULL);
> + cci_write(imx335->cci, IMX335_REG_MODE_SELECT,
> + IMX335_MODE_STANDBY, NULL);
> + pm_runtime_put(imx335->dev);
> }
>
> /**
> @@ -993,30 +1001,15 @@ static int imx335_stop_streaming(struct imx335 *imx335)
> static int imx335_set_stream(struct v4l2_subdev *sd, int enable)
> {
> struct imx335 *imx335 = to_imx335(sd);
> - int ret;
> + int ret = 0;
>
> mutex_lock(&imx335->mutex);
>
> - if (enable) {
> - ret = pm_runtime_resume_and_get(imx335->dev);
> - if (ret)
> - goto error_unlock;
> -
> + if (enable)
> ret = imx335_start_streaming(imx335);
> - if (ret)
> - goto error_power_off;
> - } else {
> + else
> imx335_stop_streaming(imx335);
> - pm_runtime_put(imx335->dev);
> - }
> -
> - mutex_unlock(&imx335->mutex);
>
> - return 0;
> -
> -error_power_off:
> - pm_runtime_put(imx335->dev);
> -error_unlock:
> mutex_unlock(&imx335->mutex);
>
> return ret;
>
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-09-11 11:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 8:14 [PATCH v2 0/8] media: imx335: Vflip, active state and binning support Jai Luthra
2025-09-11 8:14 ` [PATCH v2 1/8] media: imx335: Rectify name of mode struct Jai Luthra
2025-09-11 8:14 ` [PATCH v2 2/8] media: imx335: Support vertical flip Jai Luthra
2025-09-11 8:14 ` [PATCH v2 3/8] media: imx335: Update the native pixel array width Jai Luthra
2025-09-11 8:14 ` [PATCH v2 4/8] media: imx335: Update HBLANK range on mode change Jai Luthra
2025-09-11 8:14 ` [PATCH v2 5/8] media: imx335: Handle runtime PM in leaf functions Jai Luthra
2025-09-11 11:14 ` Kieran Bingham [this message]
2025-09-15 6:28 ` Jai Luthra
2025-09-11 8:14 ` [PATCH v2 6/8] media: imx355: Use subdev active state Jai Luthra
2025-09-11 14:30 ` Kieran Bingham
2025-09-11 8:14 ` [PATCH v2 7/8] media: imx335: Support 2x2 binning Jai Luthra
2025-09-11 11:51 ` Kieran Bingham
2025-09-11 8:14 ` [PATCH v2 8/8] media: imx335: Switch to {enable,disable}_streams Jai Luthra
2025-09-11 11:46 ` Kieran Bingham
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=175758928516.1246375.13284167198046981915@ping.linuxembedded.co.uk \
--to=kieran.bingham@ideasonboard.com \
--cc=jai.luthra@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tomm.merciai@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®