Re: [PATCH v3 2/5] mfd: syscon: add a DT property to set value width
From: Arnd Bergmann
Date: Fri Nov 20 2015 - 18:14:35 EST
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.
Another option would be
ret = of_property_read_u32(np, "bus-width", &bus_width);
/* no bus width provided, default to 32-bit */
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.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/