ia64/xen-unstable
changeset 10625:f5a5f49935fd
[XENBUS] Improve the code for waiting for devices to connect. Provide
a more useful error when devices fail to connect.
From: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
a more useful error when devices fail to connect.
From: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Fri Jun 30 17:02:22 2006 +0100 (2006-06-30) |
parents | 17e9daeb2c50 |
children | 640d3bc77ea6 |
files | linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Fri Jun 30 14:41:13 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Fri Jun 30 17:02:22 2006 +0100 1.3 @@ -886,29 +886,19 @@ void unregister_xenstore_notifier(struct 1.4 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier); 1.5 1.6 1.7 -static int all_devices_ready_(struct device *dev, void *data) 1.8 +static int find_disconnected_device_(struct device *dev, void *data) 1.9 { 1.10 struct xenbus_device *xendev = to_xenbus_device(dev); 1.11 - int *result = data; 1.12 1.13 - if (xendev->state != XenbusStateConnected) { 1.14 - *result = 0; 1.15 - return 1; 1.16 - } 1.17 - 1.18 - return 0; 1.19 + return (xendev->state == XenbusStateConnected) ? 0 : 1; 1.20 } 1.21 1.22 - 1.23 -static int all_devices_ready(void) 1.24 +static struct device *find_disconnected_device(struct device *start) 1.25 { 1.26 - int ready = 1; 1.27 - bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready, 1.28 - all_devices_ready_); 1.29 - return ready; 1.30 + return bus_find_device(&xenbus_frontend.bus, start, NULL, 1.31 + find_disconnected_device_); 1.32 } 1.33 1.34 - 1.35 void xenbus_probe(void *unused) 1.36 { 1.37 BUG_ON((xenstored_ready <= 0)); 1.38 @@ -1077,17 +1067,28 @@ postcore_initcall(xenbus_probe_init); 1.39 static int __init wait_for_devices(void) 1.40 { 1.41 unsigned long timeout = jiffies + 10*HZ; 1.42 + struct device *dev = NULL; 1.43 + struct xenbus_device *xendev; 1.44 1.45 if (!is_running_on_xen()) 1.46 return -ENODEV; 1.47 1.48 while (time_before(jiffies, timeout)) { 1.49 - if (all_devices_ready()) 1.50 + if ((dev = find_disconnected_device(NULL)) == NULL) 1.51 return 0; 1.52 + put_device(dev); 1.53 schedule_timeout_interruptible(HZ/10); 1.54 } 1.55 1.56 - printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n"); 1.57 + while (dev != NULL) { 1.58 + xendev = to_xenbus_device(dev); 1.59 + 1.60 + printk(KERN_WARNING "XENBUS: Timeout connecting to device: %s\n", 1.61 + xendev->nodename); 1.62 + 1.63 + dev = find_disconnected_device(dev); 1.64 + } 1.65 + 1.66 return 0; 1.67 } 1.68