Skip to contentSkip to conversation

gpio-charger: Add gpio_charger_resume

PATCH Superseded Benson Leung 3 participants 8 messages Apr 3, 2011 – Apr 20, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio-charger: Add gpio_charger_resume

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

--
Version history :
v2 : Changed to use dev_pm_ops
v1 : Initial

---
 drivers/power/gpio-charger.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +20 -0
index 25b88ac..df29059 100644
@@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#if defined(CONFIG_PM)
+static int gpio_charger_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+	power_supply_changed(&gpio_charger->charger);
+
+	return 0;
+}
+
+static const struct dev_pm_ops gpio_charger_pm_ops = {
+	.resume		= gpio_charger_resume,
+};
+#endif
+
+
 static struct platform_driver gpio_charger_driver = {
 	.probe = gpio_charger_probe,
 	.remove = __devexit_p(gpio_charger_remove),
 	.driver = {
 		.name = "gpio-charger",
 		.owner = THIS_MODULE,
+#if defined(CONFIG_PM)
+		.pm = &gpio_charger_pm_ops,
+#endif
 	},
 };
 
Signature · 1 line
1.7.1
#1 lore raw

Hi Lars,

Please take another look.

Thanks,
Benson

Quoted 56 lines · Benson Leung

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

--
Version history :
v2 : Changed to use dev_pm_ops
v1 : Initial
---
 drivers/power/gpio-charger.c |   20 ++++++++++++++++++++

 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +20 -1
index 25b88ac..df29059 100644
@@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
        return 0;
  }
 
+#if defined(CONFIG_PM)
+static int gpio_charger_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+       power_supply_changed(&gpio_charger->charger);
+
+       return 0;
+}
+
+static const struct dev_pm_ops gpio_charger_pm_ops = {
+       .resume         = gpio_charger_resume,
+};
+#endif
+
+
  static struct platform_driver gpio_charger_driver = {
        .probe = gpio_charger_probe,
        .remove = __devexit_p(gpio_charger_remove),
        .driver = {
                .name = "gpio-charger",
                .owner = THIS_MODULE,
+#if defined(CONFIG_PM)
+               .pm = &gpio_charger_pm_ops,
+#endif
        },
  };
 
--

1.7.1

Signature · 3 lines
Benson Leung
Software Engineer, Chrom* OS
[email protected]
#2 lore raw
Quoted 7 lines · Benson Leung

Hi Lars,

Please take another look.

Thanks,
Benson

Hi

Some minor issues:

Quoted 24 lines · Benson Leung
Quoted 23 lines

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

--
Version history :
v2 : Changed to use dev_pm_ops
v1 : Initial

---
 drivers/power/gpio-charger.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +0 -0
index 25b88ac..df29059 100644
@@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
       return 0;
 }
 
Quoted 1 line

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 164

Quoted 1 line
drivers/power/gpio-charger.c +1 -0
+#if defined(CONFIG_PM)

#ifdef CONFIG_PM_SLEEP

Quoted 6 lines
Quoted 6 lines
drivers/power/gpio-charger.c +6 -0
+static int gpio_charger_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+       power_supply_changed(&gpio_charger->charger);
Quoted 8 lines

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 178

Quoted 8 lines
drivers/power/gpio-charger.c +8 -0
+
+       return 0;
+}
+
+static const struct dev_pm_ops gpio_charger_pm_ops = {
+       .resume         = gpio_charger_resume,
+};
+#endif

static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, gpio_charger_resume, NULL);

This will also setup the pm hooks for suspend to disk.
And SIMPLE_DEV_PM_OPS will also ignore the callbacks if CONFIG_PM_SLEEP is not set, so it can go outside of the #ifdef CONFIG_PM_SLEEP and you can also get rid of the #ifdef ...

Quoted 11 lines

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 189

Quoted 11 lines
drivers/power/gpio-charger.c +5 -0
+
+
 static struct platform_driver gpio_charger_driver = {
       .probe = gpio_charger_probe,
       .remove = __devexit_p(gpio_charger_remove),
       .driver = {
               .name = "gpio-charger",
               .owner = THIS_MODULE,
+#if defined(CONFIG_PM)
+               .pm = &gpio_charger_pm_ops,
+#endif

... here.

Quoted 10 lines
Quoted 7 lines
drivers/power/gpio-charger.c +0 -1
       },
 };
 
--

1.7.1

#3 lore raw

Thanks Lars,

v3 coming right up.

Benson

Quoted 89 lines · Lars-Peter Clausen
Quoted 7 lines · Benson Leung

Hi Lars,

Please take another look.

Thanks,
Benson

Hi

Some minor issues:

Quoted 24 lines · Benson Leung
Quoted 23 lines

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

--
Version history :
v2 : Changed to use dev_pm_ops
v1 : Initial
---
 drivers/power/gpio-charger.c |   20 ++++++++++++++++++++

 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +0 -0
index 25b88ac..df29059 100644
@@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
        return 0;
  }
 
Quoted 1 line

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 164

Quoted 1 line
drivers/power/gpio-charger.c +1 -0
+#if defined(CONFIG_PM)

#ifdef CONFIG_PM_SLEEP

Quoted 6 lines
Quoted 6 lines
drivers/power/gpio-charger.c +6 -0
+static int gpio_charger_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+       power_supply_changed(&gpio_charger->charger);
Quoted 8 lines

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 178

Quoted 8 lines
drivers/power/gpio-charger.c +8 -0
+
+       return 0;
+}
+
+static const struct dev_pm_ops gpio_charger_pm_ops = {
+       .resume         = gpio_charger_resume,
+};
+#endif

static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, gpio_charger_resume, NULL);

This will also setup the pm hooks for suspend to disk.
And SIMPLE_DEV_PM_OPS will also ignore the callbacks if CONFIG_PM_SLEEP is not set, so it can go outside of the #ifdef CONFIG_PM_SLEEP and you can also get rid of the #ifdef ...

Quoted 11 lines

drivers/power/gpio-charger.c static int __devexit gpio_charger_remove(struct platform_device *pdev) · line 189

Quoted 11 lines
drivers/power/gpio-charger.c +5 -0
+
+
  static struct platform_driver gpio_charger_driver = {
        .probe = gpio_charger_probe,
        .remove = __devexit_p(gpio_charger_remove),
        .driver = {
                .name = "gpio-charger",
                .owner = THIS_MODULE,
+#if defined(CONFIG_PM)
+               .pm = &gpio_charger_pm_ops,
+#endif

... here.

Quoted 10 lines
Quoted 7 lines
drivers/power/gpio-charger.c +0 -1
        },
  };
 
--

1.7.1

Signature · 3 lines
Benson Leung
Software Engineer, Chrom* OS
[email protected]
#4 lore raw

PATCH v3 1/1 gpio-charger: Add gpio_charger_resume

In reply to Benson Leung

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

--
Version history :
v3 : Use SIMPLE_DEV_PM_OPS
v2 : Changed to use dev_ms_ops
v1 : Initial

---
 drivers/power/gpio-charger.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +15 -0
index 25b88ac..718f2c5 100644
@@ -161,12 +161,27 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int gpio_charger_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+	power_supply_changed(&gpio_charger->charger);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume);
+
 static struct platform_driver gpio_charger_driver = {
 	.probe = gpio_charger_probe,
 	.remove = __devexit_p(gpio_charger_remove),
 	.driver = {
 		.name = "gpio-charger",
 		.owner = THIS_MODULE,
+		.pm = &gpio_charger_pm_ops,
 	},
 };
 
Signature · 1 line
1.7.1
Acked-by on v3 1/1
#5 lore raw
Quoted 6 lines · Benson Leung

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

Quoted 42 lines

--
Version history :
v3 : Use SIMPLE_DEV_PM_OPS
v2 : Changed to use dev_ms_ops
v1 : Initial

---
 drivers/power/gpio-charger.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +15 -0
index 25b88ac..718f2c5 100644
@@ -161,12 +161,27 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int gpio_charger_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+	power_supply_changed(&gpio_charger->charger);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume);
+
 static struct platform_driver gpio_charger_driver = {
 	.probe = gpio_charger_probe,
 	.remove = __devexit_p(gpio_charger_remove),
 	.driver = {
 		.name = "gpio-charger",
 		.owner = THIS_MODULE,
+		.pm = &gpio_charger_pm_ops,
 	},
 };
 
#6 lore raw

Thanks Lars.

Hi Anton,

Can this patch be applied?

Thanks,
Benson

Quoted 53 lines · Lars-Peter Clausen
Quoted 6 lines · Benson Leung

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

Quoted 42 lines

--
Version history :
v3 : Use SIMPLE_DEV_PM_OPS
v2 : Changed to use dev_ms_ops
v1 : Initial
---
 drivers/power/gpio-charger.c |   15 +++++++++++++++

 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/power/gpio-charger.c +15 -0
index 25b88ac..718f2c5 100644
@@ -161,12 +161,27 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
       return 0;
  }
 
+#ifdef CONFIG_PM_SLEEP
+static int gpio_charger_resume(struct device *dev)
+{
+     struct platform_device *pdev = to_platform_device(dev);
+     struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+     power_supply_changed(&gpio_charger->charger);
+
+     return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume);
+
  static struct platform_driver gpio_charger_driver = {
       .probe = gpio_charger_probe,
       .remove = __devexit_p(gpio_charger_remove),
       .driver = {
               .name = "gpio-charger",
               .owner = THIS_MODULE,
+             .pm = &gpio_charger_pm_ops,
       },
  };
 
#7 lore raw
Quoted 5 lines · Benson Leung

Thanks Lars.

Hi Anton,

Can this patch be applied?

Applied, thanks!

Quoted 9 lines · Lars-Peter Clausen
Quoted 8 lines · Benson Leung
Quoted 6 lines

Gpio charger should notify if the gpio state had changed during suspend. This will send a CHANGED event each time the system resumes, ensuring a plug/unplug of the charger is not missed.

Signature · 2 lines
Anton Vorontsov
Email: [email protected]