diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f5adce049b35ed8351b19c15c4c2518bd86cd5b6..78e910b2046c6516b12f34965f3b044dbc1feebd 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2414,6 +2414,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
 		usb_set_device_state(udev, USB_STATE_POWERED);
 		udev->speed = USB_SPEED_UNKNOWN;
  		udev->bus_mA = hub->mA_per_port;
+		udev->level = hdev->level + 1;
 
 		/* set the address */
 		choose_address(udev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index c66303285a4570e64fc9f10d1cde3c586e382fd9..df5c93eb3ce9cc1336b75bd44dcae67107df1fbf 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -348,6 +348,7 @@ struct usb_device {
 
 	unsigned short bus_mA;		/* Current available from the bus */
 	u8 portnum;			/* Parent port number (origin 1) */
+	u8 level;			/* Number of USB hub ancestors */
 
 	int have_langid;		/* whether string_langid is valid */
 	int string_langid;		/* language ID for strings */