iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
PATCH v4 1/1 iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(), pm_runtime_autosuspend() and pm_request_autosuspend() now include a call to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to pm_runtime_mark_last_busy().
Also clean up error handling in stm32_dac_set_enable_state().
---
since v3:
- Fix condition for calling pm_runtime_put_autosuspend().
drivers/iio/dac/stm32-dac.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/iio/dac/stm32-dac.c +4 -14
@@ -82,9 +82,9 @@ static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, ret =regmap_update_bits (dac->common->regmap,STM32_DAC_CR , msk, en);mutex_unlock (&dac->lock); -if (ret <0 ) { +if (ret) {dev_err (&indio_dev->dev,"%s failed\n" ,str_enable_disable (en)); - goto err_put_pm; + goto err_pm_put; }/*
@@ -95,18 +95,9 @@ static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch,if (en && dac->common->hfsel)udelay (1 ); -if (!enable) { -pm_runtime_mark_last_busy (dev); -pm_runtime_put_autosuspend (dev); - } - -return 0 ; - -err_put_pm: -if (enable) { -pm_runtime_mark_last_busy (dev); +err_pm_put: +if (!enable || (enable && ret))pm_runtime_put_autosuspend (dev); - }return ret; }
@@ -349,7 +340,6 @@ static int stm32_dac_probe(struct platform_device *pdev)if (ret) goto err_pm_put; -pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev);return 0 ;
Signature · 1 line
2.47.2
Quoted 7 lines · Sakari Ailus
pm_runtime_put_autosuspend(),pm_runtime_put_sync_autosuspend(),pm_runtime_autosuspend()andpm_request_autosuspend()now include a call topm_runtime_mark_last_busy(). Remove the now-reduntant explicit call topm_runtime_mark_last_busy().Also clean up error handling in
stm32_dac_set_enable_state().
TL;DR: I think this change makes it harder to follow (due to complex conditional).
...
drivers/iio/dac/stm32-dac.c static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, · line 87
Quoted 7 lines
ret = regmap_update_bits(dac->common->regmap, STM32_DAC_CR, msk, en); mutex_unlock(&dac->lock);drivers/iio/dac/stm32-dac.c +2
-2-if (ret <0 ) { +if (ret) {dev_err (&indio_dev->dev,"%s failed\n" ,str_enable_disable (en)); - goto err_put_pm; + goto err_pm_put;
This is one time use for the label and we know that ret is set here.
Just
if (enable)
pm_runtime_put_autosuspend(dev);
return ret;should work.
Quoted 1 line
}
...
Quoted 6 lines
drivers/iio/dac/stm32-dac.c +0
-6-if (!enable) { -pm_runtime_mark_last_busy (dev); -pm_runtime_put_autosuspend (dev); - } - -return 0 ;
drivers/iio/dac/stm32-dac.c static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, · line 102
Quoted 10 lines
drivers/iio/dac/stm32-dac.c +2
-5- -err_put_pm: -if (enable) { -pm_runtime_mark_last_busy (dev); +err_pm_put: +if (!enable || (enable && ret))pm_runtime_put_autosuspend (dev); - }return ret;
And here is as simple as
if (!enable)
pm_runtime_put_autosuspend(dev);
return 0;
and remove the unneeded label altogether with the error path.
Signature · 2 lines
With Best Regards, Andy Shevchenko