mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: moore@free.fr (Chris Moore)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH v2 4/4] clk: meson: gxbb-aoclk: Add CEC 32k clock
Date: Sat, 29 Jul 2017 10:04:39 +0200	[thread overview]
Message-ID: <389b0cd5-4c93-e043-9c55-02bd56f590cf@free.fr> (raw)
In-Reply-To: <1501235589-318-5-git-send-email-narmstrong@baylibre.com>

Hi,

Sorry I forgot to reply to all in my previous post :(
I hope this corrects things.

Le 28/07/2017 ? 11:53, Neil Armstrong a ?crit :

[snip]

> +static long aoclk_cec_32k_round_rate(struct clk_hw *hw, unsigned long 
> rate,
> +                     unsigned long *prate)
> +{
> +    const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
> +                                  *prate);
> +
> +    /* If invalid return first one */
> +    if (!freq)
> +        return freq[0].target_rate;

Wouldn't this dereference a null pointer (or am I being stupid this 
morning)?

> +
> +    return freq->target_rate;
> +}
> +
> +static int aoclk_cec_32k_set_rate(struct clk_hw *hw, unsigned long rate,
> +                  unsigned long parent_rate)
> +{
> +    const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
> +                                  parent_rate);
> +    struct aoclk_cec_32k *cec_32k = to_aoclk_cec_32k(hw);
> +    u32 reg = 0;
> +
> +    if (!freq)
> +        return -EINVAL;
> +
> +    /* Disable clock */
> +    regmap_update_bits(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0,
> +               CLK_CNTL0_IN_GATE_EN | CLK_CNTL0_OUT_GATE_EN, 0);
> +
> +    if (freq->dualdiv)
> +        reg = CLK_CNTL0_DUALDIV_EN |
> +              FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1) |
> +              FIELD_PREP(CLK_CNTL0_N2_MASK, freq->n2 - 1);
> +    else
> +        reg = FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1);
> +

Suggestion:

+    reg = FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1);
+    if (freq->dualdiv)
+        reg |= CLK_CNTL0_DUALDIV_EN |
+               FIELD_PREP(CLK_CNTL0_N2_MASK, freq->n2 - 1);

is shorter but maybe generates the same code.

> + regmap_write(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0, reg);
> +
> +    if (freq->dualdiv)
> +        reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1) |
> +              FIELD_PREP(CLK_CNTL1_M2_MASK, freq->m2 - 1);
> +    else
> +        reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1);
> +

Idem:

+    reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1);
+    if (freq->dualdiv)
+        reg |= FIELD_PREP(CLK_CNTL1_M2_MASK, freq->m2 - 1);

Cheers,
Chris

  parent reply	other threads:[~2017-07-29  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28  9:53 [PATCH v2 0/4] " Neil Armstrong
2017-07-28  9:53 ` [PATCH v2 1/4] dt-bindings: clock: amlogic, gxbb-aoclkc: Update bindings Neil Armstrong
2017-07-28  9:53 ` [PATCH v2 2/4] clk: meson: gxbb-aoclk: Switch to regmap for register access Neil Armstrong
2017-07-28  9:53 ` [PATCH v2 3/4] dt-bindings: clock: gxbb-aoclk: Add CEC 32k clock Neil Armstrong
2017-07-28  9:53 ` [PATCH v2 4/4] clk: meson: " Neil Armstrong
2017-07-28 10:29   ` Martin Blumenstingl
2017-07-28 14:09     ` Neil Armstrong
2017-07-28 20:47       ` Martin Blumenstingl
2017-07-29  8:04   ` Chris Moore [this message]
2017-07-31  8:10     ` Neil Armstrong

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=389b0cd5-4c93-e043-9c55-02bd56f590cf@free.fr \
    --to=moore@free.fr \
    --cc=linus-amlogic@lists.infradead.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

all inboxes | Powered by JetHome®