diff options
author | Loic Poulain <loic.poulain@linaro.org> | 2021-07-30 15:34:17 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-07-30 14:03:40 +0000 |
commit | b0248e471ced05dfd5fa1cebe732722d10738add (patch) | |
tree | c325821d26de0d95f079abab4e5ea795c2cb8035 /src | |
parent | 7c4db66eb34eebecc6b17fe86375e081b49bff00 (diff) |
kernel-device: generic: Support ATTR condition
Only the plural ATTRS form was checked but we also need to support
the single ATTR for matching device's attribute only.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/kerneldevice/mm-kernel-device-generic.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/kerneldevice/mm-kernel-device-generic.c b/src/kerneldevice/mm-kernel-device-generic.c index 9c6cc292..94f969f9 100644 --- a/src/kerneldevice/mm-kernel-device-generic.c +++ b/src/kerneldevice/mm-kernel-device-generic.c @@ -128,7 +128,8 @@ read_sysfs_attribute_link_basename (const gchar *path, static gchar * lookup_sysfs_attribute_as_string (MMKernelDeviceGeneric *self, - const gchar *attribute) + const gchar *attribute, + gboolean iterate) { g_autofree gchar *iter = NULL; @@ -145,6 +146,8 @@ lookup_sysfs_attribute_as_string (MMKernelDeviceGeneric *self, /* return first one found */ if ((value = read_sysfs_attribute_as_string (iter, attribute)) != NULL) return value; + else if (!iterate) + break; if (g_strcmp0 (iter, self->priv->physdev_sysfs_path) == 0) break; @@ -834,7 +837,7 @@ check_condition (MMKernelDeviceGeneric *self, } /* Attributes checks */ - if (g_str_has_prefix (match->parameter, "ATTRS")) { + if (g_str_has_prefix (match->parameter, "ATTR")) { gchar *attribute; gchar *contents = NULL; gboolean result = FALSE; @@ -873,7 +876,7 @@ check_condition (MMKernelDeviceGeneric *self, else { g_autofree gchar *found_value = NULL; - found_value = lookup_sysfs_attribute_as_string (self, attribute); + found_value = lookup_sysfs_attribute_as_string (self, attribute, g_str_has_prefix (match->parameter, "ATTRS")); result = ((found_value && g_str_equal (found_value, match->value)) == condition_equal); } |