summaryrefslogtreecommitdiff
path: root/components/drivers/src
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/src')
-rw-r--r--components/drivers/src/ringbuffer.c4
-rw-r--r--components/drivers/src/workqueue.c6
2 files changed, 6 insertions, 4 deletions
diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c
index 29de20b087..f01a594609 100644
--- a/components/drivers/src/ringbuffer.c
+++ b/components/drivers/src/ringbuffer.c
@@ -8,6 +8,7 @@
* 2012-09-30 Bernard first version.
* 2013-05-08 Grissiom reimplement
* 2016-08-18 heyuanjie add interface
+ * 2021-07-20 arminker fix write_index bug in function rt_ringbuffer_put_force
*/
#include <rtthread.h>
@@ -138,7 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
if (length > space_length)
{
- rb->read_mirror = ~rb->read_mirror;
+ if (rb->write_index <= rb->read_index)
+ rb->read_mirror = ~rb->read_mirror;
rb->read_index = rb->write_index;
}
diff --git a/components/drivers/src/workqueue.c b/components/drivers/src/workqueue.c
index f195dad927..065c505015 100644
--- a/components/drivers/src/workqueue.c
+++ b/components/drivers/src/workqueue.c
@@ -358,7 +358,7 @@ rt_err_t rt_work_cancel(struct rt_work *work)
return rt_workqueue_cancel_work(sys_workq, work);
}
-int rt_work_sys_workqueue_init(void)
+static int rt_work_sys_workqueue_init(void)
{
if (sys_workq != RT_NULL)
return RT_EOK;
@@ -370,5 +370,5 @@ int rt_work_sys_workqueue_init(void)
return RT_EOK;
}
INIT_PREV_EXPORT(rt_work_sys_workqueue_init);
-#endif
-#endif
+#endif /* RT_USING_SYSTEM_WORKQUEUE */
+#endif /* RT_USING_HEAP */