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

iio:accel:stk8312: 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-39-jic23@kernel.org

+3 -8
+3 -8
drivers/iio/accel/stk8312.c
··· 611 611 return stk8312_set_mode(data, STK8312_MODE_STANDBY); 612 612 } 613 613 614 - #ifdef CONFIG_PM_SLEEP 615 614 static int stk8312_suspend(struct device *dev) 616 615 { 617 616 struct stk8312_data *data; ··· 629 630 return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE); 630 631 } 631 632 632 - static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume); 633 - 634 - #define STK8312_PM_OPS (&stk8312_pm_ops) 635 - #else 636 - #define STK8312_PM_OPS NULL 637 - #endif 633 + static DEFINE_SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, 634 + stk8312_resume); 638 635 639 636 static const struct i2c_device_id stk8312_i2c_id[] = { 640 637 /* Deprecated in favour of lowercase form */ ··· 643 648 static struct i2c_driver stk8312_driver = { 644 649 .driver = { 645 650 .name = STK8312_DRIVER_NAME, 646 - .pm = STK8312_PM_OPS, 651 + .pm = pm_sleep_ptr(&stk8312_pm_ops), 647 652 }, 648 653 .probe = stk8312_probe, 649 654 .remove = stk8312_remove,