Skip to content

Commit bbaf444

Browse files
jhedbergGustavo Padovan
authored andcommitted
Bluetooth: Use proper invalid value for tx_power
The core specification defines 127 as the "not available" value (well, "reserved" for BR/EDR and "not available" for LE - but essentially the same). Therefore, instead of testing for 0 (which is in fact a valid value) we should be using this invalid value to test if the tx_power is available. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 57527f8 commit bbaf444

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎include/net/bluetooth/hci.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ enum {
319319
#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
320320
#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
321321

322+
/* The core spec defines 127 as the "not available" value */
323+
#define HCI_TX_POWER_INVALID 127
324+
322325
/* Extended Inquiry Response field types */
323326
#define EIR_FLAGS 0x01 /* flags */
324327
#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */

‎net/bluetooth/hci_core.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,8 @@ struct hci_dev *hci_alloc_dev(void)
16061606
hdev->esco_type = (ESCO_HV1);
16071607
hdev->link_mode = (HCI_LM_ACCEPT);
16081608
hdev->io_capability = 0x03; /* No Input No Output */
1609+
hdev->inq_tx_power = HCI_TX_POWER_INVALID;
1610+
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
16091611

16101612
hdev->sniff_max_interval = 800;
16111613
hdev->sniff_min_interval = 80;

‎net/bluetooth/hci_event.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
202202
BIT(HCI_PERIODIC_INQ));
203203

204204
hdev->discovery.state = DISCOVERY_STOPPED;
205+
hdev->inq_tx_power = HCI_TX_POWER_INVALID;
206+
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
205207
}
206208

207209
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)

‎net/bluetooth/mgmt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
484484
ptr += (name_len + 2);
485485
}
486486

487-
if (hdev->inq_tx_power) {
487+
if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) {
488488
ptr[0] = 2;
489489
ptr[1] = EIR_TX_POWER;
490490
ptr[2] = (u8) hdev->inq_tx_power;

0 commit comments

Comments
 (0)