Re: [RFC Patch] gpio: add GPIO hogging mechanism

From: Alexandre Courbot
Date: Wed Oct 29 2014 - 20:29:28 EST


On Thu, Oct 30, 2014 at 1:21 AM, Benoit Parrot <bparrot@xxxxxx> wrote:
>> > +
>> > if (status)
>> > goto fail;
>> >
>> > @@ -1742,6 +1757,72 @@ struct gpio_desc *__must_check __gpiod_get_index_optional(struct device *dev,
>> > EXPORT_SYMBOL_GPL(__gpiod_get_index_optional);
>> >
>> > /**
>> > + * gpiod_get_hog_index - obtain a GPIO from a multi-index GPIO hog
>> > + * @dev: GPIO consumer
>> > + * @idx: index of the GPIO to obtain
>> > + *
>> > + * This should only be used by the gpiochip_add to request/set GPIO initial
>> > + * configuration.
>> > + *
>> > + * Return a valid GPIO descriptor, or an IS_ERR() condition in case of error.
>> > + */
>> > +struct gpio_desc *__must_check gpiod_get_hog_index(struct device *dev,
>> > + unsigned int idx)
>> > +{
>> > + struct gpio_desc *desc = NULL;
>> > + int err;
>> > + unsigned long flags;
>> > + const char *name;
>> > +
>> > + /* Using device tree? */
>> > + if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
>> > + desc = of_get_gpio_hog(dev->of_node, idx, &name, &flags);
>> > +
>> > + if (!desc)
>> > + return ERR_PTR(-ENOTSUPP);
>> > + else if (IS_ERR(desc))
>> > + return desc;
>> > +
>> > + dev_dbg(dev, "gpio-hog: GPIO:%d (%s) as %s%s\n",
>> > + desc_to_gpio(desc), name, (flags&GPIOF_DIR_IN)?"input":"output",
>> > + (flags&GPIOF_DIR_IN)?"":(flags&GPIOF_INIT_HIGH)?"/high":"/low");
>> > +
>>
>> ...
>
> I guess this means to remove the dev_dbg code?

No, it was just to delimitate the code which I suggested to factorize
into its own function below. :) This dev_dbg is fine IMHO.
--
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/