summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/config.c24
-rw-r--r--hw/xfree86/common/xf86platformBus.c17
-rw-r--r--hw/xfree86/os-support/linux/lnx_platform.c8
-rw-r--r--include/hotplug.h3
4 files changed, 30 insertions, 22 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)
{
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 5875a9136..6d3816dde 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -92,26 +92,13 @@ xf86_add_platform_device_attrib(int index, int attrib_id, char *attrib_name)
char *
xf86_get_platform_attrib(int index, int attrib_id)
{
- struct xf86_platform_device *device = &xf86_platform_devices[index];
- struct OdevAttribute *oa;
-
- xorg_list_for_each_entry(oa, &device->attribs->list, member) {
- if (oa->attrib_id == attrib_id)
- return oa->attrib_name;
- }
- return NULL;
+ return config_odev_get_attribute(xf86_platform_devices[index].attribs, attrib_id);
}
char *
xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib_id)
{
- struct OdevAttribute *oa;
-
- xorg_list_for_each_entry(oa, &device->attribs->list, member) {
- if (oa->attrib_id == attrib_id)
- return oa->attrib_name;
- }
- return NULL;
+ return config_odev_get_attribute(device->attribs, attrib_id);
}
Bool
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 1865b31b9..431720977 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -118,17 +118,11 @@ xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
void
xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
{
- struct OdevAttribute *attrib;
int i;
char *path = NULL;
Bool ret;
- xorg_list_for_each_entry(attrib, &attribs->list, member) {
- if (attrib->attrib_id == ODEV_ATTRIB_PATH) {
- path = attrib->attrib_name;
- break;
- }
- }
+ path = config_odev_get_attribute(attribs, ODEV_ATTRIB_PATH);
if (!path)
goto out_free;
diff --git a/include/hotplug.h b/include/hotplug.h
index 29a22c4da..ee7b7d7d5 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -53,6 +53,9 @@ Bool
config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
const char *attrib_name);
+char *
+config_odev_get_attribute(struct OdevAttributes *attribs, int attrib_id);
+
void
config_odev_free_attributes(struct OdevAttributes *attribs);