aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_cdb.c16
-rw-r--r--drivers/target/target_core_fabric_lib.c17
-rw-r--r--drivers/target/target_core_transport.c28
3 files changed, 11 insertions, 50 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 27e6a2e5e84a..8ae09a1bdf74 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -23,6 +23,7 @@
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */ 24 */
25 25
26#include <linux/kernel.h>
26#include <asm/unaligned.h> 27#include <asm/unaligned.h>
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
28 29
@@ -162,11 +163,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
162 struct t10_alua_lu_gp_member *lu_gp_mem; 163 struct t10_alua_lu_gp_member *lu_gp_mem;
163 struct t10_alua_tg_pt_gp *tg_pt_gp; 164 struct t10_alua_tg_pt_gp *tg_pt_gp;
164 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; 165 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
165 unsigned char binary, binary_new;
166 unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0]; 166 unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0];
167 u32 prod_len; 167 u32 prod_len;
168 u32 unit_serial_len, off = 0; 168 u32 unit_serial_len, off = 0;
169 int i;
170 u16 len = 0, id_len; 169 u16 len = 0, id_len;
171 170
172 off = 4; 171 off = 4;
@@ -215,16 +214,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
215 * VENDOR_SPECIFIC_IDENTIFIER and 214 * VENDOR_SPECIFIC_IDENTIFIER and
216 * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION 215 * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
217 */ 216 */
218 binary = transport_asciihex_to_binaryhex( 217 buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]);
219 &dev->se_sub_dev->t10_wwn.unit_serial[0]); 218 hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
220 buf[off++] |= (binary & 0xf0) >> 4; 219
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 }
228 len = 20; 220 len = 20;
229 off = (len + 4); 221 off = (len + 4);
230 222
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index a29968806cfc..c4ea3a9a555b 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -25,6 +25,7 @@
25 * 25 *
26 ******************************************************************************/ 26 ******************************************************************************/
27 27
28#include <linux/kernel.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/ctype.h> 30#include <linux/ctype.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
@@ -61,9 +62,8 @@ u32 sas_get_pr_transport_id(
61 int *format_code, 62 int *format_code,
62 unsigned char *buf) 63 unsigned char *buf)
63{ 64{
64 unsigned char binary, *ptr; 65 unsigned char *ptr;
65 int i; 66
66 u32 off = 4;
67 /* 67 /*
68 * Set PROTOCOL IDENTIFIER to 6h for SAS 68 * Set PROTOCOL IDENTIFIER to 6h for SAS
69 */ 69 */
@@ -74,10 +74,8 @@ u32 sas_get_pr_transport_id(
74 */ 74 */
75 ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */ 75 ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */
76 76
77 for (i = 0; i < 16; i += 2) { 77 hex2bin(&buf[4], ptr, 8);
78 binary = transport_asciihex_to_binaryhex(&ptr[i]); 78
79 buf[off++] = binary;
80 }
81 /* 79 /*
82 * The SAS Transport ID is a hardcoded 24-byte length 80 * The SAS Transport ID is a hardcoded 24-byte length
83 */ 81 */
@@ -157,7 +155,7 @@ u32 fc_get_pr_transport_id(
157 int *format_code, 155 int *format_code,
158 unsigned char *buf) 156 unsigned char *buf)
159{ 157{
160 unsigned char binary, *ptr; 158 unsigned char *ptr;
161 int i; 159 int i;
162 u32 off = 8; 160 u32 off = 8;
163 /* 161 /*
@@ -176,8 +174,7 @@ u32 fc_get_pr_transport_id(
176 i++; 174 i++;
177 continue; 175 continue;
178 } 176 }
179 binary = transport_asciihex_to_binaryhex(&ptr[i]); 177 hex2bin(&buf[off++], &ptr[i], 1);
180 buf[off++] = binary;
181 i += 2; 178 i += 2;
182 } 179 }
183 /* 180 /*
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 007cfc164f5e..46352d658e35 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2659,34 +2659,6 @@ static inline u32 transport_get_size(
2659 return dev->se_sub_dev->se_dev_attrib.block_size * sectors; 2659 return dev->se_sub_dev->se_dev_attrib.block_size * sectors;
2660} 2660}
2661 2661
2662unsigned 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}
2688EXPORT_SYMBOL(transport_asciihex_to_binaryhex);
2689
2690static void transport_xor_callback(struct se_cmd *cmd) 2662static void transport_xor_callback(struct se_cmd *cmd)
2691{ 2663{
2692 unsigned char *buf, *addr; 2664 unsigned char *buf, *addr;