mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl
@ 2022-12-21 20:51 Hanna Hawa
  2022-12-21 20:51 ` [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized Hanna Hawa
  2022-12-21 20:51 ` [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
  0 siblings, 2 replies; 5+ messages in thread
From: Hanna Hawa @ 2022-12-21 20:51 UTC (permalink / raw)
  To: wsa, linus.walleij, linux-i2c, linux-kernel, linux-gpio
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, farbere, itamark,
	hhhawa, kernel test robot

This series include two changes:
1. Adding new API to get the device pinctrl information when it's
initialized before device probed.
2. Make the i2c init recovery to get the device pins if it's not
initialized by the driver from the device pins.

Change Log v3->v4:
- Split the change into 2 commits
- Add cover letter and remove change log from commit message
- Fix compilation failure when CONFIG_PINCTRL is not defined
Reported-by: kernel test robot <lkp@intel.com>

Change Log v2->v3:
- Add API to get the device pinctrl
- Make the i2c init recovery to get the device pins

Change Log v1->v2:
- set the rinfo->pinctrl to dev->pins->p instead calling
  devm_pinctrl_get()

Hanna Hawa (2):
  pinctrl: Add an API to get the pinctrl pins if initialized
  i2c: Set i2c pinctrl recovery info from it's device pinctrl

 drivers/i2c/i2c-core-base.c     |  6 +++++-
 include/linux/pinctrl/devinfo.h | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized
  2022-12-21 20:51 [PATCH v4 0/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
@ 2022-12-21 20:51 ` Hanna Hawa
  2022-12-28 15:05   ` Andy Shevchenko
  2022-12-21 20:51 ` [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
  1 sibling, 1 reply; 5+ messages in thread
From: Hanna Hawa @ 2022-12-21 20:51 UTC (permalink / raw)
  To: wsa, linus.walleij, linux-i2c, linux-kernel, linux-gpio
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, farbere, itamark, hhhawa

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(+)

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 */
-- 
2.38.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl
  2022-12-21 20:51 [PATCH v4 0/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
  2022-12-21 20:51 ` [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized Hanna Hawa
@ 2022-12-21 20:51 ` Hanna Hawa
  2022-12-28 15:09   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Hanna Hawa @ 2022-12-21 20:51 UTC (permalink / raw)
  To: wsa, linus.walleij, linux-i2c, linux-kernel, linux-gpio
  Cc: dwmw, benh, ronenk, talel, jonnyc, hanochu, farbere, itamark, hhhawa

Currently the i2c subsystem rely on the controller device tree to
initialize the pinctrl recovery information, part of the drivers does
not set this field (rinfo->pinctrl), for example i2c designware driver.

The pins information is saved part of the device structure before probe
and it's done on pinctrl_bind_pins().

Make the i2c init recovery to get the device pins if it's not
initialized by the driver from the device pins.

Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
---
 drivers/i2c/i2c-core-base.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 7539b0740351..8c5f76c43dc8 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -34,6 +34,7 @@
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/devinfo.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_wakeirq.h>
@@ -282,7 +283,10 @@ static void i2c_gpio_init_pinctrl_recovery(struct i2c_adapter *adap)
 {
 	struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
 	struct device *dev = &adap->dev;
-	struct pinctrl *p = bri->pinctrl;
+	struct pinctrl *p;
+
+	bri->pinctrl = bri->pinctrl ?: dev_pinctrl(dev->parent);
+	p = bri->pinctrl;
 
 	/*
 	 * we can't change states without pinctrl, so remove the states if
-- 
2.38.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized
  2022-12-21 20:51 ` [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized Hanna Hawa
@ 2022-12-28 15:05   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-12-28 15:05 UTC (permalink / raw)
  To: Hanna Hawa
  Cc: wsa, linus.walleij, linux-i2c, linux-kernel, linux-gpio, dwmw,
	benh, ronenk, talel, jonnyc, hanochu, farbere, itamark

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>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl
  2022-12-21 20:51 ` [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
@ 2022-12-28 15:09   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-12-28 15:09 UTC (permalink / raw)
  To: Hanna Hawa
  Cc: wsa, linus.walleij, linux-i2c, linux-kernel, linux-gpio, dwmw,
	benh, ronenk, talel, jonnyc, hanochu, farbere, itamark

On Wed, Dec 21, 2022 at 08:51:16PM +0000, Hanna Hawa wrote:
> Currently the i2c subsystem rely on the controller device tree to
> initialize the pinctrl recovery information, part of the drivers does
> not set this field (rinfo->pinctrl), for example i2c designware driver.

DesignWare

> The pins information is saved part of the device structure before probe
> and it's done on pinctrl_bind_pins().
> 
> Make the i2c init recovery to get the device pins if it's not
> initialized by the driver from the device pins.

...

> -	struct pinctrl *p = bri->pinctrl;
> +	struct pinctrl *p;
> +
> +	bri->pinctrl = bri->pinctrl ?: dev_pinctrl(dev->parent);
> +	p = bri->pinctrl;

What about

	struct pinctrl *p = bri->pinctrl ?: dev_pinctrl(dev->parent);

	bri->pinctrl = p;

?

Seems like one line of code less.

Either way,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-28 15:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 20:51 [PATCH v4 0/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
2022-12-21 20:51 ` [PATCH v4 1/2] pinctrl: Add an API to get the pinctrl pins if initialized Hanna Hawa
2022-12-28 15:05   ` Andy Shevchenko
2022-12-21 20:51 ` [PATCH v4 2/2] i2c: Set i2c pinctrl recovery info from it's device pinctrl Hanna Hawa
2022-12-28 15:09   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®