Re: [PATCH v2] i2c: ocores: use devm_ managed clks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  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



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux