diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 185 |
1 files changed, 84 insertions, 101 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0410e1bf109a..de564b386052 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <scsi/scsi_eh.h> | 59 | #include <scsi/scsi_eh.h> |
60 | #include <scsi/scsi_host.h> | 60 | #include <scsi/scsi_host.h> |
61 | #include <scsi/scsi_ioctl.h> | 61 | #include <scsi/scsi_ioctl.h> |
62 | #include <scsi/scsi_request.h> | ||
63 | #include <scsi/scsicam.h> | 62 | #include <scsi/scsicam.h> |
64 | 63 | ||
65 | #include "scsi_logging.h" | 64 | #include "scsi_logging.h" |
@@ -125,7 +124,7 @@ static int sd_issue_flush(struct device *, sector_t *); | |||
125 | static void sd_end_flush(request_queue_t *, struct request *); | 124 | static void sd_end_flush(request_queue_t *, struct request *); |
126 | static int sd_prepare_flush(request_queue_t *, struct request *); | 125 | static int sd_prepare_flush(request_queue_t *, struct request *); |
127 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 126 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
128 | struct scsi_request *SRpnt, unsigned char *buffer); | 127 | unsigned char *buffer); |
129 | 128 | ||
130 | static struct scsi_driver sd_template = { | 129 | static struct scsi_driver sd_template = { |
131 | .owner = THIS_MODULE, | 130 | .owner = THIS_MODULE, |
@@ -682,19 +681,13 @@ not_present: | |||
682 | 681 | ||
683 | static int sd_sync_cache(struct scsi_device *sdp) | 682 | static int sd_sync_cache(struct scsi_device *sdp) |
684 | { | 683 | { |
685 | struct scsi_request *sreq; | ||
686 | int retries, res; | 684 | int retries, res; |
685 | struct scsi_sense_hdr sshdr; | ||
687 | 686 | ||
688 | if (!scsi_device_online(sdp)) | 687 | if (!scsi_device_online(sdp)) |
689 | return -ENODEV; | 688 | return -ENODEV; |
690 | 689 | ||
691 | sreq = scsi_allocate_request(sdp, GFP_KERNEL); | ||
692 | if (!sreq) { | ||
693 | printk("FAILED\n No memory for request\n"); | ||
694 | return -ENOMEM; | ||
695 | } | ||
696 | 690 | ||
697 | sreq->sr_data_direction = DMA_NONE; | ||
698 | for (retries = 3; retries > 0; --retries) { | 691 | for (retries = 3; retries > 0; --retries) { |
699 | unsigned char cmd[10] = { 0 }; | 692 | unsigned char cmd[10] = { 0 }; |
700 | 693 | ||
@@ -703,22 +696,20 @@ static int sd_sync_cache(struct scsi_device *sdp) | |||
703 | * Leave the rest of the command zero to indicate | 696 | * Leave the rest of the command zero to indicate |
704 | * flush everything. | 697 | * flush everything. |
705 | */ | 698 | */ |
706 | scsi_wait_req(sreq, cmd, NULL, 0, SD_TIMEOUT, SD_MAX_RETRIES); | 699 | res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, |
707 | if (sreq->sr_result == 0) | 700 | SD_TIMEOUT, SD_MAX_RETRIES); |
701 | if (res == 0) | ||
708 | break; | 702 | break; |
709 | } | 703 | } |
710 | 704 | ||
711 | res = sreq->sr_result; | 705 | if (res) { printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " |
712 | if (res) { | ||
713 | printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " | ||
714 | "host = %d, driver = %02x\n ", | 706 | "host = %d, driver = %02x\n ", |
715 | status_byte(res), msg_byte(res), | 707 | status_byte(res), msg_byte(res), |
716 | host_byte(res), driver_byte(res)); | 708 | host_byte(res), driver_byte(res)); |
717 | if (driver_byte(res) & DRIVER_SENSE) | 709 | if (driver_byte(res) & DRIVER_SENSE) |
718 | scsi_print_req_sense("sd", sreq); | 710 | scsi_print_sense_hdr("sd", &sshdr); |
719 | } | 711 | } |
720 | 712 | ||
721 | scsi_release_request(sreq); | ||
722 | return res; | 713 | return res; |
723 | } | 714 | } |
724 | 715 | ||
@@ -957,22 +948,19 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt) | |||
957 | scsi_io_completion(SCpnt, good_bytes, block_sectors << 9); | 948 | scsi_io_completion(SCpnt, good_bytes, block_sectors << 9); |
958 | } | 949 | } |
959 | 950 | ||
960 | static int media_not_present(struct scsi_disk *sdkp, struct scsi_request *srp) | 951 | static int media_not_present(struct scsi_disk *sdkp, |
952 | struct scsi_sense_hdr *sshdr) | ||
961 | { | 953 | { |
962 | struct scsi_sense_hdr sshdr; | ||
963 | 954 | ||
964 | if (!srp->sr_result) | 955 | if (!scsi_sense_valid(sshdr)) |
965 | return 0; | ||
966 | if (!(driver_byte(srp->sr_result) & DRIVER_SENSE)) | ||
967 | return 0; | 956 | return 0; |
968 | /* not invoked for commands that could return deferred errors */ | 957 | /* not invoked for commands that could return deferred errors */ |
969 | if (scsi_request_normalize_sense(srp, &sshdr)) { | 958 | if (sshdr->sense_key != NOT_READY && |
970 | if (sshdr.sense_key != NOT_READY && | 959 | sshdr->sense_key != UNIT_ATTENTION) |
971 | sshdr.sense_key != UNIT_ATTENTION) | 960 | return 0; |
972 | return 0; | 961 | if (sshdr->asc != 0x3A) /* medium not present */ |
973 | if (sshdr.asc != 0x3A) /* medium not present */ | 962 | return 0; |
974 | return 0; | 963 | |
975 | } | ||
976 | set_media_not_present(sdkp); | 964 | set_media_not_present(sdkp); |
977 | return 1; | 965 | return 1; |
978 | } | 966 | } |
@@ -981,10 +969,10 @@ static int media_not_present(struct scsi_disk *sdkp, struct scsi_request *srp) | |||
981 | * spinup disk - called only in sd_revalidate_disk() | 969 | * spinup disk - called only in sd_revalidate_disk() |
982 | */ | 970 | */ |
983 | static void | 971 | static void |
984 | sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | 972 | sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) |
985 | struct scsi_request *SRpnt, unsigned char *buffer) { | 973 | { |
986 | unsigned char cmd[10]; | 974 | unsigned char cmd[10]; |
987 | unsigned long spintime_value = 0; | 975 | unsigned long spintime_expire = 0; |
988 | int retries, spintime; | 976 | int retries, spintime; |
989 | unsigned int the_result; | 977 | unsigned int the_result; |
990 | struct scsi_sense_hdr sshdr; | 978 | struct scsi_sense_hdr sshdr; |
@@ -1001,18 +989,13 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1001 | cmd[0] = TEST_UNIT_READY; | 989 | cmd[0] = TEST_UNIT_READY; |
1002 | memset((void *) &cmd[1], 0, 9); | 990 | memset((void *) &cmd[1], 0, 9); |
1003 | 991 | ||
1004 | SRpnt->sr_cmd_len = 0; | 992 | the_result = scsi_execute_req(sdkp->device, cmd, |
1005 | memset(SRpnt->sr_sense_buffer, 0, | 993 | DMA_NONE, NULL, 0, |
1006 | SCSI_SENSE_BUFFERSIZE); | 994 | &sshdr, SD_TIMEOUT, |
1007 | SRpnt->sr_data_direction = DMA_NONE; | 995 | SD_MAX_RETRIES); |
1008 | 996 | ||
1009 | scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer, | ||
1010 | 0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES); | ||
1011 | |||
1012 | the_result = SRpnt->sr_result; | ||
1013 | if (the_result) | 997 | if (the_result) |
1014 | sense_valid = scsi_request_normalize_sense( | 998 | sense_valid = scsi_sense_valid(&sshdr); |
1015 | SRpnt, &sshdr); | ||
1016 | retries++; | 999 | retries++; |
1017 | } while (retries < 3 && | 1000 | } while (retries < 3 && |
1018 | (!scsi_status_is_good(the_result) || | 1001 | (!scsi_status_is_good(the_result) || |
@@ -1024,7 +1007,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1024 | * any media in it, don't bother with any of the rest of | 1007 | * any media in it, don't bother with any of the rest of |
1025 | * this crap. | 1008 | * this crap. |
1026 | */ | 1009 | */ |
1027 | if (media_not_present(sdkp, SRpnt)) | 1010 | if (media_not_present(sdkp, &sshdr)) |
1028 | return; | 1011 | return; |
1029 | 1012 | ||
1030 | if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { | 1013 | if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { |
@@ -1063,33 +1046,42 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1063 | cmd[1] = 1; /* Return immediately */ | 1046 | cmd[1] = 1; /* Return immediately */ |
1064 | memset((void *) &cmd[2], 0, 8); | 1047 | memset((void *) &cmd[2], 0, 8); |
1065 | cmd[4] = 1; /* Start spin cycle */ | 1048 | cmd[4] = 1; /* Start spin cycle */ |
1066 | SRpnt->sr_cmd_len = 0; | 1049 | scsi_execute_req(sdkp->device, cmd, DMA_NONE, |
1067 | memset(SRpnt->sr_sense_buffer, 0, | 1050 | NULL, 0, &sshdr, |
1068 | SCSI_SENSE_BUFFERSIZE); | 1051 | SD_TIMEOUT, SD_MAX_RETRIES); |
1069 | 1052 | spintime_expire = jiffies + 100 * HZ; | |
1070 | SRpnt->sr_data_direction = DMA_NONE; | 1053 | spintime = 1; |
1071 | scsi_wait_req(SRpnt, (void *)cmd, | ||
1072 | (void *) buffer, 0/*512*/, | ||
1073 | SD_TIMEOUT, SD_MAX_RETRIES); | ||
1074 | spintime_value = jiffies; | ||
1075 | } | 1054 | } |
1076 | spintime = 1; | ||
1077 | /* Wait 1 second for next try */ | 1055 | /* Wait 1 second for next try */ |
1078 | msleep(1000); | 1056 | msleep(1000); |
1079 | printk("."); | 1057 | printk("."); |
1058 | |||
1059 | /* | ||
1060 | * Wait for USB flash devices with slow firmware. | ||
1061 | * Yes, this sense key/ASC combination shouldn't | ||
1062 | * occur here. It's characteristic of these devices. | ||
1063 | */ | ||
1064 | } else if (sense_valid && | ||
1065 | sshdr.sense_key == UNIT_ATTENTION && | ||
1066 | sshdr.asc == 0x28) { | ||
1067 | if (!spintime) { | ||
1068 | spintime_expire = jiffies + 5 * HZ; | ||
1069 | spintime = 1; | ||
1070 | } | ||
1071 | /* Wait 1 second for next try */ | ||
1072 | msleep(1000); | ||
1080 | } else { | 1073 | } else { |
1081 | /* we don't understand the sense code, so it's | 1074 | /* we don't understand the sense code, so it's |
1082 | * probably pointless to loop */ | 1075 | * probably pointless to loop */ |
1083 | if(!spintime) { | 1076 | if(!spintime) { |
1084 | printk(KERN_NOTICE "%s: Unit Not Ready, " | 1077 | printk(KERN_NOTICE "%s: Unit Not Ready, " |
1085 | "sense:\n", diskname); | 1078 | "sense:\n", diskname); |
1086 | scsi_print_req_sense("", SRpnt); | 1079 | scsi_print_sense_hdr("", &sshdr); |
1087 | } | 1080 | } |
1088 | break; | 1081 | break; |
1089 | } | 1082 | } |
1090 | 1083 | ||
1091 | } while (spintime && | 1084 | } while (spintime && time_before_eq(jiffies, spintime_expire)); |
1092 | time_after(spintime_value + 100 * HZ, jiffies)); | ||
1093 | 1085 | ||
1094 | if (spintime) { | 1086 | if (spintime) { |
1095 | if (scsi_status_is_good(the_result)) | 1087 | if (scsi_status_is_good(the_result)) |
@@ -1104,14 +1096,15 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1104 | */ | 1096 | */ |
1105 | static void | 1097 | static void |
1106 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 1098 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
1107 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1099 | unsigned char *buffer) |
1100 | { | ||
1108 | unsigned char cmd[16]; | 1101 | unsigned char cmd[16]; |
1109 | struct scsi_device *sdp = sdkp->device; | ||
1110 | int the_result, retries; | 1102 | int the_result, retries; |
1111 | int sector_size = 0; | 1103 | int sector_size = 0; |
1112 | int longrc = 0; | 1104 | int longrc = 0; |
1113 | struct scsi_sense_hdr sshdr; | 1105 | struct scsi_sense_hdr sshdr; |
1114 | int sense_valid = 0; | 1106 | int sense_valid = 0; |
1107 | struct scsi_device *sdp = sdkp->device; | ||
1115 | 1108 | ||
1116 | repeat: | 1109 | repeat: |
1117 | retries = 3; | 1110 | retries = 3; |
@@ -1128,20 +1121,15 @@ repeat: | |||
1128 | memset((void *) buffer, 0, 8); | 1121 | memset((void *) buffer, 0, 8); |
1129 | } | 1122 | } |
1130 | 1123 | ||
1131 | SRpnt->sr_cmd_len = 0; | 1124 | the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, |
1132 | memset(SRpnt->sr_sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 1125 | buffer, longrc ? 12 : 8, &sshdr, |
1133 | SRpnt->sr_data_direction = DMA_FROM_DEVICE; | 1126 | SD_TIMEOUT, SD_MAX_RETRIES); |
1134 | |||
1135 | scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, | ||
1136 | longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES); | ||
1137 | 1127 | ||
1138 | if (media_not_present(sdkp, SRpnt)) | 1128 | if (media_not_present(sdkp, &sshdr)) |
1139 | return; | 1129 | return; |
1140 | 1130 | ||
1141 | the_result = SRpnt->sr_result; | ||
1142 | if (the_result) | 1131 | if (the_result) |
1143 | sense_valid = scsi_request_normalize_sense(SRpnt, | 1132 | sense_valid = scsi_sense_valid(&sshdr); |
1144 | &sshdr); | ||
1145 | retries--; | 1133 | retries--; |
1146 | 1134 | ||
1147 | } while (the_result && retries); | 1135 | } while (the_result && retries); |
@@ -1156,7 +1144,7 @@ repeat: | |||
1156 | driver_byte(the_result)); | 1144 | driver_byte(the_result)); |
1157 | 1145 | ||
1158 | if (driver_byte(the_result) & DRIVER_SENSE) | 1146 | if (driver_byte(the_result) & DRIVER_SENSE) |
1159 | scsi_print_req_sense("sd", SRpnt); | 1147 | scsi_print_sense_hdr("sd", &sshdr); |
1160 | else | 1148 | else |
1161 | printk("%s : sense not available. \n", diskname); | 1149 | printk("%s : sense not available. \n", diskname); |
1162 | 1150 | ||
@@ -1296,11 +1284,13 @@ got_data: | |||
1296 | 1284 | ||
1297 | /* called with buffer of length 512 */ | 1285 | /* called with buffer of length 512 */ |
1298 | static inline int | 1286 | static inline int |
1299 | sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, | 1287 | sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage, |
1300 | unsigned char *buffer, int len, struct scsi_mode_data *data) | 1288 | unsigned char *buffer, int len, struct scsi_mode_data *data, |
1289 | struct scsi_sense_hdr *sshdr) | ||
1301 | { | 1290 | { |
1302 | return __scsi_mode_sense(SRpnt, dbd, modepage, buffer, len, | 1291 | return scsi_mode_sense(sdp, dbd, modepage, buffer, len, |
1303 | SD_TIMEOUT, SD_MAX_RETRIES, data); | 1292 | SD_TIMEOUT, SD_MAX_RETRIES, data, |
1293 | sshdr); | ||
1304 | } | 1294 | } |
1305 | 1295 | ||
1306 | /* | 1296 | /* |
@@ -1309,25 +1299,27 @@ sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, | |||
1309 | */ | 1299 | */ |
1310 | static void | 1300 | static void |
1311 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | 1301 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, |
1312 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1302 | unsigned char *buffer) |
1303 | { | ||
1313 | int res; | 1304 | int res; |
1305 | struct scsi_device *sdp = sdkp->device; | ||
1314 | struct scsi_mode_data data; | 1306 | struct scsi_mode_data data; |
1315 | 1307 | ||
1316 | set_disk_ro(sdkp->disk, 0); | 1308 | set_disk_ro(sdkp->disk, 0); |
1317 | if (sdkp->device->skip_ms_page_3f) { | 1309 | if (sdp->skip_ms_page_3f) { |
1318 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); | 1310 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); |
1319 | return; | 1311 | return; |
1320 | } | 1312 | } |
1321 | 1313 | ||
1322 | if (sdkp->device->use_192_bytes_for_3f) { | 1314 | if (sdp->use_192_bytes_for_3f) { |
1323 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 192, &data); | 1315 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL); |
1324 | } else { | 1316 | } else { |
1325 | /* | 1317 | /* |
1326 | * First attempt: ask for all pages (0x3F), but only 4 bytes. | 1318 | * First attempt: ask for all pages (0x3F), but only 4 bytes. |
1327 | * We have to start carefully: some devices hang if we ask | 1319 | * We have to start carefully: some devices hang if we ask |
1328 | * for more than is available. | 1320 | * for more than is available. |
1329 | */ | 1321 | */ |
1330 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data); | 1322 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 4, &data, NULL); |
1331 | 1323 | ||
1332 | /* | 1324 | /* |
1333 | * Second attempt: ask for page 0 When only page 0 is | 1325 | * Second attempt: ask for page 0 When only page 0 is |
@@ -1336,14 +1328,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1336 | * CDB. | 1328 | * CDB. |
1337 | */ | 1329 | */ |
1338 | if (!scsi_status_is_good(res)) | 1330 | if (!scsi_status_is_good(res)) |
1339 | res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data); | 1331 | res = sd_do_mode_sense(sdp, 0, 0, buffer, 4, &data, NULL); |
1340 | 1332 | ||
1341 | /* | 1333 | /* |
1342 | * Third attempt: ask 255 bytes, as we did earlier. | 1334 | * Third attempt: ask 255 bytes, as we did earlier. |
1343 | */ | 1335 | */ |
1344 | if (!scsi_status_is_good(res)) | 1336 | if (!scsi_status_is_good(res)) |
1345 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, | 1337 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 255, |
1346 | &data); | 1338 | &data, NULL); |
1347 | } | 1339 | } |
1348 | 1340 | ||
1349 | if (!scsi_status_is_good(res)) { | 1341 | if (!scsi_status_is_good(res)) { |
@@ -1365,19 +1357,20 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1365 | */ | 1357 | */ |
1366 | static void | 1358 | static void |
1367 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | 1359 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, |
1368 | struct scsi_request *SRpnt, unsigned char *buffer) | 1360 | unsigned char *buffer) |
1369 | { | 1361 | { |
1370 | int len = 0, res; | 1362 | int len = 0, res; |
1363 | struct scsi_device *sdp = sdkp->device; | ||
1371 | 1364 | ||
1372 | int dbd; | 1365 | int dbd; |
1373 | int modepage; | 1366 | int modepage; |
1374 | struct scsi_mode_data data; | 1367 | struct scsi_mode_data data; |
1375 | struct scsi_sense_hdr sshdr; | 1368 | struct scsi_sense_hdr sshdr; |
1376 | 1369 | ||
1377 | if (sdkp->device->skip_ms_page_8) | 1370 | if (sdp->skip_ms_page_8) |
1378 | goto defaults; | 1371 | goto defaults; |
1379 | 1372 | ||
1380 | if (sdkp->device->type == TYPE_RBC) { | 1373 | if (sdp->type == TYPE_RBC) { |
1381 | modepage = 6; | 1374 | modepage = 6; |
1382 | dbd = 8; | 1375 | dbd = 8; |
1383 | } else { | 1376 | } else { |
@@ -1386,7 +1379,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1386 | } | 1379 | } |
1387 | 1380 | ||
1388 | /* cautiously ask */ | 1381 | /* cautiously ask */ |
1389 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4, &data); | 1382 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, 4, &data, &sshdr); |
1390 | 1383 | ||
1391 | if (!scsi_status_is_good(res)) | 1384 | if (!scsi_status_is_good(res)) |
1392 | goto bad_sense; | 1385 | goto bad_sense; |
@@ -1407,7 +1400,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1407 | len += data.header_length + data.block_descriptor_length; | 1400 | len += data.header_length + data.block_descriptor_length; |
1408 | 1401 | ||
1409 | /* Get the data */ | 1402 | /* Get the data */ |
1410 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, len, &data); | 1403 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); |
1411 | 1404 | ||
1412 | if (scsi_status_is_good(res)) { | 1405 | if (scsi_status_is_good(res)) { |
1413 | const char *types[] = { | 1406 | const char *types[] = { |
@@ -1439,7 +1432,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1439 | } | 1432 | } |
1440 | 1433 | ||
1441 | bad_sense: | 1434 | bad_sense: |
1442 | if (scsi_request_normalize_sense(SRpnt, &sshdr) && | 1435 | if (scsi_sense_valid(&sshdr) && |
1443 | sshdr.sense_key == ILLEGAL_REQUEST && | 1436 | sshdr.sense_key == ILLEGAL_REQUEST && |
1444 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) | 1437 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) |
1445 | printk(KERN_NOTICE "%s: cache data unavailable\n", | 1438 | printk(KERN_NOTICE "%s: cache data unavailable\n", |
@@ -1464,7 +1457,6 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1464 | { | 1457 | { |
1465 | struct scsi_disk *sdkp = scsi_disk(disk); | 1458 | struct scsi_disk *sdkp = scsi_disk(disk); |
1466 | struct scsi_device *sdp = sdkp->device; | 1459 | struct scsi_device *sdp = sdkp->device; |
1467 | struct scsi_request *sreq; | ||
1468 | unsigned char *buffer; | 1460 | unsigned char *buffer; |
1469 | 1461 | ||
1470 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); | 1462 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); |
@@ -1476,18 +1468,11 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1476 | if (!scsi_device_online(sdp)) | 1468 | if (!scsi_device_online(sdp)) |
1477 | goto out; | 1469 | goto out; |
1478 | 1470 | ||
1479 | sreq = scsi_allocate_request(sdp, GFP_KERNEL); | ||
1480 | if (!sreq) { | ||
1481 | printk(KERN_WARNING "(sd_revalidate_disk:) Request allocation " | ||
1482 | "failure.\n"); | ||
1483 | goto out; | ||
1484 | } | ||
1485 | |||
1486 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); | 1471 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); |
1487 | if (!buffer) { | 1472 | if (!buffer) { |
1488 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " | 1473 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " |
1489 | "failure.\n"); | 1474 | "failure.\n"); |
1490 | goto out_release_request; | 1475 | goto out; |
1491 | } | 1476 | } |
1492 | 1477 | ||
1493 | /* defaults, until the device tells us otherwise */ | 1478 | /* defaults, until the device tells us otherwise */ |
@@ -1498,25 +1483,23 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1498 | sdkp->WCE = 0; | 1483 | sdkp->WCE = 0; |
1499 | sdkp->RCD = 0; | 1484 | sdkp->RCD = 0; |
1500 | 1485 | ||
1501 | sd_spinup_disk(sdkp, disk->disk_name, sreq, buffer); | 1486 | sd_spinup_disk(sdkp, disk->disk_name); |
1502 | 1487 | ||
1503 | /* | 1488 | /* |
1504 | * Without media there is no reason to ask; moreover, some devices | 1489 | * Without media there is no reason to ask; moreover, some devices |
1505 | * react badly if we do. | 1490 | * react badly if we do. |
1506 | */ | 1491 | */ |
1507 | if (sdkp->media_present) { | 1492 | if (sdkp->media_present) { |
1508 | sd_read_capacity(sdkp, disk->disk_name, sreq, buffer); | 1493 | sd_read_capacity(sdkp, disk->disk_name, buffer); |
1509 | if (sdp->removable) | 1494 | if (sdp->removable) |
1510 | sd_read_write_protect_flag(sdkp, disk->disk_name, | 1495 | sd_read_write_protect_flag(sdkp, disk->disk_name, |
1511 | sreq, buffer); | 1496 | buffer); |
1512 | sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer); | 1497 | sd_read_cache_type(sdkp, disk->disk_name, buffer); |
1513 | } | 1498 | } |
1514 | 1499 | ||
1515 | set_capacity(disk, sdkp->capacity); | 1500 | set_capacity(disk, sdkp->capacity); |
1516 | kfree(buffer); | 1501 | kfree(buffer); |
1517 | 1502 | ||
1518 | out_release_request: | ||
1519 | scsi_release_request(sreq); | ||
1520 | out: | 1503 | out: |
1521 | return 0; | 1504 | return 0; |
1522 | } | 1505 | } |