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),
+};
+
Seems to add a lot of complexity (as in 'makes it difficult to understand')+ /* 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).