mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Can Peng <pengcan@kylinos.cn>
To: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
	andy@kernel.org, rajat.khandelwal@linux.intel.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Can Peng <pengcan@kylinos.cn>,
	stable@vger.kernel.org
Subject: [PATCH] iio: pressure: mpl115: Fix runtime PM cleanup on probe failure
Date: Sat, 18 Jul 2026 14:19:09 +0800	[thread overview]
Message-ID: <20260718061909.428476-1-pengcan@kylinos.cn> (raw)

mpl115_probe() enables runtime PM when a shutdown GPIO is present and
then returns the result of devm_iio_device_register(). If registration
fails, runtime PM remains enabled and autosuspend remains selected.

The same unmanaged runtime PM state is also left behind on driver
unbind, as the IIO device registration is managed but the runtime PM
setup is not.

Use devm_pm_runtime_enable() so runtime PM is disabled automatically
on probe failure and driver unbind. Also unwind the initial
pm_runtime_get_noresume() reference if setting up runtime PM fails
before the matching put.

Fixes: 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio")
Cc: stable@vger.kernel.org
Signed-off-by: Can Peng <pengcan@kylinos.cn>
---
 drivers/iio/pressure/mpl115.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
index 16e112b796ba..9e77b76bd1fa 100644
--- a/drivers/iio/pressure/mpl115.c
+++ b/drivers/iio/pressure/mpl115.c
@@ -204,8 +204,17 @@ int mpl115_probe(struct device *dev, const char *name,
 	if (data->shutdown) {
 		/* Enable runtime PM */
 		pm_runtime_get_noresume(dev);
-		pm_runtime_set_active(dev);
-		pm_runtime_enable(dev);
+		ret = pm_runtime_set_active(dev);
+		if (ret) {
+			pm_runtime_put_noidle(dev);
+			return ret;
+		}
+
+		ret = devm_pm_runtime_enable(dev);
+		if (ret) {
+			pm_runtime_put_noidle(dev);
+			return ret;
+		}
 
 		/*
 		 * As the device takes 3 ms to come up with a fresh
-- 
2.53.0


             reply	other threads:[~2026-07-18  6:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18  6:19 Can Peng [this message]
2026-07-18 22:14 ` 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=20260718061909.428476-1-pengcan@kylinos.cn \
    --to=pengcan@kylinos.cn \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=rajat.khandelwal@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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 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®