power_supply: Add support for WM8350 PMU
[safe/jmp/linux-2.6] / drivers / power / pda_power.c
index c8aa55b..d30bb76 100644 (file)
@@ -209,6 +209,12 @@ static int pda_power_probe(struct platform_device *pdev)
 
        pdata = pdev->dev.platform_data;
 
+       if (pdata->init) {
+               ret = pdata->init(dev);
+               if (ret < 0)
+                       goto init_failed;
+       }
+
        update_status();
        update_charger();
 
@@ -298,6 +304,9 @@ ac_irq_failed:
        if (pdata->is_ac_online)
                power_supply_unregister(&pda_psy_ac);
 ac_supply_failed:
+       if (pdata->exit)
+               pdata->exit(dev);
+init_failed:
 wrongid:
        return ret;
 }
@@ -318,18 +327,23 @@ static int pda_power_remove(struct platform_device *pdev)
                power_supply_unregister(&pda_psy_usb);
        if (pdata->is_ac_online)
                power_supply_unregister(&pda_psy_ac);
+       if (pdata->exit)
+               pdata->exit(dev);
 
        return 0;
 }
 
 #ifdef CONFIG_PM
+static int ac_wakeup_enabled;
+static int usb_wakeup_enabled;
+
 static int pda_power_suspend(struct platform_device *pdev, pm_message_t state)
 {
        if (device_may_wakeup(&pdev->dev)) {
                if (ac_irq)
-                       enable_irq_wake(ac_irq->start);
+                       ac_wakeup_enabled = !enable_irq_wake(ac_irq->start);
                if (usb_irq)
-                       enable_irq_wake(usb_irq->start);
+                       usb_wakeup_enabled = !enable_irq_wake(usb_irq->start);
        }
 
        return 0;
@@ -338,9 +352,9 @@ static int pda_power_suspend(struct platform_device *pdev, pm_message_t state)
 static int pda_power_resume(struct platform_device *pdev)
 {
        if (device_may_wakeup(&pdev->dev)) {
-               if (usb_irq)
+               if (usb_irq && usb_wakeup_enabled)
                        disable_irq_wake(usb_irq->start);
-               if (ac_irq)
+               if (ac_irq && ac_wakeup_enabled)
                        disable_irq_wake(ac_irq->start);
        }
 
@@ -351,6 +365,8 @@ static int pda_power_resume(struct platform_device *pdev)
 #define pda_power_resume NULL
 #endif /* CONFIG_PM */
 
+MODULE_ALIAS("platform:pda-power");
+
 static struct platform_driver pda_power_pdrv = {
        .driver = {
                .name = "pda-power",