diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-05-04 01:31:42 -0400 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2008-05-04 05:12:33 -0400 |
commit | 1ca5b9d2183f11bb8b69e04b19a7faf7f600a840 (patch) | |
tree | b7a48df7fc0b52217cd82b05ff8c21037333d6e7 /drivers | |
parent | afa26be86b65a7183ceac29bdf1f51d6fc6932f0 (diff) |
power_supply: Support serial number in olpc_battery
This adds serial number support to the OLPC battery driver.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/olpc_battery.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index ab1e8289f07f..7524a63a54cb 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -84,6 +84,8 @@ static struct power_supply olpc_ac = { | |||
84 | .get_property = olpc_ac_get_prop, | 84 | .get_property = olpc_ac_get_prop, |
85 | }; | 85 | }; |
86 | 86 | ||
87 | static char bat_serial[17]; /* Ick */ | ||
88 | |||
87 | /********************************************************************* | 89 | /********************************************************************* |
88 | * Battery properties | 90 | * Battery properties |
89 | *********************************************************************/ | 91 | *********************************************************************/ |
@@ -94,6 +96,7 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
94 | int ret = 0; | 96 | int ret = 0; |
95 | int16_t ec_word; | 97 | int16_t ec_word; |
96 | uint8_t ec_byte; | 98 | uint8_t ec_byte; |
99 | uint64_t ser_buf; | ||
97 | 100 | ||
98 | ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); | 101 | ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); |
99 | if (ret) | 102 | if (ret) |
@@ -241,6 +244,14 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
241 | ec_word = be16_to_cpu(ec_word); | 244 | ec_word = be16_to_cpu(ec_word); |
242 | val->intval = ec_word * 100 / 256; | 245 | val->intval = ec_word * 100 / 256; |
243 | break; | 246 | break; |
247 | case POWER_SUPPLY_PROP_SERIAL_NUMBER: | ||
248 | ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); | ||
249 | if (ret) | ||
250 | return ret; | ||
251 | |||
252 | sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); | ||
253 | val->strval = bat_serial; | ||
254 | break; | ||
244 | default: | 255 | default: |
245 | ret = -EINVAL; | 256 | ret = -EINVAL; |
246 | break; | 257 | break; |
@@ -260,6 +271,7 @@ static enum power_supply_property olpc_bat_props[] = { | |||
260 | POWER_SUPPLY_PROP_TEMP, | 271 | POWER_SUPPLY_PROP_TEMP, |
261 | POWER_SUPPLY_PROP_TEMP_AMBIENT, | 272 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
262 | POWER_SUPPLY_PROP_MANUFACTURER, | 273 | POWER_SUPPLY_PROP_MANUFACTURER, |
274 | POWER_SUPPLY_PROP_SERIAL_NUMBER, | ||
263 | }; | 275 | }; |
264 | 276 | ||
265 | /********************************************************************* | 277 | /********************************************************************* |