Add support for polling the status of the write buffer so that user space can use rpmsg character devices in non-blocking mode.
Unified · Split
| @@ -919,6 +919,21 @@ static int qcom_smd_trysend(struct rpmsg_endpoint *ept, void *data, int len) · 918 unmodified lines | ||
| 919 | 919 | return __qcom_smd_send(qsept->qsch, data, len, false); |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | +static unsigned int qcom_smd_poll(struct rpmsg_endpoint *ept, | |
| 923 | + struct file *filp, poll_table *wait) | |
| 924 | +{ | |
| 925 | + struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); | |
| 926 | + struct qcom_smd_channel *channel = qsept->qsch; | |
| 927 | + unsigned int mask = 0; | |
| 928 | + | |
| 929 | + poll_wait(filp, &channel->fblockread_event, wait); | |
| 930 | + | |
| 931 | + if (qcom_smd_get_tx_avail(channel) > 20) | |
| 932 | + mask |= POLLOUT | POLLWRNORM; | |
| 933 | + | |
| 934 | + return mask; | |
| 935 | +} | |
| 936 | + | |
| 922 | 937 | /* |
| 923 | 938 | * Finds the device_node for the smd child interested in this channel. |
| 924 | 939 | */ |
| @@ -951,6 +966,7 @@ static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { · 26 unmodified lines | ||
| 951 | 966 | .destroy_ept = qcom_smd_destroy_ept, |
| 952 | 967 | .send = qcom_smd_send, |
| 953 | 968 | .trysend = qcom_smd_trysend, |
| 969 | + .poll = qcom_smd_poll, | |
| 954 | 970 | }; |
| 955 | 971 | |
| 956 | 972 | /* |