diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-01-07 04:12:39 +0300 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2008-02-02 02:42:59 +0300 |
commit | 9ef45106261e802f9d80bf0bc652124b42b1f344 (patch) | |
tree | 6cdf673b05a9c43ab73a0fac462ce8e2d8272346 /drivers/power | |
parent | 839dc9f105c0d856f9a0be48fb3bd0982ff5df5b (diff) |
pda_power: only register available psu
Currently pda-power adds both ac and usb power supply units.
This patch fixes it so that psu are added only if they are enabled.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Anton Vorontsov <cbou@mail.ru>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/pda_power.c | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index c058f285be1a..d98622f9f31d 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c @@ -168,66 +168,74 @@ static int pda_power_probe(struct platform_device *pdev) pda_power_supplies[1].num_supplicants = pdata->num_supplicants; } - ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]); - if (ret) { - dev_err(dev, "failed to register %s power supply\n", - pda_power_supplies[0].name); - goto supply0_failed; - } + if (pdata->is_ac_online) { + ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]); + if (ret) { + dev_err(dev, "failed to register %s power supply\n", + pda_power_supplies[0].name); + goto ac_supply_failed; + } - ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]); - if (ret) { - dev_err(dev, "failed to register %s power supply\n", - pda_power_supplies[1].name); - goto supply1_failed; + if (ac_irq) { + ret = request_irq(ac_irq->start, power_changed_isr, + get_irq_flags(ac_irq), ac_irq->name, + &pda_power_supplies[0]); + if (ret) { + dev_err(dev, "request ac irq failed\n"); + goto ac_irq_failed; + } + } } - if (ac_irq) { - ret = request_irq(ac_irq->start, power_changed_isr, - get_irq_flags(ac_irq), ac_irq->name, - &pda_power_supplies[0]); + if (pdata->is_usb_online) { + ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]); if (ret) { - dev_err(dev, "request ac irq failed\n"); - goto ac_irq_failed; + dev_err(dev, "failed to register %s power supply\n", + pda_power_supplies[1].name); + goto usb_supply_failed; } - } - if (usb_irq) { - ret = request_irq(usb_irq->start, power_changed_isr, - get_irq_flags(usb_irq), usb_irq->name, - &pda_power_supplies[1]); - if (ret) { - dev_err(dev, "request usb irq failed\n"); - goto usb_irq_failed; + if (usb_irq) { + ret = request_irq(usb_irq->start, power_changed_isr, + get_irq_flags(usb_irq), + usb_irq->name, + &pda_power_supplies[1]); + if (ret) { + dev_err(dev, "request usb irq failed\n"); + goto usb_irq_failed; + } } } - goto success; + return 0; usb_irq_failed: - if (ac_irq) + if (pdata->is_usb_online) + power_supply_unregister(&pda_power_supplies[1]); +usb_supply_failed: + if (pdata->is_ac_online && ac_irq) free_irq(ac_irq->start, &pda_power_supplies[0]); ac_irq_failed: - power_supply_unregister(&pda_power_supplies[1]); -supply1_failed: - power_supply_unregister(&pda_power_supplies[0]); -supply0_failed: + if (pdata->is_ac_online) + power_supply_unregister(&pda_power_supplies[0]); +ac_supply_failed: noirqs: wrongid: -success: return ret; } static int pda_power_remove(struct platform_device *pdev) { - if (usb_irq) + if (pdata->is_usb_online && usb_irq) free_irq(usb_irq->start, &pda_power_supplies[1]); - if (ac_irq) + if (pdata->is_ac_online && ac_irq) free_irq(ac_irq->start, &pda_power_supplies[0]); del_timer_sync(&charger_timer); del_timer_sync(&supply_timer); - power_supply_unregister(&pda_power_supplies[1]); - power_supply_unregister(&pda_power_supplies[0]); + if (pdata->is_usb_online) + power_supply_unregister(&pda_power_supplies[1]); + if (pdata->is_ac_online) + power_supply_unregister(&pda_power_supplies[0]); return 0; } |