From nobody Wed Dec 17 02:40:00 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF34334688; Thu, 30 Oct 2025 08:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761813822; cv=none; b=pYy2GzAZ5vB75FdNR/uBxTJeRdVgf+JueozwdtUsxdh6hVetYad+4YomhyKTb38KYNw4WhgGeSDys1DMtYoOpxUqlhF8ItNU82rMhC3nAEBg02vWJ7tbIlxLo9282MmBl/kFYiBr/lQ708Yaku0w3g7F5Ic7j3MHuH71o0qBPUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761813822; c=relaxed/simple; bh=DptlhcOCv/jEqQi8H1Qnjja+E+XZztRNKeEjDcwb0to=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P4+pJWVqGodn/POuivcw7mfqkASaL4HFU1+x4CgILPCik/nJCXwMwt3/hdI++1oNUz4Ko0S3qaLwd3JPHRcSfdhmR0xC5Tqr+Od/dr+9to1SHF7oIzt82pxreGgDWx5FnhSHdxmZwCE15nMNhArlT40zSnjH2rdYTlYu6yYB4Uc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=ZQhoRzoz; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZQhoRzoz" Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c69:314e:ee86:ae6e:30:9d13]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 51B85EAE; Thu, 30 Oct 2025 09:41:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761813709; bh=DptlhcOCv/jEqQi8H1Qnjja+E+XZztRNKeEjDcwb0to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQhoRzozdozkqobwZEG7sAV1jVq0Y3Bf5ufsrcw44qv9Tk81hfPEiMzWmSVEnfxCt r+S9osOCOvoUrD8trebtDmDhDtl2B8QlBTnYfCOcRx7t42W4xoDrPYUWMM/7N327Tm HPDaeHaZIRT/l7Um9t+gLSR/hwg6InDyOuOKblCs= From: Jai Luthra To: Kieran Bingham , Sakari Ailus , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Umang Jain , Jai Luthra Subject: [PATCH v4 5/8] media: imx335: Handle runtime PM in leaf functions Date: Thu, 30 Oct 2025 14:12:58 +0530 Message-ID: <20251030-imx335_binning-v4-5-534f82415aa7@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251030-imx335_binning-v4-0-534f82415aa7@ideasonboard.com> References: <20251030-imx335_binning-v4-0-534f82415aa7@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Simplify .s_stream callback implementation by moving the runtime PM calls to the leaf functions. This patch should not affect any functionality. Reviewed-by: Kieran Bingham Signed-off-by: Jai Luthra --- 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 77863a28c4725ae151ac60213ab05a46bd1549ee..5e18eb998f9d76907ef88cd09ee= 19e7afe9166e4 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -912,13 +912,17 @@ static int imx335_start_streaming(struct imx335 *imx3= 35) const struct imx335_reg_list *reg_list; int ret; =20 + ret =3D pm_runtime_resume_and_get(imx335->dev); + if (ret < 0) + return ret; + /* Setup PLL */ reg_list =3D &link_freq_reglist[__ffs(imx335->link_freq_bitmap)]; ret =3D 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; } =20 /* Write sensor mode registers */ @@ -927,27 +931,27 @@ static int imx335_start_streaming(struct imx335 *imx3= 35) reg_list->num_of_regs, NULL); if (ret) { dev_err(imx335->dev, "fail to write initial registers\n"); - return ret; + goto err_rpm_put; } =20 ret =3D 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; } =20 /* Configure lanes */ ret =3D cci_write(imx335->cci, IMX335_REG_LANEMODE, imx335->lane_mode, NULL); if (ret) - return ret; + goto err_rpm_put; =20 /* Setup handler will write actual exposure and gain */ ret =3D __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; } =20 /* Start streaming */ @@ -955,25 +959,29 @@ static int imx335_start_streaming(struct imx335 *imx3= 35) IMX335_MODE_STREAMING, NULL); if (ret) { dev_err(imx335->dev, "fail to start streaming\n"); - return ret; + goto err_rpm_put; } =20 /* Initial regulator stabilization period */ usleep_range(18000, 20000); =20 return 0; + +err_rpm_put: + pm_runtime_put(imx335->dev); + + return ret; } =20 /** * 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); } =20 /** @@ -986,30 +994,15 @@ static int imx335_stop_streaming(struct imx335 *imx33= 5) static int imx335_set_stream(struct v4l2_subdev *sd, int enable) { struct imx335 *imx335 =3D to_imx335(sd); - int ret; + int ret =3D 0; =20 mutex_lock(&imx335->mutex); =20 - if (enable) { - ret =3D pm_runtime_resume_and_get(imx335->dev); - if (ret) - goto error_unlock; - + if (enable) ret =3D 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); =20 - return 0; - -error_power_off: - pm_runtime_put(imx335->dev); -error_unlock: mutex_unlock(&imx335->mutex); =20 return ret; --=20 2.51.0