mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
gpio: Add the devm_fwnode_get_index_gpiod_from_child() helper
devm_fwnode_get_gpiod_from_child() currently allows GPIO users to request a GPIO that is defined in a child fwnode instead of directly in the device fwnode. Extend this API by adding the devm_fwnode_get_index_gpiod_from_child() helper which does the same except you can also specify an index in case the 'xx-gpios' property describe several GPIOs. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
4b0947974e
commit
537b94dafc
3 changed files with 37 additions and 23 deletions
|
@ -135,14 +135,14 @@ int desc_to_gpio(const struct gpio_desc *desc);
|
|||
struct fwnode_handle;
|
||||
|
||||
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
|
||||
const char *propname,
|
||||
const char *propname, int index,
|
||||
enum gpiod_flags dflags,
|
||||
const char *label);
|
||||
struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
|
||||
const char *con_id,
|
||||
struct fwnode_handle *child,
|
||||
enum gpiod_flags flags,
|
||||
const char *label);
|
||||
struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
|
||||
const char *con_id, int index,
|
||||
struct fwnode_handle *child,
|
||||
enum gpiod_flags flags,
|
||||
const char *label);
|
||||
#else /* CONFIG_GPIOLIB */
|
||||
|
||||
static inline int gpiod_count(struct device *dev, const char *con_id)
|
||||
|
@ -417,13 +417,25 @@ struct fwnode_handle;
|
|||
|
||||
static inline
|
||||
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
|
||||
const char *propname,
|
||||
const char *propname, int index,
|
||||
enum gpiod_flags dflags,
|
||||
const char *label)
|
||||
{
|
||||
return ERR_PTR(-ENOSYS);
|
||||
}
|
||||
|
||||
static inline
|
||||
struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
|
||||
const char *con_id, int index,
|
||||
struct fwnode_handle *child,
|
||||
enum gpiod_flags flags,
|
||||
const char *label)
|
||||
{
|
||||
return ERR_PTR(-ENOSYS);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_GPIOLIB */
|
||||
|
||||
static inline
|
||||
struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
|
||||
const char *con_id,
|
||||
|
@ -431,11 +443,10 @@ struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
|
|||
enum gpiod_flags flags,
|
||||
const char *label)
|
||||
{
|
||||
return ERR_PTR(-ENOSYS);
|
||||
return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child,
|
||||
flags, label);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_GPIOLIB */
|
||||
|
||||
#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
|
||||
|
||||
int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue