diff options
Diffstat (limited to 'drivers/power/collie_battery.c')
-rw-r--r-- | drivers/power/collie_battery.c | 55 |
1 files changed, 14 insertions, 41 deletions
diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c index 548d263b1ad..74c6b23aeab 100644 --- a/drivers/power/collie_battery.c +++ b/drivers/power/collie_battery.c | |||
@@ -146,7 +146,7 @@ static void collie_bat_external_power_changed(struct power_supply *psy) | |||
146 | 146 | ||
147 | static irqreturn_t collie_bat_gpio_isr(int irq, void *data) | 147 | static irqreturn_t collie_bat_gpio_isr(int irq, void *data) |
148 | { | 148 | { |
149 | pr_info("collie_bat_gpio irq: %d\n", gpio_get_value(irq_to_gpio(irq))); | 149 | pr_info("collie_bat_gpio irq\n"); |
150 | schedule_work(&bat_work); | 150 | schedule_work(&bat_work); |
151 | return IRQ_HANDLED; | 151 | return IRQ_HANDLED; |
152 | } | 152 | } |
@@ -277,18 +277,13 @@ static struct collie_bat collie_bat_bu = { | |||
277 | .adc_temp_divider = -1, | 277 | .adc_temp_divider = -1, |
278 | }; | 278 | }; |
279 | 279 | ||
280 | static struct { | 280 | static struct gpio collie_batt_gpios[] = { |
281 | int gpio; | 281 | { COLLIE_GPIO_CO, GPIOF_IN, "main battery full" }, |
282 | char *name; | 282 | { COLLIE_GPIO_MAIN_BAT_LOW, GPIOF_IN, "main battery low" }, |
283 | bool output; | 283 | { COLLIE_GPIO_CHARGE_ON, GPIOF_OUT_INIT_LOW, "main charge on" }, |
284 | int value; | 284 | { COLLIE_GPIO_MBAT_ON, GPIOF_OUT_INIT_LOW, "main battery" }, |
285 | } gpios[] = { | 285 | { COLLIE_GPIO_TMP_ON, GPIOF_OUT_INIT_LOW, "main battery temp" }, |
286 | { COLLIE_GPIO_CO, "main battery full", 0, 0 }, | 286 | { COLLIE_GPIO_BBAT_ON, GPIOF_OUT_INIT_LOW, "backup battery" }, |
287 | { COLLIE_GPIO_MAIN_BAT_LOW, "main battery low", 0, 0 }, | ||
288 | { COLLIE_GPIO_CHARGE_ON, "main charge on", 1, 0 }, | ||
289 | { COLLIE_GPIO_MBAT_ON, "main battery", 1, 0 }, | ||
290 | { COLLIE_GPIO_TMP_ON, "main battery temp", 1, 0 }, | ||
291 | { COLLIE_GPIO_BBAT_ON, "backup battery", 1, 0 }, | ||
292 | }; | 287 | }; |
293 | 288 | ||
294 | #ifdef CONFIG_PM | 289 | #ifdef CONFIG_PM |
@@ -313,29 +308,16 @@ static int collie_bat_resume(struct ucb1x00_dev *dev) | |||
313 | static int __devinit collie_bat_probe(struct ucb1x00_dev *dev) | 308 | static int __devinit collie_bat_probe(struct ucb1x00_dev *dev) |
314 | { | 309 | { |
315 | int ret; | 310 | int ret; |
316 | int i; | ||
317 | 311 | ||
318 | if (!machine_is_collie()) | 312 | if (!machine_is_collie()) |
319 | return -ENODEV; | 313 | return -ENODEV; |
320 | 314 | ||
321 | ucb = dev->ucb; | 315 | ucb = dev->ucb; |
322 | 316 | ||
323 | for (i = 0; i < ARRAY_SIZE(gpios); i++) { | 317 | ret = gpio_request_array(collie_batt_gpios, |
324 | ret = gpio_request(gpios[i].gpio, gpios[i].name); | 318 | ARRAY_SIZE(collie_batt_gpios)); |
325 | if (ret) { | 319 | if (ret) |
326 | i--; | 320 | return ret; |
327 | goto err_gpio; | ||
328 | } | ||
329 | |||
330 | if (gpios[i].output) | ||
331 | ret = gpio_direction_output(gpios[i].gpio, | ||
332 | gpios[i].value); | ||
333 | else | ||
334 | ret = gpio_direction_input(gpios[i].gpio); | ||
335 | |||
336 | if (ret) | ||
337 | goto err_gpio; | ||
338 | } | ||
339 | 321 | ||
340 | mutex_init(&collie_bat_main.work_lock); | 322 | mutex_init(&collie_bat_main.work_lock); |
341 | 323 | ||
@@ -363,19 +345,12 @@ err_psy_reg_main: | |||
363 | 345 | ||
364 | /* see comment in collie_bat_remove */ | 346 | /* see comment in collie_bat_remove */ |
365 | cancel_work_sync(&bat_work); | 347 | cancel_work_sync(&bat_work); |
366 | 348 | gpio_free_array(collie_batt_gpios, ARRAY_SIZE(collie_batt_gpios)); | |
367 | i--; | ||
368 | err_gpio: | ||
369 | for (; i >= 0; i--) | ||
370 | gpio_free(gpios[i].gpio); | ||
371 | |||
372 | return ret; | 349 | return ret; |
373 | } | 350 | } |
374 | 351 | ||
375 | static void __devexit collie_bat_remove(struct ucb1x00_dev *dev) | 352 | static void __devexit collie_bat_remove(struct ucb1x00_dev *dev) |
376 | { | 353 | { |
377 | int i; | ||
378 | |||
379 | free_irq(gpio_to_irq(COLLIE_GPIO_CO), &collie_bat_main); | 354 | free_irq(gpio_to_irq(COLLIE_GPIO_CO), &collie_bat_main); |
380 | 355 | ||
381 | power_supply_unregister(&collie_bat_bu.psy); | 356 | power_supply_unregister(&collie_bat_bu.psy); |
@@ -387,9 +362,7 @@ static void __devexit collie_bat_remove(struct ucb1x00_dev *dev) | |||
387 | * unregistered now. | 362 | * unregistered now. |
388 | */ | 363 | */ |
389 | cancel_work_sync(&bat_work); | 364 | cancel_work_sync(&bat_work); |
390 | 365 | gpio_free_array(collie_batt_gpios, ARRAY_SIZE(collie_batt_gpios)); | |
391 | for (i = ARRAY_SIZE(gpios) - 1; i >= 0; i--) | ||
392 | gpio_free(gpios[i].gpio); | ||
393 | } | 366 | } |
394 | 367 | ||
395 | static struct ucb1x00_driver collie_bat_driver = { | 368 | static struct ucb1x00_driver collie_bat_driver = { |