diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-06-28 10:54:06 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-03 11:42:48 -0400 |
commit | 33f35721030185a2c5a1bb8afd4c3744709745b5 (patch) | |
tree | 886565f8f281ed16a6ad5c4307c746bb9b8adb91 /net | |
parent | fca20018e7b86a8716511c7681115baa47aca8e4 (diff) |
Bluetooth: Add tracking of local and piconet clock values
This patch adds support for storing the local and piconet clock values
from the HCI_Read_Clock command response to the hci_dev and hci_conn
structs. This will be later used in another patch to implement support
for the Get Clock Info mgmt command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_event.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 7a23324eac39..315d615ca3f9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -721,6 +721,41 @@ static void hci_cc_read_data_block_size(struct hci_dev *hdev, | |||
721 | hdev->block_cnt, hdev->block_len); | 721 | hdev->block_cnt, hdev->block_len); |
722 | } | 722 | } |
723 | 723 | ||
724 | static void hci_cc_read_clock(struct hci_dev *hdev, struct sk_buff *skb) | ||
725 | { | ||
726 | struct hci_rp_read_clock *rp = (void *) skb->data; | ||
727 | struct hci_cp_read_clock *cp; | ||
728 | struct hci_conn *conn; | ||
729 | |||
730 | BT_DBG("%s", hdev->name); | ||
731 | |||
732 | if (skb->len < sizeof(*rp)) | ||
733 | return; | ||
734 | |||
735 | if (rp->status) | ||
736 | return; | ||
737 | |||
738 | hci_dev_lock(hdev); | ||
739 | |||
740 | cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK); | ||
741 | if (!cp) | ||
742 | goto unlock; | ||
743 | |||
744 | if (cp->which == 0x00) { | ||
745 | hdev->clock = le32_to_cpu(rp->clock); | ||
746 | goto unlock; | ||
747 | } | ||
748 | |||
749 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); | ||
750 | if (conn) { | ||
751 | conn->clock = le32_to_cpu(rp->clock); | ||
752 | conn->clock_accuracy = le16_to_cpu(rp->accuracy); | ||
753 | } | ||
754 | |||
755 | unlock: | ||
756 | hci_dev_unlock(hdev); | ||
757 | } | ||
758 | |||
724 | static void hci_cc_read_local_amp_info(struct hci_dev *hdev, | 759 | static void hci_cc_read_local_amp_info(struct hci_dev *hdev, |
725 | struct sk_buff *skb) | 760 | struct sk_buff *skb) |
726 | { | 761 | { |
@@ -2597,6 +2632,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2597 | hci_cc_read_local_amp_info(hdev, skb); | 2632 | hci_cc_read_local_amp_info(hdev, skb); |
2598 | break; | 2633 | break; |
2599 | 2634 | ||
2635 | case HCI_OP_READ_CLOCK: | ||
2636 | hci_cc_read_clock(hdev, skb); | ||
2637 | break; | ||
2638 | |||
2600 | case HCI_OP_READ_LOCAL_AMP_ASSOC: | 2639 | case HCI_OP_READ_LOCAL_AMP_ASSOC: |
2601 | hci_cc_read_local_amp_assoc(hdev, skb); | 2640 | hci_cc_read_local_amp_assoc(hdev, skb); |
2602 | break; | 2641 | break; |