* [PATCH v4 1/1] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
@ 2025-08-25 20:52 Sakari Ailus
2025-08-26 8:05 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Sakari Ailus @ 2025-08-25 20:52 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin,
Alexandre Torgue, linux-iio, linux-stm32, linux-arm-kernel,
linux-kernel, Uwe Kleine-König
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().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
since v3:
- Fix condition for calling pm_runtime_put_autosuspend().
drivers/iio/dac/stm32-dac.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index 344388338d9b..874e6dcc0d61 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -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;
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4 1/1] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
2025-08-25 20:52 [PATCH v4 1/1] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
@ 2025-08-26 8:05 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2025-08-26 8:05 UTC (permalink / raw)
To: Sakari Ailus
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Maxime Coquelin, Alexandre Torgue, linux-iio, linux-stm32,
linux-arm-kernel, linux-kernel, Uwe Kleine-König
On Mon, Aug 25, 2025 at 11:53 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> 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().
TL;DR: I think this change makes it harder to follow (due to complex
conditional).
...
> 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;
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.
> }
...
> - 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;
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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-26 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 20:52 [PATCH v4 1/1] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
2025-08-26 8:05 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).