iio: magn: hmc5843: Move struct dev_pm_ops out of header

Having this structure defined static in the header lead to
unnecessary duplication and required additional symbol exports.
Use the EXPORT_NS_SIMPLE_DEV_PM_OPS() to clean this up in the same
fashion as many other drivers do this.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220807184534.1037363-3-jic23@kernel.org
This commit is contained in:
Jonathan Cameron 2022-08-07 19:45:34 +01:00
parent c3b4afb182
commit 71041f73dc
4 changed files with 7 additions and 18 deletions

View File

@ -52,16 +52,5 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
enum hmc5843_ids id, const char *name); enum hmc5843_ids id, const char *name);
void hmc5843_common_remove(struct device *dev); void hmc5843_common_remove(struct device *dev);
int hmc5843_common_suspend(struct device *dev); extern const struct dev_pm_ops hmc5843_pm_ops;
int hmc5843_common_resume(struct device *dev);
#ifdef CONFIG_PM_SLEEP
static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
hmc5843_common_suspend,
hmc5843_common_resume);
#define HMC5843_PM_OPS (&hmc5843_pm_ops)
#else
#define HMC5843_PM_OPS NULL
#endif
#endif /* HMC5843_CORE_H */ #endif /* HMC5843_CORE_H */

View File

@ -603,19 +603,19 @@ static const struct iio_info hmc5843_info = {
static const unsigned long hmc5843_scan_masks[] = {0x7, 0}; static const unsigned long hmc5843_scan_masks[] = {0x7, 0};
int hmc5843_common_suspend(struct device *dev) static int hmc5843_common_suspend(struct device *dev)
{ {
return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)), return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
HMC5843_MODE_SLEEP); HMC5843_MODE_SLEEP);
} }
EXPORT_SYMBOL_NS(hmc5843_common_suspend, IIO_HMC5843);
int hmc5843_common_resume(struct device *dev) static int hmc5843_common_resume(struct device *dev)
{ {
return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)), return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
HMC5843_MODE_CONVERSION_CONTINUOUS); HMC5843_MODE_CONVERSION_CONTINUOUS);
} }
EXPORT_SYMBOL_NS(hmc5843_common_resume, IIO_HMC5843); EXPORT_NS_SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_common_suspend,
hmc5843_common_resume, IIO_HMC5843);
int hmc5843_common_probe(struct device *dev, struct regmap *regmap, int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
enum hmc5843_ids id, const char *name) enum hmc5843_ids id, const char *name)

View File

@ -93,7 +93,7 @@ MODULE_DEVICE_TABLE(of, hmc5843_of_match);
static struct i2c_driver hmc5843_driver = { static struct i2c_driver hmc5843_driver = {
.driver = { .driver = {
.name = "hmc5843", .name = "hmc5843",
.pm = HMC5843_PM_OPS, .pm = pm_sleep_ptr(&hmc5843_pm_ops),
.of_match_table = hmc5843_of_match, .of_match_table = hmc5843_of_match,
}, },
.id_table = hmc5843_id, .id_table = hmc5843_id,

View File

@ -88,7 +88,7 @@ MODULE_DEVICE_TABLE(spi, hmc5843_id);
static struct spi_driver hmc5843_driver = { static struct spi_driver hmc5843_driver = {
.driver = { .driver = {
.name = "hmc5843", .name = "hmc5843",
.pm = HMC5843_PM_OPS, .pm = pm_sleep_ptr(&hmc5843_pm_ops),
}, },
.id_table = hmc5843_id, .id_table = hmc5843_id,
.probe = hmc5843_spi_probe, .probe = hmc5843_spi_probe,