aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/pda_power.c
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2008-01-06 20:12:39 -0500
committerAnton Vorontsov <cbouatmailru@gmail.com>2008-02-01 18:42:59 -0500
commit9ef45106261e802f9d80bf0bc652124b42b1f344 (patch)
tree6cdf673b05a9c43ab73a0fac462ce8e2d8272346 /drivers/power/pda_power.c
parent839dc9f105c0d856f9a0be48fb3bd0982ff5df5b (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/pda_power.c')
-rw-r--r--drivers/power/pda_power.c80
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)
168 pda_power_supplies[1].num_supplicants = pdata->num_supplicants; 168 pda_power_supplies[1].num_supplicants = pdata->num_supplicants;
169 } 169 }
170 170
171 ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]); 171 if (pdata->is_ac_online) {
172 if (ret) { 172 ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
173 dev_err(dev, "failed to register %s power supply\n", 173 if (ret) {
174 pda_power_supplies[0].name); 174 dev_err(dev, "failed to register %s power supply\n",
175 goto supply0_failed; 175 pda_power_supplies[0].name);
176 } 176 goto ac_supply_failed;
177 }
177 178
178 ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]); 179 if (ac_irq) {
179 if (ret) { 180 ret = request_irq(ac_irq->start, power_changed_isr,
180 dev_err(dev, "failed to register %s power supply\n", 181 get_irq_flags(ac_irq), ac_irq->name,
181 pda_power_supplies[1].name); 182 &pda_power_supplies[0]);
182 goto supply1_failed; 183 if (ret) {
184 dev_err(dev, "request ac irq failed\n");
185 goto ac_irq_failed;
186 }
187 }
183 } 188 }
184 189
185 if (ac_irq) { 190 if (pdata->is_usb_online) {
186 ret = request_irq(ac_irq->start, power_changed_isr, 191 ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
187 get_irq_flags(ac_irq), ac_irq->name,
188 &pda_power_supplies[0]);
189 if (ret) { 192 if (ret) {
190 dev_err(dev, "request ac irq failed\n"); 193 dev_err(dev, "failed to register %s power supply\n",
191 goto ac_irq_failed; 194 pda_power_supplies[1].name);
195 goto usb_supply_failed;
192 } 196 }
193 }
194 197
195 if (usb_irq) { 198 if (usb_irq) {
196 ret = request_irq(usb_irq->start, power_changed_isr, 199 ret = request_irq(usb_irq->start, power_changed_isr,
197 get_irq_flags(usb_irq), usb_irq->name, 200 get_irq_flags(usb_irq),
198 &pda_power_supplies[1]); 201 usb_irq->name,
199 if (ret) { 202 &pda_power_supplies[1]);
200 dev_err(dev, "request usb irq failed\n"); 203 if (ret) {
201 goto usb_irq_failed; 204 dev_err(dev, "request usb irq failed\n");
205 goto usb_irq_failed;
206 }
202 } 207 }
203 } 208 }
204 209
205 goto success; 210 return 0;
206 211
207usb_irq_failed: 212usb_irq_failed:
208 if (ac_irq) 213 if (pdata->is_usb_online)
214 power_supply_unregister(&pda_power_supplies[1]);
215usb_supply_failed:
216 if (pdata->is_ac_online && ac_irq)
209 free_irq(ac_irq->start, &pda_power_supplies[0]); 217 free_irq(ac_irq->start, &pda_power_supplies[0]);
210ac_irq_failed: 218ac_irq_failed:
211 power_supply_unregister(&pda_power_supplies[1]); 219 if (pdata->is_ac_online)
212supply1_failed: 220 power_supply_unregister(&pda_power_supplies[0]);
213 power_supply_unregister(&pda_power_supplies[0]); 221ac_supply_failed:
214supply0_failed:
215noirqs: 222noirqs:
216wrongid: 223wrongid:
217success:
218 return ret; 224 return ret;
219} 225}
220 226
221static int pda_power_remove(struct platform_device *pdev) 227static int pda_power_remove(struct platform_device *pdev)
222{ 228{
223 if (usb_irq) 229 if (pdata->is_usb_online && usb_irq)
224 free_irq(usb_irq->start, &pda_power_supplies[1]); 230 free_irq(usb_irq->start, &pda_power_supplies[1]);
225 if (ac_irq) 231 if (pdata->is_ac_online && ac_irq)
226 free_irq(ac_irq->start, &pda_power_supplies[0]); 232 free_irq(ac_irq->start, &pda_power_supplies[0]);
227 del_timer_sync(&charger_timer); 233 del_timer_sync(&charger_timer);
228 del_timer_sync(&supply_timer); 234 del_timer_sync(&supply_timer);
229 power_supply_unregister(&pda_power_supplies[1]); 235 if (pdata->is_usb_online)
230 power_supply_unregister(&pda_power_supplies[0]); 236 power_supply_unregister(&pda_power_supplies[1]);
237 if (pdata->is_ac_online)
238 power_supply_unregister(&pda_power_supplies[0]);
231 return 0; 239 return 0;
232} 240}
233 241