diff options
author | Vishal Agarwal <vishal.agarwal@stericsson.com> | 2012-04-13 08:13:22 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-04-16 05:57:40 -0400 |
commit | 745c0ce35f904aeff8e1ea325c259a14a00ff1b7 (patch) | |
tree | e1d05d006621b7cfd1009265ea2afe73b5cc2149 | |
parent | 87522a433ba6886b5ccbb497e0a7cb8097def64e (diff) |
Bluetooth: hci_persistent_key should return bool
This patch changes the return type of function hci_persistent_key
from int to bool because it makes more sense to return information
whether a key is persistent or not as a bool.
Signed-off-by: Vishal Agarwal <vishal.agarwal@stericsson.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 21 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 6822d2595aff..f8577c16fcf5 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -980,7 +980,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); | |||
980 | int mgmt_connectable(struct hci_dev *hdev, u8 connectable); | 980 | int mgmt_connectable(struct hci_dev *hdev, u8 connectable); |
981 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); | 981 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); |
982 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | 982 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, |
983 | u8 persistent); | 983 | bool persistent); |
984 | int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 984 | int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
985 | u8 addr_type, u32 flags, u8 *name, u8 name_len, | 985 | u8 addr_type, u32 flags, u8 *name, u8 name_len, |
986 | u8 *dev_class); | 986 | u8 *dev_class); |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2054c1321c87..c2251e4c3b72 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1216,40 +1216,40 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1216 | return NULL; | 1216 | return NULL; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, | 1219 | static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, |
1220 | u8 key_type, u8 old_key_type) | 1220 | u8 key_type, u8 old_key_type) |
1221 | { | 1221 | { |
1222 | /* Legacy key */ | 1222 | /* Legacy key */ |
1223 | if (key_type < 0x03) | 1223 | if (key_type < 0x03) |
1224 | return 1; | 1224 | return true; |
1225 | 1225 | ||
1226 | /* Debug keys are insecure so don't store them persistently */ | 1226 | /* Debug keys are insecure so don't store them persistently */ |
1227 | if (key_type == HCI_LK_DEBUG_COMBINATION) | 1227 | if (key_type == HCI_LK_DEBUG_COMBINATION) |
1228 | return 0; | 1228 | return false; |
1229 | 1229 | ||
1230 | /* Changed combination key and there's no previous one */ | 1230 | /* Changed combination key and there's no previous one */ |
1231 | if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff) | 1231 | if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff) |
1232 | return 0; | 1232 | return false; |
1233 | 1233 | ||
1234 | /* Security mode 3 case */ | 1234 | /* Security mode 3 case */ |
1235 | if (!conn) | 1235 | if (!conn) |
1236 | return 1; | 1236 | return true; |
1237 | 1237 | ||
1238 | /* Neither local nor remote side had no-bonding as requirement */ | 1238 | /* Neither local nor remote side had no-bonding as requirement */ |
1239 | if (conn->auth_type > 0x01 && conn->remote_auth > 0x01) | 1239 | if (conn->auth_type > 0x01 && conn->remote_auth > 0x01) |
1240 | return 1; | 1240 | return true; |
1241 | 1241 | ||
1242 | /* Local side had dedicated bonding as requirement */ | 1242 | /* Local side had dedicated bonding as requirement */ |
1243 | if (conn->auth_type == 0x02 || conn->auth_type == 0x03) | 1243 | if (conn->auth_type == 0x02 || conn->auth_type == 0x03) |
1244 | return 1; | 1244 | return true; |
1245 | 1245 | ||
1246 | /* Remote side had dedicated bonding as requirement */ | 1246 | /* Remote side had dedicated bonding as requirement */ |
1247 | if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) | 1247 | if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) |
1248 | return 1; | 1248 | return true; |
1249 | 1249 | ||
1250 | /* If none of the above criteria match, then don't store the key | 1250 | /* If none of the above criteria match, then don't store the key |
1251 | * persistently */ | 1251 | * persistently */ |
1252 | return 0; | 1252 | return false; |
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) | 1255 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) |
@@ -1286,7 +1286,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | |||
1286 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) | 1286 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) |
1287 | { | 1287 | { |
1288 | struct link_key *key, *old_key; | 1288 | struct link_key *key, *old_key; |
1289 | u8 old_key_type, persistent; | 1289 | u8 old_key_type; |
1290 | bool persistent; | ||
1290 | 1291 | ||
1291 | old_key = hci_find_link_key(hdev, bdaddr); | 1292 | old_key = hci_find_link_key(hdev, bdaddr); |
1292 | if (old_key) { | 1293 | if (old_key) { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4ef275c69675..4bb03b111122 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2884,7 +2884,7 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) | |||
2884 | return 0; | 2884 | return 0; |
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent) | 2887 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, bool persistent) |
2888 | { | 2888 | { |
2889 | struct mgmt_ev_new_link_key ev; | 2889 | struct mgmt_ev_new_link_key ev; |
2890 | 2890 | ||