Index: uspace/drv/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/usbhid/mouse/mousedev.c	(revision faa44e5822a62f097605f7e1a86f8019bcb3872e)
+++ uspace/drv/usbhid/mouse/mousedev.c	(revision 4939490cae5fd9a05bae96b3bf07c5736e2d68af)
@@ -122,7 +122,7 @@
 	sysarg_t method = IPC_GET_IMETHOD(*icall);
 	
-	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
-	
-	if (hid_dev == NULL || hid_dev->data == NULL) {
+	usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;
+	
+	if (mouse_dev == NULL) {
 		usb_log_debug("default_connection_handler: Missing "
 		    "parameters.\n");
@@ -131,7 +131,8 @@
 	}
 	
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
+	usb_log_debug("default_connection_handler: fun->name: %s\n",
+	              fun->name);
+	usb_log_debug("default_connection_handler: mouse_phone: %d, wheel "
+	    "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone);
 	
 	int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) 
@@ -145,10 +146,9 @@
 			    "phone to mouse already set.\n");
 			async_answer_0(icallid, ELIMIT);
-			//async_answer_0(icallid, EOK);
 			return;
 		}
 
 		*phone = callback;
-		usb_log_debug("Console phone to mouse set ok (%d).\n", callback);
+		usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);
 		async_answer_0(icallid, EOK);
 		return;
@@ -224,8 +224,9 @@
 /*----------------------------------------------------------------------------*/
 
-static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-    size_t buffer_size)
-{
-	usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
+static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, 
+                                     usb_mouse_t *mouse_dev, uint8_t *buffer,
+                                     size_t buffer_size)
+{
+	assert(mouse_dev != NULL);
 	
 	usb_log_debug2("got buffer: %s.\n",
@@ -378,6 +379,9 @@
 /*----------------------------------------------------------------------------*/
 
-static int usb_mouse_create_function(usb_hid_dev_t *hid_dev)
-{
+static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
+{
+	assert(hid_dev != NULL);
+	assert(mouse != NULL);
+	
 	/* Create the function exposed under /dev/devices. */
 	usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
@@ -389,10 +393,6 @@
 	}
 	
-	/*
-	 * Store the initialized HID device and HID ops
-	 * to the DDF function.
-	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &mouse->ops;
+	fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
 
 	int rc = ddf_fun_bind(fun);
@@ -431,6 +431,6 @@
 	 * to the DDF function.
 	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &mouse->ops;
+	fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
 
 	rc = ddf_fun_bind(fun);
@@ -458,5 +458,5 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_mouse_init(usb_hid_dev_t *hid_dev)
+int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
 {
 	usb_log_debug("Initializing HID/Mouse structure...\n");
@@ -485,8 +485,9 @@
 	
 	// save the Mouse device structure into the HID device structure
-	hid_dev->data = mouse_dev;
+	*data = mouse_dev;
 	
 	// set handler for incoming calls
-	hid_dev->ops.default_handler = default_connection_handler;
+	// TODO: must be one for each subdriver!!
+	mouse_dev->ops.default_handler = default_connection_handler;
 	
 	// TODO: how to know if the device supports the request???
@@ -494,5 +495,5 @@
 //	    hid_dev->usb_dev->interface_no, IDLE_RATE);
 	
-	int rc = usb_mouse_create_function(hid_dev);
+	int rc = usb_mouse_create_function(hid_dev, mouse_dev);
 	if (rc != EOK) {
 		usb_mouse_free(&mouse_dev);
@@ -505,11 +506,11 @@
 /*----------------------------------------------------------------------------*/
 
-bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-     size_t buffer_size)
+bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data, 
+     uint8_t *buffer, size_t buffer_size)
 {
 	usb_log_debug("usb_mouse_polling_callback()\n");
 	usb_debug_str_buffer(buffer, buffer_size, 0);
 	
-	if (hid_dev == NULL) {
+	if (hid_dev == NULL || data == NULL) {
 		usb_log_error("Missing argument to the mouse polling callback."
 		    "\n");
@@ -517,18 +518,17 @@
 	}
 	
-	if (hid_dev->data == NULL) {
-		usb_log_error("Wrong argument to the mouse polling callback."
-		    "\n");
-		return false;
-	}
-	
-	return usb_mouse_process_report(hid_dev, buffer, buffer_size);
-}
-
-/*----------------------------------------------------------------------------*/
-
-void usb_mouse_deinit(usb_hid_dev_t *hid_dev)
-{
-	usb_mouse_free((usb_mouse_t **)&hid_dev->data);
+	usb_mouse_t *mouse_dev = (usb_mouse_t *)data;
+		
+	return usb_mouse_process_report(hid_dev, mouse_dev, buffer, 
+	                                buffer_size);
+}
+
+/*----------------------------------------------------------------------------*/
+
+void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data)
+{
+	if (data != NULL) {
+		usb_mouse_free((usb_mouse_t **)&data);
+	}
 }
 
