From patchwork Wed Sep 15 09:47:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 182142 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8F9mh7t009918 for ; Wed, 15 Sep 2010 09:48:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409Ab0IOJrp (ORCPT ); Wed, 15 Sep 2010 05:47:45 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:51002 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719Ab0IOJrj (ORCPT ); Wed, 15 Sep 2010 05:47:39 -0400 Received: by eyb6 with SMTP id 6so3065eyb.19 for ; Wed, 15 Sep 2010 02:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=SaotL1mQYRpTowRUi31ryK6HcahwXlirwBofO1vvxAg=; b=wguuHRsdXqHhmICQhR3GEro2HYN55Lazp3jVKRBDwbvomnt2VpbrK0HPaqQnYbvc90 MSIzqzA2YnC8VWU/B/vwg/1Z3ojEY2kRcHZrzqsAzzlWMOKOOXzbu6IfSpn7YpxpFqmG 6bPXxd2GUzcKACDkXS0EizRtd9Wxu6/lQYjaw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=TPmGRdWim7nL6Rm6BQj4VSdLs02mpsdcchVs0IzfCkpKKdqJT40/bDD4bf7fejqId/ Guu9AYHlhGEXjHhRLkfx+CSABq1b3Obwza1tv4Rfmay4NT4TfxaHUisftZKIYLhWiQxk MsiKEh4liYCiPVnxmaB3Sc1wA61xexE3pKXqw= Received: by 10.213.30.4 with SMTP id s4mr3709685ebc.99.1284544057701; Wed, 15 Sep 2010 02:47:37 -0700 (PDT) Received: from localhost.localdomain (79-134-110-186.cust.suomicom.fi [79.134.110.186]) by mx.google.com with ESMTPS id z55sm1789164eeh.21.2010.09.15.02.47.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Sep 2010 02:47:37 -0700 (PDT) From: Andy Shevchenko To: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Nohee Ko , Andy Shevchenko Subject: [PATCH 2/2] staging: brcm80211: use string native library Date: Wed, 15 Sep 2010 12:47:18 +0300 Message-Id: <1284544038-5696-2-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1284544038-5696-1-git-send-email-andy.shevchenko@gmail.com> References: <1284544038-5696-1-git-send-email-andy.shevchenko@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 15 Sep 2010 09:48:43 +0000 (UTC) diff --git a/drivers/staging/brcm80211/include/bcmutils.h b/drivers/staging/brcm80211/include/bcmutils.h index f17dbb1..4aa3800 100644 --- a/drivers/staging/brcm80211/include/bcmutils.h +++ b/drivers/staging/brcm80211/include/bcmutils.h @@ -165,19 +165,6 @@ extern "C" { #define PKTPRIO_UPD 0x400 /* DSCP used to update VLAN prio */ #define PKTPRIO_DSCP 0x800 /* DSCP prio found */ -/* string */ - extern int BCMROMFN(bcm_atoi) (char *s); - extern ulong BCMROMFN(bcm_strtoul) (char *cp, char **endp, uint base); - extern char *BCMROMFN(bcmstrstr) (char *haystack, char *needle); - extern char *BCMROMFN(bcmstrcat) (char *dest, const char *src); - extern char *BCMROMFN(bcmstrncat) (char *dest, const char *src, - uint size); - extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, - ulong abuflen); - char *bcmstrtok(char **string, const char *delimiters, char *tokdelim); - int bcmstricmp(const char *s1, const char *s2); - int bcmstrnicmp(const char *s1, const char *s2, int cnt); - /* ethernet address */ extern char *bcm_ether_ntoa(const struct ether_addr *ea, char *buf); extern int BCMROMFN(bcm_ether_atoe) (char *p, struct ether_addr *ea); diff --git a/drivers/staging/brcm80211/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/phy/wlc_phy_cmn.c index f2e504e..18b9849 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_cmn.c +++ b/drivers/staging/brcm80211/phy/wlc_phy_cmn.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -177,7 +178,7 @@ int phy_getintvar(phy_info_t *pi, const char *name) if (val == NULL) return 0; - return bcm_strtoul(val, NULL, 0); + return simple_strtoul(val, NULL, 0); } void wlc_phyreg_enter(wlc_phy_t *pih) diff --git a/drivers/staging/brcm80211/sys/wl_mac80211.c b/drivers/staging/brcm80211/sys/wl_mac80211.c index 71bd463..5400360 100644 --- a/drivers/staging/brcm80211/sys/wl_mac80211.c +++ b/drivers/staging/brcm80211/sys/wl_mac80211.c @@ -1639,7 +1639,7 @@ static int __init wl_module_init(void) else { char *var = getvar(NULL, "wl_msglevel"); if (var) - wl_msg_level = bcm_strtoul(var, NULL, 0); + wl_msg_level = simple_strtoul(var, NULL, 0); } #ifndef WLC_HIGH_ONLY { @@ -1650,7 +1650,7 @@ static int __init wl_module_init(void) else { char *var = getvar(NULL, "phy_msglevel"); if (var) - phyhal_msg_level = bcm_strtoul(var, NULL, 0); + phyhal_msg_level = simple_strtoul(var, NULL, 0); } } #endif /* WLC_HIGH_ONLY */ diff --git a/drivers/staging/brcm80211/sys/wlc_bmac.c b/drivers/staging/brcm80211/sys/wlc_bmac.c index c22394d..eea1ffb 100644 --- a/drivers/staging/brcm80211/sys/wlc_bmac.c +++ b/drivers/staging/brcm80211/sys/wlc_bmac.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -760,12 +761,12 @@ BCMATTACHFN(wlc_bmac_attach) (wlc_info_t *wlc, uint16 vendor, uint16 device, var = getvar(vars, "vendid"); if (var) { - vendor = (uint16) bcm_strtoul(var, NULL, 0); + vendor = (uint16) simple_strtoul(var, NULL, 0); WL_ERROR(("Overriding vendor id = 0x%x\n", vendor)); } var = getvar(vars, "devid"); if (var) { - uint16 devid = (uint16) bcm_strtoul(var, NULL, 0); + uint16 devid = (uint16) simple_strtoul(var, NULL, 0); if (devid != 0xffff) { device = devid; WL_ERROR(("Overriding device id = 0x%x\n", diff --git a/drivers/staging/brcm80211/sys/wlc_mac80211.c b/drivers/staging/brcm80211/sys/wlc_mac80211.c index db9a7c2..1488a56 100644 --- a/drivers/staging/brcm80211/sys/wlc_mac80211.c +++ b/drivers/staging/brcm80211/sys/wlc_mac80211.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -75,8 +76,6 @@ #define W_REG(osh, r, v) RPC_WRITE_REG(osh, r, v) #endif -#include - /* * buffer length needed for wlc_format_ssid * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c index a295ecb..2637a53 100644 --- a/drivers/staging/brcm80211/util/bcmsrom.c +++ b/drivers/staging/brcm80211/util/bcmsrom.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1924,7 +1925,7 @@ BCMATTACHFN(initvars_srom_pci) (si_t *sih, void *curmap, char **vars, value = si_getdevpathvar(sih, "sromrev"); if (value) { - sromrev = (uint8) bcm_strtoul(value, NULL, 0); + sromrev = (uint8) simple_strtoul(value, NULL, 0); flash = TRUE; goto varscont; } diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index 3f521e9..cc548e0 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,8 +29,6 @@ #include #include -#include - #ifdef WLC_LOW /* nvram vars cache */ static char *nvram_vars; @@ -492,271 +492,13 @@ void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) return p; } -ulong BCMROMFN(bcm_strtoul) (char *cp, char **endp, uint base) -{ - ulong result, last_result = 0, value; - bool minus; - - minus = FALSE; - - while (isspace(*cp)) - cp++; - - if (cp[0] == '+') - cp++; - else if (cp[0] == '-') { - minus = TRUE; - cp++; - } - - if (base == 0) { - if (cp[0] == '0') { - if ((cp[1] == 'x') || (cp[1] == 'X')) { - base = 16; - cp = &cp[2]; - } else { - base = 8; - cp = &cp[1]; - } - } else - base = 10; - } else if (base == 16 && (cp[0] == '0') - && ((cp[1] == 'x') || (cp[1] == 'X'))) { - cp = &cp[2]; - } - - result = 0; - - while (isxdigit(*cp) && - (value = - isdigit(*cp) ? *cp - '0' : toupper(*cp) - 'A' + 10) < - base) { - result = result * base + value; - /* Detected overflow */ - if (result < last_result && !minus) - return (ulong) -1; - last_result = result; - cp++; - } - - if (minus) - result = (ulong) (-(long)result); - - if (endp) - *endp = (char *)cp; - - return result; -} - -int BCMROMFN(bcm_atoi) (char *s) -{ - return (int)bcm_strtoul(s, NULL, 10); -} - -/* return pointer to location of substring 'needle' in 'haystack' */ -char *BCMROMFN(bcmstrstr) (char *haystack, char *needle) -{ - int len, nlen; - int i; - - if ((haystack == NULL) || (needle == NULL)) - return haystack; - - nlen = strlen(needle); - len = strlen(haystack) - nlen + 1; - - for (i = 0; i < len; i++) - if (memcmp(needle, &haystack[i], nlen) == 0) - return &haystack[i]; - return NULL; -} - -char *BCMROMFN(bcmstrcat) (char *dest, const char *src) -{ - char *p; - - p = dest + strlen(dest); - - while ((*p++ = *src++) != '\0') - ; - - return dest; -} - -char *BCMROMFN(bcmstrncat) (char *dest, const char *src, uint size) -{ - char *endp; - char *p; - - p = dest + strlen(dest); - endp = p + size; - - while (p != endp && (*p++ = *src++) != '\0') - ; - - return dest; -} - -/**************************************************************************** -* Function: bcmstrtok -* -* Purpose: -* Tokenizes a string. This function is conceptually similiar to ANSI C strtok(), -* but allows strToken() to be used by different strings or callers at the same -* time. Each call modifies '*string' by substituting a NULL character for the -* first delimiter that is encountered, and updates 'string' to point to the char -* after the delimiter. Leading delimiters are skipped. -* -* Parameters: -* string (mod) Ptr to string ptr, updated by token. -* delimiters (in) Set of delimiter characters. -* tokdelim (out) Character that delimits the returned token. (May -* be set to NULL if token delimiter is not required). -* -* Returns: Pointer to the next token found. NULL when no more tokens are found. -***************************************************************************** -*/ -char *bcmstrtok(char **string, const char *delimiters, char *tokdelim) -{ - unsigned char *str; - unsigned long map[8]; - int count; - char *nextoken; - - if (tokdelim != NULL) { - /* Prime the token delimiter */ - *tokdelim = '\0'; - } - - /* Clear control map */ - for (count = 0; count < 8; count++) { - map[count] = 0; - } - - /* Set bits in delimiter table */ - do { - map[*delimiters >> 5] |= (1 << (*delimiters & 31)); - } while (*delimiters++); - - str = (unsigned char *)*string; - - /* Find beginning of token (skip over leading delimiters). Note that - * there is no token iff this loop sets str to point to the terminal - * null (*str == '\0') - */ - while (((map[*str >> 5] & (1 << (*str & 31))) && *str) || (*str == ' ')) { - str++; - } - - nextoken = (char *)str; - - /* Find the end of the token. If it is not the end of the string, - * put a null there. - */ - for (; *str; str++) { - if (map[*str >> 5] & (1 << (*str & 31))) { - if (tokdelim != NULL) { - *tokdelim = *str; - } - - *str++ = '\0'; - break; - } - } - - *string = (char *)str; - - /* Determine if a token has been found. */ - if (nextoken == (char *)str) { - return NULL; - } else { - return nextoken; - } -} - -#define xToLower(C) \ - ((C >= 'A' && C <= 'Z') ? (char)((int)C - (int)'A' + (int)'a') : C) - -/**************************************************************************** -* Function: bcmstricmp -* -* Purpose: Compare to strings case insensitively. -* -* Parameters: s1 (in) First string to compare. -* s2 (in) Second string to compare. -* -* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if -* t1 > t2, when ignoring case sensitivity. -***************************************************************************** -*/ -int bcmstricmp(const char *s1, const char *s2) -{ - char dc, sc; - - while (*s2 && *s1) { - dc = xToLower(*s1); - sc = xToLower(*s2); - if (dc < sc) - return -1; - if (dc > sc) - return 1; - s1++; - s2++; - } - - if (*s1 && !*s2) - return 1; - if (!*s1 && *s2) - return -1; - return 0; -} - -/**************************************************************************** -* Function: bcmstrnicmp -* -* Purpose: Compare to strings case insensitively, upto a max of 'cnt' -* characters. -* -* Parameters: s1 (in) First string to compare. -* s2 (in) Second string to compare. -* cnt (in) Max characters to compare. -* -* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if -* t1 > t2, when ignoring case sensitivity. -***************************************************************************** -*/ -int bcmstrnicmp(const char *s1, const char *s2, int cnt) -{ - char dc, sc; - - while (*s2 && *s1 && cnt) { - dc = xToLower(*s1); - sc = xToLower(*s2); - if (dc < sc) - return -1; - if (dc > sc) - return 1; - s1++; - s2++; - cnt--; - } - - if (!cnt) - return 0; - if (*s1 && !*s2) - return 1; - if (!*s1 && *s2) - return -1; - return 0; -} - /* parse a xx:xx:xx:xx:xx:xx format ethernet address */ int BCMROMFN(bcm_ether_atoe) (char *p, struct ether_addr *ea) { int i = 0; for (;;) { - ea->octet[i++] = (char)bcm_strtoul(p, &p, 16); + ea->octet[i++] = (char)simple_strtoul(p, &p, 16); if (!*p++ || i == 6) break; } @@ -820,7 +562,7 @@ int getintvar(char *vars, const char *name) if (val == NULL) return 0; - return bcm_strtoul(val, NULL, 0); + return simple_strtoul(val, NULL, 0); } int getintvararray(char *vars, const char *name, uint8 index) @@ -836,7 +578,7 @@ int getintvararray(char *vars, const char *name, uint8 index) /* table values are always separated by "," or " " */ while (*buf != '\0') { - val = bcm_strtoul(buf, &endp, 0); + val = simple_strtoul(buf, &endp, 0); if (i == index) { return val; } diff --git a/drivers/staging/brcm80211/util/bcmwifi.c b/drivers/staging/brcm80211/util/bcmwifi.c index cb41d10..b69c12b 100644 --- a/drivers/staging/brcm80211/util/bcmwifi.c +++ b/drivers/staging/brcm80211/util/bcmwifi.c @@ -17,12 +17,11 @@ #include #include +#include +#include #include -#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base)) #include -#include - /* Chanspec ASCII representation: * * digit [AB] [N] [UL] @@ -92,7 +91,7 @@ chanspec_t wf_chspec_aton(char *a) uint channel, band, bw, ctl_sb; char c; - channel = strtoul(a, &endp, 10); + channel = simple_strtoul(a, &endp, 10); /* check for no digits parsed */ if (endp == a) diff --git a/drivers/staging/brcm80211/util/hndpmu.c b/drivers/staging/brcm80211/util/hndpmu.c index daa0198..1db1b16 100644 --- a/drivers/staging/brcm80211/util/hndpmu.c +++ b/drivers/staging/brcm80211/util/hndpmu.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -663,13 +664,13 @@ static void si_pmu_res_masks(si_t *sih, uint32 * pmin, uint32 * pmax) val = getvar(NULL, "rmin"); if (val != NULL) { PMU_MSG(("Applying rmin=%s to min_mask\n", val)); - min_mask = (uint32) bcm_strtoul(val, NULL, 0); + min_mask = (uint32) simple_strtoul(val, NULL, 0); } /* Apply nvram override to max mask */ val = getvar(NULL, "rmax"); if (val != NULL) { PMU_MSG(("Applying rmax=%s to max_mask\n", val)); - max_mask = (uint32) bcm_strtoul(val, NULL, 0); + max_mask = (uint32) simple_strtoul(val, NULL, 0); } *pmin = min_mask; @@ -787,7 +788,7 @@ void BCMATTACHFN(si_pmu_res_init) (si_t *sih, osl_t *osh) val, i)); W_REG(osh, &cc->res_table_sel, (uint32) i); W_REG(osh, &cc->res_updn_timer, - (uint32) bcm_strtoul(val, NULL, 0)); + (uint32) simple_strtoul(val, NULL, 0)); } /* Program resource dependencies table */ @@ -838,7 +839,7 @@ void BCMATTACHFN(si_pmu_res_init) (si_t *sih, osl_t *osh) i)); W_REG(osh, &cc->res_table_sel, (uint32) i); W_REG(osh, &cc->res_dep_mask, - (uint32) bcm_strtoul(val, NULL, 0)); + (uint32) simple_strtoul(val, NULL, 0)); } /* Determine min/max rsrc masks */