All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls
@ 2015-01-15  2:00 ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-15  2:00 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, linux-arm-kernel, stable

enable_irq_wakeup returns 0 in case it correctly enabled the IRQ to
generate the wakeup event (and thus resume should call disable_irq_wake).
Currently gpio-charger driver has this logic inverted. Correct that thus
correcting enable/disable_irq_wake() calls balance.

Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/power/gpio-charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 7536933..e5deb11 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -168,7 +168,7 @@ static int gpio_charger_suspend(struct device *dev)
 
 	if (device_may_wakeup(dev))
 		gpio_charger->wakeup_enabled =
-			enable_irq_wake(gpio_charger->irq);
+			!enable_irq_wake(gpio_charger->irq);
 
 	return 0;
 }
@@ -178,7 +178,7 @@ 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);
 
-	if (gpio_charger->wakeup_enabled)
+	if (device_may_wakeup(dev) && gpio_charger->wakeup_enabled)
 		disable_irq_wake(gpio_charger->irq);
 	power_supply_changed(&gpio_charger->charger);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls
@ 2015-01-15  2:00 ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-15  2:00 UTC (permalink / raw)
  To: linux-arm-kernel

enable_irq_wakeup returns 0 in case it correctly enabled the IRQ to
generate the wakeup event (and thus resume should call disable_irq_wake).
Currently gpio-charger driver has this logic inverted. Correct that thus
correcting enable/disable_irq_wake() calls balance.

Cc: stable at vger.kernel.org
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/power/gpio-charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 7536933..e5deb11 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -168,7 +168,7 @@ static int gpio_charger_suspend(struct device *dev)
 
 	if (device_may_wakeup(dev))
 		gpio_charger->wakeup_enabled =
-			enable_irq_wake(gpio_charger->irq);
+			!enable_irq_wake(gpio_charger->irq);
 
 	return 0;
 }
@@ -178,7 +178,7 @@ 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);
 
-	if (gpio_charger->wakeup_enabled)
+	if (device_may_wakeup(dev) && gpio_charger->wakeup_enabled)
 		disable_irq_wake(gpio_charger->irq);
 	power_supply_changed(&gpio_charger->charger);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event
  2015-01-15  2:00 ` Dmitry Eremin-Solenikov
@ 2015-01-15  2:00   ` Dmitry Eremin-Solenikov
  -1 siblings, 0 replies; 8+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-15  2:00 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, linux-arm-kernel

Teach collie_battery driver to communicate to the kernel that it can
generate wakeup events. Handle enabling/disabling wakeup on battery full
event in suspend/resume callbacks.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/power/collie_battery.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c
index d02ae02..594e4db 100644
--- a/drivers/power/collie_battery.c
+++ b/drivers/power/collie_battery.c
@@ -26,6 +26,7 @@
 static DEFINE_MUTEX(bat_lock); /* protects gpio pins */
 static struct work_struct bat_work;
 static struct ucb1x00 *ucb;
+static int wakeup_enabled;
 
 struct collie_bat {
 	int status;
@@ -291,11 +292,21 @@ static int collie_bat_suspend(struct ucb1x00_dev *dev)
 {
 	/* flush all pending status updates */
 	flush_work(&bat_work);
+
+	if (device_may_wakeup(&dev->ucb->dev) &&
+	    collie_bat_main.status == POWER_SUPPLY_STATUS_CHARGING)
+		wakeup_enabled = !enable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
+	else
+		wakeup_enabled = 0;
+
 	return 0;
 }
 
 static int collie_bat_resume(struct ucb1x00_dev *dev)
 {
+	if (wakeup_enabled)
+		disable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
+
 	/* things may have changed while we were away */
 	schedule_work(&bat_work);
 	return 0;
@@ -334,10 +345,15 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
 				collie_bat_gpio_isr,
 				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 				"main full", &collie_bat_main);
-	if (!ret) {
-		schedule_work(&bat_work);
-		return 0;
-	}
+	if (ret)
+		goto err_irq;
+
+	device_init_wakeup(&ucb->dev, 1);
+	schedule_work(&bat_work);
+
+	return 0;
+
+err_irq:
 	power_supply_unregister(&collie_bat_bu.psy);
 err_psy_reg_bu:
 	power_supply_unregister(&collie_bat_main.psy);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event
@ 2015-01-15  2:00   ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-15  2:00 UTC (permalink / raw)
  To: linux-arm-kernel

Teach collie_battery driver to communicate to the kernel that it can
generate wakeup events. Handle enabling/disabling wakeup on battery full
event in suspend/resume callbacks.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/power/collie_battery.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c
index d02ae02..594e4db 100644
--- a/drivers/power/collie_battery.c
+++ b/drivers/power/collie_battery.c
@@ -26,6 +26,7 @@
 static DEFINE_MUTEX(bat_lock); /* protects gpio pins */
 static struct work_struct bat_work;
 static struct ucb1x00 *ucb;
+static int wakeup_enabled;
 
 struct collie_bat {
 	int status;
@@ -291,11 +292,21 @@ static int collie_bat_suspend(struct ucb1x00_dev *dev)
 {
 	/* flush all pending status updates */
 	flush_work(&bat_work);
+
+	if (device_may_wakeup(&dev->ucb->dev) &&
+	    collie_bat_main.status == POWER_SUPPLY_STATUS_CHARGING)
+		wakeup_enabled = !enable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
+	else
+		wakeup_enabled = 0;
+
 	return 0;
 }
 
 static int collie_bat_resume(struct ucb1x00_dev *dev)
 {
+	if (wakeup_enabled)
+		disable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
+
 	/* things may have changed while we were away */
 	schedule_work(&bat_work);
 	return 0;
@@ -334,10 +345,15 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
 				collie_bat_gpio_isr,
 				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 				"main full", &collie_bat_main);
-	if (!ret) {
-		schedule_work(&bat_work);
-		return 0;
-	}
+	if (ret)
+		goto err_irq;
+
+	device_init_wakeup(&ucb->dev, 1);
+	schedule_work(&bat_work);
+
+	return 0;
+
+err_irq:
 	power_supply_unregister(&collie_bat_bu.psy);
 err_psy_reg_bu:
 	power_supply_unregister(&collie_bat_main.psy);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls
  2015-01-15  2:00 ` Dmitry Eremin-Solenikov
@ 2015-01-15 13:44   ` Sebastian Reichel
  -1 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2015-01-15 13:44 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-pm, linux-kernel, linux-arm-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

Hi,

On Thu, Jan 15, 2015 at 05:00:37AM +0300, Dmitry Eremin-Solenikov wrote:
> enable_irq_wakeup returns 0 in case it correctly enabled the IRQ to
> generate the wakeup event (and thus resume should call disable_irq_wake).
> Currently gpio-charger driver has this logic inverted. Correct that thus
> correcting enable/disable_irq_wake() calls balance.

Thanks, applied:

http://git.infradead.org/battery-2.6.git/commit/9a2fb8ac9677ab9cf17ab336e06b59d93a57f4a4

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls
@ 2015-01-15 13:44   ` Sebastian Reichel
  0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2015-01-15 13:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thu, Jan 15, 2015 at 05:00:37AM +0300, Dmitry Eremin-Solenikov wrote:
> enable_irq_wakeup returns 0 in case it correctly enabled the IRQ to
> generate the wakeup event (and thus resume should call disable_irq_wake).
> Currently gpio-charger driver has this logic inverted. Correct that thus
> correcting enable/disable_irq_wake() calls balance.

Thanks, applied:

http://git.infradead.org/battery-2.6.git/commit/9a2fb8ac9677ab9cf17ab336e06b59d93a57f4a4

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150115/692e0a76/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event
  2015-01-15  2:00   ` Dmitry Eremin-Solenikov
@ 2015-01-15 13:44     ` Sebastian Reichel
  -1 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2015-01-15 13:44 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-pm, linux-kernel, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

Hi,

On Thu, Jan 15, 2015 at 05:00:38AM +0300, Dmitry Eremin-Solenikov wrote:
> Teach collie_battery driver to communicate to the kernel that it can
> generate wakeup events. Handle enabling/disabling wakeup on battery full
> event in suspend/resume callbacks.

Thanks, applied:

http://git.infradead.org/battery-2.6.git/commit/a465005643a4c1e02681b02075082fc6c7fa076a

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event
@ 2015-01-15 13:44     ` Sebastian Reichel
  0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2015-01-15 13:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thu, Jan 15, 2015 at 05:00:38AM +0300, Dmitry Eremin-Solenikov wrote:
> Teach collie_battery driver to communicate to the kernel that it can
> generate wakeup events. Handle enabling/disabling wakeup on battery full
> event in suspend/resume callbacks.

Thanks, applied:

http://git.infradead.org/battery-2.6.git/commit/a465005643a4c1e02681b02075082fc6c7fa076a

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150115/773763bd/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-15 13:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15  2:00 [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls Dmitry Eremin-Solenikov
2015-01-15  2:00 ` Dmitry Eremin-Solenikov
2015-01-15  2:00 ` [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event Dmitry Eremin-Solenikov
2015-01-15  2:00   ` Dmitry Eremin-Solenikov
2015-01-15 13:44   ` Sebastian Reichel
2015-01-15 13:44     ` Sebastian Reichel
2015-01-15 13:44 ` [PATCH RESEND V2 1/2] power: gpio-charger: balance enable/disable_irq_wake calls Sebastian Reichel
2015-01-15 13:44   ` Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.