aboutsummaryrefslogtreecommitdiffstats
path: root/usbdrv/usbdrv.c
diff options
context:
space:
mode:
Diffstat (limited to 'usbdrv/usbdrv.c')
-rw-r--r--usbdrv/usbdrv.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usbdrv/usbdrv.c b/usbdrv/usbdrv.c
index 4917078..e6c8c19 100644
--- a/usbdrv/usbdrv.c
+++ b/usbdrv/usbdrv.c
@@ -449,9 +449,13 @@ usbRequest_t *rq = (void *)data;
}
#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE
if(replyLen == USB_NO_MSG){ /* use user-supplied read/write function */
- /* do some conditioning on replyLen */
+ /* do some conditioning on replyLen, but on IN transfers only */
if((rq->bmRequestType & USBRQ_DIR_MASK) != USBRQ_DIR_HOST_TO_DEVICE){
- replyLen = rq->wLength.bytes[0]; /* IN transfers only */
+ if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */
+ replyLen = rq->wLength.bytes[0];
+ }else{
+ replyLen = rq->wLength.word;
+ }
}
usbMsgFlags = USB_FLG_USE_USER_RW;
}else /* The 'else' prevents that we limit a replyLen of USB_NO_MSG to the maximum transfer len. */