diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-12-12 18:58:56 -0500 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-12-19 00:50:09 -0500 |
commit | b2c932e7991ca7e3995457463b72fc34e64477a0 (patch) | |
tree | f0fe8507eb25b58de6fd8a5f3505ccb19ab61182 | |
parent | eb114f27fd3a6fd5005e07818043993bda67d8d1 (diff) |
rpmsg: smd: Fail send on a closed channel
Move the check for a closed channel out from the tx-full loop to fail
any send request on a non-open channel.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/rpmsg/qcom_smd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 0993e95bf0f5..ed167ab52a68 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c | |||
@@ -743,17 +743,13 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data, | |||
743 | if (ret) | 743 | if (ret) |
744 | return ret; | 744 | return ret; |
745 | 745 | ||
746 | while (qcom_smd_get_tx_avail(channel) < tlen) { | 746 | while (qcom_smd_get_tx_avail(channel) < tlen && |
747 | channel->state == SMD_CHANNEL_OPENED) { | ||
747 | if (!wait) { | 748 | if (!wait) { |
748 | ret = -EAGAIN; | 749 | ret = -EAGAIN; |
749 | goto out; | 750 | goto out; |
750 | } | 751 | } |
751 | 752 | ||
752 | if (channel->state != SMD_CHANNEL_OPENED) { | ||
753 | ret = -EPIPE; | ||
754 | goto out; | ||
755 | } | ||
756 | |||
757 | SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0); | 753 | SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0); |
758 | 754 | ||
759 | ret = wait_event_interruptible(channel->fblockread_event, | 755 | ret = wait_event_interruptible(channel->fblockread_event, |
@@ -765,6 +761,12 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data, | |||
765 | SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1); | 761 | SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1); |
766 | } | 762 | } |
767 | 763 | ||
764 | /* Fail if the channel was closed */ | ||
765 | if (channel->state != SMD_CHANNEL_OPENED) { | ||
766 | ret = -EPIPE; | ||
767 | goto out; | ||
768 | } | ||
769 | |||
768 | SET_TX_CHANNEL_FLAG(channel, fTAIL, 0); | 770 | SET_TX_CHANNEL_FLAG(channel, fTAIL, 0); |
769 | 771 | ||
770 | qcom_smd_write_fifo(channel, hdr, sizeof(hdr)); | 772 | qcom_smd_write_fifo(channel, hdr, sizeof(hdr)); |