mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 18:57:16 +08:00
cleanup kernel code
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1715 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
+19
-20
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : device.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* @return the error code, RT_EOK on initialization successfully.
|
||||
*/
|
||||
rt_err_t rt_device_register(rt_device_t dev, const char* name, rt_uint16_t flags)
|
||||
rt_err_t rt_device_register(rt_device_t dev, const char *name, rt_uint16_t flags)
|
||||
{
|
||||
if (dev == RT_NULL) return -RT_ERROR;
|
||||
|
||||
@@ -58,10 +58,10 @@ rt_err_t rt_device_unregister(rt_device_t dev)
|
||||
*
|
||||
* @return the error code, RT_EOK on successfully.
|
||||
*/
|
||||
rt_err_t rt_device_init_all()
|
||||
rt_err_t rt_device_init_all(void)
|
||||
{
|
||||
struct rt_device* device;
|
||||
struct rt_list_node* node;
|
||||
struct rt_device *device;
|
||||
struct rt_list_node *node;
|
||||
struct rt_object_information *information;
|
||||
register rt_err_t result;
|
||||
|
||||
@@ -73,7 +73,7 @@ rt_err_t rt_device_init_all()
|
||||
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);
|
||||
device = (struct rt_device *)rt_list_entry(node, struct rt_object, list);
|
||||
|
||||
/* get device init handler */
|
||||
init = device->init;
|
||||
@@ -102,10 +102,10 @@ rt_err_t rt_device_init_all()
|
||||
*
|
||||
* @return the registered device driver on successful, or RT_NULL on failure.
|
||||
*/
|
||||
rt_device_t rt_device_find(const char* name)
|
||||
rt_device_t rt_device_find(const char *name)
|
||||
{
|
||||
struct rt_object* object;
|
||||
struct rt_list_node* node;
|
||||
struct rt_object *object;
|
||||
struct rt_list_node *node;
|
||||
struct rt_object_information *information;
|
||||
|
||||
extern struct rt_object_information rt_object_container[];
|
||||
@@ -167,7 +167,7 @@ rt_err_t rt_device_init(rt_device_t dev)
|
||||
}
|
||||
}
|
||||
else result = -RT_ENOSYS;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ rt_err_t rt_device_init(rt_device_t dev)
|
||||
rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
rt_err_t result;
|
||||
rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag);
|
||||
rt_err_t (*open)(rt_device_t dev, rt_uint16_t oflag);
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
@@ -205,8 +205,7 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
/* call device open interface */
|
||||
@@ -273,9 +272,9 @@ rt_err_t rt_device_close(rt_device_t dev)
|
||||
*
|
||||
* @note since 0.4.0, the unit of size/pos is a block for block device.
|
||||
*/
|
||||
rt_size_t rt_device_read (rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
|
||||
rt_size_t rt_device_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_size_t (*read)(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size);
|
||||
rt_size_t (*read)(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
@@ -303,9 +302,9 @@ rt_size_t rt_device_read (rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t
|
||||
*
|
||||
* @note since 0.4.0, the unit of size/pos is a block for block device.
|
||||
*/
|
||||
rt_size_t rt_device_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
|
||||
rt_size_t rt_device_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_size_t (*write)(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size);
|
||||
rt_size_t (*write)(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
@@ -330,9 +329,9 @@ rt_size_t rt_device_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void* arg)
|
||||
rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void *arg)
|
||||
{
|
||||
rt_err_t (*control)(rt_device_t dev, rt_uint8_t cmd, void* arg);
|
||||
rt_err_t (*control)(rt_device_t dev, rt_uint8_t cmd, void *arg);
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
@@ -355,7 +354,7 @@ rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void* arg)
|
||||
*
|
||||
* @return RT_EOK
|
||||
*/
|
||||
rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind )(rt_device_t dev, rt_size_t size))
|
||||
rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size))
|
||||
{
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user