RE: [PATCH v10 2/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks
From: G.N. Zhou (OSS) <hidden>
Date: 2026-03-23 08:35:09
Also in:
imx, linux-devicetree, linux-media, lkml
Hi Laurent, Thanks for your review.
-----Original Message----- From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Sent: Friday, March 20, 2026 7:23 AM To: G.N. Zhou (OSS) <redacted> Cc: Rui Miguel Silva <rmfrfs@gmail.com>; Martin Kepplinger [off-list ref]; Purism Kernel Team [off-list ref]; Mauro Carvalho Chehab [off-list ref]; Rob Herring [off-list ref]; Krzysztof Kozlowski [off-list ref]; Conor Dooley [off-list ref]; Shawn Guo [off-list ref]; Sascha Hauer [off-list ref]; Pengutronix Kernel Team [off-list ref]; Fabio Estevam [off-list ref]; Philipp Zabel [off-list ref]; Frank Li [off-list ref]; linux- media@vger.kernel.org; devicetree@vger.kernel.org; imx@lists.linux.dev; linux- arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 2/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks Hi Guoniu, Thank you for the patch. On Fri, Dec 05, 2025 at 05:07:44PM +0800, Guoniu Zhou wrote:quoted
From: Guoniu Zhou <redacted> Use devm_clk_bulk_get_all() helper to simplify clock handle code. No functional changes intended. Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Guoniu Zhou <redacted> --- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 55 ++++++++++----------------- 1 file changed, 20 insertions(+), 35 deletions(-)diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.cb/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index371b4e81328c107269f89da23818ab0abd0179da..0e3a41cd35edfefc51b5631 e2c36quoted
fd76e3e14d83 100644--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c@@ -71,21 +71,6 @@ enum { ST_SUSPENDED = 4, }; -enum imx8mq_mipi_csi_clk { - CSI2_CLK_CORE, - CSI2_CLK_ESC, - CSI2_CLK_UI, - CSI2_NUM_CLKS, -}; - -static const char * const imx8mq_mipi_csi_clk_id[CSI2_NUM_CLKS] = { - [CSI2_CLK_CORE] = "core", - [CSI2_CLK_ESC] = "esc", - [CSI2_CLK_UI] = "ui", -}; - -#define CSI2_NUM_CLKS ARRAY_SIZE(imx8mq_mipi_csi_clk_id) - struct imx8mq_plat_data { int (*enable)(struct csi_state *state, u32 hs_settle); void (*disable)(struct csi_state *state); @@ -111,7 +96,9 @@ structcsi_state { struct device *dev; const struct imx8mq_plat_data *pdata; void __iomem *regs; - struct clk_bulk_data clks[CSI2_NUM_CLKS]; + struct clk_bulk_data *clks; + struct clk *esc_clk; + u32 num_clks; struct reset_control *rst; struct regulator *mipi_phy_regulator;@@ -384,24 +371,16 @@ static void imx8mq_mipi_csi_set_params(structcsi_state *state)quoted
CSI2RX_SEND_LEVEL); } -static int imx8mq_mipi_csi_clk_enable(struct csi_state *state) -{ - return clk_bulk_prepare_enable(CSI2_NUM_CLKS, state->clks); -} - -static void imx8mq_mipi_csi_clk_disable(struct csi_state *state) -{ - clk_bulk_disable_unprepare(CSI2_NUM_CLKS, state->clks); -} - -static int imx8mq_mipi_csi_clk_get(struct csi_state *state) +static struct clk *find_esc_clk(struct csi_state *state)imx8mq_mipi_csi_find_esc_clk().quoted
{ unsigned int i; - for (i = 0; i < CSI2_NUM_CLKS; i++) - state->clks[i].id = imx8mq_mipi_csi_clk_id[i]; + for (i = 0; i < state->num_clks; i++) { + if (!strcmp(state->clks[i].id, "esc")) + return state->clks[i].clk; + } - return devm_clk_bulk_get(state->dev, CSI2_NUM_CLKS, state->clks); + return ERR_PTR(-ENODEV); } static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state, @@ -456,7 +435,7 @@ static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state*state,quoted
* documentation recommends picking a value away from theboundaries.quoted
* Let's pick the average. */ - esc_clk_rate = clk_get_rate(state->clks[CSI2_CLK_ESC].clk); + esc_clk_rate = clk_get_rate(state->esc_clk); if (!esc_clk_rate) { dev_err(state->dev, "Could not get esc clock rate.\n"); return -EINVAL;@@ -783,7 +762,7 @@ static void imx8mq_mipi_csi_pm_suspend(structdevice *dev) if (state->state & ST_POWERED) { imx8mq_mipi_csi_stop_stream(state); - imx8mq_mipi_csi_clk_disable(state); + clk_bulk_disable_unprepare(state->num_clks, state->clks); state->state &= ~ST_POWERED; }@@ -801,7 +780,7 @@ static int imx8mq_mipi_csi_pm_resume(structdevicequoted
*dev) if (!(state->state & ST_POWERED)) { state->state |= ST_POWERED; - ret = imx8mq_mipi_csi_clk_enable(state); + ret = clk_bulk_prepare_enable(state->num_clks, state->clks); } if (state->state & ST_STREAMING) { sd_state = v4l2_subdev_lock_and_get_active_state(sd);@@ -1027,9 +1006,15 @@ static int imx8mq_mipi_csi_probe(structplatform_device *pdev)quoted
if (IS_ERR(state->regs)) return PTR_ERR(state->regs); - ret = imx8mq_mipi_csi_clk_get(state); + ret = devm_clk_bulk_get_all(dev, &state->clks); if (ret < 0) - return ret; + return dev_err_probe(dev, ret, "Failed to get clocks\n"); + + state->num_clks = ret; + + state->esc_clk = find_esc_clk(state); + if (IS_ERR(state->esc_clk)) + return dev_err_probe(dev, PTR_ERR(state->esc_clk), "Couldn'tfindquoted
+esc clock\n");This could be line-wrapped. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> I can make those small changes when applying if there's no other need to submit a new version.
Thank you for the review and offer! I have no other changes, so please feel free to make those adjustments when applying.
quoted
platform_set_drvdata(pdev, &state->sd);-- Regards, Laurent Pinchart