summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-02-02 11:25:34 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-03 08:13:55 +0100
commit10c64e80569bbd35e97916a067f553cab27454b5 (patch)
treeb6aa93b20c9310f485e585ca7c70c6e2dbae8ce5 /config
parent3346166a6596115421702c1f7e2732215674ab8e (diff)
OdevAttribute: Add config_odev_get_attribute helper
Add a config_odev_get_attribute helper, and replace the diy looping over all the attributes done in various places with calls to this helper. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'config')
-rw-r--r--config/config.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/config/config.c b/config/config.c
index 760cf193a..088bd5ac2 100644
--- a/config/config.c
+++ b/config/config.c
@@ -145,6 +145,18 @@ config_odev_free_attribute_list(struct OdevAttributes *attribs)
free(attribs);
}
+static struct OdevAttribute *
+config_odev_find_attribute(struct OdevAttributes *attribs, int attrib_id)
+{
+ struct OdevAttribute *oa;
+
+ xorg_list_for_each_entry(oa, &attribs->list, member) {
+ if (oa->attrib_id == attrib_id)
+ return oa;
+ }
+ return NULL;
+}
+
Bool
config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
const char *attrib_name)
@@ -161,6 +173,18 @@ config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
return TRUE;
}
+char *
+config_odev_get_attribute(struct OdevAttributes *attribs, int attrib_id)
+{
+ struct OdevAttribute *oa;
+
+ oa = config_odev_find_attribute(attribs, attrib_id);
+ if (!oa)
+ return NULL;
+
+ return oa->attrib_name;
+}
+
void
config_odev_free_attributes(struct OdevAttributes *attribs)
{