Commit 5680db4b authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Linus Torvalds

vfat: deduplicate hex2bin()

We may use hex2bin() instead of custom approach.

Link: http://lkml.kernel.org/r/87zibktpil.fsf@devronSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b9fa2ad1
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/kernel.h>
#include "fat.h" #include "fat.h"
static inline unsigned long vfat_d_version(struct dentry *dentry) static inline unsigned long vfat_d_version(struct dentry *dentry)
...@@ -510,10 +512,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -510,10 +512,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
struct nls_table *nls) struct nls_table *nls)
{ {
const unsigned char *ip; const unsigned char *ip;
unsigned char nc;
unsigned char *op; unsigned char *op;
unsigned int ec; int i, fill;
int i, k, fill;
int charlen; int charlen;
if (utf8) { if (utf8) {
...@@ -530,28 +530,17 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -530,28 +530,17 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
i < len && *outlen < FAT_LFN_LEN; i < len && *outlen < FAT_LFN_LEN;
*outlen += 1) { *outlen += 1) {
if (escape && (*ip == ':')) { if (escape && (*ip == ':')) {
u8 uc[2];
if (i > len - 5) if (i > len - 5)
return -EINVAL; return -EINVAL;
ec = 0;
for (k = 1; k < 5; k++) { if (hex2bin(uc, ip + 1, 2) < 0)
nc = ip[k];
ec <<= 4;
if (nc >= '0' && nc <= '9') {
ec |= nc - '0';
continue;
}
if (nc >= 'a' && nc <= 'f') {
ec |= nc - ('a' - 10);
continue;
}
if (nc >= 'A' && nc <= 'F') {
ec |= nc - ('A' - 10);
continue;
}
return -EINVAL; return -EINVAL;
}
*op++ = ec & 0xFF; *(wchar_t *)op = uc[0] << 8 | uc[1];
*op++ = ec >> 8;
op += 2;
ip += 5; ip += 5;
i += 5; i += 5;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment