]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
rtlwifi: rtl8192ee: Fix problems with calculating free space in FIFO
authorLarry Finger <Larry.Finger@lwfinger.net>
Tue, 3 Feb 2015 17:15:18 +0000 (11:15 -0600)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 6 Feb 2015 06:36:08 +0000 (08:36 +0200)
This driver utilizes a FIFO buffer for RX descriptors. There are four places
in the code where it calculates the number of free slots. Several of those
locations do the calculation incorrectly. To fix these and to prevent future
mistakes, a common inline routine is created.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.kernel.org> [V3.18]
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rtlwifi/pci.h
drivers/net/wireless/rtlwifi/rtl8192ee/trx.c

index 5e832306dba956c7b29fffc9cf9d1b3c9a66b2e8..d4567d12e07ebd13f17f0097baeec41a25702d31 100644 (file)
@@ -325,4 +325,11 @@ static inline void pci_write32_async(struct rtl_priv *rtlpriv,
        writel(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr);
 }
 
+static inline u16 calc_fifo_space(u16 rp, u16 wp)
+{
+       if (rp <= wp)
+               return RTL_PCI_MAX_RX_COUNT - 1 + rp - wp;
+       return rp - wp - 1;
+}
+
 #endif
index 1245e2f53c8dafb9dc86b8ace7dbf1860cdf8546..d39ee67f611368f535a8bb0669e4510a4d22692a 100644 (file)
@@ -499,14 +499,7 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, u8 queue_index)
        if (!start_rx)
                return 0;
 
-       if ((last_read_point > (RX_DESC_NUM_92E / 2)) &&
-           (read_point <= (RX_DESC_NUM_92E / 2))) {
-               remind_cnt = RX_DESC_NUM_92E - write_point;
-       } else {
-               remind_cnt = (read_point >= write_point) ?
-                            (read_point - write_point) :
-                            (RX_DESC_NUM_92E - write_point + read_point);
-       }
+       remind_cnt = calc_fifo_space(read_point, write_point);
 
        if (remind_cnt == 0)
                return 0;