Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: pcf50633: Remove #ifdef guards for PM related functions

Use the new EXPORT_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros
to handle the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Paul Cercueil and committed by
Lee Jones
245cb473 e1243e0d

+11 -30
+1 -21
drivers/mfd/pcf50633-core.c
··· 158 158 } 159 159 } 160 160 161 - #ifdef CONFIG_PM_SLEEP 162 - static int pcf50633_suspend(struct device *dev) 163 - { 164 - struct i2c_client *client = to_i2c_client(dev); 165 - struct pcf50633 *pcf = i2c_get_clientdata(client); 166 - 167 - return pcf50633_irq_suspend(pcf); 168 - } 169 - 170 - static int pcf50633_resume(struct device *dev) 171 - { 172 - struct i2c_client *client = to_i2c_client(dev); 173 - struct pcf50633 *pcf = i2c_get_clientdata(client); 174 - 175 - return pcf50633_irq_resume(pcf); 176 - } 177 - #endif 178 - 179 - static SIMPLE_DEV_PM_OPS(pcf50633_pm, pcf50633_suspend, pcf50633_resume); 180 - 181 161 static const struct regmap_config pcf50633_regmap_config = { 182 162 .reg_bits = 8, 183 163 .val_bits = 8, ··· 279 299 static struct i2c_driver pcf50633_driver = { 280 300 .driver = { 281 301 .name = "pcf50633", 282 - .pm = &pcf50633_pm, 302 + .pm = pm_sleep_ptr(&pcf50633_pm), 283 303 }, 284 304 .id_table = pcf50633_id_table, 285 305 .probe_new = pcf50633_probe,
+8 -5
drivers/mfd/pcf50633-irq.c
··· 7 7 * All rights reserved. 8 8 */ 9 9 10 + #include <linux/i2c.h> 10 11 #include <linux/interrupt.h> 11 12 #include <linux/kernel.h> 12 13 #include <linux/mutex.h> ··· 219 218 return IRQ_HANDLED; 220 219 } 221 220 222 - #ifdef CONFIG_PM 223 - 224 - int pcf50633_irq_suspend(struct pcf50633 *pcf) 221 + static int pcf50633_suspend(struct device *dev) 225 222 { 223 + struct i2c_client *client = to_i2c_client(dev); 224 + struct pcf50633 *pcf = i2c_get_clientdata(client); 226 225 int ret; 227 226 int i; 228 227 u8 res[5]; ··· 258 257 return ret; 259 258 } 260 259 261 - int pcf50633_irq_resume(struct pcf50633 *pcf) 260 + static int pcf50633_resume(struct device *dev) 262 261 { 262 + struct i2c_client *client = to_i2c_client(dev); 263 + struct pcf50633 *pcf = i2c_get_clientdata(client); 263 264 int ret; 264 265 265 266 /* Write the saved mask registers */ ··· 276 273 return ret; 277 274 } 278 275 279 - #endif 276 + EXPORT_GPL_SIMPLE_DEV_PM_OPS(pcf50633_pm, pcf50633_suspend, pcf50633_resume); 280 277 281 278 int pcf50633_irq_init(struct pcf50633 *pcf, int irq) 282 279 {
+2 -4
include/linux/mfd/pcf50633/core.h
··· 13 13 #include <linux/workqueue.h> 14 14 #include <linux/regulator/driver.h> 15 15 #include <linux/regulator/machine.h> 16 + #include <linux/pm.h> 16 17 #include <linux/power_supply.h> 17 18 #include <linux/mfd/pcf50633/backlight.h> 18 19 ··· 227 226 228 227 int pcf50633_irq_init(struct pcf50633 *pcf, int irq); 229 228 void pcf50633_irq_free(struct pcf50633 *pcf); 230 - #ifdef CONFIG_PM 231 - int pcf50633_irq_suspend(struct pcf50633 *pcf); 232 - int pcf50633_irq_resume(struct pcf50633 *pcf); 233 - #endif 229 + extern const struct dev_pm_ops pcf50633_pm; 234 230 235 231 #endif