[PATCH 1/2] GPIO: Add support for dual channel in gpio-xilinx.c

Linus Walleij linus.walleij at linaro.org
Thu Jun 20 21:33:10 EST 2013


On Thu, Jun 20, 2013 at 12:59 PM, Michal Simek <monstr at monstr.eu> wrote:
> On 06/20/2013 11:23 AM, Linus Walleij wrote:

>> What about something like this:
>>
>> static bool is_dual (struct device_node *np)
>> {
>>     struct property *prop = of_find_property(np, "xlnx,is-dual", NULL);
>>     int ret;
>>     u32 val;
>>
>>     if (!prop)
>>         return false;
>>
>>     ret = of_property_read_u32(np, "xlnx,is-dual", &val);
>>     if (ret < 0)
>>         return true; /* node exists but has no cells */
>>
>>     return !!val;
>> }
>
> we can do it in this way but what I don't like on this is that IP
> is design to support 2 channels right now.
> It can happen that Xilinx decides to extend this for new channels.
> Register map is prepared for it and there is enough space to do it.
>
> And when this is done then is-dual (which is current name which
> is used in hardware configuration from design tools) will contain
> larger value >1.
> I agree that is-dual is not the best name.

You don't say. It's about as smart as this:

#define NUMBER_TWO 4

Oh well, that's not your fault.

But seriously:

  xlnx,is-dual;

without an argument can still be taken to mean "2", and
you still need to inperpret the absence if this parameter
as "1" do you not?

> What about to do it differently?
> Generate number of channel in the description.
> And also do for() loop in the probe function to read values based
> on this channel number.

Sorry I can't translate this, can you send a patch?

Yours,
Linus Walleij


More information about the devicetree-discuss mailing list