gpio-charger: Add gpio_charger_resume
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
@@ -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
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.
Signed-off-by Benson Leung <[email protected]>--
Version history :
v2 : Changed to usedev_pm_ops
v1 : Initial
---
drivers/power/gpio-charger.c | 20 ++++++++++++++++++++1 files changed, 20 insertions(+), 0 deletions(-)drivers/power/gpio-charger.c +20
-1@@ -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]
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.
Signed-off-by Benson Leung <[email protected]>--
Version history :
v2 : Changed to usedev_pm_ops
v1 : Initial--- drivers/power/gpio-charger.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)drivers/power/gpio-charger.c +0
-0@@ -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
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,
BensonHi
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.
Signed-off-by Benson Leung <[email protected]>--
Version history :
v2 : Changed to usedev_pm_ops
v1 : Initial
---
drivers/power/gpio-charger.c | 20 ++++++++++++++++++++1 files changed, 20 insertions(+), 0 deletions(-)drivers/power/gpio-charger.c +0
-0@@ -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_SLEEPQuoted 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.
AndSIMPLE_DEV_PM_OPSwill also ignore the callbacks ifCONFIG_PM_SLEEPis not set, so it can go outside of the #ifdefCONFIG_PM_SLEEPand 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]
PATCH v3 1/1 gpio-charger: Add gpio_charger_resume
In reply to Benson LeungGpio 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
@@ -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
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.
Signed-off-by Benson Leung <[email protected]>
Quoted 42 lines
--
Version history :
v3 : UseSIMPLE_DEV_PM_OPS
v2 : Changed to usedev_ms_ops
v1 : Initial--- drivers/power/gpio-charger.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)drivers/power/gpio-charger.c +15
-0@@ -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, }, };
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.
Signed-off-by Benson Leung <[email protected]>Quoted 42 lines
--
Version history :
v3 : UseSIMPLE_DEV_PM_OPS
v2 : Changed to usedev_ms_ops
v1 : Initial
---
drivers/power/gpio-charger.c | 15 +++++++++++++++1 files changed, 15 insertions(+), 0 deletions(-)drivers/power/gpio-charger.c +15
-0@@ -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, }, };
Anton Vorontsov
AppliedQuoted 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.
Signed-off-by Benson Leung <[email protected]>
Signature · 2 lines
Anton Vorontsov Email: [email protected]