diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2017-07-11 13:20:18 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-07-18 17:58:56 +0200 |
commit | 688318c35af41e0638e5773140284836bcf0c9f3 (patch) | |
tree | c658af156b6b623d6203d53d5b7f1b0de43714cd /drivers/media/cec | |
parent | media: cec-core.rst: include cec-pin.h and cec-notifier.h (diff) | |
download | linux-688318c35af41e0638e5773140284836bcf0c9f3.tar.xz linux-688318c35af41e0638e5773140284836bcf0c9f3.zip |
media: cec: be smarter about detecting the number of attempts made
Some hardware does more than one attempt. So when it calls
cec_transmit_done when an error occurred it will e.g. use an error count
of 2 instead of 1.
The framework always assumed a single attempt, but now it is smarter
and will sum the counters to detect how many attempts were made.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/cec')
-rw-r--r-- | drivers/media/cec/cec-adap.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index b0bd466f75e2..1a021828c8d4 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -517,8 +517,13 @@ void cec_transmit_done_ts(struct cec_adapter *adap, u8 status, { struct cec_data *data; struct cec_msg *msg; + unsigned int attempts_made = arb_lost_cnt + nack_cnt + + low_drive_cnt + error_cnt; dprintk(2, "%s: status %02x\n", __func__, status); + if (attempts_made < 1) + attempts_made = 1; + mutex_lock(&adap->lock); data = adap->transmitting; if (!data) { @@ -551,10 +556,10 @@ void cec_transmit_done_ts(struct cec_adapter *adap, u8 status, * the hardware didn't signal that it retried itself (by setting * CEC_TX_STATUS_MAX_RETRIES), then we will retry ourselves. */ - if (data->attempts > 1 && + if (data->attempts > attempts_made && !(status & (CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_OK))) { /* Retry this message */ - data->attempts--; + data->attempts -= attempts_made; if (msg->timeout) dprintk(2, "retransmit: %*ph (attempts: %d, wait for 0x%02x)\n", msg->len, msg->msg, data->attempts, msg->reply); |