diff options
| author | Bernard Xiong <[email protected]> | 2014-07-19 06:46:39 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2014-07-19 06:46:39 +0800 |
| commit | 350b1080eafb565875f82bfe5da9173fa7f0f149 (patch) | |
| tree | a044f04e1d200c2421a74e840ab6da143c431b55 /src | |
| parent | 61712bbd13b7c820307f0570d49f1bc0fc6b857a (diff) | |
| parent | 50e7ae7e875c28cdc65baf9c0ec7893a59211a23 (diff) | |
Merge pull request #303 from BernardXiong/stable-v1.2.xv1.2.2
Merge 2.0.0 modification to prepare v1.2.2 release.
Diffstat (limited to 'src')
| -rw-r--r-- | src/device.c | 12 | ||||
| -rw-r--r-- | src/timer.c | 12 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/device.c b/src/device.c index 75b88bf6eb..7ee130041c 100644 --- a/src/device.c +++ b/src/device.c @@ -239,11 +239,6 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag) return -RT_EBUSY; } - dev->ref_count++; - /* don't let bad things happen silently. If you are bitten by this assert, - * please set the ref_count to a bigger type. */ - RT_ASSERT(dev->ref_count != 0); - /* call device open interface */ if (dev->open != RT_NULL) { @@ -252,8 +247,15 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag) /* set open flag */ if (result == RT_EOK || result == -RT_ENOSYS) + { dev->open_flag = oflag | RT_DEVICE_OFLAG_OPEN; + dev->ref_count++; + /* don't let bad things happen silently. If you are bitten by this assert, + * please set the ref_count to a bigger type. */ + RT_ASSERT(dev->ref_count != 0); + } + return result; } RTM_EXPORT(rt_device_open); diff --git a/src/timer.c b/src/timer.c index ac8a148d8d..53cb186243 100644 --- a/src/timer.c +++ b/src/timer.c @@ -128,6 +128,7 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) } } +#if RT_DEBUG_TIMER static int rt_timer_count_height(struct rt_timer *timer) { int i, cnt = 0; @@ -155,6 +156,7 @@ void rt_timer_dump(rt_list_t timer_heads[]) } rt_kprintf("\n"); } +#endif /** * @addtogroup Clock @@ -298,8 +300,14 @@ rt_err_t rt_timer_start(rt_timer_t timer) /* timer check */ RT_ASSERT(timer != RT_NULL); - if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED) - return -RT_ERROR; + + /* stop timer firstly */ + level = rt_hw_interrupt_disable(); + /* remove timer from list */ + _rt_timer_remove(timer); + /* change status of timer */ + timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; + rt_hw_interrupt_enable(level); RT_OBJECT_HOOK_CALL(rt_object_take_hook, (&(timer->parent))); |
