diff options
author | Richard Hughes <richard@hughsie.com> | 2011-11-29 15:59:36 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2011-11-29 15:59:36 +0000 |
commit | 6b685799cc5fad476afcdce73ead7b6a84d2cfe7 (patch) | |
tree | 6b436e20402227506f82c9d3c61ed24653def923 /src/linux/up-device-supply.c | |
parent | 21da4824a74d2d6e592f7382b061a6505d4660e4 (diff) | |
download | upower-6b685799cc5fad476afcdce73ead7b6a84d2cfe7.tar.gz |
trivial: USB devices are assumed to be 5V
Diffstat (limited to 'src/linux/up-device-supply.c')
-rw-r--r-- | src/linux/up-device-supply.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 43f6835..1b75df0 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -370,6 +370,7 @@ static gdouble up_device_supply_get_design_voltage (const gchar *native_path) { gdouble voltage; + const gchar *device_type; /* design maximum */ voltage = sysfs_get_double (native_path, "voltage_max_design") / 1000000.0; @@ -399,6 +400,14 @@ up_device_supply_get_design_voltage (const gchar *native_path) goto out; } + /* is this a USB device? */ + device_type = up_device_supply_get_string (native_path, "type"); + if (g_ascii_strcasecmp (device_type, "USB") == 0) { + g_debug ("USB device, so assuming 5v"); + voltage = 5.0f; + goto out; + } + /* completely guess, to avoid getting zero values */ g_warning ("no voltage values, using 10V as approximation"); voltage = 10.0f; |