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

On Thu, Feb 5, 2015 at 10:15 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>
> > -     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

Ok, will fix.

> > +#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 :(

Ooops, looks like I don't have CONFIG_PM_SLEEP in my test config.
Will fix. Sorry about that.

-- 
Thanks.
-- Max

      reply	other threads:[~2015-02-05 19:24 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
2015-02-05 19:24     ` Max Filippov [this message]

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=CAMo8BfJyKfKuUC5xmB7Ji1SmCELZZCm_EP2V6rD7TfpjVy4ftg@mail.gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=jacmet@sunsite.dk \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    --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).