Skip to content

Commit

Permalink
Bluetooth: Use BT_CMD_TEST macro for testing supported commands
Browse files Browse the repository at this point in the history
Make code easier to read and more consistent.

Signed-off-by: Szymon Janc <[email protected]>
  • Loading branch information
sjanc authored and jhedberg committed Sep 28, 2018
1 parent 9c5c2f8 commit a7bf9de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int prng_init(void)
int ret;

/* Check first that HCI_LE_Rand is supported */
if (!(bt_dev.supported_commands[27] & BIT(7))) {
if (!BT_CMD_TEST(bt_dev.supported_commands, 27, 7)) {
return -ENOTSUP;
}

Expand Down
12 changes: 6 additions & 6 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void report_completed_packet(struct net_buf *buf)
net_buf_destroy(buf);

/* Do nothing if controller to host flow control is not supported */
if (!(bt_dev.supported_commands[10] & 0x20)) {
if (!BT_CMD_TEST(bt_dev.supported_commands, 10, 5)) {
return;
}

Expand Down Expand Up @@ -1314,7 +1314,7 @@ static int set_flow_control(void)
int err;

/* Check if host flow control is actually supported */
if (!(bt_dev.supported_commands[10] & 0x20)) {
if (!BT_CMD_TEST(bt_dev.supported_commands, 10, 5)) {
BT_WARN("Controller to host flow control not supported");
return 0;
}
Expand Down Expand Up @@ -3802,8 +3802,8 @@ static int le_set_event_mask(void)
* If "LE Read Local P-256 Public Key" and "LE Generate DH Key" are
* supported we need to enable events generated by those commands.
*/
if ((bt_dev.supported_commands[34] & 0x02) &&
(bt_dev.supported_commands[34] & 0x04)) {
if ((BT_CMD_TEST(bt_dev.supported_commands, 34, 1)) &&
(BT_CMD_TEST(bt_dev.supported_commands, 34, 2))) {
mask |= BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE;
mask |= BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE;
}
Expand Down Expand Up @@ -5698,8 +5698,8 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
* ECC support. If "LE Generate DH Key" is not supported then there
* is no point in reading local public key.
*/
if (!(bt_dev.supported_commands[34] & 0x02) ||
!(bt_dev.supported_commands[34] & 0x04)) {
if (!BT_CMD_TEST(bt_dev.supported_commands, 34, 1) ||
!BT_CMD_TEST(bt_dev.supported_commands, 34, 2)) {
BT_WARN("ECC HCI commands not available");
return -ENOTSUP;
}
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4563,8 +4563,8 @@ static bool le_sc_supported(void)
* "LE Read Local P-256 Public Key" and "LE Generate DH Key" commands.
* Otherwise LE SC are not supported.
*/
return (bt_dev.supported_commands[34] & 0x02) &&
(bt_dev.supported_commands[34] & 0x04);
return BT_CMD_TEST(bt_dev.supported_commands, 34, 1) &&
BT_CMD_TEST(bt_dev.supported_commands, 34, 2);
}

int bt_smp_init(void)
Expand Down

0 comments on commit a7bf9de

Please sign in to comment.