ia64/xen-unstable

changeset 5885:c352c388aaec

Modify to assume transactions
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:18:11 2005 +0000 (2005-07-26)
parents aa8776c44b65
children 51fb35494e9b
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:16:55 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Jul 26 17:18:11 2005 +0000
     1.3 @@ -220,8 +220,16 @@ unlock:
     1.4  	return err;
     1.5  }
     1.6  
     1.7 -/* FIXME: When all tools use transactions, we can ignore events on
     1.8 - * subpaths. */
     1.9 +static unsigned int char_count(const char *str, char c)
    1.10 +{
    1.11 +	unsigned int i, ret = 0;
    1.12 +
    1.13 +	for (i = 0; str[i]; i++)
    1.14 +		if (str[i] == c)
    1.15 +			ret++;
    1.16 +	return ret;
    1.17 +}
    1.18 +
    1.19  static void dev_changed(struct xenbus_watch *watch, const char *node)
    1.20  {
    1.21  	char busid[BUS_ID_SIZE];
    1.22 @@ -231,28 +239,26 @@ static void dev_changed(struct xenbus_wa
    1.23  	char *type;
    1.24  
    1.25  	/* Node is of form device/<type>/<identifier>[/...] */
    1.26 -	type = strchr(node, '/');
    1.27 -	if (!type)
    1.28 +	if (char_count(node, '/') != 3)
    1.29  		return;
    1.30 +
    1.31 +	type = strchr(node, '/');
    1.32  	type++;
    1.33 -
    1.34  	typelen = strcspn(type, "/");
    1.35 -	if (!typelen)
    1.36 -		return;
    1.37  	idlen = strcspn(type + typelen + 1, "/");
    1.38 -	if (!idlen)
    1.39 -		return;
    1.40  	if (typelen + strlen("-") + idlen + 1 > BUS_ID_SIZE) {
    1.41  		printk("Device for node %s is too big!\n", node);
    1.42  		return;
    1.43  	}
    1.44  
    1.45 +	/* Does it exist? */
    1.46 +	exists = xenbus_exists(node, "");
    1.47 +
    1.48  	/* Create it with a / so we can see if it exists. */
    1.49 -	sprintf(busid, "%.*s/%.*s", typelen, type, idlen, type + typelen + 1);
    1.50 -	exists = xenbus_exists("device", busid);
    1.51 -	busid[typelen] = '-';
    1.52 +	sprintf(busid, "%.*s-%.*s", typelen, type, idlen, type + typelen + 1);
    1.53  
    1.54  	dev = xenbus_device_find(busid);
    1.55 +	printk("xenbus: device %s %s\n", busid, dev ? "exists" : "new");
    1.56  	if (dev && !exists) {
    1.57  		printk("xenbus: Unregistering device %s\n", busid);
    1.58  		/* FIXME: free? */