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

iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20220130193147.279148-10-jic23@kernel.org

+3 -8
+3 -8
drivers/iio/accel/stk8ba50.c
··· 504 504 return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); 505 505 } 506 506 507 - #ifdef CONFIG_PM_SLEEP 508 507 static int stk8ba50_suspend(struct device *dev) 509 508 { 510 509 struct stk8ba50_data *data; ··· 522 523 return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL); 523 524 } 524 525 525 - static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume); 526 - 527 - #define STK8BA50_PM_OPS (&stk8ba50_pm_ops) 528 - #else 529 - #define STK8BA50_PM_OPS NULL 530 - #endif 526 + static DEFINE_SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, 527 + stk8ba50_resume); 531 528 532 529 static const struct i2c_device_id stk8ba50_i2c_id[] = { 533 530 {"stk8ba50", 0}, ··· 541 546 static struct i2c_driver stk8ba50_driver = { 542 547 .driver = { 543 548 .name = "stk8ba50", 544 - .pm = STK8BA50_PM_OPS, 549 + .pm = pm_sleep_ptr(&stk8ba50_pm_ops), 545 550 .acpi_match_table = ACPI_PTR(stk8ba50_acpi_id), 546 551 }, 547 552 .probe = stk8ba50_probe,