]> Pileus Git - ~andy/linux/commitdiff
Bluetooth: Use proper invalid value for tx_power
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 8 Nov 2012 00:22:59 +0000 (01:22 +0100)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Mon, 19 Nov 2012 01:03:00 +0000 (23:03 -0200)
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>
include/net/bluetooth/hci.h
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 6c414f4302fea70608cf8270c029c4be0f43561b..344fea0a7244e79f93fbf071b2914de05b07e651 100644 (file)
@@ -319,6 +319,9 @@ enum {
 #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
 #define HCI_FLOW_CTL_MODE_BLOCK_BASED  0x01
 
+/* The core spec defines 127 as the "not available" value */
+#define HCI_TX_POWER_INVALID   127
+
 /* Extended Inquiry Response field types */
 #define EIR_FLAGS              0x01 /* flags */
 #define EIR_UUID16_SOME                0x02 /* 16-bit UUID, more available */
index 515d0c394f35e29820801444e3a9d4510e549f2d..9713a2917ddc7c956e8c480f802ae09315eec9ba 100644 (file)
@@ -1606,6 +1606,8 @@ struct hci_dev *hci_alloc_dev(void)
        hdev->esco_type = (ESCO_HV1);
        hdev->link_mode = (HCI_LM_ACCEPT);
        hdev->io_capability = 0x03; /* No Input No Output */
+       hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+       hdev->adv_tx_power = HCI_TX_POWER_INVALID;
 
        hdev->sniff_max_interval = 800;
        hdev->sniff_min_interval = 80;
index c08ac7c0371195d27c0a29427fcd0a5edc3614be..09c65712e8cc8afbe6829d6f468c3b25472eb873 100644 (file)
@@ -202,6 +202,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
                             BIT(HCI_PERIODIC_INQ));
 
        hdev->discovery.state = DISCOVERY_STOPPED;
+       hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+       hdev->adv_tx_power = HCI_TX_POWER_INVALID;
 }
 
 static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
index a1a62baaaafb3ffcd519e9a8df322367e2f0e512..dedbb1d8b2d252800637975d720b937bcb029b53 100644 (file)
@@ -484,7 +484,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
                ptr += (name_len + 2);
        }
 
-       if (hdev->inq_tx_power) {
+       if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) {
                ptr[0] = 2;
                ptr[1] = EIR_TX_POWER;
                ptr[2] = (u8) hdev->inq_tx_power;