All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Franky Lin" <frankyl@broadcom.com>
To: gregkh@suse.de
Cc: devel@linuxdriverproject.org, linux-wireless@vger.kernel.org
Subject: [PATCH v2 17/26] staging: brcm80211: removed global variable in softmac otp
Date: Tue, 27 Sep 2011 10:45:21 -0700	[thread overview]
Message-ID: <1317145530-18839-18-git-send-email-frankyl@broadcom.com> (raw)
In-Reply-To: <1317145530-18839-1-git-send-email-frankyl@broadcom.com>

From: Roland Vossen <rvossen@broadcom.com>

Placed variable on the stack instead and deleted unused functions.
Softmac was tested to function properly with multiple adapters in one
system.

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: Franky Lin <frankyl@broadcom.com>
---
 drivers/staging/brcm80211/brcmsmac/otp.c |  143 ++++--------------------------
 drivers/staging/brcm80211/brcmsmac/otp.h |    8 --
 2 files changed, 18 insertions(+), 133 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmsmac/otp.c b/drivers/staging/brcm80211/brcmsmac/otp.c
index 06cb575..f15e8be 100644
--- a/drivers/staging/brcm80211/brcmsmac/otp.c
+++ b/drivers/staging/brcm80211/brcmsmac/otp.c
@@ -67,15 +67,13 @@
 /* Fixed size subregions sizes in words */
 #define OTPGU_CI_SZ		2
 
+struct otpinfo;
+
 /* OTP function struct */
 struct otp_fn_s {
-	int (*size)(struct otpinfo *oi);
-	u16 (*read_bit)(struct otpinfo *oi, struct chipcregs *cc, uint off);
-	struct otpinfo *(*init)(struct si_pub *sih);
+	int (*init)(struct si_pub *sih, struct otpinfo *oi);
 	int (*read_region)(struct otpinfo *oi, int region, u16 *data,
 			   uint *wlen);
-	int (*nvread)(struct otpinfo *oi, char *data, uint *len);
-	int (*status)(struct otpinfo *oi);
 };
 
 struct otpinfo {
@@ -99,21 +97,6 @@ struct otpinfo {
 	int otpgu_base;		/* offset to General Use Region */
 };
 
-static struct otpinfo otpinfo;
-
-/*
- * IPX OTP Code
- *
- *   Exported functions:
- *	ipxotp_status()
- *	ipxotp_size()
- *	ipxotp_init()
- *	ipxotp_read_bit()
- *	ipxotp_read_region()
- *	ipxotp_nvread()
- *
- */
-
 /* OTP layout */
 /* CC revs 21, 24 and 27 OTP General Use Region word offset */
 #define REVA4_OTPGU_BASE	12
@@ -149,51 +132,11 @@ static struct otpinfo otpinfo;
 #define OTP4315_SWREG_SZ	178	/* 178 bytes */
 #define OTP_SZ_FU_144		(144/8)	/* 144 bits */
 
-static int ipxotp_status(struct otpinfo *oi)
-{
-	return (int)(oi->status);
-}
-
-/* Return size in bytes */
-static int ipxotp_size(struct otpinfo *oi)
-{
-	return (int)oi->wsize * 2;
-}
-
 static u16 ipxotp_otpr(struct otpinfo *oi, struct chipcregs *cc, uint wn)
 {
 	return R_REG(&cc->sromotp[wn]);
 }
 
-static u16 ipxotp_read_bit(struct otpinfo *oi, struct chipcregs *cc, uint off)
-{
-	uint k, row, col;
-	u32 otpp, st;
-
-	row = off / oi->cols;
-	col = off % oi->cols;
-
-	otpp = OTPP_START_BUSY |
-	    ((OTPPOC_READ << OTPP_OC_SHIFT) & OTPP_OC_MASK) |
-	    ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) |
-	    ((col << OTPP_COL_SHIFT) & OTPP_COL_MASK);
-	W_REG(&cc->otpprog, otpp);
-
-	for (k = 0;
-	     ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY)
-	     && (k < OTPP_TRIES); k++)
-		;
-	if (k >= OTPP_TRIES)
-		return 0xffff;
-
-	if (st & OTPP_READERR)
-		return 0xffff;
-
-	st = (st & OTPP_VALUE_MASK) >> OTPP_VALUE_SHIFT;
-
-	return (int)st;
-}
-
 /*
  * Calculate max HW/SW region byte size by subtracting fuse region
  * and checksum size, osizew is oi->wsize (OTP size - GU size) in words
@@ -294,28 +237,24 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc)
 	oi->flim = oi->wsize;
 }
 
-static struct otpinfo *ipxotp_init(struct si_pub *sih)
+static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi)
 {
 	uint idx;
 	struct chipcregs *cc;
-	struct otpinfo *oi;
 
 	/* Make sure we're running IPX OTP */
 	if (!OTPTYPE_IPX(sih->ccrev))
-		return NULL;
+		return -EBADE;
 
 	/* Make sure OTP is not disabled */
 	if (ai_is_otp_disabled(sih))
-		return NULL;
-
-	/* OTP is always powered */
-	oi = &otpinfo;
+		return -EBADE;
 
 	/* Check for otp size */
 	switch ((sih->cccaps & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) {
 	case 0:
 		/* Nothing there */
-		return NULL;
+		return -EBADE;
 	case 1:		/* 32x64 */
 		oi->rows = 32;
 		oi->cols = 64;
@@ -338,7 +277,7 @@ static struct otpinfo *ipxotp_init(struct si_pub *sih)
 		break;
 	default:
 		/* Don't know the geometry */
-		return NULL;
+		return -EBADE;
 	}
 
 	/* Retrieve OTP region info */
@@ -349,7 +288,7 @@ static struct otpinfo *ipxotp_init(struct si_pub *sih)
 
 	ai_setcoreidx(sih, idx);
 
-	return oi;
+	return 0;
 }
 
 static int
@@ -437,56 +376,16 @@ ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen)
 	return 0;
 }
 
-static int ipxotp_nvread(struct otpinfo *oi, char *data, uint *len)
-{
-	return -ENOTSUPP;
-}
-
 static const struct otp_fn_s ipxotp_fn = {
-	(int (*)(struct otpinfo *)) ipxotp_size,
-	(u16 (*)(struct otpinfo *, struct chipcregs *, uint)) ipxotp_read_bit,
-
-	(struct otpinfo *(*)(struct si_pub *)) ipxotp_init,
+	(int (*)(struct si_pub *, struct otpinfo *)) ipxotp_init,
 	(int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region,
-	(int (*)(struct otpinfo *, char *, uint *)) ipxotp_nvread,
-
-	(int (*)(struct otpinfo *)) ipxotp_status
 };
 
-/*
- *	otp_status()
- *	otp_size()
- *	otp_read_bit()
- *	otp_init()
- *	otp_read_region()
- *	otp_nvread()
- */
-
-int otp_status(struct otpinfo *oi)
+static int otp_init(struct si_pub *sih, struct otpinfo *oi)
 {
-	return oi->fn->status(oi);
-}
-
-int otp_size(struct otpinfo *oi)
-{
-	return oi->fn->size(oi);
-}
 
-u16 otp_read_bit(struct otpinfo *oi, uint offset)
-{
-	uint idx = ai_coreidx(oi->sih);
-	struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
-	u16 readBit = (u16) oi->fn->read_bit(oi, cc, offset);
-	ai_setcoreidx(oi->sih, idx);
-	return readBit;
-}
+	int ret;
 
-struct otpinfo *otp_init(struct si_pub *sih)
-{
-	struct otpinfo *oi;
-	struct otpinfo *ret = NULL;
-
-	oi = &otpinfo;
 	memset(oi, 0, sizeof(struct otpinfo));
 
 	oi->ccrev = sih->ccrev;
@@ -495,18 +394,19 @@ struct otpinfo *otp_init(struct si_pub *sih)
 		oi->fn = &ipxotp_fn;
 
 	if (oi->fn == NULL)
-		return NULL;
+		return -EBADE;
 
 	oi->sih = sih;
 
-	ret = (oi->fn->init) (sih);
+	ret = (oi->fn->init) (sih, oi);
 
 	return ret;
 }
 
 int
 otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) {
-	struct otpinfo *oi;
+	struct otpinfo otpinfo;
+	struct otpinfo *oi = &otpinfo;
 	int err = 0;
 
 	if (ai_is_otp_disabled(sih)) {
@@ -514,19 +414,12 @@ otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) {
 		goto out;
 	}
 
-	oi = otp_init(sih);
-	if (oi == NULL) {
-		err = -EBADE;
+	err = otp_init(sih, oi);
+	if (err)
 		goto out;
-	}
 
 	err = ((oi)->fn->read_region)(oi, region, data, wlen);
 
  out:
 	return err;
 }
-
-int otp_nvread(struct otpinfo *oi, char *data, uint *len)
-{
-	return oi->fn->nvread(oi, data, len);
-}
diff --git a/drivers/staging/brcm80211/brcmsmac/otp.h b/drivers/staging/brcm80211/brcmsmac/otp.h
index bf2f76f..6b6d31c 100644
--- a/drivers/staging/brcm80211/brcmsmac/otp.h
+++ b/drivers/staging/brcm80211/brcmsmac/otp.h
@@ -30,15 +30,7 @@
 /* OTP Size */
 #define OTP_SZ_MAX		(6144/8)	/* maximum bytes in one CIS */
 
-struct otpinfo;
-
-/* Exported functions */
-extern int otp_status(struct otpinfo *oi);
-extern int otp_size(struct otpinfo *oi);
-extern u16 otp_read_bit(struct otpinfo *oi, uint offset);
-extern struct otpinfo *otp_init(struct si_pub *sih);
 extern int otp_read_region(struct si_pub *sih, int region, u16 *data,
 			   uint *wlen);
-extern int otp_nvread(struct otpinfo *oi, char *data, uint *len);
 
 #endif				/* _BRCM_OTP_H_ */
-- 
1.7.1



  parent reply	other threads:[~2011-09-27 17:45 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 17:45 [PATCH v2 00/26] staging: brcm80211: 8th reaction for mainline patch #2 Franky Lin
2011-09-27 17:45 ` [PATCH v2 01/26] staging: brcm80211: remove uncoditional code blocks from brcmsmac Franky Lin
2011-09-27 17:45 ` [PATCH v2 02/26] staging: brcm80211: removed unused argument from softmac functions Franky Lin
2011-09-27 17:45 ` [PATCH v2 03/26] staging: brcm80211: deleted unused array of bss configurations in softmac Franky Lin
2011-09-27 17:45 ` [PATCH v2 04/26] staging: brcm80211: removed redundant wlc->cfg struct member Franky Lin
2011-09-27 17:45 ` [PATCH v2 05/26] staging: brcm80211: removed global var from aiutils.c Franky Lin
2011-09-27 17:45 ` [PATCH v2 06/26] staging: brcm80211: removed global vars in softmac ucode handling Franky Lin
2011-09-27 17:45 ` [PATCH v2 07/26] staging: brcm80211: removed unused softmac workaround Franky Lin
2011-09-27 17:45 ` [PATCH v2 08/26] staging: brcm80211: remove ht_cap field from brcms_c_info structure Franky Lin
2011-09-27 17:45 ` [PATCH v2 09/26] staging: brcm80211: use fragment number provided in transmit frame Franky Lin
2011-09-27 17:45 ` [PATCH v2 10/26] staging: brcm80211: remove unused function si_pmu_ilp_clock() Franky Lin
2011-09-27 17:45 ` [PATCH v2 11/26] staging: brcm80211: make device initializer table for wme constant Franky Lin
2011-09-27 17:45 ` [PATCH v2 12/26] staging: brcm80211: remove dongle firmware related debug code Franky Lin
2011-09-27 17:45 ` [PATCH v2 13/26] staging: brcm80211: remove unnecessary mac80211 callbacks Franky Lin
2011-09-27 17:45 ` [PATCH v2 14/26] staging: brcm80211: removed band related global vars from softmac Franky Lin
2011-09-27 17:45 ` [PATCH v2 15/26] staging: brcm80211: removed global var global_scb " Franky Lin
2011-09-27 17:45 ` [PATCH v2 16/26] staging: brcm80211: various global var related changes in softmac Franky Lin
2011-09-27 17:45 ` Franky Lin [this message]
2011-09-27 17:45 ` [PATCH v2 18/26] staging: brcm80211: changing interface to n-phy rssi compute function Franky Lin
2011-09-27 17:45 ` [PATCH v2 19/26] staging: brcm80211: change interface for common " Franky Lin
2011-09-27 17:45 ` [PATCH v2 20/26] staging: brcm80211: convert endianess before handling the frame Franky Lin
2011-09-27 17:45 ` [PATCH v2 21/26] staging: brcm80211: use endian annotated structures in brcmsmac Franky Lin
2011-09-27 17:45 ` [PATCH v2 22/26] staging: brcm80211: move rssi computation to place we need it Franky Lin
2011-09-27 17:45 ` [PATCH v2 23/26] staging: brcm80211: use d11rxhdr structure in brcms_c_recover_tsf64() Franky Lin
2011-09-27 17:45 ` [PATCH v2 24/26] staging: brcm80211: declared global vars in softmac phy as const Franky Lin
2011-09-27 18:35   ` Larry Finger
2011-09-27 21:10     ` Arend van Spriel
2011-09-28  5:12       ` Larry Finger
2011-09-27 17:45 ` [PATCH v2 25/26] staging: brcm80211: simple changes to softmac phy variables Franky Lin
2011-09-27 17:45 ` [PATCH v2 26/26] staging: brcm80211: declared global vars in softmac phy as const Franky Lin
2011-09-29 22:34 ` [PATCH v3 00/25] staging: brcm80211: 8th reaction for mainline patch #2 Franky Lin
2011-09-29 22:34   ` [PATCH v3 01/25] staging: brcm80211: remove uncoditional code blocks from brcmsmac Franky Lin
2011-09-29 22:34   ` [PATCH v3 02/25] staging: brcm80211: removed unused argument from softmac functions Franky Lin
2011-09-29 22:34   ` [PATCH v3 03/25] staging: brcm80211: deleted unused array of bss configurations in softmac Franky Lin
2011-09-29 22:34   ` [PATCH v3 04/25] staging: brcm80211: removed redundant wlc->cfg struct member Franky Lin
2011-09-29 22:34   ` [PATCH v3 05/25] staging: brcm80211: removed global var from aiutils.c Franky Lin
2011-09-29 22:34   ` [PATCH v3 06/25] staging: brcm80211: removed global vars in softmac ucode handling Franky Lin
2011-09-29 22:34   ` [PATCH v3 07/25] staging: brcm80211: removed unused softmac workaround Franky Lin
2011-09-29 22:34   ` [PATCH v3 08/25] staging: brcm80211: remove ht_cap field from brcms_c_info structure Franky Lin
2011-09-29 22:34   ` [PATCH v3 09/25] staging: brcm80211: use fragment number provided in transmit frame Franky Lin
2011-09-29 22:34   ` [PATCH v3 10/25] staging: brcm80211: remove unused function si_pmu_ilp_clock() Franky Lin
2011-09-29 22:34   ` [PATCH v3 11/25] staging: brcm80211: make device initializer table for wme constant Franky Lin
2011-09-29 22:34   ` [PATCH v3 12/25] staging: brcm80211: remove dongle firmware related debug code Franky Lin
2011-09-29 22:34   ` [PATCH v3 13/25] staging: brcm80211: remove unnecessary mac80211 callbacks Franky Lin
2011-09-29 22:34   ` [PATCH v3 14/25] staging: brcm80211: removed band related global vars from softmac Franky Lin
2011-09-29 22:34   ` [PATCH v3 15/25] staging: brcm80211: removed global var global_scb " Franky Lin
2011-09-29 22:34   ` [PATCH v3 16/25] staging: brcm80211: various global var related changes in softmac Franky Lin
2011-09-29 22:34   ` [PATCH v3 17/25] staging: brcm80211: removed global variable in softmac otp Franky Lin
2011-09-29 22:34   ` [PATCH v3 18/25] staging: brcm80211: changing interface to n-phy rssi compute function Franky Lin
2011-09-29 22:34   ` [PATCH v3 19/25] staging: brcm80211: change interface for common " Franky Lin
2011-09-29 22:34   ` [PATCH v3 20/25] staging: brcm80211: convert endianess before handling the frame Franky Lin
2011-09-29 22:34   ` [PATCH v3 21/25] staging: brcm80211: use endian annotated structures in brcmsmac Franky Lin
2011-10-10 14:35     ` Rafał Miłecki
2011-09-29 22:34   ` [PATCH v3 22/25] staging: brcm80211: move rssi computation to place we need it Franky Lin
2011-09-29 22:34   ` [PATCH v3 23/25] staging: brcm80211: use d11rxhdr structure in brcms_c_recover_tsf64() Franky Lin
2011-09-29 22:34   ` [PATCH v3 24/25] staging: brcm80211: simple changes to softmac phy variables Franky Lin
2011-09-29 22:34   ` [PATCH v3 25/25] staging: brcm80211: declared global vars in softmac phy as const Franky Lin
2011-10-03 23:23   ` [PATCH v3 00/25] staging: brcm80211: 8th reaction for mainline patch #2 Greg KH
2011-10-03 23:33     ` Franky Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317145530-18839-18-git-send-email-frankyl@broadcom.com \
    --to=frankyl@broadcom.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.