[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201306111406.14850.heiko@sntech.de>
Date: Tue, 11 Jun 2013 14:06:14 +0200
From: Heiko Stübner <heiko@...ech.de>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Mike Turquette <mturquette@...aro.org>,
Seungwon Jeon <tgih.jun@...sung.com>,
Jaehoon Chung <jh80.chung@...sung.com>,
Chris Ball <cjb@...top.org>,
"linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
Grant Likely <grant.likely@...aro.org>,
Rob Herring <rob.herring@...xeda.com>,
Linus Walleij <linus.walleij@...aro.org>,
Devicetree Discuss <devicetree-discuss@...ts.ozlabs.org>,
Russell King <linux@....linux.org.uk>,
Arnd Bergmann <arnd@...db.de>, Olof Johansson <olof@...om.net>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Subject: Re: [PATCH v3 1/7] clk: divider: add flag to limit possible dividers to even numbers
Am Dienstag, 11. Juni 2013, 13:51:56 schrieb Andy Shevchenko:
> On Tue, Jun 11, 2013 at 2:29 PM, Heiko Stübner <heiko@...ech.de> wrote:
> > SoCs like the Rockchip Cortex-A9 ones contain divider some clocks
> > that use the regular mechanisms for storage but allow only even
> > dividers and 1 to be used.
> >
> > Therefore add a flag that lets _is_valid_div limit the valid dividers
> > to these values. _get_maxdiv is also adapted to return even values
> > for the CLK_DIVIDER_ONE_BASED case.
>
> Just one nitpick below (I'm okay with current implementation, but you
> might find my proposal useful).
>
> > --- a/drivers/clk/clk-divider.c
> > +++ b/drivers/clk/clk-divider.c
> >
> > @@ -141,6 +149,8 @@ static bool _is_valid_div(struct clk_divider
> > *divider, unsigned int div)
> >
> > return is_power_of_2(div);
> >
> > if (divider->table)
> >
> > return _is_valid_table_div(divider->table, div);
> >
> > + if (divider->flags & CLK_DIVIDER_EVEN && div != 1 && (div % 2) !=
> > 0) + return false;
> >
> > return true;
> >
> > }
>
> What if rewrite like
>
> if (divider->flags & CLK_DIVIDER_EVEN == 0)
> return true;
>
> return div < 2 || div % 2 == 0;
hmm, the current structure is of the form of testing for each feature and
doing a applicable action if the flag is set. So it also is extensible for
future flags and checking for the absence of an attribute while the rest of
the conditionals check for the presence also might make the code harder to
read.
So for me the current variant somehow looks more intuitive.
But I'll just let the majority decide ;-)
Heiko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists