hal: Branch 'master' - 6 commits

Rob Taylor robtaylor at kemper.freedesktop.org
Thu Feb 1 14:15:26 PST 2007


 configure.in          |   85 +++++++++++++++++++++++++++++++++++++++++++-------
 hald/hald_runner.c    |   17 +++++++++-
 hald/hald_runner.h    |    3 +
 hald/ids.c            |   41 +++++++++++++++---------
 hald/ids.h            |   39 +++++++++++++++++++---
 hald/linux/blockdev.c |    2 -
 hald/linux/hotplug.c  |   42 +++++++++++-------------
 hald/linux/osspec.c   |    5 +-
 8 files changed, 175 insertions(+), 59 deletions(-)

New commits:
diff-tree 1a0857154bf60a03b355daa9cc8d7127db69a267 (from parents)
Merge: d4c4adeb6157bb58e06ff494062463032f13fa0b 852316baa3bffd188cb61daf24eb78978e7b36af
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date:   Thu Feb 1 22:14:08 2007 +0000

    Merge branch 'to-push'

diff-tree 852316baa3bffd188cb61daf24eb78978e7b36af (from 9c0a0686210f0bff9116ae5fb13922ab919f8336)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date:   Thu Feb 1 21:01:28 2007 +0000

    Add back autodetection of usb.ids and pci.ids when not specified.
    
    Autodetect pci.ids and usb.ids seperetely when pci or usb is enabled, respectively. Warns when they have been autodected, as the detected location may not be what the packager intends.

diff --git a/configure.in b/configure.in
index 90d8c5e..192c6eb 100644
--- a/configure.in
+++ b/configure.in
@@ -67,19 +67,33 @@ if test "x$enable_pci_ids" = "xno" ; the
   USE_PCI_IDS=no
 else
    if test -z "$PCI_IDS_DIR"; then
-     AC_ERROR([cannot find pci.ids. Use --with-pci-ids to specify location])
+     for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do
+       AC_CHECK_FILE($dir/pci.ids,PCI_IDS_DIR=$dir)
+     done
+     if test -z "$PCI_IDS_DIR"; then
+       AC_ERROR([cannot find pci.ids. Use --with-pci-ids to specify location])
+     else
+       AC_WARN([Autodetected pci.ids in $PCI_IDS_DIR])
+     fi
    fi
    USE_PCI_IDS=yes
    AC_DEFINE(USE_PCI_IDS,1,[Whether pci.ids is to be used])
 fi
 
 if test "x$enable_usb_ids" = "xno" ; then
-  USE_PCI_IDS=no
+  USE_USB_IDS=no
 else 
    if test -z "$USB_IDS_DIR"; then
-     AC_ERROR([cannot find usb.ids. Use --with-usb-ids to specify location])
+     for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do
+       AC_CHECK_FILE($dir/usb.ids,USB_IDS_DIR=$dir)
+     done
+     if test -z "$USB_IDS_DIR"; then
+       AC_ERROR([cannot find usb.ids. Use --with-usb-ids to specify location])
+     else
+       AC_WARN([Autodetected usb.ids in $USB_IDS_DIR])
+     fi
    fi
-   USE_PCI_IDS=yes
+   USE_USB_IDS=yes
    AC_DEFINE(USE_USB_IDS,1,[Whether usb.ids is to be used])
 fi
 
diff-tree d4c4adeb6157bb58e06ff494062463032f13fa0b (from parents)
Merge: 9c0a0686210f0bff9116ae5fb13922ab919f8336 3c2c3677cb9af1da44cc736b00c333cc17fb6220
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date:   Thu Feb 1 20:31:55 2007 +0000

    Merge branch 'master' of ssh://git.freedesktop.org/git/hal

diff-tree 9c0a0686210f0bff9116ae5fb13922ab919f8336 (from parents)
Merge: eb166fe59ecc83dde48e2f4ff5228830fbcfa1a4 f47230b49f1234f34c617e79963d18ba3a68cb26
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date:   Wed Jan 31 18:22:14 2007 +0000

    Merge branch 'master' into to-push

diff-tree eb166fe59ecc83dde48e2f4ff5228830fbcfa1a4 (from edc7a142ed13d6245f307187f3eadd3bddd4b9da)
Author: Rob Taylor <rob.taylor at collabora.co.uk>
Date:   Fri Dec 8 09:50:03 2006 +0000

    Make hotplugging non-recursive.
    
    This adds a notify callback for when hald_runner has finished calling a callout.
    For linux, we install hotplug_event_process_queue as the notify, and modify hotplug_event_process_queue to iterate the queue. All recrursive calls to hotplug_event_process_queue are removed. This results in massive stack and a not inconsiquential heap savings.

diff --git a/hald/hald_runner.c b/hald/hald_runner.c
index 41fa987..95edbec 100644
--- a/hald/hald_runner.c
+++ b/hald/hald_runner.c
@@ -54,6 +54,8 @@ typedef struct {
 #define DBUS_SERVER_ADDRESS "unix:tmpdir=" HALD_SOCKET_DIR
 
 static DBusConnection *runner_connection = NULL;
+static HaldRunnerRunNotify method_run_notify = NULL;
+static gpointer method_run_notify_userdata = NULL;
 
 typedef struct
 {
@@ -526,7 +528,9 @@ call_notify(DBusPendingCall *pending, vo
   g_free (hb);
 
   dbus_pending_call_unref (pending);
-  return;
+
+  goto out;
+
 malformed:
   /* Send a Fail callback on malformed messages */
   HAL_ERROR (("Malformed or unexpected reply message"));
@@ -541,6 +545,10 @@ malformed:
   g_free (hb);
 
   dbus_pending_call_unref (pending);
+
+out:
+  if (method_run_notify)
+    method_run_notify (method_run_notify_userdata);
 }
 
 /* Run a helper program using the commandline, with input as infomation on
@@ -661,3 +669,10 @@ hald_runner_kill_all(HalDevice *device) 
 
   dbus_message_unref(msg);
 }
+
+void
+hald_runner_set_method_run_notify (HaldRunnerRunNotify cb, gpointer user_data)
+{
+  method_run_notify = cb;
+  method_run_notify_userdata = user_data;
+}
diff --git a/hald/hald_runner.h b/hald/hald_runner.h
index 0fc2425..4dc1267 100644
--- a/hald/hald_runner.h
+++ b/hald/hald_runner.h
@@ -83,4 +83,7 @@ void hald_runner_kill_all();
 /* called by the core to tell the runner a device was finalized */
 void runner_device_finalized (HalDevice *device);
 
+typedef void (*HaldRunnerRunNotify)(gpointer user_data);
+void hald_runner_set_method_run_notify (HaldRunnerRunNotify cb, gpointer user_data);
+
 #endif 
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 52c6071..55f22f1 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -315,7 +315,6 @@ generate_fakevolume_hotplug_event_add_fo
 	hotplug_event->sysfs.net_ifindex = -1;
 
 	hotplug_event_enqueue (hotplug_event);
-	hotplug_event_process_queue ();
 }
 
 static void 
@@ -1303,7 +1302,6 @@ block_rescan_storage_done (HalDevice *d,
 			hotplug_event = blockdev_generate_remove_hotplug_event (fakevolume);
 			if (hotplug_event != NULL) {
 				hotplug_event_enqueue (hotplug_event);
-				hotplug_event_process_queue ();
 			}
 		}
 	}
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index b5e62bf..986b96c 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -67,7 +67,6 @@ hotplug_event_end (void *end_token)
 	} else {
 		g_free (hotplug_event);
 	}
-	hotplug_event_process_queue ();
 }
 
 void 
@@ -76,7 +75,6 @@ hotplug_event_reposted (void *end_token)
 	HotplugEvent *hotplug_event = (HotplugEvent *) end_token;
 
 	hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event);
-	hotplug_event_process_queue ();
 }
 
 static void
@@ -305,29 +303,29 @@ hotplug_event_process_queue (void)
 {
 	HotplugEvent *hotplug_event;
 
-	if (hotplug_events_in_progress == NULL && 
-	    (hotplug_event_queue == NULL || g_queue_is_empty (hotplug_event_queue))) {
-		hotplug_queue_now_empty ();
-		goto out;
-	}
+        while (hotplug_events_in_progress != NULL ||
+		(hotplug_event_queue != NULL &&
+		 !g_queue_is_empty (hotplug_event_queue))) {
+
+		/* do not process events if some other event is in progress 
+		 *
+		 * TODO: optimize so we can do add events in parallel by inspecting the
+		 *       wait_for_sysfs_path parameter and hotplug_events_in_progress list
+		 */
+		if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0)
+			goto out;
+
+		hotplug_event = g_queue_pop_head (hotplug_event_queue);
+		if (hotplug_event == NULL)
+			goto out;
 
-	/* do not process events if some other event is in progress 
-	 *
-	 * TODO: optimize so we can do add events in parallel by inspecting the
-	 *       wait_for_sysfs_path parameter and hotplug_events_in_progress list
-	 */
-	if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0)
-		goto out;
-
-	hotplug_event = g_queue_pop_head (hotplug_event_queue);
-	if (hotplug_event == NULL)
-		goto out;
-
-	hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event);
-	hotplug_event_begin (hotplug_event);
+		hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event);
+		hotplug_event_begin (hotplug_event);
+	}
 
+	hotplug_queue_now_empty ();
 out:
-	;	
+        ;
 }
 
 gboolean 
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 12047e0..1fdf90a 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -335,9 +335,6 @@ computer_callouts_add_done (HalDevice *d
 	/* Move from temporary to global device store */
 	hal_device_store_remove (hald_get_tdl (), d);
 	hal_device_store_add (hald_get_gdl (), d);
-
-	/* start processing events */
-	hotplug_event_process_queue ();
 }
 
 void
@@ -579,6 +576,8 @@ osspec_probe (void)
 
 	should_decode_dmi = FALSE;
 
+	hald_runner_set_method_run_notify (hotplug_event_process_queue,
+					   NULL);
 	root = hal_device_new ();
 	hal_device_property_set_string (root, "info.bus", "unknown");
 	hal_device_property_set_string (root, "info.product", "Computer");
diff-tree edc7a142ed13d6245f307187f3eadd3bddd4b9da (from 92209ec0ae7b860746beb243fa52a1d405efb29f)
Author: Rob Taylor <rob.taylor at collabora.co.uk>
Date:   Thu Dec 28 17:30:02 2006 +0000

    Remove checking for run-time usb.ids and pci.ids at build time
    
    Remove build time checking for location of usb.ids and pci.ids. Adds new configure flags --with-pci-ids and --with-usb-ids for specifying locations of pci.ids and usb.ids respectivly. Also adds --disable-pci-ids, --disable-usb-ids and --disable-pnp-ids.

diff --git a/configure.in b/configure.in
index c479de3..90d8c5e 100644
--- a/configure.in
+++ b/configure.in
@@ -42,20 +42,61 @@ AC_CHECK_HEADERS([sys/ioccom.h])
 
 AC_ARG_WITH(os-type,     [  --with-os-type=<os>     Distribution or OS (redhat)])
 AC_ARG_WITH(pid-file,    [  --with-pid-file=<file>  PID file for HAL daemon])
-AC_ARG_WITH(hwdata,[  --with-hwdata=<dir>     where PCI and USB IDs are found (auto)])
+
+AC_ARG_WITH(hwdata, AC_HELP_STRING([--with-hwdata=<dir>], [Where PCI and USB IDs are found]))
+AC_ARG_WITH(pci-ids, AC_HELP_STRING([--with-pci-ids=<dir>], [Where PCI IDs are found (overrides --with-hwdata)]))
+AC_ARG_WITH(usb-ids, AC_HELP_STRING([--with-usb-ids=<dir>], [Where USB IDs are found (overrides --with-hwdata)]))
+AC_ARG_ENABLE([pci-ids], AC_HELP_STRING([--disable-pci-ids], [Do not build with PCI IDs support]), [enable_pci_ids=$enableval], [enable_pci_ids=yes])
+AC_ARG_ENABLE([usb-ids], AC_HELP_STRING([--disable-usb-ids], [Do not build with USB IDs support]), [enable_usb_ids=$enableval], [enable_usb_ids=yes])
+AC_ARG_ENABLE([pnp-ids], AC_HELP_STRING([--disable-pnp-ids], [Do not build with PNP IDs support]), [enable_pnp_ids=$enableval], [enable_pnp_ids=yes])
+
+AC_ARG_WITH(socket-dir,[  --with-socket-dir=<dir>  Location of the HAL D-BUS listening sockets (auto)])
 AC_ARG_WITH(socket-dir,[  --with-socket-dir=<dir>  Location of the HAL D-BUS listening sockets (auto)])
 if ! test -z "$with_hwdata" ; then
-   HWDATA_DIR="$with_hwdata"
+  PCI_IDS_DIR="$with_hwdata"
+  USB_IDS_DIR="$with_hwdata"
+fi
+if ! test -z "$with_pci_ids" ; then
+  PCI_IDS_DIR="$with_pci_ids"
+fi
+if ! test -z "$with_usb_ids" ; then
+  USB_IDS_DIR="$with_usb_ids"
+fi
+
+if test "x$enable_pci_ids" = "xno" ; then
+  USE_PCI_IDS=no
 else
-   for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do
-      AC_CHECK_FILE($dir/pci.ids,HWDATA_DIR=$dir)
-   done
+   if test -z "$PCI_IDS_DIR"; then
+     AC_ERROR([cannot find pci.ids. Use --with-pci-ids to specify location])
+   fi
+   USE_PCI_IDS=yes
+   AC_DEFINE(USE_PCI_IDS,1,[Whether pci.ids is to be used])
 fi
-if test -z "$HWDATA_DIR"; then
-   AC_ERROR(cannot find pci.ids. Use --with-hwdata to specify location)
+
+if test "x$enable_usb_ids" = "xno" ; then
+  USE_PCI_IDS=no
+else 
+   if test -z "$USB_IDS_DIR"; then
+     AC_ERROR([cannot find usb.ids. Use --with-usb-ids to specify location])
+   fi
+   USE_PCI_IDS=yes
+   AC_DEFINE(USE_USB_IDS,1,[Whether usb.ids is to be used])
+fi
+
+if test "x$enable_pnp_ids" = "xno" ; then
+  USE_PNP_IDS=no
+else
+  USE_PNP_IDS=yes
+  AC_DEFINE(USE_PNP_IDS,1,[Whether builtin PNP IDs are to be used])
 fi
-AC_SUBST(HWDATA_DIR)
-AC_DEFINE_UNQUOTED(HWDATA_DIR,"$HWDATA_DIR", [Where PCI and USB IDs are found])
+
+AC_DEFINE_UNQUOTED(PCI_IDS_DIR,"$PCI_IDS_DIR", [Where PCI IDs are found])
+AC_DEFINE_UNQUOTED(USB_IDS_DIR,"$USB_IDS_DIR", [Where USB IDs are found])
+AC_SUBST(PCI_IDS_DIR)
+AC_SUBST(USB_IDS_DIR)
+AC_SUBST(USE_PCI_IDS)
+AC_SUBST(USE_USB_IDS)
+AC_SUBST(USE_PNP_IDS)
 
 
 AC_ARG_WITH(hal_user,[  --with-hal-user=<user>  User for running the HAL daemon (haldaemon)])
@@ -329,6 +370,13 @@ if test "x$enable_pmu" != "xno"; then
 fi
 AM_CONDITIONAL(HAVE_PMU, test x$msg_pmu = xyes, [Compiling PMU])
 
+AC_ARG_ENABLE(have_pci, [  --disable-pci          Build without PCI support])
+msg_pci=no
+if test "x$enable_pci" != "xno"; then
+	msg_pci=yes
+ 	AC_DEFINE(HAVE_PCI, [], [Set if we have ACPI support])
+fi
+
 # D-Bus libs
 PKG_CHECK_MODULES(DBUS, [$dbus_module])
 AC_SUBST(DBUS_CFLAGS)
@@ -671,7 +719,8 @@ echo "
         localstatedir:              ${LOCALSTATEDIR}
         docdir:                     ${DOCDIR}
         dbus-1 system.d dir:        ${DBUS_SYS_DIR}
-        pci.ids, usb.ids dir:       ${HWDATA_DIR}
+        pci.ids dir:                ${PCI_IDS_DIR}
+        usb.ids dir:                ${USB_IDS_DIR}
 
         compiler:                   ${CC}
         cflags:                     ${CFLAGS}
diff --git a/hald/ids.c b/hald/ids.c
index 7bfaf19..3881aca 100644
--- a/hald/ids.c
+++ b/hald/ids.c
@@ -44,6 +44,7 @@
 
 #include "ids.h"
 
+#ifdef USE_PCI_IDS
 /** Pointer to where the pci.ids file is loaded */
 static char *pci_ids = NULL;
 
@@ -306,8 +307,18 @@ out:
 	return ret;
 }
 
+void
+pci_ids_init (void)
+{
+	/* Load /usr/share/hwdata/pci.ids */
+	pci_ids_load (PCI_IDS_DIR "/pci.ids");
+}
+
+#endif /*USE_PCI_IDS*/
+
 /*==========================================================================*/
 
+#ifdef USE_USB_IDS
 /** Pointer to where the usb.ids file is loaded */
 static char *usb_ids = NULL;
 
@@ -510,25 +521,17 @@ out:
 }
 
 void
-pci_ids_init (void)
-{
-	/* Load /usr/share/hwdata/pci.ids */
-	pci_ids_load (HWDATA_DIR "/pci.ids");
-}
-
-void
 usb_ids_init (void)
 {
 	/* Load /usr/share/hwdata/usb.ids */
-	usb_ids_load (HWDATA_DIR "/usb.ids");
+	usb_ids_load (USB_IDS_DIR "/usb.ids");
 }
 
-void 
-ids_init (void)
-{
-	pci_ids_init ();
-	usb_ids_init ();
-}
+#endif /*USE_USB_IDS*/
+
+/*==========================================================================*/
+
+#ifdef USE_PNP_IDS
 
 /* This, somewhat incomplete, list is from this sources:
  * http://www.plasma-online.de/english/identify/serial/pnp_id_pnp.html 
@@ -970,3 +973,13 @@ ids_find_pnp (const char *pnp_id, char *
         	*pnp_description = NULL; 
         return;
 }
+
+#endif /*USE_PNP_IDS*/
+
+/*==========================================================================*/
+
+ids_init (void)
+{
+	pci_ids_init ();
+	usb_ids_init ();
+}
diff --git a/hald/ids.h b/hald/ids.h
index 34648b7..7773211 100644
--- a/hald/ids.h
+++ b/hald/ids.h
@@ -28,11 +28,9 @@
 
 #include <glib.h>
 
-void pci_ids_init (void);
-
-void usb_ids_init (void);
+#ifdef USE_PCI_IDS
 
-void ids_init (void);
+void pci_ids_init (void);
 
 void
 ids_find_pci (int vendor_id, int product_id,
@@ -40,12 +38,41 @@ ids_find_pci (int vendor_id, int product
 	      char **vendor_name, char **product_name,
 	      char **subsys_vendor_name, char **subsys_product_name);
 
+#else /*USE_PCI_IDS*/
+static inline void pci_ids_init (void) {return;};
+
+static inline void
+ids_find_pci (int vendor_id, int product_id,
+	      int subsys_vendor_id, int subsys_product_id,
+	      char **vendor_name, char **product_name,
+	      char **subsys_vendor_name, char **subsys_product_name) {return;}
+#endif /*USE_PCI_IDS*/
+
+#ifdef USE_PNP_IDS
+
+void
+ids_find_pnp (const char *pnp_id, char **pnp_description);
+
+#else /*USE_PNP_IDS*/
+static inline void
+ids_find_pnp (const char *pnp_id, char **pnp_description) {return;}
+#endif /*USE_PNP_IDS*/
+
+#ifdef USE_USB_IDS
+
+void usb_ids_init (void);
+
 void
 ids_find_usb (int vendor_id, int product_id,
 	      char **vendor_name, char **product_name);
 
-void
-ids_find_pnp (const char *pnp_id, char **pnp_description);
+#else /*USE_USB_IDS*/
+static inline void usb_ids_init (void) {return;}
+static inline void
+ids_find_usb (int vendor_id, int product_id,
+	      char **vendor_name, char **product_name) {return;}
+#endif /*USE_USB_IDS*/
 
+void ids_init (void);
 
 #endif /* IDS_H */


More information about the hal-commit mailing list