From patchwork Wed Sep 15 09:47:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 182132 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 o8F9mh7s009918 for ; Wed, 15 Sep 2010 09:48:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681Ab0IOJrj (ORCPT ); Wed, 15 Sep 2010 05:47:39 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:56275 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750695Ab0IOJrh (ORCPT ); Wed, 15 Sep 2010 05:47:37 -0400 Received: by ewy23 with SMTP id 23so2542ewy.19 for ; Wed, 15 Sep 2010 02:47:36 -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; bh=G4NuTJMLNnCIf3AVCiVHZYBILlU1L9DU3AD2iU3jDFo=; b=prfDy8AUCiu1yXXeL/3EgHpvNnqAyczD0ToTtDXxo1v/m4HYc8vrB2D9rqlHS0JDMw PWt5CHblJnw4S/9l7DvbcoTT/sPy1igVg+1JcL2teDBKGhImpCIAGSk4Oc1+/c6tE4vj xzhtYbEOkWglPNH/RMIOGHJjx7C7I0oqdI668= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Gvr/3rZVuL9J4puysHmp+WfD+qESv4oA91C6p05b20Cd/ZCSfS8WmljqFQ9bEqxsZF VZ9VIzpV1LeOS8Ch/cWQLgqp7BgZwpyes5hqId2iE0xgs7243FbhpsC/6jJRlH03iL89 in/coPeTqHzzNioU/qkxqW1PRwrvLLFDjZXi4= Received: by 10.213.20.78 with SMTP id e14mr913273ebb.13.1284544056011; Wed, 15 Sep 2010 02:47:36 -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.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Sep 2010 02:47:35 -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 1/2] staging: brcm80211: use native ctype library Date: Wed, 15 Sep 2010 12:47:17 +0300 Message-Id: <1284544038-5696-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.7.2.2 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 321071b..f17dbb1 100644 --- a/drivers/staging/brcm80211/include/bcmutils.h +++ b/drivers/staging/brcm80211/include/bcmutils.h @@ -21,33 +21,6 @@ extern "C" { #endif -/* ctype replacement */ -#define _BCM_U 0x01 /* upper */ -#define _BCM_L 0x02 /* lower */ -#define _BCM_D 0x04 /* digit */ -#define _BCM_C 0x08 /* cntrl */ -#define _BCM_P 0x10 /* punct */ -#define _BCM_S 0x20 /* white space (space/lf/tab) */ -#define _BCM_X 0x40 /* hex digit */ -#define _BCM_SP 0x80 /* hard space (0x20) */ - - extern const unsigned char bcm_ctype[]; -#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)]) - -#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0) -#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0) -#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0) -#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0) -#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0) -#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0) -#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0) -#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0) -#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0) -#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0) -#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0) -#define bcm_tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c)) -#define bcm_toupper(c) (bcm_islower((c)) ? ((c) + 'A' - 'a') : (c)) - /* Buffer structure for collecting string-formatted data * using bcm_bprintf() API. * Use bcm_binit() to initialize before use diff --git a/drivers/staging/brcm80211/sys/wlc_mac80211.c b/drivers/staging/brcm80211/sys/wlc_mac80211.c index 27ddc23..db9a7c2 100644 --- a/drivers/staging/brcm80211/sys/wlc_mac80211.c +++ b/drivers/staging/brcm80211/sys/wlc_mac80211.c @@ -75,6 +75,8 @@ #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. @@ -5486,7 +5488,7 @@ int wlc_format_ssid(char *buf, const uchar ssid[], uint ssid_len) if (c == '\\') { *p++ = '\\'; *p++ = '\\'; - } else if (bcm_isprint((uchar) c)) { + } else if (isprint((uchar) c)) { *p++ = (char)c; } else { p += snprintf(p, (endp - p), "\\x%02X", c); diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index 9505064..3f521e9 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -27,6 +27,8 @@ #include #include +#include + #ifdef WLC_LOW /* nvram vars cache */ static char *nvram_vars; @@ -490,52 +492,6 @@ void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) return p; } -const unsigned char bcm_ctype[] = { - - _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, /* 0-7 */ - _BCM_C, _BCM_C | _BCM_S, _BCM_C | _BCM_S, _BCM_C | _BCM_S, - _BCM_C | _BCM_S, _BCM_C | _BCM_S, _BCM_C, - _BCM_C, /* 8-15 */ - _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, /* 16-23 */ - _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, _BCM_C, /* 24-31 */ - _BCM_S | _BCM_SP, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 32-39 */ - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 40-47 */ - _BCM_D, _BCM_D, _BCM_D, _BCM_D, _BCM_D, _BCM_D, _BCM_D, _BCM_D, /* 48-55 */ - _BCM_D, _BCM_D, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 56-63 */ - _BCM_P, _BCM_U | _BCM_X, _BCM_U | _BCM_X, _BCM_U | _BCM_X, - _BCM_U | _BCM_X, _BCM_U | _BCM_X, - _BCM_U | _BCM_X, _BCM_U, /* 64-71 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 72-79 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 80-87 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 88-95 */ - _BCM_P, _BCM_L | _BCM_X, _BCM_L | _BCM_X, _BCM_L | _BCM_X, - _BCM_L | _BCM_X, _BCM_L | _BCM_X, - _BCM_L | _BCM_X, _BCM_L, /* 96-103 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 104-111 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 112-119 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_C, /* 120-127 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128-143 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144-159 */ - _BCM_S | _BCM_SP, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, - _BCM_P, _BCM_P, _BCM_P, - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 160-175 */ - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, - _BCM_P, _BCM_P, - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 176-191 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, - _BCM_U, _BCM_U, - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 192-207 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_P, _BCM_U, - _BCM_U, _BCM_U, - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_L, /* 208-223 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, - _BCM_L, _BCM_L, - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 224-239 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_P, _BCM_L, - _BCM_L, _BCM_L, - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L /* 240-255 */ -}; - ulong BCMROMFN(bcm_strtoul) (char *cp, char **endp, uint base) { ulong result, last_result = 0, value; @@ -543,7 +499,7 @@ ulong BCMROMFN(bcm_strtoul) (char *cp, char **endp, uint base) minus = FALSE; - while (bcm_isspace(*cp)) + while (isspace(*cp)) cp++; if (cp[0] == '+') @@ -571,9 +527,9 @@ ulong BCMROMFN(bcm_strtoul) (char *cp, char **endp, uint base) result = 0; - while (bcm_isxdigit(*cp) && + while (isxdigit(*cp) && (value = - bcm_isdigit(*cp) ? *cp - '0' : bcm_toupper(*cp) - 'A' + 10) < + isdigit(*cp) ? *cp - '0' : toupper(*cp) - 'A' + 10) < base) { result = result * base + value; /* Detected overflow */ @@ -1775,7 +1731,7 @@ int bcm_format_ssid(char *buf, const uchar ssid[], uint ssid_len) if (c == '\\') { *p++ = '\\'; *p++ = '\\'; - } else if (bcm_isprint((uchar) c)) { + } else if (isprint((uchar) c)) { *p++ = (char)c; } else { p += snprintf(p, (endp - p), "\\x%02X", c); diff --git a/drivers/staging/brcm80211/util/bcmwifi.c b/drivers/staging/brcm80211/util/bcmwifi.c index 5eced8e..cb41d10 100644 --- a/drivers/staging/brcm80211/util/bcmwifi.c +++ b/drivers/staging/brcm80211/util/bcmwifi.c @@ -19,9 +19,10 @@ #include #include #define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base)) -#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c)) #include +#include + /* Chanspec ASCII representation: * * digit [AB] [N] [UL]