Skip to content

Commit 00eb8f6

Browse files
chengkai15xiaoxiang781216
authored andcommitted
bluetooth: remove noblock mode handle
rootcause: move block and noblock handle to BTH4 handle. Signed-off-by: chengkai <[email protected]>
1 parent 113b660 commit 00eb8f6

File tree

1 file changed

+14
-41
lines changed

1 file changed

+14
-41
lines changed

drivers/wireless/bluetooth/bt_slip.c

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <nuttx/net/bluetooth.h>
3737
#include <nuttx/semaphore.h>
3838

39-
#include <nuttx/wireless/bluetooth/bt_ioctl.h>
4039
#include <nuttx/wireless/bluetooth/bt_slip.h>
4140

4241
/****************************************************************************
@@ -127,7 +126,6 @@ struct sliphci_s
127126
} linkstate;
128127

129128
bool dipresent; /* Data integrity check */
130-
bool nonblock; /* Send hci in noblock mode */
131129

132130
uint8_t rxack; /* Last ack number received */
133131
uint8_t txseq; /* Next seq number to send */
@@ -522,7 +520,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
522520
{
523521
size_t to_remove;
524522
uint8_t seq;
525-
int semcount = 0;
526523

527524
to_remove = bt_slip_unack_size(priv);
528525
if (to_remove == 0)
@@ -553,12 +550,14 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
553550
{
554551
bt_slip_unack_dtor(priv);
555552

556-
/* When in blocked hci write mode, we needs to notifiy bt_slip_send
557-
* if it was blocked by full tx window.
553+
/* When it was blocked by full tx window, we needs to notifiy
554+
* bt_slip_send.
558555
*/
559556

560-
if ((bt_slip_unack_size(priv) == priv->txwin - 1) && !priv->nonblock)
557+
if (bt_slip_unack_size(priv) == priv->txwin - 1)
561558
{
559+
int semcount;
560+
562561
nxsem_get_value(&priv->sem, &semcount);
563562
if (semcount < 0)
564563
{
@@ -570,7 +569,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
570569
}
571570

572571
to_remove = bt_slip_unack_size(priv);
573-
574572
if (!to_remove)
575573
{
576574
work_cancel(HPWORK, &priv->retxworker);
@@ -708,20 +706,13 @@ static int bt_slip_send(FAR struct bt_driver_s *dev,
708706
if (bt_slip_unack_size(priv) >= priv->txwin)
709707
{
710708
bt_slip_send_ack(priv);
711-
if (priv->nonblock)
712-
{
713-
ret = -EAGAIN;
714-
goto end;
715-
}
716-
else
709+
710+
nxmutex_unlock(&priv->sliplock);
711+
nxsem_wait_uninterruptible(&priv->sem);
712+
ret = nxmutex_lock(&priv->sliplock);
713+
if (ret < 0)
717714
{
718-
nxmutex_unlock(&priv->sliplock);
719-
nxsem_wait_uninterruptible(&priv->sem);
720-
ret = nxmutex_lock(&priv->sliplock);
721-
if (ret < 0)
722-
{
723-
return ret;
724-
}
715+
return ret;
725716
}
726717
}
727718

@@ -988,36 +979,18 @@ static int bt_slip_ioctl(FAR struct bt_driver_s *dev, int cmd,
988979
{
989980
FAR struct sliphci_s *priv;
990981
FAR struct bt_driver_s *drv;
991-
int ret;
992982

993983
DEBUGASSERT(dev != NULL);
994984

995985
priv = (FAR struct sliphci_s *)dev;
996986
drv = priv->drv;
997987

998-
switch (cmd)
988+
if (!drv->ioctl)
999989
{
1000-
case FIONBIO:
1001-
{
1002-
FAR int *nonblock = (FAR int *)(uintptr_t)arg;
1003-
if (nonblock && *nonblock)
1004-
{
1005-
priv->nonblock = true;
1006-
}
1007-
else
1008-
{
1009-
priv->nonblock = false;
1010-
}
1011-
}
1012-
1013-
ret = OK;
1014-
break;
1015-
default:
1016-
ret = drv->ioctl(drv, cmd, arg);
1017-
break;
990+
return -ENOTTY;
1018991
}
1019992

1020-
return ret;
993+
return drv->ioctl(drv, cmd, arg);
1021994
}
1022995

1023996
static void bt_slip_close(FAR struct bt_driver_s *dev)

0 commit comments

Comments
 (0)