Re: [PATCH 11/13] gpio: Support for unified device properties interface

Alexandre Courbot
2014-10-07T10:22:35Z

On Tue, Oct 7, 2014 at 9:18 AM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> From: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Some drivers need to deal with only firmware representation of its
> GPIOs. An example would be a GPIO button array driver where each button
> is described as a separate firmware node in device tree. Typically these
> child nodes do not have physical representation in the Linux device
> model.
>
> In order to help device drivers to handle such firmware child nodes we
> add dev[m]_get_named_gpiod_from_child() that takes a child firmware
> node pointer as its second argument (the first one is the parent device
> itself), finds the GPIO using whatever is the underlying firmware
> method, and requests the GPIO properly.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

...

> +/* Child properties interface */
> +struct gpio_desc *dev_get_named_gpiod_from_child(struct device *dev, void *child,
> + const char *propname, int index);
> +struct gpio_desc *devm_get_named_gpiod_from_child(struct device *dev, void *child,
> + const char *propname, int index);

I see the reason for these functions and am not opposed to them.
However, I wonder if we could not replace propname by a con_id that
would be resolved to one of con_id-gpio for DT and whatever naming
convention ACPI is using?

This would prevent users to name GPIOs outside of the conventions
defined in the bindings and be generally safer. Is there a particular
reason (used by some old code?) for the current direct property
access? If not, maybe we could call a slightly-modified of_find_gpio()
to resolve the GPIO property for DT, and the equivalent function for
ACPI?