lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260121020808.GG403250@killaraus>
Date: Wed, 21 Jan 2026 04:08:08 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Frank Li <Frank.Li@....com>
Cc: Steve Longerbeam <slongerbeam@...il.com>,
	Philipp Zabel <p.zabel@...gutronix.de>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>, imx@...ts.linux.dev,
	linux-media@...r.kernel.org, linux-staging@...ts.linux.dev,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND v2 3/5] media: staging: media: imx6-mipi-csi2: use
 devm_clk_bulk_get_all() to fetch clocks

On Fri, Jan 16, 2026 at 11:17:58AM -0500, Frank Li wrote:
> Use devm_clk_bulk_get_all_enabled() helper to simplify clock handling.
> 
> Defer all clock prepare and enable to csi2_start(), which previous only
> enable pix clock here.
> 
> Add clk_enable at log_status().
> 
> Do that safely because there are not register access before csi2_start().
> 
> Signed-off-by: Frank Li <Frank.Li@....com>
> ---
> changes in v2
> - add clk_bulk_prepare_enable() get at csi2_log_status()
> ---
>  drivers/staging/media/imx/imx6-mipi-csi2.c | 57 +++++++++---------------------
>  1 file changed, 16 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
> index 4f740170d2bbf586ac0a58b5d25f8f8432e9e6a3..e1b4b7fb53131ce9515b9441d8fc420e85d3e993 100644
> --- a/drivers/staging/media/imx/imx6-mipi-csi2.c
> +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
> @@ -39,9 +39,8 @@ struct csi2_dev {
>  	struct v4l2_subdev sd;
>  	struct v4l2_async_notifier notifier;
>  	struct media_pad pad[CSI2_NUM_PADS];
> -	struct clk *dphy_clk;
> -	struct clk *pllref_clk;
> -	struct clk *pix_clk; /* what is this? */
> +	struct clk_bulk_data *clks;
> +	int num_clks;
>  	void __iomem *base;
>  
>  	struct v4l2_subdev *remote;
> @@ -343,7 +342,7 @@ static int csi2_start(struct csi2_dev *csi2)
>  	unsigned int lanes;
>  	int ret;
>  
> -	ret = clk_prepare_enable(csi2->pix_clk);
> +	ret = clk_bulk_prepare_enable(csi2->num_clks, csi2->clks);
>  	if (ret)
>  		return ret;
>  
> @@ -390,7 +389,7 @@ static int csi2_start(struct csi2_dev *csi2)
>  err_assert_reset:
>  	csi2_enable(csi2, false);
>  err_disable_clk:
> -	clk_disable_unprepare(csi2->pix_clk);
> +	clk_bulk_disable_unprepare(csi2->num_clks, csi2->clks);
>  	return ret;
>  }
>  
> @@ -401,7 +400,7 @@ static void csi2_stop(struct csi2_dev *csi2)
>  	v4l2_subdev_call(csi2->src_sd, video, post_streamoff);
>  
>  	csi2_enable(csi2, false);
> -	clk_disable_unprepare(csi2->pix_clk);
> +	clk_bulk_disable_unprepare(csi2->num_clks, csi2->clks);
>  }
>  
>  /*
> @@ -570,6 +569,11 @@ static int csi2_registered(struct v4l2_subdev *sd)
>  static int csi2_log_status(struct v4l2_subdev *sd)
>  {
>  	struct csi2_dev *csi2 = sd_to_dev(sd);
> +	int ret;
> +
> +	ret = clk_bulk_prepare_enable(csi2->num_clks, csi2->clks);
> +	if (ret)
> +		return ret;
>  
>  	v4l2_info(sd, "-----MIPI CSI status-----\n");
>  	v4l2_info(sd, "VERSION: 0x%x\n",
> @@ -601,6 +605,8 @@ static int csi2_log_status(struct v4l2_subdev *sd)
>  	v4l2_info(sd, "PHY_TST_CTRL1: 0x%x\n",
>  		  readl(csi2->base + CSI2_PHY_TST_CTRL1));
>  
> +	clk_bulk_disable_unprepare(csi2->num_clks, csi2->clks);
> +
>  	return 0;
>  }
>  
> @@ -749,24 +755,6 @@ static int csi2_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	csi2->pllref_clk = devm_clk_get(&pdev->dev, "ref");
> -	if (IS_ERR(csi2->pllref_clk)) {
> -		v4l2_err(&csi2->sd, "failed to get pll reference clock\n");
> -		return PTR_ERR(csi2->pllref_clk);
> -	}
> -
> -	csi2->dphy_clk = devm_clk_get(&pdev->dev, "dphy");
> -	if (IS_ERR(csi2->dphy_clk)) {
> -		v4l2_err(&csi2->sd, "failed to get dphy clock\n");
> -		return PTR_ERR(csi2->dphy_clk);
> -	}
> -
> -	csi2->pix_clk = devm_clk_get(&pdev->dev, "pix");
> -	if (IS_ERR(csi2->pix_clk)) {
> -		v4l2_err(&csi2->sd, "failed to get pixel clock\n");
> -		return PTR_ERR(csi2->pix_clk);
> -	}
> -
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!res) {
>  		v4l2_err(&csi2->sd, "failed to get platform resources\n");
> @@ -781,20 +769,12 @@ static int csi2_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	ret = clk_prepare_enable(csi2->pllref_clk);
> -	if (ret) {
> -		v4l2_err(&csi2->sd, "failed to enable pllref_clk\n");
> -		return ret;
> -	}
> -
> -	ret = clk_prepare_enable(csi2->dphy_clk);
> -	if (ret) {
> -		v4l2_err(&csi2->sd, "failed to enable dphy_clk\n");
> -		goto pllref_off;
> -	}
> -
>  	platform_set_drvdata(pdev, &csi2->sd);
>  
> +	csi2->num_clks = devm_clk_bulk_get_all(&pdev->dev, &csi2->clks);
> +	if (csi2->num_clks < 0)
> +		return dev_err_probe(&pdev->dev, csi2->num_clks, "Failed to get clocks\n");

I'm still really not a fan of devm_clk_bulk_get_all(). I would prefer
using clk_bulk_get(). The rest looks fine, although I would have split
this patch in two, one to switch to the bulk API, and one to move
enabling/disabling of the clocks.

Ah, no, there's one clock that's already enabled at start time, so a
single patch is fine.

> +
>  	ret = csi2_async_register(csi2);
>  	if (ret)
>  		goto clean_notifier;
> @@ -804,9 +784,6 @@ static int csi2_probe(struct platform_device *pdev)
>  clean_notifier:
>  	v4l2_async_nf_unregister(&csi2->notifier);
>  	v4l2_async_nf_cleanup(&csi2->notifier);
> -	clk_disable_unprepare(csi2->dphy_clk);
> -pllref_off:
> -	clk_disable_unprepare(csi2->pllref_clk);
>  	return ret;
>  }
>  
> @@ -818,8 +795,6 @@ static void csi2_remove(struct platform_device *pdev)
>  	v4l2_async_nf_unregister(&csi2->notifier);
>  	v4l2_async_nf_cleanup(&csi2->notifier);
>  	v4l2_async_unregister_subdev(sd);
> -	clk_disable_unprepare(csi2->dphy_clk);
> -	clk_disable_unprepare(csi2->pllref_clk);
>  	media_entity_cleanup(&sd->entity);
>  }
>  

-- 
Regards,

Laurent Pinchart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ