| 798 | ****************************************************************************/ |
| 799 | |
| 800 | static int rpmsgdev_send_recv(FAR struct rpmsgdev_s *priv, |
| 801 | uint32_t command, bool copy, |
| 802 | FAR struct rpmsgdev_header_s *msg, |
| 803 | int len, FAR void *data) |
| 804 | { |
| 805 | struct rpmsgdev_cookie_s cookie; |
| 806 | int ret; |
| 807 | |
| 808 | memset(&cookie, 0, sizeof(cookie)); |
| 809 | nxsem_init(&cookie.sem, 0, 0); |
| 810 | |
| 811 | if (data != NULL) |
| 812 | { |
| 813 | cookie.data = data; |
| 814 | } |
| 815 | else if (copy) |
| 816 | { |
| 817 | cookie.data = msg; |
| 818 | } |
| 819 | |
| 820 | msg->command = command; |
| 821 | msg->result = -ENXIO; |
| 822 | msg->cookie = (uintptr_t)&cookie; |
| 823 | |
| 824 | if (copy) |
| 825 | { |
| 826 | ret = rpmsg_send(&priv->ept, msg, len); |
| 827 | } |
| 828 | else |
| 829 | { |
| 830 | ret = rpmsg_send_nocopy(&priv->ept, msg, len); |
| 831 | } |
| 832 | |
| 833 | if (ret < 0) |
| 834 | { |
| 835 | if (copy == false) |
| 836 | { |
| 837 | rpmsg_release_tx_buffer(&priv->ept, msg); |
| 838 | } |
| 839 | |
| 840 | goto fail; |
| 841 | } |
| 842 | |
| 843 | ret = rpmsg_wait(&priv->ept, &cookie.sem); |
| 844 | if (ret >= 0) |
| 845 | { |
| 846 | ret = cookie.result; |
| 847 | } |
| 848 | |
| 849 | fail: |
| 850 | nxsem_destroy(&cookie.sem); |
| 851 | return ret; |
| 852 | } |
| 853 | |
| 854 | /**************************************************************************** |
| 855 | * Name: rpmsgdev_default_handler |
no test coverage detected