From 9dc45e788d89278cc462bf50e31dfba62f3cba32 Mon Sep 17 00:00:00 2001 From: lly Date: Sat, 14 Dec 2019 16:28:22 +0800 Subject: [PATCH] ble_mesh: Remove useless parameters of lock/unlock --- .../mesh_common/include/mesh_kernel.h | 4 +-- .../bt/esp_ble_mesh/mesh_common/mesh_atomic.c | 25 ++++++++----------- .../bt/esp_ble_mesh/mesh_common/mesh_buf.c | 21 +++++++--------- .../bt/esp_ble_mesh/mesh_common/mesh_kernel.c | 8 ++---- 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h index 7d00d6426..6d1aeb85d 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h @@ -268,8 +268,8 @@ s64_t k_uptime_get(void); */ void k_sleep(s32_t duration); -unsigned int bt_mesh_irq_lock(void); -void bt_mesh_irq_unlock(unsigned int key); +void bt_mesh_irq_lock(void); +void bt_mesh_irq_unlock(void); void bt_mesh_k_init(void); diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c b/components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c index ce7363805..026f103ff 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c @@ -55,15 +55,14 @@ bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target) */ bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) { - unsigned int key; bt_mesh_atomic_val_t ret; - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); ret = *target; *target = value; - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); return ret; } @@ -83,15 +82,14 @@ bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic */ bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) { - unsigned int key; bt_mesh_atomic_val_t ret; - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); ret = *target; *target |= value; - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); return ret; } @@ -111,15 +109,14 @@ bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_ */ bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) { - unsigned int key; bt_mesh_atomic_val_t ret; - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); ret = *target; *target &= value; - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); return ret; } @@ -137,15 +134,14 @@ bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic */ bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target) { - unsigned int key; bt_mesh_atomic_val_t ret; - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); ret = *target; (*target)--; - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); return ret; } @@ -163,15 +159,14 @@ bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target) */ bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target) { - unsigned int key; bt_mesh_atomic_val_t ret; - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); ret = *target; (*target)++; - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); return ret; } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c index 9e5f6c184..928e42e9f 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c @@ -233,7 +233,6 @@ void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve) void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf) { struct net_buf *tail; - unsigned int key; NET_BUF_ASSERT(list); NET_BUF_ASSERT(buf); @@ -242,21 +241,20 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf) tail->flags |= NET_BUF_FRAGS; } - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); sys_slist_append_list(list, &buf->node, &tail->node); - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); } struct net_buf *net_buf_slist_get(sys_slist_t *list) { struct net_buf *buf, *frag; - unsigned int key; NET_BUF_ASSERT(list); - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); buf = (void *)sys_slist_get(list); - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); if (!buf) { return NULL; @@ -264,9 +262,9 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list) /* Get any fragments belonging to this buffer */ for (frag = buf; (frag->flags & NET_BUF_FRAGS); frag = frag->frags) { - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); frag->frags = (void *)sys_slist_get(list); - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); NET_BUF_ASSERT(frag->frags); @@ -373,7 +371,6 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, #endif { struct net_buf *buf = NULL; - unsigned int key; int i; NET_BUF_ASSERT(pool); @@ -384,7 +381,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, /* We need to lock interrupts temporarily to prevent race conditions * when accessing pool->uninit_count. */ - key = bt_mesh_irq_lock(); + bt_mesh_irq_lock(); /* If there are uninitialized buffers we're guaranteed to succeed * with the allocation one way or another. @@ -394,13 +391,13 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, for (i = pool->buf_count; i > 0; i--) { buf = pool_get_uninit(pool, i); if (!buf->ref) { - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); goto success; } } } - bt_mesh_irq_unlock(key); + bt_mesh_irq_unlock(); NET_BUF_ERR("%s, Failed to get free buffer", __func__); return NULL; diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c index 6d459f774..33a738cad 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c @@ -37,16 +37,12 @@ typedef struct alarm_t { int64_t deadline_us; } osi_alarm_t; -unsigned int bt_mesh_irq_lock(void) +void bt_mesh_irq_lock(void) { - /* Changed by Espressif. In BLE Mesh, in order to improve the real-time - * requirements of bt controller, we use task lock instead of IRQ lock. - */ osi_mutex_lock(&bm_irq_lock, OSI_MUTEX_MAX_TIMEOUT); - return 0; } -void bt_mesh_irq_unlock(unsigned int key) +void bt_mesh_irq_unlock(void) { osi_mutex_unlock(&bm_irq_lock); }