@@ -1760,6 +1760,69 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
1760
1760
return err ;
1761
1761
}
1762
1762
1763
+ static void set_ssp_complete (struct hci_dev * hdev , void * data , int err )
1764
+ {
1765
+ struct cmd_lookup match = { NULL , hdev };
1766
+ struct mgmt_pending_cmd * cmd = data ;
1767
+ struct mgmt_mode * cp = cmd -> param ;
1768
+ u8 enable = cp -> val ;
1769
+ bool changed ;
1770
+
1771
+ if (err ) {
1772
+ u8 mgmt_err = mgmt_status (err );
1773
+
1774
+ if (enable && hci_dev_test_and_clear_flag (hdev ,
1775
+ HCI_SSP_ENABLED )) {
1776
+ hci_dev_clear_flag (hdev , HCI_HS_ENABLED );
1777
+ new_settings (hdev , NULL );
1778
+ }
1779
+
1780
+ mgmt_pending_foreach (MGMT_OP_SET_SSP , hdev , cmd_status_rsp ,
1781
+ & mgmt_err );
1782
+ return ;
1783
+ }
1784
+
1785
+ if (enable ) {
1786
+ changed = !hci_dev_test_and_set_flag (hdev , HCI_SSP_ENABLED );
1787
+ } else {
1788
+ changed = hci_dev_test_and_clear_flag (hdev , HCI_SSP_ENABLED );
1789
+
1790
+ if (!changed )
1791
+ changed = hci_dev_test_and_clear_flag (hdev ,
1792
+ HCI_HS_ENABLED );
1793
+ else
1794
+ hci_dev_clear_flag (hdev , HCI_HS_ENABLED );
1795
+ }
1796
+
1797
+ mgmt_pending_foreach (MGMT_OP_SET_SSP , hdev , settings_rsp , & match );
1798
+
1799
+ if (changed )
1800
+ new_settings (hdev , match .sk );
1801
+
1802
+ if (match .sk )
1803
+ sock_put (match .sk );
1804
+
1805
+ hci_update_eir_sync (hdev );
1806
+ }
1807
+
1808
+ static int set_ssp_sync (struct hci_dev * hdev , void * data )
1809
+ {
1810
+ struct mgmt_pending_cmd * cmd = data ;
1811
+ struct mgmt_mode * cp = cmd -> param ;
1812
+ bool changed = false;
1813
+ int err ;
1814
+
1815
+ if (cp -> val )
1816
+ changed = !hci_dev_test_and_set_flag (hdev , HCI_SSP_ENABLED );
1817
+
1818
+ err = hci_write_ssp_mode_sync (hdev , cp -> val );
1819
+
1820
+ if (!err && changed )
1821
+ hci_dev_clear_flag (hdev , HCI_SSP_ENABLED );
1822
+
1823
+ return err ;
1824
+ }
1825
+
1763
1826
static int set_ssp (struct sock * sk , struct hci_dev * hdev , void * data , u16 len )
1764
1827
{
1765
1828
struct mgmt_mode * cp = data ;
@@ -1821,19 +1884,18 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1821
1884
}
1822
1885
1823
1886
cmd = mgmt_pending_add (sk , MGMT_OP_SET_SSP , hdev , data , len );
1824
- if (!cmd ) {
1887
+ if (!cmd )
1825
1888
err = - ENOMEM ;
1826
- goto failed ;
1827
- }
1828
-
1829
- if (!cp -> val && hci_dev_test_flag (hdev , HCI_USE_DEBUG_KEYS ))
1830
- hci_send_cmd (hdev , HCI_OP_WRITE_SSP_DEBUG_MODE ,
1831
- sizeof (cp -> val ), & cp -> val );
1889
+ else
1890
+ err = hci_cmd_sync_queue (hdev , set_ssp_sync , cmd ,
1891
+ set_ssp_complete );
1832
1892
1833
- err = hci_send_cmd (hdev , HCI_OP_WRITE_SSP_MODE , 1 , & cp -> val );
1834
1893
if (err < 0 ) {
1835
- mgmt_pending_remove (cmd );
1836
- goto failed ;
1894
+ err = mgmt_cmd_status (sk , hdev -> id , MGMT_OP_SET_SSP ,
1895
+ MGMT_STATUS_FAILED );
1896
+
1897
+ if (cmd )
1898
+ mgmt_pending_remove (cmd );
1837
1899
}
1838
1900
1839
1901
failed :
@@ -9309,74 +9371,6 @@ void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)
9309
9371
sock_put (match .sk );
9310
9372
}
9311
9373
9312
- static void clear_eir (struct hci_request * req )
9313
- {
9314
- struct hci_dev * hdev = req -> hdev ;
9315
- struct hci_cp_write_eir cp ;
9316
-
9317
- if (!lmp_ext_inq_capable (hdev ))
9318
- return ;
9319
-
9320
- memset (hdev -> eir , 0 , sizeof (hdev -> eir ));
9321
-
9322
- memset (& cp , 0 , sizeof (cp ));
9323
-
9324
- hci_req_add (req , HCI_OP_WRITE_EIR , sizeof (cp ), & cp );
9325
- }
9326
-
9327
- void mgmt_ssp_enable_complete (struct hci_dev * hdev , u8 enable , u8 status )
9328
- {
9329
- struct cmd_lookup match = { NULL , hdev };
9330
- struct hci_request req ;
9331
- bool changed = false;
9332
-
9333
- if (status ) {
9334
- u8 mgmt_err = mgmt_status (status );
9335
-
9336
- if (enable && hci_dev_test_and_clear_flag (hdev ,
9337
- HCI_SSP_ENABLED )) {
9338
- hci_dev_clear_flag (hdev , HCI_HS_ENABLED );
9339
- new_settings (hdev , NULL );
9340
- }
9341
-
9342
- mgmt_pending_foreach (MGMT_OP_SET_SSP , hdev , cmd_status_rsp ,
9343
- & mgmt_err );
9344
- return ;
9345
- }
9346
-
9347
- if (enable ) {
9348
- changed = !hci_dev_test_and_set_flag (hdev , HCI_SSP_ENABLED );
9349
- } else {
9350
- changed = hci_dev_test_and_clear_flag (hdev , HCI_SSP_ENABLED );
9351
- if (!changed )
9352
- changed = hci_dev_test_and_clear_flag (hdev ,
9353
- HCI_HS_ENABLED );
9354
- else
9355
- hci_dev_clear_flag (hdev , HCI_HS_ENABLED );
9356
- }
9357
-
9358
- mgmt_pending_foreach (MGMT_OP_SET_SSP , hdev , settings_rsp , & match );
9359
-
9360
- if (changed )
9361
- new_settings (hdev , match .sk );
9362
-
9363
- if (match .sk )
9364
- sock_put (match .sk );
9365
-
9366
- hci_req_init (& req , hdev );
9367
-
9368
- if (hci_dev_test_flag (hdev , HCI_SSP_ENABLED )) {
9369
- if (hci_dev_test_flag (hdev , HCI_USE_DEBUG_KEYS ))
9370
- hci_req_add (& req , HCI_OP_WRITE_SSP_DEBUG_MODE ,
9371
- sizeof (enable ), & enable );
9372
- __hci_req_update_eir (& req );
9373
- } else {
9374
- clear_eir (& req );
9375
- }
9376
-
9377
- hci_req_run (& req , NULL );
9378
- }
9379
-
9380
9374
static void sk_lookup (struct mgmt_pending_cmd * cmd , void * data )
9381
9375
{
9382
9376
struct cmd_lookup * match = data ;
0 commit comments