Skip to content

Commit

Permalink
staging: brcm80211: use native ctype library
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Sep 16, 2010
1 parent a7b47b9 commit 3fb4e3d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 79 deletions.
27 changes: 0 additions & 27 deletions drivers/staging/brcm80211/include/bcmutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion drivers/staging/brcm80211/sys/wlc_mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#define W_REG(osh, r, v) RPC_WRITE_REG(osh, r, v)
#endif

#include <linux/ctype.h>

/*
* buffer length needed for wlc_format_ssid
* 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL.
Expand Down Expand Up @@ -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);
Expand Down
56 changes: 6 additions & 50 deletions drivers/staging/brcm80211/util/bcmutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <proto/802.1d.h>
#include <proto/802.11.h>

#include <linux/ctype.h>

#ifdef WLC_LOW
/* nvram vars cache */
static char *nvram_vars;
Expand Down Expand Up @@ -490,60 +492,14 @@ 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;
bool minus;

minus = FALSE;

while (bcm_isspace(*cp))
while (isspace(*cp))
cp++;

if (cp[0] == '+')
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/brcm80211/util/bcmwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include <osl.h>
#include <bcmutils.h>
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))
#include <bcmwifi.h>

#include <linux/ctype.h>

/* Chanspec ASCII representation:
* <channel><band><bandwidth><ctl-sideband>
* digit [AB] [N] [UL]
Expand Down

0 comments on commit 3fb4e3d

Please sign in to comment.