summaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2014-07-19 06:46:39 +0800
committerBernard Xiong <[email protected]>2014-07-19 06:46:39 +0800
commit350b1080eafb565875f82bfe5da9173fa7f0f149 (patch)
treea044f04e1d200c2421a74e840ab6da143c431b55 /src/device.c
parent61712bbd13b7c820307f0570d49f1bc0fc6b857a (diff)
parent50e7ae7e875c28cdc65baf9c0ec7893a59211a23 (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/device.c')
-rw-r--r--src/device.c12
1 files changed, 7 insertions, 5 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);