Skip to content

Commit 73568f9

Browse files
jic23groeck
authored andcommitted
hwmon: (tmp102) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of #ifdef guards whilst achieving the same result. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20220925172759.3573439-15-jic23@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 1839391 commit 73568f9

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/hwmon/tmp102.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ static int tmp102_probe(struct i2c_client *client)
260260
return 0;
261261
}
262262

263-
#ifdef CONFIG_PM_SLEEP
264263
static int tmp102_suspend(struct device *dev)
265264
{
266265
struct i2c_client *client = to_i2c_client(dev);
@@ -283,9 +282,8 @@ static int tmp102_resume(struct device *dev)
283282

284283
return err;
285284
}
286-
#endif /* CONFIG_PM */
287285

288-
static SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume);
286+
static DEFINE_SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume);
289287

290288
static const struct i2c_device_id tmp102_id[] = {
291289
{ "tmp102", 0 },
@@ -302,7 +300,7 @@ MODULE_DEVICE_TABLE(of, tmp102_of_match);
302300
static struct i2c_driver tmp102_driver = {
303301
.driver.name = DRIVER_NAME,
304302
.driver.of_match_table = of_match_ptr(tmp102_of_match),
305-
.driver.pm = &tmp102_dev_pm_ops,
303+
.driver.pm = pm_sleep_ptr(&tmp102_dev_pm_ops),
306304
.probe_new = tmp102_probe,
307305
.id_table = tmp102_id,
308306
};

0 commit comments

Comments
 (0)