media: cec: stm32: return an error when log-address wait times out

stm32_cec_adap_log_addr() waits for TXSOM to clear before disabling CEC
and updating the logical address registers. The wait result is ignored,
so a timeout can still be reported as a successful logical address
update.

Return the polling error before touching the address registers. Compute
the address mask only for valid logical addresses so the invalid-address
path does not evaluate a shift based on CEC_LOG_ADDR_INVALID.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Pengpeng Hou 2026-06-24 22:40:15 +08:00 committed by Hans Verkuil
parent 0fbd5c2327
commit 3bc2e4a264

View File

@ -194,18 +194,24 @@ static int stm32_cec_adap_enable(struct cec_adapter *adap, bool enable)
static int stm32_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
{
struct stm32_cec *cec = adap->priv;
u32 oar = (1 << logical_addr) << 16;
u32 val;
int ret;
/* Poll every 100µs the register CEC_CR to wait end of transmission */
regmap_read_poll_timeout(cec->regmap, CEC_CR, val, !(val & TXSOM),
100, CEC_XFER_TIMEOUT_MS * 1000);
ret = regmap_read_poll_timeout(cec->regmap, CEC_CR, val, !(val & TXSOM),
100, CEC_XFER_TIMEOUT_MS * 1000);
if (ret)
return ret;
regmap_update_bits(cec->regmap, CEC_CR, CECEN, 0);
if (logical_addr == CEC_LOG_ADDR_INVALID)
if (logical_addr == CEC_LOG_ADDR_INVALID) {
regmap_update_bits(cec->regmap, CEC_CFGR, OAR, 0);
else
} else {
u32 oar = BIT(logical_addr) << 16;
regmap_update_bits(cec->regmap, CEC_CFGR, oar, oar);
}
regmap_update_bits(cec->regmap, CEC_CR, CECEN, CECEN);