mbox series

[v3,0/4] i2c: Use devm_clk_get_enabled() helpers

Message ID 20240823035116.21590-1-rongqianfeng@vivo.com
Headers show
Series i2c: Use devm_clk_get_enabled() helpers | expand

Message

Rong Qianfeng Aug. 23, 2024, 3:51 a.m. UTC
The devm_clk_get_enabled() helpers:
    - call devm_clk_get()
    - call clk_prepare_enable() and register what is needed in order to
     call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

While at it, no need to save clk pointer, drop sclk from struct
em_i2c_device.

-v3:
 *Add another patch to use dev_err_probe() in jz4780_i2c_probe().

-v2:
 *Add another patch to drop sclk from struct em_i2c_device.

Rong Qianfeng (4):
  i2c: emev2: Use devm_clk_get_enabled() helpers
  i2c: emev2: drop sclk from struct em_i2c_device
  i2c: jz4780: Use devm_clk_get_enabled() helpers
  i2c: jz4780: Use dev_err_probe()

 drivers/i2c/busses/i2c-emev2.c  | 23 +++++++----------------
 drivers/i2c/busses/i2c-jz4780.c | 33 +++++++++++----------------------
 2 files changed, 18 insertions(+), 38 deletions(-)

Comments

Andy Shevchenko Aug. 23, 2024, 3:30 p.m. UTC | #1
On Fri, Aug 23, 2024 at 11:51:13AM +0800, Rong Qianfeng wrote:
> The devm_clk_get_enabled() helpers:
>     - call devm_clk_get()
>     - call clk_prepare_enable() and register what is needed in order to
>      call clk_disable_unprepare() when needed, as a managed resource.
> 
> This simplifies the code and avoids the calls to clk_disable_unprepare().

...

>  	ret = platform_get_irq(pdev, 0);
>  	if (ret < 0)
> -		goto err_clk;
> +		return ret;
>  	priv->irq = ret;

(1)

>  	ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0,
>  				"em_i2c", priv);
>  	if (ret)
> -		goto err_clk;
> +		return ret;
>  

>  	ret = i2c_add_adapter(&priv->adap);

>  

While at it, you may move this blank line to (1) above.

>  	if (ret)
> -		goto err_clk;
> +		return ret;