Index: uspace/drv/ehci-hcd/Makefile
===================================================================
--- uspace/drv/ehci-hcd/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ehci-hcd/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHOST_PREFIX)/libusbhost.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = ehci-hcd
 
Index: uspace/drv/ohci/Makefile
===================================================================
--- uspace/drv/ohci/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,16 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHOST_PREFIX)/libusbhost.a \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = ohci
 
Index: uspace/drv/ohci/hc.c
===================================================================
--- uspace/drv/ohci/hc.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/hc.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -40,5 +40,4 @@
 #include <usb/usb.h>
 #include <usb/ddfiface.h>
-#include <usb/usbdevice.h>
 
 #include "hc.h"
Index: uspace/drv/ohci/hw_struct/endpoint_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/endpoint_descriptor.h	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/hw_struct/endpoint_descriptor.h	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -40,5 +40,5 @@
 #include <usb/host/endpoint.h>
 
-#include "utils/malloc32.h"
+#include "../utils/malloc32.h"
 #include "transfer_descriptor.h"
 
Index: uspace/drv/ohci/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/ohci/hw_struct/transfer_descriptor.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/hw_struct/transfer_descriptor.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -33,6 +33,4 @@
  */
 #include <usb/usb.h>
-#include "utils/malloc32.h"
-
 #include "transfer_descriptor.h"
 
Index: uspace/drv/ohci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -37,5 +37,5 @@
 #include <bool.h>
 #include <stdint.h>
-#include "utils/malloc32.h"
+#include "../utils/malloc32.h"
 
 #include "completion_codes.h"
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/ohci/root_hub.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -41,4 +41,6 @@
 #include "usb/classes/classes.h"
 #include "usb/devdrv.h"
+#include "ohci_regs.h"
+
 #include <usb/request.h>
 #include <usb/classes/hub.h>
@@ -109,6 +111,6 @@
  */
 static const uint32_t hub_clear_feature_valid_mask =
-    (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
-(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+    RHS_OCIC_FLAG |
+    RHS_CLEAR_PORT_POWER;
 
 /**
@@ -116,5 +118,6 @@
  */
 static const uint32_t hub_clear_feature_by_writing_one_mask =
-    1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
+   RHS_CLEAR_PORT_POWER;
+   // 1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
 
 /**
@@ -122,6 +125,8 @@
  */
 static const uint32_t hub_set_feature_valid_mask =
-    (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
-(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
+    RHS_LPSC_FLAG |
+    RHS_OCIC_FLAG;
+    //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
+    //(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
 
 /**
@@ -129,5 +134,6 @@
  */
 static const uint32_t hub_set_feature_direct_mask =
-    (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+    RHS_SET_PORT_POWER;
+    //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
 
 /**
@@ -135,8 +141,8 @@
  */
 static const uint32_t port_set_feature_valid_mask =
-    (1 << USB_HUB_FEATURE_PORT_ENABLE) |
-(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
-(1 << USB_HUB_FEATURE_PORT_RESET) |
-(1 << USB_HUB_FEATURE_PORT_POWER);
+    RHPS_SET_PORT_ENABLE |
+    RHPS_SET_PORT_SUSPEND |
+    RHPS_SET_PORT_RESET |
+    RHPS_SET_PORT_POWER;
 
 /**
@@ -144,26 +150,39 @@
  */
 static const uint32_t port_clear_feature_valid_mask =
+    RHPS_CCS_FLAG |
+    RHPS_SET_PORT_SUSPEND |
+    RHPS_POCI_FLAG |
+    RHPS_SET_PORT_POWER |
+    RHPS_CSC_FLAG |
+    RHPS_PESC_FLAG |
+    RHPS_PSSC_FLAG |
+    RHPS_OCIC_FLAG |
+    RHPS_PRSC_FLAG;
+
+/*
+
     (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
-(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
-(1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
-(1 << USB_HUB_FEATURE_PORT_POWER) |
-(1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
-(1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
-(1 << USB_HUB_FEATURE_C_PORT_SUSPEND) |
-(1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
-(1 << USB_HUB_FEATURE_C_PORT_RESET);
+    (1 << USB_HUB_FEATURE_PORT_SUSPEND) |
+    (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
+    (1 << USB_HUB_FEATURE_PORT_POWER) |
+    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
+    (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
+    (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) |
+    (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
+    (1 << USB_HUB_FEATURE_C_PORT_RESET);
+ */
 //note that USB_HUB_FEATURE_PORT_POWER bit is translated into
-//USB_HUB_FEATURE_PORT_LOW_SPEED
+//USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request
 
 /**
  * bitmask with port status changes
  */
-static const uint32_t port_status_change_mask =
-    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
-(1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
-(1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
-(1 << USB_HUB_FEATURE_C_PORT_RESET) |
-(1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
-
+static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK;
+/*    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
+    (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
+    (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
+    (1 << USB_HUB_FEATURE_C_PORT_RESET) |
+    (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
+*/
 
 static int create_serialized_hub_descriptor(rh_t *instance);
Index: uspace/drv/uhci-hcd/Makefile
===================================================================
--- uspace/drv/uhci-hcd/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/uhci-hcd/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHOST_PREFIX)/libusbhost.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = uhci-hcd
 
Index: uspace/drv/uhci-hcd/hw_struct/queue_head.h
===================================================================
--- uspace/drv/uhci-hcd/hw_struct/queue_head.h	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/uhci-hcd/hw_struct/queue_head.h	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -38,5 +38,5 @@
 #include "link_pointer.h"
 #include "transfer_descriptor.h"
-#include "utils/malloc32.h"
+#include "../utils/malloc32.h"
 
 /** This structure is defined in UHCI design guide p. 31 */
Index: uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -36,5 +36,5 @@
 
 #include "transfer_descriptor.h"
-#include "utils/malloc32.h"
+#include "../utils/malloc32.h"
 
 /** Initialize Transfer Descriptor
Index: uspace/drv/uhci-rhd/Makefile
===================================================================
--- uspace/drv/uhci-rhd/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/uhci-rhd/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = uhci-rhd
 
Index: uspace/drv/usbflbk/Makefile
===================================================================
--- uspace/drv/usbflbk/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbflbk/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = usbflbk
 
Index: uspace/drv/usbhid/Makefile
===================================================================
--- uspace/drv/usbhid/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbhid/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,17 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHID_PREFIX)/libusbhid.a \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I. \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBUSBHID_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = usbhid
 
Index: uspace/drv/usbhub/Makefile
===================================================================
--- uspace/drv/usbhub/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbhub/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = usbhub
 
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbhub/usbhub.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -71,4 +71,7 @@
 
 static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info);
+
+static void usb_hub_polling_terminted_callback(usb_device_t * device,
+    bool was_error, void * data);
 
 
@@ -351,5 +354,5 @@
 	rc = usb_device_auto_poll(hub_info->usb_device, 0,
 	    hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1,
-	    NULL, hub_info);
+	    usb_hub_polling_terminted_callback, hub_info);
 	if (rc != EOK) {
 		usb_log_error("Failed to create polling fibril: %s.\n",
@@ -489,4 +492,23 @@
 
 /**
+ * callback called from hub polling fibril when the fibril terminates
+ *
+ * Should perform a cleanup - deletes hub_info.
+ * @param device usb device afected
+ * @param was_error indicates that the fibril is stoped due to an error
+ * @param data pointer to usb_hub_info_t structure
+ */
+static void usb_hub_polling_terminted_callback(usb_device_t * device,
+    bool was_error, void * data){
+	usb_hub_info_t * hub_info = data;
+	if(!hub_info) return;
+	free(hub_info->ports);
+	free(hub_info);
+}
+
+
+
+
+/**
  * @}
  */
Index: uspace/drv/usbkbd/Makefile
===================================================================
--- uspace/drv/usbkbd/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbkbd/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,17 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHID_PREFIX)/libusbhid.a \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I. \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBUSBHID_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = usbkbd
 
Index: uspace/drv/usbmast/Makefile
===================================================================
--- uspace/drv/usbmast/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmast/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,9 +28,18 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
 BINARY = usbmast
 
 SOURCES = \
+	inquiry.c \
 	main.c \
 	mast.c
Index: uspace/drv/usbmast/inquiry.c
===================================================================
--- uspace/drv/usbmast/inquiry.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
+++ uspace/drv/usbmast/inquiry.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 drvusbmast
+ * @{
+ */
+/**
+ * @file
+ * Main routines of USB mass storage driver.
+ */
+#include <usb/devdrv.h>
+#include <usb/debug.h>
+#include <usb/classes/classes.h>
+#include <usb/classes/massstor.h>
+#include <errno.h>
+#include <str_error.h>
+#include <str.h>
+#include <ctype.h>
+#include "cmds.h"
+#include "scsi.h"
+#include "mast.h"
+
+#define BITS_GET_MASK(type, bitcount) (((type)(1 << (bitcount)))-1)
+#define BITS_GET_MID_MASK(type, bitcount, offset) \
+	((type)( BITS_GET_MASK(type, (bitcount) + (offset)) - BITS_GET_MASK(type, bitcount) ))
+#define BITS_GET(type, number, bitcount, offset) \
+	((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset))
+
+#define INQUIRY_RESPONSE_LENGTH 36
+
+#define STR_UNKNOWN "<unknown>"
+
+/** String constants for SCSI peripheral device types. */
+static const char *str_peripheral_device_types[] = {
+	"direct-access device",
+	"sequential-access device",
+	"printer device",
+	"processor device",
+	"write-once device",
+	"CDROM device",
+	"scanner device",
+	"optical memory device",
+	"medium changer",
+	"communications device",
+	"graphic arts pre-press device",
+	"graphic arts pre-press device",
+	"storage array controller device",
+	"enclosure services device",
+	"simplified direct-access device",
+	"optical card reader/writer device",
+	"bridging expander",
+	"object-based storage device",
+	"automation driver interface",
+	STR_UNKNOWN, // 0x13
+	STR_UNKNOWN, // 0x14
+	STR_UNKNOWN, // 0x15
+	STR_UNKNOWN, // 0x16
+	STR_UNKNOWN, // 0x17
+	STR_UNKNOWN, // 0x18
+	STR_UNKNOWN, // 0x19
+	STR_UNKNOWN, // 0x1A
+	STR_UNKNOWN, // 0x1B
+	STR_UNKNOWN, // 0x1C
+	STR_UNKNOWN, // 0x1D
+	"well-known logical unit",
+	"uknown or no device state"
+};
+#define str_peripheral_device_types_count \
+	(sizeof(str_peripheral_device_types)/sizeof(str_peripheral_device_types[0]))
+
+/** Get string representation for SCSI peripheral device type.
+ *
+ * See for example here for a list
+ * http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type.
+ *
+ * @param type SCSI peripheral device type code.
+ * @return String representation.
+ */
+const char *usb_str_masstor_scsi_peripheral_device_type(int type)
+{
+	if ((type < 0)
+	    || ((size_t)type >= str_peripheral_device_types_count)) {
+		return STR_UNKNOWN;
+	}
+	return str_peripheral_device_types[type];
+}
+
+/** Trim trailing spaces from a string (rewrite with string terminator).
+ *
+ * @param name String to be trimmed (in-out parameter).
+ */
+static void trim_trailing_spaces(char *name)
+{
+	size_t len = str_length(name);
+	while ((len > 0) && isspace((int) name[len - 1])) {
+		name[len - 1] = 0;
+		len--;
+	}
+}
+
+/** Perform SCSI INQUIRY command on USB mass storage device.
+ *
+ * @param dev USB device.
+ * @param bulk_in_idx Index (in dev->pipes) of bulk in pipe.
+ * @param bulk_out_idx Index of bulk out pipe.
+ * @param inquiry_result Where to store parsed inquiry result.
+ * @return Error code.
+ */
+int usb_massstor_inquiry(usb_device_t *dev,
+    size_t bulk_in_idx, size_t bulk_out_idx,
+    usb_massstor_inquiry_result_t *inquiry_result)
+{
+	scsi_cmd_inquiry_t inquiry = {
+		.op_code = 0x12,
+		.lun_evpd = 0,
+		.page_code = 0,
+		.alloc_length = host2uint16_t_be(INQUIRY_RESPONSE_LENGTH),
+		.ctrl = 0
+	};
+	size_t response_len;
+	uint8_t response[INQUIRY_RESPONSE_LENGTH];
+
+	int rc;
+
+	rc = usb_massstor_data_in(dev, bulk_in_idx, bulk_out_idx,
+	    0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry),
+	    response, INQUIRY_RESPONSE_LENGTH, &response_len);
+
+	if (rc != EOK) {
+		usb_log_error("Failed to probe device %s using %s: %s.\n",
+		   dev->ddf_dev->name, "SCSI:INQUIRY", str_error(rc));
+		return rc;
+	}
+
+	if (response_len < 8) {
+		usb_log_error("The SCSI response is too short.\n");
+		return ERANGE;
+	}
+
+	/*
+	 * This is an ugly part of the code. We will parse the returned
+	 * data by hand and try to get as many useful data as possible.
+	 */
+	bzero(inquiry_result, sizeof(*inquiry_result));
+
+	/* This shall be returned by all devices. */
+	inquiry_result->peripheral_device_type
+	    = BITS_GET(uint8_t, response[0], 5, 0);
+	inquiry_result->removable = BITS_GET(uint8_t, response[1], 1, 7);
+
+	if (response_len < 32) {
+		return EOK;
+	}
+
+	str_ncpy(inquiry_result->vendor_id, 9,
+	    (const char *) &response[8], 8);
+	trim_trailing_spaces(inquiry_result->vendor_id);
+
+	str_ncpy(inquiry_result->product_and_revision, 12,
+	    (const char *) &response[16], 11);
+	trim_trailing_spaces(inquiry_result->product_and_revision);
+
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/usbmast/main.c
===================================================================
--- uspace/drv/usbmast/main.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmast/main.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -75,65 +75,4 @@
 };
 
-#define BITS_GET_MASK(type, bitcount) (((type)(1 << (bitcount)))-1)
-#define BITS_GET_MID_MASK(type, bitcount, offset) \
-	((type)( BITS_GET_MASK(type, (bitcount) + (offset)) - BITS_GET_MASK(type, bitcount) ))
-#define BITS_GET(type, number, bitcount, offset) \
-	((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset))
-
-#define INQUIRY_RESPONSE_LENGTH 35
-
-static void try_inquiry(usb_device_t *dev)
-{
-	scsi_cmd_inquiry_t inquiry = {
-		.op_code = 0x12,
-		.lun_evpd = 0,
-		.page_code = 0,
-		.alloc_length = INQUIRY_RESPONSE_LENGTH,
-		.ctrl = 0
-	};
-	size_t response_len;
-	uint8_t response[INQUIRY_RESPONSE_LENGTH];
-
-	int rc;
-
-	rc = usb_massstor_data_in(GET_BULK_IN(dev), GET_BULK_OUT(dev),
-	    0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry),
-	    response, INQUIRY_RESPONSE_LENGTH, &response_len);
-
-	if (rc != EOK) {
-		usb_log_error("Failed to probe device %s using %s: %s.\n",
-		   dev->ddf_dev->name, "SCSI:INQUIRY", str_error(rc));
-		return;
-	}
-
-	if (response_len < 8) {
-		usb_log_error("The SCSI response is too short.\n");
-		return;
-	}
-
-	/*
-	 * This is an ugly part of the code. We will parse the returned
-	 * data by hand and try to get as many useful data as possible.
-	 */
-	int device_type = BITS_GET(uint8_t, response[0], 5, 0);
-	int removable = BITS_GET(uint8_t, response[1], 1, 7);
-
-	usb_log_info("SCSI information for device `%s':\n", dev->ddf_dev->name);
-	usb_log_info("  - peripheral device type: %d\n", device_type);
-	usb_log_info("  - removable: %s\n", removable ? "yes" : "no");
-
-	if (response_len < 32) {
-		return;
-	}
-
-	char dev_vendor[9];
-	str_ncpy(dev_vendor, 9, (const char *) &response[8], 8);
-	usb_log_info("  - vendor: '%s'\n", dev_vendor);
-
-	char dev_product[9];
-	str_ncpy(dev_product, 9, (const char *) &response[16], 8);
-	usb_log_info("  - product: '%s'\n", dev_vendor);
-}
-
 /** Callback when new device is attached and recognized as a mass storage.
  *
@@ -168,5 +107,21 @@
 	    (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
 
-	try_inquiry(dev);
+	size_t lun_count = usb_masstor_get_lun_count(dev);
+
+	usb_massstor_inquiry_result_t inquiry;
+	rc = usb_massstor_inquiry(dev, BULK_IN_EP, BULK_OUT_EP, &inquiry);
+	if (rc != EOK) {
+		usb_log_warning("Failed to inquiry device `%s': %s.\n",
+		    dev->ddf_dev->name, str_error(rc));
+		return EOK;
+	}
+
+	usb_log_info("Mass storage `%s': " \
+	    "`%s' by `%s' is %s (%s), %zu LUN(s).\n",
+	    dev->ddf_dev->name,
+	    inquiry.product_and_revision, inquiry.vendor_id,
+	    usb_str_masstor_scsi_peripheral_device_type(inquiry.peripheral_device_type),
+	    inquiry.removable ? "removable" : "non-removable",
+	    lun_count);
 
 	return EOK;
Index: uspace/drv/usbmast/mast.c
===================================================================
--- uspace/drv/usbmast/mast.c	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmast/mast.c	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -40,4 +40,5 @@
 #include <str_error.h>
 #include <usb/debug.h>
+#include <usb/request.h>
 
 bool usb_mast_verbose = true;
@@ -63,5 +64,6 @@
  * @return Error code.
  */
-int usb_massstor_data_in(usb_pipe_t *bulk_in_pipe, usb_pipe_t *bulk_out_pipe,
+int usb_massstor_data_in(usb_device_t *dev,
+    size_t bulk_in_pipe_index, size_t bulk_out_pipe_index,
     uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size,
     void *in_buffer, size_t in_buffer_size, size_t *received_size)
@@ -69,4 +71,6 @@
 	int rc;
 	size_t act_size;
+	usb_pipe_t *bulk_in_pipe = dev->pipes[bulk_in_pipe_index].pipe;
+	usb_pipe_t *bulk_out_pipe = dev->pipes[bulk_out_pipe_index].pipe;
 
 	/* Prepare CBW - command block wrapper */
@@ -135,4 +139,83 @@
 }
 
+/** Perform bulk-only mass storage reset.
+ *
+ * @param dev Device to be reseted.
+ * @return Error code.
+ */
+int usb_massstor_reset(usb_device_t *dev)
+{
+	return usb_control_request_set(&dev->ctrl_pipe,
+	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
+	    0xFF, 0, dev->interface_no, NULL, 0);
+}
+
+/** Perform complete reset recovery of bulk-only mass storage.
+ *
+ * Notice that no error is reported because if this fails, the error
+ * would reappear on next transaction somehow.
+ *
+ * @param dev Device to be reseted.
+ * @param bulk_in_idx Index of bulk in pipe.
+ * @param bulk_out_idx Index of bulk out pipe.
+ */
+void usb_massstor_reset_recovery(usb_device_t *dev,
+    size_t bulk_in_idx, size_t bulk_out_idx)
+{
+	/* We would ignore errors here because if this fails
+	 * we are doomed anyway and any following transaction would fail.
+	 */
+	usb_massstor_reset(dev);
+	usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_in_idx].pipe);
+	usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_out_idx].pipe);
+}
+
+/** Get max LUN of a mass storage device.
+ *
+ * @see usb_masstor_get_lun_count
+ *
+ * @warning Error from this command does not necessarily indicate malfunction
+ * of the device. Device does not need to support this request.
+ * You shall rather use usb_masstor_get_lun_count.
+ *
+ * @param dev Mass storage device.
+ * @return Error code of maximum LUN (index, not count).
+ */
+int usb_massstor_get_max_lun(usb_device_t *dev)
+{
+	uint8_t max_lun;
+	size_t data_recv_len;
+	int rc = usb_control_request_get(&dev->ctrl_pipe,
+	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
+	    0xFE, 0, dev->interface_no, &max_lun, 1, &data_recv_len);
+	if (rc != EOK) {
+		return rc;
+	}
+	if (data_recv_len != 1) {
+		return EEMPTY;
+	}
+	return (int) max_lun;
+}
+
+/** Get number of LUNs supported by mass storage device.
+ *
+ * @warning This function hides any error during the request
+ * (typically that shall not be a problem).
+ *
+ * @param dev Mass storage device.
+ * @return Number of LUNs.
+ */
+size_t usb_masstor_get_lun_count(usb_device_t *dev)
+{
+	int max_lun = usb_massstor_get_max_lun(dev);
+	if (max_lun < 0) {
+		max_lun = 1;
+	} else {
+		max_lun++;
+	}
+
+	return (size_t) max_lun;
+}
+
 /**
  * @}
Index: uspace/drv/usbmast/mast.h
===================================================================
--- uspace/drv/usbmast/mast.h	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmast/mast.h	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -40,7 +40,30 @@
 #include <usb/usb.h>
 #include <usb/pipes.h>
+#include <usb/devdrv.h>
 
-int usb_massstor_data_in(usb_pipe_t *, usb_pipe_t *, uint32_t, uint8_t,
-    void *, size_t, void *, size_t, size_t *);
+/** Result of SCSI INQUIRY command.
+ * This is already parsed structure, not the original buffer returned by
+ * the device.
+ */
+typedef struct {
+	/** SCSI peripheral device type. */
+	int peripheral_device_type;
+	/** Whether the device is removable. */
+	bool removable;
+	/** Vendor ID string. */
+	char vendor_id[9];
+	/** Product ID and product revision string. */
+	char product_and_revision[12];
+} usb_massstor_inquiry_result_t;
+
+int usb_massstor_data_in(usb_device_t *dev, size_t, size_t,
+    uint32_t, uint8_t, void *, size_t, void *, size_t, size_t *);
+int usb_massstor_reset(usb_device_t *);
+void usb_massstor_reset_recovery(usb_device_t *, size_t, size_t);
+int usb_massstor_get_max_lun(usb_device_t *);
+size_t usb_masstor_get_lun_count(usb_device_t *);
+int usb_massstor_inquiry(usb_device_t *, size_t, size_t,
+    usb_massstor_inquiry_result_t *);
+const char *usb_str_masstor_scsi_peripheral_device_type(int);
 
 #endif
Index: uspace/drv/usbmid/Makefile
===================================================================
--- uspace/drv/usbmid/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmid/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,14 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+	
 BINARY = usbmid
 
Index: uspace/drv/usbmouse/Makefile
===================================================================
--- uspace/drv/usbmouse/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/usbmouse/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -28,6 +28,15 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
+
+LIBS = \
+	$(LIBUSBHID_PREFIX)/libusbhid.a \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBUSBHID_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
 
 BINARY = usbmouse
Index: uspace/drv/vhc/Makefile
===================================================================
--- uspace/drv/vhc/Makefile	(revision 81db65bb2c2709895ffd352bc91bb2435f6b2de0)
+++ uspace/drv/vhc/Makefile	(revision a29529b94721f1f6d73bfa8b2239295a3db8052e)
@@ -29,4 +29,6 @@
 USPACE_PREFIX = ../..
 LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSBHOST_PREFIX)/libusbhost.a \
 	$(LIBUSB_PREFIX)/libusb.a \
 	$(LIBUSBVIRT_PREFIX)/libusbvirt.a \
@@ -34,4 +36,6 @@
 EXTRA_CFLAGS += \
 	-I$(LIBUSBVIRT_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBUSBHOST_PREFIX)/include \
 	-I$(LIBUSB_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
