Skip to contentSkip to conversation

pwm: pca9685: replace CONFIG_PM with __maybe_unused to prevent build issues

PATCH In review Rishi Gupta 2 participants 5 messages Mar 11, 2020 – Mar 21, 2020 PWM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: pca9685: replace CONFIG_PM with __maybe_unused to prevent build issues

The __maybe_unused attribute is preferred over CONFIG_PM to prevent build time issues. This commit replaces CONFIG_PM with this attribute.

---
 drivers/pwm/pwm-pca9685.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pwm/pwm-pca9685.c +2 -4
index b07bdca..b2a9e77 100644
@@ -512,8 +512,7 @@ static int pca9685_pwm_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int pca9685_pwm_runtime_suspend(struct device *dev)
+static int __maybe_unused pca9685_pwm_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct pca9685 *pca = i2c_get_clientdata(client);
@@ -522,7 +521,7 @@ static int pca9685_pwm_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int pca9685_pwm_runtime_resume(struct device *dev)
+static int __maybe_unused pca9685_pwm_runtime_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct pca9685 *pca = i2c_get_clientdata(client);
@@ -530,7 +529,6 @@ static int pca9685_pwm_runtime_resume(struct device *dev)
 	pca9685_set_sleep_mode(pca, false);
 	return 0;
 }
-#endif
 
 static const struct i2c_device_id pca9685_id[] = {
 	{ "pca9685", 0 },
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Rishi Gupta

The __maybe_unused attribute is preferred over CONFIG_PM to prevent build time issues. This commit replaces CONFIG_PM with this attribute.

I wasn't aware of build time issues and thought this was just about #ifdef being ugly.

Anyhow, the change is fine,

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw

These 2 links contains more details:
https://lore.kernel.org/patchwork/patch/732981
https://lkml.org/lkml/2019/1/17/437

Quoted 17 lines · Uwe Kleine-König
Quoted 3 lines · Rishi Gupta

The __maybe_unused attribute is preferred over CONFIG_PM to prevent build time issues. This commit replaces CONFIG_PM with this attribute.

I wasn't aware of build time issues and thought this was just about #ifdef being ugly.

Anyhow, the change is fine,

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

#4 lore raw

Tested again and found one gerrit was missing in my local build. Both __maybe_unused and CONFIG_PM are working fine.

So it is your choice to apply or not apply this patch.

Regards,
Rishi

Quoted 15 lines · Uwe Kleine-König
Quoted 3 lines · rishi gupta

These 2 links contains more details:
https://lore.kernel.org/patchwork/patch/732981
https://lkml.org/lkml/2019/1/17/437

These are both about SIMPLE_DEV_PM_OPS which doesn't apply to pwm-pca9685.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |