* @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
| 682 | * When the return value is -RT_EBUSY, it means the pipe device is busy. |
| 683 | */ |
| 684 | int 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 | /** |
no test coverage detected