From 00eb8f6461beb6d61e19b52e8e4db599dc75cc84 Mon Sep 17 00:00:00 2001 From: chengkai Date: Mon, 6 May 2024 17:36:25 +0800 Subject: [PATCH] bluetooth: remove noblock mode handle rootcause: move block and noblock handle to BTH4 handle. Signed-off-by: chengkai --- drivers/wireless/bluetooth/bt_slip.c | 55 +++++++--------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/drivers/wireless/bluetooth/bt_slip.c b/drivers/wireless/bluetooth/bt_slip.c index b3400d3cca..faa76dd0c6 100644 --- a/drivers/wireless/bluetooth/bt_slip.c +++ b/drivers/wireless/bluetooth/bt_slip.c @@ -36,7 +36,6 @@ #include #include -#include #include /**************************************************************************** @@ -127,7 +126,6 @@ struct sliphci_s } linkstate; bool dipresent; /* Data integrity check */ - bool nonblock; /* Send hci in noblock mode */ uint8_t rxack; /* Last ack number received */ uint8_t txseq; /* Next seq number to send */ @@ -522,7 +520,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv) { size_t to_remove; uint8_t seq; - int semcount = 0; to_remove = bt_slip_unack_size(priv); if (to_remove == 0) @@ -553,12 +550,14 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv) { bt_slip_unack_dtor(priv); - /* When in blocked hci write mode, we needs to notifiy bt_slip_send - * if it was blocked by full tx window. + /* When it was blocked by full tx window, we needs to notifiy + * bt_slip_send. */ - if ((bt_slip_unack_size(priv) == priv->txwin - 1) && !priv->nonblock) + if (bt_slip_unack_size(priv) == priv->txwin - 1) { + int semcount; + nxsem_get_value(&priv->sem, &semcount); if (semcount < 0) { @@ -570,7 +569,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv) } to_remove = bt_slip_unack_size(priv); - if (!to_remove) { work_cancel(HPWORK, &priv->retxworker); @@ -708,20 +706,13 @@ static int bt_slip_send(FAR struct bt_driver_s *dev, if (bt_slip_unack_size(priv) >= priv->txwin) { bt_slip_send_ack(priv); - if (priv->nonblock) + + nxmutex_unlock(&priv->sliplock); + nxsem_wait_uninterruptible(&priv->sem); + ret = nxmutex_lock(&priv->sliplock); + if (ret < 0) { - ret = -EAGAIN; - goto end; - } - else - { - nxmutex_unlock(&priv->sliplock); - nxsem_wait_uninterruptible(&priv->sem); - ret = nxmutex_lock(&priv->sliplock); - if (ret < 0) - { - return ret; - } + return ret; } } @@ -988,36 +979,18 @@ static int bt_slip_ioctl(FAR struct bt_driver_s *dev, int cmd, { FAR struct sliphci_s *priv; FAR struct bt_driver_s *drv; - int ret; DEBUGASSERT(dev != NULL); priv = (FAR struct sliphci_s *)dev; drv = priv->drv; - switch (cmd) + if (!drv->ioctl) { - case FIONBIO: - { - FAR int *nonblock = (FAR int *)(uintptr_t)arg; - if (nonblock && *nonblock) - { - priv->nonblock = true; - } - else - { - priv->nonblock = false; - } - } - - ret = OK; - break; - default: - ret = drv->ioctl(drv, cmd, arg); - break; + return -ENOTTY; } - return ret; + return drv->ioctl(drv, cmd, arg); } static void bt_slip_close(FAR struct bt_driver_s *dev)