diff options
-rw-r--r-- | drivers/acpi/battery.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 0b2707ee094b..95649d373071 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -181,6 +181,7 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
181 | enum power_supply_property psp, | 181 | enum power_supply_property psp, |
182 | union power_supply_propval *val) | 182 | union power_supply_propval *val) |
183 | { | 183 | { |
184 | int ret = 0; | ||
184 | struct acpi_battery *battery = to_acpi_battery(psy); | 185 | struct acpi_battery *battery = to_acpi_battery(psy); |
185 | 186 | ||
186 | if (acpi_battery_present(battery)) { | 187 | if (acpi_battery_present(battery)) { |
@@ -209,26 +210,44 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
209 | val->intval = battery->cycle_count; | 210 | val->intval = battery->cycle_count; |
210 | break; | 211 | break; |
211 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | 212 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
212 | val->intval = battery->design_voltage * 1000; | 213 | if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) |
214 | ret = -ENODEV; | ||
215 | else | ||
216 | val->intval = battery->design_voltage * 1000; | ||
213 | break; | 217 | break; |
214 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | 218 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
215 | val->intval = battery->voltage_now * 1000; | 219 | if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN) |
220 | ret = -ENODEV; | ||
221 | else | ||
222 | val->intval = battery->voltage_now * 1000; | ||
216 | break; | 223 | break; |
217 | case POWER_SUPPLY_PROP_CURRENT_NOW: | 224 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
218 | case POWER_SUPPLY_PROP_POWER_NOW: | 225 | case POWER_SUPPLY_PROP_POWER_NOW: |
219 | val->intval = battery->rate_now * 1000; | 226 | if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) |
227 | ret = -ENODEV; | ||
228 | else | ||
229 | val->intval = battery->rate_now * 1000; | ||
220 | break; | 230 | break; |
221 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | 231 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: |
222 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | 232 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: |
223 | val->intval = battery->design_capacity * 1000; | 233 | if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
234 | ret = -ENODEV; | ||
235 | else | ||
236 | val->intval = battery->design_capacity * 1000; | ||
224 | break; | 237 | break; |
225 | case POWER_SUPPLY_PROP_CHARGE_FULL: | 238 | case POWER_SUPPLY_PROP_CHARGE_FULL: |
226 | case POWER_SUPPLY_PROP_ENERGY_FULL: | 239 | case POWER_SUPPLY_PROP_ENERGY_FULL: |
227 | val->intval = battery->full_charge_capacity * 1000; | 240 | if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
241 | ret = -ENODEV; | ||
242 | else | ||
243 | val->intval = battery->full_charge_capacity * 1000; | ||
228 | break; | 244 | break; |
229 | case POWER_SUPPLY_PROP_CHARGE_NOW: | 245 | case POWER_SUPPLY_PROP_CHARGE_NOW: |
230 | case POWER_SUPPLY_PROP_ENERGY_NOW: | 246 | case POWER_SUPPLY_PROP_ENERGY_NOW: |
231 | val->intval = battery->capacity_now * 1000; | 247 | if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) |
248 | ret = -ENODEV; | ||
249 | else | ||
250 | val->intval = battery->capacity_now * 1000; | ||
232 | break; | 251 | break; |
233 | case POWER_SUPPLY_PROP_MODEL_NAME: | 252 | case POWER_SUPPLY_PROP_MODEL_NAME: |
234 | val->strval = battery->model_number; | 253 | val->strval = battery->model_number; |
@@ -240,9 +259,9 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
240 | val->strval = battery->serial_number; | 259 | val->strval = battery->serial_number; |
241 | break; | 260 | break; |
242 | default: | 261 | default: |
243 | return -EINVAL; | 262 | ret = -EINVAL; |
244 | } | 263 | } |
245 | return 0; | 264 | return ret; |
246 | } | 265 | } |
247 | 266 | ||
248 | static enum power_supply_property charge_battery_props[] = { | 267 | static enum power_supply_property charge_battery_props[] = { |