Merge pull request #1053 from uestczyh222/master

[Components][Driver][USB][Class]fix msc class
This commit is contained in:
Bernard Xiong 2017-11-29 16:29:23 +08:00 committed by GitHub
commit cdf2af5c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -706,7 +706,7 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
}
else
{
rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
// rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
}
}
@ -722,7 +722,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
data = (struct mstorage*)func->user_data;
if(cmd->cmd_len != cbw->cb_len)
{
rt_kprintf("cb_len error\n");
// rt_kprintf("cb_len error\n");
cmd->cmd_len = cbw->cb_len;
}
@ -753,7 +753,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
if(cbw->xfer_len < data->cb_data_size)
{
rt_kprintf("xfer_len < data_size\n");
// rt_kprintf("xfer_len < data_size\n");
data->cb_data_size = cbw->xfer_len;
data->csw_response.status = 1;
}
@ -769,7 +769,7 @@ static rt_size_t _cbw_handler(ufunction_t func, struct scsi_cmd* cmd,
RT_ASSERT(func != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_ASSERT(cmd->handler != RT_NULL);
data = (struct mstorage*)func->user_data;
data->processing = cmd;
return cmd->handler(func, cbw);
@ -896,32 +896,32 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
RT_DEBUG_LOG(RT_DEBUG_USB, ("mstorage_interface_handler\n"));
switch(setup->request)
switch(setup->bRequest)
{
case USBREQ_GET_MAX_LUN:
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_GET_MAX_LUN\n"));
if(setup->value || setup->length != 1)
if(setup->wValue || setup->wLength != 1)
{
rt_usbd_ep0_set_stall(func->device);
}
else
{
rt_usbd_ep0_write(func->device, &lun, 1);
rt_usbd_ep0_write(func->device, &lun, setup->wLength);
}
break;
case USBREQ_MASS_STORAGE_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_MASS_STORAGE_RESET\n"));
if(setup->value || setup->length != 0)
if(setup->wValue || setup->wLength != 0)
{
rt_usbd_ep0_set_stall(func->device);
}
else
{
rt_usbd_ep0_write(func->device, RT_NULL, 0);
{
dcd_ep0_send_status(func->device->dcd);
}
break;
default:

View File

@ -840,6 +840,10 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg)
{
EP_HANDLER(ep, func, ep->request.size);
}
else
{
dcd_ep_read_prepare(device->dcd, EP_ADDRESS(ep), ep->request.buffer, ep->request.remain_size > EP_MAXPACKET(ep) ? EP_MAXPACKET(ep) : ep->request.remain_size);
}
}
return RT_EOK;
@ -973,7 +977,7 @@ static rt_size_t rt_usbd_ep_read_prepare(udevice_t device, uep_t ep, void *buffe
RT_ASSERT(buffer != RT_NULL);
RT_ASSERT(ep->ep_desc != RT_NULL);
return dcd_ep_read_prepare(device->dcd, EP_ADDRESS(ep), buffer, size);
return dcd_ep_read_prepare(device->dcd, EP_ADDRESS(ep), buffer, size > EP_MAXPACKET(ep) ? EP_MAXPACKET(ep) : size);
}
/**