hal: Branch 'master'
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Jul 3 08:45:28 PDT 2007
hald/linux/device.c | 26 ++++++++++++++++++++++++++
hald/linux/device.h | 1 +
hald/linux/hotplug.c | 5 +++--
3 files changed, 30 insertions(+), 2 deletions(-)
New commits:
diff-tree b627afcf95501c5d629a2140dfb70e8b510729c8 (from 002f3d5493d3c1041634771747d7f9d690198ce3)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jul 3 16:43:27 2007 +0100
add a refresh handler for linux devices
Some stuff in sysfs now sends out uevents when values change. A good
example of this is the power_supply class which sends out a uevent when
the percentage value changes or the battery or ac adapter is removed.
At the moment we ignore the uevents, but the attached patch adds a
refresh() method that can be used to update the values.
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 1660f3f..a7855d2 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2974,6 +2974,7 @@ struct DevHandler_s
const gchar *(*get_prober)(HalDevice *d);
gboolean (*post_probing) (HalDevice *d);
gboolean (*compute_udi) (HalDevice *d);
+ gboolean (*refresh) (HalDevice *d);
gboolean (*remove) (HalDevice *d);
};
@@ -3518,6 +3519,31 @@ out:
;
}
+void
+hotplug_event_refresh_dev (const gchar *subsystem, HalDevice *d, void *end_token)
+{
+ guint i;
+ DevHandler *handler;
+
+ HAL_INFO (("remove_dev: subsys=%s", subsystem));
+
+ for (i = 0; dev_handlers [i] != NULL; i++) {
+ handler = dev_handlers[i];
+ if (strcmp (handler->subsystem, subsystem) == 0) {
+ if (handler->refresh != NULL) {
+ handler->refresh (d);
+ }
+ goto out;
+ }
+ }
+
+ /* didn't find anything - thus, ignore this hotplug event */
+ hotplug_event_end (end_token);
+out:
+ ;
+}
+
+
static void
dev_rescan_device_done (HalDevice *d,
guint32 exit_type,
diff --git a/hald/linux/device.h b/hald/linux/device.h
index 8ec9412..bc3afbc 100644
--- a/hald/linux/device.h
+++ b/hald/linux/device.h
@@ -41,6 +41,7 @@ void hotplug_event_begin_add_dev (const
void *end_token);
void hotplug_event_begin_remove_dev (const gchar *subsystem, const gchar *sysfs_path, void *end_token);
+void hotplug_event_refresh_dev (const gchar *subsystem, HalDevice *d, void *end_token);
gboolean dev_rescan_device (HalDevice *d);
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index e836fd9..6178358 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -89,9 +89,10 @@ hotplug_event_begin_sysfs (HotplugEvent
"linux.sysfs_path",
hotplug_event->sysfs.sysfs_path);
- /* FIXME: we should reprobe the device instead of skipping the event */
+ /* we should refresh the device when we get a uevent */
if (d != NULL && hotplug_event->action == HOTPLUG_ACTION_ADD) {
- HAL_ERROR (("devpath %s already present in the store, ignore event", hotplug_event->sysfs.sysfs_path));
+ HAL_ERROR (("device %s already present in the store, so refreshing", hotplug_event->sysfs.sysfs_path));
+ hotplug_event_refresh_dev (hotplug_event->sysfs.subsystem, d, (void *) hotplug_event);
hotplug_event_end ((void *) hotplug_event);
return;
}
More information about the hal-commit
mailing list