@@ -5108,24 +5108,14 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,
5108
5108
mgmt_event (MGMT_EV_ADV_MONITOR_ADDED , hdev , & ev , sizeof (ev ), sk );
5109
5109
}
5110
5110
5111
- void mgmt_adv_monitor_removed (struct hci_dev * hdev , u16 handle )
5111
+ static void mgmt_adv_monitor_removed (struct sock * sk , struct hci_dev * hdev ,
5112
+ u16 handle )
5112
5113
{
5113
5114
struct mgmt_ev_adv_monitor_removed ev ;
5114
- struct mgmt_pending_cmd * cmd ;
5115
- struct sock * sk_skip = NULL ;
5116
- struct mgmt_cp_remove_adv_monitor * cp ;
5117
-
5118
- cmd = pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev );
5119
- if (cmd ) {
5120
- cp = cmd -> param ;
5121
-
5122
- if (cp -> monitor_handle )
5123
- sk_skip = cmd -> sk ;
5124
- }
5125
5115
5126
5116
ev .monitor_handle = cpu_to_le16 (handle );
5127
5117
5128
- mgmt_event (MGMT_EV_ADV_MONITOR_REMOVED , hdev , & ev , sizeof (ev ), sk_skip );
5118
+ mgmt_event (MGMT_EV_ADV_MONITOR_REMOVED , hdev , & ev , sizeof (ev ), sk );
5129
5119
}
5130
5120
5131
5121
static int read_adv_mon_features (struct sock * sk , struct hci_dev * hdev ,
@@ -5227,8 +5217,7 @@ static int __add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
5227
5217
5228
5218
if (pending_find (MGMT_OP_SET_LE , hdev ) ||
5229
5219
pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR , hdev ) ||
5230
- pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev ) ||
5231
- pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev )) {
5220
+ pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev )) {
5232
5221
status = MGMT_STATUS_BUSY ;
5233
5222
goto unlock ;
5234
5223
}
@@ -5398,8 +5387,7 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
5398
5387
struct mgmt_pending_cmd * cmd = data ;
5399
5388
struct mgmt_cp_remove_adv_monitor * cp ;
5400
5389
5401
- if (status == - ECANCELED ||
5402
- cmd != pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev ))
5390
+ if (status == - ECANCELED )
5403
5391
return ;
5404
5392
5405
5393
hci_dev_lock (hdev );
@@ -5408,12 +5396,14 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
5408
5396
5409
5397
rp .monitor_handle = cp -> monitor_handle ;
5410
5398
5411
- if (!status )
5399
+ if (!status ) {
5400
+ mgmt_adv_monitor_removed (cmd -> sk , hdev , cp -> monitor_handle );
5412
5401
hci_update_passive_scan (hdev );
5402
+ }
5413
5403
5414
5404
mgmt_cmd_complete (cmd -> sk , cmd -> index , cmd -> opcode ,
5415
5405
mgmt_status (status ), & rp , sizeof (rp ));
5416
- mgmt_pending_remove (cmd );
5406
+ mgmt_pending_free (cmd );
5417
5407
5418
5408
hci_dev_unlock (hdev );
5419
5409
bt_dev_dbg (hdev , "remove monitor %d complete, status %d" ,
@@ -5423,10 +5413,6 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
5423
5413
static int mgmt_remove_adv_monitor_sync (struct hci_dev * hdev , void * data )
5424
5414
{
5425
5415
struct mgmt_pending_cmd * cmd = data ;
5426
-
5427
- if (cmd != pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev ))
5428
- return - ECANCELED ;
5429
-
5430
5416
struct mgmt_cp_remove_adv_monitor * cp = cmd -> param ;
5431
5417
u16 handle = __le16_to_cpu (cp -> monitor_handle );
5432
5418
@@ -5445,14 +5431,13 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
5445
5431
hci_dev_lock (hdev );
5446
5432
5447
5433
if (pending_find (MGMT_OP_SET_LE , hdev ) ||
5448
- pending_find (MGMT_OP_REMOVE_ADV_MONITOR , hdev ) ||
5449
5434
pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR , hdev ) ||
5450
5435
pending_find (MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI , hdev )) {
5451
5436
status = MGMT_STATUS_BUSY ;
5452
5437
goto unlock ;
5453
5438
}
5454
5439
5455
- cmd = mgmt_pending_add (sk , MGMT_OP_REMOVE_ADV_MONITOR , hdev , data , len );
5440
+ cmd = mgmt_pending_new (sk , MGMT_OP_REMOVE_ADV_MONITOR , hdev , data , len );
5456
5441
if (!cmd ) {
5457
5442
status = MGMT_STATUS_NO_RESOURCES ;
5458
5443
goto unlock ;
@@ -5462,7 +5447,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
5462
5447
mgmt_remove_adv_monitor_complete );
5463
5448
5464
5449
if (err ) {
5465
- mgmt_pending_remove (cmd );
5450
+ mgmt_pending_free (cmd );
5466
5451
5467
5452
if (err == - ENOMEM )
5468
5453
status = MGMT_STATUS_NO_RESOURCES ;
0 commit comments