From: linux@roeck-us.net (Guenter Roeck)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog
Date: Mon, 08 Sep 2014 06:31:40 -0700 [thread overview]
Message-ID: <540DAFBC.1010502@roeck-us.net> (raw)
In-Reply-To: <20140908123246.GB26284@lee--X1>
On 09/08/2014 05:32 AM, Lee Jones wrote:
> On Fri, 05 Sep 2014, Guenter Roeck wrote:
...
>>> +
>>> +static struct st_wdog_syscfg stid127_syscfg = {
>>> + .type_mask = BIT(2),
>>> + .enable_mask = BIT(2),
>>> +};
>>> +
>>> +static struct st_wdog_syscfg stih415_syscfg = {
>>> + .type_mask = BIT(6),
>>> + .enable_mask = BIT(7),
>>> +};
>>> +
>>> +static struct st_wdog_syscfg stih416_syscfg = {
>>> + .type_mask = BIT(6),
>>> + .enable_mask = BIT(7),
>>> +};
>>> +
>>> +static struct st_wdog_syscfg stih407_syscfg = {
>>> + .enable_mask = BIT(19),
>>> +};
>>> +
...
>>> + /* Mask/unmask watchdog reset */
>>> + regmap_update_bits(st_wdog->syscfg->regmap,
>>> + st_wdog->syscfg->enable_reg,
>>> + st_wdog->syscfg->enable_mask,
>>> + !enable);
>>
>> enable is a bool, but is supposed to provide the value to be put into the
>> register, masked with enable_mask. Unless I am missing something, the value
>> is not shifted in regmap_update_bits. So I don't think this can work, but
>> effectively always writes zero into the mask unless the mask happens to be
>> at bit position 0 - which never happens.
>>
>> Same is true for warm_reset above, which also has values 0 or 1.
>>
>> I know it does not really matter in C (at least when it comes to handling
>> 0 and 1), but I would suggest to avoid mixing booleans with bit masks.
>
> You're right of course, great spot.
>
> How about?
>
> !enable << ffs(st_wdog->syscfg->enable_mask).
>
Seems to add a lot of complexity (as in 'makes it difficult to understand')
to avoid a conditional, and assumes that enable_mask will never have more
than one bit set. I would go with
enable ? st_wdog->syscfg->enable_mask : 0
to avoid confusion, but your call.
Guenter
next prev parent reply other threads:[~2014-09-08 13:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 14:39 [PATCH 0/4] watchdog: Introduce new driver to support ST's Watchdog Lee Jones
2014-09-04 14:39 ` [PATCH 1/4] ARM: STi: DT: STiH407: Add Device Tree node for LPC Watchdog Lee Jones
2014-09-04 14:39 ` [PATCH 2/4] ARM: multi_v7_defconfig: Enable support for ST's " Lee Jones
2014-09-04 14:39 ` [PATCH 3/4] watchdog: st_wdt: Provide binding documentation for ST's LPC Watchdog driver Lee Jones
2014-09-04 14:39 ` Lee Jones
2014-09-05 15:27 ` Guenter Roeck
2014-09-08 11:57 ` Lee Jones
2014-09-04 14:39 ` [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog Lee Jones
2014-09-05 15:58 ` Guenter Roeck
2014-09-05 18:25 ` [STLinux Kernel] " Peter Griffin
2014-09-08 12:32 ` Lee Jones
2014-09-08 13:31 ` Guenter Roeck [this message]
2014-09-08 14:35 ` Lee Jones
2014-09-22 7:36 ` David Paris
2014-09-22 10:24 ` David Paris
-- strict thread matches above, loose matches on Subject: below --
2014-10-07 14:36 [PATCH v2 0/4] watchdog: Introduce new driver to support ST's Watchdog Lee Jones
2014-10-07 14:36 ` [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog Lee Jones
2014-10-07 17:23 ` Guenter Roeck
2014-10-08 9:33 [PATCH v3 0/4] watchdog: Introduce new driver to support ST's Watchdog Lee Jones
2014-10-08 9:33 ` [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog Lee Jones
2014-10-08 15:57 ` Guenter Roeck
2014-10-09 7:17 ` Lee Jones
2014-10-09 15:59 ` Guenter Roeck
2014-10-09 10:01 ` Mark Rutland
2014-10-09 10:50 ` Lee Jones
2014-10-23 15:18 [PATCH v4 0/4] watchdog: Introduce new driver to support ST's Watchdog Lee Jones
2014-10-23 15:18 ` [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog Lee Jones
2014-10-23 15:23 ` Arnd Bergmann
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=540DAFBC.1010502@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).