All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: gyro: bmg160: Fix error handling in bmg160_core_probe
@ 2022-01-05 12:56 Miaoqian Lin
  2022-01-05 13:07 ` Jonathan Cameron
  2022-01-05 13:54 ` Andy Shevchenko
  0 siblings, 2 replies; 7+ messages in thread
From: Miaoqian Lin @ 2022-01-05 12:56 UTC (permalink / raw)
  Cc: linmq006, Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko,
	Linus Walleij, Alexandru Ardelean, Stephan Gerhold,
	Gwendal Grignou, Adriana Reus, linux-iio, linux-kernel

The pm_runtime_enable will increase power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable(). In the PM Runtime docs:
    Drivers in ->remove() callback should undo the runtime PM changes done
    in ->probe(). Usually this means calling pm_runtime_disable(),
    pm_runtime_dont_use_autosuspend() etc.
We should do this in error handling.

Fixes: 7d0ead5 ("iio: Reconcile operation order between iio_register/unregister and pm functions")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/iio/gyro/bmg160_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 17b939a367ad..81a6d09788bd 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -1188,11 +1188,14 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
 	ret = iio_device_register(indio_dev);
 	if (ret < 0) {
 		dev_err(dev, "unable to register iio device\n");
-		goto err_buffer_cleanup;
+		goto err_pm_cleanup;
 	}
 
 	return 0;
 
+err_pm_cleanup:
+	pm_runtime_dont_use_autosuspend(dev);
+	pm_runtime_disable(dev);
 err_buffer_cleanup:
 	iio_triggered_buffer_cleanup(indio_dev);
 err_trigger_unregister:
-- 
2.17.1


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

end of thread, other threads:[~2022-01-30 14:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 12:56 [PATCH] iio: gyro: bmg160: Fix error handling in bmg160_core_probe Miaoqian Lin
2022-01-05 13:07 ` Jonathan Cameron
2022-01-05 13:52   ` Andy Shevchenko
2022-01-05 13:54 ` Andy Shevchenko
2022-01-06 11:23   ` [PATCH v2] iio: Fix error handling for PM Miaoqian Lin
2022-01-07 11:59     ` Andy Shevchenko
2022-01-30 14:51       ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.