diff options
author | Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> | 2014-05-09 15:35:28 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-05-09 17:16:42 -0400 |
commit | 5a134faeef82b46ff4ad244d11d8c6be41679834 (patch) | |
tree | 5e222abbed314e7a17a1cc67f8be90451577b75c /net | |
parent | b75cf9cd162244fe1c29691a21acfb1e657101a7 (diff) |
Bluetooth: Store TX power level for connection
This patch adds support to store local TX power level for connection
when reply for HCI_Read_Transmit_Power_Level is received.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_conn.c | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 55a174317925..74b368bfe102 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -407,6 +407,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
407 | conn->io_capability = hdev->io_capability; | 407 | conn->io_capability = hdev->io_capability; |
408 | conn->remote_auth = 0xff; | 408 | conn->remote_auth = 0xff; |
409 | conn->key_type = 0xff; | 409 | conn->key_type = 0xff; |
410 | conn->tx_power = HCI_TX_POWER_INVALID; | ||
410 | 411 | ||
411 | set_bit(HCI_CONN_POWER_SAVE, &conn->flags); | 412 | set_bit(HCI_CONN_POWER_SAVE, &conn->flags); |
412 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; | 413 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2bb0053d4c45..fa614e3430a7 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1264,6 +1264,30 @@ static void hci_cc_read_rssi(struct hci_dev *hdev, struct sk_buff *skb) | |||
1264 | hci_dev_unlock(hdev); | 1264 | hci_dev_unlock(hdev); |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | static void hci_cc_read_tx_power(struct hci_dev *hdev, struct sk_buff *skb) | ||
1268 | { | ||
1269 | struct hci_cp_read_tx_power *sent; | ||
1270 | struct hci_rp_read_tx_power *rp = (void *) skb->data; | ||
1271 | struct hci_conn *conn; | ||
1272 | |||
1273 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); | ||
1274 | |||
1275 | if (rp->status) | ||
1276 | return; | ||
1277 | |||
1278 | sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER); | ||
1279 | if (!sent) | ||
1280 | return; | ||
1281 | |||
1282 | hci_dev_lock(hdev); | ||
1283 | |||
1284 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); | ||
1285 | if (conn && sent->type == 0x00) | ||
1286 | conn->tx_power = rp->tx_power; | ||
1287 | |||
1288 | hci_dev_unlock(hdev); | ||
1289 | } | ||
1290 | |||
1267 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | 1291 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) |
1268 | { | 1292 | { |
1269 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | 1293 | BT_DBG("%s status 0x%2.2x", hdev->name, status); |
@@ -2660,6 +2684,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2660 | hci_cc_read_rssi(hdev, skb); | 2684 | hci_cc_read_rssi(hdev, skb); |
2661 | break; | 2685 | break; |
2662 | 2686 | ||
2687 | case HCI_OP_READ_TX_POWER: | ||
2688 | hci_cc_read_tx_power(hdev, skb); | ||
2689 | break; | ||
2690 | |||
2663 | default: | 2691 | default: |
2664 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2692 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2665 | break; | 2693 | break; |