Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bf01185 authored by Aman Deep's avatar Aman Deep Committed by Greg Kroah-Hartman
Browse files

USB: Adding #define in hub_configure() and hcd.c file



This patch is in succession of previous patch
commit c8421147
        xHCI: Adding #define values used for hub descriptor

Hub descriptors characteristics #defines values are added in
hub_configure() in place of magic numbers as asked by Alan Stern.
And the indentation for switch and case is changed to be same.

Some #defines values are added in ch11.h for defining hub class
protocols and used in hub.c and hcd.c in which magic values were
used for hub class protocols.

Signed-off-by: default avatarAman Deep <amandeep3986@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 35657c4d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -658,7 +658,7 @@ error:
				len > offsetof(struct usb_device_descriptor,
				len > offsetof(struct usb_device_descriptor,
						bDeviceProtocol))
						bDeviceProtocol))
			((struct usb_device_descriptor *) ubuf)->
			((struct usb_device_descriptor *) ubuf)->
					bDeviceProtocol = 1;
				bDeviceProtocol = USB_HUB_PR_HS_SINGLE_TT;
	}
	}


	/* any errors get returned through the urb completion */
	/* any errors get returned through the urb completion */
+44 −44
Original line number Original line Diff line number Diff line
@@ -84,7 +84,7 @@ struct usb_hub {


static inline int hub_is_superspeed(struct usb_device *hdev)
static inline int hub_is_superspeed(struct usb_device *hdev)
{
{
	return (hdev->descriptor.bDeviceProtocol == 3);
	return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS);
}
}


/* Protect struct usb_device->state and ->children members
/* Protect struct usb_device->state and ->children members
@@ -1041,27 +1041,27 @@ static int hub_configure(struct usb_hub *hub,
		dev_dbg(hub_dev, "standalone hub\n");
		dev_dbg(hub_dev, "standalone hub\n");


	switch (wHubCharacteristics & HUB_CHAR_LPSM) {
	switch (wHubCharacteristics & HUB_CHAR_LPSM) {
		case 0x00:
	case HUB_CHAR_COMMON_LPSM:
		dev_dbg(hub_dev, "ganged power switching\n");
		dev_dbg(hub_dev, "ganged power switching\n");
		break;
		break;
		case 0x01:
	case HUB_CHAR_INDV_PORT_LPSM:
		dev_dbg(hub_dev, "individual port power switching\n");
		dev_dbg(hub_dev, "individual port power switching\n");
		break;
		break;
		case 0x02:
	case HUB_CHAR_NO_LPSM:
		case 0x03:
	case HUB_CHAR_LPSM:
		dev_dbg(hub_dev, "no power switching (usb 1.0)\n");
		dev_dbg(hub_dev, "no power switching (usb 1.0)\n");
		break;
		break;
	}
	}


	switch (wHubCharacteristics & HUB_CHAR_OCPM) {
	switch (wHubCharacteristics & HUB_CHAR_OCPM) {
		case 0x00:
	case HUB_CHAR_COMMON_OCPM:
		dev_dbg(hub_dev, "global over-current protection\n");
		dev_dbg(hub_dev, "global over-current protection\n");
		break;
		break;
		case 0x08:
	case HUB_CHAR_INDV_PORT_OCPM:
		dev_dbg(hub_dev, "individual port over-current protection\n");
		dev_dbg(hub_dev, "individual port over-current protection\n");
		break;
		break;
		case 0x10:
	case HUB_CHAR_NO_OCPM:
		case 0x18:
	case HUB_CHAR_OCPM:
		dev_dbg(hub_dev, "no over-current protection\n");
		dev_dbg(hub_dev, "no over-current protection\n");
		break;
		break;
	}
	}
@@ -1070,13 +1070,13 @@ static int hub_configure(struct usb_hub *hub,
	INIT_LIST_HEAD (&hub->tt.clear_list);
	INIT_LIST_HEAD (&hub->tt.clear_list);
	INIT_WORK(&hub->tt.clear_work, hub_tt_work);
	INIT_WORK(&hub->tt.clear_work, hub_tt_work);
	switch (hdev->descriptor.bDeviceProtocol) {
	switch (hdev->descriptor.bDeviceProtocol) {
		case 0:
	case USB_HUB_PR_FS:
		break;
		break;
		case 1:
	case USB_HUB_PR_HS_SINGLE_TT:
		dev_dbg(hub_dev, "Single TT\n");
		dev_dbg(hub_dev, "Single TT\n");
		hub->tt.hub = hdev;
		hub->tt.hub = hdev;
		break;
		break;
		case 2:
	case USB_HUB_PR_HS_MULTI_TT:
		ret = usb_set_interface(hdev, 0, 1);
		ret = usb_set_interface(hdev, 0, 1);
		if (ret == 0) {
		if (ret == 0) {
			dev_dbg(hub_dev, "TT per port\n");
			dev_dbg(hub_dev, "TT per port\n");
@@ -1086,7 +1086,7 @@ static int hub_configure(struct usb_hub *hub,
				ret);
				ret);
		hub->tt.hub = hdev;
		hub->tt.hub = hdev;
		break;
		break;
		case 3:
	case USB_HUB_PR_SS:
		/* USB 3.0 hubs don't have a TT */
		/* USB 3.0 hubs don't have a TT */
		break;
		break;
	default:
	default:
+11 −0
Original line number Original line Diff line number Diff line
@@ -207,6 +207,17 @@ struct usb_hub_status {
#define USB_DT_HUB_NONVAR_SIZE		7
#define USB_DT_HUB_NONVAR_SIZE		7
#define USB_DT_SS_HUB_SIZE              12
#define USB_DT_SS_HUB_SIZE              12


/*
 * Hub Device descriptor
 * USB Hub class device protocols
 */

#define USB_HUB_PR_FS		0 /* Full speed hub */
#define USB_HUB_PR_HS_NO_TT	0 /* Hi-speed hub without TT */
#define USB_HUB_PR_HS_SINGLE_TT	1 /* Hi-speed hub with single TT */
#define USB_HUB_PR_HS_MULTI_TT	2 /* Hi-speed hub with multiple TT */
#define USB_HUB_PR_SS		3 /* Super speed hub */

struct usb_hub_descriptor {
struct usb_hub_descriptor {
	__u8  bDescLength;
	__u8  bDescLength;
	__u8  bDescriptorType;
	__u8  bDescriptorType;