forked from nuttx/nuttx-update
usbdev: move usbdev_req function to common code
Move usbdev_req function to common code, Reduce duplicated code. Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
parent
d8ca744052
commit
602d5974c8
12 changed files with 174 additions and 510 deletions
|
@ -59,7 +59,7 @@ if(CONFIG_USBDEV)
|
|||
list(APPEND SRCS cdcecm.c)
|
||||
endif()
|
||||
|
||||
list(APPEND SRCS usbdev_trace.c usbdev_trprintf.c)
|
||||
list(APPEND SRCS usbdev_req.c usbdev_trace.c usbdev_trprintf.c)
|
||||
|
||||
target_sources(drivers PRIVATE ${SRCS})
|
||||
endif()
|
||||
|
|
|
@ -58,7 +58,7 @@ ifeq ($(CONFIG_NET_CDCECM),y)
|
|||
CSRCS += cdcecm.c
|
||||
endif
|
||||
|
||||
CSRCS += usbdev_trace.c usbdev_trprintf.c
|
||||
CSRCS += usbdev_req.c usbdev_trace.c usbdev_trprintf.c
|
||||
|
||||
# Include USB device build support
|
||||
|
||||
|
|
|
@ -209,9 +209,6 @@ static void usbclass_suspend(FAR struct usbdevclass_driver_s *driver,
|
|||
static void usbclass_resume(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev);
|
||||
|
||||
static FAR struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
|
||||
/* Char device Operations ***************************************************/
|
||||
|
||||
static int adb_char_open(FAR struct file *filep);
|
||||
|
@ -333,57 +330,6 @@ static const struct adb_cfgdesc_s g_adb_cfgdesc =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate request buffer for a specified endpoint.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_copy_epdesc
|
||||
*
|
||||
|
@ -981,7 +927,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
priv->usbdev = dev;
|
||||
|
||||
priv->ctrlreq = usbclass_allocreq(dev->ep0, USBADB_MXDESCLEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, USBADB_MXDESCLEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -1050,7 +996,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
FAR struct usbadb_rdreq_s *rdcontainer;
|
||||
|
||||
rdcontainer = &priv->rdreqs[i];
|
||||
rdcontainer->req = usbclass_allocreq(priv->epbulkout, reqlen);
|
||||
rdcontainer->req = usbdev_allocreq(priv->epbulkout, reqlen);
|
||||
if (rdcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM);
|
||||
|
@ -1076,7 +1022,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
FAR struct usbadb_wrreq_s *wrcontainer;
|
||||
|
||||
wrcontainer = &priv->wrreqs[i];
|
||||
wrcontainer->req = usbclass_allocreq(priv->epbulkin, reqlen);
|
||||
wrcontainer->req = usbdev_allocreq(priv->epbulkin, reqlen);
|
||||
if (wrcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRALLOCREQ), -ENOMEM);
|
||||
|
@ -1183,7 +1129,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
usbclass_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1144,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
rdcontainer = &priv->rdreqs[i];
|
||||
if (rdcontainer->req != NULL)
|
||||
{
|
||||
usbclass_freereq(priv->epbulkout, rdcontainer->req);
|
||||
usbdev_freereq(priv->epbulkout, rdcontainer->req);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1155,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
wrcontainer = &priv->wrreqs[i];
|
||||
if (wrcontainer->req != NULL)
|
||||
{
|
||||
usbclass_freereq(priv->epbulkin, wrcontainer->req);
|
||||
usbdev_freereq(priv->epbulkin, wrcontainer->req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,13 +163,6 @@ static int cdcacm_requeue_rdrequest(FAR struct cdcacm_dev_s *priv,
|
|||
static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv);
|
||||
static void cdcacm_rxtimeout(wdparm_t arg);
|
||||
|
||||
/* Request helpers **********************************************************/
|
||||
|
||||
static struct usbdev_req_s *cdcacm_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void cdcacm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* Flow Control *************************************************************/
|
||||
|
||||
#ifdef CONFIG_CDCACM_IFLOWCONTROL
|
||||
|
@ -760,56 +753,6 @@ static void cdcacm_rxtimeout(wdparm_t arg)
|
|||
cdcacm_release_rxpending(priv);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcacm_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbdev_req_s *cdcacm_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcacm_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void cdcacm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcacm_serialstate
|
||||
*
|
||||
|
@ -1324,7 +1267,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate control request */
|
||||
|
||||
priv->ctrlreq = cdcacm_allocreq(dev->ep0, CDCACM_MXDESCLEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, CDCACM_MXDESCLEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -1391,7 +1334,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_CDCACM_NRDREQS; i++)
|
||||
{
|
||||
rdcontainer = &priv->rdreqs[i];
|
||||
rdcontainer->req = cdcacm_allocreq(priv->epbulkout, reqlen);
|
||||
rdcontainer->req = usbdev_allocreq(priv->epbulkout, reqlen);
|
||||
if (rdcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM);
|
||||
|
@ -1428,7 +1371,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_CDCACM_NWRREQS; i++)
|
||||
{
|
||||
wrcontainer = &priv->wrreqs[i];
|
||||
wrcontainer->req = cdcacm_allocreq(priv->epbulkin, reqlen);
|
||||
wrcontainer->req = usbdev_allocreq(priv->epbulkin, reqlen);
|
||||
if (wrcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRALLOCREQ), -ENOMEM);
|
||||
|
@ -1532,7 +1475,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
cdcacm_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1489,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
rdcontainer = &priv->rdreqs[i];
|
||||
if (rdcontainer->req)
|
||||
{
|
||||
cdcacm_freereq(priv->epbulkout, rdcontainer->req);
|
||||
usbdev_freereq(priv->epbulkout, rdcontainer->req);
|
||||
rdcontainer->req = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1571,7 +1514,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
wrcontainer = (struct cdcacm_wrreq_s *)sq_remfirst(&priv->txfree);
|
||||
if (wrcontainer->req != NULL)
|
||||
{
|
||||
cdcacm_freereq(priv->epbulkin, wrcontainer->req);
|
||||
usbdev_freereq(priv->epbulkin, wrcontainer->req);
|
||||
priv->nwrq--; /* Number of write requests queued */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,11 +202,6 @@ static void cdcecm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* USB Device Class helpers */
|
||||
|
||||
static struct usbdev_req_s *cdcecm_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void cdcecm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
static void cdcecm_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
static void cdcecm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
|
@ -998,59 +993,6 @@ static void cdcecm_wrcomplete(FAR struct usbdev_ep_s *ep,
|
|||
work_queue(ETHWORK, &self->irqwork, cdcecm_interrupt_work, self, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbdev_req_s *cdcecm_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
req->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void cdcecm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_resetconfig
|
||||
*
|
||||
|
@ -1667,7 +1609,7 @@ static int cdcecm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate control request */
|
||||
|
||||
self->ctrlreq = cdcecm_allocreq(dev->ep0, CDCECM_MXDESCLEN);
|
||||
self->ctrlreq = usbdev_allocreq(dev->ep0, CDCECM_MXDESCLEN);
|
||||
|
||||
if (self->ctrlreq == NULL)
|
||||
{
|
||||
|
@ -1703,7 +1645,7 @@ static int cdcecm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Pre-allocate read requests. The buffer size is one full packet. */
|
||||
|
||||
self->rdreq = cdcecm_allocreq(self->epbulkout,
|
||||
self->rdreq = usbdev_allocreq(self->epbulkout,
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
if (self->rdreq == NULL)
|
||||
{
|
||||
|
@ -1716,7 +1658,7 @@ static int cdcecm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Pre-allocate a single write request. Buffer size is one full packet. */
|
||||
|
||||
self->wrreq = cdcecm_allocreq(self->epbulkin,
|
||||
self->wrreq = usbdev_allocreq(self->epbulkin,
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
if (self->wrreq == NULL)
|
||||
{
|
||||
|
@ -1794,7 +1736,7 @@ static void cdcecm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (self->ctrlreq != NULL)
|
||||
{
|
||||
cdcecm_freereq(dev->ep0, self->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, self->ctrlreq);
|
||||
self->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -1804,7 +1746,7 @@ static void cdcecm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (self->rdreq != NULL)
|
||||
{
|
||||
cdcecm_freereq(self->epbulkout, self->rdreq);
|
||||
usbdev_freereq(self->epbulkout, self->rdreq);
|
||||
self->rdreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -1822,7 +1764,7 @@ static void cdcecm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (self->wrreq != NULL)
|
||||
{
|
||||
cdcecm_freereq(self->epbulkin, self->wrreq);
|
||||
usbdev_freereq(self->epbulkin, self->wrreq);
|
||||
self->wrreq = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,6 @@ static int composite_classsetup(FAR struct composite_dev_s *priv,
|
|||
FAR struct usbdev_s *dev,
|
||||
FAR const struct usb_ctrlreq_s *ctrl, FAR uint8_t *dataout,
|
||||
size_t outlen);
|
||||
static struct usbdev_req_s *composite_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void composite_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* USB class device *********************************************************/
|
||||
|
||||
|
@ -281,56 +277,6 @@ static int composite_msftdescriptor(FAR struct composite_dev_s *priv,
|
|||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: composite_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbdev_req_s *composite_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
if (!req->buf)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: composite_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void composite_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* USB Class Driver Methods
|
||||
****************************************************************************/
|
||||
|
@ -366,7 +312,7 @@ static int composite_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate one control request */
|
||||
|
||||
priv->ctrlreq = composite_allocreq(dev->ep0, priv->cfgdescsize);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, priv->cfgdescsize);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -460,7 +406,7 @@ static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
priv->config = COMPOSITE_CONFIGIDNONE;
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
composite_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,57 +176,6 @@ static const struct dfu_cfgdesc_s g_dfu_cfgdesc =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
|
@ -440,7 +389,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
{
|
||||
FAR struct dfu_driver_s *priv = (FAR struct dfu_driver_s *)driver;
|
||||
|
||||
priv->ctrlreq = usbclass_allocreq(dev->ep0, DFU_MAX_DESCRIPTOR_LEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, DFU_MAX_DESCRIPTOR_LEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -459,7 +408,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
usbclass_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,13 +290,6 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv);
|
|||
static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv,
|
||||
uint8_t *reqbuf, uint16_t reqlen);
|
||||
|
||||
/* Request helpers **********************************************************/
|
||||
|
||||
static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
|
||||
|
@ -760,56 +753,6 @@ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv,
|
|||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
if (!req->buf)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_mkstrdesc
|
||||
*
|
||||
|
@ -1350,7 +1293,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate control request */
|
||||
|
||||
priv->ctrlreq = usbclass_allocreq(dev->ep0, PL2303_MXDESCLEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, PL2303_MXDESCLEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -1417,7 +1360,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_PL2303_NRDREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->rdreqs[i];
|
||||
reqcontainer->req = usbclass_allocreq(priv->epbulkout, reqlen);
|
||||
reqcontainer->req = usbdev_allocreq(priv->epbulkout, reqlen);
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM);
|
||||
|
@ -1451,7 +1394,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_PL2303_NWRREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->wrreqs[i];
|
||||
reqcontainer->req = usbclass_allocreq(priv->epbulkin, reqlen);
|
||||
reqcontainer->req = usbdev_allocreq(priv->epbulkin, reqlen);
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRALLOCREQ), -ENOMEM);
|
||||
|
@ -1556,7 +1499,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
usbclass_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -1570,7 +1513,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
reqcontainer = &priv->rdreqs[i];
|
||||
if (reqcontainer->req)
|
||||
{
|
||||
usbclass_freereq(priv->epbulkout, reqcontainer->req);
|
||||
usbdev_freereq(priv->epbulkout, reqcontainer->req);
|
||||
reqcontainer->req = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1594,7 +1537,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
reqcontainer = (struct pl2303_req_s *)sq_remfirst(&priv->reqlist);
|
||||
if (reqcontainer->req != NULL)
|
||||
{
|
||||
usbclass_freereq(priv->epbulkin, reqcontainer->req);
|
||||
usbdev_freereq(priv->epbulkin, reqcontainer->req);
|
||||
priv->nwrq--; /* Number of write requests queued */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1800,68 +1800,6 @@ static void usbclass_epintin_complete(FAR struct usbdev_ep_s *ep,
|
|||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
/* rdreq/epintin_req/ctrlreq use fixed memory
|
||||
* reqcontainer use iob dynamically when needed
|
||||
*/
|
||||
|
||||
req->len = len;
|
||||
if (len > 0)
|
||||
{
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req->buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbclass_mkstrdesc
|
||||
*
|
||||
|
@ -2150,7 +2088,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate control request */
|
||||
|
||||
priv->ctrlreq = usbclass_allocreq(dev->ep0, RNDIS_CTRLREQ_LEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, RNDIS_CTRLREQ_LEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -2182,7 +2120,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
priv->epintin->priv = priv;
|
||||
|
||||
priv->epintin_req =
|
||||
usbclass_allocreq(priv->epintin, sizeof(struct rndis_notification));
|
||||
usbdev_allocreq(priv->epintin, sizeof(struct rndis_notification));
|
||||
if (priv->epintin_req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM);
|
||||
|
@ -2229,7 +2167,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
reqlen = CONFIG_RNDIS_BULKOUT_REQLEN;
|
||||
}
|
||||
|
||||
priv->rdreq = usbclass_allocreq(priv->epbulkout, reqlen);
|
||||
priv->rdreq = usbdev_allocreq(priv->epbulkout, reqlen);
|
||||
if (priv->rdreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDALLOCREQ), -ENOMEM);
|
||||
|
@ -2259,7 +2197,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_RNDIS_NWRREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->wrreqs[i];
|
||||
reqcontainer->req = usbclass_allocreq(priv->epbulkin, reqlen);
|
||||
reqcontainer->req = usbdev_allocreq(priv->epbulkin, reqlen);
|
||||
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
|
@ -2371,13 +2309,13 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
usbclass_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
if (priv->epintin_req != NULL)
|
||||
{
|
||||
usbclass_freereq(priv->epintin, priv->epintin_req);
|
||||
usbdev_freereq(priv->epintin, priv->epintin_req);
|
||||
priv->epintin_req = NULL;
|
||||
}
|
||||
|
||||
|
@ -2387,7 +2325,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->rdreq)
|
||||
{
|
||||
usbclass_freereq(priv->epbulkout, priv->rdreq);
|
||||
usbdev_freereq(priv->epbulkout, priv->rdreq);
|
||||
}
|
||||
|
||||
/* Free the bulk OUT endpoint */
|
||||
|
@ -2411,7 +2349,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
if (reqcontainer->req != NULL)
|
||||
{
|
||||
reqcontainer->req->buf = reqcontainer->buf;
|
||||
usbclass_freereq(priv->epbulkin, reqcontainer->req);
|
||||
usbdev_freereq(priv->epbulkin, reqcontainer->req);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
108
drivers/usbdev/usbdev_req.c
Normal file
108
drivers/usbdev/usbdev_req.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/****************************************************************************
|
||||
* drivers/usbdev/usbdev_req.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
|
||||
#ifndef CONFIG_USBDEV_DMA
|
||||
# include <nuttx/kmalloc.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Allocate/free I/O requests.
|
||||
* Should not be called from interrupt processing!
|
||||
*/
|
||||
|
||||
#define EP_ALLOCREQ(ep) (ep)->ops->allocreq(ep)
|
||||
#define EP_FREEREQ(ep,req) (ep)->ops->freereq(ep,req)
|
||||
|
||||
/* Allocate/free an I/O buffer.
|
||||
* Should not be called from interrupt processing!
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DMA
|
||||
# define EP_ALLOCBUFFER(ep,nb) (ep)->ops->allocbuffer(ep,nb)
|
||||
# define EP_FREEBUFFER(ep,buf) (ep)->ops->freebuffer(ep,buf)
|
||||
#else
|
||||
# define EP_ALLOCBUFFER(ep,nb) kmm_malloc(nb)
|
||||
# define EP_FREEBUFFER(ep,buf) kmm_free(buf)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct usbdev_req_s *usbdev_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
req->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||
|
||||
if (req->buf == NULL)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbdev_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
|
@ -103,10 +103,6 @@ struct usbmsc_alloc_s
|
|||
|
||||
static void usbmsc_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
static struct usbdev_req_s *usbmsc_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void usbmsc_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* Class Driver Operations (most at interrupt level) ************************/
|
||||
|
||||
|
@ -172,56 +168,6 @@ static void usbmsc_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
|||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbdev_req_s *usbmsc_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len)
|
||||
{
|
||||
FAR struct usbdev_req_s *req;
|
||||
|
||||
req = EP_ALLOCREQ(ep);
|
||||
if (req != NULL)
|
||||
{
|
||||
req->len = len;
|
||||
req->buf = EP_ALLOCBUFFER(ep, len);
|
||||
if (!req->buf)
|
||||
{
|
||||
EP_FREEREQ(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbmsc_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
if (ep != NULL && req != NULL)
|
||||
{
|
||||
if (req->buf != NULL)
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_bind
|
||||
*
|
||||
|
@ -265,7 +211,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
/* Preallocate control request */
|
||||
|
||||
priv->ctrlreq = usbmsc_allocreq(dev->ep0, USBMSC_MXDESCLEN);
|
||||
priv->ctrlreq = usbdev_allocreq(dev->ep0, USBMSC_MXDESCLEN);
|
||||
if (priv->ctrlreq == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_ALLOCCTRLREQ), 0);
|
||||
|
@ -313,7 +259,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_USBMSC_NRDREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->rdreqs[i];
|
||||
reqcontainer->req = usbmsc_allocreq(priv->epbulkout,
|
||||
reqcontainer->req = usbdev_allocreq(priv->epbulkout,
|
||||
CONFIG_USBMSC_BULKOUTREQLEN);
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
|
@ -332,7 +278,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
|||
for (i = 0; i < CONFIG_USBMSC_NWRREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->wrreqs[i];
|
||||
reqcontainer->req = usbmsc_allocreq(priv->epbulkin,
|
||||
reqcontainer->req = usbdev_allocreq(priv->epbulkin,
|
||||
CONFIG_USBMSC_BULKINREQLEN);
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
|
@ -435,7 +381,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (priv->ctrlreq != NULL)
|
||||
{
|
||||
usbmsc_freereq(dev->ep0, priv->ctrlreq);
|
||||
usbdev_freereq(dev->ep0, priv->ctrlreq);
|
||||
priv->ctrlreq = NULL;
|
||||
}
|
||||
|
||||
|
@ -448,7 +394,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
reqcontainer = &priv->rdreqs[i];
|
||||
if (reqcontainer->req)
|
||||
{
|
||||
usbmsc_freereq(priv->epbulkout, reqcontainer->req);
|
||||
usbdev_freereq(priv->epbulkout, reqcontainer->req);
|
||||
reqcontainer->req = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +419,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
if (reqcontainer->req != NULL)
|
||||
{
|
||||
usbmsc_freereq(priv->epbulkin, reqcontainer->req);
|
||||
usbdev_freereq(priv->epbulkin, reqcontainer->req);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,25 +59,6 @@
|
|||
|
||||
#define EP_DISABLE(ep) (ep)->ops->disable(ep)
|
||||
|
||||
/* Allocate/free I/O requests.
|
||||
* Should not be called from interrupt processing!
|
||||
*/
|
||||
|
||||
#define EP_ALLOCREQ(ep) (ep)->ops->allocreq(ep)
|
||||
#define EP_FREEREQ(ep,req) (ep)->ops->freereq(ep,req)
|
||||
|
||||
/* Allocate/free an I/O buffer.
|
||||
* Should not be called from interrupt processing!
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DMA
|
||||
# define EP_ALLOCBUFFER(ep,nb) (ep)->ops->allocbuffer(ep,nb)
|
||||
# define EP_FREEBUFFER(ep,buf) (ep)->ops->freebuffer(ep,buf)
|
||||
#else
|
||||
# define EP_ALLOCBUFFER(ep,nb) kmm_malloc(nb)
|
||||
# define EP_FREEBUFFER(ep,buf) kmm_free(buf)
|
||||
#endif
|
||||
|
||||
/* Submit an I/O request to the endpoint */
|
||||
|
||||
#define EP_SUBMIT(ep,req) (ep)->ops->submit(ep,req)
|
||||
|
@ -375,6 +356,28 @@ extern "C"
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_allocreq
|
||||
*
|
||||
* Description:
|
||||
* Allocate a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct usbdev_req_s *usbdev_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_freereq
|
||||
*
|
||||
* Description:
|
||||
* Free a request instance along with its buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbdev_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdevclass_register
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue