power: gpio-charger: balance enable/disable_irq_wake calls
PATCH RESEND v2 1/2 power: gpio-charger: balance enable/disable_irq_wake calls
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.
--- drivers/power/gpio-charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/gpio-charger.c +2 -2
@@ -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);
Signature · 1 line
2.1.4
PATCH RESEND v2 2/2 power: collie_battery: support generating wakeup event
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.
--- drivers/power/collie_battery.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/power/collie_battery.c +20 -4
@@ -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);
Signature · 1 line
2.1.4
Sebastian Reichel
AppliedHi,
Quoted 4 lines · Dmitry Eremin-Solenikov
enable_irq_wakeupreturns 0 in case it correctly enabled the IRQ to generate the wakeup event (and thus resume should calldisable_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>
Sebastian Reichel
AppliedRe: [PATCH RESEND V2 2/2] power: collie_battery: support generating wakeup event
In reply to Dmitry Eremin-SolenikovHi,
Quoted 3 lines · Dmitry Eremin-Solenikov
Teach
collie_batterydriver 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>