* [PATCH v2 05/12] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
[not found] <20250708231144.971170-1-sakari.ailus@linux.intel.com>
2025-07-08 23:11 ` [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
@ 2025-07-08 23:11 ` Sakari Ailus
2025-07-09 8:48 ` Andy Shevchenko
1 sibling, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2025-07-08 23:11 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Maxime Coquelin, Alexandre Torgue, Sakari Ailus,
Uwe Kleine-König
Cc: linux-iio, linux-stm32, linux-arm-kernel, linux-kernel
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().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/iio/dac/stm32-dac.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index 344388338d9b..0988c991cf60 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -95,18 +95,14 @@ 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);
+ if (!enable)
pm_runtime_put_autosuspend(dev);
- }
return 0;
err_put_pm:
- if (enable) {
- pm_runtime_mark_last_busy(dev);
+ if (enable)
pm_runtime_put_autosuspend(dev);
- }
return ret;
}
@@ -349,7 +345,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.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls
[not found] <20250708231144.971170-1-sakari.ailus@linux.intel.com>
@ 2025-07-08 23:11 ` Sakari Ailus
2025-07-09 3:52 ` Chen-Yu Tsai
2025-07-09 15:37 ` Jonathan Cameron
2025-07-08 23:11 ` [PATCH v2 05/12] iio: dac: " Sakari Ailus
1 sibling, 2 replies; 7+ messages in thread
From: Sakari Ailus @ 2025-07-08 23:11 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Cai Huoqing, Haibo Chen, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Marek Vasut,
Geert Uytterhoeven, Magnus Damm, Lad Prabhakar, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Francesco Dolcini, João Paulo Gonçalves,
Jiri Slaby (SUSE), Uwe Kleine-König, Thomas Gleixner,
Fabrice Gasnier, Rob Herring (Arm), Sakari Ailus,
Christophe JAILLET, Julien Stephan
Cc: linux-arm-kernel, linux-iio, linux-kernel, imx, linux-renesas-soc,
linux-stm32, linux-sunxi
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().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/iio/adc/ab8500-gpadc.c | 1 -
drivers/iio/adc/at91-sama5d2_adc.c | 13 +------------
drivers/iio/adc/imx8qxp-adc.c | 2 --
drivers/iio/adc/imx93_adc.c | 1 -
drivers/iio/adc/rcar-gyroadc.c | 8 +++-----
drivers/iio/adc/rzg2l_adc.c | 6 +-----
drivers/iio/adc/stm32-adc-core.c | 1 -
drivers/iio/adc/stm32-adc.c | 7 -------
drivers/iio/adc/sun4i-gpadc-iio.c | 2 --
drivers/iio/adc/ti-ads1015.c | 6 ++----
drivers/iio/adc/ti-ads1100.c | 1 -
drivers/iio/adc/ti-ads1119.c | 2 --
12 files changed, 7 insertions(+), 43 deletions(-)
diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index f3b057f92310..8eaa1dd6a89b 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -607,7 +607,6 @@ static int ab8500_gpadc_read(struct ab8500_gpadc *gpadc,
}
/* This eventually drops the regulator */
- pm_runtime_mark_last_busy(gpadc->dev);
pm_runtime_put_autosuspend(gpadc->dev);
return (high_data << 8) | low_data;
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index c3450246730e..b4c36e6a7490 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -896,7 +896,6 @@ static int at91_adc_config_emr(struct at91_adc_state *st,
emr |= osr | AT91_SAMA5D2_TRACKX(trackx);
at91_adc_writel(st, EMR, emr);
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
st->oversampling_ratio = oversampling_ratio;
@@ -971,7 +970,6 @@ static int at91_adc_configure_touch(struct at91_adc_state *st, bool state)
AT91_SAMA5D2_IER_PEN | AT91_SAMA5D2_IER_NOPEN);
at91_adc_writel(st, TSMR, 0);
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return 0;
}
@@ -1142,10 +1140,8 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
at91_adc_configure_trigger_registers(st, state);
- if (!state) {
- pm_runtime_mark_last_busy(st->dev);
+ if (!state)
pm_runtime_put_autosuspend(st->dev);
- }
return 0;
}
@@ -1336,7 +1332,6 @@ static int at91_adc_buffer_prepare(struct iio_dev *indio_dev)
at91_adc_writel(st, IER, AT91_SAMA5D2_IER_DRDY);
pm_runtime_put:
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return ret;
}
@@ -1394,7 +1389,6 @@ static int at91_adc_buffer_postdisable(struct iio_dev *indio_dev)
if (st->dma_st.dma_chan)
dmaengine_terminate_sync(st->dma_st.dma_chan);
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return 0;
@@ -1603,7 +1597,6 @@ static void at91_adc_setup_samp_freq(struct iio_dev *indio_dev, unsigned freq,
mr |= AT91_SAMA5D2_MR_TRACKTIM(tracktim);
at91_adc_writel(st, MR, mr);
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u, tracktim=%u\n",
@@ -1809,7 +1802,6 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
at91_adc_readl(st, LCDR);
pm_runtime_put:
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return ret;
}
@@ -1890,7 +1882,6 @@ static int at91_adc_read_temp(struct iio_dev *indio_dev,
restore_config:
/* Revert previous settings. */
at91_adc_temp_sensor_configure(st, false);
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
if (ret < 0)
return ret;
@@ -2465,7 +2456,6 @@ static int at91_adc_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "version: %x\n",
readl_relaxed(st->base + st->soc_info.platform->layout->VERSION));
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return 0;
@@ -2567,7 +2557,6 @@ static int at91_adc_resume(struct device *dev)
at91_adc_configure_trigger_registers(st, true);
}
- pm_runtime_mark_last_busy(st->dev);
pm_runtime_put_autosuspend(st->dev);
return 0;
diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
index be13a6ed7e00..d9da24efdcbe 100644
--- a/drivers/iio/adc/imx8qxp-adc.c
+++ b/drivers/iio/adc/imx8qxp-adc.c
@@ -229,7 +229,6 @@ static int imx8qxp_adc_read_raw(struct iio_dev *indio_dev,
ret = wait_for_completion_interruptible_timeout(&adc->completion,
IMX8QXP_ADC_TIMEOUT);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_sync_autosuspend(dev);
if (ret == 0) {
@@ -295,7 +294,6 @@ static int imx8qxp_adc_reg_access(struct iio_dev *indio_dev, unsigned int reg,
*readval = readl(adc->regs + reg);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_sync_autosuspend(dev);
return 0;
diff --git a/drivers/iio/adc/imx93_adc.c b/drivers/iio/adc/imx93_adc.c
index 7feaafd2316f..bb5bd22269b9 100644
--- a/drivers/iio/adc/imx93_adc.c
+++ b/drivers/iio/adc/imx93_adc.c
@@ -248,7 +248,6 @@ static int imx93_adc_read_raw(struct iio_dev *indio_dev,
mutex_lock(&adc->lock);
ret = imx93_adc_read_channel_conversion(adc, chan->channel, val);
mutex_unlock(&adc->lock);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_sync_autosuspend(dev);
if (ret < 0)
return ret;
diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index cc326f21d398..3a17b3898bf6 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -163,12 +163,10 @@ static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on)
{
struct device *dev = priv->dev;
- if (on) {
+ if (on)
return pm_runtime_resume_and_get(dev);
- } else {
- pm_runtime_mark_last_busy(dev);
- return pm_runtime_put_autosuspend(dev);
- }
+
+ return pm_runtime_put_autosuspend(dev);
}
static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
index 9674d48074c9..39389091ee29 100644
--- a/drivers/iio/adc/rzg2l_adc.c
+++ b/drivers/iio/adc/rzg2l_adc.c
@@ -249,7 +249,6 @@ static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc
rzg2l_adc_start_stop(adc, false);
rpm_put:
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
}
@@ -411,7 +410,6 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc)
rzg2l_adc_writel(adc, RZG2L_ADM(3), reg);
exit_hw_init:
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
}
@@ -590,10 +588,8 @@ static int rzg2l_adc_resume(struct device *dev)
return 0;
rpm_restore:
- if (adc->was_rpm_active) {
- pm_runtime_mark_last_busy(dev);
+ if (adc->was_rpm_active)
pm_runtime_put_autosuspend(dev);
- }
resets_restore:
reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
return ret;
diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index dea166c53369..b42fee4a4695 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -795,7 +795,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
goto err_irq_remove;
}
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return 0;
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 588c69e175f5..54147d0afc0f 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -1528,7 +1528,6 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev,
stm32_adc_conv_irq_disable(adc);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
@@ -1564,7 +1563,6 @@ static int stm32_adc_write_raw(struct iio_dev *indio_dev,
adc->cfg->set_ovs(indio_dev, idx);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
adc->ovs_idx = idx;
@@ -1759,7 +1757,6 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
adc->num_conv = bitmap_weight(scan_mask, iio_get_masklength(indio_dev));
ret = stm32_adc_conf_scan_seq(indio_dev, scan_mask);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
@@ -1808,7 +1805,6 @@ static int stm32_adc_debugfs_reg_access(struct iio_dev *indio_dev,
else
*readval = stm32_adc_readl(adc, reg);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return 0;
@@ -1954,7 +1950,6 @@ static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev)
err_clr_trig:
stm32_adc_set_trig(indio_dev, NULL);
err_pm_put:
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
@@ -1977,7 +1972,6 @@ static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev)
if (stm32_adc_set_trig(indio_dev, NULL))
dev_err(&indio_dev->dev, "Can't clear trigger\n");
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return 0;
@@ -2614,7 +2608,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
goto err_hw_stop;
}
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
if (IS_ENABLED(CONFIG_DEBUG_FS))
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 6b8d6bee1873..a439f4864111 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -245,7 +245,6 @@ static int sun4i_gpadc_read(struct iio_dev *indio_dev, int channel, int *val,
*val = info->temp_data;
ret = 0;
- pm_runtime_mark_last_busy(indio_dev->dev.parent);
err:
pm_runtime_put_autosuspend(indio_dev->dev.parent);
@@ -272,7 +271,6 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
- pm_runtime_mark_last_busy(indio_dev->dev.parent);
pm_runtime_put_autosuspend(indio_dev->dev.parent);
return 0;
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 48549d617e5f..f2a93c63ca14 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -374,12 +374,10 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
int ret;
struct device *dev = regmap_get_device(data->regmap);
- if (on) {
+ if (on)
ret = pm_runtime_resume_and_get(dev);
- } else {
- pm_runtime_mark_last_busy(dev);
+ else
ret = pm_runtime_put_autosuspend(dev);
- }
return ret < 0 ? ret : 0;
}
diff --git a/drivers/iio/adc/ti-ads1100.c b/drivers/iio/adc/ti-ads1100.c
index b0790e300b18..aa8946063c7d 100644
--- a/drivers/iio/adc/ti-ads1100.c
+++ b/drivers/iio/adc/ti-ads1100.c
@@ -105,7 +105,6 @@ static int ads1100_get_adc_result(struct ads1100_data *data, int chan, int *val)
ret = i2c_master_recv(data->client, (char *)&buffer, sizeof(buffer));
- pm_runtime_mark_last_busy(&data->client->dev);
pm_runtime_put_autosuspend(&data->client->dev);
if (ret < 0) {
diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
index d2f86e1ec656..9f576cfe63f9 100644
--- a/drivers/iio/adc/ti-ads1119.c
+++ b/drivers/iio/adc/ti-ads1119.c
@@ -291,7 +291,6 @@ static int ads1119_single_conversion(struct ads1119_state *st,
*val = sign_extend32(sample, chan->scan_type.realbits - 1);
ret = IIO_VAL_INT;
pdown:
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return ret;
}
@@ -470,7 +469,6 @@ static int ads1119_triggered_buffer_postdisable(struct iio_dev *indio_dev)
if (ret)
return ret;
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return 0;
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls
2025-07-08 23:11 ` [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
@ 2025-07-09 3:52 ` Chen-Yu Tsai
2025-07-09 15:37 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2025-07-09 3:52 UTC (permalink / raw)
To: Sakari Ailus
Cc: Linus Walleij, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Eugen Hristev, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Cai Huoqing, Haibo Chen, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Marek Vasut,
Geert Uytterhoeven, Magnus Damm, Lad Prabhakar, Maxime Coquelin,
Alexandre Torgue, Jernej Skrabec, Samuel Holland,
Francesco Dolcini, João Paulo Gonçalves,
Jiri Slaby (SUSE), Uwe Kleine-König, Thomas Gleixner,
Fabrice Gasnier, Rob Herring (Arm), Christophe JAILLET,
Julien Stephan, linux-arm-kernel, linux-iio, linux-kernel, imx,
linux-renesas-soc, linux-stm32, linux-sunxi
On Wed, Jul 9, 2025 at 7:12 AM 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().
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/iio/adc/sun4i-gpadc-iio.c | 2 --
Acked-by: Chen-Yu Tsai <wens@csie.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 05/12] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
2025-07-08 23:11 ` [PATCH v2 05/12] iio: dac: " Sakari Ailus
@ 2025-07-09 8:48 ` Andy Shevchenko
2025-07-09 15:49 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2025-07-09 8:48 UTC (permalink / raw)
To: Sakari Ailus
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Maxime Coquelin, Alexandre Torgue, Uwe Kleine-König,
linux-iio, linux-stm32, linux-arm-kernel, linux-kernel
On Wed, Jul 09, 2025 at 02:11:52AM +0300, Sakari Ailus 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().
...
> - if (!enable) {
> - pm_runtime_mark_last_busy(dev);
> + if (!enable)
> pm_runtime_put_autosuspend(dev);
> - }
>
> return 0;
>
> err_put_pm:
> - if (enable) {
> - pm_runtime_mark_last_busy(dev);
> + if (enable)
> pm_runtime_put_autosuspend(dev);
> - }
>
> return ret;
Hmm... Why not simply
ret = 0;
err_put_pm:
if (enable)
pm_runtime_put_autosuspend(dev);
return ret;
instead of the duplication?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls
2025-07-08 23:11 ` [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
2025-07-09 3:52 ` Chen-Yu Tsai
@ 2025-07-09 15:37 ` Jonathan Cameron
2025-08-25 11:57 ` Sakari Ailus
1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2025-07-09 15:37 UTC (permalink / raw)
To: Sakari Ailus
Cc: Linus Walleij, David Lechner, Nuno Sá, Andy Shevchenko,
Eugen Hristev, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Cai Huoqing, Haibo Chen, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Marek Vasut,
Geert Uytterhoeven, Magnus Damm, Lad Prabhakar, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Francesco Dolcini, João Paulo Gonçalves,
Jiri Slaby (SUSE), Uwe Kleine-König, Thomas Gleixner,
Fabrice Gasnier, Rob Herring (Arm), Christophe JAILLET,
Julien Stephan, linux-arm-kernel, linux-iio, linux-kernel, imx,
linux-renesas-soc, linux-stm32, linux-sunxi
On Wed, 9 Jul 2025 02:11:52 +0300
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().
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Some comments for the future as more about what can be improved on the back
of this than what you have here.
>
> diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
> index cc326f21d398..3a17b3898bf6 100644
> --- a/drivers/iio/adc/rcar-gyroadc.c
> +++ b/drivers/iio/adc/rcar-gyroadc.c
> @@ -163,12 +163,10 @@ static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on)
> {
> struct device *dev = priv->dev;
>
This is a very clear example of where the *_set_power() pattern is a bad idea.
There are two calls of this function, one with it hard coded as on and one with it
hard coded as off. We can just push the pm_runtime_resume_and_get()
to the on case etc.
I don't mind that much if we do so as a follow up patch so this one can
be the mechanical change and then we follow up with the enabled simplification.
> - if (on) {
> + if (on)
> return pm_runtime_resume_and_get(dev);
> - } else {
> - pm_runtime_mark_last_busy(dev);
> - return pm_runtime_put_autosuspend(dev);
> - }
> +
> + return pm_runtime_put_autosuspend(dev);
> }
>
> static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev,
>> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index 48549d617e5f..f2a93c63ca14 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -374,12 +374,10 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> int ret;
> struct device *dev = regmap_get_device(data->regmap);
>
> - if (on) {
> + if (on)
> ret = pm_runtime_resume_and_get(dev);
> - } else {
> - pm_runtime_mark_last_busy(dev);
> + else
> ret = pm_runtime_put_autosuspend(dev);
> - }
>
> return ret < 0 ? ret : 0;
So this one has a stub version which only brings benefits because
we have checks on the pm_runtime_put_autosuspend() path failing
(which it does if we have !CONFIG_PM).
I think the right option there is check the return value is < 0
for the resume_and_get() and don't check the _put_autosuspend()
return value at all. Then we can just push this down to the
call sites as all of them hard code the bool value.
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 05/12] iio: dac: Remove redundant pm_runtime_mark_last_busy() calls
2025-07-09 8:48 ` Andy Shevchenko
@ 2025-07-09 15:49 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2025-07-09 15:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, David Lechner, Nuno Sá, Andy Shevchenko,
Maxime Coquelin, Alexandre Torgue, Uwe Kleine-König,
linux-iio, linux-stm32, linux-arm-kernel, linux-kernel
On Wed, 9 Jul 2025 11:48:04 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Wed, Jul 09, 2025 at 02:11:52AM +0300, Sakari Ailus 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().
>
> ...
>
> > - if (!enable) {
> > - pm_runtime_mark_last_busy(dev);
> > + if (!enable)
> > pm_runtime_put_autosuspend(dev);
> > - }
> >
> > return 0;
> >
> > err_put_pm:
> > - if (enable) {
> > - pm_runtime_mark_last_busy(dev);
> > + if (enable)
> > pm_runtime_put_autosuspend(dev);
> > - }
> >
> > return ret;
>
>
> Hmm... Why not simply
>
> ret = 0;
It's already zero (as last call was a regmap_update_bits() return value ) so even easier.
However, switch if (ret < 0) to if (ret) for that regmap call
to make that more obvious.
>
> err_put_pm:
> if (enable)
> pm_runtime_put_autosuspend(dev);
>
> return ret;
>
> instead of the duplication?
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls
2025-07-09 15:37 ` Jonathan Cameron
@ 2025-08-25 11:57 ` Sakari Ailus
0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2025-08-25 11:57 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Linus Walleij, David Lechner, Nuno Sá, Andy Shevchenko,
Eugen Hristev, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Cai Huoqing, Haibo Chen, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Marek Vasut,
Geert Uytterhoeven, Magnus Damm, Lad Prabhakar, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Francesco Dolcini, João Paulo Gonçalves,
Jiri Slaby (SUSE), Uwe Kleine-König, Thomas Gleixner,
Fabrice Gasnier, Rob Herring (Arm), Christophe JAILLET,
Julien Stephan, linux-arm-kernel, linux-iio, linux-kernel, imx,
linux-renesas-soc, linux-stm32, linux-sunxi
Hi Jonathan,
Thanks for the review.
On Wed, Jul 09, 2025 at 04:37:56PM +0100, Jonathan Cameron wrote:
> On Wed, 9 Jul 2025 02:11:52 +0300
> 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().
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Some comments for the future as more about what can be improved on the back
> of this than what you have here.
>
> >
> > diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
> > index cc326f21d398..3a17b3898bf6 100644
> > --- a/drivers/iio/adc/rcar-gyroadc.c
> > +++ b/drivers/iio/adc/rcar-gyroadc.c
> > @@ -163,12 +163,10 @@ static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on)
> > {
> > struct device *dev = priv->dev;
> >
> This is a very clear example of where the *_set_power() pattern is a bad idea.
> There are two calls of this function, one with it hard coded as on and one with it
> hard coded as off. We can just push the pm_runtime_resume_and_get()
> to the on case etc.
>
> I don't mind that much if we do so as a follow up patch so this one can
> be the mechanical change and then we follow up with the enabled simplification.
Ack. I presume this pattern is due to one driver having used it first and
then other drivers copying that. I haven't seen it elsewhere, or at least
not being used as widely.
>
> > - if (on) {
> > + if (on)
> > return pm_runtime_resume_and_get(dev);
> > - } else {
> > - pm_runtime_mark_last_busy(dev);
> > - return pm_runtime_put_autosuspend(dev);
> > - }
> > +
> > + return pm_runtime_put_autosuspend(dev);
> > }
> >
> > static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev,
> >> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> > index 48549d617e5f..f2a93c63ca14 100644
> > --- a/drivers/iio/adc/ti-ads1015.c
> > +++ b/drivers/iio/adc/ti-ads1015.c
> > @@ -374,12 +374,10 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> > int ret;
> > struct device *dev = regmap_get_device(data->regmap);
> >
> > - if (on) {
> > + if (on)
> > ret = pm_runtime_resume_and_get(dev);
> > - } else {
> > - pm_runtime_mark_last_busy(dev);
> > + else
> > ret = pm_runtime_put_autosuspend(dev);
> > - }
> >
> > return ret < 0 ? ret : 0;
> So this one has a stub version which only brings benefits because
> we have checks on the pm_runtime_put_autosuspend() path failing
> (which it does if we have !CONFIG_PM).
>
> I think the right option there is check the return value is < 0
> for the resume_and_get() and don't check the _put_autosuspend()
> return value at all. Then we can just push this down to the
> call sites as all of them hard code the bool value.
Ack.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-25 12:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250708231144.971170-1-sakari.ailus@linux.intel.com>
2025-07-08 23:11 ` [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls Sakari Ailus
2025-07-09 3:52 ` Chen-Yu Tsai
2025-07-09 15:37 ` Jonathan Cameron
2025-08-25 11:57 ` Sakari Ailus
2025-07-08 23:11 ` [PATCH v2 05/12] iio: dac: " Sakari Ailus
2025-07-09 8:48 ` Andy Shevchenko
2025-07-09 15:49 ` Jonathan Cameron
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).