diff mbox

[10/21] brcmfmac: Further SDIO addressing cleanup

Message ID 20170716112129.10206-11-ian@mnementh.co.uk (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Ian Molton July 16, 2017, 11:21 a.m. UTC
---
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  | 39 +++++++++-------------
 1 file changed, 16 insertions(+), 23 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 84ae67c11970..5214556465d1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -232,19 +232,23 @@  void brcmf_sdiod_change_state(struct brcmf_sdio_dev *sdiodev,
 }
 
 static int
-brcmf_sdiod_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
+brcmf_sdiod_set_backplane_window(struct brcmf_sdio_dev *sdiodev, u32 addr)
 {
+	u32 a, bar0 = addr & SBSDIO_SBWINDOW_MASK;
 	int err = 0, i;
-	u32 addr;
 
-	addr = (address & SBSDIO_SBWINDOW_MASK) >> 8;
+	if (bar0 == sdiodev->sbwad)
+		return 0;
 
-	for (i = 0 ; i < 3 && !err ; i++) {
-		u8 data = addr & 0xff;
-		addr = addr >> 8;
 
-		brcm_sdio_func1_wb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i, data, &err);
-	}
+	a = bar0 >> 8;
+
+	for (i = 0 ; i < 3 && !err ; i++, a>>=8)
+		brcm_sdio_func1_wb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i, a & 0xff, &err);
+
+
+	if(!err)
+		sdiodev->sbwad = bar0;
 
 	return err;
 }
@@ -257,17 +261,11 @@  brcmf_sdiod_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
 static int
 brcmf_sdiod_addrprep(struct brcmf_sdio_dev *sdiodev, u32 *addr)
 {
-	uint bar0 = *addr & SBSDIO_SBWINDOW_MASK;
 	int err = 0;
 
-	if (bar0 != sdiodev->sbwad) {
-		printk("WTAF? %08x %08x\n", bar0, sdiodev->sbwad);
-		err = brcmf_sdiod_set_sbaddr_window(sdiodev, bar0);
-		if (err)
-			return err;
-
-		sdiodev->sbwad = bar0;
-	}
+	err = brcmf_sdiod_set_backplane_window(sdiodev, *addr);
+	if (err)
+		return err;
 
 	*addr &= SBSDIO_SB_OFT_ADDR_MASK;
 	*addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
@@ -699,7 +697,7 @@  brcmf_sdiod_ramrw(struct brcmf_sdio_dev *sdiodev, bool write, u32 address,
 	while (size) {
 
 		/* Set the backplane window to include the start address */
-		err = brcmf_sdiod_set_sbaddr_window(sdiodev, address);
+		err = brcmf_sdiod_set_backplane_window(sdiodev, address);
 		if (err)
 			break;
 
@@ -743,11 +741,6 @@  brcmf_sdiod_ramrw(struct brcmf_sdio_dev *sdiodev, bool write, u32 address,
 
 	dev_kfree_skb(pkt);
 
-	/* Return the window to backplane enumeration space for core access */
-	if (brcmf_sdiod_set_sbaddr_window(sdiodev, sdiodev->sbwad))
-		brcmf_err("FAILED to set window back to 0x%x\n",
-			  sdiodev->sbwad);
-
 	sdio_release_host(sdiodev->func[1]);
 
 	return err;