@@ -1370,23 +1370,20 @@ static u8 mgmt_le_support(struct hci_dev *hdev)
13701370 return MGMT_STATUS_SUCCESS ;
13711371}
13721372
1373- void mgmt_set_discoverable_complete (struct hci_dev * hdev , u8 status )
1373+ static void mgmt_set_discoverable_complete (struct hci_dev * hdev , void * data ,
1374+ int err )
13741375{
1375- struct mgmt_pending_cmd * cmd ;
1376+ struct mgmt_pending_cmd * cmd = data ;
13761377
1377- bt_dev_dbg (hdev , "status 0x%02x " , status );
1378+ bt_dev_dbg (hdev , "err %d " , err );
13781379
13791380 hci_dev_lock (hdev );
13801381
1381- cmd = pending_find (MGMT_OP_SET_DISCOVERABLE , hdev );
1382- if (!cmd )
1383- goto unlock ;
1384-
1385- if (status ) {
1386- u8 mgmt_err = mgmt_status (status );
1382+ if (err ) {
1383+ u8 mgmt_err = mgmt_status (err );
13871384 mgmt_cmd_status (cmd -> sk , cmd -> index , cmd -> opcode , mgmt_err );
13881385 hci_dev_clear_flag (hdev , HCI_LIMITED_DISCOVERABLE );
1389- goto remove_cmd ;
1386+ goto done ;
13901387 }
13911388
13921389 if (hci_dev_test_flag (hdev , HCI_DISCOVERABLE ) &&
@@ -1398,13 +1395,18 @@ void mgmt_set_discoverable_complete(struct hci_dev *hdev, u8 status)
13981395 send_settings_rsp (cmd -> sk , MGMT_OP_SET_DISCOVERABLE , hdev );
13991396 new_settings (hdev , cmd -> sk );
14001397
1401- remove_cmd :
1402- mgmt_pending_remove (cmd );
1403-
1404- unlock :
1398+ done :
1399+ mgmt_pending_free (cmd );
14051400 hci_dev_unlock (hdev );
14061401}
14071402
1403+ static int set_discoverable_sync (struct hci_dev * hdev , void * data )
1404+ {
1405+ BT_DBG ("%s" , hdev -> name );
1406+
1407+ return hci_update_discoverable_sync (hdev );
1408+ }
1409+
14081410static int set_discoverable (struct sock * sk , struct hci_dev * hdev , void * data ,
14091411 u16 len )
14101412{
@@ -1503,7 +1505,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
15031505 goto failed ;
15041506 }
15051507
1506- cmd = mgmt_pending_add (sk , MGMT_OP_SET_DISCOVERABLE , hdev , data , len );
1508+ cmd = mgmt_pending_new (sk , MGMT_OP_SET_DISCOVERABLE , hdev , data , len );
15071509 if (!cmd ) {
15081510 err = - ENOMEM ;
15091511 goto failed ;
@@ -1527,8 +1529,8 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
15271529 else
15281530 hci_dev_clear_flag (hdev , HCI_LIMITED_DISCOVERABLE );
15291531
1530- queue_work (hdev -> req_workqueue , & hdev -> discoverable_update );
1531- err = 0 ;
1532+ err = hci_cmd_sync_queue (hdev , set_discoverable_sync , cmd ,
1533+ mgmt_set_discoverable_complete ) ;
15321534
15331535failed :
15341536 hci_dev_unlock (hdev );
@@ -1677,12 +1679,7 @@ static int set_bondable(struct sock *sk, struct hci_dev *hdev, void *data,
16771679 /* In limited privacy mode the change of bondable mode
16781680 * may affect the local advertising address.
16791681 */
1680- if (hdev_is_powered (hdev ) &&
1681- hci_dev_test_flag (hdev , HCI_ADVERTISING ) &&
1682- hci_dev_test_flag (hdev , HCI_DISCOVERABLE ) &&
1683- hci_dev_test_flag (hdev , HCI_LIMITED_PRIVACY ))
1684- queue_work (hdev -> req_workqueue ,
1685- & hdev -> discoverable_update );
1682+ hci_update_discoverable (hdev );
16861683
16871684 err = new_settings (hdev , sk );
16881685 }
0 commit comments