| From a7069fe39f638ce00c7309869e4f858beaca8ae4 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Fri, 26 Mar 2021 19:08:19 +0100 |
| Subject: ath9k: Fix error check in ath9k_hw_read_revisions() for PCI devices |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| From: Toke Høiland-Jørgensen <toke@redhat.com> |
| |
| [ Upstream commit 7dd9a40fd6e0d0f1fd8e1931c007e080801dfdce ] |
| |
| 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 |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 +- |
| drivers/net/wireless/ath/ath9k/hw.c | 2 +- |
| 2 files changed, 2 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c |
| index 66ef5cf16450..88e3b4a4de31 100644 |
| --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c |
| +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c |
| @@ -246,7 +246,7 @@ static unsigned int ath9k_regread(void *hw_priv, u32 reg_offset) |
| if (unlikely(r)) { |
| ath_dbg(common, WMI, "REGISTER READ FAILED: (0x%04x, %d)\n", |
| reg_offset, r); |
| - return -EIO; |
| + return -1; |
| } |
| |
| return be32_to_cpu(val); |
| diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c |
| index 406b52f114f0..933d4f49d6b0 100644 |
| --- a/drivers/net/wireless/ath/ath9k/hw.c |
| +++ b/drivers/net/wireless/ath/ath9k/hw.c |
| @@ -285,7 +285,7 @@ static bool ath9k_hw_read_revisions(struct ath_hw *ah) |
| |
| srev = REG_READ(ah, AR_SREV); |
| |
| - if (srev == -EIO) { |
| + if (srev == -1) { |
| ath_err(ath9k_hw_common(ah), |
| "Failed to read SREV register"); |
| return false; |
| -- |
| 2.30.2 |
| |