Re: [PATCH 4/4] watchdog: st_wdt: Add new driver for ST's LPC Watchdog

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-watchdog" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux