Re: [PATCH 12/34] brcmfmac: Replace old IO functions with simpler ones.

2017-08-19 Thread Ian Molton
On 07/08/17 18:55, Ian Molton wrote:
> On 07/08/17 12:26, Arend van Spriel wrote:
>> On 7/26/2017 10:25 PM, Ian Molton wrote:
>>> Primarily this patch removes:
>>>
>>> brcmf_sdiod_f0_writeb()
>>> brcmf_sdiod_reg_write()
>>> brcmf_sdiod_reg_read()
>>
>> Having [patch 30/34] "brcmfmac: Correctly handle accesses to SDIO func0"
>> before this patch could make this look cleaner.
> 
> This is an artifact of how I came to the realisation the code was using
> the obsoleted functions - it could be reordered, but it'd probably get
> messy...

I gave it a try, and it got messy - I'd prefer to leave these patches in
their current ordering if thats OK.

-Ian


Re: [PATCH 12/34] brcmfmac: Replace old IO functions with simpler ones.

2017-08-07 Thread Ian Molton
On 07/08/17 12:26, Arend van Spriel wrote:
> On 7/26/2017 10:25 PM, Ian Molton wrote:
>> Primarily this patch removes:
>>
>> brcmf_sdiod_f0_writeb()
>> brcmf_sdiod_reg_write()
>> brcmf_sdiod_reg_read()
> 
> Having [patch 30/34] "brcmfmac: Correctly handle accesses to SDIO func0"
> before this patch could make this look cleaner.

This is an artifact of how I came to the realisation the code was using
the obsoleted functions - it could be reordered, but it'd probably get
messy...

>> Since we no longer use the quirky method of deciding which function to
>> address via the address being accessed, take the opportunity to rename
>> some IO functions more in line with common kernel code.
> 
> As mentioned here this is more a rename than a replace so please use
> that in the subject as well.

Noted.

> Reviewed-by: Arend van Spriel 
>> Signed-off-by: Ian Molton 
>> ---
>>   .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  | 166
>> +++
>>   .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 182
>> ++---
>>   .../wireless/broadcom/brcm80211/brcmfmac/sdio.h|  28 +++-
>>   3 files changed, 132 insertions(+), 244 deletions(-)
> 

-Ian


Re: [PATCH 12/34] brcmfmac: Replace old IO functions with simpler ones.

2017-08-07 Thread Arend van Spriel

On 7/26/2017 10:25 PM, Ian Molton wrote:

Primarily this patch removes:

brcmf_sdiod_f0_writeb()
brcmf_sdiod_reg_write()
brcmf_sdiod_reg_read()


Having [patch 30/34] "brcmfmac: Correctly handle accesses to SDIO func0" 
before this patch could make this look cleaner.



Since we no longer use the quirky method of deciding which function to
address via the address being accessed, take the opportunity to rename
some IO functions more in line with common kernel code.


As mentioned here this is more a rename than a replace so please use 
that in the subject as well.


Reviewed-by: Arend van Spriel 

Signed-off-by: Ian Molton 
---
  .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  | 166 +++
  .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 182 ++---
  .../wireless/broadcom/brcm80211/brcmfmac/sdio.h|  28 +++-
  3 files changed, 132 insertions(+), 244 deletions(-)




[PATCH 12/34] brcmfmac: Replace old IO functions with simpler ones.

2017-07-26 Thread Ian Molton
Primarily this patch removes:

brcmf_sdiod_f0_writeb()
brcmf_sdiod_reg_write()
brcmf_sdiod_reg_read()

Since we no longer use the quirky method of deciding which function to
address via the address being accessed, take the opportunity to rename
some IO functions more in line with common kernel code.

Signed-off-by: Ian Molton 
---
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  | 166 +++
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 182 ++---
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.h|  28 +++-
 3 files changed, 132 insertions(+), 244 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 858ad2d8706b..b2945b463fd3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -137,27 +137,25 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev 
*sdiodev)
if (sdiodev->bus_if->chip == BRCM_CC_43362_CHIP_ID) {
/* assign GPIO to SDIO core */
addr = CORE_CC_REG(SI_ENUM_BASE, gpiocontrol);
-   gpiocontrol = brcmf_sdiod_regrl(sdiodev, addr, );
+   gpiocontrol = brcmf_sdiod_readl(sdiodev, addr, );
gpiocontrol |= 0x2;
-   brcmf_sdiod_regwl(sdiodev, addr, gpiocontrol, );
+   brcmf_sdiod_writel(sdiodev, addr, gpiocontrol, );
 
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_SELECT, 0xf,
- );
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_OUT, 0, );
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_EN, 0x2, );
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_SELECT, 0xf, 
);
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_OUT, 0, );
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_EN, 0x2, );
}
 
/* must configure SDIO_CCCR_IENx to enable irq */
-   data = brcmf_sdiod_regrb(sdiodev, SDIO_CCCR_IENx, );
+   data = brcmf_sdiod_func0_rb(sdiodev, SDIO_CCCR_IENx, );
data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, data, );
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_IENx, data, );
 
/* redirect, configure and enable io for interrupt signal */
data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
if (pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
data |= SDIO_SEPINT_ACT_HI;
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, );
-
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, 
);
sdio_release_host(sdiodev->func[1]);
} else {
brcmf_dbg(SDIO, "Entering\n");
@@ -183,8 +181,8 @@ void brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev 
*sdiodev)
 
pdata = >settings->bus.sdio;
sdio_claim_host(sdiodev->func[1]);
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
sdio_release_host(sdiodev->func[1]);
 
sdiodev->oob_irq_requested = false;
@@ -242,8 +240,8 @@ static int brcmf_sdiod_set_sbaddr_window(struct 
brcmf_sdio_dev *sdiodev,
addr = (address & SBSDIO_SBWINDOW_MASK) >> 8;
 
for (i = 0 ; i < 3 && !err ; i++, addr >>= 8)
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i,
- addr & 0xff, );
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i,
+  addr & 0xff, );
 
return err;
 }
@@ -267,123 +265,15 @@ static int brcmf_sdiod_addrprep(struct brcmf_sdio_dev 
*sdiodev, u32 *addr)
return 0;
 }
 
-static inline int brcmf_sdiod_f0_writeb(struct sdio_func *func, u8 byte,
-   uint regaddr)
-{
-   int err_ret;
-
-   /*
-* Can only directly write to some F0 registers.
-* Handle CCCR_IENx and CCCR_ABORT command
-* as a special case.
-*/
-   if ((regaddr == SDIO_CCCR_ABORT) ||
-   (regaddr == SDIO_CCCR_IENx))
-   sdio_writeb(func, byte, regaddr, _ret);
-   else
-   sdio_f0_writeb(func, byte, regaddr, _ret);
-
-   return err_ret;
-}
-
-static int brcmf_sdiod_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr,
-u8 regsz, void *data)
-{
-   int ret;
-
-   /*
-* figure out how to read the register based on address range
-* 

[PATCH 12/34] brcmfmac: Replace old IO functions with simpler ones.

2017-07-19 Thread Ian Molton
Primarily this patch removes:

brcmf_sdiod_f0_writeb()
brcmf_sdiod_reg_write()
brcmf_sdiod_reg_read()

Since we no longer use the quirky method of deciding which function to
address via the address being accessed, take the opportunity to rename
some IO functions more in line with common kernel code.

Signed-off-by: Ian Molton 
---
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  | 165 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 157 +---
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.h|  27 ++--
 3 files changed, 111 insertions(+), 238 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 013b9b852d81..13f20b58d34e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -137,27 +137,25 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev 
*sdiodev)
if (sdiodev->bus_if->chip == BRCM_CC_43362_CHIP_ID) {
/* assign GPIO to SDIO core */
addr = CORE_CC_REG(SI_ENUM_BASE, gpiocontrol);
-   gpiocontrol = brcmf_sdiod_regrl(sdiodev, addr, );
+   gpiocontrol = brcmf_sdiod_readl(sdiodev, addr, );
gpiocontrol |= 0x2;
-   brcmf_sdiod_regwl(sdiodev, addr, gpiocontrol, );
+   brcmf_sdiod_writel(sdiodev, addr, gpiocontrol, );
 
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_SELECT, 0xf,
- );
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_OUT, 0, );
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_GPIO_EN, 0x2, );
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_SELECT, 0xf, 
);
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_OUT, 0, );
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_GPIO_EN, 0x2, );
}
 
/* must configure SDIO_CCCR_IENx to enable irq */
-   data = brcmf_sdiod_regrb(sdiodev, SDIO_CCCR_IENx, );
+   data = brcmf_sdiod_func0_rb(sdiodev, SDIO_CCCR_IENx, );
data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, data, );
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_IENx, data, );
 
/* redirect, configure and enable io for interrupt signal */
data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
if (pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
data |= SDIO_SEPINT_ACT_HI;
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, );
-
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, 
);
sdio_release_host(sdiodev->func[1]);
} else {
brcmf_dbg(SDIO, "Entering\n");
@@ -183,8 +181,8 @@ void brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev 
*sdiodev)
 
pdata = >settings->bus.sdio;
sdio_claim_host(sdiodev->func[1]);
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
-   brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
+   brcmf_sdiod_func0_wb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
sdio_release_host(sdiodev->func[1]);
 
sdiodev->oob_irq_requested = false;
@@ -242,7 +240,7 @@ brcmf_sdiod_set_sbaddr_window(struct brcmf_sdio_dev 
*sdiodev, u32 address)
addr = (address & SBSDIO_SBWINDOW_MASK) >> 8;
 
for ( i = 0 ; i < 3 && !err ; i++, addr >>= 8 )
-   brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i, addr & 
0xff,
+   brcmf_sdiod_writeb(sdiodev, SBSDIO_FUNC1_SBADDRLOW + i, addr & 
0xff,
);
 
return err;
@@ -268,124 +266,15 @@ brcmf_sdiod_addrprep(struct brcmf_sdio_dev *sdiodev, u32 
*addr)
return 0;
 }
 
-static inline int brcmf_sdiod_f0_writeb(struct sdio_func *func, u8 byte, uint 
regaddr)
-{
-   int err_ret;
-
-   /*
-* Can only directly write to some F0 registers.
-* Handle CCCR_IENx and CCCR_ABORT command
-* as a special case.
-*/
-   if ((regaddr == SDIO_CCCR_ABORT) ||
-   (regaddr == SDIO_CCCR_IENx))
-   sdio_writeb(func, byte, regaddr, _ret);
-   else
-   sdio_f0_writeb(func, byte, regaddr, _ret);
-
-   return err_ret;
-}
-
-static int brcmf_sdiod_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr,
-  u8 regsz, void *data)
-{
-   int ret;
-
-   /*
-* figure out how to read the register based on address range
-* 0x00 ~ 0x7FF: function 0 CCCR and FBR
-* 0x1 ~ 0x1: function 1