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

Function rt_device_close

components/drivers/core/device.c:292–319  ·  view source on GitHub ↗

* @brief This function will close a device. * * @param dev is the pointer of device driver structure. * * @return the result, RT_EOK on successfully. */

Source from the content-addressed store, hash-verified

290 * @return the result, RT_EOK on successfully.
291 */
292rt_err_t rt_device_close(rt_device_t dev)
293{
294 rt_err_t result = RT_EOK;
295
296 /* parameter check */
297 RT_ASSERT(dev != RT_NULL);
298 RT_ASSERT(rt_object_get_type(&dev->parent) == RT_Object_Class_Device);
299
300 if (dev->ref_count == 0)
301 return -RT_ERROR;
302
303 dev->ref_count--;
304
305 if (dev->ref_count != 0)
306 return RT_EOK;
307
308 /* call device_close interface */
309 if (device_close != RT_NULL)
310 {
311 result = device_close(dev);
312 }
313
314 /* set open flag */
315 if (result == RT_EOK || result == -RT_ENOSYS)
316 dev->open_flag = RT_DEVICE_OFLAG_CLOSE;
317
318 return result;
319}
320RTM_EXPORT(rt_device_close);
321
322/**

Callers 15

finsh_set_deviceFunction · 0.85
_function_disableFunction · 0.85
speaker_entryFunction · 0.85
mic_entryFunction · 0.85
sys_device_closeFunction · 0.85
sys_getrandomFunction · 0.85
serial_fops_closeFunction · 0.85
serial_fops_openFunction · 0.85
serial_fops_closeFunction · 0.85
serial_tty_closeFunction · 0.85
block_readFunction · 0.85
utest_tc_cleanupFunction · 0.85

Calls 1

rt_object_get_typeFunction · 0.85

Tested by 15

showcolorFunction · 0.68
uart_tx_demoFunction · 0.68
uart_rx_demoFunction · 0.68
test_ts_readFunction · 0.68
test_ts_controlFunction · 0.68
test_rtc_setFunction · 0.68
test_rtc_alarmFunction · 0.68
test_rtc_interfaceFunction · 0.68
test_hwtimerFunction · 0.68
test_wdt_feedFunction · 0.68
encoder_sampleFunction · 0.68
_ic_test_closeFunction · 0.68