Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 80136376d214f46fb63a3d7a552c74395a0128b1)
+++ uspace/lib/drv/generic/driver.c	(revision 56fd7cf53b8ee7af3e78e2237e566926562e0291)
@@ -36,4 +36,6 @@
 /** @file
  */
+
+#define _DDF_DATA_IMPLANT
 
 #include <assert.h>
@@ -58,4 +60,5 @@
 #include "ddf/driver.h"
 #include "ddf/interrupt.h"
+#include "private/driver.h"
 
 /** Driver structure */
@@ -523,4 +526,6 @@
 static void delete_device(ddf_dev_t *dev)
 {
+	if (dev->parent_sess)
+		async_hangup(dev->parent_sess);
 	if (dev->driver_data != NULL)
 		free(dev->driver_data);
@@ -597,4 +602,96 @@
 }
 
+/** Implant foreign driver-specific device data.
+ *
+ * XXX This is used to transition USB to new interface. Do not use
+ * in new code. Use of this function must be removed.
+ */
+void ddf_fun_data_implant(ddf_fun_t *fun, void *data)
+{
+	assert(fun->driver_data == NULL);
+	fun->driver_data = data;
+}
+
+/** Return driver-specific device data. */
+void *ddf_dev_data_get(ddf_dev_t *dev)
+{
+	return dev->driver_data;
+}
+
+/** Get device handle. */
+devman_handle_t ddf_dev_get_handle(ddf_dev_t *dev)
+{
+	return dev->handle;
+}
+
+/** Return device name.
+ *
+ * @param dev	Device
+ * @return	Device name. Valid as long as @a dev is valid.
+ */
+const char *ddf_dev_get_name(ddf_dev_t *dev)
+{
+	return dev->name;
+}
+
+/** Create session with the parent function.
+ *
+ * The session will be automatically closed when @a dev is destroyed.
+ *
+ * @param dev	Device
+ * @param mgmt	Exchange management style
+ * @return	New session or NULL if session could not be created
+ */
+async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)
+{
+	assert(dev->parent_sess == NULL);
+	dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,
+	    IPC_FLAG_BLOCKING);
+
+	return dev->parent_sess;
+}
+
+/** Return existing session with the parent function.
+ *
+ * @param dev	Device
+ * @return	Existing session or NULL if there is no session
+ */
+async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *dev)
+{
+	return dev->parent_sess;
+}
+
+/** Set function name (if it was not specified when node was created.)
+ *
+ * @param dev	Device whose name has not been set yet
+ * @param name	Name, will be copied
+ * @return	EOK on success, ENOMEM if out of memory
+ */
+int ddf_fun_set_name(ddf_fun_t *dev, const char *name)
+{
+	assert(dev->name == NULL);
+
+	dev->name = str_dup(name);
+	if (dev->name == NULL)
+		return ENOENT;
+
+	return EOK;
+}
+
+/** Get device to which function belongs. */
+ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *fun)
+{
+	return fun->dev;
+}
+
+/** Get function handle.
+ *
+ * XXX USB uses this, but its use should be eliminated.
+ */
+devman_handle_t ddf_fun_get_handle(ddf_fun_t *fun)
+{
+	return fun->handle;
+}
+
 /** Create a DDF function node.
  *
@@ -608,5 +705,7 @@
  * This function should only fail if there is not enough free memory.
  * Specifically, this function succeeds even if @a dev already has
- * a (bound) function with the same name.
+ * a (bound) function with the same name. @a name can be NULL in which
+ * case the caller will set the name later using ddf_fun_set_name().
+ * He must do this before binding the function.
  *
  * Type: A function of type fun_inner indicates that DDF should attempt
@@ -616,5 +715,5 @@
  * @param dev		Device to which we are adding function
  * @param ftype		Type of function (fun_inner or fun_exposed)
- * @param name		Name of function
+ * @param name		Name of function or NULL
  *
  * @return		New function or @c NULL if memory is not available
@@ -633,8 +732,10 @@
 	fun->ftype = ftype;
 	
-	fun->name = str_dup(name);
-	if (fun->name == NULL) {
-		delete_function(fun);
-		return NULL;
+	if (name != NULL) {
+		fun->name = str_dup(name);
+		if (fun->name == NULL) {
+			delete_function(fun);
+			return NULL;
+		}
 	}
 	
@@ -654,4 +755,20 @@
 	fun->driver_data = data;
 	return data;
+}
+
+/** Return driver-specific function data. */
+void *ddf_fun_data_get(ddf_fun_t *fun)
+{
+	return fun->driver_data;
+}
+
+/** Return function name.
+ *
+ * @param fun	Function
+ * @return	Function name. Valid as long as @a fun is valid.
+ */
+const char *ddf_fun_get_name(ddf_fun_t *fun)
+{
+	return fun->name;
 }
 
@@ -805,4 +922,21 @@
 	add_match_id(&fun->match_ids, match_id);
 	return EOK;
+}
+
+/** Set function ops. */
+void ddf_fun_set_ops(ddf_fun_t *fun, ddf_dev_ops_t *dev_ops)
+{
+	assert(fun->conn_handler == NULL);
+	fun->ops = dev_ops;
+}
+
+/** Set user-defined connection handler.
+ *
+ * This allows handling connections the non-devman way.
+ */
+void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn)
+{
+	assert(fun->ops == NULL);
+	fun->conn_handler = conn;
 }
 
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision 80136376d214f46fb63a3d7a552c74395a0128b1)
+++ uspace/lib/drv/generic/interrupt.c	(revision 56fd7cf53b8ee7af3e78e2237e566926562e0291)
@@ -41,4 +41,5 @@
 
 #include "ddf/interrupt.h"
+#include "private/driver.h"
 
 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall);
Index: uspace/lib/drv/generic/private/driver.h
===================================================================
--- uspace/lib/drv/generic/private/driver.h	(revision 56fd7cf53b8ee7af3e78e2237e566926562e0291)
+++ uspace/lib/drv/generic/private/driver.h	(revision 56fd7cf53b8ee7af3e78e2237e566926562e0291)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2012 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+
+#ifndef DDF_PRIVATE_DRIVER_H_
+#define DDF_PRIVATE_DRIVER_H_
+
+#include <async.h>
+#include <ipc/devman.h>
+#include <ipc/dev_iface.h>
+#include "dev_iface.h"
+
+/** Device structure */
+struct ddf_dev {
+	/**
+	 * Globally unique device identifier (assigned to the device by the
+	 * device manager).
+	 */
+	devman_handle_t handle;
+	
+	/** Reference count */
+	atomic_t refcnt;
+	
+	/** Session with the parent device driver */
+	async_sess_t *parent_sess;
+	
+	/** Device name */
+	const char *name;
+	
+	/** Driver-specific data associated with this device */
+	void *driver_data;
+	
+	/** Link in the list of devices handled by the driver */
+	link_t link;
+};
+
+/** Function structure */
+struct ddf_fun {
+	/** True if bound to the device manager */
+	bool bound;
+	
+	/** Function indentifier (asigned by device manager) */
+	devman_handle_t handle;
+	
+	/** Reference count */
+	atomic_t refcnt;
+	
+	/** Device which this function belogs to */
+	struct ddf_dev *dev;
+	
+	/** Function type */
+	fun_type_t ftype;
+	
+	/** Function name */
+	const char *name;
+	
+	/** List of device ids for driver matching */
+	match_id_list_t match_ids;
+	
+	/** Driver-specific data associated with this function */
+	void *driver_data;
+	
+	/** Implementation of operations provided by this function */
+	ddf_dev_ops_t *ops;
+	
+	/** Connection handler or @c NULL to use the DDF default handler. */
+	async_client_conn_t conn_handler;
+	
+	/** Link in the list of functions handled by the driver */
+	link_t link;
+};
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/ddf/driver.h
===================================================================
--- uspace/lib/drv/include/ddf/driver.h	(revision 80136376d214f46fb63a3d7a552c74395a0128b1)
+++ uspace/lib/drv/include/ddf/driver.h	(revision 56fd7cf53b8ee7af3e78e2237e566926562e0291)
@@ -42,10 +42,11 @@
 #include "../dev_iface.h"
 
-typedef struct ddf_dev ddf_dev_t;
-typedef struct ddf_fun ddf_fun_t;
 
 /*
  * Device
  */
+
+typedef struct ddf_dev ddf_dev_t;
+typedef struct ddf_fun ddf_fun_t;
 
 /** Devices operations */
@@ -75,65 +76,8 @@
 
 /** Device structure */
-struct ddf_dev {
-	/**
-	 * Globally unique device identifier (assigned to the device by the
-	 * device manager).
-	 */
-	devman_handle_t handle;
-	
-	/** Reference count */
-	atomic_t refcnt;
-	
-	/**
-	 * Session to the parent device driver (if it is different from this
-	 * driver)
-	 */
-	async_sess_t *parent_sess;
-	
-	/** Device name */
-	const char *name;
-	
-	/** Driver-specific data associated with this device */
-	void *driver_data;
-	
-	/** Link in the list of devices handled by the driver */
-	link_t link;
-};
+struct ddf_dev;
 
 /** Function structure */
-struct ddf_fun {
-	/** True if bound to the device manager */
-	bool bound;
-	
-	/** Function indentifier (asigned by device manager) */
-	devman_handle_t handle;
-	
-	/** Reference count */
-	atomic_t refcnt;
-	
-	/** Device which this function belogs to */
-	ddf_dev_t *dev;
-	
-	/** Function type */
-	fun_type_t ftype;
-	
-	/** Function name */
-	const char *name;
-	
-	/** List of device ids for driver matching */
-	match_id_list_t match_ids;
-	
-	/** Driver-specific data associated with this function */
-	void *driver_data;
-	
-	/** Implementation of operations provided by this function */
-	ddf_dev_ops_t *ops;
-	
-	/** Connection handler or @c NULL to use the DDF default handler. */
-	async_client_conn_t conn_handler;
-	
-	/** Link in the list of functions handled by the driver */
-	link_t link;
-};
+struct ddf_fun;
 
 /*
@@ -167,10 +111,25 @@
 } driver_t;
 
+/** XXX Only to transition USB */
+#ifdef _DDF_DATA_IMPLANT
+extern void ddf_fun_data_implant(ddf_fun_t *, void *);
+#endif
+
 extern int ddf_driver_main(driver_t *);
 
 extern void *ddf_dev_data_alloc(ddf_dev_t *, size_t);
+extern void *ddf_dev_data_get(ddf_dev_t *);
+extern devman_handle_t ddf_dev_get_handle(ddf_dev_t *);
+extern const char *ddf_dev_get_name(ddf_dev_t *);
+extern async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *, exch_mgmt_t);
+extern async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *);
 extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
+extern devman_handle_t ddf_fun_get_handle(ddf_fun_t *);
 extern void ddf_fun_destroy(ddf_fun_t *);
 extern void *ddf_fun_data_alloc(ddf_fun_t *, size_t);
+extern void *ddf_fun_data_get(ddf_fun_t *);
+extern const char *ddf_fun_get_name(ddf_fun_t *);
+extern int ddf_fun_set_name(ddf_fun_t *, const char *);
+extern ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *);
 extern int ddf_fun_bind(ddf_fun_t *);
 extern int ddf_fun_unbind(ddf_fun_t *);
@@ -178,5 +137,6 @@
 extern int ddf_fun_offline(ddf_fun_t *);
 extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
-
+extern void ddf_fun_set_ops(ddf_fun_t *, ddf_dev_ops_t *);
+extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_client_conn_t);
 extern int ddf_fun_add_to_category(ddf_fun_t *, const char *);
 
