Skip to contentSkip to conversation

iio: gyro: bmg160: only set power state if PM_RUNTIME is defined

PATCH Superseded Irina Tirdea 2 participants 3 messages Sep 2, 2014 – Sep 8, 2014 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 7524698..e41d6b5 100644
@@ -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
#1 lore raw
Quoted 5 lines · Irina Tirdea

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.

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
---
 drivers/iio/gyro/bmg160.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/iio/gyro/bmg160.c +7 -0
index 7524698..e41d6b5 100644
@@ -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)
#2 lore raw
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_RUNTIME is not defined and bmg160 tries to power off the device, bmg160_set_power_state will call pm_runtime_put_autosus=

pend,

Quoted 4 lines
Quoted 3 lines

which is not implemented (wil return -ENOSYS).

Only call bmg160_set_power_state when CONFIG_PM_RUNTIME is 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

---

Thanks,
Irina