Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/devman.c	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -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;
+}
 
 /** @}
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/devman.h	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -61,30 +61,42 @@
 
 typedef enum {
-	/** driver has not been started */
+	/** Driver has not been started. */
 	DRIVER_NOT_STARTED = 0,
-	/** driver has been started, but has not registered as running and ready to receive requests */
+	
+	/**
+	 * Driver has been started, but has not registered as running and ready
+	 * to receive requests.
+	 */
 	DRIVER_STARTING,
-	/** driver is running and prepared to serve incomming requests */
+	
+	/** Driver is running and prepared to serve incomming requests. */
 	DRIVER_RUNNING
 } driver_state_t;
 
-/** Representation of device driver.
- */
+/** Representation of device driver. */
 typedef struct driver {
-	/** Pointers to previous and next drivers in a linked list */
+	/** Pointers to previous and next drivers in a linked list. */
 	link_t drivers;
-	/** Specifies whether the driver has been started and wheter is running and prepared to receive requests.*/
+	
+	/**
+	 * Specifies whether the driver has been started and wheter is running
+	 * and prepared to receive requests.
+	 */
 	int state;
-	/** Phone asociated with this driver */
+	
+	/** Phone asociated with this driver. */
 	ipcarg_t phone;
-	/** Name of the device driver */
+	/** Name of the device driver. */
 	char *name;
-	/** Path to the driver's binary */
+	/** Path to the driver's binary. */
 	const char *binary_path;
-	/** List of device ids for device-to-driver matching.*/
+	/** List of device ids for device-to-driver matching. */
 	match_id_list_t match_ids;
-	/** Pointer to the linked list of devices controlled by this driver */
+	/** Pointer to the linked list of devices controlled by this driver. */
 	link_t devices;
-	/** Fibril mutex for this driver - driver state, list of devices, phone.*/
+	
+	/**
+	 * Fibril mutex for this driver - driver state, list of devices, phone.
+	 */
 	fibril_mutex_t driver_mutex;
 } driver_t;
@@ -95,5 +107,5 @@
 	link_t drivers;
 	/** Fibril mutex for list of drivers. */
-	fibril_mutex_t drivers_mutex;	
+	fibril_mutex_t drivers_mutex;
 } driver_list_t;
 
@@ -106,63 +118,103 @@
 } device_state_t;
 
-/** Representation of a node in the device tree.*/
+/** Representation of a node in the device tree. */
 struct node {
-	/** The global unique identifier of the device.*/
+	/** The global unique identifier of the device. */
 	device_handle_t handle;
 	/** The name of the device specified by its parent. */
 	char *name;
-	/** Full path and name of the device in device hierarchi (i. e. in full path in device tree).*/
-	char *pathname;	
+	
+	/**
+	 * Full path and name of the device in device hierarchi (i. e. in full
+	 * path in device tree).
+	 */
+	char *pathname;
+	
 	/** The node of the parent device. */
 	node_t *parent;
-	/** Pointers to previous and next child devices in the linked list of parent device's node.*/
+	
+	/**
+	 * Pointers to previous and next child devices in the linked list of
+	 * parent device's node.
+	 */
 	link_t sibling;
+	
 	/** List of child device nodes. */
 	link_t children;
-	/** List of device ids for device-to-driver matching.*/
+	/** List of device ids for device-to-driver matching. */
 	match_id_list_t match_ids;
-	/** Driver of this device.*/
+	/** Driver of this device. */
 	driver_t *drv;
 	/** The state of the device. */
 	device_state_t state;
-	/** Pointer to the previous and next device in the list of devices
-	    owned by one driver */
+	/**
+	 * Pointer to the previous and next device in the list of devices
+	 * owned by one driver.
+	 */
 	link_t driver_devices;
-	/** The list of device classes to which this device belongs.*/
+	
+	/** The list of device classes to which this device belongs. */
 	link_t classes;
 	/** Devmap handle if the device is registered by devmapper. */
 	dev_handle_t devmap_handle;
-	/** Used by the hash table of devices indexed by devman device handles.*/
+	
+	/**
+	 * Used by the hash table of devices indexed by devman device handles.
+	 */
 	link_t devman_link;
-	/** Used by the hash table of devices indexed by devmap device handles.*/
+	
+	/**
+	 * Used by the hash table of devices indexed by devmap device handles.
+	 */
 	link_t devmap_link;
 };
 
-
-/** Represents device tree.
- */
+/** Represents device tree. */
 typedef struct dev_tree {
 	/** Root device node. */
 	node_t *root_node;
-	/** The next available handle - handles are assigned in a sequential manner.*/
+	
+	/**
+	 * The next available handle - handles are assigned in a sequential
+	 * manner.
+	 */
 	device_handle_t current_handle;
-	/** Synchronize access to the device tree.*/
+	
+	/** Synchronize access to the device tree. */
 	fibril_rwlock_t rwlock;
-	/** Hash table of all devices indexed by devman handles.*/
+	
+	/** Hash table of all devices indexed by devman handles. */
 	hash_table_t devman_devices;
-	/** Hash table of devices registered by devmapper, indexed by devmap handles.*/
+	
+	/**
+	 * Hash table of devices registered by devmapper, indexed by devmap
+	 * handles.
+	 */
 	hash_table_t devmap_devices;
 } dev_tree_t;
 
-typedef struct dev_class {	
-	/** The name of the class.*/
+typedef struct dev_class {
+	/** The name of the class. */
 	const char *name;
-	/** Pointer to the previous and next class in the list of registered classes.*/
-	link_t link;	
-	/** List of dev_class_info structures - one for each device registered by this class.*/
+	
+	/**
+	 * Pointer to the previous and next class in the list of registered
+	 * classes.
+	 */
+	link_t link;
+	
+	/**
+	 * List of dev_class_info structures - one for each device registered by
+	 * this class.
+	 */
 	link_t devices;
-	/** Default base name for the device within the class, might be overrided by the driver.*/	
+	
+	/**
+	 * Default base name for the device within the class, might be overrided
+	 * by the driver.
+	 */
 	const char *base_dev_name;
-	/** Unique numerical identifier of the newly added device.*/
+	
+	/** Unique numerical identifier of the newly added device. */
 	size_t curr_dev_idx;
 	/** Synchronize access to the list of devices in this class. */
@@ -170,21 +222,35 @@
 } dev_class_t;
 
-/** Provides n-to-m mapping between device nodes and classes 
- * - each device may be register to the arbitrary number of classes 
- * and each class may contain the arbitrary number of devices. */
+/** Provides n-to-m mapping between device nodes and classes - each device may
+ * be register to the arbitrary number of classes and each class may contain
+ * the arbitrary number of devices.
+ */
 typedef struct dev_class_info {
-	/** The class.*/
+	/** The class. */
 	dev_class_t *dev_class;
-	/** The device.*/
+	/** The device. */
 	node_t *dev;
-	/** Pointer to the previous and next class info in the list of devices registered by the class.*/
+	
+	/**
+	 * Pointer to the previous and next class info in the list of devices
+	 * registered by the class.
+	 */
 	link_t link;
-	/** Pointer to the previous and next class info in the list of classes by which the device is registered.*/
+	
+	/**
+	 * Pointer to the previous and next class info in the list of classes
+	 * by which the device is registered.
+	 */
 	link_t dev_classes;
-	/** The name of the device within the class.*/
-	char *dev_name;	
-	/** The handle of the device by device mapper in the class namespace.*/
+	
+	/** The name of the device within the class. */
+	char *dev_name;
+	/** The handle of the device by device mapper in the class namespace. */
 	dev_handle_t devmap_handle;
-	/** Link in the hash table of devices registered by the devmapper using their class names.*/
+	
+	/**
+	 * Link in the hash table of devices registered by the devmapper using
+	 * their class names.
+	 */
 	link_t devmap_link;
 } dev_class_info_t;
@@ -192,58 +258,61 @@
 /** The list of device classes. */
 typedef struct class_list {
-	/** List of classes */
+	/** List of classes. */
 	link_t classes;
-	/** Hash table of devices registered by devmapper using their class name, indexed by devmap handles.*/
+	
+	/**
+	 * Hash table of devices registered by devmapper using their class name,
+	 * indexed by devmap handles.
+	 */
 	hash_table_t devmap_devices;
+	
 	/** Fibril mutex for list of classes. */
-	fibril_rwlock_t rwlock;	
+	fibril_rwlock_t rwlock;
 } class_list_t;
 
-// Match ids and scores
-
-int get_match_score(driver_t *drv, node_t *dev);
-
-bool parse_match_ids(char *buf, match_id_list_t *ids);
-bool read_match_ids(const char *conf_path, match_id_list_t *ids);
-char * read_match_id(char **buf);
-char * read_id(const char **buf);
-
-// Drivers
-
-/** 
+/* Match ids and scores */
+
+extern int get_match_score(driver_t *, node_t *);
+
+extern bool parse_match_ids(char *, match_id_list_t *);
+extern bool read_match_ids(const char *, match_id_list_t *);
+extern char *read_match_id(char **);
+extern char *read_id(const char **);
+
+/* Drivers */
+
+/**
  * Initialize the list of device driver's.
- * 
+ *
  * @param drv_list the list of device driver's.
- * 
- */
-static inline void init_driver_list(driver_list_t *drv_list) 
+ *
+ */
+static inline void init_driver_list(driver_list_t *drv_list)
 {
 	assert(NULL != drv_list);
 	
 	list_initialize(&drv_list->drivers);
-	fibril_mutex_initialize(&drv_list->drivers_mutex);	
-}
-
-driver_t * create_driver(void);
-bool get_driver_info(const char *base_path, const char *name, driver_t *drv);
-int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path);
-
-driver_t * find_best_match_driver(driver_list_t *drivers_list, node_t *node);
-bool assign_driver(node_t *node, driver_list_t *drivers_list, dev_tree_t *tree);
-
-void add_driver(driver_list_t *drivers_list, driver_t *drv);
-void attach_driver(node_t *node, driver_t *drv);
-void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree);
-bool start_driver(driver_t *drv);
-
-driver_t * find_driver(driver_list_t *drv_list, const char *drv_name);
-void set_driver_phone(driver_t *driver, ipcarg_t phone);
-void initialize_running_driver(driver_t *driver, dev_tree_t *tree);
-
-/** 
- * Initialize device driver structure.
- * 
- * @param drv the device driver structure.
- * 
+	fibril_mutex_initialize(&drv_list->drivers_mutex);
+}
+
+extern driver_t *create_driver(void);
+extern bool get_driver_info(const char *, const char *, driver_t *);
+extern int lookup_available_drivers(driver_list_t *, const char *);
+
+extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
+extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
+
+extern void add_driver(driver_list_t *, driver_t *);
+extern void attach_driver(node_t *, driver_t *);
+extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
+extern bool start_driver(driver_t *);
+
+extern driver_t *find_driver(driver_list_t *, const char *);
+extern void set_driver_phone(driver_t *, ipcarg_t);
+void initialize_running_driver(driver_t *, dev_tree_t *);
+
+/** Initialize device driver structure.
+ *
+ * @param drv		The device driver structure.
  */
 static inline void init_driver(driver_t *drv)
@@ -254,11 +323,10 @@
 	list_initialize(&drv->match_ids.ids);
 	list_initialize(&drv->devices);
-	fibril_mutex_initialize(&drv->driver_mutex);	
-}
-
-/**
- * Device driver structure clean-up.
- * 
- * @param drv the device driver structure. 
+	fibril_mutex_initialize(&drv->driver_mutex);
+}
+
+/** Device driver structure clean-up.
+ *
+ * @param drv		The device driver structure.
  */
 static inline void clean_driver(driver_t *drv)
@@ -267,5 +335,5 @@
 
 	free_not_null(drv->name);
-	free_not_null(drv->binary_path); 
+	free_not_null(drv->binary_path);
 
 	clean_match_ids(&drv->match_ids);
@@ -274,8 +342,7 @@
 }
 
-/**
- * Delete device driver structure.
- * 
- *  @param drv the device driver structure.* 
+/** Delete device driver structure.
+ *
+ * @param drv		The device driver structure.
  */
 static inline void delete_driver(driver_t *drv)
@@ -287,12 +354,12 @@
 }
 
-// Device nodes
-/**
- * Create a new device node.
- * 
- * @return a device node structure.
- * 
- */
-static inline node_t * create_dev_node()
+
+/* Device nodes */
+
+/** Create a new device node.
+ *
+ * @return		A device node structure.
+ */
+static inline node_t *create_dev_node(void)
 {
 	node_t *res = malloc(sizeof(node_t));
@@ -308,30 +375,30 @@
 }
 
-/**
- * Delete a device node.
- * 
- * @param node a device node structure.
- * 
+/** Delete a device node.
+ *
+ * @param node		The device node structure.
  */
 static inline void delete_dev_node(node_t *node)
 {
-	assert(list_empty(&node->children) && NULL == node->parent && NULL == node->drv);
+	assert(list_empty(&node->children));
+	assert(NULL == node->parent);
+	assert(NULL == node->drv);
 	
 	clean_match_ids(&node->match_ids);
 	free_not_null(node->name);
 	free_not_null(node->pathname);
-	free(node);	
-}
-
-/**
- * Find the device node structure of the device witch has the specified handle.
- * 
+	free(node);
+}
+
+/** Find the device node structure of the device witch has the specified handle.
+ *
  * Device tree's rwlock should be held at least for reading.
- * 
- * @param tree the device tree where we look for the device node.
- * @param handle the handle of the device.
- * @return the device node. 
- */
-static inline node_t * find_dev_node_no_lock(dev_tree_t *tree, device_handle_t handle)
+ *
+ * @param tree		The device tree where we look for the device node.
+ * @param handle	The handle of the device.
+ * @return		The device node.
+ */
+static inline node_t *
+find_dev_node_no_lock(dev_tree_t *tree, device_handle_t handle)
 {
 	unsigned long key = handle;
@@ -340,19 +407,17 @@
 }
 
-/**
- * Find the device node structure of the device witch has the specified handle.
- * 
- * @param tree the device tree where we look for the device node.
- * @param handle the handle of the device.
- * @return the device node. 
- */
-static inline node_t * find_dev_node(dev_tree_t *tree, device_handle_t handle)
+/** Find the device node structure of the device witch has the specified handle.
+ *
+ * @param tree		The device tree where we look for the device node.
+ * @param handle	The handle of the device.
+ * @return		The device node.
+ */
+static inline node_t *
+find_dev_node(dev_tree_t *tree, device_handle_t handle)
 {
 	node_t *node = NULL;
 	
 	fibril_rwlock_read_lock(&tree->rwlock);
-	
 	node = find_dev_node_no_lock(tree, handle);
-	
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
@@ -360,22 +425,26 @@
 }
 
-node_t * find_dev_node_by_path(dev_tree_t *tree, char *path);
-node_t *find_node_child(node_t *parent, const char *name);
-
-// Device tree
-
-bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list);
-bool create_root_node(dev_tree_t *tree);
-bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent);
-
-// Device classes
-
-/** Create device class. 
- *   
- * @return device class.
- */
-static inline dev_class_t * create_dev_class()
-{
-	dev_class_t *cl = (dev_class_t *)malloc(sizeof(dev_class_t));
+extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
+extern node_t *find_node_child(node_t *, const char *);
+
+
+/* Device tree */
+
+extern bool init_device_tree(dev_tree_t *, driver_list_t *);
+extern bool create_root_node(dev_tree_t *);
+extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
+
+
+/* Device classes */
+
+/** Create device class.
+ *
+ * @return		Device class.
+ */
+static inline dev_class_t *create_dev_class(void)
+{
+	dev_class_t *cl;
+	
+	cl = (dev_class_t *) malloc(sizeof(dev_class_t));
 	if (NULL != cl) {
 		memset(cl, 0, sizeof(dev_class_t));
@@ -383,18 +452,21 @@
 		fibril_mutex_initialize(&cl->mutex);
 	}
-	return cl;	
-}
-
-/** Create device class info. 
- * 
- * @return device class info.
- */
-static inline dev_class_info_t * create_dev_class_info()
-{
-	dev_class_info_t *info = (dev_class_info_t *)malloc(sizeof(dev_class_info_t));
-	if (NULL != info) {
+	
+	return cl;
+}
+
+/** Create device class info.
+ *
+ * @return		Device class info.
+ */
+static inline dev_class_info_t *create_dev_class_info(void)
+{
+	dev_class_info_t *info;
+	
+	info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
+	if (NULL != info)
 		memset(info, 0, sizeof(dev_class_info_t));
-	}
-	return info;	
+	
+	return info;
 }
 
@@ -402,19 +474,23 @@
 {
 	size_t dev_idx;
+	
 	fibril_mutex_lock(&cl->mutex);
 	dev_idx = ++cl->curr_dev_idx;
 	fibril_mutex_unlock(&cl->mutex);
+	
 	return dev_idx;
 }
 
-char * create_dev_name_for_class(dev_class_t *cl, const char *base_dev_name);
-dev_class_info_t * add_device_to_class(node_t *dev, dev_class_t *cl, const char *base_dev_name);
-
-void init_class_list(class_list_t *class_list);
-
-dev_class_t * get_dev_class(class_list_t *class_list, char *class_name);
-dev_class_t * find_dev_class_no_lock(class_list_t *class_list, const char *class_name);
-
-static inline void add_dev_class_no_lock(class_list_t *class_list, dev_class_t *cl)
+extern char *create_dev_name_for_class(dev_class_t *, const char *);
+extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
+    const char *);
+
+extern void init_class_list(class_list_t *);
+
+extern dev_class_t *get_dev_class(class_list_t *, char *);
+extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *);
+
+static inline void
+add_dev_class_no_lock(class_list_t *class_list, dev_class_t *cl)
 {
 	list_append(&cl->link, &class_list->classes);
@@ -422,13 +498,14 @@
 
 
-// devmap devices
-
-node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle);
-node_t *find_devmap_class_device(class_list_t *classes, dev_handle_t devmap_handle);
-
-
-static inline void class_add_devmap_device(class_list_t *class_list, dev_class_info_t *cli)
-{
-	unsigned long key = (unsigned long)cli->devmap_handle;
+/* Devmap devices */
+
+extern node_t *find_devmap_tree_device(dev_tree_t *, dev_handle_t);
+extern node_t *find_devmap_class_device(class_list_t *, dev_handle_t);
+
+static inline void
+class_add_devmap_device(class_list_t *class_list, dev_class_info_t *cli)
+{
+	unsigned long key = (unsigned long) cli->devmap_handle;
+	
 	fibril_rwlock_write_lock(&class_list->rwlock);
 	hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
@@ -438,8 +515,8 @@
 static inline void tree_add_devmap_device(dev_tree_t *tree, node_t *node)
 {
-	unsigned long key = (unsigned long)node->devmap_handle;
+	unsigned long key = (unsigned long) node->devmap_handle;
 	fibril_rwlock_write_lock(&tree->rwlock);
 	hash_table_insert(&tree->devmap_devices, &key, &node->devmap_link);
-	fibril_rwlock_write_unlock(&tree->rwlock);	
+	fibril_rwlock_write_unlock(&tree->rwlock);
 }
 
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/main.c	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -63,9 +63,7 @@
 static class_list_t class_list;
 
-/**
- * Register running driver.
- */
-static driver_t * devman_driver_register(void)
-{	
+/** Register running driver. */
+static driver_t *devman_driver_register(void)
+{
 	printf(NAME ": devman_driver_register \n");
 	
@@ -81,13 +79,14 @@
 	char *drv_name = NULL;
 	
-	// Get driver name
-	int rc = async_data_write_accept((void **)&drv_name, true, 0, 0, 0, 0);
+	/* Get driver name. */
+	int rc = async_data_write_accept((void **) &drv_name, true, 0, 0, 0, 0);
 	if (rc != EOK) {
 		ipc_answer_0(iid, rc);
 		return NULL;
 	}
-	printf(NAME ": the %s driver is trying to register by the service.\n", drv_name);
-	
-	// Find driver structure
+	printf(NAME ": the %s driver is trying to register by the service.\n",
+	    drv_name);
+	
+	/* Find driver structure. */
 	driver = find_driver(&drivers_list, drv_name);
 	
@@ -103,8 +102,8 @@
 	drv_name = NULL;
 	
-	// Create connection to the driver
-	printf(NAME ":  creating connection to the %s driver.\n", driver->name);	
+	/* Create connection to the driver. */
+	printf(NAME ":  creating connection to the %s driver.\n", driver->name);
 	ipc_call_t call;
-	ipc_callid_t callid = async_get_call(&call);		
+	ipc_callid_t callid = async_get_call(&call);
 	if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
 		ipc_answer_0(callid, ENOTSUP);
@@ -113,11 +112,11 @@
 	}
 	
-	// remember driver's phone
+	/* Remember driver's phone. */
 	set_driver_phone(driver, IPC_GET_ARG5(call));
 	
-	printf(NAME ":  the %s driver was successfully registered as running.\n", driver->name);
-	
-	ipc_answer_0(callid, EOK);	
-	
+	printf(NAME ": the %s driver was successfully registered as running.\n",
+	    driver->name);
+	
+	ipc_answer_0(callid, EOK);
 	ipc_answer_0(iid, EOK);
 	
@@ -125,13 +124,12 @@
 }
 
-/**
- * Receive device match ID from the device's parent driver and add it to the list of devices match ids.
- * 
- * @param match_ids the list of the device's match ids.
- * 
- * @return 0 on success, negative error code otherwise. 
- */
-static int devman_receive_match_id(match_id_list_t *match_ids) {
-	
+/** Receive device match ID from the device's parent driver and add it to the
+ * list of devices match ids.
+ *
+ * @param match_ids	The list of the device's match ids.
+ * @return		Zero on success, negative error code otherwise.
+ */
+static int devman_receive_match_id(match_id_list_t *match_ids)
+{
 	match_id_t *match_id = create_match_id();
 	ipc_callid_t callid;
@@ -141,5 +139,6 @@
 	callid = async_get_call(&call);
 	if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
-		printf(NAME ": ERROR: devman_receive_match_id - invalid protocol.\n");
+		printf(NAME ": ERROR: devman_receive_match_id - invalid "
+		    "protocol.\n");
 		ipc_answer_0(callid, EINVAL); 
 		delete_match_id(match_id);
@@ -148,5 +147,6 @@
 	
 	if (NULL == match_id) {
-		printf(NAME ": ERROR: devman_receive_match_id - failed to allocate match id.\n");
+		printf(NAME ": ERROR: devman_receive_match_id - failed to "
+		    "allocate match id.\n");
 		ipc_answer_0(callid, ENOMEM);
 		return ENOMEM;
@@ -158,9 +158,10 @@
 	
 	char *match_id_str;
-	rc = async_data_write_accept((void **)&match_id_str, true, 0, 0, 0, 0);
+	rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0);
 	match_id->id = match_id_str;
 	if (EOK != rc) {
 		delete_match_id(match_id);
-		printf(NAME ": devman_receive_match_id - failed to receive match id string.\n");
+		printf(NAME ": devman_receive_match_id - failed to receive "
+		    "match id string.\n");
 		return rc;
 	}
@@ -168,37 +169,35 @@
 	list_append(&match_id->link, &match_ids->ids);
 	
-	printf(NAME ": received match id '%s', score = %d \n", match_id->id, match_id->score);
+	printf(NAME ": received match id '%s', score = %d \n",
+	    match_id->id, match_id->score);
 	return rc;
 }
 
-/**
- * Receive device match IDs from the device's parent driver 
- * and add them to the list of devices match ids.
- * 
- * @param match_count the number of device's match ids to be received.
- * @param match_ids the list of the device's match ids.
- * 
- * @return 0 on success, negative error code otherwise.
- */
-static int devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids) 
-{	
+/** Receive device match IDs from the device's parent driver and add them to the
+ * list of devices match ids.
+ *
+ * @param match_count	The number of device's match ids to be received.
+ * @param match_ids	The list of the device's match ids.
+ * @return		Zero on success, negative error code otherwise.
+ */
+static int
+devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids)
+{
 	int ret = EOK;
 	size_t i;
+	
 	for (i = 0; i < match_count; i++) {
-		if (EOK != (ret = devman_receive_match_id(match_ids))) {
+		if (EOK != (ret = devman_receive_match_id(match_ids)))
 			return ret;
-		}
 	}
 	return ret;
 }
 
-/** Handle child device registration. 
- * 
+/** Handle child device registration.
+ *
  * Child devices are registered by their parent's device driver.
  */
 static void devman_add_child(ipc_callid_t callid, ipc_call_t *call)
 {
-	//printf(NAME ": devman_add_child\n");
-	
 	device_handle_t parent_handle = IPC_GET_ARG1(*call);
 	ipcarg_t match_count = IPC_GET_ARG2(*call);
@@ -215,5 +214,5 @@
 	
 	char *dev_name = NULL;
-	int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);	
+	int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
 	if (EOK != rc) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
@@ -221,5 +220,4 @@
 		return;
 	}
-	//printf(NAME ": newly added child device's name is '%s'.\n", dev_name);
 	
 	node_t *node = create_dev_node();
@@ -236,27 +234,33 @@
 	devman_receive_match_ids(match_count, &node->match_ids);
 	
-	// return device handle to parent's driver
+	/* Return device handle to parent's driver. */
 	ipc_answer_1(callid, EOK, node->handle);
 	
-	// try to find suitable driver and assign it to the device
-	assign_driver(node, &drivers_list, &device_tree);	
+	/* Try to find suitable driver and assign it to the device. */
+	assign_driver(node, &drivers_list, &device_tree);
 }
 
 static void devmap_register_class_dev(dev_class_info_t *cli)
 {
-	// create devmap path and name for the device
+	/* Create devmap path and name for the device. */
 	char *devmap_pathname = NULL;
-	asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE, cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
-	if (NULL == devmap_pathname) {
-		return;
-	}
-	
-	// register the device by the device mapper and remember its devmap handle
-	devmap_device_register(devmap_pathname, &cli->devmap_handle);	
-	
-	// add device to the hash map of class devices registered by device mapper
+	asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
+	    cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
+	if (NULL == devmap_pathname)
+		return;
+	
+	/*
+	 * Register the device by the device mapper and remember its devmap
+	 * handle.
+	 */
+	devmap_device_register(devmap_pathname, &cli->devmap_handle);
+	
+	/*
+	 * Add device to the hash map of class devices registered by device
+	 * mapper.
+	 */
 	class_add_devmap_device(&class_list, cli);
 	
-	free(devmap_pathname);	
+	free(devmap_pathname);
 }
 
@@ -265,7 +269,8 @@
 	device_handle_t handle = IPC_GET_ARG1(*call);
 	
-	// Get class name
+	/* Get class name. */
 	char *class_name;
-	int rc = async_data_write_accept((void **)&class_name, true, 0, 0, 0, 0);
+	int rc = async_data_write_accept((void **) &class_name, true,
+	    0, 0, 0, 0);
 	if (rc != EOK) {
 		ipc_answer_0(callid, rc);
@@ -280,34 +285,34 @@
 	
 	dev_class_t *cl = get_dev_class(&class_list, class_name);
-		
 	dev_class_info_t *class_info = add_device_to_class(dev, cl, NULL);
 	
-	// register the device's class alias by devmapper
+	/* Register the device's class alias by devmapper. */
 	devmap_register_class_dev(class_info);
 	
-	printf(NAME ": device '%s' added to class '%s', class name '%s' was asigned to it\n", dev->pathname, class_name, class_info->dev_name);
-	
-	ipc_answer_0(callid, EOK);	
-}
-
-/**
- * Initialize driver which has registered itself as running and ready.
- * 
- * The initialization is done in a separate fibril to avoid deadlocks 
- * (if the driver needed to be served by devman during the driver's initialization). 
+	printf(NAME ": device '%s' added to class '%s', class name '%s' was "
+	    "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
+	
+	ipc_answer_0(callid, EOK);
+}
+
+/** Initialize driver which has registered itself as running and ready.
+ *
+ * The initialization is done in a separate fibril to avoid deadlocks (if the
+ * driver needed to be served by devman during the driver's initialization).
  */
 static int init_running_drv(void *drv)
 {
-	driver_t *driver = (driver_t *)drv;
-	initialize_running_driver(driver, &device_tree);	
-	printf(NAME ": the %s driver was successfully initialized. \n", driver->name);
+	driver_t *driver = (driver_t *) drv;
+	
+	initialize_running_driver(driver, &device_tree);
+	printf(NAME ": the %s driver was successfully initialized. \n",
+	    driver->name);
 	return 0;
 }
 
-/** Function for handling connections from a driver to the device manager.
- */
+/** Function for handling connections from a driver to the device manager. */
 static void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
-{	
-	/* Accept the connection */
+{
+	/* Accept the connection. */
 	ipc_answer_0(iid, EOK);
 	
@@ -316,18 +321,16 @@
 		return;
 	
-	// Initialize the driver as running (e.g. pass assigned devices to it) in a separate fibril;
-	// the separate fibril is used to enable the driver 
-	// to use devman service during the driver's initialization.
+	/*
+	 * Initialize the driver as running (e.g. pass assigned devices to it)
+	 * in a separate fibril; the separate fibril is used to enable the
+	 * driver to use devman service during the driver's initialization.
+	 */
 	fid_t fid = fibril_create(init_running_drv, driver);
 	if (fid == 0) {
-		printf(NAME ": Error creating fibril for the initialization of the newly registered running driver.\n");
+		printf(NAME ": Error creating fibril for the initialization of "
+		    "the newly registered running driver.\n");
 		return;
 	}
 	fibril_add_ready(fid);
-	
-	/*thread_id_t tid;
-	if (0 != thread_create(init_running_drv, driver, "init_running_drv", &tid)) {
-		printf(NAME ": failed to start the initialization of the newly registered running driver.\n");
-	}*/
 	
 	ipc_callid_t callid;
@@ -354,10 +357,11 @@
 }
 
-/** Find handle for the device instance identified by the device's path in the device tree.
- */
+/** Find handle for the device instance identified by the device's path in the
+ * device tree. */
 static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
 {
-	char *pathname;	
-	int rc = async_data_write_accept((void **)&pathname, true, 0, 0, 0, 0);
+	char *pathname;
+	
+	int rc = async_data_write_accept((void **) &pathname, true, 0, 0, 0, 0);
 	if (rc != EOK) {
 		ipc_answer_0(iid, rc);
@@ -365,5 +369,5 @@
 	}
 	
-	node_t * dev = find_dev_node_by_path(&device_tree, pathname); 
+	node_t * dev = find_dev_node_by_path(&device_tree, pathname);
 	
 	free(pathname);
@@ -378,9 +382,8 @@
 
 
-/** Function for handling connections from a client to the device manager.
- */
+/** Function for handling connections from a client to the device manager. */
 static void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
 {
-	/* Accept connection */
+	/* Accept connection. */
 	ipc_answer_0(iid, EOK);
 	
@@ -404,12 +407,13 @@
 }
 
-static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) {	
-	
+static void
+devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent)
+{
 	device_handle_t handle = IPC_GET_ARG2(*icall);
-	// printf(NAME ": devman_forward - trying to forward connection to device with handle %x.\n", handle);
 	
 	node_t *dev = find_dev_node(&device_tree, handle);
 	if (NULL == dev) {
-		printf(NAME ": devman_forward error - no device with handle %x was found.\n", handle);
+		printf(NAME ": devman_forward error - no device with handle %x "
+		    "was found.\n", handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -419,45 +423,45 @@
 	
 	if (drv_to_parent) {
-		if (NULL != dev->parent) {
-			driver = dev->parent->drv;		
-		}
+		if (NULL != dev->parent)
+			driver = dev->parent->drv;
 	} else if (DEVICE_USABLE == dev->state) {
-		driver = dev->drv;		
+		driver = dev->drv;
 		assert(NULL != driver);
 	}
 	
-	if (NULL == driver) {	
-		printf(NAME ": devman_forward error - the device is not in usable state.\n", handle);
+	if (NULL == driver) {
+		printf(NAME ": devman_forward error - the device is not in "
+		    "usable state.\n", handle);
 		ipc_answer_0(iid, ENOENT);
-		return;	
-	}
-	
-	int method;	
-	if (drv_to_parent) {
+		return;
+	}
+	
+	int method;
+	if (drv_to_parent)
 		method = DRIVER_DRIVER;
-	} else {
+	else
 		method = DRIVER_CLIENT;
-	}
 	
 	if (driver->phone <= 0) {
-		printf(NAME ": devman_forward: cound not forward to driver %s ", driver->name);
+		printf(NAME ": devman_forward: cound not forward to driver %s ",
+		    driver->name);
 		printf("the driver's phone is %x).\n", driver->phone);
 		ipc_answer_0(iid, EINVAL);
 		return;
 	}
-	printf(NAME ": devman_forward: forward connection to device %s to driver %s.\n", 
-		dev->pathname, driver->name);
-	ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);	
-}
-
-/** Function for handling connections from a client forwarded by the device mapper to the device manager.
- */
+	printf(NAME ": devman_forward: forward connection to device %s to "
+	    "driver %s.\n", dev->pathname, driver->name);
+	ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
+}
+
+/** Function for handling connections from a client forwarded by the device
+ * mapper to the device manager. */
 static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
 {
 	dev_handle_t devmap_handle = IPC_GET_METHOD(*icall);
+	
 	node_t *dev = find_devmap_tree_device(&device_tree, devmap_handle);
-	if (NULL == dev) {
+	if (NULL == dev)
 		dev = find_devmap_class_device(&class_list, devmap_handle);
-	}
 	
 	if (NULL == dev || NULL == dev->drv) {
@@ -471,28 +475,32 @@
 	}
 	
-	printf(NAME ": devman_connection_devmapper: forward connection to device %s to driver %s.\n", 
-		dev->pathname, dev->drv->name);
-	ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0, IPC_FF_NONE);	
-}
-
-/** Function for handling connections to device manager.
- *
- */
+	printf(NAME ": devman_connection_devmapper: forward connection to "
+	    "device %s to driver %s.\n", dev->pathname, dev->drv->name);
+	ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
+	    IPC_FF_NONE);
+}
+
+/** Function for handling connections to device manager. */
 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
-{	
-	// Silly hack to enable the device manager to register as a driver by the device mapper. 
-	// If the ipc method is not IPC_M_CONNECT_ME_TO, this is not the forwarded connection from naming service,
-	// so it must be a connection from the devmapper which thinks this is a devmapper-style driver. 
-	// So pretend this is a devmapper-style driver. 
-	// (This does not work for device with handle == IPC_M_CONNECT_ME_TO, 
-	// because devmapper passes device handle to the driver as an ipc method.)
-	if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall)) {
+{
+	/*
+	 * Silly hack to enable the device manager to register as a driver by
+	 * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this
+	 * is not the forwarded connection from naming service, so it must be a
+	 * connection from the devmapper which thinks this is a devmapper-style
+	 * driver. So pretend this is a devmapper-style driver. (This does not
+	 * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper
+	 * passes device handle to the driver as an ipc method.)
+	 */
+	if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))
 		devman_connection_devmapper(iid, icall);
-	}
-
-	// ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection from naming service
-	// by which we registered as device manager, so be device manager
-	
-	// Select interface 
+
+	/*
+	 * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection
+	 * from naming service by which we registered as device manager, so be
+	 * device manager.
+	 */
+	
+	/* Select interface. */
 	switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
 	case DEVMAN_DRIVER:
@@ -503,11 +511,11 @@
 		break;
 	case DEVMAN_CONNECT_TO_DEVICE:
-		// Connect client to selected device
+		/* Connect client to selected device. */
 		devman_forward(iid, icall, false);
 		break;
 	case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
-		// Connect client to selected device
+		/* Connect client to selected device. */
 		devman_forward(iid, icall, true);
-		break;		
+		break;
 	default:
 		/* No such interface */
@@ -516,30 +524,33 @@
 }
 
-/** Initialize device manager internal structures.
- */
-static bool devman_init()
-{
-	printf(NAME ": devman_init - looking for available drivers. \n");	
-	
-	// initialize list of available drivers
+/** Initialize device manager internal structures. */
+static bool devman_init(void)
+{
+	printf(NAME ": devman_init - looking for available drivers.\n");
+	
+	/* Initialize list of available drivers. */
 	init_driver_list(&drivers_list);
-	if (0 == lookup_available_drivers(&drivers_list, DRIVER_DEFAULT_STORE)) {
+	if (0 == lookup_available_drivers(&drivers_list,
+	    DRIVER_DEFAULT_STORE)) {
 		printf(NAME " no drivers found.");
 		return false;
 	}
-	printf(NAME ": devman_init  - list of drivers has been initialized. \n");
-
-	// create root device node 
+	printf(NAME ": devman_init  - list of drivers has been initialized.\n");
+
+	/* Create root device node. */
 	if (!init_device_tree(&device_tree, &drivers_list)) {
 		printf(NAME " failed to initialize device tree.");
-		return false;		
+		return false;
 	}
 
 	init_class_list(&class_list);
 	
-	// !!! devman_connection ... as the device manager is not a real devmap driver 
-	// (it uses a completely different ipc protocol than an ordinary devmap driver)
-	// forwarding a connection from client to the devman by devmapper would not work
-	devmap_driver_register(NAME, devman_connection);	
+	/*
+	 * !!! devman_connection ... as the device manager is not a real devmap
+	 * driver (it uses a completely different ipc protocol than an ordinary
+	 * devmap driver) forwarding a connection from client to the devman by
+	 * devmapper would not work.
+	 */
+	devmap_driver_register(NAME, devman_connection);
 	
 	return true;
@@ -555,8 +566,8 @@
 	}
 	
-	// Set a handler of incomming connections
+	/* Set a handler of incomming connections. */
 	async_set_client_connection(devman_connection);
 
-	// Register device manager at naming service
+	/* Register device manager at naming service. */
 	ipcarg_t phonead;
 	if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
@@ -566,5 +577,5 @@
 	async_manager();
 
-	// Never reached
+	/* Never reached. */
 	return 0;
 }
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/match.c	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -30,22 +30,19 @@
  * @{
  */
- 
- 
+
 #include <str.h>
 
 #include "devman.h"
 
-
 int get_match_score(driver_t *drv, node_t *dev)
-{	
-	link_t* drv_head = &drv->match_ids.ids;	
-	link_t* dev_head = &dev->match_ids.ids;
+{
+	link_t *drv_head = &drv->match_ids.ids;
+	link_t *dev_head = &dev->match_ids.ids;
 	
-	if (list_empty(drv_head) || list_empty(dev_head)) {
+	if (list_empty(drv_head) || list_empty(dev_head))
 		return 0;
-	}
 	
-	link_t* drv_link = drv->match_ids.ids.next;
-	link_t* dev_link = dev->match_ids.ids.next;
+	link_t *drv_link = drv->match_ids.ids.next;
+	link_t *dev_link = dev->match_ids.ids.next;
 	
 	match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
@@ -56,24 +53,42 @@
 	
 	do {
-		if (0 == str_cmp(drv_id->id, dev_id->id)) { 	// we found a match	
-			// return the score of the match
+		match_id_t *tmp_ma_id;
+	
+		if (0 == str_cmp(drv_id->id, dev_id->id)) {
+		 	/*
+		 	 * We found a match.
+		 	 * Return the score of the match.
+		 	 */
 			return drv_id->score * dev_id->score;
 		}
 		
-		// compute the next score we get, if we advance in the driver's list of match ids 
+		/*
+		 * Compute the next score we get, if we advance in the driver's
+		 * list of match ids.
+		 */
 		if (drv_head != drv_link->next) {
-			score_next_drv = dev_id->score * list_get_instance(drv_link->next, match_id_t, link)->score;			
+			tmp_ma_id = list_get_instance(drv_link->next,
+			    match_id_t, link);
+			score_next_drv = dev_id->score * tmp_ma_id->score;
 		} else {
 			score_next_drv = 0;
 		}
 		
-		// compute the next score we get, if we advance in the device's list of match ids 
+		/*
+		 * Compute the next score we get, if we advance in the device's
+		 * list of match ids.
+		 */
 		if (dev_head != dev_link->next) {
-			score_next_dev = drv_id->score * list_get_instance(dev_link->next, match_id_t, link)->score;			
+			tmp_ma_id = list_get_instance(dev_link->next,
+			    match_id_t, link);
+			score_next_dev = drv_id->score * tmp_ma_id->score;
 		} else {
 			score_next_dev = 0;
 		}
 		
-		// advance in one of the two lists, so we get the next highest score
+		/*
+		 * Advance in one of the two lists, so we get the next highest
+		 * score.
+		 */
 		if (score_next_drv > score_next_dev) {
 			drv_link = drv_link->next;
@@ -89,4 +104,4 @@
 }
 
-
-
+/** @}
+ */
Index: uspace/srv/devman/util.c
===================================================================
--- uspace/srv/devman/util.c	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/util.c	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -32,14 +32,13 @@
 
 #include <stdlib.h>
-#include <str.h> 
- 
+#include <str.h>
+
 #include "util.h"
- 
 
-char * get_abs_path(const char *base_path, const char *name, const char *ext) 
+char *get_abs_path(const char *base_path, const char *name, const char *ext)
 {
 	char *res;
 	int base_len = str_size(base_path);
-	int size = base_len + 2*str_size(name) + str_size(ext) + 3;	
+	int size = base_len + 2 * str_size(name) + str_size(ext) + 3;
 	
 	res = malloc(size);
@@ -47,14 +46,12 @@
 	if (res) {
 		str_cpy(res, size, base_path);
-		if(base_path[base_len - 1] != '/') { 
-			str_append(res, size, "/");			
-		}
+		if (base_path[base_len - 1] != '/')
+			str_append(res, size, "/");
 		str_append(res, size, name);
 		str_append(res, size, "/");
 		str_append(res, size, name);
-		if(ext[0] != '.') {
+		if (ext[0] != '.')
 			str_append(res, size, ".");
-		}
-		str_append(res, size, ext);		
+		str_append(res, size, ext);
 	}
 	
@@ -62,9 +59,11 @@
 }
 
-char * get_path_elem_end(char *path)
+char *get_path_elem_end(char *path)
 {
-	while (0 != *path && '/' != *path) {
+	while (0 != *path && '/' != *path)
 		path++;
-	}
 	return path;
 }
+
+/** @}
+ */
Index: uspace/srv/devman/util.h
===================================================================
--- uspace/srv/devman/util.h	(revision a79d88da204957831a1715d66a6d80828c09d5c1)
+++ uspace/srv/devman/util.h	(revision 472020fcce0d34f10b66ca0bd38c3b005abb9a4c)
@@ -30,5 +30,5 @@
  * @{
  */
- 
+
 #ifndef DEVMAN_UTIL_H_
 #define DEVMAN_UTIL_H_
@@ -38,19 +38,18 @@
 #include <malloc.h>
 
+extern char *get_abs_path(const char *, const char *, const char *);
+extern char *get_path_elem_end(char *);
 
-char * get_abs_path(const char *base_path, const char *name, const char *ext);
-char * get_path_elem_end(char *path);
-
-static inline bool skip_spaces(char **buf) 
+static inline bool skip_spaces(char **buf)
 {
-	while (isspace(**buf)) {
-		(*buf)++;		
-	}
-	return *buf != 0;	
+	while (isspace(**buf))
+		(*buf)++;
+	return *buf != 0;
 }
 
-static inline size_t get_nonspace_len(const char *str) 
+static inline size_t get_nonspace_len(const char *str)
 {
 	size_t len = 0;
+	
 	while(*str != 0 && !isspace(*str)) {
 		len++;
@@ -62,16 +61,16 @@
 static inline void free_not_null(const void *ptr)
 {
-	if (NULL != ptr) {
+	if (NULL != ptr)
 		free(ptr);
-	}
 }
 
-static inline char * clone_string(const char *s) 
+static inline char *clone_string(const char *s)
 {
 	size_t size = str_size(s) + 1;
-	char *str = (char *)malloc(size);
-	if (NULL != str) {
+	char *str;
+	
+	str = (char *) malloc(size);
+	if (NULL != str)
 		str_cpy(str, size, s);
-	}
 	return str;
 }
@@ -80,7 +79,6 @@
 {
 	while (*str) {
-		if (orig == *str) {
+		if (orig == *str)
 			*str = repl;
-		}
 		str++;
 	}
@@ -88,2 +86,5 @@
 
 #endif
+
+/** @}
+ */
