summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-08-31 15:58:59 +0200
committerBastien Nocera <hadess@hadess.net>2017-08-31 16:21:25 +0200
commit623a6bfc57c3d3ea52d671079947a10cb3150999 (patch)
treeb9bfddbc71dcefbf8ec2c10868d26710dbba50d3 /src
parent320cc87811de80715dfadee30bcdc6dab100f7fd (diff)
linux: Move function to prepare for new use
Move up_device_supply_get_sibling_with_subsystem() so we can use it in up_device_supply_refresh_device() https://bugs.freedesktop.org/show_bug.cgi?id=102493
Diffstat (limited to 'src')
-rw-r--r--src/linux/up-device-supply.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 15987b8..1e2bfb6 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -848,6 +848,51 @@ out:
return ret;
}
+static GUdevDevice *
+up_device_supply_get_sibling_with_subsystem (GUdevDevice *device,
+ const char *subsystem)
+{
+ GUdevDevice *parent;
+ GUdevClient *client;
+ GUdevDevice *sibling;
+ const char * class[] = { NULL, NULL };
+ const char *parent_path;
+ GList *devices, *l;
+
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (subsystem != NULL, NULL);
+
+ parent = g_udev_device_get_parent (device);
+ if (!parent)
+ return NULL;
+ parent_path = g_udev_device_get_sysfs_path (parent);
+
+ sibling = NULL;
+ class[0] = subsystem;
+ client = g_udev_client_new (class);
+ devices = g_udev_client_query_by_subsystem (client, subsystem);
+ for (l = devices; l != NULL && sibling == NULL; l = l->next) {
+ GUdevDevice *d = l->data;
+ GUdevDevice *p;
+ const char *p_path;
+
+ p = g_udev_device_get_parent (d);
+ if (!p)
+ continue;
+ p_path = g_udev_device_get_sysfs_path (p);
+ if (g_strcmp0 (p_path, parent_path) == 0)
+ sibling = g_object_ref (d);
+
+ g_object_unref (p);
+ }
+
+ g_list_free_full (devices, (GDestroyNotify) g_object_unref);
+ g_object_unref (client);
+ g_object_unref (parent);
+
+ return sibling;
+}
+
/**
* up_device_supply_refresh_device:
*
@@ -948,51 +993,6 @@ up_device_supply_poll_unknown_battery (UpDevice *device)
return FALSE;
}
-static GUdevDevice *
-up_device_supply_get_sibling_with_subsystem (GUdevDevice *device,
- const char *subsystem)
-{
- GUdevDevice *parent;
- GUdevClient *client;
- GUdevDevice *sibling;
- const char * class[] = { NULL, NULL };
- const char *parent_path;
- GList *devices, *l;
-
- g_return_val_if_fail (device != NULL, NULL);
- g_return_val_if_fail (subsystem != NULL, NULL);
-
- parent = g_udev_device_get_parent (device);
- if (!parent)
- return NULL;
- parent_path = g_udev_device_get_sysfs_path (parent);
-
- sibling = NULL;
- class[0] = subsystem;
- client = g_udev_client_new (class);
- devices = g_udev_client_query_by_subsystem (client, subsystem);
- for (l = devices; l != NULL && sibling == NULL; l = l->next) {
- GUdevDevice *d = l->data;
- GUdevDevice *p;
- const char *p_path;
-
- p = g_udev_device_get_parent (d);
- if (!p)
- continue;
- p_path = g_udev_device_get_sysfs_path (p);
- if (g_strcmp0 (p_path, parent_path) == 0)
- sibling = g_object_ref (d);
-
- g_object_unref (p);
- }
-
- g_list_free_full (devices, (GDestroyNotify) g_object_unref);
- g_object_unref (client);
- g_object_unref (parent);
-
- return sibling;
-}
-
static UpDeviceKind
up_device_supply_guess_type (GUdevDevice *native,
const char *native_path)