ia64/xen-unstable

changeset 10629:4d7565ba9ff3

[XENBUS] Another fix to the wait-for-device-connection code.
The new method for printing unconnected device status is arguably
cleaner and also does not screw up reference counts (previous code
called bus_find_device() with no put_device() on the result.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Fri Jun 30 18:14:57 2006 +0100 (2006-06-30)
parents 9633faf65e22
children a377304fc4e6
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 17:53:52 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Jun 30 18:14:57 2006 +0100
     1.3 @@ -1057,15 +1057,21 @@ static struct device *find_disconnected_
     1.4  			       find_disconnected_device_);
     1.5  }
     1.6  
     1.7 -static int find_driverless_device_(struct device *dev, void *data)
     1.8 +static int print_device_status(struct device *dev, void *data)
     1.9  {
    1.10 -	return !dev->driver;
    1.11 -}
    1.12 +	struct xenbus_device *xendev = to_xenbus_device(dev);
    1.13  
    1.14 -static struct device *find_driverless_device(struct device *start)
    1.15 -{
    1.16 -	return bus_find_device(&xenbus_frontend.bus, start, NULL,
    1.17 -			       find_driverless_device_);
    1.18 +	if (!dev->driver) {
    1.19 +		/* Information only: is this too noisy? */
    1.20 +		printk(KERN_INFO "XENBUS: Device with no driver: %s\n",
    1.21 +		       xendev->nodename);
    1.22 +	} else if (xendev->state != XenbusStateConnected) {
    1.23 +		printk(KERN_WARNING "XENBUS: Timeout connecting "
    1.24 +		       "to device: %s (state %d)\n",
    1.25 +		       xendev->nodename, xendev->state);
    1.26 +	}
    1.27 +
    1.28 +	return 0;
    1.29  }
    1.30  
    1.31  /*
    1.32 @@ -1086,7 +1092,6 @@ static int __init wait_for_devices(void)
    1.33  {
    1.34  	unsigned long timeout = jiffies + 10*HZ;
    1.35  	struct device *dev = NULL;
    1.36 -	struct xenbus_device *xendev;
    1.37  
    1.38  	if (!is_running_on_xen())
    1.39  		return -ENODEV;
    1.40 @@ -1098,22 +1103,8 @@ static int __init wait_for_devices(void)
    1.41  		schedule_timeout_interruptible(HZ/10);
    1.42  	}
    1.43  
    1.44 -	/* List devices which have drivers but are not yet connected. */
    1.45 -	while (dev != NULL) {
    1.46 -		xendev = to_xenbus_device(dev);
    1.47 -
    1.48 -		printk(KERN_WARNING "XENBUS: Timeout connecting "
    1.49 -		       "to device: %s\n", xendev->nodename);
    1.50 -
    1.51 -		dev = find_disconnected_device(dev);
    1.52 -	}
    1.53 -
    1.54 -	/* List devices with no driver (this is not necessarily an error). */
    1.55 -	while ((dev = find_driverless_device(dev)) != NULL) {
    1.56 -		xendev = to_xenbus_device(dev);
    1.57 -		printk(KERN_INFO "XENBUS: Device with no driver: %s\n",
    1.58 -		       xendev->nodename);
    1.59 -	}
    1.60 +	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL,
    1.61 +			 print_device_status);
    1.62  
    1.63  	return 0;
    1.64  }