@@ -3246,24 +3246,17 @@ static void adv_expire(struct hci_dev *hdev, u32 flags)
32463246 hci_req_run (& req , NULL );
32473247}
32483248
3249- static void set_name_complete (struct hci_dev * hdev , u8 status , u16 opcode )
3249+ static void set_name_complete (struct hci_dev * hdev , void * data , int err )
32503250{
3251- struct mgmt_cp_set_local_name * cp ;
3252- struct mgmt_pending_cmd * cmd ;
3253-
3254- bt_dev_dbg (hdev , "status 0x%02x" , status );
3255-
3256- hci_dev_lock (hdev );
3257-
3258- cmd = pending_find (MGMT_OP_SET_LOCAL_NAME , hdev );
3259- if (!cmd )
3260- goto unlock ;
3251+ struct mgmt_pending_cmd * cmd = data ;
3252+ struct mgmt_cp_set_local_name * cp = cmd -> param ;
3253+ u8 status = mgmt_status (err );
32613254
3262- cp = cmd -> param ;
3255+ bt_dev_dbg ( hdev , "err %d" , err ) ;
32633256
32643257 if (status ) {
32653258 mgmt_cmd_status (cmd -> sk , hdev -> id , MGMT_OP_SET_LOCAL_NAME ,
3266- mgmt_status ( status ) );
3259+ status );
32673260 } else {
32683261 mgmt_cmd_complete (cmd -> sk , hdev -> id , MGMT_OP_SET_LOCAL_NAME , 0 ,
32693262 cp , sizeof (* cp ));
@@ -3273,17 +3266,29 @@ static void set_name_complete(struct hci_dev *hdev, u8 status, u16 opcode)
32733266 }
32743267
32753268 mgmt_pending_remove (cmd );
3269+ }
32763270
3277- unlock :
3278- hci_dev_unlock (hdev );
3271+ static int set_name_sync (struct hci_dev * hdev , void * data )
3272+ {
3273+ if (lmp_bredr_capable (hdev )) {
3274+ hci_update_name_sync (hdev );
3275+ hci_update_eir_sync (hdev );
3276+ }
3277+
3278+ /* The name is stored in the scan response data and so
3279+ * no need to update the advertising data here.
3280+ */
3281+ if (lmp_le_capable (hdev ) && hci_dev_test_flag (hdev , HCI_ADVERTISING ))
3282+ hci_update_scan_rsp_data_sync (hdev , hdev -> cur_adv_instance );
3283+
3284+ return 0 ;
32793285}
32803286
32813287static int set_local_name (struct sock * sk , struct hci_dev * hdev , void * data ,
32823288 u16 len )
32833289{
32843290 struct mgmt_cp_set_local_name * cp = data ;
32853291 struct mgmt_pending_cmd * cmd ;
3286- struct hci_request req ;
32873292 int err ;
32883293
32893294 bt_dev_dbg (hdev , "sock %p" , sk );
@@ -3319,29 +3324,23 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data,
33193324 }
33203325
33213326 cmd = mgmt_pending_add (sk , MGMT_OP_SET_LOCAL_NAME , hdev , data , len );
3322- if (!cmd ) {
3327+ if (!cmd )
33233328 err = - ENOMEM ;
3324- goto failed ;
3325- }
3329+ else
3330+ err = hci_cmd_sync_queue (hdev , set_name_sync , cmd ,
3331+ set_name_complete );
33263332
3327- memcpy (hdev -> dev_name , cp -> name , sizeof (hdev -> dev_name ));
3333+ if (err < 0 ) {
3334+ err = mgmt_cmd_status (sk , hdev -> id , MGMT_OP_SET_LOCAL_NAME ,
3335+ MGMT_STATUS_FAILED );
33283336
3329- hci_req_init (& req , hdev );
3337+ if (cmd )
3338+ mgmt_pending_remove (cmd );
33303339
3331- if (lmp_bredr_capable (hdev )) {
3332- __hci_req_update_name (& req );
3333- __hci_req_update_eir (& req );
3340+ goto failed ;
33343341 }
33353342
3336- /* The name is stored in the scan response data and so
3337- * no need to update the advertising data here.
3338- */
3339- if (lmp_le_capable (hdev ) && hci_dev_test_flag (hdev , HCI_ADVERTISING ))
3340- __hci_req_update_scan_rsp_data (& req , hdev -> cur_adv_instance );
3341-
3342- err = hci_req_run (& req , set_name_complete );
3343- if (err < 0 )
3344- mgmt_pending_remove (cmd );
3343+ memcpy (hdev -> dev_name , cp -> name , sizeof (hdev -> dev_name ));
33453344
33463345failed :
33473346 hci_dev_unlock (hdev );
0 commit comments