SUPERH platform development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] ARM: shmobile: Fix device node reference leakage in shmobile_init_delay
Date: Wed, 21 May 2014 16:13:43 +0000	[thread overview]
Message-ID: <6156422.goNWLVtGTU@avalon> (raw)
In-Reply-To: <1400679065-17287-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Hi Geert,

On Wednesday 21 May 2014 15:56:20 Geert Uytterhoeven wrote:
> Hi Laurent, Magnus,
> 
> On Wed, May 21, 2014 at 3:31 PM, Laurent Pinchart wrote:
> > +       bool is_a8_a9 = false;
> > +       bool is_a15 = false;
> > +       u32 max_freq = 0;
> > +
> > +       cpus = of_find_node_by_path("/cpus");
> > +       if (!cpus)
> > +               return;
> > +
> > +       for_each_child_of_node(cpus, np) {
> > +               u32 freq;
> > +
> > +               if (!of_property_read_u32(np, "clock-frequency", &freq))
> > +                       max_freq = max(max_freq, freq);
> > 
> > -       if (max_freq) {
> > -               if (of_find_compatible_node(NULL, NULL, "arm,cortex-a8"))
> > -                       shmobile_setup_delay_hz(max_freq, 1, 3);
> > -               else if (of_find_compatible_node(NULL, NULL,
> > "arm,cortex-a9")) -                      
> > shmobile_setup_delay_hz(max_freq, 1, 3);
> > -               else if (of_find_compatible_node(NULL, NULL,
> > "arm,cortex-a15")) -                       if
> > (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER))
> > -                               shmobile_setup_delay_hz(max_freq, 2, 4);
> > +               if (of_device_is_compatible(np, "arm,cortex-a8") ||
> > +                   of_device_is_compatible(np, "arm,cortex-a9"))
> > +                       is_a8_a9 = true;
> 
> So now we have to care about CPU families in two places: here and below,
> when calling shmobile_setup_delay_hz().
> 
> IIUC, "shmobile_setup_delay_hz(max_freq, 2, 4)" is (ignoring rounding)
> equivalent to "shmobile_setup_delay_hz(max_freq, 1, 2)"?
> Do we actually have cases where mult needs to be different from 1?
> If not, we can kill the "mult" parameter, and replace the "is_a8_a9 = true"
> by:
> 
> div = 3;
> 
> > +               else if (of_device_is_compatible(np, "arm,cortex-a15"))
> > +                       is_a15 = true;
> 
> and
> 
> else if (of_device_is_compatible(np, "arm,cortex-a15") &&
>          !IS_ENABLED(CONFIG_ARM_ARCH_TIMER))
>         div = 2;
> 
> >         }
> > 
> > +
> > +       of_node_put(cpus);
> > +
> > +       if (!max_freq)
> > +               return;
> > +
> > +       if (is_a8_a9)
> > +               shmobile_setup_delay_hz(max_freq, 1, 3);
> > +       else if (is_a15 && !IS_ENABLED(CONFIG_ARM_ARCH_TIMER))
> > +               shmobile_setup_delay_hz(max_freq, 2, 4);
> 
> and this just becomes:
> 
> if (div)
>     shmobile_setup_delay_hz(max_freq, div);
> 
> Am I missing something?

That's an option as well, but I find the code flow to slightly be less clear 
in that case. I have no strong preference so I'll let Magnus decide.

-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2014-05-21 16:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 13:31 [PATCH] ARM: shmobile: Fix device node reference leakage in shmobile_init_delay Laurent Pinchart
2014-05-21 13:56 ` Geert Uytterhoeven
2014-05-21 16:13 ` Laurent Pinchart [this message]
2014-05-22  0:24 ` Magnus Damm
2014-05-22  0:50 ` Laurent Pinchart
2014-05-22  3:10 ` Magnus Damm
2014-05-22  9:42 ` Laurent Pinchart
2014-05-22 11:35 ` Magnus Damm
2014-05-22 11:37 ` Magnus Damm
2014-05-26  1:56 ` Simon Horman
  -- strict thread matches above, loose matches on Subject: below --
2014-06-23  2:25 [GIT PULL] Renesas ARM Based SoC Clock Updates for v3.17 Simon Horman
2014-06-23  2:25 ` [PATCH] ARM: shmobile: Fix device node reference leakage in shmobile_init_delay Simon Horman

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=6156422.goNWLVtGTU@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-sh@vger.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