fixed the coding style in device.c
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2502 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
a810c1ae73
commit
7e159dfb76
19
src/device.c
19
src/device.c
|
@ -79,10 +79,14 @@ rt_err_t rt_device_init_all(void)
|
||||||
information = &rt_object_container[RT_Object_Class_Device];
|
information = &rt_object_container[RT_Object_Class_Device];
|
||||||
|
|
||||||
/* for each device */
|
/* for each device */
|
||||||
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
|
for (node = information->object_list.next;
|
||||||
|
node != &(information->object_list);
|
||||||
|
node = node->next)
|
||||||
{
|
{
|
||||||
rt_err_t (*init)(rt_device_t dev);
|
rt_err_t (*init)(rt_device_t dev);
|
||||||
device = (struct rt_device *)rt_list_entry(node, struct rt_object, list);
|
device = (struct rt_device *)rt_list_entry(node,
|
||||||
|
struct rt_object,
|
||||||
|
list);
|
||||||
|
|
||||||
/* get device init handler */
|
/* get device init handler */
|
||||||
init = device->init;
|
init = device->init;
|
||||||
|
@ -125,7 +129,9 @@ rt_device_t rt_device_find(const char *name)
|
||||||
|
|
||||||
/* try to find device object */
|
/* try to find device object */
|
||||||
information = &rt_object_container[RT_Object_Class_Device];
|
information = &rt_object_container[RT_Object_Class_Device];
|
||||||
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
|
for (node = information->object_list.next;
|
||||||
|
node != &(information->object_list);
|
||||||
|
node = node->next)
|
||||||
{
|
{
|
||||||
object = rt_list_entry(node, struct rt_object, list);
|
object = rt_list_entry(node, struct rt_object, list);
|
||||||
if (rt_strncmp(object->name, name, RT_NAME_MAX) == 0)
|
if (rt_strncmp(object->name, name, RT_NAME_MAX) == 0)
|
||||||
|
@ -158,7 +164,7 @@ rt_err_t rt_device_init(rt_device_t dev)
|
||||||
{
|
{
|
||||||
rt_err_t result = RT_EOK;
|
rt_err_t result = RT_EOK;
|
||||||
rt_err_t (*init)(rt_device_t dev);
|
rt_err_t (*init)(rt_device_t dev);
|
||||||
|
|
||||||
RT_ASSERT(dev != RT_NULL);
|
RT_ASSERT(dev != RT_NULL);
|
||||||
|
|
||||||
/* get device init handler */
|
/* get device init handler */
|
||||||
|
@ -221,8 +227,11 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* device is a stand alone device and opened */
|
/* device is a stand alone device and opened */
|
||||||
if ((dev->flag & RT_DEVICE_FLAG_STANDALONE) && (dev->open_flag & RT_DEVICE_OFLAG_OPEN))
|
if ((dev->flag & RT_DEVICE_FLAG_STANDALONE) &&
|
||||||
|
(dev->open_flag & RT_DEVICE_OFLAG_OPEN))
|
||||||
|
{
|
||||||
return -RT_EBUSY;
|
return -RT_EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
/* call device open interface */
|
/* call device open interface */
|
||||||
open = dev->open;
|
open = dev->open;
|
||||||
|
|
Loading…
Reference in New Issue