@@ -94,7 +94,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
9494 struct rt_work * work , rt_tick_t ticks )
9595{
9696 rt_base_t level ;
97- rt_err_t err ;
97+ rt_err_t err = RT_EOK ;
9898
9999 level = rt_spin_lock_irqsave (& (queue -> spinlock ));
100100
@@ -113,13 +113,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
113113 {
114114 /* resume work thread, and do a re-schedule if succeed */
115115 rt_thread_resume (queue -> work_thread );
116- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
117116 }
118- else
119- {
120- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
121- }
122- return RT_EOK ;
123117 }
124118 else if (ticks < RT_TICK_MAX / 2 )
125119 {
@@ -139,12 +133,14 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
139133 rt_list_insert_after (queue -> delayed_list .prev , & (work -> list ));
140134
141135 err = rt_timer_start (& (work -> timer ));
142- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
143-
144- return err ;
145136 }
137+ else
138+ {
139+ err = - RT_ERROR ;
140+ }
141+
146142 rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
147- return - RT_ERROR ;
143+ return err ;
148144}
149145
150146static rt_err_t _workqueue_cancel_work (struct rt_workqueue * queue , struct rt_work * work )
@@ -160,14 +156,14 @@ static rt_err_t _workqueue_cancel_work(struct rt_workqueue *queue, struct rt_wor
160156 {
161157 if ((err = rt_timer_stop (& (work -> timer ))) != RT_EOK )
162158 {
163- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
164- return err ;
159+ goto exit ;
165160 }
166161 rt_timer_detach (& (work -> timer ));
167162 work -> flags &= ~RT_WORK_STATE_SUBMITTING ;
168163 }
169164 err = queue -> work_current != work ? RT_EOK : - RT_EBUSY ;
170165 work -> workqueue = RT_NULL ;
166+ exit :
171167 rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
172168 return err ;
173169}
@@ -200,12 +196,9 @@ static void _delayed_work_timeout_handler(void *parameter)
200196 {
201197 /* resume work thread, and do a re-schedule if succeed */
202198 rt_thread_resume (queue -> work_thread );
203- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
204- }
205- else
206- {
207- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
208199 }
200+
201+ rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
209202}
210203
211204/**
@@ -358,13 +351,9 @@ rt_err_t rt_workqueue_urgent_work(struct rt_workqueue *queue, struct rt_work *wo
358351 {
359352 /* resume work thread, and do a re-schedule if succeed */
360353 rt_thread_resume (queue -> work_thread );
361- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
362- }
363- else
364- {
365- rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
366354 }
367355
356+ rt_spin_unlock_irqrestore (& (queue -> spinlock ), level );
368357 return RT_EOK ;
369358}
370359
0 commit comments