Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision a32defadb7bdc01eed96b5df1ab80f7b95365eb1)
+++ uspace/srv/devman/devman.c	(revision 38b3bafe41afc8f7e1fd5caacbdb63618dcb65e5)
@@ -40,5 +40,5 @@
 #include "devman.h"
 
-// hash table operations
+/* hash table operations */
 
 static hash_index_t devices_hash(unsigned long key[])
@@ -47,5 +47,6 @@
 }
 
-static int devman_devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
+static int
+devman_devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
 	node_t *dev = hash_table_get_instance(item, node_t, devman_link);
@@ -53,5 +54,6 @@
 }
 
-static int devmap_devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
+static int
+devmap_devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
 	node_t *dev = hash_table_get_instance(item, node_t, devmap_link);
@@ -76,18 +78,17 @@
 
 /** Allocate and initialize a new driver structure.
- * 
- * @return driver structure.
- */
-driver_t * create_driver() 
+ *
+ * @return		Driver structure.
+ */
+driver_t *create_driver(void)
 {	
 	driver_t *res = malloc(sizeof(driver_t));
-	if(res != NULL) {
+	if (res != NULL)
 		init_driver(res);
-	}
 	return res;
 }
 
 /** Add a driver to the list of drivers.
- * 
+ *
  * @param drivers_list the list of drivers.
  * @param drv the driver's structure.
@@ -99,25 +100,27 @@
 	fibril_mutex_unlock(&drivers_list->drivers_mutex);
 	
-	printf(NAME": the '%s' driver was added to the list of available drivers.\n", drv->name);
-}
-
-/** Read match id at the specified position of a string and set 
- * the position in the string to the first character following the id.
- * 
- * @param buf the position in the input string.
- * 
- * @return the match id. 
- */
-char * read_match_id(char **buf) 
+	printf(NAME": the '%s' driver was added to the list of available "
+	    "drivers.\n", drv->name);
+}
+
+/** Read match id at the specified position of a string and set the position in
+ * the string to the first character following the id.
+ *
+ * @param buf		The position in the input string.
+ * @return		The match id.
+ */
+char *read_match_id(char **buf)
 {
 	char *res = NULL;
 	size_t len = get_nonspace_len(*buf);
+	
 	if (len > 0) {
 		res = malloc(len + 1);
 		if (res != NULL) {
-			str_ncpy(res, len + 1, *buf, len);	
+			str_ncpy(res, len + 1, *buf, len);
 			*buf += len;
 		}
 	}
+	
 	return res;
 }
@@ -125,13 +128,14 @@
 /**
  * Read match ids and associated match scores from a string.
- * 
- * Each match score in the string is followed by its match id. 
- * The match ids and match scores are separated by whitespaces. 
- * Neither match ids nor match scores can contain whitespaces. 
- * 
- * @param buf the string from which the match ids are read.
- * @param ids the list of match ids into which the match ids and scores are added.
- * 
- * @return true if at least one match id and associated match score was successfully read, false otherwise.
+ *
+ * Each match score in the string is followed by its match id.
+ * The match ids and match scores are separated by whitespaces.
+ * Neither match ids nor match scores can contain whitespaces.
+ *
+ * @param buf		The string from which the match ids are read.
+ * @param ids		The list of match ids into which the match ids and
+ *			scores are added.
+ * @return		True if at least one match id and associated match score
+ *			was successfully read, false otherwise.
  */
 bool parse_match_ids(char *buf, match_id_list_t *ids)
@@ -142,31 +146,30 @@
 	
 	while (true) {
-		// skip spaces
-		if (!skip_spaces(&buf)) {
+		/* skip spaces */
+		if (!skip_spaces(&buf))
 			break;
-		}
-		// read score
+		
+		/* read score */
 		score = strtoul(buf, &buf, 10);
 		
-		// skip spaces
-		if (!skip_spaces(&buf)) {
+		/* skip spaces */
+		if (!skip_spaces(&buf))
 			break;
-		}
-		
-		// read id
-		if (NULL == (id = read_match_id(&buf))) {
-			break;			
-		}
-		
-		// create new match_id structure
+		
+		/* read id */
+		id = read_match_id(&buf);
+		if (NULL == id)
+			break;
+		
+		/* create new match_id structure */
 		match_id_t *mid = create_match_id();
 		mid->id = id;
 		mid->score = score;
 		
-		/// add it to the list
+		/* add it to the list */
 		add_match_id(ids, mid);
 		
-		ids_read++;		
-	}	
+		ids_read++;
+	}
 	
 	return ids_read > 0;
@@ -175,22 +178,23 @@
 /**
  * Read match ids and associated match scores from a file.
- * 
- * Each match score in the file is followed by its match id. 
- * The match ids and match scores are separated by whitespaces. 
- * Neither match ids nor match scores can contain whitespaces. 
- * 
- * @param buf the path to the file from which the match ids are read.
- * @param ids the list of match ids into which the match ids and scores are added.
- * 
- * @return true if at least one match id and associated match score was successfully read, false otherwise.
- */
-bool read_match_ids(const char *conf_path, match_id_list_t *ids) 
-{	
+ *
+ * Each match score in the file is followed by its match id.
+ * The match ids and match scores are separated by whitespaces.
+ * Neither match ids nor match scores can contain whitespaces.
+ *
+ * @param buf		The path to the file from which the match ids are read.
+ * @param ids		The list of match ids into which the match ids and
+ *			scores are added.
+ * @return		True if at least one match id and associated match score
+ *			was successfully read, false otherwise.
+ */
+bool read_match_ids(const char *conf_path, match_id_list_t *ids)
+{
 	printf(NAME ": read_match_ids conf_path = %s.\n", conf_path);
 	
-	bool suc = false;	
+	bool suc = false;
 	char *buf = NULL;
 	bool opened = false;
-	int fd;		
+	int fd;
 	size_t len = 0;
 	
@@ -199,17 +203,18 @@
 		printf(NAME ": unable to open %s\n", conf_path);
 		goto cleanup;
-	} 
-	opened = true;	
+	}
+	opened = true;
 	
 	len = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);	
+	lseek(fd, 0, SEEK_SET);
 	if (len == 0) {
 		printf(NAME ": configuration file '%s' is empty.\n", conf_path);
-		goto cleanup;		
+		goto cleanup;
 	}
 	
 	buf = malloc(len + 1);
 	if (buf == NULL) {
-		printf(NAME ": memory allocation failed when parsing file '%s'.\n", conf_path);
+		printf(NAME ": memory allocation failed when parsing file "
+		    "'%s'.\n", conf_path);
 		goto cleanup;
 	}	
@@ -224,10 +229,8 @@
 	
 cleanup:
-	
 	free(buf);
 	
-	if(opened) {
-		close(fd);	
-	}
+	if(opened)
+		close(fd);
 	
 	return suc;
@@ -236,54 +239,54 @@
 /**
  * Get information about a driver.
- * 
- * Each driver has its own directory in the base directory. 
+ *
+ * Each driver has its own directory in the base directory.
  * The name of the driver's directory is the same as the name of the driver.
- * The driver's directory contains driver's binary (named as the driver without extension)
- * and the configuration file with match ids for device-to-driver matching 
- * (named as the driver with a special extension).
- * 
- * This function searches for the driver's directory and containing configuration files.
- * If all the files needed are found, they are parsed and 
- * the information about the driver is stored to the driver's structure.
- * 
- * @param base_path the base directory, in which we look for driver's subdirectory.
- * @param name the name of the driver.
- * @param drv the driver structure to fill information in.
- * 
- * @return true on success, false otherwise.
+ * The driver's directory contains driver's binary (named as the driver without
+ * extension) and the configuration file with match ids for device-to-driver
+ *  matching (named as the driver with a special extension).
+ *
+ * This function searches for the driver's directory and containing
+ * configuration files. If all the files needed are found, they are parsed and
+ * the information about the driver is stored in the driver's structure.
+ *
+ * @param base_path	The base directory, in which we look for driver's
+ *			subdirectory.
+ * @param name		The name of the driver.
+ * @param drv		The driver structure to fill information in.
+ *
+ * @return		True on success, false otherwise.
  */
 bool get_driver_info(const char *base_path, const char *name, driver_t *drv)
 {
-	printf(NAME ": get_driver_info base_path = %s, name = %s.\n", base_path, name);
+	printf(NAME ": get_driver_info base_path = %s, name = %s.\n",
+	    base_path, name);
 	
 	assert(base_path != NULL && name != NULL && drv != NULL);
 	
 	bool suc = false;
-	char *match_path = NULL;	
+	char *match_path = NULL;
 	size_t name_size = 0;
 	
-	// read the list of match ids from the driver's configuration file
-	if (NULL == (match_path = get_abs_path(base_path, name, MATCH_EXT))) {
+	/* Read the list of match ids from the driver's configuration file. */
+	match_path = get_abs_path(base_path, name, MATCH_EXT);
+	if (NULL == match_path)
 		goto cleanup;
-	}	
-	
-	if (!read_match_ids(match_path, &drv->match_ids)) {
+	
+	if (!read_match_ids(match_path, &drv->match_ids))
 		goto cleanup;
-	}	
-	
-	// allocate and fill driver's name
-	name_size = str_size(name)+1;
+	
+	/* Allocate and fill driver's name. */
+	name_size = str_size(name) + 1;
 	drv->name = malloc(name_size);
-	if (!drv->name) {
+	if (!drv->name)
 		goto cleanup;
-	}	
 	str_cpy(drv->name, name_size, name);
 	
-	// initialize path with driver's binary
-	if (NULL == (drv->binary_path = get_abs_path(base_path, name, ""))) {
+	/* Initialize path with driver's binary. */
+	drv->binary_path = get_abs_path(base_path, name, "");
+	if (NULL == drv->binary_path)
 		goto cleanup;
-	}
-	
-	// check whether the driver's binary exists
+	
+	/* Check whether the driver's binary exists. */
 	struct stat s;
 	if (stat(drv->binary_path, &s) == ENOENT) {
@@ -295,10 +298,9 @@
 	
 cleanup:
-	
 	if (!suc) {
 		free(drv->binary_path);
 		free(drv->name);
-		// set the driver structure to the default state
-		init_driver(drv); 
+		/* Set the driver structure to the default state. */
+		init_driver(drv);
 	}
 	
@@ -309,10 +311,9 @@
 
 /** Lookup drivers in the directory.
- * 
- * @param drivers_list the list of available drivers.
- * @param dir_path the path to the directory where we search for drivers. 
- * 
- * @return number of drivers which were found.
- */ 
+ *
+ * @param drivers_list	The list of available drivers.
+ * @param dir_path	The path to the directory where we search for drivers.
+ * @return		Number of drivers which were found.
+ */
 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
 {
@@ -327,10 +328,10 @@
 	if (dir != NULL) {
 		driver_t *drv = create_driver();
-		while ((diren = readdir(dir))) {			
+		while ((diren = readdir(dir))) {
 			if (get_driver_info(dir_path, diren->d_name, drv)) {
 				add_driver(drivers_list, drv);
 				drv_cnt++;
 				drv = create_driver();
-			}	
+			}
 		}
 		delete_driver(drv);
@@ -342,7 +343,7 @@
 
 /** Create root device node in the device tree.
- * 
- * @param tree the device tree.
- * @return true on success, false otherwise.
+ *
+ * @param tree		The device tree.
+ * @return		True on success, false otherwise.
  */
 bool create_root_node(dev_tree_t *tree)
@@ -350,5 +351,5 @@
 	printf(NAME ": create_root_node\n");
 	node_t *node = create_dev_node();
-	if (node) {		
+	if (node) {
 		insert_dev_node(tree, node, clone_string(""), NULL);
 		match_id_t *id = create_match_id();
@@ -358,23 +359,24 @@
 		tree->root_node = node;
 	}
-	return node != NULL;	
-}
-
-/** Lookup the best matching driver for the specified device in the list of drivers.
- * 
- * A match between a device and a driver is found 
- * if one of the driver's match ids match one of the device's match ids.
- * The score of the match is the product of the driver's and device's score associated with the matching id.
- * The best matching driver for a device is the driver
- * with the highest score of the match between the device and the driver.
- * 
- * @param drivers_list the list of drivers, where we look for the driver suitable for handling the device.
- * @param node the device node structure of the device.
- *
- * @return the best matching driver or NULL if no matching driver is found.
- */
-driver_t * find_best_match_driver(driver_list_t *drivers_list, node_t *node)
-{
-	//printf(NAME ": find_best_match_driver for device '%s' \n", node->pathname);
+	return node != NULL;
+}
+
+/** Lookup the best matching driver for the specified device in the list of
+ * drivers.
+ *
+ * A match between a device and a driver is found if one of the driver's match
+ * ids match one of the device's match ids. The score of the match is the
+ * product of the driver's and device's score associated with the matching id.
+ * The best matching driver for a device is the driver with the highest score
+ * of the match between the device and the driver.
+ *
+ * @param drivers_list	The list of drivers, where we look for the driver
+ *			suitable for handling the device.
+ * @param node		The device node structure of the device.
+ * @return		The best matching driver or NULL if no matching driver
+ *			is found.
+ */
+driver_t *find_best_match_driver(driver_list_t *drivers_list, node_t *node)
+{
 	driver_t *best_drv = NULL, *drv = NULL;
 	int best_score = 0, score = 0;
@@ -382,5 +384,5 @@
 	fibril_mutex_lock(&drivers_list->drivers_mutex);
 	
-	link_t *link = drivers_list->drivers.next;		
+	link_t *link = drivers_list->drivers.next;
 	while (link != &drivers_list->drivers) {
 		drv = list_get_instance(link, driver_t, drivers);
@@ -395,16 +397,16 @@
 	fibril_mutex_unlock(&drivers_list->drivers_mutex);
 	
-	return best_drv;	
-}
-
-/**
- * Assign a driver to a device.
- * 
- * @param node the device's node in the device tree.
- * @param drv the driver.
- */
-void attach_driver(node_t *node, driver_t *drv) 
-{
-	printf(NAME ": attach_driver %s to device %s\n", drv->name, node->pathname);
+	return best_drv;
+}
+
+/** Assign a driver to a device.
+ *
+ * @param node		The device's node in the device tree.
+ * @param drv		The driver.
+ */
+void attach_driver(node_t *node, driver_t *drv)
+{
+	printf(NAME ": attach_driver %s to device %s\n",
+	    drv->name, node->pathname);
 	
 	fibril_mutex_lock(&drv->driver_mutex);
@@ -416,10 +418,11 @@
 }
 
-/** Start a driver.
- * 
+/** Start a driver
+ *
  * The driver's mutex is assumed to be locked.
- * 
- * @param drv the driver's structure.
- * @return true if the driver's task is successfully spawned, false otherwise.
+ *
+ * @param drv		The driver's structure.
+ * @return		True if the driver's task is successfully spawned, false
+ *			otherwise.
  */
 bool start_driver(driver_t *drv)
@@ -434,5 +437,6 @@
 	int err;
 	if (!task_spawn(drv->binary_path, argv, &err)) {
-		printf(NAME ": error spawning %s, errno = %d\n", drv->name, err);
+		printf(NAME ": error spawning %s, errno = %d\n",
+		    drv->name, err);
 		return false;
 	}
@@ -443,17 +447,18 @@
 
 /** Find device driver in the list of device drivers.
- * 
- * @param drv_list the list of device drivers.
- * @param drv_name the name of the device driver which is searched.
- * @return the device driver of the specified name, if it is in the list, NULL otherwise.  
- */
-driver_t * find_driver(driver_list_t *drv_list, const char *drv_name) 
-{	
+ *
+ * @param drv_list	The list of device drivers.
+ * @param drv_name	The name of the device driver which is searched.
+ * @return		The device driver of the specified name, if it is in the
+ *			list, NULL otherwise.
+ */
+driver_t *find_driver(driver_list_t *drv_list, const char *drv_name)
+{
 	driver_t *res = NULL;
 	
-	fibril_mutex_lock(&drv_list->drivers_mutex);	
+	fibril_mutex_lock(&drv_list->drivers_mutex);
 	
 	driver_t *drv = NULL;
-	link_t *link = drv_list->drivers.next; 	
+	link_t *link = drv_list->drivers.next;
 	while (link !=  &drv_list->drivers) {
 		drv = list_get_instance(link, driver_t, drivers);
@@ -471,24 +476,24 @@
 
 /** Remember the driver's phone.
- * @param driver the driver.
- * @param phone the phone to the driver.
+ *
+ * @param driver	The driver.
+ * @param phone		The phone to the driver.
  */
 void set_driver_phone(driver_t *driver, ipcarg_t phone)
-{		
-	fibril_mutex_lock(&driver->driver_mutex);	
+{
+	fibril_mutex_lock(&driver->driver_mutex);
 	assert(DRIVER_STARTING == driver->state);
-	driver->phone = phone;	
-	fibril_mutex_unlock(&driver->driver_mutex);	
-}
-
-/**
- * Notify driver about the devices to which it was assigned.
- * 
+	driver->phone = phone;
+	fibril_mutex_unlock(&driver->driver_mutex);
+}
+
+/** Notify driver about the devices to which it was assigned.
+ *
  * The driver's mutex must be locked.
- * 
- * @param driver the driver to which the devices are passed.
+ *
+ * @param driver	The driver to which the devices are passed.
  */
 static void pass_devices_to_driver(driver_t *driver, dev_tree_t *tree)
-{	
+{
 	printf(NAME ": pass_devices_to_driver\n");
 	node_t *dev;
@@ -510,21 +515,26 @@
 }
 
-/** Finish the initialization of a driver after it has succesfully started 
+/** Finish the initialization of a driver after it has succesfully started
  * and after it has registered itself by the device manager.
- * 
- * Pass devices formerly matched to the driver to the driver and remember the driver is running and fully functional now.
- * 
- * @param driver the driver which registered itself as running by the device manager.
- */
-void initialize_running_driver(driver_t *driver, dev_tree_t *tree) 
-{	
+ *
+ * Pass devices formerly matched to the driver to the driver and remember the
+ * driver is running and fully functional now.
+ *
+ * @param driver	The driver which registered itself as running by the
+ *			device manager.
+ */
+void initialize_running_driver(driver_t *driver, dev_tree_t *tree)
+{
 	printf(NAME ": initialize_running_driver\n");
 	fibril_mutex_lock(&driver->driver_mutex);
 	
-	// pass devices which have been already assigned to the driver to the driver
-	pass_devices_to_driver(driver, tree);	
-	
-	// change driver's state to running
-	driver->state = DRIVER_RUNNING;	
+	/*
+	 * Pass devices which have been already assigned to the driver to the
+	 * driver.
+	 */
+	pass_devices_to_driver(driver, tree);
+	
+	/* Change driver's state to running. */
+	driver->state = DRIVER_RUNNING;
 	
 	fibril_mutex_unlock(&driver->driver_mutex);
@@ -532,22 +542,22 @@
 
 
+/** Create devmap path and name for the device. */
 static void devmap_register_tree_device(node_t *node, dev_tree_t *tree)
 {
-	// create devmap path and name for the device
 	char *devmap_pathname = NULL;
 	char *devmap_name = NULL;
 	
 	asprintf(&devmap_name, "%s", node->pathname);
-	if (NULL == devmap_name) {
+	if (NULL == devmap_name)
 		return;
-	}
 	
 	replace_char(devmap_name, '/', DEVMAP_SEPARATOR);
 	
-	asprintf(&devmap_pathname, "%s/%s", DEVMAP_DEVICE_NAMESPACE, devmap_name);
+	asprintf(&devmap_pathname, "%s/%s", DEVMAP_DEVICE_NAMESPACE,
+	    devmap_name);
 	if (NULL == devmap_pathname) {
 		free(devmap_name);
 		return;
-	}	
+	}
 	
 	devmap_device_register(devmap_pathname, &node->devmap_handle);
@@ -556,12 +566,12 @@
 	
 	free(devmap_name);
-	free(devmap_pathname);	
+	free(devmap_pathname);
 }
 
 
 /** Pass a device to running driver.
- * 
- * @param drv the driver's structure.
- * @param node the device's node in the device tree.
+ *
+ * @param drv		The driver's structure.
+ * @param node		The device's node in the device tree.
  */
 void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree)
@@ -572,14 +582,16 @@
 	ipc_call_t answer;
 	
-	// send the device to the driver
-	aid_t req = async_send_1(phone, DRIVER_ADD_DEVICE, node->handle, &answer);
-	
-	// send the device's name to the driver
-	rc = async_data_write_start(phone, node->name, str_size(node->name) + 1);
-    if (rc != EOK) {
-		// TODO handle error
-    }
-	
-	// wait for answer from the driver
+	/* Send the device to the driver. */
+	aid_t req = async_send_1(phone, DRIVER_ADD_DEVICE, node->handle,
+	    &answer);
+	
+	/* Send the device's name to the driver. */
+	rc = async_data_write_start(phone, node->name,
+	    str_size(node->name) + 1);
+	if (rc != EOK) {
+		/* TODO handle error */
+	}
+	
+	/* Wait for answer from the driver. */
 	async_wait_for(req, &rc);
 	switch(rc) {
@@ -592,5 +604,5 @@
 		break;
 	default:
-		node->state = DEVICE_INVALID;		
+		node->state = DEVICE_INVALID;
 	}
 	
@@ -598,36 +610,36 @@
 }
 
-/** 
- * Find suitable driver for a device and assign the driver to it.
- * 
- * @param node the device node of the device in the device tree.
- * @param drivers_list the list of available drivers.
- * 
- * @return true if the suitable driver is found and successfully assigned to the device, false otherwise. 
- */
-bool assign_driver(node_t *node, driver_list_t *drivers_list, dev_tree_t *tree) 
-{
-	//printf(NAME ": assign_driver\n");
-	
-	// find the driver which is the most suitable for handling this device
+/** Find suitable driver for a device and assign the driver to it.
+ *
+ * @param node		The device node of the device in the device tree.
+ * @param drivers_list	The list of available drivers.
+ * @return		True if the suitable driver is found and
+ *			successfully assigned to the device, false otherwise.
+ */
+bool assign_driver(node_t *node, driver_list_t *drivers_list, dev_tree_t *tree)
+{
+	/*
+	 * Find the driver which is the most suitable for handling this device.
+	 */
 	driver_t *drv = find_best_match_driver(drivers_list, node);
 	if (NULL == drv) {
-		printf(NAME ": no driver found for device '%s'.\n", node->pathname); 
-		return false;		
-	}
-	
-	// attach the driver to the device
+		printf(NAME ": no driver found for device '%s'.\n",
+		    node->pathname);
+		return false;
+	}
+	
+	/* Attach the driver to the device. */
 	attach_driver(node, drv);
 	
 	if (DRIVER_NOT_STARTED == drv->state) {
-		// start driver
+		/* Start the driver. */
 		start_driver(drv);
-	} 
+	}
 	
 	if (DRIVER_RUNNING == drv->state) {
-		// notify driver about new device
+		/* Notify the driver about the new device. */
 		int phone = ipc_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
 		if (phone > 0) {
-			add_device(phone, drv, node, tree);		
+			add_device(phone, drv, node, tree);
 			ipc_hangup(phone);
 		}
@@ -637,12 +649,11 @@
 }
 
-/**
- * Initialize the device tree.
- * 
+/** Initialize the device tree.
+ *
  * Create root device node of the tree and assign driver to it.
- * 
- * @param tree the device tree.
- * @param the list of available drivers.
- * @return true on success, false otherwise.
+ *
+ * @param tree		The device tree.
+ * @param drivers_list	the list of available drivers.
+ * @return		True on success, false otherwise.
  */
 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list)
@@ -652,34 +663,36 @@
 	tree->current_handle = 0;
 	
-	hash_table_create(&tree->devman_devices, DEVICE_BUCKETS, 1, &devman_devices_ops);
-	hash_table_create(&tree->devmap_devices, DEVICE_BUCKETS, 1, &devmap_devices_ops);
+	hash_table_create(&tree->devman_devices, DEVICE_BUCKETS, 1,
+	    &devman_devices_ops);
+	hash_table_create(&tree->devmap_devices, DEVICE_BUCKETS, 1,
+	    &devmap_devices_ops);
 	
 	fibril_rwlock_initialize(&tree->rwlock);
 	
-	// create root node and add it to the device tree
-	if (!create_root_node(tree)) {
+	/* Create root node and add it to the device tree. */
+	if (!create_root_node(tree))
 		return false;
-	}
-
-	// find suitable driver and start it
+
+	/* Find suitable driver and start it. */
 	return assign_driver(tree->root_node, drivers_list, tree);
 }
 
 /** Create and set device's full path in device tree.
- * 
- * @param node the device's device node.
- * @param parent the parent device node.
- * @return true on success, false otherwise (insufficient resources etc.). 
+ *
+ * @param node		The device's device node.
+ * @param parent	The parent device node.
+ * @return		True on success, false otherwise (insufficient
+ *			resources etc.).
  */
 static bool set_dev_path(node_t *node, node_t *parent)
-{	
+{
 	assert(NULL != node->name);
 	
-	size_t pathsize = (str_size(node->name) + 1);	
-	if (NULL != parent) {		
-		pathsize += str_size(parent->pathname) + 1;		
-	}
-	
-	if (NULL == (node->pathname = (char *)malloc(pathsize))) {
+	size_t pathsize = (str_size(node->name) + 1);
+	if (NULL != parent)
+		pathsize += str_size(parent->pathname) + 1;
+	
+	node->pathname = (char *) malloc(pathsize);
+	if (NULL == node->pathname) {
 		printf(NAME ": failed to allocate device path.\n");
 		return false;
@@ -698,17 +711,18 @@
 
 /** Insert new device into device tree.
- * 
- * The device tree's rwlock should be already held exclusively when calling this function.
- * 
- * @param tree the device tree.
- * @param node the newly added device node. 
- * @param dev_name the name of the newly added device.
- * @param parent the parent device node.
- * @return true on success, false otherwise (insufficient resources etc.).
- */
-bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent)
-{
-	// printf(NAME ": insert_dev_node\n");
-	
+ *
+ * The device tree's rwlock should be already held exclusively when calling this
+ * function.
+ *
+ * @param tree		The device tree.
+ * @param node		The newly added device node. 
+ * @param dev_name	The name of the newly added device.
+ * @param parent	The parent device node.
+ * @return		True on success, false otherwise (insufficient resources
+ *			etc.).
+ */
+bool
+insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent)
+{
 	assert(NULL != node && NULL != tree && NULL != dev_name);
 	
@@ -716,40 +730,42 @@
 	if (!set_dev_path(node, parent)) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
-		return false;		
-	}
-	
-	// add the node to the handle-to-node map
+		return false;
+	}
+	
+	/* Add the node to the handle-to-node map. */
 	node->handle = ++tree->current_handle;
 	unsigned long key = node->handle;
 	hash_table_insert(&tree->devman_devices, &key, &node->devman_link);
 
-	// add the node to the list of its parent's children
+	/* Add the node to the list of its parent's children. */
 	node->parent = parent;
-	if (NULL != parent) {
-		list_append(&node->sibling, &parent->children);		
-	}
+	if (NULL != parent)
+		list_append(&node->sibling, &parent->children);
+	
 	return true;
 }
 
-/** 
- * Find device node with a specified path in the device tree.
+/** Find device node with a specified path in the device tree.
  * 
- * @param path the path of the device node in the device tree.
- * @param tree the device tree.
- * 
- * @return the device node if it is present in the tree, NULL otherwise.
- */
-node_t * find_dev_node_by_path(dev_tree_t *tree, char *path)
+ * @param path		The path of the device node in the device tree.
+ * @param tree		The device tree.
+ * @return		The device node if it is present in the tree, NULL
+ *			otherwise.
+ */
+node_t *find_dev_node_by_path(dev_tree_t *tree, char *path)
 {
 	fibril_rwlock_read_lock(&tree->rwlock);
 	
 	node_t *dev = tree->root_node;
-	// relative path to the device from its parent (but with '/' at the beginning)
+	/*
+	 * Relative path to the device from its parent (but with '/' at the
+	 * beginning)
+	 */
 	char *rel_path = path;
 	char *next_path_elem = NULL;
 	bool cont = '/' == rel_path[0];
 	
-	while (cont && NULL != dev) {		
-		next_path_elem  = get_path_elem_end(rel_path + 1);		
+	while (cont && NULL != dev) {
+		next_path_elem  = get_path_elem_end(rel_path + 1);
 		if ('/' == next_path_elem[0]) {
 			cont = true;
@@ -759,11 +775,11 @@
 		}
 		
-		dev = find_node_child(dev, rel_path + 1);		
+		dev = find_node_child(dev, rel_path + 1);
 		
 		if (cont) {
-			// restore the original path
+			/* Restore the original path. */
 			next_path_elem[0] = '/';
 		}
-		rel_path = next_path_elem;		
+		rel_path = next_path_elem;
 	}
 	
@@ -773,13 +789,11 @@
 }
 
-/**
- * Find child device node with a specified name.
- * 
- * Device tree rwlock should be held at least for reading. 
- * 
- * @param parent the parent device node.
- * @param name the name of the child device node.
- * 
- * @return the child device node.
+/** Find child device node with a specified name.
+ *
+ * Device tree rwlock should be held at least for reading.
+ *
+ * @param parent	The parent device node.
+ * @param name		The name of the child device node.
+ * @return		The child device node.
  */
 node_t *find_node_child(node_t *parent, const char *name)
@@ -787,5 +801,5 @@
 	node_t *dev;
 	link_t *link;
-			
+	
 	link = parent->children.next;
 	
@@ -793,65 +807,69 @@
 		dev = list_get_instance(link, node_t, sibling);
 		
-		if (0 == str_cmp(name, dev->name)) {
-			return dev;			
-		}
+		if (0 == str_cmp(name, dev->name))
+			return dev;
 		
 		link = link->next;
-	}	
-		
+	}
+	
 	return NULL;
 }
 
-/** Create unique device name within the class. 
- * 
- * @param cl the class.
- * @param base_dev_name contains base name for the device 
- * if it was specified by the driver when it registered the device by the class; 
- * NULL if driver specified no base name.
- * @return the unique name for the device within the class.
- */
-char * create_dev_name_for_class(dev_class_t *cl, const char *base_dev_name)
+/** Create unique device name within the class.
+ *
+ * @param cl		The class.
+ * @param base_dev_name	Contains the base name for the device if it was
+ *			specified by the driver when it registered the device by
+ *			the class; NULL if driver specified no base name.
+ * @return		The unique name for the device within the class.
+ */
+char *create_dev_name_for_class(dev_class_t *cl, const char *base_dev_name)
 {
 	char *dev_name;
 	const char *base_name;
-	if (NULL != base_dev_name) {
+	
+	if (NULL != base_dev_name)
 		base_name = base_dev_name;
-	} else {
+	else
 		base_name = cl->base_dev_name;
-	}
 	
 	size_t idx = get_new_class_dev_idx(cl);
 	asprintf(&dev_name, "%s%d", base_name, idx);
-	return dev_name;	
+	
+	return dev_name;
 }
 
 /** Add the device to the class.
- * 
- * The device may be added to multiple classes and a class may contain multiple devices.
- * The class and the device are associated with each other by the dev_class_info_t structure.
- * 
- * @param dev the device.
- * @param class the class.
- * @param base_dev_name the base name of the device within the class if specified by the driver,
- * NULL otherwise.
- * @return dev_class_info_t structure which associates the device with the class.
- */
-dev_class_info_t * add_device_to_class(node_t *dev, dev_class_t *cl, const char *base_dev_name)
-{	
+ *
+ * The device may be added to multiple classes and a class may contain multiple
+ * devices. The class and the device are associated with each other by the
+ * dev_class_info_t structure.
+ *
+ * @param dev		The device.
+ * @param class		The class.
+ * @param base_dev_name	The base name of the device within the class if
+ *			specified by the driver, NULL otherwise.
+ * @return		dev_class_info_t structure which associates the device
+ *			with the class.
+ */
+dev_class_info_t *
+add_device_to_class(node_t *dev, dev_class_t *cl, const char *base_dev_name)
+{
 	dev_class_info_t *info = create_dev_class_info();
+	
 	if (NULL != info) {
 		info->dev_class = cl;
 		info->dev = dev;
 		
-		// add the device to the class
+		/* Add the device to the class. */
 		fibril_mutex_lock(&cl->mutex);
 		list_append(&info->link, &cl->devices);
 		fibril_mutex_unlock(&cl->mutex);
 		
-		// add the class to the device
+		/* Add the class to the device. */
 		list_append(&info->dev_classes, &dev->classes);
 		
-		// create unique name for the device within the class
-		info->dev_name = create_dev_name_for_class(cl, base_dev_name);	
+		/* Create unique name for the device within the class. */
+		info->dev_name = create_dev_name_for_class(cl, base_dev_name);
 	}
 	
@@ -859,33 +877,35 @@
 }
 
-dev_class_t * get_dev_class(class_list_t *class_list, char *class_name)
+dev_class_t *get_dev_class(class_list_t *class_list, char *class_name)
 {
 	dev_class_t *cl;
-	fibril_rwlock_write_lock(&class_list->rwlock);	
+	
+	fibril_rwlock_write_lock(&class_list->rwlock);
 	cl = find_dev_class_no_lock(class_list, class_name);
 	if (NULL == cl) {
 		cl = create_dev_class();
 		if (NULL != cl) {
-			cl->name = class_name;	
+			cl->name = class_name;
 			cl->base_dev_name = "";
 			add_dev_class_no_lock(class_list, cl);
-		}		
-	}	
+		}
+	}
 	fibril_rwlock_write_unlock(&class_list->rwlock);
 	return cl;
 }
 
-dev_class_t * find_dev_class_no_lock(class_list_t *class_list, const char *class_name)
+dev_class_t *
+find_dev_class_no_lock(class_list_t *class_list, const char *class_name)
 {
 	dev_class_t *cl;
 	link_t *link = class_list->classes.next;
+	
 	while (link != &class_list->classes) {
 		cl = list_get_instance(link, dev_class_t, link);
-		if (0 == str_cmp(cl->name, class_name)) {
+		if (0 == str_cmp(cl->name, class_name))
 			return cl;
-		}
-	}
-	
-	return NULL;	
+	}
+	
+	return NULL;
 }
 
@@ -894,9 +914,10 @@
 	list_initialize(&class_list->classes);
 	fibril_rwlock_initialize(&class_list->rwlock);
-	hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1, &devmap_devices_ops);	
-}
-
-
-// devmap devices
+	hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
+	    &devmap_devices_ops);
+}
+
+
+/* devmap devices */
 
 node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle)
@@ -904,11 +925,10 @@
 	node_t *dev = NULL;
 	link_t *link;
-	unsigned long key = (unsigned long)devmap_handle;
+	unsigned long key = (unsigned long) devmap_handle;
 	
 	fibril_rwlock_read_lock(&tree->rwlock);
-	link = hash_table_find(&tree->devmap_devices, &key);	
-	if (NULL != link) {
+	link = hash_table_find(&tree->devmap_devices, &key);
+	if (NULL != link)
 		dev = hash_table_get_instance(link, node_t, devmap_link);
-	}
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
@@ -916,5 +936,6 @@
 }
 
-node_t *find_devmap_class_device(class_list_t *classes, dev_handle_t devmap_handle)
+node_t *
+find_devmap_class_device(class_list_t *classes, dev_handle_t devmap_handle)
 {
 	node_t *dev = NULL;
@@ -924,14 +945,14 @@
 	
 	fibril_rwlock_read_lock(&classes->rwlock);
-	link = hash_table_find(&classes->devmap_devices, &key);	
+	link = hash_table_find(&classes->devmap_devices, &key);
 	if (NULL != link) {
-		cli = hash_table_get_instance(link, dev_class_info_t, devmap_link);
+		cli = hash_table_get_instance(link, dev_class_info_t,
+		    devmap_link);
 		dev = cli->dev;
 	}
 	fibril_rwlock_read_unlock(&classes->rwlock);
 	
-	return dev;	
-}
-
+	return dev;
+}
 
 /** @}
