From: Mike Turquette <mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Tero Kristo <t-kristo-l0cyMroinI0@public.gmane.org>,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCHv2 02/11] CLK: use of_property_read_u32 instead of read_u8
Date: Fri, 21 Jun 2013 09:21:00 -0700 [thread overview]
Message-ID: <20130621162100.9136.5273@quantum> (raw)
In-Reply-To: <20130621124558.GB16513@kahuna>
Quoting Nishanth Menon (2013-06-21 05:45:58)
> On 17:57-20130620, Mike Turquette wrote:
> > On Wed, Jun 19, 2013 at 6:18 AM, Tero Kristo <t-kristo-l0cyMroinI0@public.gmane.org> wrote:
> > > of_property_read_u8 does not work properly because of endianess problem
> > > with its current implementation, and this causes it to always return
> > > 0 with little endian architectures. Instead, use property_read_u32
> > > until this is fixed.
> >
> > Tero,
> >
> > Thanks for the fix. Heiko Stubner pointed out to me that in order to
> > read a u8 value the DT node needs to specify "/bits/ 8" before the
> > values. From the of_property_read_u8_array kerneldoc:
> >
> > "
> > /**
> > ...
> > * dts entry of array should be like:
> > * property = /bits/ 8 <0x50 0x60 0x70>;
> > *
> > * The out_value is modified only if a valid u8 value can be decoded.
> > */
> > "
> >
> > Still I think it is a bit silly to have to do this in all of the
> > bindings, so I'm going to roll this patch into my next version of the
> > series if only for the sake of readability. Not only that but it is
> > slightly more future proof for the binding to use a u32 value. The
> > fact that the implementation in Linux uses a u8 is of little
> > consequence to the binding. I'll also add a cast like the following
> > to your patch:
> >
> > clk = clk_register_gate(NULL, clk_name, parent_name, 0, reg, (u8) bit_idx,
> > clk_gate_flags, NULL);
> >
> Given that dtb size could be directly impacted, could we consider
> something like a preprocessor macro to make it readable, yet not too
> huge dts size?
bit-shift is an optional property and you don't need it at all. It is
mostly there for legacy reasons and also it is useful to the Rockchip
and Hisilicon drivers.
The OMAP DT clock data could simply use a 32-bit mask that covers the
whole register and not provide bit-shift at all, if you're worried about
the extra 24 bits.
Regards,
Mike
> >
> > >
> > > Signed-off-by: Tero Kristo <t-kristo-l0cyMroinI0@public.gmane.org>
> > > ---
> > > drivers/clk/clk-divider.c | 4 ++--
> > > drivers/clk/clk-gate.c | 4 ++--
> > > drivers/clk/clk-mux.c | 4 ++--
> > > 3 files changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> > > index 17ea475..3413602 100644
> > > --- a/drivers/clk/clk-divider.c
> > > +++ b/drivers/clk/clk-divider.c
> > > @@ -361,7 +361,7 @@ void of_divider_clk_setup(struct device_node *node)
> > > const char *parent_name;
> > > u8 clk_divider_flags = 0;
> > > u32 mask = 0;
> > > - u8 shift = 0;
> > > + u32 shift = 0;
> > > struct clk_div_table *table;
> > >
> > > of_property_read_string(node, "clock-output-names", &clk_name);
> > > @@ -375,7 +375,7 @@ void of_divider_clk_setup(struct device_node *node)
> > > return;
> > > }
> > >
> > > - if (of_property_read_u8(node, "bit-shift", &shift)) {
> > > + if (of_property_read_u32(node, "bit-shift", &shift)) {
> > > shift = __ffs(mask);
> > > pr_debug("%s: bit-shift property defaults to 0x%x for %s\n",
> > > __func__, shift, node->name);
> > > diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
> > > index 72cf99d..61b4dc1 100644
> > > --- a/drivers/clk/clk-gate.c
> > > +++ b/drivers/clk/clk-gate.c
> > > @@ -162,7 +162,7 @@ void of_gate_clk_setup(struct device_node *node)
> > > void __iomem *reg;
> > > const char *parent_name;
> > > u8 clk_gate_flags = 0;
> > > - u8 bit_idx = 0;
> > > + u32 bit_idx = 0;
> > >
> > > of_property_read_string(node, "clock-output-names", &clk_name);
> > >
> > > @@ -170,7 +170,7 @@ void of_gate_clk_setup(struct device_node *node)
> > >
> > > reg = of_iomap(node, 0);
> > >
> > > - if (of_property_read_u8(node, "bit-shift", &bit_idx)) {
> > > + if (of_property_read_u32(node, "bit-shift", &bit_idx)) {
> > > pr_err("%s: missing bit-shift property for %s\n",
> > > __func__, node->name);
> > > return;
> > > diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
> > > index c9f9f32..e63dd1b 100644
> > > --- a/drivers/clk/clk-mux.c
> > > +++ b/drivers/clk/clk-mux.c
> > > @@ -170,7 +170,7 @@ void of_mux_clk_setup(struct device_node *node)
> > > int i;
> > > u8 clk_mux_flags = 0;
> > > u32 mask = 0;
> > > - u8 shift = 0;
> > > + u32 shift = 0;
> > >
> > > of_property_read_string(node, "clock-output-names", &clk_name);
> > >
> > > @@ -194,7 +194,7 @@ void of_mux_clk_setup(struct device_node *node)
> > > return;
> > > }
> > >
> > > - if (of_property_read_u8(node, "bit-shift", &shift)) {
> > > + if (of_property_read_u32(node, "bit-shift", &shift)) {
> > > shift = __ffs(mask);
> > > pr_debug("%s: bit-shift property defaults to 0x%x for %s\n",
> > > __func__, shift, node->name);
> > > --
> > > 1.7.9.5
> > >
>
> --
> Regards,
> Nishanth Menon
next prev parent reply other threads:[~2013-06-21 16:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 13:18 [PATCHv2 00/11] ARM: OMAP4 clock data conversion to DT Tero Kristo
2013-06-19 13:18 ` [PATCHv2 01/11] CLK: clkdev: add support for looking up clocks from DT Tero Kristo
2013-06-19 13:18 ` [PATCHv2 02/11] CLK: use of_property_read_u32 instead of read_u8 Tero Kristo
[not found] ` <1371647942-4811-3-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2013-06-21 0:57 ` Mike Turquette
2013-06-21 12:45 ` Nishanth Menon
2013-06-21 16:21 ` Mike Turquette [this message]
2013-06-19 13:18 ` [PATCHv2 03/11] CLK: divider: fix table parsing logic for DT Tero Kristo
2013-06-19 13:18 ` [PATCHv2 04/11] clk: omap: introduce clock driver Tero Kristo
2013-06-19 13:18 ` [PATCHv2 05/11] CLK: OMAP4: Add DPLL clock support Tero Kristo
2013-06-19 13:18 ` [PATCHv2 06/11] CLK: omap: move part of the machine specific clock header contents to driver Tero Kristo
2013-06-21 7:32 ` Tony Lindgren
2013-06-24 7:42 ` Tero Kristo
2013-06-19 13:18 ` [PATCHv2 07/11] ARM: OMAP: clock: add DT duplicate clock registration mechanism Tero Kristo
2013-06-19 13:18 ` [PATCHv2 08/11] CLK: omap: add autoidle support Tero Kristo
2013-06-19 13:19 ` [PATCHv2 09/11] CLK: omap: add support for OMAP gate clock Tero Kristo
2013-06-19 13:19 ` [PATCHv2 10/11] ARM: dts: omap4 clock data Tero Kristo
2013-06-19 13:30 ` Nishanth Menon
2013-06-19 13:49 ` Tero Kristo
2013-06-19 13:56 ` Nishanth Menon
2013-06-21 1:24 ` Stephen Boyd
2013-06-24 7:39 ` Tero Kristo
2013-06-19 13:19 ` [PATCHv2 11/11] ARM: OMAP4: register DT clocks and remove old data Tero Kristo
2013-06-21 7:25 ` Tony Lindgren
2013-06-24 7:45 ` Tero Kristo
2013-06-24 7:50 ` Tony Lindgren
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=20130621162100.9136.5273@quantum \
--to=mturquette-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nm-l0cyMroinI0@public.gmane.org \
--cc=t-kristo-l0cyMroinI0@public.gmane.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;
as well as URLs for NNTP newsgroup(s).