public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths
@ 2022-05-20  9:54 Wolfram Sang
  2022-05-21  6:17 ` Wolfram Sang
  2022-05-23  8:07 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Wolfram Sang @ 2022-05-20  9:54 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc, Kuninori Morimoto, Wolfram Sang

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We have to take care of ID_P_PM_BLOCKED when bailing out during probe.

Fixes: 7ee24eb508d6 ("i2c: rcar: disable PM in multi-master mode")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Changes since v1:
* fixed some exit points to 'out_pm_put' so the fix actually gets applied
* added special handling for errors on clock calculation
* reworded commit message and subject

 drivers/i2c/busses/i2c-rcar.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index ca61dbe218bf..3e49e652d83c 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -1086,8 +1086,10 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 	ret = rcar_i2c_clock_calculate(priv);
-	if (ret < 0)
-		goto out_pm_put;
+	if (ret < 0) {
+		pm_runtime_put(dev);
+		goto out_pm_disable;
+	}
 
 	rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
 
@@ -1116,19 +1118,19 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0)
-		goto out_pm_disable;
+		goto out_pm_put;
 	priv->irq = ret;
 	ret = devm_request_irq(dev, priv->irq, irqhandler, irqflags, dev_name(dev), priv);
 	if (ret < 0) {
 		dev_err(dev, "cannot get irq %d\n", priv->irq);
-		goto out_pm_disable;
+		goto out_pm_put;
 	}
 
 	platform_set_drvdata(pdev, priv);
 
 	ret = i2c_add_numbered_adapter(adap);
 	if (ret < 0)
-		goto out_pm_disable;
+		goto out_pm_put;
 
 	if (priv->flags & ID_P_HOST_NOTIFY) {
 		priv->host_notify_client = i2c_new_slave_host_notify_device(adap);
@@ -1145,7 +1147,8 @@ static int rcar_i2c_probe(struct platform_device *pdev)
  out_del_device:
 	i2c_del_adapter(&priv->adap);
  out_pm_put:
-	pm_runtime_put(dev);
+	if (priv->flags & ID_P_PM_BLOCKED)
+		pm_runtime_put(dev);
  out_pm_disable:
 	pm_runtime_disable(dev);
 	return ret;
-- 
2.35.1


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

* Re: [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths
  2022-05-20  9:54 [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths Wolfram Sang
@ 2022-05-21  6:17 ` Wolfram Sang
  2022-05-23  8:07 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2022-05-21  6:17 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc, Kuninori Morimoto

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

On Fri, May 20, 2022 at 11:54:21AM +0200, Wolfram Sang wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> We have to take care of ID_P_PM_BLOCKED when bailing out during probe.
> 
> Fixes: 7ee24eb508d6 ("i2c: rcar: disable PM in multi-master mode")
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.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

* Re: [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths
  2022-05-20  9:54 [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths Wolfram Sang
  2022-05-21  6:17 ` Wolfram Sang
@ 2022-05-23  8:07 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-05-23  8:07 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Linux I2C, Linux-Renesas, Kuninori Morimoto

Hi Wolfram,

On Sat, May 21, 2022 at 1:48 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> We have to take care of ID_P_PM_BLOCKED when bailing out during probe.
>
> Fixes: 7ee24eb508d6 ("i2c: rcar: disable PM in multi-master mode")
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2022-05-23  8:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-20  9:54 [PATCH v2] i2c: rcar: fix PM ref counts in probe error paths Wolfram Sang
2022-05-21  6:17 ` Wolfram Sang
2022-05-23  8:07 ` Geert Uytterhoeven

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