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: <20230613235453.msezptxa5pwpizoi@intel.intel>
Date:   Wed, 14 Jun 2023 01:54:53 +0200
From:   Andi Shyti <andi.shyti@...nel.org>
To:     Wang Zhang <silver_code@...t.edu.cn>
Cc:     Peter Korsgaard <peter@...sgaard.com>,
        Andrew Lunn <andrew@...n.ch>, Wolfram Sang <wsa@...nel.org>,
        Andreas Larsson <andreas@...sler.com>,
        hust-os-kernel-patches@...glegroups.com,
        Peter Korsgaard <jacmet@...site.dk>, linux-i2c@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] i2c: ocores: use devm_ managed clks

Hi Wang,

> -	i2c->clk = devm_clk_get(&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;
> -	}
> -
> +	i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
> +	if (IS_ERR(i2c->clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
> +				     "devm_clk_get_optional_enabled failed\n");
> +
> +	i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000;

if devm_clk_get_optional_enabled() returns NULL, clk_get_rate()
returns '0' and op_clk_khz would be '0'...

> +	if (clock_frequency_present)
> +		i2c->bus_clock_khz = clock_frequency / 1000;
>  	if (i2c->ip_clock_khz == 0) {

... and we fall inside this 'if', as expected. Looks correct!

Reviewed-by: Andi Shyti <andi.shyti@...nel.org> 

Thanks,
Andi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ