Skip to content

Commit 1f920f6

Browse files
bluecmdmvp
authored andcommitted
Fix endian conversions to work for big-endian
Before: ``` Current status for hub 3 [6b1d:0200 Linux 6.1.98 xhci-hcd xHCI Host Controller 0000:01:00.0, USB 0.02, 2 ports, ppps] Port 1: 0305 power lowspeed suspend connect [9911:c068 Sierra Wireless, Incorporated MC7304-CP] Port 2: 0301 power lowspeed connect [0304:0160 FTDI FT232R USB UART A10OEDEW] ``` After: ``` Current status for hub 1 [1d6b:0002 Linux 6.1.98 ehci_hcd EHCI Host Controller 16f0000000000.ehci, USB 2.00, 2 ports, nops] Port 1: 0503 power highspeed enable connect [0424:2240 Generic Ultra Fast Media 000000225001] Port 2: 0100 power Current status for hub 3 [1d6b:0002 Linux 6.1.98 xhci-hcd xHCI Host Controller 0000:01:00.0, USB 2.00, 2 ports, ppps] Port 1: 0503 power highspeed enable connect [1199:68c0 Sierra Wireless, Incorporated MC7304-CP] Port 2: 0103 power enable connect [0403:6001 FTDI FT232R USB UART A10OEDEW] ``` Tested on both x86-64 and MIPS64. Signed-off-by: Christian Svensson <[email protected]>
1 parent 746891d commit 1f920f6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

uhubctl.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int get_hub_info(struct libusb_device *dev, struct hub_info *info)
404404
return rc;
405405
if (desc.bDeviceClass != LIBUSB_CLASS_HUB)
406406
return LIBUSB_ERROR_INVALID_PARAM;
407-
int bcd_usb = libusb_le16_to_cpu(desc.bcdUSB);
407+
int bcd_usb = desc.bcdUSB;
408408
int desc_type = bcd_usb >= USB_SS_BCD ? LIBUSB_DT_SUPERSPEED_HUB
409409
: LIBUSB_DT_HUB;
410410
rc = libusb_open(dev, &devh);
@@ -427,8 +427,8 @@ static int get_hub_info(struct libusb_device *dev, struct hub_info *info)
427427
snprintf(
428428
info->vendor, sizeof(info->vendor),
429429
"%04x:%04x",
430-
libusb_le16_to_cpu(desc.idVendor),
431-
libusb_le16_to_cpu(desc.idProduct)
430+
desc.idVendor,
431+
desc.idProduct
432432
);
433433

434434
/* Convert bus and ports array into USB location string */
@@ -550,7 +550,7 @@ static int get_port_status(struct libusb_device_handle *devh, int port)
550550
if (rc < 0) {
551551
return rc;
552552
}
553-
return ust.wPortStatus;
553+
return libusb_le16_to_cpu(ust.wPortStatus);
554554
}
555555

556556

@@ -688,8 +688,8 @@ static int get_device_description(struct libusb_device * dev, struct descriptor_
688688
if (rc)
689689
return rc;
690690
bzero(ds, sizeof(*ds));
691-
id_vendor = libusb_le16_to_cpu(desc.idVendor);
692-
id_product = libusb_le16_to_cpu(desc.idProduct);
691+
id_vendor = desc.idVendor;
692+
id_product = desc.idProduct;
693693
rc = libusb_open(dev, &devh);
694694
if (rc == 0) {
695695
if (!opt_nodesc) {

0 commit comments

Comments
 (0)