Skip to contentSkip to conversation

iio: pressure: bmp280: return on runtime PM resume failure

PATCH Superseded Yash Suthar 3 participants 7 messages Jun 16 – Jun 23 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: pressure: bmp280: return on runtime PM resume failure

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and propagate error.

---
 drivers/iio/pressure/bmp280-core.c | 32 ++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/iio/pressure/bmp280-core.c +24 -8
index d983ce9c0b99..7f4b0976ff22 100644
@@ -749,8 +749,10 @@ static int bmp280_read_raw(struct iio_dev *indio_dev,
 {
 	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	pm_runtime_get_sync(data->dev);
 	ret = bmp280_read_raw_impl(indio_dev, chan, val, val2, mask);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -923,8 +925,10 @@ static int bmp280_write_raw(struct iio_dev *indio_dev,
 {
 	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	pm_runtime_get_sync(data->dev);
 	ret = bmp280_write_raw_impl(indio_dev, chan, val, val2, mask);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -2253,8 +2257,10 @@ static int bmp580_nvmem_read(void *priv, unsigned int offset, void *val,
 {
 	struct bmp280_data *data = priv;
 	int ret;
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	pm_runtime_get_sync(data->dev);
 	ret = bmp580_nvmem_read_impl(priv, offset, val, bytes);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -2327,8 +2333,10 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
 {
 	struct bmp280_data *data = priv;
 	int ret;
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	pm_runtime_get_sync(data->dev);
 	ret = bmp580_nvmem_write_impl(priv, offset, val, bytes);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -3108,9 +3116,17 @@ EXPORT_SYMBOL_NS(bmp085_chip_info, "IIO_BMP280");
 static int bmp280_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct bmp280_data *data = iio_priv(indio_dev);
+	int ret;
 
-	pm_runtime_get_sync(data->dev);
-	data->chip_info->set_mode(data, BMP280_NORMAL);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
+	ret = data->chip_info->set_mode(data, BMP280_NORMAL);
+	if (ret) {
+		pm_runtime_put_autosuspend(data->dev);
+		return ret;
+	}
 
 	return 0;
 }
@@ -3133,8 +3149,8 @@ static void bmp280_pm_disable(void *data)
 {
 	struct device *dev = data;
 
-	pm_runtime_get_sync(dev);
-	pm_runtime_put_noidle(dev);
+	if (pm_runtime_resume_and_get(dev) >= 0)
+		pm_runtime_put_noidle(dev);
 	pm_runtime_disable(dev);
 }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 2 lines · Yash Suthar

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and propagate error.

...

Review

Quoted 4 lines

static int bmp280_read_raw(struct iio_dev *indio_dev,
{

(quoted diff) +0 -0
 	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;

No, here must be a blank line. And so on...

Quoted 7 lines
drivers/iio/pressure/bmp280-core.c +3 -1
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	pm_runtime_get_sync(data->dev);
 	ret = bmp280_read_raw_impl(indio_dev, chan, val, val2, mask);
 	pm_runtime_put_autosuspend(data->dev);

...

Quoted 8 lines

static int bmp280_buffer_preenable(struct iio_dev *indio_dev) {

drivers/iio/pressure/bmp280-core.c +2 -2
 	struct bmp280_data *data = iio_priv(indio_dev);
+	int ret;
 
-	pm_runtime_get_sync(data->dev);
-	data->chip_info->set_mode(data, BMP280_NORMAL);
+	ret = pm_runtime_resume_and_get(data->dev);

drivers/iio/pressure/bmp280-core.c EXPORT_SYMBOL_NS(bmp085_chip_info, "IIO_BMP280"); · line 3131

Quoted 10 lines
drivers/iio/pressure/bmp280-core.c +8 -0
+	if (ret < 0)
+		return ret;
+
+	ret = data->chip_info->set_mode(data, BMP280_NORMAL);
+	if (ret) {
+		pm_runtime_put_autosuspend(data->dev);
+		return ret;
+	}
 
 	return 0;

Also possible

	ret = data->chip_info->set_mode(data, BMP280_NORMAL);
	if (ret)
		pm_runtime_put_autosuspend(data->dev);

	return ret;
Quoted 1 line

}

...

drivers/iio/pressure/bmp280-core.c static void bmp280_pm_disable(void *data)

Quoted 8 lines

static void bmp280_pm_disable(void *data)
{

drivers/iio/pressure/bmp280-core.c +1 -2
 	struct device *dev = data;
 
-	pm_runtime_get_sync(dev);
-	pm_runtime_put_noidle(dev);
 
+	if (pm_runtime_resume_and_get(dev) >= 0)

Why this change?

Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1 -0
+		pm_runtime_put_noidle(dev);
 	pm_runtime_disable(dev);
 }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

Thanks for the review.

Quoted 9 lines

No, here must be a blank line. And so on...

Also possible

	ret = data->chip_info->set_mode(data, BMP280_NORMAL);
	if (ret)
		pm_runtime_put_autosuspend(data->dev);

	return ret;

Agreed, will ship in v2.

Quoted 1 line

Why this change?

Fair, there is nothing to propagate, will drop that change in v2. The intent is to use pm_runtime_resume_and_get() instead of pm_runtime_get_sync().

Sincerly,
Yash Suthar

#3 lore raw

PATCH v2 1/1 iio: pressure: bmp280: return on runtime PM resume failure

In reply to Yash Suthar

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and propagate error.

---
 drivers/iio/pressure/bmp280-core.c | 32 +++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/iio/pressure/bmp280-core.c +25 -7
index d983ce9c0b99..e2e22b1c7288 100644
@@ -750,7 +750,10 @@ static int bmp280_read_raw(struct iio_dev *indio_dev,
 	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
-	pm_runtime_get_sync(data->dev);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = bmp280_read_raw_impl(indio_dev, chan, val, val2, mask);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -924,7 +927,10 @@ static int bmp280_write_raw(struct iio_dev *indio_dev,
 	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
-	pm_runtime_get_sync(data->dev);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = bmp280_write_raw_impl(indio_dev, chan, val, val2, mask);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -2254,7 +2260,10 @@ static int bmp580_nvmem_read(void *priv, unsigned int offset, void *val,
 	struct bmp280_data *data = priv;
 	int ret;
 
-	pm_runtime_get_sync(data->dev);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = bmp580_nvmem_read_impl(priv, offset, val, bytes);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -2328,7 +2337,10 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
 	struct bmp280_data *data = priv;
 	int ret;
 
-	pm_runtime_get_sync(data->dev);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = bmp580_nvmem_write_impl(priv, offset, val, bytes);
 	pm_runtime_put_autosuspend(data->dev);
 
@@ -3108,11 +3120,17 @@ EXPORT_SYMBOL_NS(bmp085_chip_info, "IIO_BMP280");
 static int bmp280_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct bmp280_data *data = iio_priv(indio_dev);
+	int ret;
 
-	pm_runtime_get_sync(data->dev);
-	data->chip_info->set_mode(data, BMP280_NORMAL);
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
 
-	return 0;
+	ret = data->chip_info->set_mode(data, BMP280_NORMAL);
+	if (ret)
+		pm_runtime_put_autosuspend(data->dev);
+
+	return ret;
 }
 
 static int bmp280_buffer_postdisable(struct iio_dev *indio_dev)
Signature · 1 line
2.43.0
#4 lore raw
Quoted 5 lines · Yash Suthar

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and propagate error.

---

v2? Where is the changelog, please?

(This time just reply to this email with a changelog text, next time put it for
a single patch after the '---' line.)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

v2:
- Restore the blank line after the variable.
- Simplify the error path in bmp280_buffer_preenable().
- Drop the bmp280_pm_disable() change, because no caller to propagate the error.

Sincerely,
Yash Suthar

maintainer
#6 lore raw
Quoted 6 lines · On Wed, 17 Jun 2026 13:50:58 +0530 Yash Suthar <[email protected]> wrote:

v2:
- Restore the blank line after the variable.
- Simplify the error path in bmp280_buffer_preenable().
- Drop the bmp280_pm_disable() change, because no caller to propagate the error.

Applied to the testing branch of iio.git which will get rebase on rc1 once available.

thanks,

Jonathan

Quoted 2 lines

Sincerely,
Yash Suthar