mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
rndis.c: move ifup in setconfig to the work queue
Move network interface up operation (ifup) to work queue in RNDIS USB device driver to avoid calling netdev_carrier_on API in interrupt context. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
+25
-3
@@ -2752,6 +2752,22 @@ static void usbclass_resetconfig(FAR struct rndis_dev_s *priv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: rndis_carrier_on_work
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Schedule to work queue because netdev_carrier_on API can't be used in
|
||||||
|
* interrupt context
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void rndis_carrier_on_work(FAR void *arg)
|
||||||
|
{
|
||||||
|
FAR struct rndis_dev_s *priv = arg;
|
||||||
|
|
||||||
|
netdev_carrier_on(&priv->netdev);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbclass_setconfig
|
* Name: usbclass_setconfig
|
||||||
*
|
*
|
||||||
@@ -2860,10 +2876,16 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
|
|||||||
/* We are successfully configured */
|
/* We are successfully configured */
|
||||||
|
|
||||||
priv->config = config;
|
priv->config = config;
|
||||||
if (priv->netdev.d_ifup(&priv->netdev) == OK)
|
|
||||||
{
|
|
||||||
priv->netdev.d_flags |= IFF_UP;
|
priv->netdev.d_flags |= IFF_UP;
|
||||||
}
|
|
||||||
|
/* Schedule to work queue because netdev_carrier_on API can't be used in
|
||||||
|
* interrupt context. Since the current network card is not yet RUNNING,
|
||||||
|
* it will not be selected to trigger rndis_txavail, so pollwork can be
|
||||||
|
* reused.
|
||||||
|
*/
|
||||||
|
|
||||||
|
work_queue(LPWORK, &priv->pollwork, rndis_carrier_on_work, priv, 0);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user