LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: Peter Korsgaard <jacmet@sunsite.dk>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] i2c: i2c-ocores: add common clock support
Date: Thu, 5 Feb 2015 20:15:11 +0100	[thread overview]
Message-ID: <20150205191510.GB15307@katana> (raw)
In-Reply-To: <1422890893-30989-3-git-send-email-jcmvbkbc@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]

> -	if (of_property_read_u32(np, "opencores,ip-clock-frequency", &val)) {
> +#ifdef CONFIG_HAVE_CLK
> +	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;
> +	} else
> +#endif
> +		if (of_property_read_u32(np, "opencores,ip-clock-frequency",
> +					 &val)) {

This is not very readable (wrong indentation) and fragile. I'd suggest
to leave out #ifdeffery, the compiler will remove the code for !HAVE_CLK
because of the empty dummy functions[1]. Then, you can write properly
formatted code again.

[1] Well, it should if there wasn't a bug in that: https://lkml.org/lkml/2015/2/5/544

> +#ifdef CONFIG_HAVE_CLK
> +	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;
> +	}
> +#endif

Ahem, there is a build error in here :(


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-02-05 19:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 15:28 [PATCH v2 0/2] i2c: i2c-ocores: clock improvements Max Filippov
2015-02-02 15:28 ` [PATCH v2 1/2] i2c: i2c-ocores: fix clock-frequency binding usage Max Filippov
2015-02-05 19:11   ` Wolfram Sang
2015-02-05 19:46     ` Max Filippov
2015-02-05 19:51       ` Wolfram Sang
2015-02-02 15:28 ` [PATCH v2 2/2] i2c: i2c-ocores: add common clock support Max Filippov
2015-02-05 19:15   ` Wolfram Sang [this message]
2015-02-05 19:24     ` Max Filippov

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=20150205191510.GB15307@katana \
    --to=wsa@the-dreams.de \
    --cc=jacmet@sunsite.dk \
    --cc=jcmvbkbc@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH v2 2/2] i2c: i2c-ocores: add common clock support' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).