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:
zhanghongyu
2026-02-24 16:12:05 +08:00
committed by archer
parent 0d12f82074
commit e404fe4b8d

View File

@@ -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
*
@@ -2860,10 +2876,16 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
/* We are successfully configured */
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;