hal/hald/linux block_class_device.c, 1.64, 1.65 bus_device.c, 1.18,
1.19 bus_device.h, 1.8, 1.9 class_device.c, 1.27,
1.28 osspec.c, 1.37, 1.38
David Zeuthen
david at freedesktop.org
Sat Aug 28 06:35:50 PDT 2004
Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv23927/hald/linux
Modified Files:
block_class_device.c bus_device.c bus_device.h class_device.c
osspec.c
Log Message:
2004-08-28 David Zeuthen <david at fubar.dk>
* hald/linux/block_class_device.c:
(block_class_visit): Fail if parent isn't already there (this and
other things should close RH Bug #131154)
* hald/linux/bus_device.c:
(bus_device_visit): Fail if parent isn't already there
* hald/linux/class_device.c:
(class_device_visit): Fail if parent isn't already there; return
NULL if we merge onto parent. Leave TODO about how to deal with
this (other devices will be processed while we merge; probably
not a big deal since we don't yet have callouts)
(class_device_final): Add a TODO about running callouts when merge
is complete
* hald/linux/osspec.c:
(process_coldplug_list_callouts_done_for_device): Also discon. cancelled
(process_coldplug_list_device_cancelled): Also discon. done_for_device
(process_coldplug_list): Pass coldplug_list as param to cancelled
(reenable_hotplug_proc_on_device_cancel): Also disconnect _proc
(reenable_hotplug_proc): Also disconnect _cancel
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- block_class_device.c 28 Aug 2004 11:18:34 -0000 1.64
+++ block_class_device.c 28 Aug 2004 13:35:47 -0000 1.65
@@ -174,6 +174,7 @@
struct sysfs_class_device *class_device)
{
HalDevice *d;
+ HalDevice *parent;
char *parent_sysfs_path;
ClassAsyncData *cad;
struct sysfs_device *sysdevice;
@@ -224,34 +225,27 @@
self->udev_event (self, d, dev_file);
}
- /* Now find the parent device; this happens asynchronously as it
- * might be added later. */
cad = g_new0 (ClassAsyncData, 1);
cad->device = d;
cad->handler = self;
- hal_device_store_match_key_value_string_async (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path,
- class_device_got_parent_device, cad,
- HAL_LINUX_HOTPLUG_TIMEOUT);
+ /* Find parent; this can happen synchronously as our parent is
+ * sure to be added before us (we probe devices in the right order
+ * and we reorder hotplug events)
+ */
+ parent = hal_device_store_match_key_value_string (hald_get_gdl (),
+ "linux.sysfs_path_device",
+ parent_sysfs_path);
+ if (parent == NULL) {
+ hal_device_store_remove (hald_get_tdl (), d);
+ d = NULL;
+ goto out;
+ }
- /*hal_device_print (d);*/
+ class_device_got_parent_device (hald_get_tdl (), parent, cad);
- /* Now that a) hotplug happens in the right order; and b) the device
- * from a hotplug event is completely added to the GDL before the
- * next event is processed; the aysnc call above is actually
- * synchronous so we can test immediately whether we want to
- * proceed
- */
- if (hal_device_store_match_key_value_string (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path) == NULL)
- return NULL;
- else
- return d;
+out:
+ return d;
}
Index: bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/bus_device.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- bus_device.c 22 Aug 2004 19:27:22 -0000 1.18
+++ bus_device.c 28 Aug 2004 13:35:47 -0000 1.19
@@ -53,8 +53,7 @@
*/
/* fwd decl */
-static void bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
- gpointer user_data);
+static void bus_device_got_parent (HalDeviceStore *store, HalDevice *parent, gpointer user_data);
/** Generic accept function that accepts the device if and only if
* the bus name from sysfs equals the bus name in the class
@@ -64,8 +63,7 @@
* @param device libsysfs object for device
*/
dbus_bool_t
-bus_device_accept (BusDeviceHandler *self, const char *path,
- struct sysfs_device *device)
+bus_device_accept (BusDeviceHandler *self, const char *path, struct sysfs_device *device)
{
/* only care about given bus name */
return strcmp (device->bus, self->sysfs_bus_name) == 0;
@@ -87,9 +85,10 @@
bus_device_visit (BusDeviceHandler *self, const char *path,
struct sysfs_device *device)
{
- BusAsyncData *bad;
HalDevice *d;
+ HalDevice *parent;
char *parent_sysfs_path;
+ BusAsyncData *bad;
char buf[256];
/* Construct a new device and add to temporary device list */
@@ -119,40 +118,25 @@
* with parent set to NULL
*/
bus_device_got_parent (hald_get_gdl(), NULL, bad);
- } 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, bad,
- 0/*HAL_LINUX_HOTPLUG_TIMEOUT*/);
- }
+ goto out;
+ }
- /* Now that a) hotplug happens in the right order; and b) the device
- * from a hotplug event is completely added to the GDL before the
- * next event is processed; the aysnc call above is actually
- * synchronous so we can test immediately whether we want to
- * proceed
+ /* Find parent; this can happen synchronously as our parent is
+ * sure to be added before us (we probe devices in the right order
+ * and we reorder hotplug events)
*/
-
- /*
- if (hal_device_store_match_key_value_string (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path) == NULL) {
-
- free (parent_sysfs_path);
- return NULL;
- } else {
- free (parent_sysfs_path);
- return d;
+ parent = hal_device_store_match_key_value_string (hald_get_gdl (),
+ "linux.sysfs_path_device",
+ parent_sysfs_path);
+ if (parent == NULL) {
+ hal_device_store_remove (hald_get_tdl (), d);
+ d = NULL;
+ goto out;
}
- */
+ bus_device_got_parent (hald_get_gdl(), parent, bad);
+
+out:
free (parent_sysfs_path);
return d;
}
@@ -196,8 +180,7 @@
* @param user_data User data from find call
*/
static void
-bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
- gpointer user_data)
+bus_device_got_parent (HalDeviceStore *store, HalDevice *parent, gpointer user_data)
{
const char *sysfs_path = NULL;
char *new_udi = NULL;
Index: bus_device.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/bus_device.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- bus_device.h 15 Aug 2004 18:54:57 -0000 1.8
+++ bus_device.h 28 Aug 2004 13:35:47 -0000 1.9
@@ -190,11 +190,11 @@
HalDevice *d,
const char *udi);
-/* Convenience structure for passing around multiple pieces of data to
- the got_parent_device() functions */
+/* Convenience structure for passing around multiple pieces of data to asynchronous functions */
typedef struct {
- HalDevice *device;
- BusDeviceHandler *handler;
+ HalDevice *device;
+ BusDeviceHandler *handler;
} BusAsyncData;
+
#endif /* BUS_DEVICE_H */
Index: class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- class_device.c 25 Aug 2004 20:55:13 -0000 1.27
+++ class_device.c 28 Aug 2004 13:35:47 -0000 1.28
@@ -106,6 +106,7 @@
{
ClassAsyncData *cad;
HalDevice *d;
+ HalDevice *hal_target;
char dev_file[SYSFS_PATH_MAX];
char dev_file_prop_name[SYSFS_PATH_MAX];
gboolean merge_or_add;
@@ -133,11 +134,9 @@
* we want the bus to just be "unknown"
*/
if (!self->merge_or_add) {
- hal_device_property_set_string (d, "info.bus",
- self->hal_class_name);
+ hal_device_property_set_string (d, "info.bus", self->hal_class_name);
} else {
- hal_device_property_set_string (d, "info.bus",
- "unknown");
+ hal_device_property_set_string (d, "info.bus", "unknown");
}
hal_device_property_set_string (d, "linux.sysfs_path", path);
@@ -153,33 +152,25 @@
if (self->require_device_file) {
/* Find the property name we should store the device file in */
- self->get_device_file_target (self, d, path, class_device,
- dev_file_prop_name,
- SYSFS_PATH_MAX);
+ self->get_device_file_target (self, d, path, class_device, dev_file_prop_name, SYSFS_PATH_MAX);
/* Temporary property used for _udev_event() */
- hal_device_property_set_string (d, ".target_dev",
- dev_file_prop_name);
+ hal_device_property_set_string (d, ".target_dev", dev_file_prop_name);
}
- hal_device_property_set_string (
- d, ".udev.class_name", self->sysfs_class_name);
- hal_device_property_set_string (
- d, ".udev.sysfs_path", path);
+ hal_device_property_set_string (d, ".udev.class_name", self->sysfs_class_name);
+ hal_device_property_set_string (d, ".udev.sysfs_path", path);
if (self->require_device_file) {
/* Ask udev about the device file if we are 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 "
- "sysfs path %s", path));
- return NULL;
+ if (!class_device_get_device_file (path, dev_file, SYSFS_PATH_MAX)) {
+ HAL_WARNING (("Couldn't get device file for sysfs path %s", path));
+ goto error;
}
- /* If we are not probing this function will be called
- * upon receiving a dbus event */
+ /* If we are not probing this function will be called upon receiving a dbus event */
self->udev_event (self, d, dev_file);
}
}
@@ -189,56 +180,49 @@
cad->handler = self;
cad->merge_or_add = merge_or_add;
- /* Now find the physical device; this happens asynchronously as it
- * might be added later. */
+ /* Find target (to either merge to or be child of); this can
+ * happen synchronously as our parent is sure to be added
+ * before us (we probe devices in the right order and we
+ * reorder hotplug events)
+ */
if (merge_or_add) {
what_to_find = sysdevice->path;
- /* find the sysdevice */
- hal_device_store_match_key_value_string_async (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- what_to_find,
- class_device_got_sysdevice, cad,
- HAL_LINUX_HOTPLUG_TIMEOUT);
+ /* find the sysdevice we should merge to */
+ hal_target = hal_device_store_match_key_value_string (hald_get_gdl (),
+ "linux.sysfs_path_device",
+ what_to_find);
+ if (hal_target == NULL)
+ goto error;
+
+ class_device_got_sysdevice (hald_get_gdl (), hal_target, cad);
+
+ /* return NULL as we are merging onto a device; TODO: maybe should return device we merge onto? */
+ return NULL;
} else {
if (sysdevice != NULL) {
what_to_find = get_parent_sysfs_path (sysdevice->path);
} else {
- what_to_find = "(none)";
+ what_to_find = "(none)"; /* DZE: Yikes, hack to get added as a child to 'computer'? */
}
- /* find the sysdevice */
- hal_device_store_match_key_value_string_async (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- what_to_find,
- class_device_got_parent_device, cad,
- HAL_LINUX_HOTPLUG_TIMEOUT);
- }
+ /* find the sysdevice we should be a child of */
+ hal_target = hal_device_store_match_key_value_string (hald_get_gdl (),
+ "linux.sysfs_path_device",
+ what_to_find);
+ if (hal_target == NULL)
+ goto error;
+ class_device_got_parent_device (hald_get_gdl(), hal_target, cad);
+ }
- if (!merge_or_add) {
- /* Now that a) hotplug happens in the right order; and b) the device
- * from a hotplug event is completely added to the GDL before the
- * next event is processed; the aysnc call above is actually
- * synchronous so we can test immediately whether we want to
- * proceed
- */
- /*
- if (hal_device_store_match_key_value_string (
- hald_get_gdl (),
- "linux.sysfs_path_device",
- what_to_find) == NULL)
- return NULL;
- else
- return d;
- */
- return d;
+ return d;
- } else
- return NULL;
+error:
+ HAL_INFO (("erroring on %s", path));
+ hal_device_store_remove (hald_get_tdl (), d);
+ return NULL;
}
/** Called when the class device instance have been removed
@@ -497,10 +481,13 @@
hal_device_get_udi (d),
hal_device_get_udi (sysdevice)));
+ self->post_merge (self, sysdevice);
+
+ /* @todo : run capability callouts on new device */
+
/* get rid of temporary device */
hal_device_store_remove (hald_get_tdl (), d);
- self->post_merge (self, sysdevice);
} else {
char *new_udi;
HalDevice *new_d;
Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/osspec.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- osspec.c 26 Aug 2004 22:16:17 -0000 1.37
+++ osspec.c 28 Aug 2004 13:35:47 -0000 1.38
@@ -705,12 +705,15 @@
static void process_coldplug_list (GSList *coldplug_list);
+static void process_coldplug_list_device_cancelled (HalDevice *device, gpointer user_data);
+
static void
process_coldplug_list_callouts_done_for_device (HalDevice *device, gpointer user_data)
{
GSList *coldplug_list = user_data;
g_signal_handlers_disconnect_by_func (device, process_coldplug_list_callouts_done_for_device, user_data);
+ g_signal_handlers_disconnect_by_func (device, process_coldplug_list_device_cancelled, user_data);
process_coldplug_list (coldplug_list);
}
@@ -720,6 +723,7 @@
{
GSList *coldplug_list = user_data;
+ g_signal_handlers_disconnect_by_func (device, process_coldplug_list_callouts_done_for_device, user_data);
g_signal_handlers_disconnect_by_func (device, process_coldplug_list_device_cancelled, user_data);
process_coldplug_list (coldplug_list);
@@ -750,7 +754,7 @@
g_signal_connect (device, "callouts_finished",
G_CALLBACK (process_coldplug_list_callouts_done_for_device), coldplug_list);
g_signal_connect (device, "cancelled",
- G_CALLBACK (process_coldplug_list_device_cancelled), NULL);
+ G_CALLBACK (process_coldplug_list_device_cancelled), coldplug_list);
} else {
process_coldplug_list (coldplug_list);
}
@@ -856,8 +860,9 @@
if (strcmp (ch->sysfs_class_name, subsystem) == 0) {
if (ch->accept (ch, sysfs_path, class_device)) {
hal_device = ch->visit (ch, sysfs_path, class_device);
- if (hal_device != NULL)
+ if (hal_device != NULL) {
break;
+ }
}
}
sysfs_close_class_device (class_device);
@@ -1090,16 +1095,20 @@
process_shutdown_list (shutdown_list);
}
+static void reenable_hotplug_proc (HalDevice *d, gpointer user_data);
+
static void
reenable_hotplug_proc_on_device_cancel (HalDevice *d, gpointer user_data)
{
g_signal_handlers_disconnect_by_func (d, reenable_hotplug_proc_on_device_cancel, user_data);
+ g_signal_handlers_disconnect_by_func (d, reenable_hotplug_proc, user_data);
hotplug_sem_down ();
}
static void
reenable_hotplug_proc (HalDevice *d, gpointer user_data)
{
+ g_signal_handlers_disconnect_by_func (d, reenable_hotplug_proc_on_device_cancel, user_data);
g_signal_handlers_disconnect_by_func (d, reenable_hotplug_proc, user_data);
hotplug_sem_down ();
}
More information about the hal-commit
mailing list