aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/mgmt.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7a906d6e0236..07e31f73f703 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1394,6 +1394,20 @@ failed:
1394 return err; 1394 return err;
1395} 1395}
1396 1396
1397static bool enable_service_cache(struct hci_dev *hdev)
1398{
1399 if (!hdev_is_powered(hdev))
1400 return false;
1401
1402 if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) {
1403 schedule_delayed_work(&hdev->service_cache,
1404 msecs_to_jiffies(SERVICE_CACHE_TIMEOUT));
1405 return true;
1406 }
1407
1408 return false;
1409}
1410
1397static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) 1411static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len)
1398{ 1412{
1399 struct mgmt_cp_remove_uuid *cp = data; 1413 struct mgmt_cp_remove_uuid *cp = data;
@@ -1425,10 +1439,11 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len)
1425 if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) { 1439 if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) {
1426 err = hci_uuids_clear(hdev); 1440 err = hci_uuids_clear(hdev);
1427 1441
1428 if (hdev_is_powered(hdev) && 1442 if (enable_service_cache(hdev)) {
1429 !test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) 1443 err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0,
1430 schedule_delayed_work(&hdev->service_cache, 1444 hdev->dev_class, 3);
1431 msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); 1445 goto unlock;
1446 }
1432 1447
1433 goto update_class; 1448 goto update_class;
1434 } 1449 }