Magellan Linux

Contents of /trunk/hal/patches/hal-0.5.10-remove-all-childs-of-a-device-if-it-get-removed.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 597 - (show annotations) (download)
Mon May 19 19:05:19 2008 UTC (15 years, 11 months ago) by niro
File size: 2814 byte(s)
-gentoo patches

1 From bc6242ea7ee85d8f9c0108937f2d5c84f14fb2bf Mon Sep 17 00:00:00 2001
2 From: Danny Kukawka <danny.kukawka@web.de>
3 Date: Thu, 6 Dec 2007 10:36:06 +0100
4 Subject: [PATCH] remove all childs of a device if it get removed
5
6 This change removes all child-devices of a device which get removed.
7
8 This solves problems e.g. with via fdi rules spawned devices, which currently
9 get not removed if their parent device get removed.
10
11 Currently if the parent get removed they are still there also if they are not
12 visible in lshal. This mean also, that all addons of a spawned device (as
13 e.g. the dell backlight addon) are still running. This patch should fix it.
14 ---
15 hald/linux/device.c | 31 +++++++++++++++++++++++++++++--
16 1 files changed, 29 insertions(+), 2 deletions(-)
17
18 diff --git a/hald/linux/device.c b/hald/linux/device.c
19 index dc955c6..6175a0c 100644
20 --- a/hald/linux/device.c
21 +++ b/hald/linux/device.c
22 @@ -3712,6 +3712,18 @@ dev_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2)
23 }
24
25 static void
26 +dev_callouts_remove_child_done (HalDevice *d, gpointer userdata1, gpointer userdata2)
27 +{
28 + HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d)));
29 +
30 + if (!hal_device_store_remove (hald_get_gdl (), d)) {
31 + HAL_WARNING (("Error removing device"));
32 + }
33 +
34 + g_object_unref (d);
35 +}
36 +static void
37 +
38 add_dev_after_probing (HalDevice *d, DevHandler *handler, void *end_token)
39 {
40 /* Compute UDI */
41 @@ -3887,7 +3899,9 @@ hotplug_event_begin_remove_dev (const gchar *subsystem, const gchar *sysfs_path,
42 {
43 guint i;
44 HalDevice *d;
45 -
46 + HalDevice *child;
47 + GSList *children;
48 + GSList *tmp;
49
50 HAL_INFO (("remove_dev: subsys=%s sysfs_path=%s", subsystem, sysfs_path));
51
52 @@ -3900,8 +3914,21 @@ hotplug_event_begin_remove_dev (const gchar *subsystem, const gchar *sysfs_path,
53
54 handler = dev_handlers[i];
55 if (strcmp (handler->subsystem, subsystem) == 0) {
56 - if (strcmp (subsystem, "scsi") == 0)
57 + if (strcmp (subsystem, "scsi") == 0) {
58 missing_scsi_host(sysfs_path, (HotplugEvent *)end_token, HOTPLUG_ACTION_REMOVE);
59 + }
60 +
61 + /* check if there are children left before remove the device */
62 + children = hal_device_store_match_multiple_key_value_string (hald_get_gdl (),
63 + "info.parent",
64 + hal_device_get_udi(d));
65 +
66 + for (tmp = children; tmp != NULL; tmp = g_slist_next (tmp)) {
67 + child = HAL_DEVICE (tmp->data);
68 + HAL_INFO(("Remove now: %s as child of: %s", hal_device_get_udi(child), hal_device_get_udi(d)));
69 + hal_util_callout_device_remove (child, dev_callouts_remove_child_done, NULL, NULL);
70 + }
71 + g_slist_free (children);
72
73 handler->remove (d);
74 hal_util_callout_device_remove (d, dev_callouts_remove_done, end_token, NULL);
75 --
76 1.5.3.7
77