From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: <linux-kernel@vger.kernel.org>
Cc: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>,
Geoff Levand <geoffrey.levand@am.sony.com>
Subject: [PATCHv2] drivers: net: optimize hex2bin()
Date: Tue, 2 Mar 2010 09:59:26 +0200 [thread overview]
Message-ID: <1267516766-25977-1-git-send-email-andy.shevchenko@gmail.com> (raw)
In-Reply-To: <4B8C485A.8000409@am.sony.com>
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Optimize hex2bin() function used in ps3_gelic_wireless.c. It requires to have
hex_to_bin() implementation introduced by starter patch [1] in series.
[1] http://patchwork.kernel.org/patch/81224/
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: Geoff Levand <geoffrey.levand@am.sony.com>
---
drivers/net/ps3_gelic_wireless.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 227b141..7c3d7f1 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -1394,23 +1394,20 @@ static int gelic_wl_get_mode(struct net_device *netdev,
static int hex2bin(u8 *str, u8 *bin, unsigned int len)
{
unsigned int i;
- static unsigned char *hex = "0123456789ABCDEF";
- unsigned char *p, *q;
- u8 tmp;
if (len != WPA_PSK_LEN * 2)
return -EINVAL;
for (i = 0; i < WPA_PSK_LEN * 2; i += 2) {
- p = strchr(hex, toupper(str[i]));
- q = strchr(hex, toupper(str[i + 1]));
- if (!p || !q) {
+ int h = hex_to_bin(str[i]);
+ int l = hex_to_bin(str[i+1]);
+
+ if ((h == -1) || (l == -1)) {
pr_info("%s: unconvertible PSK digit=%d\n",
__func__, i);
return -EINVAL;
}
- tmp = ((p - hex) << 4) + (q - hex);
- *bin++ = tmp;
+ *bin++ = (h << 4) + l;
}
return 0;
};
--
1.5.6.5
next prev parent reply other threads:[~2010-03-02 8:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-22 18:08 [PATCH 00/11] Introduce common hex_to_bin() helper Andy Shevchenko
2010-02-22 18:09 ` [PATCH 01/11] lib: introduce common method to convert hex digits Andy Shevchenko
2010-02-22 18:09 ` [PATCH 02/11] drivers: isdn: use new hex_to_bin() method Andy Shevchenko
2010-02-22 18:09 ` [PATCH 03/11] drivers: net: optimize hex2bin() Andy Shevchenko
2010-02-22 18:09 ` [PATCH 04/11] usb: atm: speedtch: use new hex_to_bin() method Andy Shevchenko
2010-02-22 18:09 ` [PATCH 05/11] drivers: net: " Andy Shevchenko
2010-02-22 18:09 ` [PATCH 06/11] " Andy Shevchenko
2010-02-22 18:09 ` [PATCH 07/11] sysctl: don't use own implementation of hex_to_bin() Andy Shevchenko
2010-02-22 18:09 ` [PATCH 08/11] staging: rt2860: use new hex_to_bin() method Andy Shevchenko
2010-02-22 18:09 ` [PATCH 09/11] fs: ldm: don't use own implementation of hex_to_bin() Andy Shevchenko
2010-02-22 18:09 ` [PATCH 10/11] drivers: wireless: use new hex_to_bin() method Andy Shevchenko
2010-02-22 18:09 ` [PATCH 11/11] drivers: acpi: don't use own implementation of hex_to_bin() Andy Shevchenko
2010-03-01 23:06 ` [PATCH 03/11] drivers: net: optimize hex2bin() Geoff Levand
2010-03-02 7:59 ` Andy Shevchenko [this message]
2010-03-02 16:04 ` [PATCHv2] " Geoff Levand
2010-03-03 22:02 ` Geoff Levand
2010-02-22 21:22 ` [PATCH 02/11] drivers: isdn: use new hex_to_bin() method Tilman Schmidt
2010-03-09 1:03 ` [PATCH 01/11] lib: introduce common method to convert hex digits Andy Shevchenko
2010-03-09 19:57 ` Andrew Morton
2010-04-22 8:39 ` Andy Shevchenko
2010-04-29 22:11 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1267516766-25977-1-git-send-email-andy.shevchenko@gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=ext-andriy.shevchenko@nokia.com \
--cc=geoffrey.levand@am.sony.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).