ia64/xen-unstable

changeset 5884:aa8776c44b65

Do not use device_find: crashes for some reason
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Jul 26 17:16:55 2005 +0000 (2005-07-26)
parents c20ccb474166
children c352c388aaec
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	Tue Jul 26 17:15:53 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Jul 26 17:16:55 2005 +0000
     1.3 @@ -113,6 +113,33 @@ void xenbus_unregister_driver(struct xen
     1.4  	driver_unregister(&drv->driver);
     1.5  }
     1.6  
     1.7 +struct xb_find_info
     1.8 +{
     1.9 +	struct xenbus_device *dev;
    1.10 +	const char *busid;
    1.11 +};
    1.12 +
    1.13 +static int cmp_dev(struct device *dev, void *data)
    1.14 +{
    1.15 +	struct xb_find_info *info = data;
    1.16 +
    1.17 +	if (streq(dev->bus_id, info->busid)) {
    1.18 +		info->dev = container_of(get_device(dev),
    1.19 +					 struct xenbus_device, dev);
    1.20 +		return 1;
    1.21 +	}
    1.22 +	return 0;
    1.23 +}
    1.24 +
    1.25 +/* FIXME: device_find seems to be broken. --RR */
    1.26 +struct xenbus_device *xenbus_device_find(const char *busid)
    1.27 +{
    1.28 +	struct xb_find_info info = { .dev = NULL, .busid = busid };
    1.29 +
    1.30 +	bus_for_each_dev(&xenbus_type, NULL, &info, cmp_dev);
    1.31 +	return info.dev;
    1.32 +}
    1.33 +
    1.34  /* devices/<typename>/<name> */
    1.35  static int xenbus_probe_device(const char *dirpath, const char *devicetype,
    1.36  			       const char *name)
    1.37 @@ -200,7 +227,7 @@ static void dev_changed(struct xenbus_wa
    1.38  	char busid[BUS_ID_SIZE];
    1.39  	unsigned int typelen, idlen;
    1.40  	int exists;
    1.41 -	struct device *dev;
    1.42 +	struct xenbus_device *dev;
    1.43  	char *type;
    1.44  
    1.45  	/* Node is of form device/<type>/<identifier>[/...] */
    1.46 @@ -225,17 +252,19 @@ static void dev_changed(struct xenbus_wa
    1.47  	exists = xenbus_exists("device", busid);
    1.48  	busid[typelen] = '-';
    1.49  
    1.50 -	dev = device_find(busid, &xenbus_type);
    1.51 +	dev = xenbus_device_find(busid);
    1.52  	if (dev && !exists) {
    1.53  		printk("xenbus: Unregistering device %s\n", busid);
    1.54  		/* FIXME: free? */
    1.55 -		device_unregister(dev);
    1.56 +		device_unregister(&dev->dev);
    1.57  	}
    1.58  	if (!dev && exists) {
    1.59  		printk("xenbus: Adding device %s\n", busid);
    1.60  		busid[typelen] = '\0';
    1.61  		xenbus_probe_device("device", busid, busid+typelen+1);
    1.62  	}
    1.63 +	if (dev)
    1.64 +		put_device(&dev->dev);
    1.65  }
    1.66  
    1.67  /* We watch for devices appearing and vanishing. */