Commit a7bf9de0 authored by Szymon Janc's avatar Szymon Janc Committed by Johan Hedberg
Browse files

Bluetooth: Use BT_CMD_TEST macro for testing supported commands



Make code easier to read and more consistent.

Signed-off-by: default avatarSzymon Janc <szymon.janc@codecoup.pl>
parent 9c5c2f8b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}

+6 −6
Original line number Diff line number Diff line
@@ -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;
	}

@@ -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;
	}
@@ -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;
	}
@@ -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;
	}
+2 −2
Original line number Diff line number Diff line
@@ -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)