Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
libusbhost: Fix problem reading USB string descriptors on some quirky…
Browse files Browse the repository at this point in the history
… devices

Some devices fail to send USB string descriptors if you attempt to read more
than 255 bytes

Bug: 21871761
Change-Id: Id5b8865179f80523f0ad5b6028d49dd99db2b36b
  • Loading branch information
Mike Lockwood committed Jun 18, 2015
1 parent d503930 commit 0dd1aab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libusbhost/usbhost.c
Expand Up @@ -56,6 +56,9 @@
#define USB_FS_ID_SCANNER USB_FS_DIR "/%d/%d"
#define USB_FS_ID_FORMAT USB_FS_DIR "/%03d/%03d"

// Some devices fail to send string descriptors if we attempt reading > 255 bytes
#define MAX_STRING_DESCRIPTOR_LENGTH 255

// From drivers/usb/core/devio.c
// I don't know why this isn't in a kernel header
#define MAX_USBFS_BUFFER_SIZE 16384
Expand Down Expand Up @@ -449,8 +452,8 @@ const struct usb_device_descriptor* usb_device_get_device_descriptor(struct usb_
char* usb_device_get_string(struct usb_device *device, int id)
{
char string[256];
__u16 buffer[128];
__u16 languages[128];
__u16 buffer[MAX_STRING_DESCRIPTOR_LENGTH / sizeof(__u16)];
__u16 languages[MAX_STRING_DESCRIPTOR_LENGTH / sizeof(__u16)];
int i, result;
int languageCount = 0;

Expand Down

0 comments on commit 0dd1aab

Please sign in to comment.