direct-io.hg

changeset 5635:cb3da7250118

Rewrite xenbus_path and cleanup whitespace.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Jul 01 14:31:22 2005 +0000 (2005-07-01)
parents 7c95f26c2f0e
children 88a7a299d927
files linux-2.6.11-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Jul 01 13:35:03 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Jul 01 14:31:22 2005 +0000
     1.3 @@ -65,19 +65,19 @@ static int xs_init_done = 0;
     1.4  char *xenbus_path(const char *dir, const char *name)
     1.5  {
     1.6  	char *ret;
     1.7 -        if(name && strlen(name)){
     1.8 -                ret = kmalloc(strlen(dir) + 1 + strlen(name) + 1, GFP_KERNEL);
     1.9 -                if (!ret)
    1.10 -                        return NULL;
    1.11 -                strcpy(ret, dir);
    1.12 +	int len;
    1.13 +
    1.14 +	len = strlen(dir) + 1;
    1.15 +	if (name)
    1.16 +		len += strlen(name) + 1;
    1.17 +	ret = kmalloc(len, GFP_KERNEL);
    1.18 +	if (ret == NULL)
    1.19 +	    return NULL;
    1.20 +	strcpy(ret, dir);
    1.21 +	if (name) {
    1.22  		strcat(ret, "/");
    1.23  		strcat(ret, name);
    1.24 -	} else {
    1.25 -                ret = kmalloc(strlen(dir) + 1, GFP_KERNEL);
    1.26 -                if (!ret)
    1.27 -                        return NULL;
    1.28 -                strcpy(ret, dir);
    1.29 -        }
    1.30 +	}
    1.31  	return ret;
    1.32  }
    1.33  
    1.34 @@ -85,59 +85,58 @@ char *xenbus_path(const char *dir, const
    1.35  
    1.36  char *xenbus_read(const char *dir, const char *name, unsigned int *data_n)
    1.37  {
    1.38 -        int err = 0;
    1.39 +	int err = 0;
    1.40  	char *data = NULL;
    1.41  	char *path = xenbus_path(dir, name);
    1.42 -        int n = 0;
    1.43 +	int n = 0;
    1.44  
    1.45  	if (!path) {
    1.46 -                err = -ENOMEM;
    1.47 -                goto out;
    1.48 -        }
    1.49 +		err = -ENOMEM;
    1.50 +		goto out;
    1.51 +	}
    1.52  	data = xs_read(path, &n);
    1.53 -	if (IS_ERR(data)){
    1.54 -                err = PTR_ERR(data);
    1.55 -                if(err == -EISDIR){
    1.56 -                        err = -ENOENT;
    1.57 -                }
    1.58 -        } else if(n == 0){
    1.59 -                err = -ENOENT;
    1.60 -                kfree(data);
    1.61 -        }
    1.62 -        kfree(path);
    1.63 +	if (IS_ERR(data)) {
    1.64 +		err = PTR_ERR(data);
    1.65 +		if (err == -EISDIR)
    1.66 +			err = -ENOENT;
    1.67 +	} else if (n == 0) {
    1.68 +		err = -ENOENT;
    1.69 +		kfree(data);
    1.70 +	}
    1.71 +	kfree(path);
    1.72    out:
    1.73 -        if(data_n)
    1.74 -                *data_n = n;
    1.75 +	if (data_n)
    1.76 +		*data_n = n;
    1.77  	return (err ? ERR_PTR(err) : data);
    1.78  }
    1.79  
    1.80  int xenbus_write(const char *dir, const char *name, const char *data, int data_n)
    1.81  {
    1.82 -        int err = 0;
    1.83 +	int err = 0;
    1.84  	char *path = xenbus_path(dir, name);
    1.85  
    1.86  	if (!path)
    1.87  		return -ENOMEM;
    1.88 -        err = xs_write(path, data, data_n, O_CREAT);
    1.89 +	err = xs_write(path, data, data_n, O_CREAT);
    1.90  	kfree(path);
    1.91 -        return err;
    1.92 +	return err;
    1.93  }
    1.94  
    1.95  int xenbus_read_string(const char *dir, const char *name, char **val)
    1.96  {
    1.97 -        int err = 0;
    1.98 +	int err = 0;
    1.99  
   1.100 -        *val = xenbus_read(dir, name, NULL);
   1.101 -        if (IS_ERR(*val)) {
   1.102 -                err = PTR_ERR(*val);
   1.103 -                *val = NULL;
   1.104 -        }
   1.105 -        return err;
   1.106 +	*val = xenbus_read(dir, name, NULL);
   1.107 +	if (IS_ERR(*val)) {
   1.108 +		err = PTR_ERR(*val);
   1.109 +		*val = NULL;
   1.110 +	}
   1.111 +	return err;
   1.112  }
   1.113  
   1.114  int xenbus_write_string(const char *dir, const char *name, const char *val)
   1.115  {
   1.116 -        return xenbus_write(dir, name, val, strlen(val) + 1);
   1.117 +	return xenbus_write(dir, name, val, strlen(val) + 1);
   1.118  }
   1.119  
   1.120  int xenbus_read_ulong(const char *dir, const char *name, unsigned long *val)
   1.121 @@ -149,23 +148,23 @@ int xenbus_read_ulong(const char *dir, c
   1.122  	data = xenbus_read(dir, name, &data_n);
   1.123  	if (IS_ERR(data)) {
   1.124  		err = PTR_ERR(data);
   1.125 -                goto out;
   1.126 -        }
   1.127 -        if (data_n <= 1) {
   1.128 -                err = -ENOENT;
   1.129 -                goto free_data;
   1.130 -        }
   1.131 -        *val = simple_strtoul(data, &end, 10);
   1.132 -        if (end != data + data_n - 1) {
   1.133 -                printk("XENBUS: Path %s/%s, bad parse of '%s' as ulong\n",
   1.134 -                       dir, name, data);
   1.135 -                err = -EINVAL;
   1.136 +		goto out;
   1.137 +	}
   1.138 +	if (data_n <= 1) {
   1.139 +		err = -ENOENT;
   1.140 +		goto free_data;
   1.141 +	}
   1.142 +	*val = simple_strtoul(data, &end, 10);
   1.143 +	if (end != data + data_n - 1) {
   1.144 +		printk("XENBUS: Path %s/%s, bad parse of '%s' as ulong\n",
   1.145 +		       dir, name, data);
   1.146 +		err = -EINVAL;
   1.147  	}
   1.148    free_data:
   1.149  	kfree(data);
   1.150    out:
   1.151 -        if (err)
   1.152 -                *val = 0;
   1.153 +	if (err)
   1.154 +		*val = 0;
   1.155  	return err;
   1.156  }
   1.157  
   1.158 @@ -173,7 +172,7 @@ int xenbus_write_ulong(const char *dir, 
   1.159  {
   1.160  	char data[32] = {};
   1.161  
   1.162 -        snprintf(data, sizeof(data), "%lu", val);
   1.163 +	snprintf(data, sizeof(data), "%lu", val);
   1.164  	return xenbus_write(dir, name, data, strlen(data) + 1);
   1.165  }
   1.166  
   1.167 @@ -186,23 +185,23 @@ int xenbus_read_long(const char *dir, co
   1.168  	data = xenbus_read(dir, name, &data_n);
   1.169  	if (IS_ERR(data)) {
   1.170  		err = PTR_ERR(data);
   1.171 -                goto out;
   1.172 -        }
   1.173 -        if (data_n <= 1) {
   1.174 -                err = -ENOENT;
   1.175 -                goto free_data;
   1.176 -        }
   1.177 -        *val = simple_strtol(data, &end, 10);
   1.178 -        if (end != data + data_n - 1) {
   1.179 -                printk("XENBUS: Path %s/%s, bad parse of '%s' as long\n",
   1.180 -                       dir, name, data);
   1.181 -                err = -EINVAL;
   1.182 -        }
   1.183 +		goto out;
   1.184 +	}
   1.185 +	if (data_n <= 1) {
   1.186 +		err = -ENOENT;
   1.187 +		goto free_data;
   1.188 +	}
   1.189 +	*val = simple_strtol(data, &end, 10);
   1.190 +	if (end != data + data_n - 1) {
   1.191 +		printk("XENBUS: Path %s/%s, bad parse of '%s' as long\n",
   1.192 +		       dir, name, data);
   1.193 +		err = -EINVAL;
   1.194 +	}
   1.195    free_data:
   1.196  	kfree(data);
   1.197    out:
   1.198 -        if (err)
   1.199 -                *val = 0;
   1.200 +	if (err)
   1.201 +		*val = 0;
   1.202  	return err;
   1.203  }
   1.204  
   1.205 @@ -210,7 +209,7 @@ int xenbus_write_long(const char *dir, c
   1.206  {
   1.207  	char data[32] = {};
   1.208  
   1.209 -        snprintf(data, sizeof(data), "%li", val);
   1.210 +	snprintf(data, sizeof(data), "%li", val);
   1.211  	return xenbus_write(dir, name, data, strlen(data) + 1);
   1.212  }
   1.213  
   1.214 @@ -222,42 +221,40 @@ int xenbus_write_long(const char *dir, c
   1.215   * Each X denotes a hex digit: 0..9, a..f, A..F.
   1.216   * Also supports using '-' as the separator instead of ':'.
   1.217   */
   1.218 -static int mac_aton(const char *macstr, unsigned int n, unsigned char mac[6]){
   1.219 -        int err = -EINVAL;
   1.220 -        int i, j;
   1.221 -        const char *p;
   1.222 -        char sep = 0;
   1.223 -        
   1.224 -        if(!macstr || n != MAC_LENGTH){
   1.225 -                goto exit;
   1.226 -        }
   1.227 -        for(i = 0, p = macstr; i < 6; i++){
   1.228 -                unsigned char d = 0;
   1.229 -                if(i){
   1.230 -                        if(!sep){
   1.231 -                                if(*p == ':' || *p == '-') sep = *p;
   1.232 -                        }
   1.233 -                        if(sep && *p == sep){
   1.234 -                                p++;
   1.235 -                        } else {
   1.236 -                                goto exit;
   1.237 -                        }
   1.238 -                }
   1.239 -                for(j = 0; j < 2; j++, p++){
   1.240 -                        if(j) d <<= 4;
   1.241 -                        if(isdigit(*p)){
   1.242 -                                d += *p - '0';
   1.243 -                        } else if(isxdigit(*p)){
   1.244 -                                d += toupper(*p) - 'A' + 10;
   1.245 -                        } else {
   1.246 -                                goto exit;
   1.247 -                        }
   1.248 -                }
   1.249 -                mac[i] = d;
   1.250 -        }
   1.251 -        err = 0;
   1.252 +static int mac_aton(const char *macstr, unsigned int n, unsigned char mac[6])
   1.253 +{
   1.254 +	int err = -EINVAL;
   1.255 +	int i, j;
   1.256 +	const char *p;
   1.257 +	char sep = 0;
   1.258 +	
   1.259 +	if (!macstr || n != MAC_LENGTH)
   1.260 +		goto exit;
   1.261 +	for (i = 0, p = macstr; i < 6; i++) {
   1.262 +		unsigned char d = 0;
   1.263 +		if (i) {
   1.264 +			if (!sep && (*p == ':' || *p == '-'))
   1.265 +				sep = *p;
   1.266 +			if (sep && *p == sep)
   1.267 +				p++;
   1.268 +			else
   1.269 +				goto exit;
   1.270 +		}
   1.271 +		for (j = 0; j < 2; j++, p++) {
   1.272 +			if (j)
   1.273 +				d <<= 4;
   1.274 +			if (isdigit(*p))
   1.275 +				d += *p - '0';
   1.276 +			else if (isxdigit(*p))
   1.277 +				d += toupper(*p) - 'A' + 10;
   1.278 +			else
   1.279 +				goto exit;
   1.280 +		}
   1.281 +		mac[i] = d;
   1.282 +	}
   1.283 +	err = 0;
   1.284    exit:
   1.285 -        return err;
   1.286 +	return err;
   1.287  }
   1.288  
   1.289  int xenbus_read_mac(const char *dir, const char *name, unsigned char mac[6])
   1.290 @@ -269,35 +266,35 @@ int xenbus_read_mac(const char *dir, con
   1.291  	data = xenbus_read(dir, name, &data_n);
   1.292  	if (IS_ERR(data)) {
   1.293  		err = PTR_ERR(data);
   1.294 -                goto out;
   1.295 -        }
   1.296 -        if (data_n <= 1) {
   1.297 -                err = -ENOENT;
   1.298 -                goto free_data;
   1.299 -        }
   1.300 -        err = mac_aton(data, data_n - 1, mac);
   1.301 -        if (err) {
   1.302 -                printk("XENBUS: Path %s/%s, bad parse of '%s' as mac\n",
   1.303 -                       dir, name, data);
   1.304 -                err = -EINVAL;
   1.305 -        }
   1.306 +		goto out;
   1.307 +	}
   1.308 +	if (data_n <= 1) {
   1.309 +		err = -ENOENT;
   1.310 +		goto free_data;
   1.311 +	}
   1.312 +	err = mac_aton(data, data_n - 1, mac);
   1.313 +	if (err) {
   1.314 +		printk("XENBUS: Path %s/%s, bad parse of '%s' as mac\n",
   1.315 +		       dir, name, data);
   1.316 +		err = -EINVAL;
   1.317 +	}
   1.318    free_data:
   1.319 -        kfree(data);
   1.320 +	kfree(data);
   1.321    out:
   1.322 -        if(err)
   1.323 -                memset(mac, 0, sizeof(mac));
   1.324 -        return err;
   1.325 +	if (err)
   1.326 +		memset(mac, 0, sizeof(mac));
   1.327 +	return err;
   1.328  }
   1.329  
   1.330  int xenbus_write_mac(const char *dir, const char *name, const unsigned char mac[6])
   1.331  {
   1.332 -        char buf[MAC_LENGTH + 1] = {};
   1.333 -        int buf_n = sizeof(buf);
   1.334 -        
   1.335 -        snprintf(buf, buf_n, "%02x:%02x:%02x:%02x:%02x:%02x",
   1.336 -                 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
   1.337 -        buf[buf_n - 1] = '\0';
   1.338 -        return xenbus_write(dir, name, buf, buf_n);
   1.339 +	char buf[MAC_LENGTH + 1] = {};
   1.340 +	int buf_n = sizeof(buf);
   1.341 +	
   1.342 +	snprintf(buf, buf_n, "%02x:%02x:%02x:%02x:%02x:%02x",
   1.343 +		 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
   1.344 +	buf[buf_n - 1] = '\0';
   1.345 +	return xenbus_write(dir, name, buf, buf_n);
   1.346  }
   1.347  
   1.348  /* Read event channel information from xenstore.
   1.349 @@ -310,30 +307,30 @@ int xenbus_write_mac(const char *dir, co
   1.350   */
   1.351  int xenbus_read_evtchn(const char *dir, const char *name, struct xenbus_evtchn *evtchn)
   1.352  {
   1.353 -        int err = 0;
   1.354 -        char *evtchn_path = xenbus_path(dir, name);
   1.355 +	int err = 0;
   1.356 +	char *evtchn_path = xenbus_path(dir, name);
   1.357  
   1.358 -        if (!evtchn_path) {
   1.359 -                err = -ENOMEM;
   1.360 -                goto out;
   1.361 -        }
   1.362 -        err = xenbus_read_ulong(evtchn_path, "dom1",  &evtchn->dom1);
   1.363 -        if(err)
   1.364 -                goto free_evtchn_path;
   1.365 -        err = xenbus_read_ulong(evtchn_path, "port1", &evtchn->port1);
   1.366 -        if(err)
   1.367 -                goto free_evtchn_path;
   1.368 -        err = xenbus_read_ulong(evtchn_path, "dom2",  &evtchn->dom2);
   1.369 -        if(err)
   1.370 -                goto free_evtchn_path;
   1.371 -        err = xenbus_read_ulong(evtchn_path, "port2", &evtchn->port2);
   1.372 +	if (!evtchn_path) {
   1.373 +		err = -ENOMEM;
   1.374 +		goto out;
   1.375 +	}
   1.376 +	err = xenbus_read_ulong(evtchn_path, "dom1",  &evtchn->dom1);
   1.377 +	if (err)
   1.378 +		goto free_evtchn_path;
   1.379 +	err = xenbus_read_ulong(evtchn_path, "port1", &evtchn->port1);
   1.380 +	if (err)
   1.381 +		goto free_evtchn_path;
   1.382 +	err = xenbus_read_ulong(evtchn_path, "dom2",  &evtchn->dom2);
   1.383 +	if (err)
   1.384 +		goto free_evtchn_path;
   1.385 +	err = xenbus_read_ulong(evtchn_path, "port2", &evtchn->port2);
   1.386  
   1.387    free_evtchn_path:
   1.388 -        kfree(evtchn_path);
   1.389 +	kfree(evtchn_path);
   1.390    out:
   1.391 -        if (err)
   1.392 -                *evtchn = (struct xenbus_evtchn){};
   1.393 -        return err;
   1.394 +	if (err)
   1.395 +		*evtchn = (struct xenbus_evtchn){};
   1.396 +	return err;
   1.397  }
   1.398  
   1.399  /* Write a message to 'dir'.
   1.400 @@ -342,66 +339,66 @@ int xenbus_read_evtchn(const char *dir, 
   1.401   */
   1.402  int xenbus_message(const char *dir, const char *val, ...)
   1.403  {
   1.404 -        static const char *mid_name = "@mid";
   1.405 -        va_list args;
   1.406 -        int err = 0;
   1.407 -        char *mid_path = NULL; 
   1.408 -        char *msg_path = NULL;
   1.409 -        char mid_str[32] = {};
   1.410 -        long mid = 0;
   1.411 -        int i;
   1.412 +	static const char *mid_name = "@mid";
   1.413 +	va_list args;
   1.414 +	int err = 0;
   1.415 +	char *mid_path = NULL; 
   1.416 +	char *msg_path = NULL;
   1.417 +	char mid_str[32] = {};
   1.418 +	long mid = 0;
   1.419 +	int i;
   1.420  
   1.421 -        va_start(args, val);
   1.422 -        mid_path = xenbus_path(dir, mid_name);
   1.423 -        if (!mid_path) {
   1.424 -                err = -ENOMEM;
   1.425 -                goto out;
   1.426 -        }
   1.427 -        err = xenbus_read_long(dir, mid_name, &mid);
   1.428 -        if(err != -ENOENT)
   1.429 -                goto out;
   1.430 -        mid++;
   1.431 -        err = xenbus_write_long(dir, mid_name, mid);
   1.432 -        if(err)
   1.433 -                goto out;
   1.434 -        sprintf(mid_str, "%li", mid);
   1.435 -        msg_path = xenbus_path(dir, mid_str);
   1.436 -        if (!mid_path) {
   1.437 -                err = -ENOMEM;
   1.438 -                goto out;
   1.439 -        }
   1.440 +	va_start(args, val);
   1.441 +	mid_path = xenbus_path(dir, mid_name);
   1.442 +	if (!mid_path) {
   1.443 +		err = -ENOMEM;
   1.444 +		goto out;
   1.445 +	}
   1.446 +	err = xenbus_read_long(dir, mid_name, &mid);
   1.447 +	if (err != -ENOENT)
   1.448 +		goto out;
   1.449 +	mid++;
   1.450 +	err = xenbus_write_long(dir, mid_name, mid);
   1.451 +	if (err)
   1.452 +		goto out;
   1.453 +	sprintf(mid_str, "%li", mid);
   1.454 +	msg_path = xenbus_path(dir, mid_str);
   1.455 +	if (!mid_path) {
   1.456 +		err = -ENOMEM;
   1.457 +		goto out;
   1.458 +	}
   1.459  
   1.460 -        for(i = 0; i < 16; i++){
   1.461 -                char *k, *v;
   1.462 -                k = va_arg(args, char *);
   1.463 -                if(!k)
   1.464 -                        break;
   1.465 -                v = va_arg(args, char *);
   1.466 -                if(!v)
   1.467 -                        break;
   1.468 -                err = xenbus_write_string(msg_path, k, v);
   1.469 -                if(err)
   1.470 -                        goto out;
   1.471 -        }
   1.472 -        err = xenbus_write_string(msg_path, NULL, val);
   1.473 +	for (i = 0; i < 16; i++) {
   1.474 +		char *k, *v;
   1.475 +		k = va_arg(args, char *);
   1.476 +		if (!k)
   1.477 +			break;
   1.478 +		v = va_arg(args, char *);
   1.479 +		if (!v)
   1.480 +			break;
   1.481 +		err = xenbus_write_string(msg_path, k, v);
   1.482 +		if (err)
   1.483 +			goto out;
   1.484 +	}
   1.485 +	err = xenbus_write_string(msg_path, NULL, val);
   1.486  
   1.487    out:
   1.488 -        kfree(msg_path);
   1.489 -        kfree(mid_path);
   1.490 -        va_end(args);
   1.491 -        return err;
   1.492 +	kfree(msg_path);
   1.493 +	kfree(mid_path);
   1.494 +	va_end(args);
   1.495 +	return err;
   1.496  }
   1.497  
   1.498  /* If something in array of ids matches this device, return it. */
   1.499  static const struct xenbus_device_id *
   1.500  match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
   1.501  {
   1.502 -	for( ; !streq(arr->devicetype, ""); arr++) {
   1.503 +	for (; !streq(arr->devicetype, ""); arr++) {
   1.504  		if (!streq(arr->devicetype, dev->devicetype))
   1.505  			continue;
   1.506  
   1.507 -		if (streq(arr->subtype, "")
   1.508 -		    || streq(arr->subtype, dev->subtype)) {
   1.509 +		if (streq(arr->subtype, "") ||
   1.510 +		    streq(arr->subtype, dev->subtype)) {
   1.511  			return arr;
   1.512  		}
   1.513  	}
   1.514 @@ -427,63 +424,63 @@ static struct bus_type xenbus_type = {
   1.515  
   1.516  /* Bus type for backend drivers. */
   1.517  static struct bus_type xenback_type = {
   1.518 -        .name  = "xenback",
   1.519 -        .match = xenbus_match,
   1.520 +	.name  = "xenback",
   1.521 +	.match = xenbus_match,
   1.522  };
   1.523  
   1.524  struct xenbus_for_dev {
   1.525 -        int (*fn)(struct xenbus_device *, void *);
   1.526 -        void *data;
   1.527 +	int (*fn)(struct xenbus_device *, void *);
   1.528 +	void *data;
   1.529  };
   1.530  
   1.531  static int for_dev(struct device *_dev, void *_data)
   1.532  {
   1.533 -        struct xenbus_device *dev = to_xenbus_device(_dev);
   1.534 -        struct xenbus_for_dev *data = _data;
   1.535 -        dev = to_xenbus_device(_dev);
   1.536 -        return data->fn(dev, data->data);
   1.537 +	struct xenbus_device *dev = to_xenbus_device(_dev);
   1.538 +	struct xenbus_for_dev *data = _data;
   1.539 +	dev = to_xenbus_device(_dev);
   1.540 +	return data->fn(dev, data->data);
   1.541  }
   1.542  
   1.543  int xenbus_for_each_dev(struct xenbus_device * start, void * data,
   1.544 -                        int (*fn)(struct xenbus_device *, void *))
   1.545 +			int (*fn)(struct xenbus_device *, void *))
   1.546  {
   1.547 -        struct xenbus_for_dev for_data = {
   1.548 -                .fn = fn,
   1.549 -                .data = data,
   1.550 -        };
   1.551 -        if(!fn)
   1.552 -                return -EINVAL;
   1.553 -        printk("%s> data=%p fn=%p for_data=%p\n", __FUNCTION__,
   1.554 -               data, fn, &for_data);
   1.555 -        return bus_for_each_dev(&xenbus_type, 
   1.556 -                                (start ? &start->dev : NULL),
   1.557 -                                &for_data, for_dev);
   1.558 +	struct xenbus_for_dev for_data = {
   1.559 +		.fn = fn,
   1.560 +		.data = data,
   1.561 +	};
   1.562 +	if (!fn)
   1.563 +		return -EINVAL;
   1.564 +	printk("%s> data=%p fn=%p for_data=%p\n", __FUNCTION__,
   1.565 +	       data, fn, &for_data);
   1.566 +	return bus_for_each_dev(&xenbus_type, 
   1.567 +				(start ? &start->dev : NULL),
   1.568 +				&for_data, for_dev);
   1.569  }
   1.570  
   1.571  struct xenbus_for_drv {
   1.572 -        int (*fn)(struct xenbus_driver *, void *);
   1.573 -        void *data;
   1.574 +	int (*fn)(struct xenbus_driver *, void *);
   1.575 +	void *data;
   1.576  };
   1.577  
   1.578  static int for_drv(struct device_driver *_drv, void *_data)
   1.579  {
   1.580 -        struct xenbus_driver *drv = to_xenbus_driver(_drv);
   1.581 -        struct xenbus_for_drv *data = _data;
   1.582 -        return data->fn(drv, data->data);
   1.583 +	struct xenbus_driver *drv = to_xenbus_driver(_drv);
   1.584 +	struct xenbus_for_drv *data = _data;
   1.585 +	return data->fn(drv, data->data);
   1.586  }
   1.587  
   1.588  int xenbus_for_each_drv(struct xenbus_driver * start, void * data,
   1.589 -                        int (*fn)(struct xenbus_driver *, void *))
   1.590 +			int (*fn)(struct xenbus_driver *, void *))
   1.591  {
   1.592 -        struct xenbus_for_drv for_data = {
   1.593 -                .fn = fn,
   1.594 -                .data = data,
   1.595 -        };
   1.596 -        if(!fn)
   1.597 -                return -EINVAL;
   1.598 -        return bus_for_each_drv(&xenbus_type,
   1.599 -                                (start ? &start->driver: NULL),
   1.600 -                                &for_data, for_drv);
   1.601 +	struct xenbus_for_drv for_data = {
   1.602 +		.fn = fn,
   1.603 +		.data = data,
   1.604 +	};
   1.605 +	if (!fn)
   1.606 +		return -EINVAL;
   1.607 +	return bus_for_each_drv(&xenbus_type,
   1.608 +				(start ? &start->driver: NULL),
   1.609 +				&for_data, for_drv);
   1.610  }
   1.611  
   1.612  static int xenbus_dev_probe(struct device *_dev)
   1.613 @@ -506,17 +503,17 @@ static int xenbus_dev_remove(struct devi
   1.614  	struct xenbus_device *dev = to_xenbus_device(_dev);
   1.615  	struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
   1.616  
   1.617 -        if(!drv->remove)
   1.618 -                return 0;
   1.619 -        return drv->remove(dev);
   1.620 +	if (!drv->remove)
   1.621 +		return 0;
   1.622 +	return drv->remove(dev);
   1.623  }
   1.624  
   1.625  int xenbus_register_driver(struct xenbus_driver *drv)
   1.626  {
   1.627 -        int err = 0;
   1.628 +	int err = 0;
   1.629  
   1.630 -        printk("%s> frontend driver %p %s\n", __FUNCTION__,
   1.631 -               drv, drv->name);
   1.632 +	printk("%s> frontend driver %p %s\n", __FUNCTION__,
   1.633 +	       drv, drv->name);
   1.634  	drv->driver.name = drv->name;
   1.635  	drv->driver.bus = &xenbus_type;
   1.636  	drv->driver.owner = drv->owner;
   1.637 @@ -524,12 +521,12 @@ int xenbus_register_driver(struct xenbus
   1.638  	drv->driver.remove = xenbus_dev_remove;
   1.639  
   1.640  	err = driver_register(&drv->driver);
   1.641 -        if(err == 0 && xs_init_done && drv->connect){
   1.642 -                printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.643 -                       drv, drv->name);
   1.644 -                drv->connect(drv);
   1.645 -        }
   1.646 -        return err;
   1.647 +	if (err == 0 && xs_init_done && drv->connect) {
   1.648 +		printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.649 +		       drv, drv->name);
   1.650 +		drv->connect(drv);
   1.651 +	}
   1.652 +	return err;
   1.653  }
   1.654  
   1.655  void xenbus_unregister_driver(struct xenbus_driver *drv)
   1.656 @@ -558,14 +555,13 @@ static int xenbus_probe_device(const cha
   1.657  	}
   1.658  
   1.659  	err = xenbus_read_long(nodename, XENBUS_DEVICE_ID, &id);
   1.660 -	if (err == -ENOENT) {
   1.661 +	if (err == -ENOENT)
   1.662  		id = 0;
   1.663 -        } else if (err != 0) {
   1.664 +	else if (err != 0)
   1.665  		goto free_devicetype;
   1.666 -        }
   1.667  
   1.668  	dprintf("> devicetype='%s' name='%s' id=%ld\n", devicetype, name, id);
   1.669 -        /* FIXME: This could be a rescan. Don't re-register existing devices. */
   1.670 +	/* FIXME: This could be a rescan. Don't re-register existing devices. */
   1.671  
   1.672  	/* Add space for the strings. */
   1.673  	xendev_n = sizeof(*xendev) + strlen(nodename) + strlen(devicetype) + 2;
   1.674 @@ -576,7 +572,7 @@ static int xenbus_probe_device(const cha
   1.675  	}
   1.676  	memset(xendev, 0, xendev_n);
   1.677  
   1.678 -        snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s-%s", devicetype, name);
   1.679 +	snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s-%s", devicetype, name);
   1.680  	xendev->dev.bus = &xenbus_type;
   1.681  
   1.682  	xendev->id = id;
   1.683 @@ -588,14 +584,13 @@ static int xenbus_probe_device(const cha
   1.684  	strcpy(xendev->devicetype, devicetype);
   1.685  
   1.686  	/* Register with generic device framework. */
   1.687 -        printk("XENBUS: Registering device %s\n", xendev->dev.bus_id);
   1.688 +	printk("XENBUS: Registering device %s\n", xendev->dev.bus_id);
   1.689  	err = device_register(&xendev->dev);
   1.690 -        if (err) {
   1.691 -                printk("XENBUS: Registering device %s: error %i\n",
   1.692 -                       xendev->dev.bus_id, err);
   1.693 -        }
   1.694 -	if (err)
   1.695 +	if (err) {
   1.696 +		printk("XENBUS: Registering device %s: error %i\n",
   1.697 +		       xendev->dev.bus_id, err);
   1.698  		kfree(xendev);
   1.699 +	}
   1.700  
   1.701  free_devicetype:
   1.702  	kfree(devicetype);
   1.703 @@ -682,7 +677,7 @@ static int xenbus_probe_backend(const ch
   1.704  	}
   1.705  
   1.706  	dprintf("> devicetype='%s'\n", devicetype);
   1.707 -        /* FIXME: This could be a rescan. Don't re-register existing devices. */
   1.708 +	/* FIXME: This could be a rescan. Don't re-register existing devices. */
   1.709  
   1.710  	/* Add space for the strings. */
   1.711  	xendev_n = sizeof(*xendev) + strlen(nodename) + strlen(devicetype) + 2;
   1.712 @@ -693,7 +688,7 @@ static int xenbus_probe_backend(const ch
   1.713  	}
   1.714  	memset(xendev, 0, xendev_n);
   1.715  
   1.716 -        snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s", devicetype);
   1.717 +	snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s", devicetype);
   1.718  	xendev->dev.bus = &xenback_type;
   1.719  
   1.720  	/* Copy the strings into the extra space. */
   1.721 @@ -703,14 +698,13 @@ static int xenbus_probe_backend(const ch
   1.722  	strcpy(xendev->devicetype, devicetype);
   1.723  
   1.724  	/* Register with generic device framework. */
   1.725 -        printk("XENBUS: Registering backend %s\n", xendev->dev.bus_id);
   1.726 +	printk("XENBUS: Registering backend %s\n", xendev->dev.bus_id);
   1.727  	err = device_register(&xendev->dev);
   1.728 -        if (err) {
   1.729 -                printk("XENBUS: Registering device %s: error %i\n",
   1.730 -                       xendev->dev.bus_id, err);
   1.731 -        }
   1.732 -	if (err)
   1.733 +	if (err) {
   1.734 +		printk("XENBUS: Registering device %s: error %i\n",
   1.735 +		       xendev->dev.bus_id, err);
   1.736  		kfree(xendev);
   1.737 +	}
   1.738  
   1.739  free_devicetype:
   1.740  	kfree(devicetype);
   1.741 @@ -747,10 +741,10 @@ unlock:
   1.742  
   1.743  int xenbus_register_backend(struct xenbus_driver *drv)
   1.744  {
   1.745 -        int err = 0;
   1.746 +	int err = 0;
   1.747  
   1.748 -        printk("%s> backend driver %p %s\n", __FUNCTION__,
   1.749 -               drv, drv->name);
   1.750 +	printk("%s> backend driver %p %s\n", __FUNCTION__,
   1.751 +	       drv, drv->name);
   1.752  	drv->driver.name = drv->name;
   1.753  	drv->driver.bus = &xenback_type;
   1.754  	drv->driver.owner = drv->owner;
   1.755 @@ -758,12 +752,12 @@ int xenbus_register_backend(struct xenbu
   1.756  	drv->driver.remove = xenbus_dev_remove;
   1.757  
   1.758  	err = driver_register(&drv->driver);
   1.759 -        if(err == 0 && xs_init_done && drv->connect){
   1.760 -                printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.761 -                       drv, drv->name);
   1.762 -                drv->connect(drv);
   1.763 -        }
   1.764 -        return err;
   1.765 +	if (err == 0 && xs_init_done && drv->connect) {
   1.766 +		printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.767 +		       drv, drv->name);
   1.768 +		drv->connect(drv);
   1.769 +	}
   1.770 +	return err;
   1.771  }
   1.772  
   1.773  void xenbus_unregister_backend(struct xenbus_driver *drv)
   1.774 @@ -772,17 +766,17 @@ void xenbus_unregister_backend(struct xe
   1.775  }
   1.776  
   1.777  int xenbus_for_each_backend(struct xenbus_driver * start, void * data,
   1.778 -                            int (*fn)(struct xenbus_driver *, void *))
   1.779 +			    int (*fn)(struct xenbus_driver *, void *))
   1.780  {
   1.781 -        struct xenbus_for_drv for_data = {
   1.782 -                .fn = fn,
   1.783 -                .data = data,
   1.784 -        };
   1.785 -        if(!fn)
   1.786 -                return -EINVAL;
   1.787 -        return bus_for_each_drv(&xenback_type,
   1.788 -                                (start ? &start->driver: NULL),
   1.789 -                                &for_data, for_drv);
   1.790 +	struct xenbus_for_drv for_data = {
   1.791 +		.fn = fn,
   1.792 +		.data = data,
   1.793 +	};
   1.794 +	if (!fn)
   1.795 +		return -EINVAL;
   1.796 +	return bus_for_each_drv(&xenback_type,
   1.797 +				(start ? &start->driver: NULL),
   1.798 +				&for_data, for_drv);
   1.799  }
   1.800  
   1.801  static void test_callback(struct xenbus_watch *w, const char *node)
   1.802 @@ -792,67 +786,68 @@ static void test_callback(struct xenbus_
   1.803  
   1.804  static void test_watch(void)
   1.805  {
   1.806 -        static int init_done = 0;
   1.807 +	static int init_done = 0;
   1.808  	static struct xenbus_watch watch = { .node = "/", 
   1.809  					     .priority = 0, 
   1.810  					     .callback = test_callback };
   1.811  
   1.812 -        if(init_done) return;
   1.813 +	if (init_done)
   1.814 +		return;
   1.815  	printk("registering watch %lX = %i\n",
   1.816 -               (long)&watch,
   1.817 +	       (long)&watch,
   1.818  	       register_xenbus_watch(&watch));
   1.819 -        init_done = 1;
   1.820 +	init_done = 1;
   1.821  }
   1.822  
   1.823  static int xenbus_driver_connect(struct xenbus_driver *drv, void *data)
   1.824  {
   1.825 -        printk("%s> driver %p %s\n", __FUNCTION__, drv, drv->name);
   1.826 -        if (drv->connect) {
   1.827 -                printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.828 -                       drv, drv->name);
   1.829 -                drv->connect(drv);
   1.830 -        }
   1.831 -        printk("%s< driver %p %s\n", __FUNCTION__, drv, drv->name);
   1.832 -        return 0;
   1.833 +	printk("%s> driver %p %s\n", __FUNCTION__, drv, drv->name);
   1.834 +	if (drv->connect) {
   1.835 +		printk("%s> connecting driver %p %s\n", __FUNCTION__,
   1.836 +		       drv, drv->name);
   1.837 +		drv->connect(drv);
   1.838 +	}
   1.839 +	printk("%s< driver %p %s\n", __FUNCTION__, drv, drv->name);
   1.840 +	return 0;
   1.841  }
   1.842  
   1.843  int do_xenbus_connect(void *unused)
   1.844  {
   1.845  	int err = 0;
   1.846  
   1.847 -        printk("%s> xs_init_done=%d\n", __FUNCTION__, xs_init_done);
   1.848 +	printk("%s> xs_init_done=%d\n", __FUNCTION__, xs_init_done);
   1.849  	if (xs_init_done)
   1.850 -                goto exit;
   1.851 -        /* Initialize xenstore comms unless already done. */
   1.852 -        printk("store_evtchn = %i\n", xen_start_info.store_evtchn);
   1.853 -        err = xs_init();
   1.854 -        if (err) {
   1.855 -                printk("XENBUS: Error initializing xenstore comms:"
   1.856 -                       " %i\n", err);
   1.857 -                goto exit;
   1.858 -        }
   1.859 -        xs_init_done = 1;
   1.860 +		goto exit;
   1.861 +	/* Initialize xenstore comms unless already done. */
   1.862 +	printk("store_evtchn = %i\n", xen_start_info.store_evtchn);
   1.863 +	err = xs_init();
   1.864 +	if (err) {
   1.865 +		printk("XENBUS: Error initializing xenstore comms:"
   1.866 +		       " %i\n", err);
   1.867 +		goto exit;
   1.868 +	}
   1.869 +	xs_init_done = 1;
   1.870  
   1.871 -        /* Notify drivers that xenstore has connected. */
   1.872 -        test_watch();
   1.873 -        printk("%s> connect drivers...\n", __FUNCTION__);
   1.874 -        xenbus_for_each_drv(NULL, NULL, xenbus_driver_connect);
   1.875 -        printk("%s> connect backends...\n", __FUNCTION__);
   1.876 -        xenbus_for_each_backend(NULL, NULL, xenbus_driver_connect);
   1.877 -        
   1.878 -        /* Enumerate devices and backends in xenstore. */
   1.879 +	/* Notify drivers that xenstore has connected. */
   1.880 +	test_watch();
   1.881 +	printk("%s> connect drivers...\n", __FUNCTION__);
   1.882 +	xenbus_for_each_drv(NULL, NULL, xenbus_driver_connect);
   1.883 +	printk("%s> connect backends...\n", __FUNCTION__);
   1.884 +	xenbus_for_each_backend(NULL, NULL, xenbus_driver_connect);
   1.885 +	
   1.886 +	/* Enumerate devices and backends in xenstore. */
   1.887  	xenbus_probe_devices(XENBUS_DEVICE_DIR);
   1.888 -        xenbus_probe_backends(XENBUS_BACKEND_DIR);
   1.889 +	xenbus_probe_backends(XENBUS_BACKEND_DIR);
   1.890  
   1.891  exit:
   1.892 -        printk("%s< err=%d\n", __FUNCTION__, err);
   1.893 -        return err;
   1.894 +	printk("%s< err=%d\n", __FUNCTION__, err);
   1.895 +	return err;
   1.896  }
   1.897  
   1.898  static int __init xenbus_probe_init(void)
   1.899  {
   1.900 -        bus_register(&xenbus_type);
   1.901 -        bus_register(&xenback_type);
   1.902 +	bus_register(&xenbus_type);
   1.903 +	bus_register(&xenback_type);
   1.904  
   1.905  	if (!xen_start_info.store_evtchn)
   1.906  		return 0;