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: <fc8ed989-68e6-4fd4-a818-ae077bf5e6aa@lunn.ch>
Date:   Mon, 17 Apr 2023 17:50:03 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Wang Zhang <silver_code@...t.edu.cn>
Cc:     Peter Korsgaard <peter@...sgaard.com>,
        hust-os-kernel-patches@...glegroups.com, linux-i2c@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ