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 use dev_pm_ops
v1 : Initial
---
drivers/power/gpio-charger.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 25b88ac..df29059 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -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
Hi Lars,
Please take another look.
Thanks,
Benson
On Sat, Apr 2, 2011 at 7:13 PM, Benson Leung <[email protected]> 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]>
>
> --
> Version history :
> v2 : Changed to use dev_pm_ops
> v1 : Initial
> ---
> ?drivers/power/gpio-charger.c | ? 20 ++++++++++++++++++++
> ?1 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index 25b88ac..df29059 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -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
>
>
--
Benson Leung
Software Engineer,?Chrom* OS
[email protected]
On 04/06/2011 11:08 AM, Benson Leung wrote:
> Hi Lars,
>
> Please take another look.
>
> Thanks,
> Benson
>
Hi
Some minor issues:
> On Sat, Apr 2, 2011 at 7:13 PM, Benson Leung <[email protected]> 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]>
>>
>> --
>> Version history :
>> v2 : Changed to use dev_pm_ops
>> v1 : Initial
>> ---
>> drivers/power/gpio-charger.c | 20 ++++++++++++++++++++
>> 1 files changed, 20 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
>> index 25b88ac..df29059 100644
>> --- a/drivers/power/gpio-charger.c
>> +++ b/drivers/power/gpio-charger.c
>> @@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
>> return 0;
>> }
>>
>> +#if defined(CONFIG_PM)
#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;
>> +}
>> +
>> +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 ...
>> +
>> +
>> 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.
>> },
>> };
>>
>> --
>> 1.7.1
>>
>>
>
>
>
Thanks Lars,
v3 coming right up.
Benson
On Wed, Apr 6, 2011 at 7:40 AM, Lars-Peter Clausen <[email protected]> wrote:
> On 04/06/2011 11:08 AM, Benson Leung wrote:
>> Hi Lars,
>>
>> Please take another look.
>>
>> Thanks,
>> Benson
>>
>
> Hi
>
> Some minor issues:
>
>> On Sat, Apr 2, 2011 at 7:13 PM, Benson Leung <[email protected]> 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]>
>>>
>>> --
>>> Version history :
>>> v2 : Changed to use dev_pm_ops
>>> v1 : Initial
>>> ---
>>> ?drivers/power/gpio-charger.c | ? 20 ++++++++++++++++++++
>>> ?1 files changed, 20 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
>>> index 25b88ac..df29059 100644
>>> --- a/drivers/power/gpio-charger.c
>>> +++ b/drivers/power/gpio-charger.c
>>> @@ -161,12 +161,32 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
>>> ? ? ? ?return 0;
>>> ?}
>>>
>>> +#if defined(CONFIG_PM)
>
> #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;
>>> +}
>>> +
>>> +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 ...
>
>>> +
>>> +
>>> ?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.
>
>>> ? ? ? ?},
>>> ?};
>>>
>>> --
>>> 1.7.1
>>>
>>>
>>
>>
>>
>
>
--
Benson Leung
Software Engineer,?Chrom* OS
[email protected]
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 :
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(-)
diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 25b88ac..718f2c5 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -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,
},
};
--
1.7.1
On 04/07/2011 01:55 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]>
Acked-By: Lars-Peter Clausen <[email protected]>
>
> --
> 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(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index 25b88ac..718f2c5 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -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
On Wed, Apr 6, 2011 at 5:15 PM, Lars-Peter Clausen <[email protected]> wrote:
> On 04/07/2011 01:55 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]>
> Acked-By: Lars-Peter Clausen <[email protected]>
>
>>
>> --
>> 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(-)
>>
>> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
>> index 25b88ac..718f2c5 100644
>> --- a/drivers/power/gpio-charger.c
>> +++ b/drivers/power/gpio-charger.c
>> @@ -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,
>> ? ? ? },
>> ?};
>>
>
>
On Mon, Apr 11, 2011 at 09:19:42PM -0700, Benson Leung wrote:
> Thanks Lars.
>
> Hi Anton,
>
> Can this patch be applied?
Applied, thanks!
> On Wed, Apr 6, 2011 at 5:15 PM, Lars-Peter Clausen <[email protected]> wrote:
> > On 04/07/2011 01:55 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]>
> > Acked-By: Lars-Peter Clausen <[email protected]>
--
Anton Vorontsov
Email: [email protected]