ble_mesh: Remove useless parameters of lock/unlock
This commit is contained in:
parent
d2bc597e9f
commit
e4223df60f
4 changed files with 23 additions and 35 deletions
|
@ -268,8 +268,8 @@ s64_t k_uptime_get(void);
|
||||||
*/
|
*/
|
||||||
void k_sleep(s32_t duration);
|
void k_sleep(s32_t duration);
|
||||||
|
|
||||||
unsigned int bt_mesh_irq_lock(void);
|
void bt_mesh_irq_lock(void);
|
||||||
void bt_mesh_irq_unlock(unsigned int key);
|
void bt_mesh_irq_unlock(void);
|
||||||
|
|
||||||
void bt_mesh_k_init(void);
|
void bt_mesh_k_init(void);
|
||||||
|
|
||||||
|
|
|
@ -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)
|
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;
|
bt_mesh_atomic_val_t ret;
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
ret = *target;
|
ret = *target;
|
||||||
*target = value;
|
*target = value;
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
return ret;
|
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)
|
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;
|
bt_mesh_atomic_val_t ret;
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
ret = *target;
|
ret = *target;
|
||||||
*target |= value;
|
*target |= value;
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
return ret;
|
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)
|
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;
|
bt_mesh_atomic_val_t ret;
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
ret = *target;
|
ret = *target;
|
||||||
*target &= value;
|
*target &= value;
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
return ret;
|
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)
|
bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target)
|
||||||
{
|
{
|
||||||
unsigned int key;
|
|
||||||
bt_mesh_atomic_val_t ret;
|
bt_mesh_atomic_val_t ret;
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
ret = *target;
|
ret = *target;
|
||||||
(*target)--;
|
(*target)--;
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
return ret;
|
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)
|
bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target)
|
||||||
{
|
{
|
||||||
unsigned int key;
|
|
||||||
bt_mesh_atomic_val_t ret;
|
bt_mesh_atomic_val_t ret;
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
ret = *target;
|
ret = *target;
|
||||||
(*target)++;
|
(*target)++;
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
|
||||||
{
|
{
|
||||||
struct net_buf *tail;
|
struct net_buf *tail;
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
NET_BUF_ASSERT(list);
|
NET_BUF_ASSERT(list);
|
||||||
NET_BUF_ASSERT(buf);
|
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;
|
tail->flags |= NET_BUF_FRAGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
sys_slist_append_list(list, &buf->node, &tail->node);
|
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 *net_buf_slist_get(sys_slist_t *list)
|
||||||
{
|
{
|
||||||
struct net_buf *buf, *frag;
|
struct net_buf *buf, *frag;
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
NET_BUF_ASSERT(list);
|
NET_BUF_ASSERT(list);
|
||||||
|
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
buf = (void *)sys_slist_get(list);
|
buf = (void *)sys_slist_get(list);
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -264,9 +262,9 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list)
|
||||||
|
|
||||||
/* Get any fragments belonging to this buffer */
|
/* Get any fragments belonging to this buffer */
|
||||||
for (frag = buf; (frag->flags & NET_BUF_FRAGS); frag = frag->frags) {
|
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);
|
frag->frags = (void *)sys_slist_get(list);
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
NET_BUF_ASSERT(frag->frags);
|
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
|
#endif
|
||||||
{
|
{
|
||||||
struct net_buf *buf = NULL;
|
struct net_buf *buf = NULL;
|
||||||
unsigned int key;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
NET_BUF_ASSERT(pool);
|
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
|
/* We need to lock interrupts temporarily to prevent race conditions
|
||||||
* when accessing pool->uninit_count.
|
* when accessing pool->uninit_count.
|
||||||
*/
|
*/
|
||||||
key = bt_mesh_irq_lock();
|
bt_mesh_irq_lock();
|
||||||
|
|
||||||
/* If there are uninitialized buffers we're guaranteed to succeed
|
/* If there are uninitialized buffers we're guaranteed to succeed
|
||||||
* with the allocation one way or another.
|
* 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--) {
|
for (i = pool->buf_count; i > 0; i--) {
|
||||||
buf = pool_get_uninit(pool, i);
|
buf = pool_get_uninit(pool, i);
|
||||||
if (!buf->ref) {
|
if (!buf->ref) {
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_mesh_irq_unlock(key);
|
bt_mesh_irq_unlock();
|
||||||
|
|
||||||
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
|
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -37,16 +37,12 @@ typedef struct alarm_t {
|
||||||
int64_t deadline_us;
|
int64_t deadline_us;
|
||||||
} osi_alarm_t;
|
} 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);
|
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);
|
osi_mutex_unlock(&bm_irq_lock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue