mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stepan Ionichev <sozdayvek@gmail.com>
To: jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] iio: adc: ti-ads1015: use devm_pm_runtime_enable() to fix probe error path
Date: Fri, 29 May 2026 15:10:11 +0500	[thread overview]
Message-ID: <20260529101011.3030-1-sozdayvek@gmail.com> (raw)

ads1015_probe() calls pm_runtime_enable() and then iio_device_register().
If iio_device_register() fails the function returns directly, leaving
runtime PM enabled and autosuspend in use. On subsequent probe/rebind
the runtime PM tracking complains about an unbalanced enable.

Switch to devm_pm_runtime_enable() so the enable (and the matching
dont_use_autosuspend) are torn down automatically on probe failure and
on driver unbind. The manual pm_runtime_disable() and
pm_runtime_set_suspended() calls in ads1015_remove() are no longer
needed and are dropped; the devm action runs after .remove() and now
handles the teardown. While here, convert the dev_err() + return to
dev_err_probe() to follow current style.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/adc/ti-ads1015.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index c7ffe47449e2..2331e946c519 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -1037,13 +1037,14 @@ static int ads1015_probe(struct i2c_client *client)
 		return ret;
 	pm_runtime_set_autosuspend_delay(&client->dev, ADS1015_SLEEP_DELAY_MS);
 	pm_runtime_use_autosuspend(&client->dev);
-	pm_runtime_enable(&client->dev);
+	ret = devm_pm_runtime_enable(&client->dev);
+	if (ret)
+		return ret;
 
 	ret = iio_device_register(indio_dev);
-	if (ret < 0) {
-		dev_err(&client->dev, "Failed to register IIO device\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&client->dev, ret,
+				     "Failed to register IIO device\n");
 
 	return 0;
 }
@@ -1056,9 +1057,6 @@ static void ads1015_remove(struct i2c_client *client)
 
 	iio_device_unregister(indio_dev);
 
-	pm_runtime_disable(&client->dev);
-	pm_runtime_set_suspended(&client->dev);
-
 	/* power down single shot mode */
 	ret = ads1015_set_conv_mode(data, ADS1015_SINGLESHOT);
 	if (ret)
-- 
2.43.0


             reply	other threads:[~2026-05-29 10:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 10:10 Stepan Ionichev [this message]
2026-05-29 11:07 ` Joshua Crofts
2026-05-29 17:34 ` 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=20260529101011.3030-1-sozdayvek@gmail.com \
    --to=sozdayvek@gmail.com \
    --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 \
    /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®