* [PATCH v3] iio: adc: ti-ads1015: fix conversion when CONFIG_PM is not set
@ 2020-07-29 10:35 Maxim Kochetkov
2020-08-01 15:57 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Maxim Kochetkov @ 2020-07-29 10:35 UTC (permalink / raw)
Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
Andy Shevchenko, Maxim Kochetkov, linux-iio, bigunclemax
To stop conversion ads1015_set_power_state() function call unimplemented
function __pm_runtime_suspend() from pm_runtime_put_autosuspend()
if CONFIG_PM is not set.
In case of CONFIG_PM is not set: __pm_runtime_suspend() returns -ENOSYS,
so ads1015_read_raw() failed because ads1015_set_power_state() returns an
error.
If CONFIG_PM is disabled, there is no need to start/stop conversion.
Fix it by adding return 0 function variant if CONFIG_PM is not set.
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Tested-by: Maxim Kiselev <bigunclemax@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/adc/ti-ads1015.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 5ea4f45d6bad..64fe3b2a6ec6 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -316,6 +316,7 @@ static const struct iio_chan_spec ads1115_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
};
+#ifdef CONFIG_PM
static int ads1015_set_power_state(struct ads1015_data *data, bool on)
{
int ret;
@@ -333,6 +334,15 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
return ret < 0 ? ret : 0;
}
+#else /* !CONFIG_PM */
+
+static int ads1015_set_power_state(struct ads1015_data *data, bool on)
+{
+ return 0;
+}
+
+#endif /* !CONFIG_PM */
+
static
int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
{
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] iio: adc: ti-ads1015: fix conversion when CONFIG_PM is not set
2020-07-29 10:35 [PATCH v3] iio: adc: ti-ads1015: fix conversion when CONFIG_PM is not set Maxim Kochetkov
@ 2020-08-01 15:57 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-08-01 15:57 UTC (permalink / raw)
To: Maxim Kochetkov
Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Andy Shevchenko,
linux-iio, bigunclemax
On Wed, 29 Jul 2020 13:35:23 +0300
Maxim Kochetkov <fido_max@inbox.ru> wrote:
> To stop conversion ads1015_set_power_state() function call unimplemented
> function __pm_runtime_suspend() from pm_runtime_put_autosuspend()
> if CONFIG_PM is not set.
> In case of CONFIG_PM is not set: __pm_runtime_suspend() returns -ENOSYS,
> so ads1015_read_raw() failed because ads1015_set_power_state() returns an
> error.
>
> If CONFIG_PM is disabled, there is no need to start/stop conversion.
> Fix it by adding return 0 function variant if CONFIG_PM is not set.
>
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> Tested-by: Maxim Kiselev <bigunclemax@gmail.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Patch looks good, but can I have a Fixes tag for it?
Thanks,
Jonathan
> ---
> drivers/iio/adc/ti-ads1015.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index 5ea4f45d6bad..64fe3b2a6ec6 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -316,6 +316,7 @@ static const struct iio_chan_spec ads1115_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
> };
>
> +#ifdef CONFIG_PM
> static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> {
> int ret;
> @@ -333,6 +334,15 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> return ret < 0 ? ret : 0;
> }
>
> +#else /* !CONFIG_PM */
> +
> +static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> +{
> + return 0;
> +}
> +
> +#endif /* !CONFIG_PM */
> +
> static
> int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
> {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-01 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 10:35 [PATCH v3] iio: adc: ti-ads1015: fix conversion when CONFIG_PM is not set Maxim Kochetkov
2020-08-01 15:57 ` 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).