From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nicholas A. Bellinger" Subject: Re: [PATCH] target: simplify target_parse_naa_6h_vendor_specific() Date: Wed, 28 Sep 2011 14:04:59 -0700 Message-ID: <1317243899.27352.238.camel@haakon2.linux-iscsi.org> References: <1316413492.3622.91.camel@haakon2.linux-iscsi.org> <9d522de8482ec20816be2b68b2d37ab8406f6876.1316419814.git.andriy.shevchenko@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linux-iscsi.org ([67.23.28.174]:48559 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632Ab1I1VFE (ORCPT ); Wed, 28 Sep 2011 17:05:04 -0400 In-Reply-To: Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: Andy Shevchenko Cc: Andy Shevchenko , target-devel , linux-scsi On Tue, 2011-09-27 at 13:48 +0300, Andy Shevchenko wrote: > On Mon, Sep 19, 2011 at 11:11 AM, Andy Shevchenko > wrote: > > Signed-off-by: Andy Shevchenko > > Cc: Nicholas Bellinger > > --- > > drivers/target/target_core_cdb.c | 30 +++++++++++++----------------- > > 1 files changed, 13 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c > > index f04d4ef..b796115 100644 > > --- a/drivers/target/target_core_cdb.c > > +++ b/drivers/target/target_core_cdb.c > > @@ -24,7 +24,6 @@ > > */ > > > > #include > > -#include > > #include > > #include > > > > @@ -156,11 +155,12 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) > > } > > > > 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 *buf = buf_off; > > - int cnt = 0, next = 1; > > + int cnt; > > + bool next = true; > > + > > /* > > * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on > > * byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field > > @@ -169,20 +169,16 @@ 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 > > * per device uniqeness. > > */ > > - while (*p != '\0') { > > - if (cnt >= 13) > > - break; > > - if (!isxdigit(*p)) { > > - p++; > > + for (cnt = 0; *p && cnt < 13; next = !next) { > > + int val = hex_to_bin(*p++); > > + > > + if (val < 0) > > continue; > > - } > > - if (next != 0) { > > - buf[cnt++] |= hex_to_bin(*p++); > > - next = 0; > > - } else { > > - buf[cnt] = hex_to_bin(*p++) << 4; > > - next = 1; > > - } > > + > > + if (next) > > + buf[cnt++] |= val; > > + else > > + buf[cnt] = val << 4; > > } > > } > > > > Nicholas, any comment on this? > Hi Andy, This simplification is fine with me, and will plan to queue this for v3.2. Thanks again! --nab