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.
Signed-off-by: Benson Leung <[email protected]>
---
drivers/power/gpio-charger.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 25b88ac..e83c892 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -161,9 +161,26 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
return 0;
}
+#if defined CONFIG_PM
+static int gpio_charger_resume(struct platform_device *pdev)
+{
+ struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
+
+ power_supply_changed(&gpio_charger->charger);
+
+ return 0;
+}
+#else
+#define gpio_charger_resume NULL
+#endif
+#define gpio_charger_suspend NULL
+
+
static struct platform_driver gpio_charger_driver = {
.probe = gpio_charger_probe,
.remove = __devexit_p(gpio_charger_remove),
+ .suspend = gpio_charger_suspend,
+ .resume = gpio_charger_resume,
.driver = {
.name = "gpio-charger",
.owner = THIS_MODULE,
--
1.7.1
On 04/03/2011 01:16 AM, Benson Leung wrote:
> 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.
>
> Signed-off-by: Benson Leung <[email protected]>
Seems reasonable, but please use dev_pm_ops.
- Lars
> ---
> drivers/power/gpio-charger.c | 17 +++++++++++++++++
> 1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index 25b88ac..e83c892 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -161,9 +161,26 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#if defined CONFIG_PM
> +static int gpio_charger_resume(struct platform_device *pdev)
> +{
> + struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
> +
> + power_supply_changed(&gpio_charger->charger);
> +
> + return 0;
> +}
> +#else
> +#define gpio_charger_resume NULL
> +#endif
> +#define gpio_charger_suspend NULL
> +
> +
> static struct platform_driver gpio_charger_driver = {
> .probe = gpio_charger_probe,
> .remove = __devexit_p(gpio_charger_remove),
> + .suspend = gpio_charger_suspend,
> + .resume = gpio_charger_resume,
> .driver = {
> .name = "gpio-charger",
> .owner = THIS_MODULE,