lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140908143554.GD30307@lee--X1>
Date:	Mon, 8 Sep 2014 15:35:54 +0100
From:	Lee Jones <lee.jones@...aro.org>
To:	Guenter Roeck <linux@...ck-us.net>
Cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	kernel@...inux.com, wim@...ana.be, linux-watchdog@...r.kernel.org,
	David Paris <david.paris@...com>
Subject: Re: [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC
 Watchdog

On Mon, 08 Sep 2014, Guenter Roeck wrote:

> 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.

Actually, it would be the other way round, but the implementation is
nice.  I'll use that instead.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ