@@ -105,29 +105,6 @@ static void adxl34x_i2c_remove(struct i2c_client *client)
adxl34x_remove(ac);
}
-static int __maybe_unused adxl34x_i2c_suspend(struct device *dev)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct adxl34x *ac = i2c_get_clientdata(client);
-
- adxl34x_suspend(ac);
-
- return 0;
-}
-
-static int __maybe_unused adxl34x_i2c_resume(struct device *dev)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct adxl34x *ac = i2c_get_clientdata(client);
-
- adxl34x_resume(ac);
-
- return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend,
- adxl34x_i2c_resume);
-
static const struct i2c_device_id adxl34x_id[] = {
{ "adxl34x", 0 },
{ }
@@ -155,7 +132,7 @@ MODULE_DEVICE_TABLE(of, adxl34x_of_id);
static struct i2c_driver adxl34x_driver = {
.driver = {
.name = "adxl34x",
- .pm = &adxl34x_i2c_pm,
+ .pm = pm_sleep_ptr(&adxl34x_pm),
.of_match_table = adxl34x_of_id,
},
.probe_new = adxl34x_i2c_probe,
@@ -94,33 +94,10 @@ static void adxl34x_spi_remove(struct spi_device *spi)
adxl34x_remove(ac);
}
-static int __maybe_unused adxl34x_spi_suspend(struct device *dev)
-{
- struct spi_device *spi = to_spi_device(dev);
- struct adxl34x *ac = spi_get_drvdata(spi);
-
- adxl34x_suspend(ac);
-
- return 0;
-}
-
-static int __maybe_unused adxl34x_spi_resume(struct device *dev)
-{
- struct spi_device *spi = to_spi_device(dev);
- struct adxl34x *ac = spi_get_drvdata(spi);
-
- adxl34x_resume(ac);
-
- return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend,
- adxl34x_spi_resume);
-
static struct spi_driver adxl34x_driver = {
.driver = {
.name = "adxl34x",
- .pm = &adxl34x_spi_pm,
+ .pm = pm_sleep_ptr(&adxl34x_pm),
},
.probe = adxl34x_spi_probe,
.remove = adxl34x_spi_remove,
@@ -412,8 +412,10 @@ static void __adxl34x_enable(struct adxl34x *ac)
AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE);
}
-void adxl34x_suspend(struct adxl34x *ac)
+static int adxl34x_suspend(struct device *dev)
{
+ struct adxl34x *ac = dev_get_drvdata(dev);
+
mutex_lock(&ac->mutex);
if (!ac->suspended && !ac->disabled && ac->opened)
@@ -422,11 +424,14 @@ void adxl34x_suspend(struct adxl34x *ac)
ac->suspended = true;
mutex_unlock(&ac->mutex);
+
+ return 0;
}
-EXPORT_SYMBOL_GPL(adxl34x_suspend);
-void adxl34x_resume(struct adxl34x *ac)
+static int adxl34x_resume(struct device *dev)
{
+ struct adxl34x *ac = dev_get_drvdata(dev);
+
mutex_lock(&ac->mutex);
if (ac->suspended && !ac->disabled && ac->opened)
@@ -435,8 +440,9 @@ void adxl34x_resume(struct adxl34x *ac)
ac->suspended = false;
mutex_unlock(&ac->mutex);
+
+ return 0;
}
-EXPORT_SYMBOL_GPL(adxl34x_resume);
static ssize_t adxl34x_disable_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -906,6 +912,8 @@ void adxl34x_remove(struct adxl34x *ac)
}
EXPORT_SYMBOL_GPL(adxl34x_remove);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume);
+
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver");
MODULE_LICENSE("GPL");
@@ -20,11 +20,11 @@ struct adxl34x_bus_ops {
int (*write)(struct device *, unsigned char, unsigned char);
};
-void adxl34x_suspend(struct adxl34x *ac);
-void adxl34x_resume(struct adxl34x *ac);
struct adxl34x *adxl34x_probe(struct device *dev, int irq,
bool fifo_delay_default,
const struct adxl34x_bus_ops *bops);
void adxl34x_remove(struct adxl34x *ac);
+extern const struct dev_pm_ops adxl34x_pm;
+
#endif