diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 161 |
1 files changed, 65 insertions, 96 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 41ba0809f791..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,8 +969,8 @@ 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_expire = 0; | 975 | unsigned long spintime_expire = 0; |
988 | int retries, spintime; | 976 | int retries, spintime; |
@@ -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,14 +1046,9 @@ 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 | |||
1070 | SRpnt->sr_data_direction = DMA_NONE; | ||
1071 | scsi_wait_req(SRpnt, (void *)cmd, | ||
1072 | (void *) buffer, 0/*512*/, | ||
1073 | SD_TIMEOUT, SD_MAX_RETRIES); | ||
1074 | spintime_expire = jiffies + 100 * HZ; | 1052 | spintime_expire = jiffies + 100 * HZ; |
1075 | spintime = 1; | 1053 | spintime = 1; |
1076 | } | 1054 | } |
@@ -1098,7 +1076,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1098 | if(!spintime) { | 1076 | if(!spintime) { |
1099 | printk(KERN_NOTICE "%s: Unit Not Ready, " | 1077 | printk(KERN_NOTICE "%s: Unit Not Ready, " |
1100 | "sense:\n", diskname); | 1078 | "sense:\n", diskname); |
1101 | scsi_print_req_sense("", SRpnt); | 1079 | scsi_print_sense_hdr("", &sshdr); |
1102 | } | 1080 | } |
1103 | break; | 1081 | break; |
1104 | } | 1082 | } |
@@ -1118,14 +1096,15 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1118 | */ | 1096 | */ |
1119 | static void | 1097 | static void |
1120 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 1098 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
1121 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1099 | unsigned char *buffer) |
1100 | { | ||
1122 | unsigned char cmd[16]; | 1101 | unsigned char cmd[16]; |
1123 | struct scsi_device *sdp = sdkp->device; | ||
1124 | int the_result, retries; | 1102 | int the_result, retries; |
1125 | int sector_size = 0; | 1103 | int sector_size = 0; |
1126 | int longrc = 0; | 1104 | int longrc = 0; |
1127 | struct scsi_sense_hdr sshdr; | 1105 | struct scsi_sense_hdr sshdr; |
1128 | int sense_valid = 0; | 1106 | int sense_valid = 0; |
1107 | struct scsi_device *sdp = sdkp->device; | ||
1129 | 1108 | ||
1130 | repeat: | 1109 | repeat: |
1131 | retries = 3; | 1110 | retries = 3; |
@@ -1142,20 +1121,15 @@ repeat: | |||
1142 | memset((void *) buffer, 0, 8); | 1121 | memset((void *) buffer, 0, 8); |
1143 | } | 1122 | } |
1144 | 1123 | ||
1145 | SRpnt->sr_cmd_len = 0; | 1124 | the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, |
1146 | memset(SRpnt->sr_sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 1125 | buffer, longrc ? 12 : 8, &sshdr, |
1147 | SRpnt->sr_data_direction = DMA_FROM_DEVICE; | 1126 | SD_TIMEOUT, SD_MAX_RETRIES); |
1148 | |||
1149 | scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, | ||
1150 | longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES); | ||
1151 | 1127 | ||
1152 | if (media_not_present(sdkp, SRpnt)) | 1128 | if (media_not_present(sdkp, &sshdr)) |
1153 | return; | 1129 | return; |
1154 | 1130 | ||
1155 | the_result = SRpnt->sr_result; | ||
1156 | if (the_result) | 1131 | if (the_result) |
1157 | sense_valid = scsi_request_normalize_sense(SRpnt, | 1132 | sense_valid = scsi_sense_valid(&sshdr); |
1158 | &sshdr); | ||
1159 | retries--; | 1133 | retries--; |
1160 | 1134 | ||
1161 | } while (the_result && retries); | 1135 | } while (the_result && retries); |
@@ -1170,7 +1144,7 @@ repeat: | |||
1170 | driver_byte(the_result)); | 1144 | driver_byte(the_result)); |
1171 | 1145 | ||
1172 | if (driver_byte(the_result) & DRIVER_SENSE) | 1146 | if (driver_byte(the_result) & DRIVER_SENSE) |
1173 | scsi_print_req_sense("sd", SRpnt); | 1147 | scsi_print_sense_hdr("sd", &sshdr); |
1174 | else | 1148 | else |
1175 | printk("%s : sense not available. \n", diskname); | 1149 | printk("%s : sense not available. \n", diskname); |
1176 | 1150 | ||
@@ -1310,11 +1284,13 @@ got_data: | |||
1310 | 1284 | ||
1311 | /* called with buffer of length 512 */ | 1285 | /* called with buffer of length 512 */ |
1312 | static inline int | 1286 | static inline int |
1313 | 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, |
1314 | 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) | ||
1315 | { | 1290 | { |
1316 | return __scsi_mode_sense(SRpnt, dbd, modepage, buffer, len, | 1291 | return scsi_mode_sense(sdp, dbd, modepage, buffer, len, |
1317 | SD_TIMEOUT, SD_MAX_RETRIES, data); | 1292 | SD_TIMEOUT, SD_MAX_RETRIES, data, |
1293 | sshdr); | ||
1318 | } | 1294 | } |
1319 | 1295 | ||
1320 | /* | 1296 | /* |
@@ -1323,25 +1299,27 @@ sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, | |||
1323 | */ | 1299 | */ |
1324 | static void | 1300 | static void |
1325 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | 1301 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, |
1326 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1302 | unsigned char *buffer) |
1303 | { | ||
1327 | int res; | 1304 | int res; |
1305 | struct scsi_device *sdp = sdkp->device; | ||
1328 | struct scsi_mode_data data; | 1306 | struct scsi_mode_data data; |
1329 | 1307 | ||
1330 | set_disk_ro(sdkp->disk, 0); | 1308 | set_disk_ro(sdkp->disk, 0); |
1331 | if (sdkp->device->skip_ms_page_3f) { | 1309 | if (sdp->skip_ms_page_3f) { |
1332 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); | 1310 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); |
1333 | return; | 1311 | return; |
1334 | } | 1312 | } |
1335 | 1313 | ||
1336 | if (sdkp->device->use_192_bytes_for_3f) { | 1314 | if (sdp->use_192_bytes_for_3f) { |
1337 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 192, &data); | 1315 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL); |
1338 | } else { | 1316 | } else { |
1339 | /* | 1317 | /* |
1340 | * First attempt: ask for all pages (0x3F), but only 4 bytes. | 1318 | * First attempt: ask for all pages (0x3F), but only 4 bytes. |
1341 | * We have to start carefully: some devices hang if we ask | 1319 | * We have to start carefully: some devices hang if we ask |
1342 | * for more than is available. | 1320 | * for more than is available. |
1343 | */ | 1321 | */ |
1344 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data); | 1322 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 4, &data, NULL); |
1345 | 1323 | ||
1346 | /* | 1324 | /* |
1347 | * Second attempt: ask for page 0 When only page 0 is | 1325 | * Second attempt: ask for page 0 When only page 0 is |
@@ -1350,14 +1328,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1350 | * CDB. | 1328 | * CDB. |
1351 | */ | 1329 | */ |
1352 | if (!scsi_status_is_good(res)) | 1330 | if (!scsi_status_is_good(res)) |
1353 | res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data); | 1331 | res = sd_do_mode_sense(sdp, 0, 0, buffer, 4, &data, NULL); |
1354 | 1332 | ||
1355 | /* | 1333 | /* |
1356 | * Third attempt: ask 255 bytes, as we did earlier. | 1334 | * Third attempt: ask 255 bytes, as we did earlier. |
1357 | */ | 1335 | */ |
1358 | if (!scsi_status_is_good(res)) | 1336 | if (!scsi_status_is_good(res)) |
1359 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, | 1337 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 255, |
1360 | &data); | 1338 | &data, NULL); |
1361 | } | 1339 | } |
1362 | 1340 | ||
1363 | if (!scsi_status_is_good(res)) { | 1341 | if (!scsi_status_is_good(res)) { |
@@ -1379,19 +1357,20 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1379 | */ | 1357 | */ |
1380 | static void | 1358 | static void |
1381 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | 1359 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, |
1382 | struct scsi_request *SRpnt, unsigned char *buffer) | 1360 | unsigned char *buffer) |
1383 | { | 1361 | { |
1384 | int len = 0, res; | 1362 | int len = 0, res; |
1363 | struct scsi_device *sdp = sdkp->device; | ||
1385 | 1364 | ||
1386 | int dbd; | 1365 | int dbd; |
1387 | int modepage; | 1366 | int modepage; |
1388 | struct scsi_mode_data data; | 1367 | struct scsi_mode_data data; |
1389 | struct scsi_sense_hdr sshdr; | 1368 | struct scsi_sense_hdr sshdr; |
1390 | 1369 | ||
1391 | if (sdkp->device->skip_ms_page_8) | 1370 | if (sdp->skip_ms_page_8) |
1392 | goto defaults; | 1371 | goto defaults; |
1393 | 1372 | ||
1394 | if (sdkp->device->type == TYPE_RBC) { | 1373 | if (sdp->type == TYPE_RBC) { |
1395 | modepage = 6; | 1374 | modepage = 6; |
1396 | dbd = 8; | 1375 | dbd = 8; |
1397 | } else { | 1376 | } else { |
@@ -1400,7 +1379,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1400 | } | 1379 | } |
1401 | 1380 | ||
1402 | /* cautiously ask */ | 1381 | /* cautiously ask */ |
1403 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4, &data); | 1382 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, 4, &data, &sshdr); |
1404 | 1383 | ||
1405 | if (!scsi_status_is_good(res)) | 1384 | if (!scsi_status_is_good(res)) |
1406 | goto bad_sense; | 1385 | goto bad_sense; |
@@ -1421,7 +1400,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1421 | len += data.header_length + data.block_descriptor_length; | 1400 | len += data.header_length + data.block_descriptor_length; |
1422 | 1401 | ||
1423 | /* Get the data */ | 1402 | /* Get the data */ |
1424 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, len, &data); | 1403 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); |
1425 | 1404 | ||
1426 | if (scsi_status_is_good(res)) { | 1405 | if (scsi_status_is_good(res)) { |
1427 | const char *types[] = { | 1406 | const char *types[] = { |
@@ -1453,7 +1432,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1453 | } | 1432 | } |
1454 | 1433 | ||
1455 | bad_sense: | 1434 | bad_sense: |
1456 | if (scsi_request_normalize_sense(SRpnt, &sshdr) && | 1435 | if (scsi_sense_valid(&sshdr) && |
1457 | sshdr.sense_key == ILLEGAL_REQUEST && | 1436 | sshdr.sense_key == ILLEGAL_REQUEST && |
1458 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) | 1437 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) |
1459 | printk(KERN_NOTICE "%s: cache data unavailable\n", | 1438 | printk(KERN_NOTICE "%s: cache data unavailable\n", |
@@ -1478,7 +1457,6 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1478 | { | 1457 | { |
1479 | struct scsi_disk *sdkp = scsi_disk(disk); | 1458 | struct scsi_disk *sdkp = scsi_disk(disk); |
1480 | struct scsi_device *sdp = sdkp->device; | 1459 | struct scsi_device *sdp = sdkp->device; |
1481 | struct scsi_request *sreq; | ||
1482 | unsigned char *buffer; | 1460 | unsigned char *buffer; |
1483 | 1461 | ||
1484 | 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)); |
@@ -1490,18 +1468,11 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1490 | if (!scsi_device_online(sdp)) | 1468 | if (!scsi_device_online(sdp)) |
1491 | goto out; | 1469 | goto out; |
1492 | 1470 | ||
1493 | sreq = scsi_allocate_request(sdp, GFP_KERNEL); | ||
1494 | if (!sreq) { | ||
1495 | printk(KERN_WARNING "(sd_revalidate_disk:) Request allocation " | ||
1496 | "failure.\n"); | ||
1497 | goto out; | ||
1498 | } | ||
1499 | |||
1500 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); | 1471 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); |
1501 | if (!buffer) { | 1472 | if (!buffer) { |
1502 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " | 1473 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " |
1503 | "failure.\n"); | 1474 | "failure.\n"); |
1504 | goto out_release_request; | 1475 | goto out; |
1505 | } | 1476 | } |
1506 | 1477 | ||
1507 | /* defaults, until the device tells us otherwise */ | 1478 | /* defaults, until the device tells us otherwise */ |
@@ -1512,25 +1483,23 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1512 | sdkp->WCE = 0; | 1483 | sdkp->WCE = 0; |
1513 | sdkp->RCD = 0; | 1484 | sdkp->RCD = 0; |
1514 | 1485 | ||
1515 | sd_spinup_disk(sdkp, disk->disk_name, sreq, buffer); | 1486 | sd_spinup_disk(sdkp, disk->disk_name); |
1516 | 1487 | ||
1517 | /* | 1488 | /* |
1518 | * Without media there is no reason to ask; moreover, some devices | 1489 | * Without media there is no reason to ask; moreover, some devices |
1519 | * react badly if we do. | 1490 | * react badly if we do. |
1520 | */ | 1491 | */ |
1521 | if (sdkp->media_present) { | 1492 | if (sdkp->media_present) { |
1522 | sd_read_capacity(sdkp, disk->disk_name, sreq, buffer); | 1493 | sd_read_capacity(sdkp, disk->disk_name, buffer); |
1523 | if (sdp->removable) | 1494 | if (sdp->removable) |
1524 | sd_read_write_protect_flag(sdkp, disk->disk_name, | 1495 | sd_read_write_protect_flag(sdkp, disk->disk_name, |
1525 | sreq, buffer); | 1496 | buffer); |
1526 | sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer); | 1497 | sd_read_cache_type(sdkp, disk->disk_name, buffer); |
1527 | } | 1498 | } |
1528 | 1499 | ||
1529 | set_capacity(disk, sdkp->capacity); | 1500 | set_capacity(disk, sdkp->capacity); |
1530 | kfree(buffer); | 1501 | kfree(buffer); |
1531 | 1502 | ||
1532 | out_release_request: | ||
1533 | scsi_release_request(sreq); | ||
1534 | out: | 1503 | out: |
1535 | return 0; | 1504 | return 0; |
1536 | } | 1505 | } |