diff options
author | Jonas Aaberg <jonas.aberg@stericsson.com> | 2013-01-11 08:12:53 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-01-15 20:35:21 -0500 |
commit | a864c5a869dcdb40617fc15166385e0ffa609592 (patch) | |
tree | b0f2871e0d981a70a5517c4104ee3e942ca27735 | |
parent | 9a0bd070fd3582aed024a2f13a30b1de307db1e2 (diff) |
ab8500_charger: Handle gpadc errors
Gracefully handle gpadc conversion errors.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Johan BJORNSTEDT <johan.bjornstedt@stericsson.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
-rw-r--r-- | drivers/power/ab8500_charger.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 24c4ae58dab5..126b325cddc9 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c | |||
@@ -160,6 +160,7 @@ struct ab8500_charger_info { | |||
160 | int charger_voltage; | 160 | int charger_voltage; |
161 | int cv_active; | 161 | int cv_active; |
162 | bool wd_expired; | 162 | bool wd_expired; |
163 | int charger_current; | ||
163 | }; | 164 | }; |
164 | 165 | ||
165 | struct ab8500_charger_event_flags { | 166 | struct ab8500_charger_event_flags { |
@@ -2358,6 +2359,7 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, | |||
2358 | union power_supply_propval *val) | 2359 | union power_supply_propval *val) |
2359 | { | 2360 | { |
2360 | struct ab8500_charger *di; | 2361 | struct ab8500_charger *di; |
2362 | int ret; | ||
2361 | 2363 | ||
2362 | di = to_ab8500_charger_ac_device_info(psy_to_ux500_charger(psy)); | 2364 | di = to_ab8500_charger_ac_device_info(psy_to_ux500_charger(psy)); |
2363 | 2365 | ||
@@ -2379,7 +2381,10 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, | |||
2379 | val->intval = di->ac.charger_connected; | 2381 | val->intval = di->ac.charger_connected; |
2380 | break; | 2382 | break; |
2381 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | 2383 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
2382 | di->ac.charger_voltage = ab8500_charger_get_ac_voltage(di); | 2384 | ret = ab8500_charger_get_ac_voltage(di); |
2385 | if (ret >= 0) | ||
2386 | di->ac.charger_voltage = ret; | ||
2387 | /* On error, use previous value */ | ||
2383 | val->intval = di->ac.charger_voltage * 1000; | 2388 | val->intval = di->ac.charger_voltage * 1000; |
2384 | break; | 2389 | break; |
2385 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: | 2390 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: |
@@ -2391,7 +2396,10 @@ static int ab8500_charger_ac_get_property(struct power_supply *psy, | |||
2391 | val->intval = di->ac.cv_active; | 2396 | val->intval = di->ac.cv_active; |
2392 | break; | 2397 | break; |
2393 | case POWER_SUPPLY_PROP_CURRENT_NOW: | 2398 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
2394 | val->intval = ab8500_charger_get_ac_current(di) * 1000; | 2399 | ret = ab8500_charger_get_ac_current(di); |
2400 | if (ret >= 0) | ||
2401 | di->ac.charger_current = ret; | ||
2402 | val->intval = di->ac.charger_current * 1000; | ||
2395 | break; | 2403 | break; |
2396 | default: | 2404 | default: |
2397 | return -EINVAL; | 2405 | return -EINVAL; |
@@ -2418,6 +2426,7 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, | |||
2418 | union power_supply_propval *val) | 2426 | union power_supply_propval *val) |
2419 | { | 2427 | { |
2420 | struct ab8500_charger *di; | 2428 | struct ab8500_charger *di; |
2429 | int ret; | ||
2421 | 2430 | ||
2422 | di = to_ab8500_charger_usb_device_info(psy_to_ux500_charger(psy)); | 2431 | di = to_ab8500_charger_usb_device_info(psy_to_ux500_charger(psy)); |
2423 | 2432 | ||
@@ -2441,7 +2450,9 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, | |||
2441 | val->intval = di->usb.charger_connected; | 2450 | val->intval = di->usb.charger_connected; |
2442 | break; | 2451 | break; |
2443 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | 2452 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
2444 | di->usb.charger_voltage = ab8500_charger_get_vbus_voltage(di); | 2453 | ret = ab8500_charger_get_vbus_voltage(di); |
2454 | if (ret >= 0) | ||
2455 | di->usb.charger_voltage = ret; | ||
2445 | val->intval = di->usb.charger_voltage * 1000; | 2456 | val->intval = di->usb.charger_voltage * 1000; |
2446 | break; | 2457 | break; |
2447 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: | 2458 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: |
@@ -2453,7 +2464,10 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, | |||
2453 | val->intval = di->usb.cv_active; | 2464 | val->intval = di->usb.cv_active; |
2454 | break; | 2465 | break; |
2455 | case POWER_SUPPLY_PROP_CURRENT_NOW: | 2466 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
2456 | val->intval = ab8500_charger_get_usb_current(di) * 1000; | 2467 | ret = ab8500_charger_get_usb_current(di); |
2468 | if (ret >= 0) | ||
2469 | di->usb.charger_current = ret; | ||
2470 | val->intval = di->usb.charger_current * 1000; | ||
2457 | break; | 2471 | break; |
2458 | case POWER_SUPPLY_PROP_CURRENT_AVG: | 2472 | case POWER_SUPPLY_PROP_CURRENT_AVG: |
2459 | /* | 2473 | /* |