Bluetooth: SMP: Use flag for tracking if encryption pending
There is no need to have sparate bool in context structure while flags field is available. Change-Id: Ib1bcf9794c32268897b0a873787566a620f3097b Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
8e645f9e7c
commit
e6b32cd098
1 changed files with 4 additions and 8 deletions
|
@ -64,6 +64,7 @@ enum pairing_method {
|
|||
enum {
|
||||
SMP_FLAG_TK_VALID, /* if TK values is valid */
|
||||
SMP_FLAG_CFM_DELAYED, /* if confirm should be send when TK is valid */
|
||||
SMP_FLAG_ENC_PENDING, /* if waiting for an encryption change event */
|
||||
};
|
||||
|
||||
/* SMP channel specific context */
|
||||
|
@ -74,9 +75,6 @@ struct bt_smp {
|
|||
/* Commands that remote is allowed to send */
|
||||
atomic_t allowed_cmds;
|
||||
|
||||
/* If we're waiting for an encryption change event */
|
||||
bool pending_encrypt;
|
||||
|
||||
/* Flags for SMP state machine */
|
||||
atomic_t flags;
|
||||
|
||||
|
@ -756,7 +754,7 @@ static uint8_t smp_pairing_random(struct bt_conn *conn, struct bt_buf *buf)
|
|||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
smp->pending_encrypt = true;
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_ENC_PENDING);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -781,7 +779,7 @@ static uint8_t smp_pairing_random(struct bt_conn *conn, struct bt_buf *buf)
|
|||
|
||||
BT_DBG("generated STK %s\n", h(keys->slave_ltk.val, 16));
|
||||
|
||||
smp->pending_encrypt = true;
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_ENC_PENDING);
|
||||
|
||||
smp_send_pairing_random(conn);
|
||||
|
||||
|
@ -1219,12 +1217,10 @@ static void bt_smp_encrypt_change(struct bt_conn *conn)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!smp->pending_encrypt) {
|
||||
if (!atomic_test_and_clear_bit(&smp->flags, SMP_FLAG_ENC_PENDING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
smp->pending_encrypt = false;
|
||||
|
||||
if (smp->remote_dist & BT_SMP_DIST_ENC_KEY) {
|
||||
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_ENCRYPT_INFO);
|
||||
} else if (smp->remote_dist & BT_SMP_DIST_ID_KEY) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue