22
33/*
44 * SPDX-FileCopyrightText: 2017 Intel Corporation
5- * SPDX-FileContributor: 2018-2022 Espressif Systems (Shanghai) CO LTD
5+ * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
66 *
77 * SPDX-License-Identifier: Apache-2.0
88 */
@@ -335,8 +335,7 @@ static void adv_thread(void *p)
335335 }
336336
337337 /* busy == 0 means this was canceled */
338- if (BLE_MESH_ADV (* buf )-> busy ) {
339- BLE_MESH_ADV (* buf )-> busy = 0U ;
338+ if (bt_mesh_atomic_cas (& BLE_MESH_ADV_BUSY (* buf ), 1 , 0 )) {
340339#if !CONFIG_BLE_MESH_RELAY_ADV_BUF
341340 if (adv_send (* buf )) {
342341 BT_WARN ("Failed to send adv packet" );
@@ -449,7 +448,7 @@ static void bt_mesh_unref_buf(bt_mesh_msg_t *msg)
449448
450449 if (msg -> arg ) {
451450 buf = (struct net_buf * )msg -> arg ;
452- BLE_MESH_ADV ( buf )-> busy = 0U ;
451+ bt_mesh_atomic_set ( & BLE_MESH_ADV_BUSY ( buf ), 0 ) ;
453452 if (buf -> ref > 1U ) {
454453 buf -> ref = 1U ;
455454 }
@@ -490,7 +489,7 @@ void bt_mesh_adv_send(struct net_buf *buf, uint8_t xmit,
490489
491490 BLE_MESH_ADV (buf )-> cb = cb ;
492491 BLE_MESH_ADV (buf )-> cb_data = cb_data ;
493- BLE_MESH_ADV ( buf )-> busy = 1U ;
492+ bt_mesh_atomic_set ( & BLE_MESH_ADV_BUSY ( buf ), 1 ) ;
494493 BLE_MESH_ADV (buf )-> xmit = xmit ;
495494
496495 bt_mesh_adv_buf_ref_debug (__func__ , buf , 3U , BLE_MESH_BUF_REF_SMALL );
@@ -589,7 +588,7 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, uint8_t xmit,
589588
590589 BLE_MESH_ADV (buf )-> cb = cb ;
591590 BLE_MESH_ADV (buf )-> cb_data = cb_data ;
592- BLE_MESH_ADV ( buf )-> busy = 1U ;
591+ bt_mesh_atomic_set ( & BLE_MESH_ADV_BUSY ( buf ), 1 ) ;
593592 BLE_MESH_ADV (buf )-> xmit = xmit ;
594593
595594 msg .arg = (void * )net_buf_ref (buf );
@@ -753,7 +752,7 @@ static void bt_mesh_ble_adv_send(struct net_buf *buf, const struct bt_mesh_send_
753752
754753 BLE_MESH_ADV (buf )-> cb = cb ;
755754 BLE_MESH_ADV (buf )-> cb_data = cb_data ;
756- BLE_MESH_ADV ( buf )-> busy = 1U ;
755+ bt_mesh_atomic_set ( & BLE_MESH_ADV_BUSY ( buf ), 1 ) ;
757756
758757 bt_mesh_adv_buf_ref_debug (__func__ , buf , 3U , BLE_MESH_BUF_REF_SMALL );
759758
@@ -772,7 +771,7 @@ static void ble_adv_tx_reset(struct ble_adv_tx *tx, bool unref)
772771 }
773772 bt_mesh_atomic_set (tx -> flags , 0 );
774773 memset (& tx -> param , 0 , sizeof (tx -> param ));
775- BLE_MESH_ADV ( tx -> buf )-> busy = 0U ;
774+ bt_mesh_atomic_set ( & BLE_MESH_ADV_BUSY ( tx -> buf ), 0 ) ;
776775 if (unref ) {
777776 net_buf_unref (tx -> buf );
778777 }
@@ -961,7 +960,8 @@ int bt_mesh_stop_ble_advertising(uint8_t index)
961960 /* busy 1, ref 1; busy 1, ref 2;
962961 * busy 0, ref 0; busy 0, ref 1;
963962 */
964- if (BLE_MESH_ADV (tx -> buf )-> busy == 1U &&
963+
964+ if (bt_mesh_atomic_get (& BLE_MESH_ADV_BUSY (tx -> buf )) &&
965965 tx -> buf -> ref == 1U ) {
966966 unref = false;
967967 }
0 commit comments