diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2011-09-19 04:11:21 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:20:41 -0400 |
commit | b6b4e61ff4e26d6721b2607ea23402825a38c402 (patch) | |
tree | 4bff0e5f62a908ae864e71df59b8c0bd205712fa /drivers/target | |
parent | 39c05f321a4b27f3036392eed68bd94ce2267155 (diff) |
target: simplify target_parse_naa_6h_vendor_specific()
This patch adds a minor simplfication in target_parse_naa_6h_vendor_specific()
to remove direct isxdigit() + ctype.h usage.
(nab: Fix next assignment breakage in for loop)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_cdb.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index f04d4ef99dc..0d02391d1fb 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/ctype.h> | ||
28 | #include <asm/unaligned.h> | 27 | #include <asm/unaligned.h> |
29 | #include <scsi/scsi.h> | 28 | #include <scsi/scsi.h> |
30 | 29 | ||
@@ -156,11 +155,12 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) | |||
156 | } | 155 | } |
157 | 156 | ||
158 | static void | 157 | static void |
159 | target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf_off) | 158 | target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf) |
160 | { | 159 | { |
161 | unsigned char *p = &dev->se_sub_dev->t10_wwn.unit_serial[0]; | 160 | unsigned char *p = &dev->se_sub_dev->t10_wwn.unit_serial[0]; |
162 | unsigned char *buf = buf_off; | 161 | int cnt; |
163 | int cnt = 0, next = 1; | 162 | bool next = true; |
163 | |||
164 | /* | 164 | /* |
165 | * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on | 165 | * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on |
166 | * byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field | 166 | * byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field |
@@ -169,19 +169,18 @@ target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf_of | |||
169 | * NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure | 169 | * NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure |
170 | * per device uniqeness. | 170 | * per device uniqeness. |
171 | */ | 171 | */ |
172 | while (*p != '\0') { | 172 | for (cnt = 0; *p && cnt < 13; p++) { |
173 | if (cnt >= 13) | 173 | int val = hex_to_bin(*p); |
174 | break; | 174 | |
175 | if (!isxdigit(*p)) { | 175 | if (val < 0) |
176 | p++; | ||
177 | continue; | 176 | continue; |
178 | } | 177 | |
179 | if (next != 0) { | 178 | if (next) { |
180 | buf[cnt++] |= hex_to_bin(*p++); | 179 | next = false; |
181 | next = 0; | 180 | buf[cnt++] |= val; |
182 | } else { | 181 | } else { |
183 | buf[cnt] = hex_to_bin(*p++) << 4; | 182 | next = true; |
184 | next = 1; | 183 | buf[cnt] = val << 4; |
185 | } | 184 | } |
186 | } | 185 | } |
187 | } | 186 | } |