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

From: Linus Walleij
Date: Thu Jun 20 2013 - 07:33:22 EST


On Thu, Jun 20, 2013 at 12:59 PM, Michal Simek <monstr@xxxxxxxxx> 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
--
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/