diff mbox

[12/12] staging: brcm80211: cleaned up softmac srom macro

Message ID 1314972039-27098-13-git-send-email-rvossen@broadcom.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Roland Vossen Sept. 2, 2011, 2 p.m. UTC
Substituted macro.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Roland Vossen <rvossen@broadcom.com>
---
 drivers/staging/brcm80211/brcmsmac/srom.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

Comments

Joe Perches Sept. 2, 2011, 3:49 p.m. UTC | #1
On Fri, 2011-09-02 at 16:00 +0200, Roland Vossen wrote:
> Substituted macro.
[]
> diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c
[]
> @@ -792,6 +780,14 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = {
>  
>  static u8 srom_crc8_table[CRC8_TABLE_SIZE];
>  
> +static u8 *srom_window_address(struct si_pub *sih, void *curmap)
> +{
> +	return sih->ccrev > 31 ?
> +	       (((sih->cccaps & CC_CAP_SROM) == 0) ? NULL :
> +	       ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) :
> +	       ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET);
> +}

Please try to make code more readable when
converting to functions too.

Maybe:

static u16 *srom_window_address(struct si_pub *sih, u8 *curmap)
{
	if (sih->ccrev < 32)
		return (u16 *)(curmap + PCI_BAR0_SPROM_OFFSET);
	if (sih->cccaps & CC_CAP_SROM)
		return (u16 *)(curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP);

	return NULL;
}
> @@ -1147,7 +1143,7 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars,
>  	if (!srom)
>  		return -ENOMEM;
>  
> -	sromwindow = (u16 *) SROM_OFFSET(sih);
> +	sromwindow = (u16 *) srom_window_address(sih, curmap);

	sromwindow = srom_window_address(sih, curmap)


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roland Vossen Sept. 2, 2011, 8:31 p.m. UTC | #2
Hello Joe,

> Please try to make code more readable when converting to functions too.

Good feedback. I will redo this particular patch [12/12] and keep this in mind for the future. Expect a new patch coming Monday.

Thanks, Roland.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roland Vossen Sept. 5, 2011, 8:06 a.m. UTC | #3
please drop this particular patch (#12) but keep the other ones 
(#1..#11). Will sent out a v2 patch shortly.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c
index c8f6897..165b88d 100644
--- a/drivers/staging/brcm80211/brcmsmac/srom.c
+++ b/drivers/staging/brcm80211/brcmsmac/srom.c
@@ -28,18 +28,6 @@ 
 #include "otp.h"
 #include "srom.h"
 
-#define SROM_OFFSET(sih) ((sih->ccrev > 31) ? \
-	(((sih->cccaps & CC_CAP_SROM) == 0) ? NULL : \
-	 ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) : \
-	((u8 *)curmap + PCI_BAR0_SPROM_OFFSET))
-
-#if defined(BCMDBG)
-/* 500 ms after write enable/disable toggle */
-#define WRITE_ENABLE_DELAY	500
-/* 20 ms between each word write */
-#define WRITE_WORD_DELAY	20
-#endif
-
 /*
  * SROM CRC8 polynomial value:
  *
@@ -792,6 +780,14 @@  static const struct brcms_sromvar perpath_pci_sromvars[] = {
 
 static u8 srom_crc8_table[CRC8_TABLE_SIZE];
 
+static u8 *srom_window_address(struct si_pub *sih, void *curmap)
+{
+	return sih->ccrev > 31 ?
+	       (((sih->cccaps & CC_CAP_SROM) == 0) ? NULL :
+	       ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) :
+	       ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET);
+}
+
 /* Parse SROM and create name=value pairs. 'srom' points to
  * the SROM word array. 'off' specifies the offset of the
  * first word 'srom' points to, which should be either 0 or
@@ -1147,7 +1143,7 @@  static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars,
 	if (!srom)
 		return -ENOMEM;
 
-	sromwindow = (u16 *) SROM_OFFSET(sih);
+	sromwindow = (u16 *) srom_window_address(sih, curmap);
 
 	crc8_populate_lsb(srom_crc8_table, SROM_CRC8_POLY);
 	if (ai_is_sprom_available(sih)) {