[PATCH] config/udev: add pre_init stage to config and udev.

Dave Airlie airlied at gmail.com
Sun May 6 09:36:57 PDT 2012


From: Dave Airlie <airlied at redhat.com>

In order to use udev for gpu enumeration, we need to init udev earlier
than input initialisations. This splits the config init stuff so that udev
pre init sets up before output initialisation.

this is just a prepatory patch, doesn't change anything major.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 config/config-backends.h     |    1 +
 config/config.c              |    9 +++++++++
 config/udev.c                |   16 ++++++++++++----
 hw/xfree86/common/xf86Init.c |    2 ++
 include/hotplug.h            |    1 +
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/config/config-backends.h b/config/config-backends.h
index e5622d5..62abc0a 100644
--- a/config/config-backends.h
+++ b/config/config-backends.h
@@ -33,6 +33,7 @@ void remove_devices(const char *backend, const char *config_info);
 BOOL device_is_duplicate(const char *config_info);
 
 #ifdef CONFIG_UDEV
+int config_udev_pre_init(void);
 int config_udev_init(void);
 void config_udev_fini(void);
 #else
diff --git a/config/config.c b/config/config.c
index 2b96dbb..24e7ba7 100644
--- a/config/config.c
+++ b/config/config.c
@@ -33,6 +33,15 @@
 #include "config-backends.h"
 
 void
+config_pre_init(void)
+{
+#ifdef CONFIG_UDEV
+    if (!config_udev_pre_init())
+        ErrorF("[config] failed to pre-init udev\n");
+#endif
+}
+
+void
 config_init(void)
 {
 #ifdef CONFIG_UDEV
diff --git a/config/udev.c b/config/udev.c
index 8b3ca04..1995184 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -281,15 +281,14 @@ block_handler(pointer data, struct timeval **tv, pointer read_mask)
 }
 
 int
-config_udev_init(void)
+config_udev_pre_init(void)
 {
     struct udev *udev;
-    struct udev_enumerate *enumerate;
-    struct udev_list_entry *devices, *device;
 
     udev = udev_new();
     if (!udev)
         return 0;
+
     udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
     if (!udev_monitor)
         return 0;
@@ -302,12 +301,21 @@ config_udev_init(void)
     if (SeatId && strcmp(SeatId, "seat0"))
         udev_monitor_filter_add_match_tag(udev_monitor, SeatId);
 #endif
-
     if (udev_monitor_enable_receiving(udev_monitor)) {
         ErrorF("config/udev: failed to bind the udev monitor\n");
         return 0;
     }
+    return 1;
+}
 
+int
+config_udev_init(void)
+{
+    struct udev *udev;
+    struct udev_enumerate *enumerate;
+    struct udev_list_entry *devices, *device;
+
+    udev = udev_monitor_get_udev(udev_monitor);
     enumerate = udev_enumerate_new(udev);
     if (!enumerate)
         return 0;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index f42dd10..ead47cc 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -405,6 +405,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
 
     xf86Initialising = TRUE;
 
+    config_pre_init();
+
     if (serverGeneration == 1) {
         if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
             xf86ServerName++;
diff --git a/include/hotplug.h b/include/hotplug.h
index caa3201..f3eeea2 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -26,6 +26,7 @@
 #ifndef HOTPLUG_H
 #define HOTPLUG_H
 
+extern _X_EXPORT void config_pre_init(void);
 extern _X_EXPORT void config_init(void);
 extern _X_EXPORT void config_fini(void);
 
-- 
1.7.7.6



More information about the xorg-devel mailing list