Skip to content

Commit

Permalink
[PATCH] USB: make wHubCharacteristics __le16 to match other usb descr…
Browse files Browse the repository at this point in the history
…iptor fields

Also has the nice benefit of making sparc alignment issues go away.

Thanks to David Miller for pointing out the problems here.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

 drivers/usb/core/hub.c |   22 ++++++++++++----------
 drivers/usb/core/hub.h |    2 +-
 2 files changed, 13 insertions(+), 11 deletions(-)
  • Loading branch information
Greg Kroah-Hartman committed Oct 28, 2005
1 parent 22efcf4 commit 74ad9bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,10 @@ static void hub_power_on(struct usb_hub *hub)
{
int port1;
unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);

/* if hub supports power switching, enable power on each port */
if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) < 2) {
if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) {
dev_dbg(hub->intfdev, "enabling power on all ports\n");
for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
set_port_feature(hub->hdev, port1,
Expand Down Expand Up @@ -525,6 +526,7 @@ static int hub_configure(struct usb_hub *hub,
struct usb_device *hdev = hub->hdev;
struct device *hub_dev = hub->intfdev;
u16 hubstatus, hubchange;
u16 wHubCharacteristics;
unsigned int pipe;
int maxp, ret;
char *message;
Expand Down Expand Up @@ -570,9 +572,9 @@ static int hub_configure(struct usb_hub *hub,
dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild,
(hdev->maxchild == 1) ? "" : "s");

le16_to_cpus(&hub->descriptor->wHubCharacteristics);
wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);

if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) {
if (wHubCharacteristics & HUB_CHAR_COMPOUND) {
int i;
char portstr [USB_MAXCHILDREN + 1];

Expand All @@ -585,7 +587,7 @@ static int hub_configure(struct usb_hub *hub,
} else
dev_dbg(hub_dev, "standalone hub\n");

switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) {
switch (wHubCharacteristics & HUB_CHAR_LPSM) {
case 0x00:
dev_dbg(hub_dev, "ganged power switching\n");
break;
Expand All @@ -598,7 +600,7 @@ static int hub_configure(struct usb_hub *hub,
break;
}

switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) {
switch (wHubCharacteristics & HUB_CHAR_OCPM) {
case 0x00:
dev_dbg(hub_dev, "global over-current protection\n");
break;
Expand Down Expand Up @@ -638,7 +640,7 @@ static int hub_configure(struct usb_hub *hub,
}

/* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */
switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_TTTT) {
switch (wHubCharacteristics & HUB_CHAR_TTTT) {
case HUB_TTTT_8_BITS:
if (hdev->descriptor.bDeviceProtocol != 0) {
hub->tt.think_time = 666;
Expand Down Expand Up @@ -668,7 +670,7 @@ static int hub_configure(struct usb_hub *hub,
}

/* probe() zeroes hub->indicator[] */
if (hub->descriptor->wHubCharacteristics & HUB_CHAR_PORTIND) {
if (wHubCharacteristics & HUB_CHAR_PORTIND) {
hub->has_indicators = 1;
dev_dbg(hub_dev, "Port indicators are supported\n");
}
Expand Down Expand Up @@ -713,7 +715,7 @@ static int hub_configure(struct usb_hub *hub,
(hubstatus & HUB_STATUS_LOCAL_POWER)
? "lost (inactive)" : "good");

if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) == 0)
if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0)
dev_dbg(hub_dev, "%sover-current condition exists\n",
(hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");

Expand Down Expand Up @@ -2432,6 +2434,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
{
struct usb_device *hdev = hub->hdev;
struct device *hub_dev = hub->intfdev;
u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
int status, i;

dev_dbg (hub_dev,
Expand Down Expand Up @@ -2469,8 +2472,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
if (!(portstatus & USB_PORT_STAT_CONNECTION)) {

/* maybe switch power back on (e.g. root hub was reset) */
if ((hub->descriptor->wHubCharacteristics
& HUB_CHAR_LPSM) < 2
if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
&& !(portstatus & (1 << USB_PORT_FEAT_POWER)))
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/core/hub.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct usb_hub_descriptor {
__u8 bDescLength;
__u8 bDescriptorType;
__u8 bNbrPorts;
__u16 wHubCharacteristics;
__le16 wHubCharacteristics;
__u8 bPwrOn2PwrGood;
__u8 bHubContrCurrent;
/* add 1 bit for hub status change; round to bytes */
Expand Down

0 comments on commit 74ad9bd

Please sign in to comment.