uniform code writing-disable interrupt

This commit is contained in:
thewon86
2022-04-20 14:22:43 +08:00
committed by guo
parent 5fa15a19a0
commit f5b0bfd3f4
47 changed files with 293 additions and 290 deletions
+4 -4
View File
@@ -86,7 +86,7 @@ void rt_prio_queue_detach(struct rt_prio_queue *que)
rt_thread_t thread;
/* disable interrupt */
rt_ubase_t temp = rt_hw_interrupt_disable();
rt_base_t level = rt_hw_interrupt_disable();
/* get next suspend thread */
thread = rt_list_entry(que->suspended_pop_list.next, struct rt_thread, tlist);
@@ -96,7 +96,7 @@ void rt_prio_queue_detach(struct rt_prio_queue *que)
rt_thread_resume(thread);
/* enable interrupt */
rt_hw_interrupt_enable(temp);
rt_hw_interrupt_enable(level);
}
rt_mp_detach(&que->pool);
}
@@ -136,7 +136,7 @@ rt_err_t rt_prio_queue_push(struct rt_prio_queue *que,
void *data,
rt_int32_t timeout)
{
rt_ubase_t level;
rt_base_t level;
struct rt_prio_queue_item *item;
RT_ASSERT(que);
@@ -182,7 +182,7 @@ rt_err_t rt_prio_queue_pop(struct rt_prio_queue *que,
void *data,
rt_int32_t timeout)
{
rt_ubase_t level;
rt_base_t level;
struct rt_prio_queue_item *item;
RT_ASSERT(que);
+14 -14
View File
@@ -222,7 +222,7 @@ static void _bus_out_entry(void *param)
/* wait for enough space */
while (sp < dnr)
{
rt_ubase_t lvl = rt_hw_interrupt_disable();
rt_base_t level = rt_hw_interrupt_disable();
RT_VBUS_OUT_RING->blocked = 1;
rt_vbus_smp_wmb();
@@ -235,7 +235,7 @@ static void _bus_out_entry(void *param)
RT_VBUS_OUT_RING->blocked = 0;
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
sp = _bus_ring_space_nr(RT_VBUS_OUT_RING);
}
@@ -474,11 +474,11 @@ rt_err_t rt_vbus_listen_on(rt_uint8_t chnr,
void rt_vbus_data_push(unsigned int id, struct rt_vbus_data *act)
{
rt_ubase_t lvl;
rt_base_t level;
RT_ASSERT(0 < id && id < RT_VBUS_CHANNEL_NR);
lvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
if (_bus_in_action[id][_IN_ACT_HEAD] == RT_NULL)
{
@@ -495,7 +495,7 @@ void rt_vbus_data_push(unsigned int id, struct rt_vbus_data *act)
_bus_in_action_nr[id]++;
#endif
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
#ifdef RT_VBUS_USING_FLOW_CONTROL
_chn_recv_wm[id].level++;
@@ -519,11 +519,11 @@ void rt_vbus_data_push(unsigned int id, struct rt_vbus_data *act)
struct rt_vbus_data* rt_vbus_data_pop(unsigned int id)
{
struct rt_vbus_data *act;
rt_ubase_t lvl;
rt_base_t level;
RT_ASSERT(0 < id && id < RT_VBUS_CHANNEL_NR);
lvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
act = _bus_in_action[id][_IN_ACT_HEAD];
if (act)
@@ -531,7 +531,7 @@ struct rt_vbus_data* rt_vbus_data_pop(unsigned int id)
_bus_in_action[id][_IN_ACT_HEAD] = act->next;
}
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
#ifdef RT_VBUS_USING_FLOW_CONTROL
if (_chn_recv_wm[id].level != 0)
@@ -901,9 +901,9 @@ int rt_vbus_request_chn(struct rt_vbus_request *req,
int i, chnr, err;
size_t plen = rt_strlen(req->name) + 2;
unsigned char *pbuf;
rt_ubase_t lvl;
rt_base_t level;
lvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
for (i = 0; i < ARRAY_SIZE(_sess); i++)
{
if (_sess[i].st == SESSIOM_AVAILABLE)
@@ -911,7 +911,7 @@ int rt_vbus_request_chn(struct rt_vbus_request *req,
}
if (i == ARRAY_SIZE(_sess))
{
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
return -RT_ERROR;
}
@@ -921,7 +921,7 @@ int rt_vbus_request_chn(struct rt_vbus_request *req,
if (req->is_server)
{
_sess[i].st = SESSIOM_LISTENING;
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
vbus_debug("request listening %s on %d\n", req->name, i);
@@ -933,12 +933,12 @@ int rt_vbus_request_chn(struct rt_vbus_request *req,
pbuf = rt_malloc(plen);
if (!pbuf)
{
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
return -RT_ENOMEM;
}
_sess[i].st = SESSIOM_ESTABLISHING;
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
pbuf[0] = RT_VBUS_CHN0_CMD_ENABLE;
rt_memcpy(pbuf+1, req->name, plen-1);
+9 -9
View File
@@ -41,7 +41,7 @@ void rt_wm_que_dump(struct rt_watermark_queue *wg);
rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
int timeout)
{
rt_base_t ilvl;
rt_base_t level;
/* Assert as early as possible. */
if (timeout != 0)
@@ -49,7 +49,7 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
RT_DEBUG_IN_THREAD_CONTEXT;
}
ilvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
while (wg->level > wg->high_mark)
{
@@ -57,7 +57,7 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
if (timeout == 0)
{
rt_hw_interrupt_enable(ilvl);
rt_hw_interrupt_enable(level);
return -RT_EFULL;
}
@@ -72,12 +72,12 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
&timeout);
rt_timer_start(&(thread->thread_timer));
}
rt_hw_interrupt_enable(ilvl);
rt_hw_interrupt_enable(level);
rt_schedule();
if (thread->error != RT_EOK)
return thread->error;
ilvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
}
wg->level++;
@@ -87,7 +87,7 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
wg->level = ~0;
}
rt_hw_interrupt_enable(ilvl);
rt_hw_interrupt_enable(level);
return RT_EOK;
}
@@ -101,12 +101,12 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
rt_inline void rt_wm_que_dec(struct rt_watermark_queue *wg)
{
int need_sched = 0;
rt_base_t ilvl;
rt_base_t level;
if (wg->level == 0)
return;
ilvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
wg->level--;
if (wg->level == wg->low_mark)
{
@@ -123,7 +123,7 @@ rt_inline void rt_wm_que_dec(struct rt_watermark_queue *wg)
need_sched = 1;
}
}
rt_hw_interrupt_enable(ilvl);
rt_hw_interrupt_enable(level);
if (need_sched)
rt_schedule();