mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: "Linus Walleij" <linusw@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Antoniu Miclaus <antoniu.miclaus@analog.com>
Subject: [PATCH] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
Date: Fri, 30 Jan 2026 17:32:27 +0200	[thread overview]
Message-ID: <20260130153227.213413-2-antoniu.miclaus@analog.com> (raw)
In-Reply-To: <20260130153227.213413-1-antoniu.miclaus@analog.com>

Use pm_runtime_resume_and_get() in mpu3050_read_raw() and
mpu3050_buffer_preenable(), adding proper error handling. In
preenable, call pm_runtime_put_autosuspend() if set_8khz_samplerate()
fails since postdisable won't be called on preenable failure.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/gyro/mpu3050-core.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index ee2fcd20545d..1cc421eb4782 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -322,7 +322,9 @@ static int mpu3050_read_raw(struct iio_dev *indio_dev,
 		}
 	case IIO_CHAN_INFO_RAW:
 		/* Resume device */
-		pm_runtime_get_sync(mpu3050->dev);
+		ret = pm_runtime_resume_and_get(mpu3050->dev);
+		if (ret)
+			return ret;
 		mutex_lock(&mpu3050->lock);
 
 		ret = mpu3050_set_8khz_samplerate(mpu3050);
@@ -647,12 +649,19 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
 static int mpu3050_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct mpu3050 *mpu3050 = iio_priv(indio_dev);
+	int ret;
 
-	pm_runtime_get_sync(mpu3050->dev);
+	ret = pm_runtime_resume_and_get(mpu3050->dev);
+	if (ret)
+		return ret;
 
 	/* Unless we have OUR trigger active, run at full speed */
-	if (!mpu3050->hw_irq_trigger)
-		return mpu3050_set_8khz_samplerate(mpu3050);
+	if (!mpu3050->hw_irq_trigger) {
+		ret = mpu3050_set_8khz_samplerate(mpu3050);
+		if (ret)
+			pm_runtime_put_autosuspend(mpu3050->dev);
+		return ret;
+	}
 
 	return 0;
 }
-- 
2.43.0


  reply	other threads:[~2026-01-30 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 15:32 [PATCH] iio: gyro: mpu3050-i2c: " Antoniu Miclaus
2026-01-30 15:32 ` Antoniu Miclaus [this message]
2026-02-03  0:21   ` [PATCH] iio: gyro: mpu3050-core: " Linus Walleij
2026-01-31 16:41 ` [PATCH] iio: gyro: mpu3050-i2c: " Jonathan Cameron
2026-02-03  9:39   ` Nuno Sá
2026-02-03 11:13 ` Andy Shevchenko

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=20260130153227.213413-2-antoniu.miclaus@analog.com \
    --to=antoniu.miclaus@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linusw@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®