ia64/xen-unstable
changeset 5887:c1c2a023dbc4
Fix bus watch code, and clean up a little.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
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:19:38 2005 +0000 (2005-07-26) |
parents | 51fb35494e9b |
children | b52196300306 |
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:18:55 2005 +0000 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Jul 26 17:19:38 2005 +0000 1.3 @@ -233,29 +233,25 @@ static unsigned int char_count(const cha 1.4 static void dev_changed(struct xenbus_watch *watch, const char *node) 1.5 { 1.6 char busid[BUS_ID_SIZE]; 1.7 - unsigned int typelen, idlen; 1.8 int exists; 1.9 struct xenbus_device *dev; 1.10 - char *type; 1.11 + char *p; 1.12 1.13 /* Node is of form device/<type>/<identifier>[/...] */ 1.14 - if (char_count(node, '/') != 3) 1.15 + if (char_count(node, '/') != 2) 1.16 return; 1.17 1.18 - type = strchr(node, '/'); 1.19 - type++; 1.20 - typelen = strcspn(type, "/"); 1.21 - idlen = strcspn(type + typelen + 1, "/"); 1.22 - if (typelen + strlen("-") + idlen + 1 > BUS_ID_SIZE) { 1.23 + /* Created or deleted? */ 1.24 + exists = xenbus_exists(node, ""); 1.25 + 1.26 + p = strchr(node, '/') + 1; 1.27 + if (strlen(p) + 1 > BUS_ID_SIZE) { 1.28 printk("Device for node %s is too big!\n", node); 1.29 return; 1.30 } 1.31 - 1.32 - /* Does it exist? */ 1.33 - exists = xenbus_exists(node, ""); 1.34 - 1.35 - /* Create it with a / so we can see if it exists. */ 1.36 - sprintf(busid, "%.*s-%.*s", typelen, type, idlen, type + typelen + 1); 1.37 + /* Bus ID is name with / changed to - */ 1.38 + strcpy(busid, p); 1.39 + *strchr(busid, '/') = '-'; 1.40 1.41 dev = xenbus_device_find(busid); 1.42 printk("xenbus: device %s %s\n", busid, dev ? "exists" : "new"); 1.43 @@ -263,12 +259,14 @@ static void dev_changed(struct xenbus_wa 1.44 printk("xenbus: Unregistering device %s\n", busid); 1.45 /* FIXME: free? */ 1.46 device_unregister(&dev->dev); 1.47 - } 1.48 - if (!dev && exists) { 1.49 + } else if (!dev && exists) { 1.50 printk("xenbus: Adding device %s\n", busid); 1.51 - busid[typelen] = '\0'; 1.52 - xenbus_probe_device("device", busid, busid+typelen+1); 1.53 - } 1.54 + /* Hack bus id back into two strings. */ 1.55 + *strrchr(busid, '-') = '\0'; 1.56 + xenbus_probe_device("device", busid, busid+strlen(busid)+1); 1.57 + } else 1.58 + printk("xenbus: strange, %s already %s\n", busid, 1.59 + exists ? "exists" : "gone"); 1.60 if (dev) 1.61 put_device(&dev->dev); 1.62 }