diff mbox series

[v4,1/2] pinctrl: Add an API to get the pinctrl pins if initialized

Message ID 20221221205116.73941-2-hhhawa@amazon.com
State New
Headers show
Series i2c: Set i2c pinctrl recovery info from it's device pinctrl | expand

Commit Message

Hanna Hawa Dec. 21, 2022, 8:51 p.m. UTC
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>
---
 include/linux/pinctrl/devinfo.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Andy Shevchenko Dec. 28, 2022, 3:05 p.m. UTC | #1
On Wed, Dec 21, 2022 at 08:51:15PM +0000, Hanna Hawa wrote:
> 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.

...

>  /* The device core acts as a consumer toward pinctrl */

> +#include <linux/device.h>

It's slightly misplaced. The comment above is for the below inclusion.

>  #include <linux/pinctrl/consumer.h>

Can we make it

----8<----
#include <linux/device.h>

/* The device core acts as a consumer toward pinctrl */
#include <linux/pinctrl/consumer.h>
----8<----

?

With this addressed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
diff mbox series

Patch

diff --git a/include/linux/pinctrl/devinfo.h b/include/linux/pinctrl/devinfo.h
index a48ff69acddd..83eef2ac8cd6 100644
--- a/include/linux/pinctrl/devinfo.h
+++ b/include/linux/pinctrl/devinfo.h
@@ -17,6 +17,7 @@ 
 #ifdef CONFIG_PINCTRL
 
 /* The device core acts as a consumer toward pinctrl */
+#include <linux/device.h>
 #include <linux/pinctrl/consumer.h>
 
 /**
@@ -40,6 +41,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
 
 struct device;
@@ -56,5 +65,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 */