Commit 9ef45106 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Anton Vorontsov

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: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: default avatarAnton Vorontsov <cbou@mail.ru>
parent 839dc9f1
...@@ -168,66 +168,74 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -168,66 +168,74 @@ static int pda_power_probe(struct platform_device *pdev)
pda_power_supplies[1].num_supplicants = pdata->num_supplicants; pda_power_supplies[1].num_supplicants = pdata->num_supplicants;
} }
ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]); if (pdata->is_ac_online) {
if (ret) { ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
dev_err(dev, "failed to register %s power supply\n", if (ret) {
pda_power_supplies[0].name); dev_err(dev, "failed to register %s power supply\n",
goto supply0_failed; pda_power_supplies[0].name);
} goto ac_supply_failed;
}
ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]); if (ac_irq) {
if (ret) { ret = request_irq(ac_irq->start, power_changed_isr,
dev_err(dev, "failed to register %s power supply\n", get_irq_flags(ac_irq), ac_irq->name,
pda_power_supplies[1].name); &pda_power_supplies[0]);
goto supply1_failed; if (ret) {
dev_err(dev, "request ac irq failed\n");
goto ac_irq_failed;
}
}
} }
if (ac_irq) { if (pdata->is_usb_online) {
ret = request_irq(ac_irq->start, power_changed_isr, ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
get_irq_flags(ac_irq), ac_irq->name,
&pda_power_supplies[0]);
if (ret) { if (ret) {
dev_err(dev, "request ac irq failed\n"); dev_err(dev, "failed to register %s power supply\n",
goto ac_irq_failed; pda_power_supplies[1].name);
goto usb_supply_failed;
} }
}
if (usb_irq) { if (usb_irq) {
ret = request_irq(usb_irq->start, power_changed_isr, ret = request_irq(usb_irq->start, power_changed_isr,
get_irq_flags(usb_irq), usb_irq->name, get_irq_flags(usb_irq),
&pda_power_supplies[1]); usb_irq->name,
if (ret) { &pda_power_supplies[1]);
dev_err(dev, "request usb irq failed\n"); if (ret) {
goto usb_irq_failed; dev_err(dev, "request usb irq failed\n");
goto usb_irq_failed;
}
} }
} }
goto success; return 0;
usb_irq_failed: 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]); free_irq(ac_irq->start, &pda_power_supplies[0]);
ac_irq_failed: ac_irq_failed:
power_supply_unregister(&pda_power_supplies[1]); if (pdata->is_ac_online)
supply1_failed: power_supply_unregister(&pda_power_supplies[0]);
power_supply_unregister(&pda_power_supplies[0]); ac_supply_failed:
supply0_failed:
noirqs: noirqs:
wrongid: wrongid:
success:
return ret; return ret;
} }
static int pda_power_remove(struct platform_device *pdev) 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]); 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]); free_irq(ac_irq->start, &pda_power_supplies[0]);
del_timer_sync(&charger_timer); del_timer_sync(&charger_timer);
del_timer_sync(&supply_timer); del_timer_sync(&supply_timer);
power_supply_unregister(&pda_power_supplies[1]); if (pdata->is_usb_online)
power_supply_unregister(&pda_power_supplies[0]); power_supply_unregister(&pda_power_supplies[1]);
if (pdata->is_ac_online)
power_supply_unregister(&pda_power_supplies[0]);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment