Skip to content

Commit

Permalink
Bluetooth: Store max TX power level for connection
Browse files Browse the repository at this point in the history
This patch adds support to store local maximum 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>
  • Loading branch information
Andrzej Kaczmarek authored and Marcel Holtmann committed May 16, 2014
1 parent f7faab0 commit d0455ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ struct hci_conn {
__u16 le_conn_max_interval;
__s8 rssi;
__s8 tx_power;
__s8 max_tx_power;
unsigned long flags;

unsigned long conn_info_timestamp;
Expand Down
1 change: 1 addition & 0 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
conn->remote_auth = 0xff;
conn->key_type = 0xff;
conn->tx_power = HCI_TX_POWER_INVALID;
conn->max_tx_power = HCI_TX_POWER_INVALID;

set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
Expand Down
12 changes: 11 additions & 1 deletion net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,9 +1282,19 @@ static void hci_cc_read_tx_power(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);

conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
if (conn && sent->type == 0x00)
if (!conn)
goto unlock;

switch (sent->type) {
case 0x00:
conn->tx_power = rp->tx_power;
break;
case 0x01:
conn->max_tx_power = rp->tx_power;
break;
}

unlock:
hci_dev_unlock(hdev);
}

Expand Down

0 comments on commit d0455ed

Please sign in to comment.