Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2c932e7 authored by Bjorn Andersson's avatar Bjorn Andersson
Browse files

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: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent eb114f27
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -743,17 +743,13 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data,
	if (ret)
	if (ret)
		return ret;
		return ret;


	while (qcom_smd_get_tx_avail(channel) < tlen) {
	while (qcom_smd_get_tx_avail(channel) < tlen &&
	       channel->state == SMD_CHANNEL_OPENED) {
		if (!wait) {
		if (!wait) {
			ret = -EAGAIN;
			ret = -EAGAIN;
			goto out;
			goto out;
		}
		}


		if (channel->state != SMD_CHANNEL_OPENED) {
			ret = -EPIPE;
			goto out;
		}

		SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0);
		SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0);


		ret = wait_event_interruptible(channel->fblockread_event,
		ret = wait_event_interruptible(channel->fblockread_event,
@@ -765,6 +761,12 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data,
		SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1);
		SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1);
	}
	}


	/* Fail if the channel was closed */
	if (channel->state != SMD_CHANNEL_OPENED) {
		ret = -EPIPE;
		goto out;
	}

	SET_TX_CHANNEL_FLAG(channel, fTAIL, 0);
	SET_TX_CHANNEL_FLAG(channel, fTAIL, 0);


	qcom_smd_write_fifo(channel, hdr, sizeof(hdr));
	qcom_smd_write_fifo(channel, hdr, sizeof(hdr));