linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] i2c: core: Make debug message even more debuggish
@ 2021-05-28  9:13 Andy Shevchenko
  2021-05-28  9:13 ` [PATCH v2 2/2] i2c: core: Propagate all possible errors when requesting recovery GPIOs Andy Shevchenko
  2021-05-28 14:01 ` [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-05-28  9:13 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Wolfram Sang, Andy Shevchenko

One may notice that dev_printk(KERN_DEBUG ...) is *not* an equivalent
to dev_dbg(). It will be printed whenever loglevel is high enough.
And currently it will be the only message in the I²C core in some
configurations that got printed under above conditions.

Moving to dev_dbg() will hide it in the configurations where Dynamic Debug
is enabled and hence align with all other debug messages in the I²C core..

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: renamed error_or_debug to is_error_level (Wolfram)
 drivers/i2c/i2c-core-base.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 5a97e4a02fa2..ae1b1b610aca 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -399,7 +399,8 @@ static int i2c_gpio_init_recovery(struct i2c_adapter *adap)
 static int i2c_init_recovery(struct i2c_adapter *adap)
 {
 	struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
-	char *err_str, *err_level = KERN_ERR;
+	bool is_error_level = true;
+	char *err_str;
 
 	if (!bri)
 		return 0;
@@ -409,7 +410,7 @@ static int i2c_init_recovery(struct i2c_adapter *adap)
 
 	if (!bri->recover_bus) {
 		err_str = "no suitable method provided";
-		err_level = KERN_DEBUG;
+		is_error_level = false;
 		goto err;
 	}
 
@@ -436,7 +437,10 @@ static int i2c_init_recovery(struct i2c_adapter *adap)
 
 	return 0;
  err:
-	dev_printk(err_level, &adap->dev, "Not using recovery: %s\n", err_str);
+	if (is_error_level)
+		dev_err(&adap->dev, "Not using recovery: %s\n", err_str);
+	else
+		dev_dbg(&adap->dev, "Not using recovery: %s\n", err_str);
 	adap->bus_recovery_info = NULL;
 
 	return -EINVAL;
-- 
2.30.2


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

* [PATCH v2 2/2] i2c: core: Propagate all possible errors when requesting recovery GPIOs
  2021-05-28  9:13 [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Andy Shevchenko
@ 2021-05-28  9:13 ` Andy Shevchenko
  2021-05-28 14:01 ` [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-05-28  9:13 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Wolfram Sang, Andy Shevchenko

If GPIO is available but we can't get it by some other, than deferred probe,
reason, propagate it to the caller.

No functional change since i2c_register_adapter() still cares only about
deferred probe.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: made it as a series to avoid error when applying (LKP)
 drivers/i2c/i2c-core-base.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index ae1b1b610aca..40b8aa91db9a 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -348,19 +348,20 @@ static int i2c_gpio_init_generic_recovery(struct i2c_adapter *adap)
 	 * GPIO recovery is available
 	 */
 	if (!bri->scl_gpiod) {
-		gpiod = devm_gpiod_get(dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN);
-		if (PTR_ERR(gpiod) == -EPROBE_DEFER) {
-			ret  = -EPROBE_DEFER;
+		gpiod = devm_gpiod_get_optional(dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN);
+		if (IS_ERR(gpiod)) {
+			ret = PTR_ERR(gpiod);
 			goto cleanup_pinctrl_state;
 		}
-		if (!IS_ERR(gpiod)) {
+
+		if (gpiod) {
 			bri->scl_gpiod = gpiod;
 			bri->recover_bus = i2c_generic_scl_recovery;
 			dev_info(dev, "using generic GPIOs for recovery\n");
 		}
 	}
 
-	/* SDA GPIOD line is optional, so we care about DEFER only */
+	/* SDA GPIO line is optional */
 	if (!bri->sda_gpiod) {
 		/*
 		 * We have SCL. Pull SCL low and wait a bit so that SDA glitches
@@ -368,18 +369,19 @@ static int i2c_gpio_init_generic_recovery(struct i2c_adapter *adap)
 		 */
 		gpiod_direction_output(bri->scl_gpiod, 0);
 		udelay(10);
-		gpiod = devm_gpiod_get(dev, "sda", GPIOD_IN);
+
+		gpiod = devm_gpiod_get_optional(dev, "sda", GPIOD_IN);
 
 		/* Wait a bit in case of a SDA glitch, and then release SCL. */
 		udelay(10);
 		gpiod_direction_output(bri->scl_gpiod, 1);
 
-		if (PTR_ERR(gpiod) == -EPROBE_DEFER) {
-			ret = -EPROBE_DEFER;
+		if (IS_ERR(gpiod)) {
+			ret = PTR_ERR(gpiod);
 			goto cleanup_pinctrl_state;
 		}
-		if (!IS_ERR(gpiod))
-			bri->sda_gpiod = gpiod;
+
+		bri->sda_gpiod = gpiod;
 	}
 
 cleanup_pinctrl_state:
@@ -401,12 +403,14 @@ static int i2c_init_recovery(struct i2c_adapter *adap)
 	struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;
 	bool is_error_level = true;
 	char *err_str;
+	int ret;
 
 	if (!bri)
 		return 0;
 
-	if (i2c_gpio_init_recovery(adap) == -EPROBE_DEFER)
-		return -EPROBE_DEFER;
+	ret = i2c_gpio_init_recovery(adap);
+	if (ret)
+		return ret;
 
 	if (!bri->recover_bus) {
 		err_str = "no suitable method provided";
-- 
2.30.2


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

* Re: [PATCH v2 1/2] i2c: core: Make debug message even more debuggish
  2021-05-28  9:13 [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Andy Shevchenko
  2021-05-28  9:13 ` [PATCH v2 2/2] i2c: core: Propagate all possible errors when requesting recovery GPIOs Andy Shevchenko
@ 2021-05-28 14:01 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2021-05-28 14:01 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

On Fri, May 28, 2021 at 12:13:50PM +0300, Andy Shevchenko wrote:
> One may notice that dev_printk(KERN_DEBUG ...) is *not* an equivalent
> to dev_dbg(). It will be printed whenever loglevel is high enough.
> And currently it will be the only message in the I²C core in some
> configurations that got printed under above conditions.
> 
> Moving to dev_dbg() will hide it in the configurations where Dynamic Debug
> is enabled and hence align with all other debug messages in the I²C core..
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-05-28 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28  9:13 [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Andy Shevchenko
2021-05-28  9:13 ` [PATCH v2 2/2] i2c: core: Propagate all possible errors when requesting recovery GPIOs Andy Shevchenko
2021-05-28 14:01 ` [PATCH v2 1/2] i2c: core: Make debug message even more debuggish Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).