aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth/hci_core.h
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-06-25 21:52:52 -0300
committerMarcel Holtmann <marcel@holtmann.org>2014-07-03 17:42:52 +0200
commitd4905f2453bd228d8ffc57f4e25bba0a8f52c805 (patch)
treee04e8379f1e9ed13d368c1235a2023181d1d8a60 /include/net/bluetooth/hci_core.h
parentBluetooth: Start background scanning only when controller is ready (diff)
downloadlinux-dev-d4905f2453bd228d8ffc57f4e25bba0a8f52c805.tar.xz
linux-dev-d4905f2453bd228d8ffc57f4e25bba0a8f52c805.zip
Bluetooth: Connection parameters check helper
This patch renames l2cap_check_conn_param() to hci_check_conn_params() and moves it to hci_core.h so it can reused in others files. This helper will be reused in the next patch. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net/bluetooth/hci_core.h')
-rw-r--r--include/net/bluetooth/hci_core.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c0d2506e2019..ec830871b9b8 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1181,6 +1181,27 @@ static inline struct smp_irk *hci_get_irk(struct hci_dev *hdev,
return hci_find_irk_by_rpa(hdev, bdaddr);
}
+static inline int hci_check_conn_params(u16 min, u16 max, u16 latency,
+ u16 to_multiplier)
+{
+ u16 max_latency;
+
+ if (min > max || min < 6 || max > 3200)
+ return -EINVAL;
+
+ if (to_multiplier < 10 || to_multiplier > 3200)
+ return -EINVAL;
+
+ if (max >= to_multiplier * 8)
+ return -EINVAL;
+
+ max_latency = (to_multiplier * 8 / max) - 1;
+ if (latency > 499 || latency > max_latency)
+ return -EINVAL;
+
+ return 0;
+}
+
int hci_register_cb(struct hci_cb *hcb);
int hci_unregister_cb(struct hci_cb *hcb);