Commit 22b7d170 authored by Christian Kellner's avatar Christian Kellner
Browse files

device: strip vendor prefix from name

Some thunderbolt devices have their name prefixed with the vendor
name. Since this is redundant we strip it.
parent 43b508a5
......@@ -518,6 +518,34 @@ bolt_sysfs_security_for_device (struct udev_device *udev)
return s;
}
static const char *
cleanup_name (const char *name,
const char *vendor,
GError **error)
{
g_return_val_if_fail (vendor != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
/* some devices have the vendor name as a prefix */
if (!g_str_has_prefix (name, vendor))
return name;
name += strlen (vendor);
while (g_ascii_isspace (*name))
name++;
if (*name == '\0')
{
g_set_error_literal (error,
BOLT_ERROR, BOLT_ERROR_UDEV,
"device has empty name after cleanup");
return NULL;
}
return name;
}
/* device authorization */
typedef struct
......@@ -763,6 +791,10 @@ bolt_device_new_for_udev (struct udev_device *udev,
if (vendor == NULL)
return NULL;
name = cleanup_name (name, vendor, error);
if (name == NULL)
return NULL;
parent = bolt_sysfs_get_parent_uid (udev);
dev = g_object_new (BOLT_TYPE_DEVICE,
"uid", uid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment