diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 160 |
1 files changed, 64 insertions, 96 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 15c2039059c9..611ccde84778 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_value = 0; | 975 | unsigned long spintime_value = 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_value = jiffies; | 1052 | spintime_value = jiffies; |
1075 | } | 1053 | } |
1076 | spintime = 1; | 1054 | spintime = 1; |
@@ -1083,7 +1061,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1083 | if(!spintime) { | 1061 | if(!spintime) { |
1084 | printk(KERN_NOTICE "%s: Unit Not Ready, " | 1062 | printk(KERN_NOTICE "%s: Unit Not Ready, " |
1085 | "sense:\n", diskname); | 1063 | "sense:\n", diskname); |
1086 | scsi_print_req_sense("", SRpnt); | 1064 | scsi_print_sense_hdr("", &sshdr); |
1087 | } | 1065 | } |
1088 | break; | 1066 | break; |
1089 | } | 1067 | } |
@@ -1104,14 +1082,15 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, | |||
1104 | */ | 1082 | */ |
1105 | static void | 1083 | static void |
1106 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 1084 | sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
1107 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1085 | unsigned char *buffer) |
1086 | { | ||
1108 | unsigned char cmd[16]; | 1087 | unsigned char cmd[16]; |
1109 | struct scsi_device *sdp = sdkp->device; | ||
1110 | int the_result, retries; | 1088 | int the_result, retries; |
1111 | int sector_size = 0; | 1089 | int sector_size = 0; |
1112 | int longrc = 0; | 1090 | int longrc = 0; |
1113 | struct scsi_sense_hdr sshdr; | 1091 | struct scsi_sense_hdr sshdr; |
1114 | int sense_valid = 0; | 1092 | int sense_valid = 0; |
1093 | struct scsi_device *sdp = sdkp->device; | ||
1115 | 1094 | ||
1116 | repeat: | 1095 | repeat: |
1117 | retries = 3; | 1096 | retries = 3; |
@@ -1128,20 +1107,15 @@ repeat: | |||
1128 | memset((void *) buffer, 0, 8); | 1107 | memset((void *) buffer, 0, 8); |
1129 | } | 1108 | } |
1130 | 1109 | ||
1131 | SRpnt->sr_cmd_len = 0; | 1110 | the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, |
1132 | memset(SRpnt->sr_sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 1111 | buffer, longrc ? 12 : 8, &sshdr, |
1133 | SRpnt->sr_data_direction = DMA_FROM_DEVICE; | 1112 | 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 | 1113 | ||
1138 | if (media_not_present(sdkp, SRpnt)) | 1114 | if (media_not_present(sdkp, &sshdr)) |
1139 | return; | 1115 | return; |
1140 | 1116 | ||
1141 | the_result = SRpnt->sr_result; | ||
1142 | if (the_result) | 1117 | if (the_result) |
1143 | sense_valid = scsi_request_normalize_sense(SRpnt, | 1118 | sense_valid = scsi_sense_valid(&sshdr); |
1144 | &sshdr); | ||
1145 | retries--; | 1119 | retries--; |
1146 | 1120 | ||
1147 | } while (the_result && retries); | 1121 | } while (the_result && retries); |
@@ -1156,7 +1130,7 @@ repeat: | |||
1156 | driver_byte(the_result)); | 1130 | driver_byte(the_result)); |
1157 | 1131 | ||
1158 | if (driver_byte(the_result) & DRIVER_SENSE) | 1132 | if (driver_byte(the_result) & DRIVER_SENSE) |
1159 | scsi_print_req_sense("sd", SRpnt); | 1133 | scsi_print_sense_hdr("sd", &sshdr); |
1160 | else | 1134 | else |
1161 | printk("%s : sense not available. \n", diskname); | 1135 | printk("%s : sense not available. \n", diskname); |
1162 | 1136 | ||
@@ -1296,12 +1270,13 @@ got_data: | |||
1296 | 1270 | ||
1297 | /* called with buffer of length 512 */ | 1271 | /* called with buffer of length 512 */ |
1298 | static inline int | 1272 | static inline int |
1299 | sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, | 1273 | sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage, |
1300 | unsigned char *buffer, int len, struct scsi_mode_data *data) | 1274 | unsigned char *buffer, int len, struct scsi_mode_data *data, |
1275 | struct scsi_sense_hdr *sshdr) | ||
1301 | { | 1276 | { |
1302 | return scsi_mode_sense(SRpnt->sr_device, dbd, modepage, buffer, len, | 1277 | return scsi_mode_sense(sdp, dbd, modepage, buffer, len, |
1303 | SD_TIMEOUT, SD_MAX_RETRIES, data, | 1278 | SD_TIMEOUT, SD_MAX_RETRIES, data, |
1304 | SRpnt->sr_sense_buffer); | 1279 | sshdr); |
1305 | } | 1280 | } |
1306 | 1281 | ||
1307 | /* | 1282 | /* |
@@ -1310,25 +1285,27 @@ sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, | |||
1310 | */ | 1285 | */ |
1311 | static void | 1286 | static void |
1312 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | 1287 | sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, |
1313 | struct scsi_request *SRpnt, unsigned char *buffer) { | 1288 | unsigned char *buffer) |
1289 | { | ||
1314 | int res; | 1290 | int res; |
1291 | struct scsi_device *sdp = sdkp->device; | ||
1315 | struct scsi_mode_data data; | 1292 | struct scsi_mode_data data; |
1316 | 1293 | ||
1317 | set_disk_ro(sdkp->disk, 0); | 1294 | set_disk_ro(sdkp->disk, 0); |
1318 | if (sdkp->device->skip_ms_page_3f) { | 1295 | if (sdp->skip_ms_page_3f) { |
1319 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); | 1296 | printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); |
1320 | return; | 1297 | return; |
1321 | } | 1298 | } |
1322 | 1299 | ||
1323 | if (sdkp->device->use_192_bytes_for_3f) { | 1300 | if (sdp->use_192_bytes_for_3f) { |
1324 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 192, &data); | 1301 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL); |
1325 | } else { | 1302 | } else { |
1326 | /* | 1303 | /* |
1327 | * First attempt: ask for all pages (0x3F), but only 4 bytes. | 1304 | * First attempt: ask for all pages (0x3F), but only 4 bytes. |
1328 | * We have to start carefully: some devices hang if we ask | 1305 | * We have to start carefully: some devices hang if we ask |
1329 | * for more than is available. | 1306 | * for more than is available. |
1330 | */ | 1307 | */ |
1331 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data); | 1308 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 4, &data, NULL); |
1332 | 1309 | ||
1333 | /* | 1310 | /* |
1334 | * Second attempt: ask for page 0 When only page 0 is | 1311 | * Second attempt: ask for page 0 When only page 0 is |
@@ -1337,14 +1314,14 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1337 | * CDB. | 1314 | * CDB. |
1338 | */ | 1315 | */ |
1339 | if (!scsi_status_is_good(res)) | 1316 | if (!scsi_status_is_good(res)) |
1340 | res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data); | 1317 | res = sd_do_mode_sense(sdp, 0, 0, buffer, 4, &data, NULL); |
1341 | 1318 | ||
1342 | /* | 1319 | /* |
1343 | * Third attempt: ask 255 bytes, as we did earlier. | 1320 | * Third attempt: ask 255 bytes, as we did earlier. |
1344 | */ | 1321 | */ |
1345 | if (!scsi_status_is_good(res)) | 1322 | if (!scsi_status_is_good(res)) |
1346 | res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, | 1323 | res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 255, |
1347 | &data); | 1324 | &data, NULL); |
1348 | } | 1325 | } |
1349 | 1326 | ||
1350 | if (!scsi_status_is_good(res)) { | 1327 | if (!scsi_status_is_good(res)) { |
@@ -1366,19 +1343,20 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, | |||
1366 | */ | 1343 | */ |
1367 | static void | 1344 | static void |
1368 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | 1345 | sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, |
1369 | struct scsi_request *SRpnt, unsigned char *buffer) | 1346 | unsigned char *buffer) |
1370 | { | 1347 | { |
1371 | int len = 0, res; | 1348 | int len = 0, res; |
1349 | struct scsi_device *sdp = sdkp->device; | ||
1372 | 1350 | ||
1373 | int dbd; | 1351 | int dbd; |
1374 | int modepage; | 1352 | int modepage; |
1375 | struct scsi_mode_data data; | 1353 | struct scsi_mode_data data; |
1376 | struct scsi_sense_hdr sshdr; | 1354 | struct scsi_sense_hdr sshdr; |
1377 | 1355 | ||
1378 | if (sdkp->device->skip_ms_page_8) | 1356 | if (sdp->skip_ms_page_8) |
1379 | goto defaults; | 1357 | goto defaults; |
1380 | 1358 | ||
1381 | if (sdkp->device->type == TYPE_RBC) { | 1359 | if (sdp->type == TYPE_RBC) { |
1382 | modepage = 6; | 1360 | modepage = 6; |
1383 | dbd = 8; | 1361 | dbd = 8; |
1384 | } else { | 1362 | } else { |
@@ -1387,7 +1365,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1387 | } | 1365 | } |
1388 | 1366 | ||
1389 | /* cautiously ask */ | 1367 | /* cautiously ask */ |
1390 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4, &data); | 1368 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, 4, &data, &sshdr); |
1391 | 1369 | ||
1392 | if (!scsi_status_is_good(res)) | 1370 | if (!scsi_status_is_good(res)) |
1393 | goto bad_sense; | 1371 | goto bad_sense; |
@@ -1408,7 +1386,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1408 | len += data.header_length + data.block_descriptor_length; | 1386 | len += data.header_length + data.block_descriptor_length; |
1409 | 1387 | ||
1410 | /* Get the data */ | 1388 | /* Get the data */ |
1411 | res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, len, &data); | 1389 | res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); |
1412 | 1390 | ||
1413 | if (scsi_status_is_good(res)) { | 1391 | if (scsi_status_is_good(res)) { |
1414 | const char *types[] = { | 1392 | const char *types[] = { |
@@ -1440,7 +1418,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1440 | } | 1418 | } |
1441 | 1419 | ||
1442 | bad_sense: | 1420 | bad_sense: |
1443 | if (scsi_request_normalize_sense(SRpnt, &sshdr) && | 1421 | if (scsi_sense_valid(&sshdr) && |
1444 | sshdr.sense_key == ILLEGAL_REQUEST && | 1422 | sshdr.sense_key == ILLEGAL_REQUEST && |
1445 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) | 1423 | sshdr.asc == 0x24 && sshdr.ascq == 0x0) |
1446 | printk(KERN_NOTICE "%s: cache data unavailable\n", | 1424 | printk(KERN_NOTICE "%s: cache data unavailable\n", |
@@ -1465,7 +1443,6 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1465 | { | 1443 | { |
1466 | struct scsi_disk *sdkp = scsi_disk(disk); | 1444 | struct scsi_disk *sdkp = scsi_disk(disk); |
1467 | struct scsi_device *sdp = sdkp->device; | 1445 | struct scsi_device *sdp = sdkp->device; |
1468 | struct scsi_request *sreq; | ||
1469 | unsigned char *buffer; | 1446 | unsigned char *buffer; |
1470 | 1447 | ||
1471 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); | 1448 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); |
@@ -1477,18 +1454,11 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1477 | if (!scsi_device_online(sdp)) | 1454 | if (!scsi_device_online(sdp)) |
1478 | goto out; | 1455 | goto out; |
1479 | 1456 | ||
1480 | sreq = scsi_allocate_request(sdp, GFP_KERNEL); | ||
1481 | if (!sreq) { | ||
1482 | printk(KERN_WARNING "(sd_revalidate_disk:) Request allocation " | ||
1483 | "failure.\n"); | ||
1484 | goto out; | ||
1485 | } | ||
1486 | |||
1487 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); | 1457 | buffer = kmalloc(512, GFP_KERNEL | __GFP_DMA); |
1488 | if (!buffer) { | 1458 | if (!buffer) { |
1489 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " | 1459 | printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " |
1490 | "failure.\n"); | 1460 | "failure.\n"); |
1491 | goto out_release_request; | 1461 | goto out; |
1492 | } | 1462 | } |
1493 | 1463 | ||
1494 | /* defaults, until the device tells us otherwise */ | 1464 | /* defaults, until the device tells us otherwise */ |
@@ -1499,25 +1469,23 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1499 | sdkp->WCE = 0; | 1469 | sdkp->WCE = 0; |
1500 | sdkp->RCD = 0; | 1470 | sdkp->RCD = 0; |
1501 | 1471 | ||
1502 | sd_spinup_disk(sdkp, disk->disk_name, sreq, buffer); | 1472 | sd_spinup_disk(sdkp, disk->disk_name); |
1503 | 1473 | ||
1504 | /* | 1474 | /* |
1505 | * Without media there is no reason to ask; moreover, some devices | 1475 | * Without media there is no reason to ask; moreover, some devices |
1506 | * react badly if we do. | 1476 | * react badly if we do. |
1507 | */ | 1477 | */ |
1508 | if (sdkp->media_present) { | 1478 | if (sdkp->media_present) { |
1509 | sd_read_capacity(sdkp, disk->disk_name, sreq, buffer); | 1479 | sd_read_capacity(sdkp, disk->disk_name, buffer); |
1510 | if (sdp->removable) | 1480 | if (sdp->removable) |
1511 | sd_read_write_protect_flag(sdkp, disk->disk_name, | 1481 | sd_read_write_protect_flag(sdkp, disk->disk_name, |
1512 | sreq, buffer); | 1482 | buffer); |
1513 | sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer); | 1483 | sd_read_cache_type(sdkp, disk->disk_name, buffer); |
1514 | } | 1484 | } |
1515 | 1485 | ||
1516 | set_capacity(disk, sdkp->capacity); | 1486 | set_capacity(disk, sdkp->capacity); |
1517 | kfree(buffer); | 1487 | kfree(buffer); |
1518 | 1488 | ||
1519 | out_release_request: | ||
1520 | scsi_release_request(sreq); | ||
1521 | out: | 1489 | out: |
1522 | return 0; | 1490 | return 0; |
1523 | } | 1491 | } |