PERFORCE change 89400 for review

Scott Long scottl at FreeBSD.org
Sun Jan 8 21:00:54 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=89400

Change 89400 by scottl at scottl-junior on 2006/01/09 05:00:21

	Reverse merge whitespace fixes.

Affected files ...

.. //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_probe.c#3 integrate

Differences ...

==== //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_probe.c#3 (text+ko) ====

@@ -98,39 +98,39 @@
 static const struct xenbus_device_id *
 match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
 {
-		for (; !streq(arr->devicetype, ""); arr++) {
-				if (streq(arr->devicetype, dev->devicetype))
-						return arr;
-		}
-		return NULL;
+	for (; !streq(arr->devicetype, ""); arr++) {
+		if (streq(arr->devicetype, dev->devicetype))
+			return arr;
+	}
+	return NULL;
 }
 
 #if 0
 static int xenbus_match(device_t _dev)
 {
-		struct xenbus_driver *drv; 
-		struct xenbus_device *dev;
-	
-		dev = device_get_softc(_dev);
-		drv = dev->driver;
+	struct xenbus_driver *drv; 
+	struct xenbus_device *dev;
+
+	dev = device_get_softc(_dev);
+	drv = dev->driver;
 
-		if (!drv->ids)
-				return 0;
+	if (!drv->ids)
+		return 0;
 
-		return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
+	return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
 }
 #endif
 
 struct xen_bus_type
 {
-		char *root;
-		unsigned int levels;
-		int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
-		int (*probe)(const char *type, const char *dir, int unit);
-		struct xendev_list_head *bus;
+	char *root;
+	unsigned int levels;
+	int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
+	int (*probe)(const char *type, const char *dir, int unit);
+	struct xendev_list_head *bus;
 #if 0
-		struct bus_type bus;
-		struct device dev;
+	struct bus_type bus;
+	struct device dev;
 #endif 
 };
 
@@ -138,19 +138,19 @@
 /* device/<type>/<id> => <type>-<id> */
 static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
-		nodename = strchr(nodename, '/');
-		if (!nodename || strlen(nodename + 1) >= BUS_ID_SIZE) {
-				printk(KERN_WARNING "XENBUS: bad frontend %s\n", nodename);
-				return EINVAL;
-		}
+	nodename = strchr(nodename, '/');
+	if (!nodename || strlen(nodename + 1) >= BUS_ID_SIZE) {
+		printk(KERN_WARNING "XENBUS: bad frontend %s\n", nodename);
+		return EINVAL;
+	}
 
-		strlcpy(bus_id, nodename + 1, BUS_ID_SIZE);
-		if (!strchr(bus_id, '/')) {
-				printk(KERN_WARNING "XENBUS: bus_id %s no slash\n", bus_id);
-				return EINVAL;
-		}
-		*strchr(bus_id, '/') = '-';
-		return 0;
+	strlcpy(bus_id, nodename + 1, BUS_ID_SIZE);
+	if (!strchr(bus_id, '/')) {
+		printk(KERN_WARNING "XENBUS: bus_id %s no slash\n", bus_id);
+		return EINVAL;
+	}
+	*strchr(bus_id, '/') = '-';
+	return 0;
 }
 
 
@@ -158,843 +158,832 @@
 read_otherend_details(struct xenbus_device *xendev, char *id_node, 
 					  char *path_node)
 {
-		int err = xenbus_gather(NULL, xendev->nodename,
-								id_node, "%i", &xendev->otherend_id,
-								path_node, NULL, &xendev->otherend,
-								NULL);
-		if (err) {
-				xenbus_dev_fatal(xendev, err,
-								 "reading other end details from %s",
-								 xendev->nodename);
-				return err;
-		}
-		if (strlen(xendev->otherend) == 0 ||
-			!xenbus_exists(NULL, xendev->otherend, "")) {
-				xenbus_dev_fatal(xendev, ENOENT, "missing other end from %s",
-								 xendev->nodename);
-				kfree(xendev->otherend);
-				xendev->otherend = NULL;
-				return ENOENT;
-		}
+	int err = xenbus_gather(NULL, xendev->nodename,
+				id_node, "%i", &xendev->otherend_id,
+				path_node, NULL, &xendev->otherend,
+				NULL);
+	if (err) {
+		xenbus_dev_fatal(xendev, err,
+				 "reading other end details from %s",
+				 xendev->nodename);
+		return err;
+	}
+	if (strlen(xendev->otherend) == 0 ||
+	    !xenbus_exists(NULL, xendev->otherend, "")) {
+		xenbus_dev_fatal(xendev, ENOENT, "missing other end from %s",
+						 xendev->nodename);
+		kfree(xendev->otherend);
+		xendev->otherend = NULL;
+			return ENOENT;
+	}
 
-		return 0;
+	return 0;
 }
 
 
 static int read_backend_details(struct xenbus_device *xendev)
 {
-		return read_otherend_details(xendev, "backend-id", "backend");
+	return read_otherend_details(xendev, "backend-id", "backend");
 }
 
 
 static int read_frontend_details(struct xenbus_device *xendev)
 {
-		return read_otherend_details(xendev, "frontend-id", "frontend");
+	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
 
 static void free_otherend_details(struct xenbus_device *dev)
 {
-		kfree(dev->otherend);
-		dev->otherend = NULL;
+	kfree(dev->otherend);
+	dev->otherend = NULL;
 }
 
 
 static void free_otherend_watch(struct xenbus_device *dev)
 {
-		if (dev->otherend_watch.node) {
-				unregister_xenbus_watch(&dev->otherend_watch);
-				kfree(dev->otherend_watch.node);
-				dev->otherend_watch.node = NULL;
-		}
+	if (dev->otherend_watch.node) {
+		unregister_xenbus_watch(&dev->otherend_watch);
+		kfree(dev->otherend_watch.node);
+		dev->otherend_watch.node = NULL;
+	}
 }
 
 /* Bus type for frontend drivers. */
 static int xenbus_probe_frontend(const char *type, const char *name, int unit);
 static struct xen_bus_type xenbus_frontend = {
-		.root = "device",
-		.levels = 2, 		/* device/type/<id> */
-		.get_bus_id = frontend_bus_id,
-		.probe = xenbus_probe_frontend,
-		.bus = &xenbus_device_frontend_list,
+	.root = "device",
+	.levels = 2, 		/* device/type/<id> */
+	.get_bus_id = frontend_bus_id,
+	.probe = xenbus_probe_frontend,
+	.bus = &xenbus_device_frontend_list,
 #if 0
-		/* this initialization needs to happen dynamically */
-		.bus = {
-				.name  = "xen",
-				.match = xenbus_match,
-		},
-		.dev = {
-				.bus_id = "xen",
-		},
+	/* this initialization needs to happen dynamically */
+	.bus = {
+		.name  = "xen",
+		.match = xenbus_match,
+	},
+	.dev = {
+		.bus_id = "xen",
+	},
 #endif
 };
 
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
-		int domid, err;
-		const char *devid, *type; 
-		char *frontend;
-		unsigned int typelen;
+	int domid, err;
+	const char *devid, *type; 
+	char *frontend;
+	unsigned int typelen;
 
-		type = strchr(nodename, '/');
-		if (!type)
-				return EINVAL;
-		type++;
-		typelen = strcspn(type, "/");
-		if (!typelen || type[typelen] != '/')
-				return EINVAL;
+	type = strchr(nodename, '/');
+	if (!type)
+		return EINVAL;
+	type++;
+	typelen = strcspn(type, "/");
+	if (!typelen || type[typelen] != '/')
+		return EINVAL;
 
-		devid = strrchr(nodename, '/') + 1;
+	devid = strrchr(nodename, '/') + 1;
 
-		err = xenbus_gather(NULL, nodename, "frontend-id", "%i", &domid,
-							"frontend", NULL, &frontend,
-							NULL);
-		if (err)
-				return err;
-		if (strlen(frontend) == 0)
-				err = ERANGE;
+	err = xenbus_gather(NULL, nodename, "frontend-id", "%i", &domid,
+			    "frontend", NULL, &frontend, NULL);
+	if (err)
+		return err;
+	if (strlen(frontend) == 0)
+		err = ERANGE;
 
-		if (!err && !xenbus_exists(NULL, frontend, ""))
-				err = ENOENT;
+	if (!err && !xenbus_exists(NULL, frontend, ""))
+		err = ENOENT;
 
-		if (err) {
-				kfree(frontend);
-				return err;
-		}
+	if (err) {
+		kfree(frontend);
+		return err;
+	}
 
-		if (snprintf(bus_id, BUS_ID_SIZE,
-					 "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
-				return ENOSPC;
-		return 0;
+	if (snprintf(bus_id, BUS_ID_SIZE,
+		     "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
+		return ENOSPC;
+	return 0;
 }
 #if 0
 static int xenbus_hotplug_backend(device_t dev, char **envp,
-								  int num_envp, char *buffer, int buffer_size)
+				  int num_envp, char *buffer, int buffer_size)
 {
-		panic("implement me");
+	panic("implement me");
 #if 0
-		struct xenbus_device *xdev;
-		struct xenbus_driver *drv = NULL;
-		int i = 0;
-		int length = 0;
-		char *basepath_end;
-		char *frontend_id;
+	struct xenbus_device *xdev;
+	struct xenbus_driver *drv = NULL;
+	int i = 0;
+	int length = 0;
+	char *basepath_end;
+	char *frontend_id;
 
-		DPRINTK("");
+	DPRINTK("");
 
-		if (dev == NULL)
-				return ENODEV;
+	if (dev == NULL)
+		return ENODEV;
 
-		xdev = to_xenbus_device(dev);
-		if (xdev == NULL)
-				return ENODEV;
+	xdev = to_xenbus_device(dev);
+	if (xdev == NULL)
+		return ENODEV;
 
-		if (dev->driver)
-				drv = to_xenbus_driver(dev->driver);
+	if (dev->driver)
+		drv = to_xenbus_driver(dev->driver);
 
-		/* stuff we want to pass to /sbin/hotplug */
-		add_hotplug_env_var(envp, num_envp, &i,
-							buffer, buffer_size, &length,
-							"XENBUS_TYPE=%s", xdev->devicetype);
+	/* stuff we want to pass to /sbin/hotplug */
+	add_hotplug_env_var(envp, num_envp, &i,
+			    buffer, buffer_size, &length,
+			    "XENBUS_TYPE=%s", xdev->devicetype);
 
-		add_hotplug_env_var(envp, num_envp, &i,
-							buffer, buffer_size, &length,
-							"XENBUS_PATH=%s", xdev->nodename);
+	add_hotplug_env_var(envp, num_envp, &i,
+			    buffer, buffer_size, &length,
+			    "XENBUS_PATH=%s", xdev->nodename);
 
-		add_hotplug_env_var(envp, num_envp, &i,
-							buffer, buffer_size, &length,
-							"XENBUS_BASE_PATH=%s", xdev->nodename);
+	add_hotplug_env_var(envp, num_envp, &i,
+			    buffer, buffer_size, &length,
+			    "XENBUS_BASE_PATH=%s", xdev->nodename);
 
-		basepath_end = strrchr(envp[i - 1], '/');
-		length -= strlen(basepath_end);
-		*basepath_end = '\0';
-		basepath_end = strrchr(envp[i - 1], '/');
-		length -= strlen(basepath_end);
-		*basepath_end = '\0';
+	basepath_end = strrchr(envp[i - 1], '/');
+	length -= strlen(basepath_end);
+	*basepath_end = '\0';
+	basepath_end = strrchr(envp[i - 1], '/');
+	length -= strlen(basepath_end);
+	*basepath_end = '\0';
 
-		basepath_end++;
-		frontend_id = kmalloc(strlen(basepath_end) + 1, GFP_KERNEL);
-		strcpy(frontend_id, basepath_end);
-		add_hotplug_env_var(envp, num_envp, &i,
-							buffer, buffer_size, &length,
-							"XENBUS_FRONTEND_ID=%s", frontend_id);
-		kfree(frontend_id);
+	basepath_end++;
+	frontend_id = kmalloc(strlen(basepath_end) + 1, GFP_KERNEL);
+	strcpy(frontend_id, basepath_end);
+	add_hotplug_env_var(envp, num_envp, &i,
+			    buffer, buffer_size, &length,
+			    "XENBUS_FRONTEND_ID=%s", frontend_id);
+	kfree(frontend_id);
 
-		/* terminate, set to next free slot, shrink available space */
-		envp[i] = NULL;
-		envp = &envp[i];
-		num_envp -= i;
-		buffer = &buffer[length];
-		buffer_size -= length;
+	/* terminate, set to next free slot, shrink available space */
+	envp[i] = NULL;
+	envp = &envp[i];
+	num_envp -= i;
+	buffer = &buffer[length];
+	buffer_size -= length;
 
-		if (drv && drv->hotplug)
-				return drv->hotplug(xdev, envp, num_envp, buffer,
-									buffer_size);
+	if (drv && drv->hotplug)
+		return drv->hotplug(xdev, envp, num_envp, buffer, buffer_size);
 
 #endif
-		return 0;
+	return 0;
 }
 #endif
 
 static int xenbus_probe_backend(const char *type, const char *domid, int unit);
 static struct xen_bus_type xenbus_backend = {
-		.root = "backend",
-		.levels = 3, 		/* backend/type/<frontend>/<id> */
-		.get_bus_id = backend_bus_id,
-		.probe = xenbus_probe_backend,
-		/* at init time */
-		.bus = &xenbus_device_backend_list,
+	.root = "backend",
+	.levels = 3, 		/* backend/type/<frontend>/<id> */
+	.get_bus_id = backend_bus_id,
+	.probe = xenbus_probe_backend,
+	/* at init time */
+	.bus = &xenbus_device_backend_list,
 #if 0
-		.bus = {
-				.name  = "xen-backend",
-				.match = xenbus_match,
-				.hotplug = xenbus_hotplug_backend,
-		},
-		.dev = {
-				.bus_id = "xen-backend",
-		},
+	.bus = {
+		.name  = "xen-backend",
+		.match = xenbus_match,
+		.hotplug = xenbus_hotplug_backend,
+	},
+	.dev = {
+		.bus_id = "xen-backend",
+	},
 #endif
 };
 
 
 static void otherend_changed(struct xenbus_watch *watch,
-							 const char **vec, unsigned int len)
+			     const char **vec, unsigned int len)
 {
 
+	struct xenbus_device *dev = (struct xenbus_device *)watch;
+	struct xenbus_driver *drv = dev->driver;
+	XenbusState state;
+		
+	/* Protect us against watches firing on old details when the otherend
+	   details change, say immediately after a resume. */
+	if (!dev->otherend || strncmp(dev->otherend, vec[XS_WATCH_PATH],
+	    strlen(dev->otherend))) {
+		DPRINTK("Ignoring watch at %s", vec[XS_WATCH_PATH]);
+		return;
+	}
+
+	state = xenbus_read_driver_state(dev->otherend);
 
-		struct xenbus_device *dev = (struct xenbus_device *)watch;
-		struct xenbus_driver *drv = dev->driver;
-		XenbusState state;
-		
-		/* Protect us against watches firing on old details when the otherend
-		   details change, say immediately after a resume. */
-		if (!dev->otherend ||
-			strncmp(dev->otherend, vec[XS_WATCH_PATH],
-					strlen(dev->otherend))) {
-				DPRINTK("Ignoring watch at %s", vec[XS_WATCH_PATH]);
-				return;
-		}
+	DPRINTK("state is %d, %s, %s", state, dev->otherend_watch.node,
+		vec[XS_WATCH_PATH]);
+	if (drv->otherend_changed)
+		drv->otherend_changed(dev, state);
 
-		state = xenbus_read_driver_state(dev->otherend);
-		
-		DPRINTK("state is %d, %s, %s",
-				state, dev->otherend_watch.node, vec[XS_WATCH_PATH]);
-		if (drv->otherend_changed)
-				drv->otherend_changed(dev, state);
-	
 }
 
 
 static int talk_to_otherend(struct xenbus_device *dev)
 {
-		struct xenbus_driver *drv;
+	struct xenbus_driver *drv;
 
-		drv = dev->driver;
+	drv = dev->driver;
 
-		free_otherend_watch(dev);
-		free_otherend_details(dev);
+	free_otherend_watch(dev);
+	free_otherend_details(dev);
 
-		return drv->read_otherend_details(dev);
-
-
+	return drv->read_otherend_details(dev);
 }
 
 static int watch_otherend(struct xenbus_device *dev)
 {
-		return xenbus_watch_path2(dev, dev->otherend, "state",
-								  &dev->otherend_watch, otherend_changed);
+	return xenbus_watch_path2(dev, dev->otherend, "state",
+				  &dev->otherend_watch, otherend_changed);
 }
 
 static int 
 xenbus_dev_probe(struct xenbus_device *dev)
 {
-		struct xenbus_driver *drv = dev->driver;
-		const struct xenbus_device_id *id;
-		int err;
+	struct xenbus_driver *drv = dev->driver;
+	const struct xenbus_device_id *id;
+	int err;
 		
-		DPRINTK("");
+	DPRINTK("");
 		
-		if (!drv->probe) {
-				err = -ENODEV;
-				goto fail;
-		}
+	if (!drv->probe) {
+		err = -ENODEV;
+		goto fail;
+	}
 		
-		id = match_device(drv->ids, dev);
-		if (!id) {
-				err = -ENODEV;
-				goto fail;
-		}
+	id = match_device(drv->ids, dev);
+	if (!id) {
+		err = -ENODEV;
+		goto fail;
+	}
 		
-		err = talk_to_otherend(dev);
-		if (err) {
-				printk(KERN_WARNING
-					   "xenbus_probe: talk_to_otherend on %s failed.\n",
-					   dev->nodename);
-				return err;
-		}
+	err = talk_to_otherend(dev);
+	if (err) {
+		printk(KERN_WARNING
+		       "xenbus_probe: talk_to_otherend on %s failed.\n",
+		       dev->nodename);
+			return err;
+	}
 		
-		err = drv->probe(dev, id);
-		if (err)
-				goto fail;
+	err = drv->probe(dev, id);
+	if (err)
+		goto fail;
 		
-		err = watch_otherend(dev);
-		if (err) {
-				printk(KERN_WARNING
-					   "xenbus_probe: watch_otherend on %s failed.\n",
-					   dev->nodename);
-				return err;
-		}
+	err = watch_otherend(dev);
+	if (err) {
+		printk(KERN_WARNING
+		   "xenbus_probe: watch_otherend on %s failed.\n",
+		   dev->nodename);
+		return err;
+	}
 		
-		return 0;
+	return 0;
  fail:
-		xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename);
-		xenbus_switch_state(dev, NULL, XenbusStateClosed);
-		return ENODEV;		
+	xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename);
+	xenbus_switch_state(dev, NULL, XenbusStateClosed);
+	return ENODEV;		
 }
 #if 0
 static int 
 xenbus_dev_remove(device_t _dev)
 {
-		struct xenbus_device *dev = to_xenbus_device(_dev);
-		struct xenbus_driver *drv = dev->driver;
+	struct xenbus_device *dev = to_xenbus_device(_dev);
+	struct xenbus_driver *drv = dev->driver;
 
-		DPRINTK("");
+	DPRINTK("");
 
-		free_otherend_watch(dev);
-		free_otherend_details(dev);
+	free_otherend_watch(dev);
+	free_otherend_details(dev);
 
-		if (drv->remove)
-				drv->remove(dev);
+	if (drv->remove)
+		drv->remove(dev);
 
-		xenbus_switch_state(dev, NULL, XenbusStateClosed);
-		return 0;
+	xenbus_switch_state(dev, NULL, XenbusStateClosed);
+	return 0;
 }
 #endif
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
-										 struct xen_bus_type *bus)
+					 struct xen_bus_type *bus)
 {
-		struct xenbus_device *xdev;
+	struct xenbus_device *xdev;
 		
 #if 0
-		int ret;
-		/* this all happens in the driver itself 
-		 * doing this here simple serves to obfuscate
-		 */
+	int ret;
+	/* this all happens in the driver itself 
+	 * doing this here simple serves to obfuscate
+	 */
 
-		drv->driver.name = drv->name;
-		drv->driver.bus = &bus->bus;
-		drv->driver.owner = drv->owner;
-		drv->driver.probe = xenbus_dev_probe;
-		drv->driver.remove = xenbus_dev_remove;
+	drv->driver.name = drv->name;
+	drv->driver.bus = &bus->bus;
+	drv->driver.owner = drv->owner;
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
 
 
-		return ret;
+	return ret;
 #endif
-		down(&xenwatch_mutex);
-		LIST_INSERT_HEAD(&xendrv_list, drv, list);
-		up(&xenwatch_mutex);
-		LIST_FOREACH(xdev, bus->bus, list) {
-				if (streq(drv->name, xdev->devicetype)) {
-						xdev->driver = drv;
-						xenbus_dev_probe(xdev);
+	down(&xenwatch_mutex);
+	LIST_INSERT_HEAD(&xendrv_list, drv, list);
+	up(&xenwatch_mutex);
+	LIST_FOREACH(xdev, bus->bus, list) {
+		if (streq(drv->name, xdev->devicetype)) {
+			xdev->driver = drv;
+			xenbus_dev_probe(xdev);
 				}
 		}
-		return 0;
+	return 0;
 }
 
 int xenbus_register_frontend(struct xenbus_driver *drv)
 {
-		drv->read_otherend_details = read_backend_details;
+	drv->read_otherend_details = read_backend_details;
 
-		return xenbus_register_driver_common(drv, &xenbus_frontend);
+	return xenbus_register_driver_common(drv, &xenbus_frontend);
 }
 EXPORT_SYMBOL(xenbus_register_frontend);
 
 int xenbus_register_backend(struct xenbus_driver *drv)
 {
-		drv->read_otherend_details = read_frontend_details;
+	drv->read_otherend_details = read_frontend_details;
 
-		return xenbus_register_driver_common(drv, &xenbus_backend);
+	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL(xenbus_register_backend);
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
 #if 0
-		driver_unregister(&drv->driver);
+	driver_unregister(&drv->driver);
 #endif
 }
 EXPORT_SYMBOL(xenbus_unregister_driver);
 
 struct xb_find_info
 {
-		struct xenbus_device *dev;
-		const char *nodename;
+	struct xenbus_device *dev;
+	const char *nodename;
 };
 
 static struct xenbus_device *
 xenbus_device_find(const char *nodename, struct xendev_list_head *bus)
 {
-		struct xenbus_device *xdev;
-		LIST_FOREACH(xdev, bus, list) {
-				if (streq(xdev->nodename, nodename)) { 
-						return xdev;
+	struct xenbus_device *xdev;
+	LIST_FOREACH(xdev, bus, list) {
+		if (streq(xdev->nodename, nodename)) { 
+			return xdev;
 #if 0
-						get_device(dev);
+			get_device(dev);
 #endif	
-				}
 		}
-		return NULL;
+	}
+	return NULL;
 }
 #if 0
 static int cleanup_dev(device_t dev, void *data)
 {
-		struct xenbus_device *xendev = device_get_softc(dev);
-		struct xb_find_info *info = data;
-		int len = strlen(info->nodename);
+	struct xenbus_device *xendev = device_get_softc(dev);
+	struct xb_find_info *info = data;
+	int len = strlen(info->nodename);
 
-		DPRINTK("%s", info->nodename);
+	DPRINTK("%s", info->nodename);
 
-		if (!strncmp(xendev->nodename, info->nodename, len)) {
-				info->dev = xendev;
+	if (!strncmp(xendev->nodename, info->nodename, len)) {
+		info->dev = xendev;
 #if 0
-				get_device(dev);
+		get_device(dev);
 #endif
-				return 1;
-		}
-		return 0;
+		return 1;
+	}
+	return 0;
 }
 
 #endif
 static void xenbus_cleanup_devices(const char *path, struct xendev_list_head * bus)
 {
-		panic("unimplemented");
+	panic("unimplemented");
 #if 0
-		struct xb_find_info info = { .nodename = path };
+	struct xb_find_info info = { .nodename = path };
 
-		do {
-				info.dev = NULL;
-				bus_for_each_dev(bus, NULL, &info, cleanup_dev);
-				if (info.dev) {
-						device_unregister(&info.dev->dev);
-						put_device(&info.dev->dev);
-				}
-		} while (info.dev);
+	do {
+		info.dev = NULL;
+		bus_for_each_dev(bus, NULL, &info, cleanup_dev);
+		if (info.dev) {
+			device_unregister(&info.dev->dev);
+			put_device(&info.dev->dev);
+		}
+	} while (info.dev);
 #endif 
 }
 
 #if 0
 static void xenbus_dev_free(struct xenbus_device *xendev)
 {
-		kfree(xendev);
+	kfree(xendev);
 }
 
 
 void xenbus_dev_release(device_t dev)
 {
-		/* 
-		 * nothing to do softc gets freed with the device
-		 */
+	/* 
+	 * nothing to do softc gets freed with the device
+	 */
 		
 }
 #endif
 /* Simplified asprintf. */
 static char *kasprintf(const char *fmt, ...)
 {
-		va_list ap;
-		unsigned int len;
-		char *p, dummy[1];
+	va_list ap;
+	unsigned int len;
+	char *p, dummy[1];
 
-		va_start(ap, fmt);
-		/* FIXME: vsnprintf has a bug, NULL should work */
-		len = vsnprintf(dummy, 0, fmt, ap);
-		va_end(ap);
+	va_start(ap, fmt);
+	/* FIXME: vsnprintf has a bug, NULL should work */
+	len = vsnprintf(dummy, 0, fmt, ap);
+	va_end(ap);
 
-		p = kmalloc(len + 1, GFP_KERNEL);
-		if (!p)
-				return NULL;
-		va_start(ap, fmt);
-		vsprintf(p, fmt, ap);
-		va_end(ap);
-		return p;
+	p = kmalloc(len + 1, GFP_KERNEL);
+	if (!p)
+		return NULL;
+	va_start(ap, fmt);
+	vsprintf(p, fmt, ap);
+	va_end(ap);
+	return p;
 }
 
 #if 0
 static ssize_t xendev_show_nodename(struct device *dev, char *buf)
 {
-		return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
+	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev, char *buf)
 {
-		return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
+	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
 DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
 #endif
 
-static int xenbus_probe_node(struct xen_bus_type *bus,
-							 const char *type,
-							 const char *nodename,
-							 int unit)
+static int xenbus_probe_node(struct xen_bus_type *bus, const char *type,
+			     const char *nodename, int unit)
 {
-#define CHECK_FAIL			\
+#define CHECK_FAIL				\
 	do {					\
 		if (err)			\
 			goto fail;		\
-	}					    \
-	while (0)				\
+	} while (0)				\
 
 
 
-		int err;
-		struct xenbus_device *xendev;
-		struct xenbus_driver *xdrv;
-		size_t stringlen;
-		char *tmpstring;
+	int err;
+	struct xenbus_device *xendev;
+	struct xenbus_driver *xdrv;
+	size_t stringlen;
+	char *tmpstring;
 
-		XenbusState state = xenbus_read_driver_state(nodename);
+	XenbusState state = xenbus_read_driver_state(nodename);
 		
-		if (state != XenbusStateInitialising) {
-				/* Device is not new, so ignore it.  This can happen if a
-				   device is going away after switching to Closed.  */
-				return 0;
-		}
+	if (state != XenbusStateInitialising) {
+		/* Device is not new, so ignore it.  This can happen if a
+		   device is going away after switching to Closed.  */
+		return 0;
+	}
 		
-		stringlen = strlen(nodename) + 1 + strlen(type) + 1;
-		xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
-		if (!xendev)
-				return ENOMEM;
-		memset(xendev, 0, sizeof(*xendev));
+	stringlen = strlen(nodename) + 1 + strlen(type) + 1;
+	xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
+	if (!xendev)
+		return ENOMEM;
+	memset(xendev, 0, sizeof(*xendev));
 		
-		/* Copy the strings into the extra space. */
+	/* Copy the strings into the extra space. */
+
+	tmpstring = (char *)(xendev + 1);
+	strcpy(tmpstring, nodename);
+	xendev->nodename = tmpstring;
 		
-		tmpstring = (char *)(xendev + 1);
-		strcpy(tmpstring, nodename);
-		xendev->nodename = tmpstring;
-		
-		tmpstring += strlen(tmpstring) + 1;
-		strcpy(tmpstring, type);
-		xendev->devicetype = tmpstring;
-/*
- * equivalent to device registration 
- * events
- */
-		LIST_INSERT_HEAD(bus->bus, xendev, list);
-		LIST_FOREACH(xdrv, &xendrv_list, list) {
-				if (streq(xdrv->name, xendev->devicetype))
-						xendev->driver = xdrv;
-		}
+	tmpstring += strlen(tmpstring) + 1;
+	strcpy(tmpstring, type);
+	xendev->devicetype = tmpstring;
+	/*
+	 * equivalent to device registration 
+	 * events
+	 */
+	LIST_INSERT_HEAD(bus->bus, xendev, list);
+	LIST_FOREACH(xdrv, &xendrv_list, list) {
+		if (streq(xdrv->name, xendev->devicetype))
+			xendev->driver = xdrv;
+	}
 
-		if (xendev->driver != NULL)
-				xenbus_dev_probe(xendev);
+	if (xendev->driver != NULL)
+		xenbus_dev_probe(xendev);
 		
 #if 0
-		xendev->dev.parent = &bus->dev;
-		xendev->dev.bus = &bus->bus;
-		xendev->dev.release = xenbus_dev_release;
+	xendev->dev.parent = &bus->dev;
+	xendev->dev.bus = &bus->bus;
+	xendev->dev.release = xenbus_dev_release;
+
+	err = bus->get_bus_id(xendev->dev.bus_id, xendev->nodename);
+	CHECK_FAIL;
 		
-		err = bus->get_bus_id(xendev->dev.bus_id, xendev->nodename);
-		CHECK_FAIL;
+	/* Register with generic device framework. */
+	err = device_register(&xendev->dev);
+	CHECK_FAIL;
 		
-		/* Register with generic device framework. */
-		err = device_register(&xendev->dev);
-		CHECK_FAIL;
-		
-		device_create_file(&xendev->dev, &dev_attr_nodename);
-		device_create_file(&xendev->dev, &dev_attr_devtype);
+	device_create_file(&xendev->dev, &dev_attr_nodename);
+	device_create_file(&xendev->dev, &dev_attr_devtype);
 #endif
-		return 0;
+	return 0;
 		
 #undef CHECK_FAIL
 #if 0
  fail:
-		xenbus_dev_free(xendev);
+	xenbus_dev_free(xendev);
 #endif
-		return err;
+	return err;
 }
 
 /* device/<typename>/<name> */
 static int xenbus_probe_frontend(const char *type, const char *name, int unit)
 {
-		char *nodename;
-		int err;
+	char *nodename;
+	int err;
+
+	nodename = kasprintf("%s/%s/%s", xenbus_frontend.root, type, name);
+	if (!nodename)

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list