diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2014-06-25 20:52:52 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-03 11:42:52 -0400 |
commit | d4905f2453bd228d8ffc57f4e25bba0a8f52c805 (patch) | |
tree | e04e8379f1e9ed13d368c1235a2023181d1d8a60 | |
parent | c20c02d5c8d76f39be461c25bf5de3a1dc96885e (diff) |
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>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 21 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 23 |
2 files changed, 22 insertions, 22 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, | |||
1181 | return hci_find_irk_by_rpa(hdev, bdaddr); | 1181 | return hci_find_irk_by_rpa(hdev, bdaddr); |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | static inline int hci_check_conn_params(u16 min, u16 max, u16 latency, | ||
1185 | u16 to_multiplier) | ||
1186 | { | ||
1187 | u16 max_latency; | ||
1188 | |||
1189 | if (min > max || min < 6 || max > 3200) | ||
1190 | return -EINVAL; | ||
1191 | |||
1192 | if (to_multiplier < 10 || to_multiplier > 3200) | ||
1193 | return -EINVAL; | ||
1194 | |||
1195 | if (max >= to_multiplier * 8) | ||
1196 | return -EINVAL; | ||
1197 | |||
1198 | max_latency = (to_multiplier * 8 / max) - 1; | ||
1199 | if (latency > 499 || latency > max_latency) | ||
1200 | return -EINVAL; | ||
1201 | |||
1202 | return 0; | ||
1203 | } | ||
1204 | |||
1184 | int hci_register_cb(struct hci_cb *hcb); | 1205 | int hci_register_cb(struct hci_cb *hcb); |
1185 | int hci_unregister_cb(struct hci_cb *hcb); | 1206 | int hci_unregister_cb(struct hci_cb *hcb); |
1186 | 1207 | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index d015aa190fdc..e203a5fdf874 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -5213,27 +5213,6 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, | |||
5213 | return 0; | 5213 | return 0; |
5214 | } | 5214 | } |
5215 | 5215 | ||
5216 | static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, | ||
5217 | u16 to_multiplier) | ||
5218 | { | ||
5219 | u16 max_latency; | ||
5220 | |||
5221 | if (min > max || min < 6 || max > 3200) | ||
5222 | return -EINVAL; | ||
5223 | |||
5224 | if (to_multiplier < 10 || to_multiplier > 3200) | ||
5225 | return -EINVAL; | ||
5226 | |||
5227 | if (max >= to_multiplier * 8) | ||
5228 | return -EINVAL; | ||
5229 | |||
5230 | max_latency = (to_multiplier * 8 / max) - 1; | ||
5231 | if (latency > 499 || latency > max_latency) | ||
5232 | return -EINVAL; | ||
5233 | |||
5234 | return 0; | ||
5235 | } | ||
5236 | |||
5237 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | 5216 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, |
5238 | struct l2cap_cmd_hdr *cmd, | 5217 | struct l2cap_cmd_hdr *cmd, |
5239 | u16 cmd_len, u8 *data) | 5218 | u16 cmd_len, u8 *data) |
@@ -5261,7 +5240,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
5261 | 5240 | ||
5262 | memset(&rsp, 0, sizeof(rsp)); | 5241 | memset(&rsp, 0, sizeof(rsp)); |
5263 | 5242 | ||
5264 | err = l2cap_check_conn_param(min, max, latency, to_multiplier); | 5243 | err = hci_check_conn_params(min, max, latency, to_multiplier); |
5265 | if (err) | 5244 | if (err) |
5266 | rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED); | 5245 | rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED); |
5267 | else | 5246 | else |