mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
drivers/cdcacm/serial: add release interface to release uart_dev resource
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
+25
-1
@@ -222,6 +222,7 @@ static bool cdcuart_rxflowcontrol(FAR struct uart_dev_s *dev,
|
||||
#endif
|
||||
static void cdcuart_txint(FAR struct uart_dev_s *dev, bool enable);
|
||||
static bool cdcuart_txempty(FAR struct uart_dev_s *dev);
|
||||
static int cdcuart_release(FAR struct uart_dev_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -272,7 +273,8 @@ static const struct uart_ops_s g_uartops =
|
||||
NULL, /* send */
|
||||
cdcuart_txint, /* txinit */
|
||||
NULL, /* txready */
|
||||
cdcuart_txempty /* txempty */
|
||||
cdcuart_txempty, /* txempty */
|
||||
cdcuart_release /* release */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2800,6 +2802,28 @@ static bool cdcuart_txempty(FAR struct uart_dev_s *dev)
|
||||
return priv->nwrq >= CONFIG_CDCACM_NWRREQS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcuart_release
|
||||
*
|
||||
* Description:
|
||||
* This is called to release some resource about the device when device
|
||||
* was close and unregistered.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int cdcuart_release(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
FAR struct cdcacm_dev_s *priv = (FAR struct cdcacm_dev_s *)dev->priv;
|
||||
|
||||
usbtrace(CDCACM_CLASSAPI_RELEASE, 0);
|
||||
|
||||
/* And free the memory resources. */
|
||||
|
||||
wd_cancel(&priv->rxfailsafe);
|
||||
kmm_free(priv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
#define CDCACM_CLASSAPI_TXREADY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXREADY)
|
||||
#define CDCACM_CLASSAPI_TXEMPTY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXEMPTY)
|
||||
#define CDCACM_CLASSAPI_FLOWCONTROL TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_FLOWCONTROL)
|
||||
#define CDCACM_CLASSAPI_RELEASE TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_RELEASE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
||||
Reference in New Issue
Block a user