提交 11650b85 编写于 作者: A Andy Shevchenko 提交者: Nicholas Bellinger

target: remove custom hex2bin() implementation

This patch drops transport_asciihex_to_binaryhex() in favor of proper
hex2bin usage from include/linux/kernel.h:hex2bin()
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 163cd5fa
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <linux/kernel.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
...@@ -162,11 +163,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -162,11 +163,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
struct t10_alua_lu_gp_member *lu_gp_mem; struct t10_alua_lu_gp_member *lu_gp_mem;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
unsigned char binary, binary_new;
unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0]; unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0];
u32 prod_len; u32 prod_len;
u32 unit_serial_len, off = 0; u32 unit_serial_len, off = 0;
int i;
u16 len = 0, id_len; u16 len = 0, id_len;
off = 4; off = 4;
...@@ -215,16 +214,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -215,16 +214,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
* VENDOR_SPECIFIC_IDENTIFIER and * VENDOR_SPECIFIC_IDENTIFIER and
* VENDOR_SPECIFIC_IDENTIFIER_EXTENTION * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
*/ */
binary = transport_asciihex_to_binaryhex( buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]);
&dev->se_sub_dev->t10_wwn.unit_serial[0]); hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
buf[off++] |= (binary & 0xf0) >> 4;
for (i = 0; i < 24; i += 2) {
binary_new = transport_asciihex_to_binaryhex(
&dev->se_sub_dev->t10_wwn.unit_serial[i+2]);
buf[off] = (binary & 0x0f) << 4;
buf[off++] |= (binary_new & 0xf0) >> 4;
binary = binary_new;
}
len = 20; len = 20;
off = (len + 4); off = (len + 4);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* *
******************************************************************************/ ******************************************************************************/
#include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -61,9 +62,8 @@ u32 sas_get_pr_transport_id( ...@@ -61,9 +62,8 @@ u32 sas_get_pr_transport_id(
int *format_code, int *format_code,
unsigned char *buf) unsigned char *buf)
{ {
unsigned char binary, *ptr; unsigned char *ptr;
int i;
u32 off = 4;
/* /*
* Set PROTOCOL IDENTIFIER to 6h for SAS * Set PROTOCOL IDENTIFIER to 6h for SAS
*/ */
...@@ -74,10 +74,8 @@ u32 sas_get_pr_transport_id( ...@@ -74,10 +74,8 @@ u32 sas_get_pr_transport_id(
*/ */
ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */ ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */
for (i = 0; i < 16; i += 2) { hex2bin(&buf[4], ptr, 8);
binary = transport_asciihex_to_binaryhex(&ptr[i]);
buf[off++] = binary;
}
/* /*
* The SAS Transport ID is a hardcoded 24-byte length * The SAS Transport ID is a hardcoded 24-byte length
*/ */
...@@ -157,7 +155,7 @@ u32 fc_get_pr_transport_id( ...@@ -157,7 +155,7 @@ u32 fc_get_pr_transport_id(
int *format_code, int *format_code,
unsigned char *buf) unsigned char *buf)
{ {
unsigned char binary, *ptr; unsigned char *ptr;
int i; int i;
u32 off = 8; u32 off = 8;
/* /*
...@@ -176,8 +174,7 @@ u32 fc_get_pr_transport_id( ...@@ -176,8 +174,7 @@ u32 fc_get_pr_transport_id(
i++; i++;
continue; continue;
} }
binary = transport_asciihex_to_binaryhex(&ptr[i]); hex2bin(&buf[off++], &ptr[i], 1);
buf[off++] = binary;
i += 2; i += 2;
} }
/* /*
......
...@@ -2659,34 +2659,6 @@ static inline u32 transport_get_size( ...@@ -2659,34 +2659,6 @@ static inline u32 transport_get_size(
return dev->se_sub_dev->se_dev_attrib.block_size * sectors; return dev->se_sub_dev->se_dev_attrib.block_size * sectors;
} }
unsigned char transport_asciihex_to_binaryhex(unsigned char val[2])
{
unsigned char result = 0;
/*
* MSB
*/
if ((val[0] >= 'a') && (val[0] <= 'f'))
result = ((val[0] - 'a' + 10) & 0xf) << 4;
else
if ((val[0] >= 'A') && (val[0] <= 'F'))
result = ((val[0] - 'A' + 10) & 0xf) << 4;
else /* digit */
result = ((val[0] - '0') & 0xf) << 4;
/*
* LSB
*/
if ((val[1] >= 'a') && (val[1] <= 'f'))
result |= ((val[1] - 'a' + 10) & 0xf);
else
if ((val[1] >= 'A') && (val[1] <= 'F'))
result |= ((val[1] - 'A' + 10) & 0xf);
else /* digit */
result |= ((val[1] - '0') & 0xf);
return result;
}
EXPORT_SYMBOL(transport_asciihex_to_binaryhex);
static void transport_xor_callback(struct se_cmd *cmd) static void transport_xor_callback(struct se_cmd *cmd)
{ {
unsigned char *buf, *addr; unsigned char *buf, *addr;
......
...@@ -179,7 +179,6 @@ extern void transport_new_cmd_failure(struct se_cmd *); ...@@ -179,7 +179,6 @@ extern void transport_new_cmd_failure(struct se_cmd *);
extern int transport_generic_handle_tmr(struct se_cmd *); extern int transport_generic_handle_tmr(struct se_cmd *);
extern void transport_generic_free_cmd_intr(struct se_cmd *); extern void transport_generic_free_cmd_intr(struct se_cmd *);
extern void __transport_stop_task_timer(struct se_task *, unsigned long *); extern void __transport_stop_task_timer(struct se_task *, unsigned long *);
extern unsigned char transport_asciihex_to_binaryhex(unsigned char val[2]);
extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32, extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32,
struct scatterlist *, u32); struct scatterlist *, u32);
extern int transport_clear_lun_from_sessions(struct se_lun *); extern int transport_clear_lun_from_sessions(struct se_lun *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册