All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linmq006@gmail.com, Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandru Ardelean <ardeleanalex@gmail.com>,
	Stephan Gerhold <stephan@gerhold.net>,
	Gwendal Grignou <gwendal@chromium.org>,
	Adriana Reus <adi.reus@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] iio: gyro: bmg160: Fix error handling in bmg160_core_probe
Date: Wed,  5 Jan 2022 12:56:30 +0000	[thread overview]
Message-ID: <20220105125633.21989-1-linmq006@gmail.com> (raw)

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


             reply	other threads:[~2022-01-05 12:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 12:56 Miaoqian Lin [this message]
2022-01-05 13:07 ` [PATCH] iio: gyro: bmg160: Fix error handling in bmg160_core_probe 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220105125633.21989-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=adi.reus@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ardeleanalex@gmail.com \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stephan@gerhold.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.