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

Configure Feed

Select the types of activity you want to include in your feed.

Input: adxl34x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()

The I2C and SPI PM callbacks were identical (though wrapped in some
bouncing out to the bus specific container of the struct device and
then back again to get the drvdata). As such rather than just moving
these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity
to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS()
macro so that we can drop the unused suspend and resume callbacks as well
as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks
__maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20230114171620.42891-9-jic23@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jonathan Cameron and committed by
Dmitry Torokhov
40be0646 c0a150ee

+17 -55
+1 -24
drivers/input/misc/adxl34x-i2c.c
··· 105 105 adxl34x_remove(ac); 106 106 } 107 107 108 - static int __maybe_unused adxl34x_i2c_suspend(struct device *dev) 109 - { 110 - struct i2c_client *client = to_i2c_client(dev); 111 - struct adxl34x *ac = i2c_get_clientdata(client); 112 - 113 - adxl34x_suspend(ac); 114 - 115 - return 0; 116 - } 117 - 118 - static int __maybe_unused adxl34x_i2c_resume(struct device *dev) 119 - { 120 - struct i2c_client *client = to_i2c_client(dev); 121 - struct adxl34x *ac = i2c_get_clientdata(client); 122 - 123 - adxl34x_resume(ac); 124 - 125 - return 0; 126 - } 127 - 128 - static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend, 129 - adxl34x_i2c_resume); 130 - 131 108 static const struct i2c_device_id adxl34x_id[] = { 132 109 { "adxl34x", 0 }, 133 110 { } ··· 132 155 static struct i2c_driver adxl34x_driver = { 133 156 .driver = { 134 157 .name = "adxl34x", 135 - .pm = &adxl34x_i2c_pm, 158 + .pm = pm_sleep_ptr(&adxl34x_pm), 136 159 .of_match_table = adxl34x_of_id, 137 160 }, 138 161 .probe_new = adxl34x_i2c_probe,
+1 -24
drivers/input/misc/adxl34x-spi.c
··· 94 94 adxl34x_remove(ac); 95 95 } 96 96 97 - static int __maybe_unused adxl34x_spi_suspend(struct device *dev) 98 - { 99 - struct spi_device *spi = to_spi_device(dev); 100 - struct adxl34x *ac = spi_get_drvdata(spi); 101 - 102 - adxl34x_suspend(ac); 103 - 104 - return 0; 105 - } 106 - 107 - static int __maybe_unused adxl34x_spi_resume(struct device *dev) 108 - { 109 - struct spi_device *spi = to_spi_device(dev); 110 - struct adxl34x *ac = spi_get_drvdata(spi); 111 - 112 - adxl34x_resume(ac); 113 - 114 - return 0; 115 - } 116 - 117 - static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend, 118 - adxl34x_spi_resume); 119 - 120 97 static struct spi_driver adxl34x_driver = { 121 98 .driver = { 122 99 .name = "adxl34x", 123 - .pm = &adxl34x_spi_pm, 100 + .pm = pm_sleep_ptr(&adxl34x_pm), 124 101 }, 125 102 .probe = adxl34x_spi_probe, 126 103 .remove = adxl34x_spi_remove,
+13 -5
drivers/input/misc/adxl34x.c
··· 412 412 AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); 413 413 } 414 414 415 - void adxl34x_suspend(struct adxl34x *ac) 415 + static int adxl34x_suspend(struct device *dev) 416 416 { 417 + struct adxl34x *ac = dev_get_drvdata(dev); 418 + 417 419 mutex_lock(&ac->mutex); 418 420 419 421 if (!ac->suspended && !ac->disabled && ac->opened) ··· 424 422 ac->suspended = true; 425 423 426 424 mutex_unlock(&ac->mutex); 427 - } 428 - EXPORT_SYMBOL_GPL(adxl34x_suspend); 429 425 430 - void adxl34x_resume(struct adxl34x *ac) 426 + return 0; 427 + } 428 + 429 + static int adxl34x_resume(struct device *dev) 431 430 { 431 + struct adxl34x *ac = dev_get_drvdata(dev); 432 + 432 433 mutex_lock(&ac->mutex); 433 434 434 435 if (ac->suspended && !ac->disabled && ac->opened) ··· 440 435 ac->suspended = false; 441 436 442 437 mutex_unlock(&ac->mutex); 438 + 439 + return 0; 443 440 } 444 - EXPORT_SYMBOL_GPL(adxl34x_resume); 445 441 446 442 static ssize_t adxl34x_disable_show(struct device *dev, 447 443 struct device_attribute *attr, char *buf) ··· 911 905 kfree(ac); 912 906 } 913 907 EXPORT_SYMBOL_GPL(adxl34x_remove); 908 + 909 + EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume); 914 910 915 911 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 916 912 MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver");
+2 -2
drivers/input/misc/adxl34x.h
··· 20 20 int (*write)(struct device *, unsigned char, unsigned char); 21 21 }; 22 22 23 - void adxl34x_suspend(struct adxl34x *ac); 24 - void adxl34x_resume(struct adxl34x *ac); 25 23 struct adxl34x *adxl34x_probe(struct device *dev, int irq, 26 24 bool fifo_delay_default, 27 25 const struct adxl34x_bus_ops *bops); 28 26 void adxl34x_remove(struct adxl34x *ac); 27 + 28 + extern const struct dev_pm_ops adxl34x_pm; 29 29 30 30 #endif