From dc366ecf7a2946c8f071735f5f2065d51000240a Mon Sep 17 00:00:00 2001 From: Grissiom Date: Wed, 18 Jun 2014 11:16:21 +0800 Subject: device: only increase the ref_count when device is truly opened --- src/device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/device.c') 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); -- cgit v1.3.1 From 1e7b0894949be4fe86c31ddf3c1bd754908459aa Mon Sep 17 00:00:00 2001 From: bernard Date: Thu, 10 Jul 2014 13:34:52 +0800 Subject: [Kernel] Remove rt_device_init_all implemetation. --- src/device.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) (limited to 'src/device.c') diff --git a/src/device.c b/src/device.c index 7ee130041c..2bb3cc0f9c 100644 --- a/src/device.c +++ b/src/device.c @@ -79,45 +79,12 @@ RTM_EXPORT(rt_device_unregister); * This function initializes all registered device driver * * @return the error code, RT_EOK on successfully. + * + * @deprecated This function is not needed because the initialization + * of a device is performed when applicaiton opens it. */ rt_err_t rt_device_init_all(void) { - struct rt_device *device; - struct rt_list_node *node; - struct rt_object_information *information; - register rt_err_t result; - - extern struct rt_object_information rt_object_container[]; - - information = &rt_object_container[RT_Object_Class_Device]; - - /* for each device */ - for (node = information->object_list.next; - node != &(information->object_list); - node = node->next) - { - rt_err_t (*init)(rt_device_t dev); - device = (struct rt_device *)rt_list_entry(node, - struct rt_object, - list); - - /* get device init handler */ - init = device->init; - if (init != RT_NULL && !(device->flag & RT_DEVICE_FLAG_ACTIVATED)) - { - result = init(device); - if (result != RT_EOK) - { - rt_kprintf("To initialize device:%s failed. The error code is %d\n", - device->parent.name, result); - } - else - { - device->flag |= RT_DEVICE_FLAG_ACTIVATED; - } - } - } - return RT_EOK; } -- cgit v1.3.1 From 33fed1b167e1b2a653d9e58853537e40628f4e2e Mon Sep 17 00:00:00 2001 From: bernard Date: Mon, 21 Jul 2014 06:29:15 +0800 Subject: [Kernel] Better documentation for doxygen. --- src/device.c | 2 +- src/module.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/device.c') diff --git a/src/device.c b/src/device.c index 2bb3cc0f9c..835a517ce3 100644 --- a/src/device.c +++ b/src/device.c @@ -80,7 +80,7 @@ RTM_EXPORT(rt_device_unregister); * * @return the error code, RT_EOK on successfully. * - * @deprecated This function is not needed because the initialization + * @deprecated since 1.2.x, this function is not needed because the initialization * of a device is performed when applicaiton opens it. */ rt_err_t rt_device_init_all(void) diff --git a/src/module.c b/src/module.c index 0603159b91..5d5d02c580 100644 --- a/src/module.c +++ b/src/module.c @@ -1120,8 +1120,8 @@ rt_module_t rt_module_open(const char *path) * This function will do a excutable program with main function and parameters. * * @param path the full path of application module - * @cmd_line the command line of program - * @size the size of command line of program + * @param cmd_line the command line of program + * @param size the size of command line of program * * @return the module object */ -- cgit v1.3.1