summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <david@fubar.dk>2004-04-03 07:27:50 +0000
committerDavid Zeuthen <david@fubar.dk>2004-04-03 07:27:50 +0000
commit817d5d3334b274166b75cfc9dd0ce04fb3a84b41 (patch)
treef4a03e9e135b44f491ebec0fc1c3ecc7aec3d3f4
parent03550b529ddbb1144d7ee94f163a7cc692b7a89d (diff)
Various cleanupshal-gobject-branch
Various cleanups Various cleanups New method
-rw-r--r--ChangeLog10
-rw-r--r--hald/device.c85
-rw-r--r--hald/device.h10
-rw-r--r--hald/device_info.c2
-rw-r--r--hald/linux/block_class_device.c80
-rw-r--r--hald/linux/bus_device.c55
-rw-r--r--hald/linux/class_device.c268
-rw-r--r--hald/linux/class_device.h10
-rw-r--r--hald/linux/common.c5
-rw-r--r--hald/linux/ide_bus_device.c2
-rw-r--r--hald/linux/osspec.c2
-rw-r--r--hald/linux/usb_bus_device.c9
12 files changed, 239 insertions, 299 deletions
diff --git a/ChangeLog b/ChangeLog
index b847707a..22475add 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-04-03 David Zeuthen <david@fubar.dk>
+
+ * hald/linux/bus_device.c: Various cleanups
+
+ * hald/linux/class_device.c: Various cleanups
+
+ * hald/linux/block_class_device.c: Various cleanups
+
+ * hald/device.c (hal_device_async_wait_property): New method
+
2004-04-02 David Zeuthen <david@fubar.dk>
* hald/linux/osspec.c (handle_hotplug): Actually remove class devices
diff --git a/hald/device.c b/hald/device.c
index 0f6a7cc4..62b04fd3 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -678,3 +678,88 @@ hal_device_print (HalDevice *device)
}
printf ("\n");
}
+
+
+typedef struct {
+ char *key;
+ HalDevice *device;
+ HalDeviceAsyncCallback callback;
+ gpointer user_data;
+
+ guint prop_signal_id;
+ guint timeout_id;
+} AsyncMatchInfo;
+
+static void
+destroy_async_match_info (AsyncMatchInfo *ai)
+{
+ g_free (ai->key);
+ g_signal_handler_disconnect (ai->device, ai->prop_signal_id);
+ g_source_remove (ai->timeout_id);
+ g_free (ai);
+}
+
+static void
+prop_changed_cb (HalDevice *device, const char *key,
+ gboolean removed, gboolean added, gpointer user_data)
+{
+ AsyncMatchInfo *ai = user_data;
+
+ if (strcmp (key, ai->key) != 0)
+ return;
+
+ /* the property is no longer there */
+ if (removed)
+ goto cleanup;
+
+
+ ai->callback (ai->device, ai->user_data, TRUE);
+
+cleanup:
+ destroy_async_match_info (ai);
+}
+
+
+static gboolean
+async_wait_timeout (gpointer user_data)
+{
+ AsyncMatchInfo *ai = (AsyncMatchInfo *) user_data;
+
+ ai->callback (ai->device, ai->user_data, FALSE);
+
+ destroy_async_match_info (ai);
+
+ return FALSE;
+}
+
+void
+hal_device_async_wait_property (HalDevice *device,
+ const char *key,
+ HalDeviceAsyncCallback callback,
+ gpointer user_data,
+ int timeout)
+{
+ HalProperty *prop;
+ AsyncMatchInfo *ai;
+
+ /* check if property already exists */
+ prop = hal_device_property_find (device, key);
+
+ if (prop != NULL || timeout==0) {
+ callback (device, user_data, prop != NULL);
+ return;
+ }
+
+ ai = g_new0 (AsyncMatchInfo, 1);
+
+ ai->device = device;
+ ai->key = g_strdup (key);
+ ai->callback = callback;
+ ai->user_data = user_data;
+
+ ai->prop_signal_id = g_signal_connect (device, "property_changed",
+ G_CALLBACK (prop_changed_cb),
+ ai);
+
+ ai->timeout_id = g_timeout_add (timeout, async_wait_timeout, ai);
+}
diff --git a/hald/device.h b/hald/device.h
index d951a686..62d079e8 100644
--- a/hald/device.h
+++ b/hald/device.h
@@ -66,6 +66,10 @@ struct _HalDeviceClass {
#define HAL_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
HAL_TYPE_DEVICE))
+typedef void (*HalDeviceAsyncCallback) (HalDevice *device,
+ gpointer user_data,
+ gboolean prop_exists);
+
/* Return value of FALSE means that the foreach should be short-circuited */
typedef gboolean (*HalDevicePropertyForeachFn) (HalDevice *device,
HalProperty *property,
@@ -129,4 +133,10 @@ gboolean hal_device_property_remove (HalDevice *device,
void hal_device_print (HalDevice *device);
+void hal_device_async_wait_property (HalDevice *device,
+ const char *key,
+ HalDeviceAsyncCallback callback,
+ gpointer user_data,
+ int timeout);
+
#endif /* DEVICE_H */
diff --git a/hald/device_info.c b/hald/device_info.c
index 9bb1c55e..59eb8092 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -280,8 +280,6 @@ parsing_abort (ParsingContext * pc)
static void
start (ParsingContext * pc, const char *el, const char **attr)
{
- int i;
-
if (pc->aborted)
return;
diff --git a/hald/linux/block_class_device.c b/hald/linux/block_class_device.c
index e4999e85..2ef79404 100644
--- a/hald/linux/block_class_device.c
+++ b/hald/linux/block_class_device.c
@@ -27,6 +27,8 @@
# include <config.h>
#endif
+#define _GNU_SOURCE 1
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,27 +39,25 @@
#include <stdarg.h>
#include <limits.h>
#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <signal.h>
-
-#include "../logger.h"
-#include "../device_store.h"
+#include <linux/kdev_t.h>
+#include <linux/cdrom.h>
+#include <linux/fs.h>
+#include <glib.h>
+
#include "../hald.h"
#include "../hald_dbus.h"
-
+#include "../logger.h"
+#include "../device_store.h"
#include "class_device.h"
#include "common.h"
-
+
#include "linux_dvd_rw_utils.h"
-#define _GNU_SOURCE 1
-#include <linux/fcntl.h>
-#include <linux/kdev_t.h>
-#include <linux/cdrom.h>
-#include <linux/fs.h>
-
/**
* @defgroup HalDaemonLinuxBlock Block device class
* @ingroup HalDaemonLinux
@@ -71,17 +71,6 @@ typedef struct {
} AsyncInfo;
static void
-got_parent_device_cb (HalDeviceStore *store, HalDevice *parent,
- gpointer user_data)
-{
- AsyncInfo *ai = user_data;
-
- class_device_got_parent_device (parent, ai->device, ai->handler);
-
- g_free (ai);
-}
-
-static void
block_class_visit (ClassDeviceHandler *self,
const char *path,
struct sysfs_class_device *class_device,
@@ -89,6 +78,7 @@ block_class_visit (ClassDeviceHandler *self,
{
HalDevice *d;
char *parent_sysfs_path;
+ AsyncInfo *ai;
/* only care about given sysfs class name */
if (strcmp (class_device->classname, "block") != 0)
@@ -133,33 +123,16 @@ block_class_visit (ClassDeviceHandler *self,
/* Now find the parent device; this happens asynchronously as it
* might be added later. */
-#if 0
- ds_device_async_find_by_key_value_string
- ("linux.sysfs_path_device",
- parent_sysfs_path,
- TRUE, class_device_got_parent_device,
- (void *) d, (void *) self,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#elif 0
- class_device_got_parent_device (
- hal_device_store_match_key_value_string (hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path),
- d, self);
-#else
- {
- AsyncInfo *ai = g_new0 (AsyncInfo, 1);
- ai->device = d;
- ai->handler = self;
+ 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,
- got_parent_device_cb, ai,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
- }
-#endif
+ hal_device_store_match_key_value_string_async (
+ hald_get_gdl (),
+ "linux.sysfs_path_device",
+ parent_sysfs_path,
+ class_device_got_parent_device, ai,
+ is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
}
@@ -1188,15 +1161,6 @@ sigio_handler (int sig)
sigio_etc_changed = TRUE;
}
-/** Init function for block device handling
- *
- */
-void
-linux_class_block_init ()
-{
-}
-
-
static void
block_class_removed (ClassDeviceHandler* self,
diff --git a/hald/linux/bus_device.c b/hald/linux/bus_device.c
index 701f66a2..317c6c7b 100644
--- a/hald/linux/bus_device.c
+++ b/hald/linux/bus_device.c
@@ -76,7 +76,7 @@ bus_device_accept (BusDeviceHandler *self, const char *path,
return strcmp (device->bus, self->sysfs_bus_name) == 0;
}
-/** Visitor function for PCI device.
+/** Visitor function for a bus device.
*
* This function parses the attributes present and creates a new HAL
* device based on this information.
@@ -90,16 +90,11 @@ void
bus_device_visit (BusDeviceHandler *self, const char *path,
struct sysfs_device *device, dbus_bool_t is_probing)
{
+ AsyncInfo *ai;
HalDevice *d;
char *parent_sysfs_path;
char buf[256];
- /* only care about given bus name */
-/*
- if (strcmp (device->bus, self->sysfs_bus_name) != 0)
- return;
-*/
-
/* Construct a new device and add to temporary device list */
d = hal_device_new ();
hal_device_store_add (hald_get_tdl (), d);
@@ -120,32 +115,17 @@ bus_device_visit (BusDeviceHandler *self, const char *path,
* be added later. If we are probing this can't happen so the
* timeout is set to zero in that event
*/
-#if 0
- ds_device_async_find_by_key_value_string
- ("linux.sysfs_path_device", parent_sysfs_path, TRUE,
- bus_device_got_parent,
- (void *) d, (void*) self,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#elif 0
- bus_device_got_parent (
- hal_device_store_match_key_value_string (hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path),
- d, self);
-#else
- {
- AsyncInfo *ai = g_new0 (AsyncInfo, 1);
- ai->device = d;
- ai->handler = self;
+
+ 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);
- }
-#endif
+ 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);
free (parent_sysfs_path);
}
@@ -153,9 +133,9 @@ bus_device_visit (BusDeviceHandler *self, const char *path,
/** Callback when the parent is found or if there is no parent.. This is
* where we get added to the GDL..
*
+ * @param store Device store we searched
* @param parent Async Return value from the find call
- * @param data1 User data
- * @param data2 User data
+ * @param user_data User data from find call
*/
static void
bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
@@ -171,7 +151,7 @@ bus_device_got_parent (HalDeviceStore *store, HalDevice *parent,
g_free (ai);
- /* set parent, if applicable */
+ /* set parent, if any */
if (parent != NULL) {
hal_device_property_set_string (d, "info.parent", parent->udi);
}
@@ -230,7 +210,7 @@ bus_device_shutdown (BusDeviceHandler *self)
/** Called regulary (every two seconds) for polling / monitoring on devices
- * of this bus type. Empty
+ * of this bus type. 
*
* @param self Pointer to class members
*/
@@ -248,8 +228,7 @@ bus_device_tick (BusDeviceHandler *self)
* this device
*/
void
-bus_device_removed (BusDeviceHandler *self,
- const char *sysfs_path,
+bus_device_removed (BusDeviceHandler *self, const char *sysfs_path,
HalDevice *d)
{
}
diff --git a/hald/linux/class_device.c b/hald/linux/class_device.c
index 41d863e3..4d051c23 100644
--- a/hald/linux/class_device.c
+++ b/hald/linux/class_device.c
@@ -37,8 +37,6 @@
#include <stdarg.h>
#include <limits.h>
-#include <linux/input.h> /* for EV_* etc. */
-
#include "../logger.h"
#include "../device_store.h"
#include "../hald.h"
@@ -59,26 +57,8 @@ typedef struct {
} AsyncInfo;
static void
-got_sysdevice_cb (HalDeviceStore *store, HalDevice *device,
- gpointer user_data)
-{
- AsyncInfo *ai = user_data;
-
- class_device_got_sysdevice (device, ai->device, ai->handler);
-
- g_free (ai);
-}
-
-static void
-got_parent_cb (HalDeviceStore *store, HalDevice *device,
- gpointer user_data)
-{
- AsyncInfo *ai = user_data;
-
- class_device_got_parent_device (device, ai->device, ai->handler);
-
- g_free (ai);
-}
+class_device_got_device_file (HalDevice *d, gpointer user_data,
+ gboolean prop_exists);
/** Generic visitor method for class devices.
@@ -86,8 +66,10 @@ got_parent_cb (HalDeviceStore *store, HalDevice *device,
* This function parses the attributes present and merges more information
* into the HAL device this class device points to
*
+ * @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,
@@ -96,116 +78,91 @@ class_device_visit (ClassDeviceHandler *self,
dbus_bool_t is_probing)
{
HalDevice *d;
+ char dev_file[SYSFS_PATH_MAX];
char dev_file_prop_name[SYSFS_PATH_MAX];
/* only care about given sysfs class name */
if (strcmp (class_device->classname, self->sysfs_class_name) != 0)
return;
+ /* don't care if there is no sysdevice */
if (class_device->sysdevice == NULL) {
- HAL_WARNING (("class device %s doesn't have sysdevice", path));
return;
}
/* Construct a new device and add to temporary device list */
d = hal_device_new ();
hal_device_store_add (hald_get_tdl (), d);
+
+ /* Need some properties if we are to appear in the tree on our own */
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);
hal_device_property_set_string (d, "linux.sysfs_path", path);
hal_device_property_set_string (d, "linux.sysfs_path_device",
class_device->sysdevice->path);
}
+ /* We may require a device file */
if (self->require_device_file) {
- /* temporary property used for _udev_event() */
+ /* Temporary property used for _udev_event() */
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.class_name",
+ self->sysfs_class_name);
/* 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);
- hal_device_property_set_string (d, ".target_dev", dev_file_prop_name);
- }
-
- /* Ask udev about the device file if we are probing */
- if (self->require_device_file && is_probing) {
- char dev_file[SYSFS_PATH_MAX];
-
- 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;
+ dev_file_prop_name,
+ SYSFS_PATH_MAX);
+ hal_device_property_set_string (d, ".target_dev",
+ dev_file_prop_name);
+
+ /* Ask udev about the device file if we are probing */
+ if (is_probing) {
+ 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;
+ }
+
+ /* If we are not probing this function will be called
+ * upon receiving a dbus event */
+ self->udev_event (self, d, dev_file);
}
-
- /* If we are not probing this function will be called upon
- * receiving a dbus event */
- self->udev_event (self, d, dev_file);
}
/* Now find the physical device; this happens asynchronously as it
* might be added later. */
if (self->merge_or_add) {
-#if 0
- ds_device_async_find_by_key_value_string
- ("linux.sysfs_path_device",
- class_device->sysdevice->path,
- TRUE, class_device_got_sysdevice,
- (void *) d, (void *) self,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#elif 0
- class_device_got_sysdevice (
- hal_device_store_match_key_value_string (hald_get_gdl (),
- "linux.sysfs_path_device",
- class_device->sysdevice->path),
- d, self);
-#else
- {
- AsyncInfo *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",
- class_device->sysdevice->path,
- got_sysdevice_cb, ai,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
- }
-#endif
+ AsyncInfo *ai = g_new0 (AsyncInfo, 1);
+ ai->device = d;
+ ai->handler = self;
+
+ /* find the sysdevice */
+ hal_device_store_match_key_value_string_async (
+ hald_get_gdl (),
+ "linux.sysfs_path_device",
+ class_device->sysdevice->path,
+ class_device_got_sysdevice, ai,
+ is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
} else {
char *parent_sysfs_path;
+ AsyncInfo *ai = g_new0 (AsyncInfo, 1);
- parent_sysfs_path = get_parent_sysfs_path (class_device->sysdevice->path);
-
-#if 0
- ds_device_async_find_by_key_value_string
- ("linux.sysfs_path_device",
- parent_sysfs_path,
- TRUE, class_device_got_parent_device,
- (void *) d, (void *) self,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#elif 0
- class_device_got_parent_device (
- hal_device_store_match_key_value_string (hald_get_gdl (),
- "linux.sysfs_path_device",
- parent_sysfs_path),
- d, self);
-#else
- {
- AsyncInfo *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,
- got_parent_cb, ai,
- is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
- }
-#endif
+ parent_sysfs_path =
+ get_parent_sysfs_path (class_device->sysdevice->path);
+
+ ai->device = d;
+ ai->handler = self;
+
+ /* find the parent */
+ hal_device_store_match_key_value_string_async (
+ hald_get_gdl (),
+ "linux.sysfs_path_device",
+ parent_sysfs_path,
+ class_device_got_parent_device, ai,
+ is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
}
}
@@ -218,11 +175,10 @@ class_device_visit (ClassDeviceHandler *self,
* this device class
*/
void
-class_device_removed (ClassDeviceHandler* self,
- const char *sysfs_path,
+class_device_removed (ClassDeviceHandler* self, const char *sysfs_path,
HalDevice *d)
{
- HAL_INFO (("entering : sysfs_path = '%s'", sysfs_path));
+ HAL_INFO (("sysfs_path = '%s'", sysfs_path));
}
/** Called when a device file (e.g. a file in /dev) have been created by udev
@@ -233,8 +189,8 @@ class_device_removed (ClassDeviceHandler* self,
* @param dev_file device file, e.g. /dev/input/event4
*/
void
-class_device_udev_event (ClassDeviceHandler *self,
- HalDevice *d, char *dev_file)
+class_device_udev_event (ClassDeviceHandler *self, HalDevice *d,
+ char *dev_file)
{
const char *target_dev;
char *target_dev_copy;
@@ -254,34 +210,6 @@ class_device_udev_event (ClassDeviceHandler *self,
free (target_dev_copy);
}
-typedef struct {
- char *target_dev;
- ClassDeviceHandler *handler;
- guint signal_id;
-} PropInfo;
-
-static void
-prop_changed_cb (HalDevice *device, const char *key,
- gboolean removed, gboolean added, gpointer user_data)
-{
- PropInfo *pi = user_data;
-
- if (strcmp (key, pi->target_dev) != 0)
- return;
-
- /* the property is no longer there */
- if (removed)
- goto cleanup;
-
-
- class_device_got_device_file (device, device, pi->handler);
-
-cleanup:
- g_signal_handler_disconnect (device, pi->signal_id);
-
- g_free (pi->target_dev);
- g_free (pi);
-}
/** Callback when the parent device is found or if timeout for search occurs.
* (only applicable if self->merge_or_add==FALSE)
@@ -292,16 +220,20 @@ cleanup:
* @param data2 User data
*/
void
-class_device_got_parent_device (HalDevice *parent, void *data1, void *data2)
+class_device_got_parent_device (HalDeviceStore *store, HalDevice *parent,
+ gpointer user_data)
{
+ AsyncInfo *ai = user_data;
const char *target_dev = NULL;
const char *sysfs_path = NULL;
char *new_udi = NULL;
HalDevice *new_d = NULL;
- HalDevice *d = (HalDevice *) data1;
- ClassDeviceHandler *self = (ClassDeviceHandler *) data2;
+ HalDevice *d = (HalDevice *) ai->device;
+ ClassDeviceHandler *self = ai->handler;
struct sysfs_class_device *class_device;
+ g_free (ai);
+
if (parent == NULL) {
HAL_WARNING (("No parent for class device at sysfs path %s",
d->udi));
@@ -329,26 +261,12 @@ class_device_got_parent_device (HalDevice *parent, void *data1, void *data2)
if (self->require_device_file) {
target_dev = hal_device_property_get_string (d, ".target_dev");
assert (target_dev != NULL);
-#if 0
- ds_device_async_wait_for_property (
+
+ hal_device_async_wait_property (
d, target_dev,
class_device_got_device_file,
- (void *) d, (void *) self,
+ (gpointer) self,
is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#else
- if (hal_device_has_property (d, target_dev))
- class_device_got_device_file (d, d, self);
- else {
- PropInfo *pi;
-
- pi = g_new0 (PropInfo, 1);
- pi->target_dev = g_strdup (target_dev);
- pi->handler = self;
- pi->signal_id = g_signal_connect (d,
- "property_changed",
- prop_changed_cb, pi);
- }
-#endif
} else {
/* Compute a proper UDI (unique device id) and try to locate a
* persistent unplugged device or simple add this new device...
@@ -375,13 +293,16 @@ class_device_got_parent_device (HalDevice *parent, void *data1, void *data2)
* @param data2 User data
*/
void
-class_device_got_sysdevice (HalDevice *sysdevice, void *data1, void *data2)
+class_device_got_sysdevice (HalDeviceStore *store,
+ HalDevice *sysdevice,
+ gpointer user_data)
{
+ AsyncInfo *ai = user_data;
const char *target_dev;
const char *parent_udi;
HalDevice *parent_device;
- HalDevice *d = (HalDevice *) data1;
- ClassDeviceHandler *self = (ClassDeviceHandler *) data2;
+ HalDevice *d = (HalDevice *) ai->device;
+ ClassDeviceHandler *self = ai->handler;
HAL_INFO (("Entering d=0x%0x, sysdevice=0x%0x!", d, sysdevice));
@@ -413,47 +334,26 @@ class_device_got_sysdevice (HalDevice *sysdevice, void *data1, void *data2)
if (self->require_device_file ) {
target_dev = hal_device_property_get_string (d, ".target_dev");
assert (target_dev != NULL);
-#if 0
- ds_device_async_wait_for_property (
+
+ hal_device_async_wait_property (
d, target_dev,
class_device_got_device_file,
- (void *) d, (void *) self,
+ (gpointer) self,
is_probing ? 0 : HAL_LINUX_HOTPLUG_TIMEOUT);
-#else
- if (hal_device_has_property (d, target_dev))
- class_device_got_device_file (d, d, self);
- else {
- PropInfo *pi;
-
- pi = g_new0 (PropInfo, 1);
- pi->target_dev = g_strdup (target_dev);
- pi->handler = self;
- pi->signal_id = g_signal_connect (d,
- "property_changed",
- prop_changed_cb, pi);
- }
-#endif
} else {
/** @todo FIXME */
DIE (("fix me here"));
}
}
-/** Callback when we got a device file found or on timeout on search occurs.
- *
- * @param sysdevice Async Return value from the find call or NULL
- * if timeout
- * @param data1 User data (our own device in this case)
- * @param data2 User data
- */
-void
-class_device_got_device_file (HalDevice *dm, void *data1, void *data2)
+static void
+class_device_got_device_file (HalDevice *d, gpointer user_data,
+ gboolean prop_exists)
{
- HalDevice *d = (HalDevice *) data1;
HalDevice *sysdevice;
- ClassDeviceHandler *self = (ClassDeviceHandler *) data2;
+ ClassDeviceHandler *self = (ClassDeviceHandler *) user_data;
- if (dm == NULL) {
+ if (!prop_exists) {
HAL_WARNING (("Never got device file for class device at %s",
hal_device_property_get_string (d, ".udev.sysfs_path")));
hal_device_store_remove (hald_get_tdl (), d);
diff --git a/hald/linux/class_device.h b/hald/linux/class_device.h
index 0921076c..681c0794 100644
--- a/hald/linux/class_device.h
+++ b/hald/linux/class_device.h
@@ -226,11 +226,13 @@ void class_device_get_device_file_target (ClassDeviceHandler *self,
char* dev_file_prop,
int dev_file_prop_len);
-void class_device_got_device_file (HalDevice *dm, void *data1, void *data2);
+void class_device_got_sysdevice (HalDeviceStore *store,
+ HalDevice *sysdevice,
+ gpointer user_data);
-void class_device_got_sysdevice (HalDevice *sysdevice, void *data1, void *data2);
-
-void class_device_got_parent_device (HalDevice *parent, void *data1, void *data2);
+void class_device_got_parent_device (HalDeviceStore *store,
+ HalDevice *parent,
+ gpointer user_data);
#endif /* CLASS_DEVICE_H */
diff --git a/hald/linux/common.c b/hald/linux/common.c
index 22d58acd..7f740bd6 100644
--- a/hald/linux/common.c
+++ b/hald/linux/common.c
@@ -615,9 +615,10 @@ class_device_get_device_file (const char *sysfs_path,
char *dev_file, int dev_file_length)
{
int i;
- int sysfs_mount_path_len;
+ unsigned int sysfs_mount_path_len;
char sysfs_path_trunc[SYSFS_NAME_LEN];
- char *udev_argv[7] = { udevinfo_path (), "-r", "-q", "name", "-p",
+ char *udev_argv[7] = { (char *) udevinfo_path (),
+ "-r", "-q", "name", "-p",
sysfs_path_trunc, NULL };
char *udev_stdout;
char *udev_stderr;
diff --git a/hald/linux/ide_bus_device.c b/hald/linux/ide_bus_device.c
index 7817f436..d638af96 100644
--- a/hald/linux/ide_bus_device.c
+++ b/hald/linux/ide_bus_device.c
@@ -59,7 +59,7 @@ ide_device_compute_udi (HalDevice *d, int append_num)
hal_device_property_get_int (d, "ide.host"),
hal_device_property_get_int (d, "ide.channel"));
else
- sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d/d",
+ sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d/%d",
hal_device_property_get_int (d, "ide.host"),
hal_device_property_get_int (d, "ide.channel"),
append_num);
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 0accb83f..f5e34e0a 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -541,7 +541,7 @@ udev_node_created_cb (HalDeviceStore *store, HalDevice *device,
{
const char *filename = user_data;
- handle_udev_node_created_found_device (device, filename, NULL);
+ handle_udev_node_created_found_device (device, (void*) filename, NULL);
}
/** Handle a org.freedesktop.Hal.HotplugEvent message. This message
diff --git a/hald/linux/usb_bus_device.c b/hald/linux/usb_bus_device.c
index 82cf6ad6..1a163229 100644
--- a/hald/linux/usb_bus_device.c
+++ b/hald/linux/usb_bus_device.c
@@ -606,15 +606,6 @@ usb_device_init ()
usb_proc_parse ();
}
-/** This function is called when all device detection on startup is done
- * in order to perform optional batch processing on devices
- *
- */
-static void
-usb_device_detection_done ()
-{
-}
-
/** Shutdown function for USB handling
*