nusb/usbd: work around devices that ignore the high byte of wLength in control transfer reads

there appear to be devices out there such as Realtek RTL2838UHIDIR
SDR that do not process control transfers correctly, ignoring the
high byte of the wLength field. to work around this, we specify an
odd number of bytes for read sizes >= 256 which keeps the low byte
0xFF.
This commit is contained in:
cinap_lenrek 2019-05-07 09:19:53 +02:00
parent ceed9b8853
commit 3a4a3faf29
2 changed files with 10 additions and 3 deletions

View file

@ -42,7 +42,12 @@ struct Hiddev
/* report descriptor */
int nrep;
uchar rep[512];
/*
* use odd size as some devices ignore the high byte of
* wLength in control transfer reads.
*/
uchar rep[512-1];
};
typedef struct Hidreport Hidreport;

View file

@ -136,8 +136,10 @@ enum
/*
* Max device conf is also limited by max control request size as
* limited by Maxctllen in the kernel usb.h (both limits are arbitrary).
* Some devices ignore the high byte of control transfer reads so keep
* the low byte all ones. asking for 16K kills Newsham's disk.
*/
Maxdevconf = 4 * 1024, /* asking for 16K kills Newsham's disk */
Maxdevconf = 4*1024 - 1,
};
int
@ -201,7 +203,7 @@ mkstr(uchar *b, int n)
char*
loaddevstr(Dev *d, int sid)
{
uchar buf[256];
uchar buf[256-2]; /* keep size < 256 */
int langid;
int type;
int nr;