hal/hald/linux block_class_device.c, 1.14, 1.15 bus_device.c, 1.5, 1.6 bus_device.h, 1.3, 1.4 class_device.c, 1.10, 1.11 class_device.h, 1.5, 1.6 common.c, 1.4, 1.5 common.h, 1.1, 1.2 ide_host_bus_device.c, 1.4, 1.5 net_class_device.c, 1.2, 1.3 osspec.c, 1.14, 1.15 printer_class_device.c, 1.5, 1.6 usb_bus_device.c, 1.8, 1.9 usbif_bus_device.c, 1.5, 1.6

David Zeuthen david at pdx.freedesktop.org
Sun Apr 25 10:24:47 PDT 2004


Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv10816/hald/linux

Modified Files:
	block_class_device.c bus_device.c bus_device.h class_device.c 
	class_device.h common.c common.h ide_host_bus_device.c 
	net_class_device.c osspec.c printer_class_device.c 
	usb_bus_device.c usbif_bus_device.c 
Log Message:
2004-04-25  David Zeuthen  <david at fubar.dk>

	* doc/TODO: Add our notes about current issues with the Linux 2.6
	kernel

	* hald/linux/usbif_bus_device.c (usbif_device_accept): remove 
	is_probing

	* hald/linux/usb_bus_device.c (usb_device_accept): remove is_probing

	* hald/linux/printer_class_device.c (printer_class_device_accept): 
	remove is_probing

	* hald/linux/osspec.c (visit_class_device): optionally take and use
	a ClassDeviceHandler object
	(visit_class): -do-
	(visit_device): optionally take and use a BusDeviceHandler object
	(visit_bus): new function; not currently used
	(osspec_probe): add a comment about migration to visit_bus once the
	kernel is ready; slight changes

	* hald/linux/net_class_device.c (net_class_pre_process): set category
	and capabilities

	* hald/linux/ide_host_bus_device.c (ide_host_device_accept): remove
	is_probing

	* hald/linux/common.c (got_parent): new function

	* hald/linux/class_device.h: change prototypes by removing is_probing
	parameter

	* hald/linux/class_device.c don't pass is_probing; use 
	hald_is_initialising global instead

	* hald/linux/bus_device.h: change prototypes by removing is_probing
	parameter

	* hald/linux/bus_device.c: don't pass is_probing; use the global
	hald_is_initialising instead. Don't try to find parent if the sysfs
	path indicates that there is no parent.

	* hald/linux/block_class_device.c : don't pass is_probing; use 
	hald_is_initialising global



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/block_class_device.c	12 Apr 2004 20:11:51 -0000	1.14
+++ b/block_class_device.c	25 Apr 2004 17:24:44 -0000	1.15
@@ -73,8 +73,7 @@
 static void
 block_class_visit (ClassDeviceHandler *self,
 		   const char *path,
-		   struct sysfs_class_device *class_device,
-		   dbus_bool_t is_probing)
+		   struct sysfs_class_device *class_device)
 {
 	HalDevice *d;
 	char *parent_sysfs_path;
@@ -106,7 +105,7 @@
 	hal_device_property_set_string (d, ".target_dev", "block.device");
 
 	/* Ask udev about the device file if we are probing */
-	if (self->require_device_file && is_probing) {
+	if (self->require_device_file && hald_is_initialising) {
 		char dev_file[SYSFS_PATH_MAX];
 
 		if (!class_device_get_device_file (path, dev_file, 
@@ -132,7 +131,7 @@
 		"linux.sysfs_path_device",
 		parent_sysfs_path,
 		class_device_got_parent_device, ai,
-		is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+		HAL_LINUX_HOTPLUG_TIMEOUT);
 }
 
 

Index: bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/bus_device.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/bus_device.c	12 Apr 2004 20:11:51 -0000	1.5
+++ b/bus_device.c	25 Apr 2004 17:24:44 -0000	1.6
@@ -66,11 +66,10 @@
  *  @param  self                Pointer to class members
  *  @param  path                Sysfs-path for device
  *  @param  device              libsysfs object for device
- *  @param  is_probing          Set to TRUE only on initial detection
  */
 dbus_bool_t
 bus_device_accept (BusDeviceHandler *self, const char *path, 
-		   struct sysfs_device *device, dbus_bool_t is_probing)
+		   struct sysfs_device *device)
 {
 	/* only care about given bus name  */
 	return strcmp (device->bus, self->sysfs_bus_name) == 0;
@@ -84,11 +83,10 @@
  *  @param  self                Pointer to class members
  *  @param  path                Sysfs-path for device
  *  @param  device              libsysfs object for device
- *  @param  is_probing          Set to TRUE only on initial detection
  */
 void
 bus_device_visit (BusDeviceHandler *self, const char *path, 
-		  struct sysfs_device *device, dbus_bool_t is_probing)
+		  struct sysfs_device *device)
 {
 	AsyncInfo *ai;
 	HalDevice *d;
@@ -111,21 +109,27 @@
 
 	parent_sysfs_path = get_parent_sysfs_path (path);
 
-	/* Find parent; this happens asynchronously as our parent might
-	 * be added later. If we are probing this can't happen so the
-	 * timeout is set to zero in that event
-	 */
-
 	ai = g_new0 (AsyncInfo, 1);
 	ai->device = d;
 	ai->handler = self;
-		
-	hal_device_store_match_key_value_string_async (
-		hald_get_gdl (),
-		"linux.sysfs_path_device",
-		parent_sysfs_path,
-		bus_device_got_parent, ai,
-		is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+
+	if (!got_parent(path)) {
+		/* no need to find parent; we have none; just add directly 
+		 * with parent set to NULL 
+		 */
+		bus_device_got_parent (hald_get_gdl(), NULL, ai);
+	} else {
+		/* Find parent; this happens asynchronously as our parent might
+		 * be added later. If we are probing this can't happen so the
+		 * timeout is set to zero in that event
+		 */
+		hal_device_store_match_key_value_string_async (
+			hald_get_gdl (),
+			"linux.sysfs_path_device",
+			parent_sysfs_path,
+			bus_device_got_parent, ai,
+			HAL_LINUX_HOTPLUG_TIMEOUT);
+	}
 
 	free (parent_sysfs_path);
 }

Index: bus_device.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/bus_device.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/bus_device.h	12 Apr 2004 20:11:51 -0000	1.3
+++ b/bus_device.h	25 Apr 2004 17:24:44 -0000	1.4
@@ -66,14 +66,12 @@
 	 *                        the device in sysfs
 	 *  @param  device        Libsysfs object representing new device
 	 *                        instance
-	 *  @param  is_probing    Set to TRUE only on initial detection
 	 *  @return               Must return TRUE if this class should
 	 *                        process this device
 	 */
 	dbus_bool_t (*accept) (BusDeviceHandler *self,
 			       const char *sysfs_path,
-			       struct sysfs_device *device,
-			       dbus_bool_t is_probing);
+			       struct sysfs_device *device);
 
 	/** Called to process the new device instance has passed accept().
 	 *
@@ -88,12 +86,10 @@
 	 *                        the device in sysfs
 	 *  @param  device        Libsysfs object representing new device
 	 *                        instance
-	 *  @param  is_probing    Set to TRUE only on initial detection
 	 */
 	void (*visit) (BusDeviceHandler *self,
 		       const char *sysfs_path,
-		       struct sysfs_device *device,
-		       dbus_bool_t is_probing);
+		       struct sysfs_device *device);
 
 	/** Called when the class device instance have been removed
 	 *
@@ -160,11 +156,10 @@
 };
 
 dbus_bool_t bus_device_accept (BusDeviceHandler *self, const char *path, 
-			       struct sysfs_device *device, 
-			       dbus_bool_t is_probing);
+			       struct sysfs_device *device);
 
 void bus_device_visit (BusDeviceHandler *self, const char *path, 
-		       struct sysfs_device *device, dbus_bool_t is_probing);
+		       struct sysfs_device *device);
 
 void bus_device_detection_done (BusDeviceHandler *self);
 

Index: class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- a/class_device.c	22 Apr 2004 21:52:05 -0000	1.10
+++ b/class_device.c	25 Apr 2004 17:24:44 -0000	1.11
@@ -70,13 +70,11 @@
  *  @param  self                Pointer to class members
  *  @param  path                Sysfs-path for device
  *  @param  class_device        libsysfs object for class device
- *  @param  is_probing          Set to TRUE only on initial detection
  */
 dbus_bool_t
 class_device_accept (ClassDeviceHandler *self,
 		     const char *path,
-		     struct sysfs_class_device *class_device,
-		     dbus_bool_t is_probing)
+		     struct sysfs_class_device *class_device)
 {
 
 	/*HAL_INFO (("path = %s, classname = %s", 
@@ -98,13 +96,11 @@
  *  @param  self               Pointer to class members
  *  @param  path                Sysfs-path for class device
  *  @param  class_device        Libsysfs object for device
- *  @param  is_probing          Whether we are probing
  */
 void
 class_device_visit (ClassDeviceHandler *self,
 		    const char *path,
-		    struct sysfs_class_device *class_device,
-		    dbus_bool_t is_probing)
+		    struct sysfs_class_device *class_device)
 {
 	HalDevice *d;
 	char dev_file[SYSFS_PATH_MAX];
@@ -144,7 +140,7 @@
 						dev_file_prop_name);
 
 		/* Ask udev about the device file if we are probing */
-		if (is_probing) {
+		if (hald_is_initialising) {
 			if (!class_device_get_device_file (path, dev_file, 
 							   SYSFS_PATH_MAX)) {
 				HAL_WARNING (("Couldn't get device file for "
@@ -171,7 +167,7 @@
 			"linux.sysfs_path_device",
 			class_device->sysdevice->path,
 			class_device_got_sysdevice, ai,
-			is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+			HAL_LINUX_HOTPLUG_TIMEOUT);
 	} else {
 		char *parent_sysfs_path;
 		AsyncInfo *ai = g_new0 (AsyncInfo, 1);
@@ -188,7 +184,7 @@
 			"linux.sysfs_path_device",
 			parent_sysfs_path,
 			class_device_got_parent_device, ai,
-			is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+			HAL_LINUX_HOTPLUG_TIMEOUT);
 	}
 }
 
@@ -277,7 +273,7 @@
 			d, target_dev, 
 			class_device_got_device_file,
 			(gpointer) self,
-			is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+			HAL_LINUX_HOTPLUG_TIMEOUT);
 	} else {
 		class_device_final (self, d);
 	}
@@ -341,7 +337,7 @@
 			d, target_dev, 
 			class_device_got_device_file,
 			(gpointer) self,
-			is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
+			HAL_LINUX_HOTPLUG_TIMEOUT);
 	} else {
 		class_device_final (self, d);
 	}

Index: class_device.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/class_device.h	12 Apr 2004 20:11:51 -0000	1.5
+++ b/class_device.h	25 Apr 2004 17:24:44 -0000	1.6
@@ -66,14 +66,12 @@
 	 *                        the device in sysfs
 	 *  @param  class_device  Libsysfs object representing new class device
 	 *                        instance
-	 *  @param  is_probing    Set to TRUE only on initial detection
 	 *  @return               Must return TRUE if this class should
 	 *                        process this device
 	 */
 	dbus_bool_t (*accept) (ClassDeviceHandler *self,
 			       const char *sysfs_path,
-			       struct sysfs_class_device *class_device,
-			       dbus_bool_t is_probing);
+			       struct sysfs_class_device *class_device);
 
 	/** Called when a new instance of a class device is detected either
 	 *  through hotplug or through initial detection.
@@ -98,12 +96,10 @@
 	 *                        the class device in sysfs
 	 *  @param  class_device  Libsysfs object representing new class device
 	 *                        instance
-	 *  @param  is_probing    Set to TRUE only initial detection
 	 */
 	void (*visit) (ClassDeviceHandler* self,
 		       const char *sysfs_path,
-		       struct sysfs_class_device *class_device,
-		       dbus_bool_t is_probing);
+		       struct sysfs_class_device *class_device);
 
 	/** Called when the class device instance have been removed
 	 *
@@ -238,13 +234,11 @@
 
 dbus_bool_t class_device_accept (ClassDeviceHandler *self,
 				 const char *path,
-				 struct sysfs_class_device *class_device,
-				 dbus_bool_t is_probing);
+				 struct sysfs_class_device *class_device);
 
 void class_device_visit (ClassDeviceHandler *self,
 			 const char *path,
-			 struct sysfs_class_device *class_device,
-			 dbus_bool_t is_probing);
+			 struct sysfs_class_device *class_device);
 
 void class_device_removed (ClassDeviceHandler* self, 
 			   const char *sysfs_path, 

Index: common.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/common.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/common.c	21 Apr 2004 18:44:41 -0000	1.4
+++ b/common.c	25 Apr 2004 17:24:44 -0000	1.5
@@ -721,6 +721,33 @@
 	return NULL;
 }
 
+/** Check if a device got a parent by looking at the sysfs path
+ *
+ *  @param sysfs_path           Fully qualified path to into sysfs, e.g.
+ *                              /sys/devices/pci0001:01/0001:01:17
+ *  @return                     TRUE iff the device got a parent
+ */
+dbus_bool_t got_parent (const char *sysfs_path)
+{
+	char *parent_sysfs_path;
+	char *grandparent_sysfs_path;
+	char buf[256];
+	dbus_bool_t rc;
+
+	/** @todo Hmm, this implementation can be improved */
+
+	parent_sysfs_path = get_parent_sysfs_path (sysfs_path);
+
+	grandparent_sysfs_path = get_parent_sysfs_path (parent_sysfs_path);
+	snprintf (buf, sizeof(buf), "%s/devices", sysfs_mount_path);
+        rc = (strcmp (grandparent_sysfs_path, buf) != 0);
+
+	free (grandparent_sysfs_path);
+	free (parent_sysfs_path);
+
+	return rc;
+}
+
 /** Collect all drivers being used on a bus. This is only bandaid until
  *  sysutils fill in the driver_name in sysfs_device.
  *

Index: common.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- a/common.h	14 Mar 2004 17:09:35 -0000	1.1
+++ b/common.h	25 Apr 2004 17:24:44 -0000	1.2
@@ -92,7 +92,9 @@
  */
 #define HAL_LINUX_HOTPLUG_TIMEOUT 30000
 
-extern dbus_bool_t is_probing;
+dbus_bool_t got_parent (const char *sysfs_path);
+
+extern dbus_bool_t hald_is_initialising;
 
 extern char sysfs_mount_path[SYSFS_PATH_MAX];
 

Index: ide_host_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/ide_host_bus_device.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/ide_host_bus_device.c	12 Apr 2004 20:11:51 -0000	1.4
+++ b/ide_host_bus_device.c	25 Apr 2004 17:24:44 -0000	1.5
@@ -51,7 +51,7 @@
 
 static dbus_bool_t
 ide_host_device_accept (BusDeviceHandler *self, const char *path, 
-			struct sysfs_device *device, dbus_bool_t is_probing)
+			struct sysfs_device *device)
 {
 	int ide_host_number;
 

Index: net_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/net_class_device.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/net_class_device.c	12 Apr 2004 21:10:00 -0000	1.2
+++ b/net_class_device.c	25 Apr 2004 17:24:44 -0000	1.3
@@ -465,6 +465,10 @@
 
 	media = media_type_to_string (media_type);
 	hal_device_property_set_string (d, "net.media", media);
+
+	hal_device_add_capability (d, "net");
+	hal_device_add_capability (d, "net.ethernet");
+	hal_device_property_set_string (d, "info.category", "net.ethernet");
 }
 
 static void

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/osspec.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/osspec.c	22 Apr 2004 21:52:05 -0000	1.14
+++ b/osspec.c	25 Apr 2004 17:24:44 -0000	1.15
@@ -115,6 +115,8 @@
  *
  *  @param  path                Sysfs-path for class device, e.g.
  *                              /sys/class/scsi_host/host7
+ *  @param  handler             A ClassDeviceHandler object to use or NULL to
+ *                              try all handlers
  *  @param  visit_children      If children of this device should be visited
  *                              set this to #TRUE. For device-probing, this
  *                              should set be set to true so as to visit
@@ -123,11 +125,11 @@
  *                              generate a separate event.
  */
 static void
-visit_class_device (const char *path, dbus_bool_t visit_children)
+visit_class_device (const char *path, ClassDeviceHandler *handler,
+		    dbus_bool_t visit_children)
 {
 	int i;
 	struct sysfs_class_device *class_device;
-	struct sysfs_directory *subdir;
 
 	class_device = sysfs_open_class_device (path);
 	if (class_device == NULL) {
@@ -140,21 +142,28 @@
 		   class_device->classname,
 		   class_device->path));
 
-	for (i=0; class_device_handlers[i] != NULL; i++) {
-		ClassDeviceHandler *ch = class_device_handlers[i];
-		if (ch->accept (ch, path, class_device, is_probing))
-			ch->visit (ch, path, class_device, is_probing);
+	if (handler != NULL) {
+		if (handler->accept (handler, path, class_device))
+			handler->visit (handler, path, class_device);
+	} else {
+		for (i=0; class_device_handlers[i] != NULL; i++) {
+			ClassDeviceHandler *ch = class_device_handlers[i];
+			if (ch->accept (ch, path, class_device))
+				ch->visit (ch, path, class_device);
+		}
 	}
 
 	/* Visit children */
 	if (visit_children && class_device->directory != NULL &&
 	    class_device->directory->subdirs != NULL) {
+		struct sysfs_directory *subdir;
+
 		dlist_for_each_data (class_device->directory->subdirs,
 				     subdir, struct sysfs_directory) {
 			char newpath[SYSFS_PATH_MAX];
 			snprintf (newpath, SYSFS_PATH_MAX, "%s/%s", path,
 				  subdir->name);
-			visit_class_device (newpath, TRUE);
+			visit_class_device (newpath, handler, visit_children);
 		}
 	}
 
@@ -164,6 +173,8 @@
 /** Visit all devices of a given class
  *
  *  @param  class_name          Name of class, e.g. scsi_host or block
+ *  @param  handler             A ClassDeviceHandler object to use or NULL to
+ *                              try all handlers
  *  @param  visit_children      If children of this device should be visited
  *                              set this to #TRUE. For device-probing, this
  *                              should set be set to true so as to visit
@@ -172,7 +183,8 @@
  *                              generate a separate event.
  */
 static void
-visit_class (const char *class_name, dbus_bool_t visit_children)
+visit_class (const char *class_name, ClassDeviceHandler *handler,
+	     dbus_bool_t visit_children)
 {
 	struct sysfs_class *cls = NULL;
 	struct sysfs_class_device *cur = NULL;
@@ -186,7 +198,8 @@
 	if (cls->devices != NULL) {
 		dlist_for_each_data (cls->devices, cur,
 				     struct sysfs_class_device) {
-			visit_class_device (cur->path, visit_children);
+			visit_class_device (cur->path, handler,
+					    visit_children);
 		}
 	}
 
@@ -199,6 +212,8 @@
  *  appropriate visit_device_<bustype> function if matched.
  *
  *  @param  path                Sysfs-path for device
+ *  @param  handler             A BusDeviceHandler object to use or NULL to try
+ *                              all handlers
  *  @param  visit_children      If children of this device should be visited
  *                              set this to #TRUE. For device-probing, this
  *                              should set be set to true so as to visit
@@ -207,11 +222,10 @@
  *                              generate a separate event.
  */
 static void
-visit_device (const char *path, dbus_bool_t visit_children)
+visit_device (const char *path, BusDeviceHandler *handler, 
+	      dbus_bool_t visit_children)
 {
-	int i;
 	struct sysfs_device *device;
-	struct sysfs_directory *subdir;
 
 	device = sysfs_open_device (path);
 	if (device == NULL) {
@@ -224,20 +238,28 @@
 
 	/*HAL_INFO ((" path=%s", path));*/
 
-	for (i=0; bus_device_handlers[i] != NULL; i++) {
-		BusDeviceHandler *bh = bus_device_handlers[i];
-		if (bh->accept (bh, path, device, is_probing))
-			bh->visit (bh, path, device, is_probing);
+	if (handler != NULL ) {
+		if (handler->accept (handler, path, device))
+			handler->visit (handler, path, device);
+	} else {
+		int i;
+		for (i=0; bus_device_handlers[i] != NULL; i++) {
+			BusDeviceHandler *bh = bus_device_handlers[i];
+			if (bh->accept (bh, path, device))
+				bh->visit (bh, path, device);
+		}
 	}
 
 	/* Visit children */
 	if (visit_children && device->directory->subdirs != NULL) {
+		struct sysfs_directory *subdir;
+	
 		dlist_for_each_data (device->directory->subdirs, subdir,
 				     struct sysfs_directory) {
 			char newpath[SYSFS_PATH_MAX];
 			snprintf (newpath, SYSFS_PATH_MAX, "%s/%s", path,
 				  subdir->name);
-			visit_device (newpath, TRUE);
+			visit_device (newpath, handler, visit_children);
 		}
 	}
 
@@ -245,6 +267,35 @@
 }
 
 
+/** Visit all devices on a given bus
+ *
+ *  @param  class_name          Name of class, e.g. scsi_host or block
+ *  @param  handler             A BusDeviceHandler object to use or NULL to try
+ *                              all handlers
+ */
+static void
+visit_bus (const char *bus_name, BusDeviceHandler *handler)
+{
+	struct sysfs_bus *bus = NULL;
+	struct sysfs_device *cur = NULL;
+
+	bus = sysfs_open_bus (bus_name);
+	if (bus == NULL) {
+		HAL_ERROR (("Error opening bus %s\n", bus_name));
+		return;
+	}
+
+	if (bus->devices != NULL) {
+		dlist_for_each_data (bus->devices, cur,
+				     struct sysfs_device) {
+			visit_device (cur->path, handler, FALSE);
+		}
+	}
+
+	sysfs_close_bus (bus);
+}
+
+
 /** Timeout handler for polling
  *
  *  @param  data                User data when setting up timer
@@ -310,45 +361,57 @@
 }
 
 /** This is set to #TRUE if we are probing and #FALSE otherwise */
-dbus_bool_t is_probing;
+dbus_bool_t hald_is_initialising;
 
 /* This function is documented in ../osspec.h */
 void
 osspec_probe ()
 {
 	int i;
-	char path[SYSFS_PATH_MAX];
-	struct sysfs_directory *current;
-	struct sysfs_directory *dir;
 
-	is_probing = TRUE;
+	hald_is_initialising = TRUE;
 
-	/* traverse /sys/devices */
-	strncpy (path, sysfs_mount_path, SYSFS_PATH_MAX);
-	strncat (path, SYSFS_DEVICES_DIR, SYSFS_PATH_MAX);
+	/** @todo When the kernel has all devices in /sys/devices
+	 *        under either /sys/bus or /sys/class then we can
+	 *        have code like this
 
-	dir = sysfs_open_directory (path);
-	if (dir == NULL) {
-		DIE (("Error opening sysfs directory at %s\n", path));
-	}
-	if (sysfs_read_directory (dir) != 0) {
-		DIE (("Error reading sysfs directory at %s\n", path));
+	for (i=0; bus_device_handlers[i] != NULL; i++) {
+		BusDeviceHandler *bh = bus_device_handlers[i];
+		visit_bus (bh->sysfs_bus_name, bh);
 	}
-	if (dir->subdirs != NULL) {
-		dlist_for_each_data (dir->subdirs, current,
-				     struct sysfs_directory) {
-			visit_device (current->path, TRUE);
+	*/
+
+	{
+		char path[SYSFS_PATH_MAX];
+		struct sysfs_directory *current;
+		struct sysfs_directory *dir;
+
+		/* traverse /sys/devices */
+		strncpy (path, sysfs_mount_path, SYSFS_PATH_MAX);
+		strncat (path, SYSFS_DEVICES_DIR, SYSFS_PATH_MAX);
+
+		dir = sysfs_open_directory (path);
+		if (dir == NULL) {
+			DIE (("Error opening sysfs directory at %s\n", path));
+		}
+		if (sysfs_read_directory (dir) != 0) {
+			DIE (("Error reading sysfs directory at %s\n", path));
+		}
+		if (dir->subdirs != NULL) {
+			dlist_for_each_data (dir->subdirs, current,
+					     struct sysfs_directory) {
+				visit_device (current->path, NULL, TRUE);
+			}
 		}
+		sysfs_close_directory (dir);
 	}
-	sysfs_close_directory (dir);
 
 	for (i=0; class_device_handlers[i] != NULL; i++) {
 		ClassDeviceHandler *ch = class_device_handlers[i];
-		visit_class (ch->sysfs_class_name, TRUE);
-		/** @todo FIXME how to select TRUE/FALSE above (see below) */
+		visit_class (ch->sysfs_class_name, ch, TRUE);
 	}
 
-	is_probing = FALSE;
+	hald_is_initialising = FALSE;
 
 	/* Notify various device and class types that detection is done, so 
 	 * they can do some (optional) batch processing
@@ -505,15 +568,18 @@
 	    strncmp (sysfs_devpath_wo_mp, "/class", 6)==0 ) {
 		/* handle class devices */
 		if (is_add)
-			visit_class_device (sysfs_devpath, FALSE);
+			/* dunno what handler to use; try all */
+			visit_class_device (sysfs_devpath, NULL, FALSE);
 		else
 			remove_class_device (sysfs_devpath, subsystem);
 	} else {
 		/* handle bus devices */
-		if (is_add)
-			visit_device (sysfs_devpath, FALSE);
-		else
+		if (is_add) {
+			/* dunno what handler to use; try all */
+			visit_device (sysfs_devpath, NULL, FALSE);
+		} else {
 			remove_device (sysfs_devpath, subsystem);
+		}
 	}
 		
 

Index: printer_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/printer_class_device.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/printer_class_device.c	12 Apr 2004 20:11:51 -0000	1.5
+++ b/printer_class_device.c	25 Apr 2004 17:24:44 -0000	1.6
@@ -63,8 +63,7 @@
 static dbus_bool_t
 printer_class_device_accept (ClassDeviceHandler *self,
 			     const char *path,
-			     struct sysfs_class_device *class_device,
-			     dbus_bool_t is_probing)
+			     struct sysfs_class_device *class_device)
 {
 	int lp_number;
 

Index: usb_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/usb_bus_device.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/usb_bus_device.c	22 Apr 2004 21:52:06 -0000	1.8
+++ b/usb_bus_device.c	25 Apr 2004 17:24:44 -0000	1.9
@@ -573,11 +573,10 @@
  *  @param  self                Pointer to class members
  *  @param  path                Sysfs-path for device
  *  @param  device              libsysfs object for device
- *  @param  is_probing          Set to TRUE only on initial detection
  */
 static dbus_bool_t
 usb_device_accept (BusDeviceHandler *self, const char *path, 
-		   struct sysfs_device *device, dbus_bool_t is_probing)
+		   struct sysfs_device *device)
 {
 	unsigned int i;
 

Index: usbif_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/usbif_bus_device.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/usbif_bus_device.c	21 Apr 2004 18:44:41 -0000	1.5
+++ b/usbif_bus_device.c	25 Apr 2004 17:24:44 -0000	1.6
@@ -54,11 +54,10 @@
  *  @param  self                Pointer to class members
  *  @param  path                Sysfs-path for device
  *  @param  device              libsysfs object for device
- *  @param  is_probing          Set to TRUE only on initial detection
  */
 static dbus_bool_t
 usbif_device_accept (BusDeviceHandler *self, const char *path, 
-		     struct sysfs_device *device, dbus_bool_t is_probing)
+		     struct sysfs_device *device)
 {
 	unsigned int i;
 





More information about the hal-commit mailing list