Skip to content

Commit 5e13036

Browse files
jhedbergGustavo Padovan
authored andcommitted
Bluetooth: Introduce a new HCI_RFKILLED flag
This makes it more convenient to check for rfkill (no need to check for dev->rfkill before calling rfkill_blocked()) and also avoids potential races if the RFKILL state needs to be checked from within the rfkill callback. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Cc: stable@vger.kernel.org Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 330b6c1 commit 5e13036

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎include/net/bluetooth/hci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ enum {
104104
enum {
105105
HCI_SETUP,
106106
HCI_AUTO_OFF,
107+
HCI_RFKILLED,
107108
HCI_MGMT,
108109
HCI_PAIRABLE,
109110
HCI_SERVICE_CACHE,

‎net/bluetooth/hci_core.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ int hci_dev_open(__u16 dev)
11461146
goto done;
11471147
}
11481148

1149-
if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) {
1149+
if (test_bit(HCI_RFKILLED, &hdev->dev_flags)) {
11501150
ret = -ERFKILL;
11511151
goto done;
11521152
}
@@ -1566,10 +1566,12 @@ static int hci_rfkill_set_block(void *data, bool blocked)
15661566

15671567
BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
15681568

1569-
if (!blocked)
1570-
return 0;
1571-
1572-
hci_dev_do_close(hdev);
1569+
if (blocked) {
1570+
set_bit(HCI_RFKILLED, &hdev->dev_flags);
1571+
hci_dev_do_close(hdev);
1572+
} else {
1573+
clear_bit(HCI_RFKILLED, &hdev->dev_flags);
1574+
}
15731575

15741576
return 0;
15751577
}
@@ -2209,6 +2211,9 @@ int hci_register_dev(struct hci_dev *hdev)
22092211
}
22102212
}
22112213

2214+
if (hdev->rfkill && rfkill_blocked(hdev->rfkill))
2215+
set_bit(HCI_RFKILLED, &hdev->dev_flags);
2216+
22122217
set_bit(HCI_SETUP, &hdev->dev_flags);
22132218

22142219
if (hdev->dev_type != HCI_AMP)

0 commit comments

Comments
 (0)