Thread (1 message) 1 message, 1 author, 2019-03-22

Re: [PATCH] ath9k: Check for errors when reading SREV register

From: Kalle Valo <hidden>
Date: 2019-03-22 08:37:33
Also in: linux-wireless, lkml

Tim Schumacher [off-list ref] writes:
On 21.03.19 11:02, Kalle Valo wrote:
quoted
Tim Schumacher [off-list ref] writes:
quoted
-	val = REG_READ(ah, AR_SREV) & AR_SREV_ID;
+	srev = REG_READ(ah, AR_SREV);
+
+	if (srev == -EIO) {
+		ath_err(ath9k_hw_common(ah),
+			"Failed to read SREV register");
+		return false;
+	}
I really don't like how the error handling is implemented in REG_READ().
If the register has value 0xfffffffb (= -EIO ==-5) won't this interpret
that as an error?
If the register had that value, it would indeed report an error. However
(at least if I read the current code and the data sheet correctly), to make
use of the higher 24 bits of the register, the "small"/old version of the
SREV_ID (i.e. the rightmost 8 bit) need to be set to 0xFF. Therefore, a
register read of 0xfffffffb should never happen in this register.
Good, thanks for checking.
But the error handling is indeed a bit weird. Making the return value a pure
status indicator and saving the value from the register by passing a
reference would probably be the best solution to fixing this up.
Yeah, that would be so much better. But that can fixed in another patch,
no need to do that here.

-- 
Kalle Valo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help