iio: pressure: bmp280: return on runtime PM resume failure
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
@@ -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
Quoted 2 lines · Yash Suthar
Replace
pm_runtime_get_sync()withpm_runtime_resume_and_get()and propagate error.
...
Review
Quoted 4 lines
static int bmp280_read_raw(struct
iio_dev*indio_dev,
{(quoted diff) +0
-0struct 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
-2struct 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
-2struct 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
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
PATCH v2 1/1 iio: pressure: bmp280: return on runtime PM resume failure
In reply to Yash SutharReplace 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
@@ -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
Quoted 5 lines · Yash Suthar
Replace
pm_runtime_get_sync()withpm_runtime_resume_and_get()and propagate error.Signed-off-by Yash Suthar <[email protected]>---
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
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
Jonathan Cameron
maintainerQuoted 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 inbmp280_buffer_preenable().
- Drop thebmp280_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