Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ath9k: Fix error check in ath9k_hw_read_revisions() for PCI devices

When the error check in ath9k_hw_read_revisions() was added, it checked for
-EIO which is what ath9k_regread() in the ath9k_htc driver uses. However,
for plain ath9k, the register read function uses ioread32(), which just
returns -1 on error. So if such a read fails, it still gets passed through
and ends up as a weird mac revision in the log output.

Fix this by changing ath9k_regread() to return -1 on error like ioread32()
does, and fix the error check to look for that instead of -EIO.

Fixes: 2f90c7e5d094 ("ath9k: Check for errors when reading SREV register")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210326180819.142480-1-toke@redhat.com

authored by

Toke Høiland-Jørgensen and committed by
Kalle Valo
7dd9a40f afda3349

+2 -2
+1 -1
drivers/net/wireless/ath/ath9k/htc_drv_init.c
··· 246 246 if (unlikely(r)) { 247 247 ath_dbg(common, WMI, "REGISTER READ FAILED: (0x%04x, %d)\n", 248 248 reg_offset, r); 249 - return -EIO; 249 + return -1; 250 250 } 251 251 252 252 return be32_to_cpu(val);
+1 -1
drivers/net/wireless/ath/ath9k/hw.c
··· 286 286 287 287 srev = REG_READ(ah, AR_SREV); 288 288 289 - if (srev == -EIO) { 289 + if (srev == -1) { 290 290 ath_err(ath9k_hw_common(ah), 291 291 "Failed to read SREV register"); 292 292 return false;