[U-Boot] [PATCH V2 2/2] sunxi: gpio: convert bind() to use driver data

Stephen Warren swarren at wwwdotorg.org
Thu May 12 19:50:23 CEST 2016


On 05/12/2016 11:43 AM, Simon Glass wrote:
> Hi Stephen,
>
> On 11 May 2016 at 15:26, Stephen Warren <swarren at wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren at nvidia.com>
>>
>> Now that the DM core sets driver_data before calling bind(), this driver
>> can make use of driver_data to determine the set of child devices to
>> create, rather than manually re-implementing the matching logic in code.

>> diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c

>> +#define ID(_compat_, _soc_data_) \
>> +       { .compatible = _compat_, .data = (ulong)&soc_data_##_soc_data_ }
>> +
>>   static const struct udevice_id sunxi_gpio_ids[] = {
>> -       { .compatible = "allwinner,sun4i-a10-pinctrl" },
>> -       { .compatible = "allwinner,sun5i-a10s-pinctrl" },
>> -       { .compatible = "allwinner,sun5i-a13-pinctrl" },
...
>> +       ID("allwinner,sun4i-a10-pinctrl",       a_all),
>> +       ID("allwinner,sun5i-a10s-pinctrl",      a_all),
>
> I don't think the #define adds a lot of value - consider removing it
> an writing things out in full?

I originally did that, but you either end up with lines over 80 columns 
which checkpatch complains about, or multiple lines per entry which 
makes it harder to read for such a large table. Still, I can convert it 
if you want.


More information about the U-Boot mailing list