Re: [RFC PATCH 4/6] extcon-gpio: Add devicetree support

From: Guenter Roeck
Date: Thu Sep 12 2013 - 13:00:37 EST


On Thu, Sep 12, 2013 at 05:45:45PM +0100, Mark Rutland wrote:
> On Fri, Aug 30, 2013 at 05:29:36AM +0100, Guenter Roeck wrote:
> > Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> > ---
> > drivers/extcon/extcon-gpio.c | 59 ++++++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 57 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
> > index d4e3c89..16951fe 100644
> > --- a/drivers/extcon/extcon-gpio.c
> > +++ b/drivers/extcon/extcon-gpio.c
> > @@ -30,6 +30,8 @@
> > #include <linux/gpio.h>
> > #include <linux/extcon.h>
> > #include <linux/extcon/extcon-gpio.h>
> > +#include <linux/of_gpio.h>
> > +#include <linux/err.h>
> >
> > struct gpio_extcon_data {
> > struct extcon_dev edev;
> > @@ -77,14 +79,66 @@ static ssize_t extcon_gpio_print_state(struct extcon_dev *edev, char *buf)
> > return -EINVAL;
> > }
> >
> > +#ifdef CONFIG_OF_GPIO
> > +
> > +static struct gpio_extcon_platform_data *
> > +extcon_gpio_config_of(struct device *dev)
> > +{
> > + struct gpio_extcon_platform_data *pdata;
> > + struct device_node *np = dev->of_node;
> > + enum of_gpio_flags flags;
> > + int gpio, ret;
> > + u32 debounce;
> > +
> > + gpio = of_get_named_gpio_flags(np, "presence-detect-gpios", 0, &flags);
> > + if (gpio < 0)
> > + return ERR_PTR(gpio);
> > +
> > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> > + if (!pdata)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + pdata->gpio = gpio;
> > + pdata->gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
> > + pdata->irq_flags = IRQ_TYPE_EDGE_BOTH;
> > +
> > + if (!of_property_read_u32(np, "debounce-interval", &debounce))
> > + pdata->debounce = debounce;
> > +
> > + ret = of_property_read_string(np, "name", &pdata->name);
>
> This wasn't listed in the binding. What's this for?
>
This returns the node name.
For example, if the bindings are

my-connector {
...
};

it returns the string "my-connector".

I can add a reference to the bindings document if that helps. It is typically
not mentioned in bindings, though, so I didn't do it either.

Thanks,
Guenter
--
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/