All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] remove custom implementation of hex_to_bin()
@ 2010-07-23 13:18 Andy Shevchenko
  2010-07-23 13:18 ` [PATCH 1/5] drivers: atm: don't use private copy " Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel; +Cc: Andy Shevchenko

Remove custom implementation of recently introduced hex_to_bin() method. All
changes related to the network subsystem in the kernel.

Andy Shevchenko (5):
  drivers: atm: don't use private copy of hex_to_bin()
  drivers: net: use newly introduced hex_to_bin()
  usb: usbnet: use newly introduced hex_to_bin()
  wireless: use newly introduced hex_to_bin()
  net: core: don't use own hex_to_bin() method

 drivers/atm/nicstar.c         |   15 ++-------------
 drivers/net/ksz884x.c         |   11 +++++------
 drivers/net/usb/usbnet.c      |   13 ++-----------
 drivers/net/wireless/ray_cs.c |   23 ++---------------------
 net/core/pktgen.c             |   36 ++++++++++++------------------------
 5 files changed, 23 insertions(+), 75 deletions(-)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] drivers: atm: don't use private copy of hex_to_bin()
  2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
@ 2010-07-23 13:18 ` Andy Shevchenko
  2010-07-23 19:51   ` David Miller
  2010-07-23 13:18 ` [PATCH 2/5] drivers: net: use newly introduced hex_to_bin() Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel
  Cc: Andy Shevchenko, Chas Williams, linux-atm-general

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Chas Williams <chas@cmf.nrl.navy.mil>
Cc: linux-atm-general@lists.sourceforge.net
---
 drivers/atm/nicstar.c |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 729a149..2f3516b 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -154,7 +154,6 @@ static void which_list(ns_dev * card, struct sk_buff *skb);
 #endif
 static void ns_poll(unsigned long arg);
 static int ns_parse_mac(char *mac, unsigned char *esi);
-static short ns_h2i(char c);
 static void ns_phy_put(struct atm_dev *dev, unsigned char value,
 		       unsigned long addr);
 static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr);
@@ -2824,9 +2823,9 @@ static int ns_parse_mac(char *mac, unsigned char *esi)
 		return -1;
 	j = 0;
 	for (i = 0; i < 6; i++) {
-		if ((byte1 = ns_h2i(mac[j++])) < 0)
+		if ((byte1 = hex_to_bin(mac[j++])) < 0)
 			return -1;
-		if ((byte0 = ns_h2i(mac[j++])) < 0)
+		if ((byte0 = hex_to_bin(mac[j++])) < 0)
 			return -1;
 		esi[i] = (unsigned char)(byte1 * 16 + byte0);
 		if (i < 5) {
@@ -2837,16 +2836,6 @@ static int ns_parse_mac(char *mac, unsigned char *esi)
 	return 0;
 }
 
-static short ns_h2i(char c)
-{
-	if (c >= '0' && c <= '9')
-		return (short)(c - '0');
-	if (c >= 'A' && c <= 'F')
-		return (short)(c - 'A' + 10);
-	if (c >= 'a' && c <= 'f')
-		return (short)(c - 'a' + 10);
-	return -1;
-}
 
 static void ns_phy_put(struct atm_dev *dev, unsigned char value,
 		       unsigned long addr)
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] drivers: net: use newly introduced hex_to_bin()
  2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
  2010-07-23 13:18 ` [PATCH 1/5] drivers: atm: don't use private copy " Andy Shevchenko
@ 2010-07-23 13:18 ` Andy Shevchenko
  2010-07-23 19:51   ` David Miller
  2010-07-23 13:18 ` [PATCH 3/5] usb: usbnet: " Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel; +Cc: Andy Shevchenko

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/net/ksz884x.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 1d998e1..37504a3 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -6894,13 +6894,12 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port)
 	i = j = num = got_num = 0;
 	while (j < MAC_ADDR_LEN) {
 		if (macaddr[i]) {
+			int digit;
+
 			got_num = 1;
-			if ('0' <= macaddr[i] && macaddr[i] <= '9')
-				num = num * 16 + macaddr[i] - '0';
-			else if ('A' <= macaddr[i] && macaddr[i] <= 'F')
-				num = num * 16 + 10 + macaddr[i] - 'A';
-			else if ('a' <= macaddr[i] && macaddr[i] <= 'f')
-				num = num * 16 + 10 + macaddr[i] - 'a';
+			digit = hex_to_bin(macaddr[i]);
+			if (digit >= 0)
+				num = num * 16 + digit;
 			else if (':' == macaddr[i])
 				got_num = 2;
 			else
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] usb: usbnet: use newly introduced hex_to_bin()
  2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
  2010-07-23 13:18 ` [PATCH 1/5] drivers: atm: don't use private copy " Andy Shevchenko
  2010-07-23 13:18 ` [PATCH 2/5] drivers: net: use newly introduced hex_to_bin() Andy Shevchenko
@ 2010-07-23 13:18 ` Andy Shevchenko
  2010-07-23 19:51   ` David Miller
  2010-07-23 13:18 ` [PATCH 4/5] wireless: " Andy Shevchenko
  2010-07-23 13:18 ` [PATCH 5/5] net: core: don't use own hex_to_bin() method Andy Shevchenko
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel
  Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-usb

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-usb@vger.kernel.org
---
 drivers/net/usb/usbnet.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 7eab407..f5e1639 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -44,6 +44,7 @@
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
 #include <linux/slab.h>
+#include <linux/kernel.h>
 
 #define DRIVER_VERSION		"22-Aug-2005"
 
@@ -158,16 +159,6 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
 }
 EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
 
-static u8 nibble(unsigned char c)
-{
-	if (likely(isdigit(c)))
-		return c - '0';
-	c = toupper(c);
-	if (likely(isxdigit(c)))
-		return 10 + c - 'A';
-	return 0;
-}
-
 int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
 {
 	int 		tmp, i;
@@ -183,7 +174,7 @@ int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
 	}
 	for (i = tmp = 0; i < 6; i++, tmp += 2)
 		dev->net->dev_addr [i] =
-			(nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
+			(hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] wireless: use newly introduced hex_to_bin()
  2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2010-07-23 13:18 ` [PATCH 3/5] usb: usbnet: " Andy Shevchenko
@ 2010-07-23 13:18 ` Andy Shevchenko
  2010-07-26 18:27   ` John W. Linville
  2010-07-23 13:18 ` [PATCH 5/5] net: core: don't use own hex_to_bin() method Andy Shevchenko
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel
  Cc: Andy Shevchenko, Corey Thomas, John W. Linville, linux-wireless

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Corey Thomas <coreythomas@charter.net>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
---
 drivers/net/wireless/ray_cs.c |   23 ++---------------------
 1 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index abff893..9c38fc3 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -97,7 +97,6 @@ static iw_stats *ray_get_wireless_stats(struct net_device *dev);
 static const struct iw_handler_def ray_handler_def;
 
 /***** Prototypes for raylink functions **************************************/
-static int asc_to_int(char a);
 static void authenticate(ray_dev_t *local);
 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type);
 static void authenticate_timeout(u_long);
@@ -1717,24 +1716,6 @@ static void authenticate_timeout(u_long data)
 }
 
 /*===========================================================================*/
-static int asc_to_int(char a)
-{
-	if (a < '0')
-		return -1;
-	if (a <= '9')
-		return (a - '0');
-	if (a < 'A')
-		return -1;
-	if (a <= 'F')
-		return (10 + a - 'A');
-	if (a < 'a')
-		return -1;
-	if (a <= 'f')
-		return (10 + a - 'a');
-	return -1;
-}
-
-/*===========================================================================*/
 static int parse_addr(char *in_str, UCHAR *out)
 {
 	int len;
@@ -1754,14 +1735,14 @@ static int parse_addr(char *in_str, UCHAR *out)
 	i = 5;
 
 	while (j > 0) {
-		if ((k = asc_to_int(in_str[j--])) != -1)
+		if ((k = hex_to_bin(in_str[j--])) != -1)
 			out[i] = k;
 		else
 			return 0;
 
 		if (j == 0)
 			break;
-		if ((k = asc_to_int(in_str[j--])) != -1)
+		if ((k = hex_to_bin(in_str[j--])) != -1)
 			out[i] += k << 4;
 		else
 			return 0;
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] net: core: don't use own hex_to_bin() method
  2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
                   ` (3 preceding siblings ...)
  2010-07-23 13:18 ` [PATCH 4/5] wireless: " Andy Shevchenko
@ 2010-07-23 13:18 ` Andy Shevchenko
  2010-07-23 19:51   ` David Miller
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2010-07-23 13:18 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel; +Cc: Andy Shevchenko

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 net/core/pktgen.c |   36 ++++++++++++------------------------
 1 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 24a19de..10a1ea7 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1434,18 +1434,12 @@ static ssize_t pktgen_if_write(struct file *file,
 		i += len;
 
 		for (*m = 0; *v && m < pkt_dev->dst_mac + 6; v++) {
-			if (*v >= '0' && *v <= '9') {
-				*m *= 16;
-				*m += *v - '0';
-			}
-			if (*v >= 'A' && *v <= 'F') {
-				*m *= 16;
-				*m += *v - 'A' + 10;
-			}
-			if (*v >= 'a' && *v <= 'f') {
-				*m *= 16;
-				*m += *v - 'a' + 10;
-			}
+			int value;
+
+			value = hex_to_bin(*v);
+			if (value >= 0)
+				*m = *m * 16 + value;
+
 			if (*v == ':') {
 				m++;
 				*m = 0;
@@ -1476,18 +1470,12 @@ static ssize_t pktgen_if_write(struct file *file,
 		i += len;
 
 		for (*m = 0; *v && m < pkt_dev->src_mac + 6; v++) {
-			if (*v >= '0' && *v <= '9') {
-				*m *= 16;
-				*m += *v - '0';
-			}
-			if (*v >= 'A' && *v <= 'F') {
-				*m *= 16;
-				*m += *v - 'A' + 10;
-			}
-			if (*v >= 'a' && *v <= 'f') {
-				*m *= 16;
-				*m += *v - 'a' + 10;
-			}
+			int value;
+
+			value = hex_to_bin(*v);
+			if (value >= 0)
+				*m = *m * 16 + value;
+
 			if (*v == ':') {
 				m++;
 				*m = 0;
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] drivers: atm: don't use private copy of hex_to_bin()
  2010-07-23 13:18 ` [PATCH 1/5] drivers: atm: don't use private copy " Andy Shevchenko
@ 2010-07-23 19:51   ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2010-07-23 19:51 UTC (permalink / raw)
  To: andy.shevchenko; +Cc: netdev, linux-kernel, chas, linux-atm-general

From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Fri, 23 Jul 2010 16:18:06 +0300

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] drivers: net: use newly introduced hex_to_bin()
  2010-07-23 13:18 ` [PATCH 2/5] drivers: net: use newly introduced hex_to_bin() Andy Shevchenko
@ 2010-07-23 19:51   ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2010-07-23 19:51 UTC (permalink / raw)
  To: andy.shevchenko; +Cc: netdev, linux-kernel

From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Fri, 23 Jul 2010 16:18:07 +0300

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] usb: usbnet: use newly introduced hex_to_bin()
  2010-07-23 13:18 ` [PATCH 3/5] usb: usbnet: " Andy Shevchenko
@ 2010-07-23 19:51   ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2010-07-23 19:51 UTC (permalink / raw)
  To: andy.shevchenko; +Cc: netdev, linux-kernel, gregkh, linux-usb

From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Fri, 23 Jul 2010 16:18:08 +0300

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] net: core: don't use own hex_to_bin() method
  2010-07-23 13:18 ` [PATCH 5/5] net: core: don't use own hex_to_bin() method Andy Shevchenko
@ 2010-07-23 19:51   ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2010-07-23 19:51 UTC (permalink / raw)
  To: andy.shevchenko; +Cc: netdev, linux-kernel

From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Fri, 23 Jul 2010 16:18:10 +0300

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] wireless: use newly introduced hex_to_bin()
  2010-07-23 13:18 ` [PATCH 4/5] wireless: " Andy Shevchenko
@ 2010-07-26 18:27   ` John W. Linville
  0 siblings, 0 replies; 11+ messages in thread
From: John W. Linville @ 2010-07-26 18:27 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: David S. Miller, netdev, linux-kernel, Corey Thomas, linux-wireless

On Fri, Jul 23, 2010 at 04:18:09PM +0300, Andy Shevchenko wrote:
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Corey Thomas <coreythomas@charter.net>
> Cc: "John W. Linville" <linville@tuxdriver.com>
> Cc: linux-wireless@vger.kernel.org

Acked-by: John W. Linville <linville@tuxdriver.com>

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-07-26 18:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 13:18 [PATCH 0/5] remove custom implementation of hex_to_bin() Andy Shevchenko
2010-07-23 13:18 ` [PATCH 1/5] drivers: atm: don't use private copy " Andy Shevchenko
2010-07-23 19:51   ` David Miller
2010-07-23 13:18 ` [PATCH 2/5] drivers: net: use newly introduced hex_to_bin() Andy Shevchenko
2010-07-23 19:51   ` David Miller
2010-07-23 13:18 ` [PATCH 3/5] usb: usbnet: " Andy Shevchenko
2010-07-23 19:51   ` David Miller
2010-07-23 13:18 ` [PATCH 4/5] wireless: " Andy Shevchenko
2010-07-26 18:27   ` John W. Linville
2010-07-23 13:18 ` [PATCH 5/5] net: core: don't use own hex_to_bin() method Andy Shevchenko
2010-07-23 19:51   ` David Miller

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.