Skip to contentSkip to conversation

Input: ad7877 - Convert to dev_pm_ops

PATCH Applied Mark Brown 3 participants 7 messages Jan 20, 2011 – Jan 21, 2011

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/3 Input: ad7877 - Convert to dev_pm_ops

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ad7879 SPI driver.

---
 drivers/input/touchscreen/ad7877.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ad7877.c +9 -10
index a1952fc..714d4e0 100644
@@ -41,6 +41,7 @@
 #include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/pm.h>
 #include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ad7877.h>
@@ -826,39 +827,37 @@ static int __devexit ad7877_remove(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int ad7877_suspend(struct spi_device *spi, pm_message_t message)
+#ifdef CONFIG_PM_SLEEP
+static int ad7877_suspend(struct device *dev)
 {
-	struct ad7877 *ts = dev_get_drvdata(&spi->dev);
+	struct ad7877 *ts = dev_get_drvdata(dev);
 
 	ad7877_disable(ts);
 
 	return 0;
 }
 
-static int ad7877_resume(struct spi_device *spi)
+static int ad7877_resume(struct device *dev)
 {
-	struct ad7877 *ts = dev_get_drvdata(&spi->dev);
+	struct ad7877 *ts = dev_get_drvdata(dev);
 
 	ad7877_enable(ts);
 
 	return 0;
 }
-#else
-#define ad7877_suspend NULL
-#define ad7877_resume  NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume);
+
 static struct spi_driver ad7877_driver = {
 	.driver = {
 		.name	= "ad7877",
 		.bus	= &spi_bus_type,
 		.owner	= THIS_MODULE,
+		.pm	= &ad7877_pm,
 	},
 	.probe		= ad7877_probe,
 	.remove		= __devexit_p(ad7877_remove),
-	.suspend	= ad7877_suspend,
-	.resume		= ad7877_resume,
 };
 
 static int __init ad7877_init(void)
Signature · 1 line
1.7.2.3
author
#1 lore raw

PATCH 2/3 Input: ad7879 - Convert SPI to dev_pm_ops

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ad7979 SPI driver.

---
 drivers/input/touchscreen/ad7879-spi.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
drivers/input/touchscreen/ad7879-spi.c +9 -8
index 59c6e68..ddf732f 100644
@@ -7,6 +7,7 @@
  */
 
 #include <linux/input.h>	/* BUS_SPI */
+#include <linux/pm.h>
 #include <linux/spi/spi.h>
 
 #include "ad7879.h"
@@ -20,9 +21,10 @@
 #define AD7879_WRITECMD(reg) (AD7879_CMD(reg))
 #define AD7879_READCMD(reg)  (AD7879_CMD(reg) | AD7879_CMD_READ)
 
-#ifdef CONFIG_PM
-static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message)
+#ifdef CONFIG_PM_SLEEP
+static int ad7879_spi_suspend(struct device *dev)
 {
+	struct spi_device *spi = to_spi_device(dev);
 	struct ad7879 *ts = spi_get_drvdata(spi);
 
 	ad7879_suspend(ts);
@@ -30,19 +32,19 @@ static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message)
 	return 0;
 }
 
-static int ad7879_spi_resume(struct spi_device *spi)
+static int ad7879_spi_resume(struct device *dev)
 {
+	struct spi_device *spi = to_spi_device(dev);
 	struct ad7879 *ts = spi_get_drvdata(spi);
 
 	ad7879_resume(ts);
 
 	return 0;
 }
-#else
-# define ad7879_spi_suspend NULL
-# define ad7879_spi_resume  NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend, ad7879_spi_resume);
+
 /*
  * ad7879_read/write are only used for initial setup and for sysfs controls.
  * The main traffic is done in ad7879_collect().
@@ -173,11 +175,10 @@ static struct spi_driver ad7879_spi_driver = {
 		.name	= "ad7879",
 		.bus	= &spi_bus_type,
 		.owner	= THIS_MODULE,
+		.pm	= &ad7879_spi_pm,
 	},
 	.probe		= ad7879_spi_probe,
 	.remove		= __devexit_p(ad7879_spi_remove),
-	.suspend	= ad7879_spi_suspend,
-	.resume		= ad7879_spi_resume,
 };
 
 static int __init ad7879_spi_init(void)
Signature · 1 line
1.7.2.3
author
#3 lore raw

PATCH 3/3 Input: ads7846 - Convert to dev_pm_ops

In reply to Mark Brown

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ads7846 driver.

---
 drivers/input/touchscreen/ads7846.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/input/touchscreen/ads7846.c +10 -6
index 14ea54b..b31e90f 100644
@@ -26,6 +26,7 @@
 #include <linux/input.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/pm.h>
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -892,9 +893,10 @@ static irqreturn_t ads7846_irq(int irq, void *handle)
 	return IRQ_HANDLED;
 }
 
-static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
+#ifdef CONFIG_PM_SLEEP
+static int ads7846_suspend(struct device *dev)
 {
-	struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+	struct ads7846 *ts = dev_get_drvdata(dev);
 
 	mutex_lock(&ts->lock);
 
@@ -914,9 +916,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
 	return 0;
 }
 
-static int ads7846_resume(struct spi_device *spi)
+static int ads7846_resume(struct device *dev)
 {
-	struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+	struct ads7846 *ts = dev_get_drvdata(dev);
 
 	mutex_lock(&ts->lock);
 
@@ -935,6 +937,9 @@ static int ads7846_resume(struct spi_device *spi)
 
 	return 0;
 }
+#endif
+
+static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
 
 static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts)
 {
@@ -1402,11 +1407,10 @@ static struct spi_driver ads7846_driver = {
 		.name	= "ads7846",
 		.bus	= &spi_bus_type,
 		.owner	= THIS_MODULE,
+		.pm	= &ads7846_pm,
 	},
 	.probe		= ads7846_probe,
 	.remove		= __devexit_p(ads7846_remove),
-	.suspend	= ads7846_suspend,
-	.resume		= ads7846_resume,
 };
 
 static int __init ads7846_init(void)
Signature · 1 line
1.7.2.3
maintainer Acked-by on v1 1/3
#5 lore raw
In reply to Mark Brown

Mark Brown wrote on 2011-01-20:

Quoted 6 lines

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ad7879 SPI driver.

Quoted 40 lines
---
 drivers/input/touchscreen/ad7877.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

b/drivers/input/touchscreen/ad7877.c index a1952fc..714d4e0 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c @@ -41,6 +41,7 @@
#include <linux/delay.h> #include <linux/input.h> #include <linux/interrupt.h> +#include <linux/pm.h> #include <linux/slab.h> #include <linux/spi/spi.h> #include <linux/spi/ad7877.h>

drivers/input/touchscreen/ad7877.c +0 -1
@@ -826,39 +827,37 @@ static int __devexit ad7877_remove(struct
 spi_device *spi)
      return 0;
 }
-#ifdef CONFIG_PM -static int ad7877_suspend(struct spi_device *spi,

pm_message_t message) +#ifdef CONFIG_PM_SLEEP +static int ad7877_suspend(struct device *dev)
{

drivers/input/touchscreen/ad7877.c +4 -6
-     struct ad7877 *ts = dev_get_drvdata(&spi->dev);
+     struct ad7877 *ts = dev_get_drvdata(dev);
 
      ad7877_disable(ts);
 
      return 0;
 }
-static int ad7877_resume(struct spi_device *spi)
+static int ad7877_resume(struct device *dev)
 {
-     struct ad7877 *ts = dev_get_drvdata(&spi->dev);
+     struct ad7877 *ts = dev_get_drvdata(dev);
 
      ad7877_enable(ts);
 
      return 0;
 }
-#else
-#define ad7877_suspend NULL
-#define ad7877_resume  NULL
 #endif
+static SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume);

drivers/input/touchscreen/ad7877.c static int __devexit ad7877_remove(struct spi_device *spi) · line 863

Quoted 10 lines
drivers/input/touchscreen/ad7877.c +1 -2
+
 static struct spi_driver ad7877_driver = {   .driver = {             .name   =
 "ad7877",            .bus    = &spi_bus_type,                .owner  = THIS_MODULE, +                .pm     =
 &ad7877_pm,  },      .probe          = ad7877_probe,         .remove         =
 __devexit_p(ad7877_remove),
-     .suspend        = ad7877_suspend,
-     .resume         = ad7877_resume,
 };
 
 static int __init ad7877_init(void)

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif

maintainer Acked-by on v1 2/3
#2 lore raw

RE: [PATCH 2/3] Input: ad7879 - Convert SPI to dev_pm_ops

In reply to Mark Brown

Mark Brown wrote on 2011-01-20:

Quoted 6 lines

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ad7979 SPI driver.

Quoted 45 lines
---
 drivers/input/touchscreen/ad7879-spi.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/input/touchscreen/ad7879-spi.c index 59c6e68..ddf732f 100644 --- a/drivers/input/touchscreen/ad7879-spi.c +++ b/drivers/input/touchscreen/ad7879-spi.c @@ -7,6 +7,7 @@
*/
#include <linux/input.h> /* BUS_SPI */ +#include <linux/pm.h> #include
<linux/spi/spi.h>

#include "ad7879.h" @@ -20,9 +21,10 @@ #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) #define
AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ)

-#ifdef CONFIG_PM -static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message) +#ifdef CONFIG_PM_SLEEP +static int ad7879_spi_suspend(struct device *dev)
{ + struct spi_device *spi = to_spi_device(dev); struct ad7879 *ts =
spi_get_drvdata(spi);

      ad7879_suspend(ts);
drivers/input/touchscreen/ad7879-spi.c +3 -4
@@ -30,19 +32,19 @@ static int ad7879_spi_suspend(struct spi_device
 *spi, pm_message_t message)
      return 0;
 }
-static int ad7879_spi_resume(struct spi_device *spi)
+static int ad7879_spi_resume(struct device *dev)
 { +  struct spi_device *spi = to_spi_device(dev);    struct ad7879 *ts =
 spi_get_drvdata(spi);
 
      ad7879_resume(ts);
 
      return 0;
 }
-#else
-# define ad7879_spi_suspend NULL
-# define ad7879_spi_resume  NULL
 #endif
+static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend,
+ad7879_spi_resume); +
 /*
  * ad7879_read/write are only used for initial setup and for sysfs
  controls. * The main traffic is done in ad7879_collect().

drivers/input/touchscreen/ad7879-spi.c static struct spi_driver ad7879_spi_driver = { · line 180

Quoted 8 lines
drivers/input/touchscreen/ad7879-spi.c +0 -2
@@ -173,11 +175,10 @@ static struct spi_driver ad7879_spi_driver = {
              .name   = "ad7879",             .bus    = &spi_bus_type,                .owner  = THIS_MODULE,
 +            .pm     = &ad7879_spi_pm,       },      .probe          = ad7879_spi_probe,     .remove         =
 __devexit_p(ad7879_spi_remove),
-     .suspend        = ad7879_spi_suspend,
-     .resume         = ad7879_spi_resume,
 };
 
 static int __init ad7879_spi_init(void)

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif

maintainer Acked-by on v1 3/3
#4 lore raw

RE: [PATCH 3/3] Input: ads7846 - Convert to dev_pm_ops

In reply to Mark Brown

Mark Brown wrote on 2011-01-20:

Quoted 6 lines

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ads7846 driver.

Looks good to me.

Quoted 46 lines
---
 drivers/input/touchscreen/ads7846.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/input/touchscreen/ads7846.c index 14ea54b..b31e90f 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -26,6 +26,7 @@
#include <linux/input.h> #include <linux/interrupt.h> #include <linux/slab.h> +#include <linux/pm.h> #include <linux/gpio.h> #include <linux/spi/spi.h> #include <linux/spi/ads7846.h>

drivers/input/touchscreen/ads7846.c +0 -1
@@ -892,9 +893,10 @@ static irqreturn_t ads7846_irq(int irq, void
 *handle)
      return IRQ_HANDLED;
 }
-static int ads7846_suspend(struct spi_device *spi, pm_message_t

message) +#ifdef CONFIG_PM_SLEEP +static int ads7846_suspend(struct device *dev)
{

drivers/input/touchscreen/ads7846.c +5 -3
-     struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+     struct ads7846 *ts = dev_get_drvdata(dev);
 
      mutex_lock(&ts->lock);
@@ -914,9 +916,9 @@ static int ads7846_suspend(struct spi_device *spi,
 pm_message_t message)
      return 0;
 }
-static int ads7846_resume(struct spi_device *spi)
+static int ads7846_resume(struct device *dev)
 {
-     struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+     struct ads7846 *ts = dev_get_drvdata(dev);
 
      mutex_lock(&ts->lock);
@@ -935,6 +937,9 @@ static int ads7846_resume(struct spi_device *spi)
 
      return 0;
 }
+#endif + +static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend,
+ads7846_resume);
 
 static int __devinit ads7846_setup_pendown(struct spi_device *spi,

struct ads7846 *ts) { @@ -1402,11 +1407,10 @@ static struct spi_driver ads7846_driver = {

              .name   = "ads7846",            .bus    = &spi_bus_type,                .owner  = THIS_MODULE,
 +            .pm     = &ads7846_pm,  },      .probe          = ads7846_probe,        .remove         =

__devexit_p(ads7846_remove),

drivers/input/touchscreen/ads7846.c static struct spi_driver ads7846_driver = { · line 1416

Quoted 5 lines
drivers/input/touchscreen/ads7846.c +0 -2
-     .suspend        = ads7846_suspend,
-     .resume         = ads7846_resume,
 };
 
 static int __init ads7846_init(void)

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif

maintainer Applied
#6 lore raw
In reply to Mark Brown
Quoted 6 lines · Mark Brown

There is a move to deprecate bus-specific PM operations and move to using dev_pm_ops instead in order to reduce the amount of boilerplate code in buses and facilitiate updates to the PM core. Do this move for the ad7879 SPI driver.

Applied all 3 to next, thanks Mark.

Signature · 1 line
Dmitry