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

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

+3 -7
+3 -7
drivers/iio/accel/dmard06.c
··· 170 170 return devm_iio_device_register(&client->dev, indio_dev); 171 171 } 172 172 173 - #ifdef CONFIG_PM_SLEEP 174 173 static int dmard06_suspend(struct device *dev) 175 174 { 176 175 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); ··· 198 199 return 0; 199 200 } 200 201 201 - static SIMPLE_DEV_PM_OPS(dmard06_pm_ops, dmard06_suspend, dmard06_resume); 202 - #define DMARD06_PM_OPS (&dmard06_pm_ops) 203 - #else 204 - #define DMARD06_PM_OPS NULL 205 - #endif 202 + static DEFINE_SIMPLE_DEV_PM_OPS(dmard06_pm_ops, dmard06_suspend, 203 + dmard06_resume); 206 204 207 205 static const struct i2c_device_id dmard06_id[] = { 208 206 { "dmard05", 0 }, ··· 223 227 .driver = { 224 228 .name = DMARD06_DRV_NAME, 225 229 .of_match_table = dmard06_of_match, 226 - .pm = DMARD06_PM_OPS, 230 + .pm = pm_sleep_ptr(&dmard06_pm_ops), 227 231 }, 228 232 }; 229 233 module_i2c_driver(dmard06_driver);