usbdev/adb: fixed usbclass steup issue

1. set usbdev when usb class bind
2. don't call EP_SUBMIT when receive OUT message

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2022-12-01 09:47:31 +08:00 committed by Xiang Xiao
parent d9acaeaccf
commit 5dc4e23bb7

View File

@ -549,7 +549,8 @@ static void usb_adb_wrcomplete(FAR struct usbdev_ep_s *ep,
case -ESHUTDOWN: /* Disconnection */ case -ESHUTDOWN: /* Disconnection */
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRSHUTDOWN), sq_count(&priv->txfree)); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRSHUTDOWN),
sq_count(&priv->txfree));
} }
break; break;
@ -957,6 +958,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
usbtrace(TRACE_CLASSBIND, 0); usbtrace(TRACE_CLASSBIND, 0);
priv->usbdev = dev;
priv->ctrlreq = usbclass_allocreq(dev->ep0, USBADB_MXDESCLEN); priv->ctrlreq = usbclass_allocreq(dev->ep0, USBADB_MXDESCLEN);
if (priv->ctrlreq == NULL) if (priv->ctrlreq == NULL)
{ {
@ -1123,6 +1126,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
uint16_t value; uint16_t value;
uint16_t len; uint16_t len;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
bool cfg_req = true;
FAR struct usbdev_adb_s *priv; FAR struct usbdev_adb_s *priv;
FAR struct usbdev_req_s *ctrlreq; FAR struct usbdev_req_s *ctrlreq;
@ -1255,6 +1259,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
if (ctrl->type == 0) if (ctrl->type == 0)
{ {
ret = usbclass_setconfig(priv, value); ret = usbclass_setconfig(priv, value);
cfg_req = false;
} }
} }
break; break;
@ -1265,6 +1270,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
break; break;
} }
} }
break;
case USB_REQ_TYPE_CLASS: case USB_REQ_TYPE_CLASS:
{ {
@ -1277,8 +1283,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
default: default:
{ {
usbtrace( usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDTYPE),
TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDTYPE),
ctrl->type); ctrl->type);
} }
} }
@ -1288,7 +1293,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
* value (ret < 0), the USB driver will stall. * value (ret < 0), the USB driver will stall.
*/ */
if (ret >= 0) if (ret >= 0 && cfg_req)
{ {
ctrlreq->len = (len < ret) ? len : ret; ctrlreq->len = (len < ret) ? len : ret;
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT; ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;