Re: [PATCH v3 05/15] gpio / ACPI: Add support for _DSD device properties

Alexandre Courbot
2014-10-05T10:36:25Z

On Wed, Oct 1, 2014 at 5:03 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 01 October 2014 04:12:41 Rafael J. Wysocki wrote:
>> + static const char * const suffixes[] = { "gpios", "gpio" };
>> + struct acpi_device *adev = ACPI_COMPANION(dev);
>> struct acpi_gpio_info info;
>> struct gpio_desc *desc;
>> + char propname[32];
>> + int i;
>>
>> - desc = acpi_get_gpiod_by_index(dev, idx, &info);
>> - if (IS_ERR(desc))
>> - return desc;
>> + /* Try first from _DSD */
>> + for (i = 0; i < ARRAY_SIZE(suffixes); i++) {
>> + if (con_id && strcmp(con_id, "gpios")) {
>> + snprintf(propname, sizeof(propname), "%s-%s",
>> + con_id, suffixes[i]);
>> + } else {
>> + snprintf(propname, sizeof(propname), "%s",
>> + suffixes[i]);
>> + }
>
> The general interface seems fine, but I'd be happier if you didn't
> try to support all four of the possible syntaxes we have in DT.
> It would be much better to have only "gpios" and not "gpio", and
> the "foo-gpios" syntax should be replaced with whatever method you
> use to name other subsystem specific links. For most subsystems
> we now use something like "gpio-names", but unfortunately the GPIO
> binding goes back to the time before we had come to that agreement.
> The same applies to regulators.

Wouldn't restricting the naming scheme cause problems for ACPI drivers
that want to reuse existing DT bindings? Since DT bindings are set in
stone, this means we would have to use different properties for DT and
ACPI.

I agree that there are too much ways to define GPIOs, but I'm afraid
we will have to carry them over for the sake of consistency.