fu-udev-device: add fu_udev_device_get_parent_name

This will fetch the name from parent device
This commit is contained in:
Mario Limonciello 2020-03-27 14:35:46 -05:00 committed by Mario Limonciello
parent 224b685fae
commit 0d207d8dea
3 changed files with 28 additions and 0 deletions

View File

@ -943,6 +943,32 @@ fu_udev_device_pwrite (FuUdevDevice *self, goffset port, guint8 data, GError **e
#endif #endif
} }
/**
* fu_udev_device_get_parent_name
* @self: A #FuUdevDevice
*
* Returns the name of the direct ancestor of this device
*
* Returns: string or NULL if unset or invalid
*
* Since: 1.4.2
**/
gchar *
fu_udev_device_get_parent_name (FuUdevDevice *self)
{
#ifdef HAVE_GUDEV
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
g_autoptr(GUdevDevice) parent = NULL;
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), NULL);
parent = g_udev_device_get_parent (priv->udev_device);
return parent == NULL ? NULL : g_strdup (g_udev_device_get_name (parent));
#else
return NULL;
#endif
}
/** /**
* fu_udev_device_get_sysfs_attr: * fu_udev_device_get_sysfs_attr:
* @self: A #FuUdevDevice * @self: A #FuUdevDevice

View File

@ -88,3 +88,4 @@ gboolean fu_udev_device_pread (FuUdevDevice *self,
const gchar *fu_udev_device_get_sysfs_attr (FuUdevDevice *self, const gchar *fu_udev_device_get_sysfs_attr (FuUdevDevice *self,
const gchar *attr, const gchar *attr,
GError **error); GError **error);
gchar *fu_udev_device_get_parent_name (FuUdevDevice *self);

View File

@ -583,6 +583,7 @@ LIBFWUPDPLUGIN_1.4.1 {
LIBFWUPDPLUGIN_1.4.2 { LIBFWUPDPLUGIN_1.4.2 {
global: global:
fu_udev_device_get_parent_name;
fu_udev_device_get_sysfs_attr; fu_udev_device_get_sysfs_attr;
local: *; local: *;
} LIBFWUPDPLUGIN_1.4.1; } LIBFWUPDPLUGIN_1.4.1;