diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/constants.c | 48 | ||||
-rw-r--r-- | drivers/scsi/scsi_ioctl.c | 15 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 67 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 13 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 160 |
5 files changed, 139 insertions, 164 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 0d58d3538bdf..f6be2c1c3942 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -1156,6 +1156,31 @@ scsi_show_extd_sense(unsigned char asc, unsigned char ascq) | |||
1156 | } | 1156 | } |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | void | ||
1160 | scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) | ||
1161 | { | ||
1162 | const char *sense_txt; | ||
1163 | /* An example of deferred is when an earlier write to disk cache | ||
1164 | * succeeded, but now the disk discovers that it cannot write the | ||
1165 | * data to the magnetic media. | ||
1166 | */ | ||
1167 | const char *error = scsi_sense_is_deferred(sshdr) ? | ||
1168 | "<<DEFERRED>>" : "Current"; | ||
1169 | printk(KERN_INFO "%s: %s", name, error); | ||
1170 | if (sshdr->response_code >= 0x72) | ||
1171 | printk(" [descriptor]"); | ||
1172 | |||
1173 | sense_txt = scsi_sense_key_string(sshdr->sense_key); | ||
1174 | if (sense_txt) | ||
1175 | printk(": sense key: %s\n", sense_txt); | ||
1176 | else | ||
1177 | printk(": sense key=0x%x\n", sshdr->sense_key); | ||
1178 | printk(KERN_INFO " "); | ||
1179 | scsi_show_extd_sense(sshdr->asc, sshdr->ascq); | ||
1180 | printk("\n"); | ||
1181 | } | ||
1182 | EXPORT_SYMBOL(scsi_print_sense_hdr); | ||
1183 | |||
1159 | /* Print sense information */ | 1184 | /* Print sense information */ |
1160 | void | 1185 | void |
1161 | __scsi_print_sense(const char *name, const unsigned char *sense_buffer, | 1186 | __scsi_print_sense(const char *name, const unsigned char *sense_buffer, |
@@ -1163,8 +1188,6 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer, | |||
1163 | { | 1188 | { |
1164 | int k, num, res; | 1189 | int k, num, res; |
1165 | unsigned int info; | 1190 | unsigned int info; |
1166 | const char *error; | ||
1167 | const char *sense_txt; | ||
1168 | struct scsi_sense_hdr ssh; | 1191 | struct scsi_sense_hdr ssh; |
1169 | 1192 | ||
1170 | res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); | 1193 | res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); |
@@ -1182,26 +1205,7 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer, | |||
1182 | printk("\n"); | 1205 | printk("\n"); |
1183 | return; | 1206 | return; |
1184 | } | 1207 | } |
1185 | 1208 | scsi_print_sense_hdr(name, &ssh); | |
1186 | /* An example of deferred is when an earlier write to disk cache | ||
1187 | * succeeded, but now the disk discovers that it cannot write the | ||
1188 | * data to the magnetic media. | ||
1189 | */ | ||
1190 | error = scsi_sense_is_deferred(&ssh) ? | ||
1191 | "<<DEFERRED>>" : "Current"; | ||
1192 | printk(KERN_INFO "%s: %s", name, error); | ||
1193 | if (ssh.response_code >= 0x72) | ||
1194 | printk(" [descriptor]"); | ||
1195 | |||
1196 | sense_txt = scsi_sense_key_string(ssh.sense_key); | ||
1197 | if (sense_txt) | ||
1198 | printk(": sense key: %s\n", sense_txt); | ||
1199 | else | ||
1200 | printk(": sense key=0x%x\n", ssh.sense_key); | ||
1201 | printk(KERN_INFO " "); | ||
1202 | scsi_show_extd_sense(ssh.asc, ssh.ascq); | ||
1203 | printk("\n"); | ||
1204 | |||
1205 | if (ssh.response_code < 0x72) { | 1209 | if (ssh.response_code < 0x72) { |
1206 | /* only decode extras for "fixed" format now */ | 1210 | /* only decode extras for "fixed" format now */ |
1207 | char buff[80]; | 1211 | char buff[80]; |
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 5f399c9c68ee..179a767d221d 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c | |||
@@ -90,19 +90,16 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, | |||
90 | { | 90 | { |
91 | int result; | 91 | int result; |
92 | struct scsi_sense_hdr sshdr; | 92 | struct scsi_sense_hdr sshdr; |
93 | char sense[SCSI_SENSE_BUFFERSIZE]; | ||
94 | 93 | ||
95 | SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); | 94 | SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); |
96 | 95 | ||
97 | |||
98 | memset(sense, 0, sizeof(*sense)); | ||
99 | result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, | 96 | result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, |
100 | sense, timeout, retries); | 97 | &sshdr, timeout, retries); |
101 | 98 | ||
102 | SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result)); | 99 | SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result)); |
103 | 100 | ||
104 | if ((driver_byte(result) & DRIVER_SENSE) && | 101 | if ((driver_byte(result) & DRIVER_SENSE) && |
105 | (scsi_normalize_sense(sense, sizeof(*sense), &sshdr))) { | 102 | (scsi_sense_valid(&sshdr))) { |
106 | switch (sshdr.sense_key) { | 103 | switch (sshdr.sense_key) { |
107 | case ILLEGAL_REQUEST: | 104 | case ILLEGAL_REQUEST: |
108 | if (cmd[0] == ALLOW_MEDIUM_REMOVAL) | 105 | if (cmd[0] == ALLOW_MEDIUM_REMOVAL) |
@@ -132,7 +129,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, | |||
132 | sdev->id, | 129 | sdev->id, |
133 | sdev->lun, | 130 | sdev->lun, |
134 | result); | 131 | result); |
135 | __scsi_print_sense(" ", sense, sizeof(*sense)); | 132 | scsi_print_sense_hdr(" ", &sshdr); |
136 | break; | 133 | break; |
137 | } | 134 | } |
138 | } | 135 | } |
@@ -315,9 +312,9 @@ int scsi_ioctl_send_command(struct scsi_device *sdev, | |||
315 | break; | 312 | break; |
316 | } | 313 | } |
317 | 314 | ||
318 | result = scsi_execute_req(sdev, cmd, data_direction, buf, needed, | 315 | result = scsi_execute(sdev, cmd, data_direction, buf, needed, |
319 | sense, timeout, retries); | 316 | sense, timeout, retries, 0); |
320 | 317 | ||
321 | /* | 318 | /* |
322 | * If there was an error condition, pass the info back to the user. | 319 | * If there was an error condition, pass the info back to the user. |
323 | */ | 320 | */ |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 42edf29223ab..bdea26b56dc4 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -293,8 +293,8 @@ EXPORT_SYMBOL(scsi_wait_req); | |||
293 | * @retries: number of times to retry request | 293 | * @retries: number of times to retry request |
294 | * @flags: or into request flags; | 294 | * @flags: or into request flags; |
295 | * | 295 | * |
296 | * scsi_execute_req returns the req->errors value which is the | 296 | * returns the req->errors value which is the the scsi_cmnd result |
297 | * the scsi_cmnd result field. | 297 | * field. |
298 | **/ | 298 | **/ |
299 | int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | 299 | int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, |
300 | int data_direction, void *buffer, unsigned bufflen, | 300 | int data_direction, void *buffer, unsigned bufflen, |
@@ -328,9 +328,31 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | |||
328 | 328 | ||
329 | return ret; | 329 | return ret; |
330 | } | 330 | } |
331 | |||
332 | EXPORT_SYMBOL(scsi_execute); | 331 | EXPORT_SYMBOL(scsi_execute); |
333 | 332 | ||
333 | |||
334 | int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, | ||
335 | int data_direction, void *buffer, unsigned bufflen, | ||
336 | struct scsi_sense_hdr *sshdr, int timeout, int retries) | ||
337 | { | ||
338 | char *sense = NULL; | ||
339 | |||
340 | if (sshdr) { | ||
341 | sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); | ||
342 | if (!sense) | ||
343 | return DRIVER_ERROR << 24; | ||
344 | memset(sense, 0, sizeof(*sense)); | ||
345 | } | ||
346 | int result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, | ||
347 | sense, timeout, retries, 0); | ||
348 | if (sshdr) | ||
349 | scsi_normalize_sense(sense, sizeof(*sense), sshdr); | ||
350 | |||
351 | kfree(sense); | ||
352 | return result; | ||
353 | } | ||
354 | EXPORT_SYMBOL(scsi_execute_req); | ||
355 | |||
334 | /* | 356 | /* |
335 | * Function: scsi_init_cmd_errh() | 357 | * Function: scsi_init_cmd_errh() |
336 | * | 358 | * |
@@ -1614,7 +1636,7 @@ void scsi_exit_queue(void) | |||
1614 | } | 1636 | } |
1615 | } | 1637 | } |
1616 | /** | 1638 | /** |
1617 | * __scsi_mode_sense - issue a mode sense, falling back from 10 to | 1639 | * scsi_mode_sense - issue a mode sense, falling back from 10 to |
1618 | * six bytes if necessary. | 1640 | * six bytes if necessary. |
1619 | * @sdev: SCSI device to be queried | 1641 | * @sdev: SCSI device to be queried |
1620 | * @dbd: set if mode sense will allow block descriptors to be returned | 1642 | * @dbd: set if mode sense will allow block descriptors to be returned |
@@ -1634,26 +1656,22 @@ void scsi_exit_queue(void) | |||
1634 | int | 1656 | int |
1635 | scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, | 1657 | scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, |
1636 | unsigned char *buffer, int len, int timeout, int retries, | 1658 | unsigned char *buffer, int len, int timeout, int retries, |
1637 | struct scsi_mode_data *data, char *sense) { | 1659 | struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr) { |
1638 | unsigned char cmd[12]; | 1660 | unsigned char cmd[12]; |
1639 | int use_10_for_ms; | 1661 | int use_10_for_ms; |
1640 | int header_length; | 1662 | int header_length; |
1641 | int result; | 1663 | int result; |
1642 | char *sense_buffer = NULL; | 1664 | struct scsi_sense_hdr my_sshdr; |
1643 | 1665 | ||
1644 | memset(data, 0, sizeof(*data)); | 1666 | memset(data, 0, sizeof(*data)); |
1645 | memset(&cmd[0], 0, 12); | 1667 | memset(&cmd[0], 0, 12); |
1646 | cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ | 1668 | cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ |
1647 | cmd[2] = modepage; | 1669 | cmd[2] = modepage; |
1648 | 1670 | ||
1649 | if (!sense) { | 1671 | /* caller might not be interested in sense, but we need it */ |
1650 | sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); | 1672 | if (!sshdr) |
1651 | if (!sense_buffer) { | 1673 | sshdr = &my_sshdr; |
1652 | dev_printk(KERN_ERR, &sdev->sdev_gendev, "failed to allocate sense buffer\n"); | 1674 | |
1653 | return 0; | ||
1654 | } | ||
1655 | sense = sense_buffer; | ||
1656 | } | ||
1657 | retry: | 1675 | retry: |
1658 | use_10_for_ms = sdev->use_10_for_ms; | 1676 | use_10_for_ms = sdev->use_10_for_ms; |
1659 | 1677 | ||
@@ -1673,12 +1691,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, | |||
1673 | header_length = 4; | 1691 | header_length = 4; |
1674 | } | 1692 | } |
1675 | 1693 | ||
1676 | memset(sense, 0, SCSI_SENSE_BUFFERSIZE); | ||
1677 | |||
1678 | memset(buffer, 0, len); | 1694 | memset(buffer, 0, len); |
1679 | 1695 | ||
1680 | result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, | 1696 | result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, |
1681 | sense, timeout, retries); | 1697 | sshdr, timeout, retries); |
1682 | 1698 | ||
1683 | /* This code looks awful: what it's doing is making sure an | 1699 | /* This code looks awful: what it's doing is making sure an |
1684 | * ILLEGAL REQUEST sense return identifies the actual command | 1700 | * ILLEGAL REQUEST sense return identifies the actual command |
@@ -1687,11 +1703,9 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, | |||
1687 | 1703 | ||
1688 | if (use_10_for_ms && !scsi_status_is_good(result) && | 1704 | if (use_10_for_ms && !scsi_status_is_good(result) && |
1689 | (driver_byte(result) & DRIVER_SENSE)) { | 1705 | (driver_byte(result) & DRIVER_SENSE)) { |
1690 | struct scsi_sense_hdr sshdr; | 1706 | if (scsi_sense_valid(sshdr)) { |
1691 | 1707 | if ((sshdr->sense_key == ILLEGAL_REQUEST) && | |
1692 | if (scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) { | 1708 | (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { |
1693 | if ((sshdr.sense_key == ILLEGAL_REQUEST) && | ||
1694 | (sshdr.asc == 0x20) && (sshdr.ascq == 0)) { | ||
1695 | /* | 1709 | /* |
1696 | * Invalid command operation code | 1710 | * Invalid command operation code |
1697 | */ | 1711 | */ |
@@ -1718,7 +1732,6 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, | |||
1718 | } | 1732 | } |
1719 | } | 1733 | } |
1720 | 1734 | ||
1721 | kfree(sense_buffer); | ||
1722 | return result; | 1735 | return result; |
1723 | } | 1736 | } |
1724 | EXPORT_SYMBOL(scsi_mode_sense); | 1737 | EXPORT_SYMBOL(scsi_mode_sense); |
@@ -1729,17 +1742,15 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries) | |||
1729 | char cmd[] = { | 1742 | char cmd[] = { |
1730 | TEST_UNIT_READY, 0, 0, 0, 0, 0, | 1743 | TEST_UNIT_READY, 0, 0, 0, 0, 0, |
1731 | }; | 1744 | }; |
1732 | char sense[SCSI_SENSE_BUFFERSIZE]; | 1745 | struct scsi_sense_hdr sshdr; |
1733 | int result; | 1746 | int result; |
1734 | 1747 | ||
1735 | result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sense, | 1748 | result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, &sshdr, |
1736 | timeout, retries); | 1749 | timeout, retries); |
1737 | 1750 | ||
1738 | if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { | 1751 | if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { |
1739 | struct scsi_sense_hdr sshdr; | ||
1740 | 1752 | ||
1741 | if ((scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, | 1753 | if ((scsi_sense_valid(&sshdr)) && |
1742 | &sshdr)) && | ||
1743 | ((sshdr.sense_key == UNIT_ATTENTION) || | 1754 | ((sshdr.sense_key == UNIT_ATTENTION) || |
1744 | (sshdr.sense_key == NOT_READY))) { | 1755 | (sshdr.sense_key == NOT_READY))) { |
1745 | sdev->changed = 1; | 1756 | sdev->changed = 1; |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 0048beaffc9f..19c9a232a754 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -446,7 +446,6 @@ void scsi_target_reap(struct scsi_target *starget) | |||
446 | static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, | 446 | static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, |
447 | int result_len, int *bflags) | 447 | int result_len, int *bflags) |
448 | { | 448 | { |
449 | char sense[SCSI_SENSE_BUFFERSIZE]; | ||
450 | unsigned char scsi_cmd[MAX_COMMAND_SIZE]; | 449 | unsigned char scsi_cmd[MAX_COMMAND_SIZE]; |
451 | int first_inquiry_len, try_inquiry_len, next_inquiry_len; | 450 | int first_inquiry_len, try_inquiry_len, next_inquiry_len; |
452 | int response_len = 0; | 451 | int response_len = 0; |
@@ -474,11 +473,10 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, | |||
474 | scsi_cmd[0] = INQUIRY; | 473 | scsi_cmd[0] = INQUIRY; |
475 | scsi_cmd[4] = (unsigned char) try_inquiry_len; | 474 | scsi_cmd[4] = (unsigned char) try_inquiry_len; |
476 | 475 | ||
477 | memset(sense, 0, sizeof(sense)); | ||
478 | memset(inq_result, 0, try_inquiry_len); | 476 | memset(inq_result, 0, try_inquiry_len); |
479 | 477 | ||
480 | result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, | 478 | result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, |
481 | inq_result, try_inquiry_len, sense, | 479 | inq_result, try_inquiry_len, &sshdr, |
482 | HZ / 2 + HZ * scsi_inq_timeout, 3); | 480 | HZ / 2 + HZ * scsi_inq_timeout, 3); |
483 | 481 | ||
484 | SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s " | 482 | SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s " |
@@ -493,8 +491,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, | |||
493 | * but many buggy devices do so anyway. | 491 | * but many buggy devices do so anyway. |
494 | */ | 492 | */ |
495 | if ((driver_byte(result) & DRIVER_SENSE) && | 493 | if ((driver_byte(result) & DRIVER_SENSE) && |
496 | scsi_normalize_sense(sense, sizeof(sense), | 494 | scsi_sense_valid(&sshdr)) { |
497 | &sshdr)) { | ||
498 | if ((sshdr.sense_key == UNIT_ATTENTION) && | 495 | if ((sshdr.sense_key == UNIT_ATTENTION) && |
499 | ((sshdr.asc == 0x28) || | 496 | ((sshdr.asc == 0x28) || |
500 | (sshdr.asc == 0x29)) && | 497 | (sshdr.asc == 0x29)) && |
@@ -1057,7 +1054,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, | |||
1057 | int rescan) | 1054 | int rescan) |
1058 | { | 1055 | { |
1059 | char devname[64]; | 1056 | char devname[64]; |
1060 | char sense[SCSI_SENSE_BUFFERSIZE]; | ||
1061 | unsigned char scsi_cmd[MAX_COMMAND_SIZE]; | 1057 | unsigned char scsi_cmd[MAX_COMMAND_SIZE]; |
1062 | unsigned int length; | 1058 | unsigned int length; |
1063 | unsigned int lun; | 1059 | unsigned int lun; |
@@ -1134,9 +1130,8 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, | |||
1134 | " REPORT LUNS to %s (try %d)\n", devname, | 1130 | " REPORT LUNS to %s (try %d)\n", devname, |
1135 | retries)); | 1131 | retries)); |
1136 | 1132 | ||
1137 | memset(sense, 0, sizeof(sense)); | ||
1138 | result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, | 1133 | result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, |
1139 | lun_data, length, sense, | 1134 | lun_data, length, &sshdr, |
1140 | SCSI_TIMEOUT + 4 * HZ, 3); | 1135 | SCSI_TIMEOUT + 4 * HZ, 3); |
1141 | 1136 | ||
1142 | SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS" | 1137 | SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS" |
@@ -1144,7 +1139,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, | |||
1144 | ? "failed" : "successful", retries, result)); | 1139 | ? "failed" : "successful", retries, result)); |
1145 | if (result == 0) | 1140 | if (result == 0) |
1146 | break; | 1141 | break; |
1147 | else if (scsi_normalize_sense(sense, sizeof(sense), &sshdr)) { | 1142 | else if (scsi_sense_valid(&sshdr)) { |
1148 | if (sshdr.sense_key != UNIT_ATTENTION) | 1143 | if (sshdr.sense_key != UNIT_ATTENTION) |
1149 | break; | 1144 | break; |
1150 | } | 1145 | } |
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 | } |