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

Function rt_pipe_delete

components/drivers/ipc/pipe.c:684–724  ·  view source on GitHub ↗

* @brief This function will delete a pipe device. * The system will release the pipe handle and unregister the pipe device from the system. * * @param pipe is the pointer to the pipe device. * * @return Return the operation status. * When the return value is 0, it means the operation is successful. * When the return value is -RT_EINVAL, it means the pip

Source from the content-addressed store, hash-verified

682 * When the return value is -RT_EBUSY, it means the pipe device is busy.
683 */
684int rt_pipe_delete(const char *name)
685{
686 int result = 0;
687 rt_device_t device;
688
689 device = rt_device_find(name);
690 if (device)
691 {
692 if (device->type == RT_Device_Class_Pipe)
693 {
694 rt_pipe_t *pipe;
695
696 pipe = (rt_pipe_t *)device;
697
698 rt_condvar_detach(&pipe->waitfor_parter);
699 rt_mutex_detach(&pipe->lock);
700#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE)
701 resource_id_put(&id_mgr, pipe->pipeno);
702#endif
703 rt_device_unregister(device);
704
705 /* close fifo ringbuffer */
706 if (pipe->fifo)
707 {
708 rt_ringbuffer_destroy(pipe->fifo);
709 pipe->fifo = RT_NULL;
710 }
711 rt_free(pipe);
712 }
713 else
714 {
715 result = -ENODEV;
716 }
717 }
718 else
719 {
720 result = -ENODEV;
721 }
722
723 return result;
724}
725
726#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE)
727/**

Callers 2

pipe_fops_closeFunction · 0.85
pipeFunction · 0.85

Calls 7

rt_device_findFunction · 0.85
rt_condvar_detachFunction · 0.85
rt_mutex_detachFunction · 0.85
resource_id_putFunction · 0.85
rt_device_unregisterFunction · 0.85
rt_ringbuffer_destroyFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected