From: Hanna Hawa Date: Wed, 28 Dec 2022 16:48:12 +0000 (+0000) Subject: pinctrl: Add an API to get the pinctrl pins if initialized X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=13e80244ca7e51d5eb7803f05e0579b11fc89048;p=linux.git pinctrl: Add an API to get the pinctrl pins if initialized Add an API to get the pinctrl pins if it was initialized before driver probed. This API will be used in I2C core to get the device pinctrl information for recovery state change. Signed-off-by: Hanna Hawa Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Signed-off-by: Wolfram Sang --- diff --git a/include/linux/pinctrl/devinfo.h b/include/linux/pinctrl/devinfo.h index 9e8b559e12530..bb6653af4f92b 100644 --- a/include/linux/pinctrl/devinfo.h +++ b/include/linux/pinctrl/devinfo.h @@ -18,6 +18,8 @@ struct device; #ifdef CONFIG_PINCTRL +#include + /* The device core acts as a consumer toward pinctrl */ #include @@ -44,6 +46,14 @@ struct dev_pin_info { extern int pinctrl_bind_pins(struct device *dev); extern int pinctrl_init_done(struct device *dev); +static inline struct pinctrl *dev_pinctrl(struct device *dev) +{ + if (!dev->pins) + return NULL; + + return dev->pins->p; +} + #else /* Stubs if we're not using pinctrl */ @@ -58,5 +68,10 @@ static inline int pinctrl_init_done(struct device *dev) return 0; } +static inline struct pinctrl *dev_pinctrl(struct device *dev) +{ + return NULL; +} + #endif /* CONFIG_PINCTRL */ #endif /* PINCTRL_DEVINFO_H */