Commit 11650b859681e03fdbf26277fcfc5f1f62186703
Committed by
Nicholas Bellinger
1 parent
163cd5fa9f
Exists in
master
and in
6 other branches
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Showing 4 changed files with 11 additions and 51 deletions Side-by-side Diff
drivers/target/target_core_cdb.c
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24 | 24 | */ |
25 | 25 | |
26 | +#include <linux/kernel.h> | |
26 | 27 | #include <asm/unaligned.h> |
27 | 28 | #include <scsi/scsi.h> |
28 | 29 | |
29 | 30 | |
... | ... | @@ -162,11 +163,9 @@ |
162 | 163 | struct t10_alua_lu_gp_member *lu_gp_mem; |
163 | 164 | struct t10_alua_tg_pt_gp *tg_pt_gp; |
164 | 165 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; |
165 | - unsigned char binary, binary_new; | |
166 | 166 | unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0]; |
167 | 167 | u32 prod_len; |
168 | 168 | u32 unit_serial_len, off = 0; |
169 | - int i; | |
170 | 169 | u16 len = 0, id_len; |
171 | 170 | |
172 | 171 | off = 4; |
... | ... | @@ -215,16 +214,9 @@ |
215 | 214 | * VENDOR_SPECIFIC_IDENTIFIER and |
216 | 215 | * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION |
217 | 216 | */ |
218 | - binary = transport_asciihex_to_binaryhex( | |
219 | - &dev->se_sub_dev->t10_wwn.unit_serial[0]); | |
220 | - buf[off++] |= (binary & 0xf0) >> 4; | |
221 | - for (i = 0; i < 24; i += 2) { | |
222 | - binary_new = transport_asciihex_to_binaryhex( | |
223 | - &dev->se_sub_dev->t10_wwn.unit_serial[i+2]); | |
224 | - buf[off] = (binary & 0x0f) << 4; | |
225 | - buf[off++] |= (binary_new & 0xf0) >> 4; | |
226 | - binary = binary_new; | |
227 | - } | |
217 | + buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]); | |
218 | + hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12); | |
219 | + | |
228 | 220 | len = 20; |
229 | 221 | off = (len + 4); |
230 | 222 |
drivers/target/target_core_fabric_lib.c
... | ... | @@ -25,6 +25,7 @@ |
25 | 25 | * |
26 | 26 | ******************************************************************************/ |
27 | 27 | |
28 | +#include <linux/kernel.h> | |
28 | 29 | #include <linux/string.h> |
29 | 30 | #include <linux/ctype.h> |
30 | 31 | #include <linux/spinlock.h> |
... | ... | @@ -61,9 +62,8 @@ |
61 | 62 | int *format_code, |
62 | 63 | unsigned char *buf) |
63 | 64 | { |
64 | - unsigned char binary, *ptr; | |
65 | - int i; | |
66 | - u32 off = 4; | |
65 | + unsigned char *ptr; | |
66 | + | |
67 | 67 | /* |
68 | 68 | * Set PROTOCOL IDENTIFIER to 6h for SAS |
69 | 69 | */ |
... | ... | @@ -74,10 +74,8 @@ |
74 | 74 | */ |
75 | 75 | ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */ |
76 | 76 | |
77 | - for (i = 0; i < 16; i += 2) { | |
78 | - binary = transport_asciihex_to_binaryhex(&ptr[i]); | |
79 | - buf[off++] = binary; | |
80 | - } | |
77 | + hex2bin(&buf[4], ptr, 8); | |
78 | + | |
81 | 79 | /* |
82 | 80 | * The SAS Transport ID is a hardcoded 24-byte length |
83 | 81 | */ |
... | ... | @@ -157,7 +155,7 @@ |
157 | 155 | int *format_code, |
158 | 156 | unsigned char *buf) |
159 | 157 | { |
160 | - unsigned char binary, *ptr; | |
158 | + unsigned char *ptr; | |
161 | 159 | int i; |
162 | 160 | u32 off = 8; |
163 | 161 | /* |
... | ... | @@ -176,8 +174,7 @@ |
176 | 174 | i++; |
177 | 175 | continue; |
178 | 176 | } |
179 | - binary = transport_asciihex_to_binaryhex(&ptr[i]); | |
180 | - buf[off++] = binary; | |
177 | + hex2bin(&buf[off++], &ptr[i], 1); | |
181 | 178 | i += 2; |
182 | 179 | } |
183 | 180 | /* |
drivers/target/target_core_transport.c
... | ... | @@ -2659,34 +2659,6 @@ |
2659 | 2659 | return dev->se_sub_dev->se_dev_attrib.block_size * sectors; |
2660 | 2660 | } |
2661 | 2661 | |
2662 | -unsigned char transport_asciihex_to_binaryhex(unsigned char val[2]) | |
2663 | -{ | |
2664 | - unsigned char result = 0; | |
2665 | - /* | |
2666 | - * MSB | |
2667 | - */ | |
2668 | - if ((val[0] >= 'a') && (val[0] <= 'f')) | |
2669 | - result = ((val[0] - 'a' + 10) & 0xf) << 4; | |
2670 | - else | |
2671 | - if ((val[0] >= 'A') && (val[0] <= 'F')) | |
2672 | - result = ((val[0] - 'A' + 10) & 0xf) << 4; | |
2673 | - else /* digit */ | |
2674 | - result = ((val[0] - '0') & 0xf) << 4; | |
2675 | - /* | |
2676 | - * LSB | |
2677 | - */ | |
2678 | - if ((val[1] >= 'a') && (val[1] <= 'f')) | |
2679 | - result |= ((val[1] - 'a' + 10) & 0xf); | |
2680 | - else | |
2681 | - if ((val[1] >= 'A') && (val[1] <= 'F')) | |
2682 | - result |= ((val[1] - 'A' + 10) & 0xf); | |
2683 | - else /* digit */ | |
2684 | - result |= ((val[1] - '0') & 0xf); | |
2685 | - | |
2686 | - return result; | |
2687 | -} | |
2688 | -EXPORT_SYMBOL(transport_asciihex_to_binaryhex); | |
2689 | - | |
2690 | 2662 | static void transport_xor_callback(struct se_cmd *cmd) |
2691 | 2663 | { |
2692 | 2664 | unsigned char *buf, *addr; |
include/target/target_core_transport.h
... | ... | @@ -179,7 +179,6 @@ |
179 | 179 | extern int transport_generic_handle_tmr(struct se_cmd *); |
180 | 180 | extern void transport_generic_free_cmd_intr(struct se_cmd *); |
181 | 181 | extern void __transport_stop_task_timer(struct se_task *, unsigned long *); |
182 | -extern unsigned char transport_asciihex_to_binaryhex(unsigned char val[2]); | |
183 | 182 | extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32, |
184 | 183 | struct scatterlist *, u32); |
185 | 184 | extern int transport_clear_lun_from_sessions(struct se_lun *); |