upower: Handle Linux power supplies not exporting a present property

A patch from »upower: Handle Linux power supplies not exporting a present property« in state Accepted for upower

From: Heiko Stuebner <heiko@...> Date: Sun, 27 Nov 2011 20:12:13 +0100

Commit-Message

According to Anton Vorontsov (Linux power supply maintainer) power supplies should not export a present property when they are not hotpluggable and users of the properties should handle supplies without present-property as always present. This patch implements this feature using an additional sysfs_file_exists call before sysfs_get_bool.

Patch-Comment

src/linux/up-device-supply.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)

Statistics

  • 5 lines added
  • 1 lines removed

Changes

------------------------- src/linux/up-device-supply.c -------------------------
index d272e36..9da4861 100644
@@ -516,7 +516,11 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
native_path = g_udev_device_get_sysfs_path (native);
/* have we just been removed? */
- is_present = sysfs_get_bool (native_path, "present");
+ if (sysfs_file_exists (native_path, "present"))
+ is_present = sysfs_get_bool (native_path, "present");
+ else
+ /* when no present property exists, handle as present */
+ is_present = 1;
g_object_set (device, "is-present", is_present, NULL);
if (!is_present) {
up_device_supply_reset_values (supply);
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...