[PATCH] Replace drivers/net/wan custom ctype macros with standard ones
Replace the custom is_digit()/is_hex_digit() macros with isdigit()/isxdigit() from <linux/ctype.h> Additionaly remove unused macro is_alpha() from <linux/wanpipe.h> Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch> Cc: Jeff Garzik <jgarzik@pobox.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
parent
3173c8907f
commit
8e18d1f9c9
@ -78,6 +78,7 @@
|
|||||||
|
|
||||||
#define CYCLOMX_X25_DEBUG 1
|
#define CYCLOMX_X25_DEBUG 1
|
||||||
|
|
||||||
|
#include <linux/ctype.h> /* isdigit() */
|
||||||
#include <linux/errno.h> /* return codes */
|
#include <linux/errno.h> /* return codes */
|
||||||
#include <linux/if_arp.h> /* ARPHRD_HWX25 */
|
#include <linux/if_arp.h> /* ARPHRD_HWX25 */
|
||||||
#include <linux/kernel.h> /* printk(), and other useful stuff */
|
#include <linux/kernel.h> /* printk(), and other useful stuff */
|
||||||
@ -418,7 +419,7 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
|
|||||||
|
|
||||||
/* Set channel timeouts (default if not specified) */
|
/* Set channel timeouts (default if not specified) */
|
||||||
chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90;
|
chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90;
|
||||||
} else if (is_digit(conf->addr[0])) { /* PVC */
|
} else if (isdigit(conf->addr[0])) { /* PVC */
|
||||||
s16 lcn = dec_to_uint(conf->addr, 0);
|
s16 lcn = dec_to_uint(conf->addr, 0);
|
||||||
|
|
||||||
if (lcn >= card->u.x.lo_pvc && lcn <= card->u.x.hi_pvc)
|
if (lcn >= card->u.x.lo_pvc && lcn <= card->u.x.hi_pvc)
|
||||||
@ -1531,7 +1532,7 @@ static unsigned dec_to_uint(u8 *str, int len)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
for (; len && is_digit(*str); ++str, --len)
|
for (; len && isdigit(*str); ++str, --len)
|
||||||
val = (val * 10) + (*str - (unsigned) '0');
|
val = (val * 10) + (*str - (unsigned) '0');
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
@ -822,7 +822,7 @@ static int new_if(struct wan_device* wandev, struct net_device* dev,
|
|||||||
chan->card = card;
|
chan->card = card;
|
||||||
|
|
||||||
/* verify media address */
|
/* verify media address */
|
||||||
if (is_digit(conf->addr[0])) {
|
if (isdigit(conf->addr[0])) {
|
||||||
|
|
||||||
dlci = dec_to_uint(conf->addr, 0);
|
dlci = dec_to_uint(conf->addr, 0);
|
||||||
|
|
||||||
@ -3456,7 +3456,7 @@ static unsigned int dec_to_uint (unsigned char* str, int len)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
for (val = 0; len && is_digit(*str); ++str, --len)
|
for (val = 0; len && isdigit(*str); ++str, --len)
|
||||||
val = (val * 10) + (*str - (unsigned)'0');
|
val = (val * 10) + (*str - (unsigned)'0');
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
@ -957,7 +957,7 @@ static int new_if(struct wan_device* wandev, struct net_device* dev,
|
|||||||
chan->hold_timeout = (conf->hold_timeout) ?
|
chan->hold_timeout = (conf->hold_timeout) ?
|
||||||
conf->hold_timeout : 10;
|
conf->hold_timeout : 10;
|
||||||
|
|
||||||
}else if (is_digit(conf->addr[0])){ /* PVC */
|
}else if (isdigit(conf->addr[0])){ /* PVC */
|
||||||
int lcn = dec_to_uint(conf->addr, 0);
|
int lcn = dec_to_uint(conf->addr, 0);
|
||||||
|
|
||||||
if ((lcn >= card->u.x.lo_pvc) && (lcn <= card->u.x.hi_pvc)){
|
if ((lcn >= card->u.x.lo_pvc) && (lcn <= card->u.x.hi_pvc)){
|
||||||
@ -3875,7 +3875,7 @@ static unsigned int dec_to_uint (unsigned char* str, int len)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
for (val = 0; len && is_digit(*str); ++str, --len)
|
for (val = 0; len && isdigit(*str); ++str, --len)
|
||||||
val = (val * 10) + (*str - (unsigned)'0');
|
val = (val * 10) + (*str - (unsigned)'0');
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
@ -3896,9 +3896,9 @@ static unsigned int hex_to_uint (unsigned char* str, int len)
|
|||||||
for (val = 0; len; ++str, --len)
|
for (val = 0; len; ++str, --len)
|
||||||
{
|
{
|
||||||
ch = *str;
|
ch = *str;
|
||||||
if (is_digit(ch))
|
if (isdigit(ch))
|
||||||
val = (val << 4) + (ch - (unsigned)'0');
|
val = (val << 4) + (ch - (unsigned)'0');
|
||||||
else if (is_hex_digit(ch))
|
else if (isxdigit(ch))
|
||||||
val = (val << 4) + ((ch & 0xDF) - (unsigned)'A' + 10);
|
val = (val << 4) + ((ch & 0xDF) - (unsigned)'A' + 10);
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,6 @@
|
|||||||
#include <linux/cycx_x25.h>
|
#include <linux/cycx_x25.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
|
|
||||||
|
|
||||||
/* Adapter Data Space.
|
/* Adapter Data Space.
|
||||||
* This structure is needed because we handle multiple cards, otherwise
|
* This structure is needed because we handle multiple cards, otherwise
|
||||||
* static data would do it.
|
* static data would do it.
|
||||||
|
@ -265,15 +265,6 @@ typedef struct {
|
|||||||
#include <linux/tty_driver.h>
|
#include <linux/tty_driver.h>
|
||||||
#include <linux/tty_flip.h>
|
#include <linux/tty_flip.h>
|
||||||
|
|
||||||
|
|
||||||
#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
|
|
||||||
#define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
|
|
||||||
((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
|
|
||||||
#define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
|
|
||||||
((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
|
|
||||||
((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
|
|
||||||
|
|
||||||
|
|
||||||
/****** Data Structures *****************************************************/
|
/****** Data Structures *****************************************************/
|
||||||
|
|
||||||
/* Adapter Data Space.
|
/* Adapter Data Space.
|
||||||
|
Loading…
Reference in New Issue
Block a user