All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cec: clear fields before transmit and set sequence only if timeout !=0
@ 2016-07-16 10:27 Hans Verkuil
  0 siblings, 0 replies; only message in thread
From: Hans Verkuil @ 2016-07-16 10:27 UTC (permalink / raw)
  To: Linux Media Mailing List

Clear all status-related fields before transmitting the message.

Also set the sequence counter only for messages with a non-zero timeout (== they wait for
a reply) and make sure the sequence counter is never 0.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/staging/media/cec/cec-adap.c
index 4d86a6c..fc752de 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -574,6 +574,17 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
 	unsigned int timeout;
 	int res = 0;

+	msg->rx_ts = 0;
+	msg->tx_ts = 0;
+	msg->rx_status = 0;
+	msg->tx_status = 0;
+	msg->tx_arb_lost_cnt = 0;
+	msg->tx_nack_cnt = 0;
+	msg->tx_low_drive_cnt = 0;
+	msg->tx_error_cnt = 0;
+	msg->sequence = 0;
+	msg->flags = 0;
+
 	if (msg->reply && msg->timeout == 0) {
 		/* Make sure the timeout isn't 0. */
 		msg->timeout = 1000;
@@ -640,14 +651,12 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
 		dprintk(2, "cec_transmit_msg: %*ph%s\n",
 			msg->len, msg->msg, !block ? " (nb)" : "");

-	msg->rx_ts = 0;
-	msg->tx_ts = 0;
-	msg->rx_status = 0;
-	msg->tx_status = 0;
-	msg->tx_arb_lost_cnt = 0;
-	msg->tx_nack_cnt = 0;
-	msg->tx_low_drive_cnt = 0;
-	msg->tx_error_cnt = 0;
+	if (msg->timeout) {
+		msg->sequence = ++adap->sequence;
+		if (!msg->sequence)
+			msg->sequence = ++adap->sequence;
+	}
+
 	data->msg = *msg;
 	data->fh = fh;
 	data->adap = adap;
@@ -673,7 +682,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
 	init_completion(&data->c);
 	INIT_DELAYED_WORK(&data->work, cec_wait_timeout);

-	data->msg.sequence = adap->sequence++;
 	if (fh)
 		list_add_tail(&data->xfer_list, &fh->xfer_list);
 	list_add_tail(&data->list, &adap->transmit_queue);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-16 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16 10:27 [PATCH] cec: clear fields before transmit and set sequence only if timeout !=0 Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.