summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-10-18 16:04:45 +0200
committerBastien Nocera <hadess@hadess.net>2013-10-18 16:16:54 +0200
commit456a9a4ea409cb8630a62a1ecf224e2ed65a817e (patch)
tree9c2e2b4fe15211ba2aee7fc35137531fe447ff46
parenta1a91e7e5d3338bc649119d8c462f9c32135d971 (diff)
downloadupower-456a9a4ea409cb8630a62a1ecf224e2ed65a817e.tar.gz
linux: Use up_device_supply_get_string()
In up_device_supply_get_state()
-rw-r--r--src/linux/up-device-supply.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 0b8a0eb..6edf420 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -450,8 +450,12 @@ up_device_supply_get_state (const gchar *native_path)
UpDeviceState state;
gchar *status;
- status = g_strstrip (sysfs_get_string (native_path, "status"));
- if (g_ascii_strcasecmp (status, "charging") == 0)
+ status = up_device_supply_get_string (native_path, "status");
+ if (status == NULL ||
+ g_ascii_strcasecmp (status, "unknown") == 0 ||
+ *status == '\0') {
+ state = UP_DEVICE_STATE_UNKNOWN;
+ } else if (g_ascii_strcasecmp (status, "charging") == 0)
state = UP_DEVICE_STATE_CHARGING;
else if (g_ascii_strcasecmp (status, "discharging") == 0)
state = UP_DEVICE_STATE_DISCHARGING;
@@ -459,9 +463,6 @@ up_device_supply_get_state (const gchar *native_path)
state = UP_DEVICE_STATE_FULLY_CHARGED;
else if (g_ascii_strcasecmp (status, "empty") == 0)
state = UP_DEVICE_STATE_EMPTY;
- else if (g_ascii_strcasecmp (status, "unknown") == 0 ||
- *status == '\0')
- state = UP_DEVICE_STATE_UNKNOWN;
else if (g_ascii_strcasecmp (status, "not charging") == 0)
state = UP_DEVICE_STATE_PENDING_CHARGE;
else {