diff options
Diffstat (limited to 'drivers/media/cec/cec-adap.c')
-rw-r--r-- | drivers/media/cec/cec-adap.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 31d1f4ab915e..65a933a21e68 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c | |||
@@ -807,7 +807,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, | |||
807 | } | 807 | } |
808 | 808 | ||
809 | if (adap->transmit_queue_sz >= CEC_MAX_MSG_TX_QUEUE_SZ) { | 809 | if (adap->transmit_queue_sz >= CEC_MAX_MSG_TX_QUEUE_SZ) { |
810 | dprintk(1, "%s: transmit queue full\n", __func__); | 810 | dprintk(2, "%s: transmit queue full\n", __func__); |
811 | return -EBUSY; | 811 | return -EBUSY; |
812 | } | 812 | } |
813 | 813 | ||
@@ -1180,6 +1180,8 @@ static int cec_config_log_addr(struct cec_adapter *adap, | |||
1180 | { | 1180 | { |
1181 | struct cec_log_addrs *las = &adap->log_addrs; | 1181 | struct cec_log_addrs *las = &adap->log_addrs; |
1182 | struct cec_msg msg = { }; | 1182 | struct cec_msg msg = { }; |
1183 | const unsigned int max_retries = 2; | ||
1184 | unsigned int i; | ||
1183 | int err; | 1185 | int err; |
1184 | 1186 | ||
1185 | if (cec_has_log_addr(adap, log_addr)) | 1187 | if (cec_has_log_addr(adap, log_addr)) |
@@ -1188,19 +1190,44 @@ static int cec_config_log_addr(struct cec_adapter *adap, | |||
1188 | /* Send poll message */ | 1190 | /* Send poll message */ |
1189 | msg.len = 1; | 1191 | msg.len = 1; |
1190 | msg.msg[0] = (log_addr << 4) | log_addr; | 1192 | msg.msg[0] = (log_addr << 4) | log_addr; |
1191 | err = cec_transmit_msg_fh(adap, &msg, NULL, true); | ||
1192 | 1193 | ||
1193 | /* | 1194 | for (i = 0; i < max_retries; i++) { |
1194 | * While trying to poll the physical address was reset | 1195 | err = cec_transmit_msg_fh(adap, &msg, NULL, true); |
1195 | * and the adapter was unconfigured, so bail out. | ||
1196 | */ | ||
1197 | if (!adap->is_configuring) | ||
1198 | return -EINTR; | ||
1199 | 1196 | ||
1200 | if (err) | 1197 | /* |
1201 | return err; | 1198 | * While trying to poll the physical address was reset |
1199 | * and the adapter was unconfigured, so bail out. | ||
1200 | */ | ||
1201 | if (!adap->is_configuring) | ||
1202 | return -EINTR; | ||
1203 | |||
1204 | if (err) | ||
1205 | return err; | ||
1202 | 1206 | ||
1203 | if (msg.tx_status & CEC_TX_STATUS_OK) | 1207 | /* |
1208 | * The message was aborted due to a disconnect or | ||
1209 | * unconfigure, just bail out. | ||
1210 | */ | ||
1211 | if (msg.tx_status & CEC_TX_STATUS_ABORTED) | ||
1212 | return -EINTR; | ||
1213 | if (msg.tx_status & CEC_TX_STATUS_OK) | ||
1214 | return 0; | ||
1215 | if (msg.tx_status & CEC_TX_STATUS_NACK) | ||
1216 | break; | ||
1217 | /* | ||
1218 | * Retry up to max_retries times if the message was neither | ||
1219 | * OKed or NACKed. This can happen due to e.g. a Lost | ||
1220 | * Arbitration condition. | ||
1221 | */ | ||
1222 | } | ||
1223 | |||
1224 | /* | ||
1225 | * If we are unable to get an OK or a NACK after max_retries attempts | ||
1226 | * (and note that each attempt already consists of four polls), then | ||
1227 | * then we assume that something is really weird and that it is not a | ||
1228 | * good idea to try and claim this logical address. | ||
1229 | */ | ||
1230 | if (i == max_retries) | ||
1204 | return 0; | 1231 | return 0; |
1205 | 1232 | ||
1206 | /* | 1233 | /* |