drivers/usbdev/cdcacm.c: This fixes a problem where the host sent a "get descriptor" message of type "standard" with a recipient of type "interface". Since the composite driver would only pass messages to the child interfaces when a message was not "standard", this message was not handled. I changed the condition so that the composite driver checks not only if this is a "standard" message but if it is also directed to the device. Otherwise, the handling is delegated to the children of the composite device.

This commit is contained in:
Matias N 2019-03-26 21:54:01 -06:00 committed by Gregory Nutt
parent 2d3623e2f9
commit a9d8b705cc

View file

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/usbdev/composite.c
*
* Copyright (C) 2012, 2016-2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016-2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -500,6 +500,7 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
uint16_t len;
bool dispatched = false;
int ret = -EOPNOTSUPP;
uint8_t recipient;
#ifdef CONFIG_DEBUG_FEATURES
if (!driver || !dev || !dev->ep0 || !ctrl)
@ -534,7 +535,10 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
ctrl->type, ctrl->req, value, index, len);
UNUSED(index);
if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
recipient = ctrl->type & USB_REQ_RECIPIENT_MASK;
if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD &&
recipient == USB_REQ_RECIPIENT_DEVICE)
{
/**********************************************************************
* Standard Requests
@ -701,10 +705,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
ret = composite_msftdescriptor(priv, dev, ctrl, ctrlreq, &dispatched);
}
#endif
else
else if (recipient == USB_REQ_RECIPIENT_INTERFACE ||
recipient == USB_REQ_RECIPIENT_ENDPOINT)
{
uint8_t recipient;
/**********************************************************************
* Non-Standard Class Requests
**********************************************************************/
@ -713,12 +716,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
* requests.
*/
recipient = ctrl->type & USB_REQ_RECIPIENT_MASK;
if (recipient == USB_REQ_RECIPIENT_INTERFACE || recipient == USB_REQ_RECIPIENT_ENDPOINT)
{
ret = composite_classsetup(priv, dev, ctrl, dataout, outlen);
dispatched = true;
}
ret = composite_classsetup(priv, dev, ctrl, dataout, outlen);
dispatched = true;
}
/* Respond to the setup command if (1) data was returned, and (2) the