diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2017-07-06 16:09:52 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-07-18 17:37:21 +0200 |
commit | 15e809e961bad6c31f995100bf5e3c3f860b1b2c (patch) | |
tree | ad97a2c0c8b4874856aa2ae1ab1085d94f545760 | |
parent | media: cec: clear all cec_log_addrs fields (diff) | |
download | linux-15e809e961bad6c31f995100bf5e3c3f860b1b2c.tar.xz linux-15e809e961bad6c31f995100bf5e3c3f860b1b2c.zip |
media: cec: only increase the seqnr if CEC_TRANSMIT would return 0
The transmit code would increase the sequence number first thing, even though
CEC_TRANSMIT would return an error due to a malformatted cec_msg struct later
on.
While valid behavior, this had the disadvantage of producing holes in the
sequence list that made debugging harder.
Only increase the sequence number when the whole message is validated.
When debugging (i.e. with cec-ctl -M) the sequence numbering is now nicely
increasing by 1 per message.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/cec/cec-adap.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 5a2363cbaeb1..a311c52723a1 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -630,9 +630,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, msg->tx_nack_cnt = 0; msg->tx_low_drive_cnt = 0; msg->tx_error_cnt = 0; - msg->sequence = ++adap->sequence; - if (!msg->sequence) - msg->sequence = ++adap->sequence; + msg->sequence = 0; if (msg->reply && msg->timeout == 0) { /* Make sure the timeout isn't 0. */ @@ -671,6 +669,9 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, msg->tx_status = CEC_TX_STATUS_NACK | CEC_TX_STATUS_MAX_RETRIES; msg->tx_nack_cnt = 1; + msg->sequence = ++adap->sequence; + if (!msg->sequence) + msg->sequence = ++adap->sequence; return 0; } } @@ -705,6 +706,10 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, if (!data) return -ENOMEM; + msg->sequence = ++adap->sequence; + if (!msg->sequence) + msg->sequence = ++adap->sequence; + if (msg->len > 1 && msg->msg[1] == CEC_MSG_CDC_MESSAGE) { msg->msg[2] = adap->phys_addr >> 8; msg->msg[3] = adap->phys_addr & 0xff; |