36
36
#include <nuttx/net/bluetooth.h>
37
37
#include <nuttx/semaphore.h>
38
38
39
- #include <nuttx/wireless/bluetooth/bt_ioctl.h>
40
39
#include <nuttx/wireless/bluetooth/bt_slip.h>
41
40
42
41
/****************************************************************************
@@ -127,7 +126,6 @@ struct sliphci_s
127
126
} linkstate ;
128
127
129
128
bool dipresent ; /* Data integrity check */
130
- bool nonblock ; /* Send hci in noblock mode */
131
129
132
130
uint8_t rxack ; /* Last ack number received */
133
131
uint8_t txseq ; /* Next seq number to send */
@@ -522,7 +520,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
522
520
{
523
521
size_t to_remove ;
524
522
uint8_t seq ;
525
- int semcount = 0 ;
526
523
527
524
to_remove = bt_slip_unack_size (priv );
528
525
if (to_remove == 0 )
@@ -553,12 +550,14 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
553
550
{
554
551
bt_slip_unack_dtor (priv );
555
552
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 .
558
555
*/
559
556
560
- if (( bt_slip_unack_size (priv ) == priv -> txwin - 1 ) && ! priv -> nonblock )
557
+ if (bt_slip_unack_size (priv ) == priv -> txwin - 1 )
561
558
{
559
+ int semcount ;
560
+
562
561
nxsem_get_value (& priv -> sem , & semcount );
563
562
if (semcount < 0 )
564
563
{
@@ -570,7 +569,6 @@ static void bt_slip_unack_handle(FAR struct sliphci_s *priv)
570
569
}
571
570
572
571
to_remove = bt_slip_unack_size (priv );
573
-
574
572
if (!to_remove )
575
573
{
576
574
work_cancel (HPWORK , & priv -> retxworker );
@@ -708,20 +706,13 @@ static int bt_slip_send(FAR struct bt_driver_s *dev,
708
706
if (bt_slip_unack_size (priv ) >= priv -> txwin )
709
707
{
710
708
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 )
717
714
{
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 ;
725
716
}
726
717
}
727
718
@@ -988,36 +979,18 @@ static int bt_slip_ioctl(FAR struct bt_driver_s *dev, int cmd,
988
979
{
989
980
FAR struct sliphci_s * priv ;
990
981
FAR struct bt_driver_s * drv ;
991
- int ret ;
992
982
993
983
DEBUGASSERT (dev != NULL );
994
984
995
985
priv = (FAR struct sliphci_s * )dev ;
996
986
drv = priv -> drv ;
997
987
998
- switch ( cmd )
988
+ if (! drv -> ioctl )
999
989
{
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 ;
1018
991
}
1019
992
1020
- return ret ;
993
+ return drv -> ioctl ( drv , cmd , arg ) ;
1021
994
}
1022
995
1023
996
static void bt_slip_close (FAR struct bt_driver_s * dev )
0 commit comments