MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_device_register

Function rt_device_register

components/drivers/core/device.c:67–92  ·  view source on GitHub ↗

* @brief This function registers a device driver with a specified name. * * @param dev is the pointer of device driver structure. * * @param name is the device driver's name. * * @param flags is the capabilities flag of device. * * @return the error code, RT_EOK on initialization successfully. */

Source from the content-addressed store, hash-verified

65 * @return the error code, RT_EOK on initialization successfully.
66 */
67rt_err_t rt_device_register(rt_device_t dev,
68 const char *name,
69 rt_uint16_t flags)
70{
71 if (dev == RT_NULL)
72 return -RT_ERROR;
73
74 if (rt_device_find(name) != RT_NULL)
75 return -RT_ERROR;
76
77 rt_object_init(&(dev->parent), RT_Object_Class_Device, name);
78 dev->flag = flags;
79 dev->ref_count = 0;
80 dev->open_flag = 0;
81
82#ifdef RT_USING_POSIX_DEVIO
83 dev->fops = RT_NULL;
84 rt_wqueue_init(&(dev->wait_queue));
85#endif /* RT_USING_POSIX_DEVIO */
86
87#if defined (RT_USING_DFS_V2) && defined (RT_USING_DFS_DEVFS)
88 dfs_devfs_device_add(dev);
89#endif /* RT_USING_DFS_V2 */
90
91 return RT_EOK;
92}
93RTM_EXPORT(rt_device_register);
94
95/**

Callers 15

fal_blk_device_createFunction · 0.85
fal_char_device_createFunction · 0.85
rt_usb_winusb_initFunction · 0.85
rt_usb_hid_initFunction · 0.85
rt_udisk_runFunction · 0.85
rt_usbh_adk_enableFunction · 0.85
sys_device_registerFunction · 0.85
lwp_ptmx_initFunction · 0.85
_sys_ptmx_initFunction · 0.85
lwp_ctty_registerFunction · 0.85
_cons_initFunction · 0.85
lwp_tty_registerFunction · 0.85

Calls 4

rt_device_findFunction · 0.85
rt_object_initFunction · 0.85
rt_wqueue_initFunction · 0.85
dfs_devfs_device_addFunction · 0.85

Tested by 1