lkml.org 
[lkml]   [2023]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] i2c: ocores: use devm_ managed clks
>  drivers/i2c/busses/i2c-ocores.c | 62 +++++++++++++--------------------
> 1 file changed, 24 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> index a0af027db04c..1dcb1af1ad13 100644
> --- a/drivers/i2c/busses/i2c-ocores.c
> +++ b/drivers/i2c/busses/i2c-ocores.c
> @@ -549,28 +549,24 @@ static int ocores_i2c_of_probe(struct platform_device *pdev,
> &clock_frequency);
> i2c->bus_clock_khz = 100;
>
> - i2c->clk = devm_clk_get(&pdev->dev, NULL);
> + i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>
> - if (!IS_ERR(i2c->clk)) {
> - int ret = clk_prepare_enable(i2c->clk);
> -
> - if (ret) {
> - dev_err(&pdev->dev,
> - "clk_prepare_enable failed: %d\n", ret);
> - return ret;
> - }
> - i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000;
> - if (clock_frequency_present)
> - i2c->bus_clock_khz = clock_frequency / 1000;
> + if (IS_ERR(i2c->clk)) {
> + dev_err(&pdev->dev,
> + "devm_clk_get_enabled failed\n");
> + return PTR_ERR(i2c->clk);

I think this is wrong. The old code would not return an error if
devm_clk_get() failed, e.g because the clock does not exist in
DT. i2c->bus_clock_khz would default to 100, and it keeps going. Now,
it appears you have turned the missing clock into a fatal error.

devm_clk_get_optional_enabled() seems to do what you want.

Andrew

\
 
 \ /
  Last update: 2023-04-17 17:52    [W:0.064 / U:0.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site