iio: gyro: bmg160: only set power state if PM_RUNTIME is defined
PATCH 1/1 iio: gyro: bmg160: only set power state if PM_RUNTIME is defined
When CONFIG_PM_RUNTIME is not defined and bmg160 tries to power off the device, bmg160_set_power_state will call pm_runtime_put_autosuspend, which is not implemented (wil return -ENOSYS).
Only call bmg160_set_power_state when CONFIG_PM_RUNTIME is defined.
--- drivers/iio/gyro/bmg160.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/gyro/bmg160.c +7 -0
@@ -235,6 +235,7 @@ static int bmg160_chip_init(struct bmg160_data *data)return 0 ; } +#ifdef CONFIG_PM_RUNTIME static int bmg160_set_power_state (struct bmg160_data *data,bool on) {int ret;
@@ -254,6 +255,12 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on) return 0; } +#else +static int bmg160_set_power_state (struct bmg160_data *data,bool on) +{ +return 0 ; +} +#endif static int bmg160_setup_any_motion_interrupt (struct bmg160_data *data,bool status)
Signature · 1 line
1.7.9.5
Quoted 5 lines · Irina Tirdea
When
CONFIG_PM_RUNTIMEis not defined and bmg160 tries to power off the device,bmg160_set_power_statewill callpm_runtime_put_autosuspend, which is not implemented (wil return-ENOSYS).Only call
bmg160_set_power_statewhenCONFIG_PM_RUNTIMEis defined.
Unless there is anything more to come, what about putting the #ifdef into first line inside bmg160_set_power_state() and just an #endif before the return 0 at the end? Saves 5 lines.
Quoted 31 lines
Signed-off-by Irina Tirdea <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>--- drivers/iio/gyro/bmg160.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/iio/gyro/bmg160.c +7
-0@@ -235,6 +235,7 @@ static int bmg160_chip_init(struct bmg160_data *data)return 0 ; } +#ifdef CONFIG_PM_RUNTIME static int bmg160_set_power_state (struct bmg160_data *data,bool on) {int ret;@@ -254,6 +255,12 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on) return 0; } +#else +static int bmg160_set_power_state (struct bmg160_data *data,bool on) +{ +return 0 ; +} +#endif static int bmg160_setup_any_motion_interrupt (struct bmg160_data *data,bool status)
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]=
.org] On Behalf Of Hartmut Knaack
Quoted 3 lines
Sent: 06 September, 2014 15:12
To: Tirdea, Irina; Jonathan Cameron; [email protected]
Cc: Lars-Peter Clausen; Peter Meerwald; Srinivas Pandruvada; linux-kernel=
@vger.kernel.org
Quoted 1 line
Subject: Re: [PATCH] iio: gyro: bmg160: only set power state if PM_RUNTIM=
E is defined
Quoted 4 lines
=20
Quoted 2 lines · Irina Tirdea
When
CONFIG_PM_RUNTIMEis not defined and bmg160 tries to power off the device,bmg160_set_power_statewill call pm_runtime_put_autosus=
pend,
Quoted 4 lines
Quoted 3 lines
which is not implemented (wil return
-ENOSYS).Only call
bmg160_set_power_statewhenCONFIG_PM_RUNTIMEis defined.Unless there is anything more to come, what about putting the #ifdef into=
first line inside bmg160_set_power_state() and just an
Quoted 1 line
#endif before the return 0 at the end? Saves 5 lines.
Thanks for the suggestion! Will fix it in v2.
Quoted 3 lines
Quoted 3 lines
Signed-off-by Irina Tirdea <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>---
Thanks,
Irina