Commit b6b4e61f authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Nicholas Bellinger

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 39c05f32
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/ctype.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
...@@ -156,11 +155,12 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) ...@@ -156,11 +155,12 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
} }
static void static void
target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf_off) target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf)
{ {
unsigned char *p = &dev->se_sub_dev->t10_wwn.unit_serial[0]; unsigned char *p = &dev->se_sub_dev->t10_wwn.unit_serial[0];
unsigned char *buf = buf_off; int cnt;
int cnt = 0, next = 1; bool next = true;
/* /*
* Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on
* byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field * 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,19 +169,18 @@ target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf_of
* NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure * NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure
* per device uniqeness. * per device uniqeness.
*/ */
while (*p != '\0') { for (cnt = 0; *p && cnt < 13; p++) {
if (cnt >= 13) int val = hex_to_bin(*p);
break;
if (!isxdigit(*p)) { if (val < 0)
p++;
continue; continue;
}
if (next != 0) { if (next) {
buf[cnt++] |= hex_to_bin(*p++); next = false;
next = 0; buf[cnt++] |= val;
} else { } else {
buf[cnt] = hex_to_bin(*p++) << 4; next = true;
next = 1; buf[cnt] = val << 4;
} }
} }
} }
......
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