fix MSD_REQ_GET_MAX_LUN

This commit is contained in:
Matthew Kennedy 2021-02-12 16:14:45 -08:00
parent 0a0aa7491d
commit 702f32276e
1 changed files with 27 additions and 29 deletions

View File

@ -263,13 +263,12 @@ static THD_FUNCTION(usb_msd_worker, arg) {
* @notapi * @notapi
*/ */
bool msd_request_hook(USBDriver *usbp) { bool msd_request_hook(USBDriver *usbp) {
if (usbp->setup[0] == (USB_RTYPE_TYPE_CLASS | USB_RTYPE_RECIPIENT_INTERFACE | USB_RTYPE_DIR_HOST2DEV)) {
/* check that the request is for interface 0.*/ /* check that the request is for interface 0.*/
if (MSD_SETUP_INDEX(usbp->setup) != 0) if (MSD_SETUP_INDEX(usbp->setup) != 0)
return false; return false;
/* act depending on bRequest = setup[1] */
switch (usbp->setup[1]) { if (usbp->setup[0] == (USB_RTYPE_TYPE_CLASS | USB_RTYPE_RECIPIENT_INTERFACE | USB_RTYPE_DIR_HOST2DEV)
case MSD_REQ_RESET: && usbp->setup[1] == MSD_REQ_RESET) {
/* Bulk-Only Mass Storage Reset (class-specific request) /* Bulk-Only Mass Storage Reset (class-specific request)
This request is used to reset the mass storage device and its associated interface. This request is used to reset the mass storage device and its associated interface.
This class-specific request shall ready the device for the next CBW from the host. */ This class-specific request shall ready the device for the next CBW from the host. */
@ -282,17 +281,16 @@ bool msd_request_hook(USBDriver *usbp) {
/* response to this request using EP0 */ /* response to this request using EP0 */
usbSetupTransfer(usbp, 0, 0, NULL); usbSetupTransfer(usbp, 0, 0, NULL);
return true; return true;
case MSD_REQ_GET_MAX_LUN: } else if (usbp->setup[0] == (USB_RTYPE_TYPE_CLASS | USB_RTYPE_RECIPIENT_INTERFACE | USB_RTYPE_DIR_DEV2HOST)
&& usbp->setup[1] == MSD_REQ_GET_MAX_LUN) {
/* Return the maximum supported LUN. */ /* Return the maximum supported LUN. */
usbSetupTransfer(usbp, 0, 1, NULL); usbSetupTransfer(usbp, 0, 1, NULL);
return true; return true;
/* OR */ /* OR */
/* Return false to stall to indicate that we don't support LUN */ /* Return false to stall to indicate that we don't support LUN */
// return false; // return false;
default:
return false;
}
} }
return false; return false;
} }