aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_error.c38
-rw-r--r--include/scsi/scsi_eh.h4
2 files changed, 17 insertions, 25 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 53e334356f31..d70c67cf46ef 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -46,6 +46,8 @@
46 46
47#include <trace/events/scsi.h> 47#include <trace/events/scsi.h>
48 48
49#include <asm/unaligned.h>
50
49static void scsi_eh_done(struct scsi_cmnd *scmd); 51static void scsi_eh_done(struct scsi_cmnd *scmd);
50 52
51/* 53/*
@@ -2361,44 +2363,34 @@ EXPORT_SYMBOL(scsi_command_normalize_sense);
2361 * field will be placed if found. 2363 * field will be placed if found.
2362 * 2364 *
2363 * Return value: 2365 * Return value:
2364 * 1 if information field found, 0 if not found. 2366 * true if information field found, false if not found.
2365 */ 2367 */
2366int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, 2368bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len,
2367 u64 * info_out) 2369 u64 *info_out)
2368{ 2370{
2369 int j;
2370 const u8 * ucp; 2371 const u8 * ucp;
2371 u64 ull;
2372 2372
2373 if (sb_len < 7) 2373 if (sb_len < 7)
2374 return 0; 2374 return false;
2375 switch (sense_buffer[0] & 0x7f) { 2375 switch (sense_buffer[0] & 0x7f) {
2376 case 0x70: 2376 case 0x70:
2377 case 0x71: 2377 case 0x71:
2378 if (sense_buffer[0] & 0x80) { 2378 if (sense_buffer[0] & 0x80) {
2379 *info_out = (sense_buffer[3] << 24) + 2379 *info_out = get_unaligned_be32(&sense_buffer[3]);
2380 (sense_buffer[4] << 16) + 2380 return true;
2381 (sense_buffer[5] << 8) + sense_buffer[6]; 2381 }
2382 return 1; 2382 return false;
2383 } else
2384 return 0;
2385 case 0x72: 2383 case 0x72:
2386 case 0x73: 2384 case 0x73:
2387 ucp = scsi_sense_desc_find(sense_buffer, sb_len, 2385 ucp = scsi_sense_desc_find(sense_buffer, sb_len,
2388 0 /* info desc */); 2386 0 /* info desc */);
2389 if (ucp && (0xa == ucp[1])) { 2387 if (ucp && (0xa == ucp[1])) {
2390 ull = 0; 2388 *info_out = get_unaligned_be64(&ucp[4]);
2391 for (j = 0; j < 8; ++j) { 2389 return true;
2392 if (j > 0) 2390 }
2393 ull <<= 8; 2391 return false;
2394 ull |= ucp[4 + j];
2395 }
2396 *info_out = ull;
2397 return 1;
2398 } else
2399 return 0;
2400 default: 2392 default:
2401 return 0; 2393 return false;
2402 } 2394 }
2403} 2395}
2404EXPORT_SYMBOL(scsi_get_sense_info_fld); 2396EXPORT_SYMBOL(scsi_get_sense_info_fld);
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index a25b3285dd6f..64d30d80dadb 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -23,8 +23,8 @@ static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
23 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); 23 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
24} 24}
25 25
26extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, 26extern bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len,
27 u64 * info_out); 27 u64 *info_out);
28 28
29extern int scsi_ioctl_reset(struct scsi_device *, int __user *); 29extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
30 30