public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: Wang Zhang <silver_code@hust.edu.cn>
Cc: Peter Korsgaard <peter@korsgaard.com>,
	Andrew Lunn <andrew@lunn.ch>, Wolfram Sang <wsa@kernel.org>,
	Andreas Larsson <andreas@gaisler.com>,
	hust-os-kernel-patches@googlegroups.com,
	Peter Korsgaard <jacmet@sunsite.dk>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] i2c: ocores: use devm_ managed clks
Date: Wed, 14 Jun 2023 01:54:53 +0200	[thread overview]
Message-ID: <20230613235453.msezptxa5pwpizoi@intel.intel> (raw)
In-Reply-To: <20230526070534.76112-1-silver_code@hust.edu.cn>

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@kernel.org> 

Thanks,
Andi

  reply	other threads:[~2023-06-13 23:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16  7:20 [PATCH] i2c: ocores: add missing unwind goto in `ocores_i2c_probe` Wang Zhang
2023-04-16 15:33 ` Andrew Lunn
2023-04-17 13:27   ` [PATCH v2] i2c: ocores: use devm_ managed clks Wang Zhang
2023-04-17 14:05   ` Wang Zhang
2023-04-17 14:29     ` Peter Rosin
2023-04-17 15:50     ` Andrew Lunn
2023-04-22 12:32       ` [PATCH v3] " Wang Zhang
2023-04-25  9:58         ` 张网
2023-04-25 11:57         ` Andrew Lunn
2023-04-25 14:47           ` 张网
2023-04-25 15:06             ` Andrew Lunn
2023-05-26  7:05               ` [PATCH v4] " Wang Zhang
2023-06-13 23:54                 ` Andi Shyti [this message]
2023-06-23  8:22                 ` Wolfram Sang
2023-06-23  8:26                   ` Wolfram Sang
2023-05-23  4:49           ` Re: [PATCH v3] " 张网
2023-05-23 12:10             ` Andrew Lunn
2023-05-23 14:33             ` Wang Zhang
2023-05-24 15:35             ` Wang Zhang
2023-05-24 15:43             ` Wang Zhang
2023-05-24 18:45               ` Dan Carpenter
2023-05-24 19:21               ` Christophe JAILLET
2023-05-25  3:33                 ` 张网
2023-05-25 19:16                   ` Christophe JAILLET
2023-05-25  5:05                 ` Dan Carpenter
2023-05-25  5:02               ` Dan Carpenter
2023-05-25  9:28                 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230613235453.msezptxa5pwpizoi@intel.intel \
    --to=andi.shyti@kernel.org \
    --cc=andreas@gaisler.com \
    --cc=andrew@lunn.ch \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=jacmet@sunsite.dk \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@korsgaard.com \
    --cc=silver_code@hust.edu.cn \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox