linux: Use existing gudev functions in Watts-Up driver

This commit is contained in:
Bastien Nocera 2020-09-15 13:09:50 +02:00
parent 2ab63bd81b
commit fe9332cbe4

View file

@ -296,10 +296,10 @@ up_device_wup_coldplug (UpDevice *device)
gboolean ret = FALSE;
const gchar *device_file;
const gchar *type;
const gchar *native_path;
gchar *data;
const gchar *vendor;
const gchar *product;
g_autofree char *serial = NULL;
/* detect what kind of device we are */
native = G_UDEV_DEVICE (up_device_get_native (device));
@ -358,7 +358,9 @@ up_device_wup_coldplug (UpDevice *device)
product = g_udev_device_get_property (native, "ID_PRODUCT");
/* hardcode some values */
native_path = g_udev_device_get_sysfs_path (native);
serial = g_strdup (g_udev_device_get_sysfs_attr (native, "serial"));
if (serial)
g_strstrip (serial);
g_object_set (device,
"type", UP_DEVICE_KIND_MONITOR,
"is-rechargeable", FALSE,
@ -366,7 +368,7 @@ up_device_wup_coldplug (UpDevice *device)
"is-present", FALSE,
"vendor", vendor,
"model", product,
"serial", g_strstrip (sysfs_get_string (native_path, "serial")),
"serial", serial,
"has-history", TRUE,
"state", UP_DEVICE_STATE_DISCHARGING,
NULL);