pinctrl: Add an API to get the pinctrl pins if initialized
authorHanna Hawa <hhhawa@amazon.com>
Wed, 28 Dec 2022 16:48:12 +0000 (16:48 +0000)
committerWolfram Sang <wsa@kernel.org>
Fri, 20 Jan 2023 08:52:15 +0000 (09:52 +0100)
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 <hhhawa@amazon.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
include/linux/pinctrl/devinfo.h

index 9e8b559..bb6653a 100644 (file)
@@ -18,6 +18,8 @@ struct device;
 
 #ifdef CONFIG_PINCTRL
 
+#include <linux/device.h>
+
 /* The device core acts as a consumer toward pinctrl */
 #include <linux/pinctrl/consumer.h>
 
@@ -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 */