From: Lee Jones <lee.jones@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
Guenter Roeck <linux@roeck-us.net>,
dinh.linux@gmail.com, linux-watchdog@vger.kernel.org,
Damien Riegel <damien.riegel@savoirfairelinux.com>,
linux-kernel@vger.kernel.org, wim@iguana.be, robh+dt@kernel.org,
kernel@savoirfairelinux.com, kernel@pengutronix.de,
shawnguo@kernel.org, sameo@linux.intel.com
Subject: Re: [PATCH v3 2/5] mfd: syscon: add a DT property to set value width
Date: Mon, 23 Nov 2015 08:20:11 +0000 [thread overview]
Message-ID: <20151123082011.GG3098@x1> (raw)
In-Reply-To: <4478024.TgK5OkRQEy@wuerfel>
On Sat, 21 Nov 2015, Arnd Bergmann wrote:
> On Tuesday 17 November 2015 09:26:49 Guenter Roeck wrote:
> > >
> > > This syntax is confusing, as we normally associate it with an error
> > > condition. Instead, I'd use:
> > >
> > > if (of_property_read_u32(np, "bus-width", &bus_width) == 0)
> >
> > Or maybe better
> >
> > if (!of_property_read_u32(np, "bus-width", &bus_width))
>
> I would also prefer the latter, but it doesn't matter much either way.
>
> > >
> > > Or, for more clarity:
> > >
> > > of_property_read_u32(np, "bus-width", &bus_width);
> > > if (bus_width)
> > >
> > > If you choose this version (which I think is my preferred method, don't
> > > forget to initialise 'bus_width' to zero.
> > >
> > Ignoring an error and depending on bus_width==0 to determine if the property
> > was provided seems odd, especially since it would "hide" if the bus-width
> > property is set to 0. In the original code, this would be detected as error.
>
> Right.
>
> Another option would be
>
> ret = of_property_read_u32(np, "bus-width", &bus_width);
> /* no bus width provided, default to 32-bit */
> if (ret)
> bus_width = 32;
>
> syscon_config.val_bits = bus_width;
> syscon_config.reg_stride = syscon_config.val_bits / 8;
>
> which has the same effect but seems a little clearer to me.
Works for me.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
WARNING: multiple messages have this Message-ID (diff)
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/5] mfd: syscon: add a DT property to set value width
Date: Mon, 23 Nov 2015 08:20:11 +0000 [thread overview]
Message-ID: <20151123082011.GG3098@x1> (raw)
In-Reply-To: <4478024.TgK5OkRQEy@wuerfel>
On Sat, 21 Nov 2015, Arnd Bergmann wrote:
> On Tuesday 17 November 2015 09:26:49 Guenter Roeck wrote:
> > >
> > > This syntax is confusing, as we normally associate it with an error
> > > condition. Instead, I'd use:
> > >
> > > if (of_property_read_u32(np, "bus-width", &bus_width) == 0)
> >
> > Or maybe better
> >
> > if (!of_property_read_u32(np, "bus-width", &bus_width))
>
> I would also prefer the latter, but it doesn't matter much either way.
>
> > >
> > > Or, for more clarity:
> > >
> > > of_property_read_u32(np, "bus-width", &bus_width);
> > > if (bus_width)
> > >
> > > If you choose this version (which I think is my preferred method, don't
> > > forget to initialise 'bus_width' to zero.
> > >
> > Ignoring an error and depending on bus_width==0 to determine if the property
> > was provided seems odd, especially since it would "hide" if the bus-width
> > property is set to 0. In the original code, this would be detected as error.
>
> Right.
>
> Another option would be
>
> ret = of_property_read_u32(np, "bus-width", &bus_width);
> /* no bus width provided, default to 32-bit */
> if (ret)
> bus_width = 32;
>
> syscon_config.val_bits = bus_width;
> syscon_config.reg_stride = syscon_config.val_bits / 8;
>
> which has the same effect but seems a little clearer to me.
Works for me.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2015-11-23 8:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 19:06 [PATCH v3 0/5] Add board support for TS-4800 Damien Riegel
2015-11-16 19:06 ` Damien Riegel
2015-11-16 19:06 ` [PATCH v3 1/5] of: add vendor prefix for Technologic Systems Damien Riegel
2015-11-16 19:06 ` Damien Riegel
2015-11-16 19:06 ` [PATCH v3 2/5] mfd: syscon: add a DT property to set value width Damien Riegel
2015-11-16 19:06 ` Damien Riegel
2015-11-17 9:19 ` Lee Jones
2015-11-17 9:19 ` Lee Jones
2015-11-17 9:21 ` Lee Jones
2015-11-17 9:21 ` Lee Jones
2015-11-17 17:26 ` Guenter Roeck
2015-11-17 17:26 ` Guenter Roeck
2015-11-18 8:21 ` Lee Jones
2015-11-18 8:21 ` Lee Jones
2015-11-18 8:21 ` Lee Jones
2015-11-18 15:10 ` Guenter Roeck
2015-11-18 15:10 ` Guenter Roeck
2015-11-18 15:27 ` Lee Jones
2015-11-18 15:27 ` Lee Jones
2015-11-18 15:27 ` Lee Jones
2015-11-20 23:13 ` Arnd Bergmann
2015-11-20 23:13 ` Arnd Bergmann
2015-11-23 8:20 ` Lee Jones [this message]
2015-11-23 8:20 ` Lee Jones
2015-11-16 19:06 ` [PATCH v3 3/5] watchdog: ts4800: add driver for TS-4800 watchdog Damien Riegel
2015-11-16 19:06 ` Damien Riegel
2015-11-17 17:56 ` Guenter Roeck
2015-11-17 17:56 ` Guenter Roeck
2015-11-16 19:06 ` [PATCH v3 4/5] ARM: imx_v6_v7_defconfig: add " Damien Riegel
2015-11-16 19:06 ` Damien Riegel
2015-11-16 19:06 ` [PATCH v3 5/5] ARM: dts: TS-4800: add basic device tree Damien Riegel
2015-11-16 19:06 ` Damien Riegel
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=20151123082011.GG3098@x1 \
--to=lee.jones@linaro.org \
--cc=arnd@arndb.de \
--cc=damien.riegel@savoirfairelinux.com \
--cc=dinh.linux@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kernel@savoirfairelinux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
--cc=shawnguo@kernel.org \
--cc=wim@iguana.be \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.