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 3/4] iio: temperature: mlx90614: use devm_pm_runtime_enable() to fix probe error path
Date: Fri, 29 May 2026 15:44:55 +0500	[thread overview]
Message-ID: <983359a9d0ebdad84f47a8ea95301a9626bf5abd.1780050609.git.sozdayvek@gmail.com> (raw)
In-Reply-To: <cover.1780050609.git.sozdayvek@gmail.com>

When data->wakeup_gpio is present, mlx90614_probe() enables runtime PM with pm_runtime_enable() and then calls the non-devm iio_device_register(). If iio_device_register() fails, probe returns without calling pm_runtime_disable(), leaving the runtime PM enable_count unbalanced. On a subsequent bind attempt the core complains with "Unbalanced pm_runtime_enable".

Switch to devm_pm_runtime_enable() so the framework disables runtime PM automatically when the device is unbound or when probe fails after this point. The corresponding pm_runtime_disable() and pm_runtime_set_suspended() calls in mlx90614_remove() become redundant and are removed; the existing pm_runtime_status_suspended() check and mlx90614_sleep() call are preserved so the part is still put to sleep on unbind when it was not already runtime-suspended.

The edits stay inside the existing if (data->wakeup_gpio) branches, so devices without a wakeup GPIO are unaffected.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/temperature/mlx90614.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index 1ad21b73e1b4..9e09597a1c31 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -625,7 +625,9 @@ static int mlx90614_probe(struct i2c_client *client)
 						 MLX90614_AUTOSLEEP_DELAY);
 		pm_runtime_use_autosuspend(&client->dev);
 		pm_runtime_set_active(&client->dev);
-		pm_runtime_enable(&client->dev);
+		ret = devm_pm_runtime_enable(&client->dev);
+		if (ret)
+			return ret;
 	}
 
 	return iio_device_register(indio_dev);
@@ -639,10 +641,8 @@ static void mlx90614_remove(struct i2c_client *client)
 	iio_device_unregister(indio_dev);
 
 	if (data->wakeup_gpio) {
-		pm_runtime_disable(&client->dev);
 		if (!pm_runtime_status_suspended(&client->dev))
 			mlx90614_sleep(data);
-		pm_runtime_set_suspended(&client->dev);
 	}
 }
 
-- 
2.43.0


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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 10:44 [PATCH 0/4] iio: fix PM-enable leak on probe error path across 4 drivers Stepan Ionichev
2026-05-29 10:44 ` [PATCH 1/4] iio: light: isl29028: use devm_pm_runtime_enable() to fix probe error path Stepan Ionichev
2026-05-29 10:44 ` [PATCH 2/4] iio: light: tsl2583: " Stepan Ionichev
2026-05-29 10:44 ` Stepan Ionichev [this message]
2026-05-29 10:44 ` [PATCH 4/4] iio: accel: bmi088-accel: " Stepan Ionichev
2026-05-29 11:11 ` [PATCH 0/4] iio: fix PM-enable leak on probe error path across 4 drivers Joshua Crofts

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=983359a9d0ebdad84f47a8ea95301a9626bf5abd.1780050609.git.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®