Skip to content

Commit

Permalink
rpmsg: qcom_smd: Implement endpoint "poll"
Browse files Browse the repository at this point in the history
Add support for polling the status of the write buffer so that user
space can use rpmsg character devices in non-blocking mode.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
andersson committed Jan 18, 2017
1 parent 84d5813 commit adaa11b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/rpmsg/qcom_smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,21 @@ static int qcom_smd_trysend(struct rpmsg_endpoint *ept, void *data, int len)
return __qcom_smd_send(qsept->qsch, data, len, false);
}

static unsigned int qcom_smd_poll(struct rpmsg_endpoint *ept,
struct file *filp, poll_table *wait)
{
struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept);
struct qcom_smd_channel *channel = qsept->qsch;
unsigned int mask = 0;

poll_wait(filp, &channel->fblockread_event, wait);

if (qcom_smd_get_tx_avail(channel) > 20)
mask |= POLLOUT | POLLWRNORM;

return mask;
}

/*
* Finds the device_node for the smd child interested in this channel.
*/
Expand Down Expand Up @@ -951,6 +966,7 @@ static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = {
.destroy_ept = qcom_smd_destroy_ept,
.send = qcom_smd_send,
.trysend = qcom_smd_trysend,
.poll = qcom_smd_poll,
};

/*
Expand Down

0 comments on commit adaa11b

Please sign in to comment.