aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/3w-xxxx.c57
-rw-r--r--drivers/scsi/Kconfig8
-rw-r--r--drivers/scsi/aacraid/aacraid.h6
-rw-r--r--drivers/scsi/aacraid/linit.c3
-rw-r--r--drivers/scsi/ahci.c1
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c24
-rw-r--r--drivers/scsi/arm/Kconfig2
-rw-r--r--drivers/scsi/ata_piix.c2
-rw-r--r--drivers/scsi/ch.c38
-rw-r--r--drivers/scsi/constants.c48
-rw-r--r--drivers/scsi/dc395x.c48
-rw-r--r--drivers/scsi/dpt_i2o.c9
-rw-r--r--drivers/scsi/ibmvscsi/srp.h2
-rw-r--r--drivers/scsi/ips.c8
-rw-r--r--drivers/scsi/ips.h39
-rw-r--r--drivers/scsi/libata-core.c25
-rw-r--r--drivers/scsi/libata-scsi.c1
-rw-r--r--drivers/scsi/libata.h2
-rw-r--r--drivers/scsi/sata_promise.c2
-rw-r--r--drivers/scsi/sata_sx4.c2
-rw-r--r--drivers/scsi/scsi_error.c6
-rw-r--r--drivers/scsi/scsi_ioctl.c43
-rw-r--r--drivers/scsi/scsi_lib.c292
-rw-r--r--drivers/scsi/scsi_scan.c123
-rw-r--r--drivers/scsi/scsi_transport_fc.c19
-rw-r--r--drivers/scsi/scsi_transport_spi.c126
-rw-r--r--drivers/scsi/sd.c161
-rw-r--r--drivers/scsi/sg.c13
-rw-r--r--drivers/scsi/sr.c51
-rw-r--r--drivers/scsi/sr_ioctl.c62
-rw-r--r--drivers/scsi/st.c8
31 files changed, 594 insertions, 637 deletions
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 973c51fb0fe2..ae9e0203e9de 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1499,22 +1499,43 @@ static int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id)
1499 return 0; 1499 return 0;
1500} /* End tw_scsiop_inquiry() */ 1500} /* End tw_scsiop_inquiry() */
1501 1501
1502static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id,
1503 void *data, unsigned int len)
1504{
1505 struct scsi_cmnd *cmd = tw_dev->srb[request_id];
1506 void *buf;
1507 unsigned int transfer_len;
1508
1509 if (cmd->use_sg) {
1510 struct scatterlist *sg =
1511 (struct scatterlist *)cmd->request_buffer;
1512 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1513 transfer_len = min(sg->length, len);
1514 } else {
1515 buf = cmd->request_buffer;
1516 transfer_len = min(cmd->request_bufflen, len);
1517 }
1518
1519 memcpy(buf, data, transfer_len);
1520
1521 if (cmd->use_sg) {
1522 struct scatterlist *sg;
1523
1524 sg = (struct scatterlist *)cmd->request_buffer;
1525 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1526 }
1527}
1528
1502/* This function is called by the isr to complete an inquiry command */ 1529/* This function is called by the isr to complete an inquiry command */
1503static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id) 1530static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id)
1504{ 1531{
1505 unsigned char *is_unit_present; 1532 unsigned char *is_unit_present;
1506 unsigned char *request_buffer; 1533 unsigned char request_buffer[36];
1507 TW_Param *param; 1534 TW_Param *param;
1508 1535
1509 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry_complete()\n"); 1536 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry_complete()\n");
1510 1537
1511 /* Fill request buffer */ 1538 memset(request_buffer, 0, sizeof(request_buffer));
1512 if (tw_dev->srb[request_id]->request_buffer == NULL) {
1513 printk(KERN_WARNING "3w-xxxx: tw_scsiop_inquiry_complete(): Request buffer NULL.\n");
1514 return 1;
1515 }
1516 request_buffer = tw_dev->srb[request_id]->request_buffer;
1517 memset(request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
1518 request_buffer[0] = TYPE_DISK; /* Peripheral device type */ 1539 request_buffer[0] = TYPE_DISK; /* Peripheral device type */
1519 request_buffer[1] = 0; /* Device type modifier */ 1540 request_buffer[1] = 0; /* Device type modifier */
1520 request_buffer[2] = 0; /* No ansi/iso compliance */ 1541 request_buffer[2] = 0; /* No ansi/iso compliance */
@@ -1522,6 +1543,8 @@ static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_i
1522 memcpy(&request_buffer[8], "3ware ", 8); /* Vendor ID */ 1543 memcpy(&request_buffer[8], "3ware ", 8); /* Vendor ID */
1523 sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id); 1544 sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id);
1524 memcpy(&request_buffer[32], TW_DRIVER_VERSION, 3); 1545 memcpy(&request_buffer[32], TW_DRIVER_VERSION, 3);
1546 tw_transfer_internal(tw_dev, request_id, request_buffer,
1547 sizeof(request_buffer));
1525 1548
1526 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; 1549 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
1527 if (param == NULL) { 1550 if (param == NULL) {
@@ -1612,7 +1635,7 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques
1612{ 1635{
1613 TW_Param *param; 1636 TW_Param *param;
1614 unsigned char *flags; 1637 unsigned char *flags;
1615 unsigned char *request_buffer; 1638 unsigned char request_buffer[8];
1616 1639
1617 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_mode_sense_complete()\n"); 1640 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_mode_sense_complete()\n");
1618 1641
@@ -1622,8 +1645,7 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques
1622 return 1; 1645 return 1;
1623 } 1646 }
1624 flags = (char *)&(param->data[0]); 1647 flags = (char *)&(param->data[0]);
1625 request_buffer = tw_dev->srb[request_id]->buffer; 1648 memset(request_buffer, 0, sizeof(request_buffer));
1626 memset(request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
1627 1649
1628 request_buffer[0] = 0xf; /* mode data length */ 1650 request_buffer[0] = 0xf; /* mode data length */
1629 request_buffer[1] = 0; /* default medium type */ 1651 request_buffer[1] = 0; /* default medium type */
@@ -1635,6 +1657,8 @@ static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int reques
1635 request_buffer[6] = 0x4; /* WCE on */ 1657 request_buffer[6] = 0x4; /* WCE on */
1636 else 1658 else
1637 request_buffer[6] = 0x0; /* WCE off */ 1659 request_buffer[6] = 0x0; /* WCE off */
1660 tw_transfer_internal(tw_dev, request_id, request_buffer,
1661 sizeof(request_buffer));
1638 1662
1639 return 0; 1663 return 0;
1640} /* End tw_scsiop_mode_sense_complete() */ 1664} /* End tw_scsiop_mode_sense_complete() */
@@ -1701,17 +1725,12 @@ static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int req
1701{ 1725{
1702 unsigned char *param_data; 1726 unsigned char *param_data;
1703 u32 capacity; 1727 u32 capacity;
1704 char *buff; 1728 char buff[8];
1705 TW_Param *param; 1729 TW_Param *param;
1706 1730
1707 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity_complete()\n"); 1731 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity_complete()\n");
1708 1732
1709 buff = tw_dev->srb[request_id]->request_buffer; 1733 memset(buff, 0, sizeof(buff));
1710 if (buff == NULL) {
1711 printk(KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Request buffer NULL.\n");
1712 return 1;
1713 }
1714 memset(buff, 0, tw_dev->srb[request_id]->request_bufflen);
1715 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; 1734 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
1716 if (param == NULL) { 1735 if (param == NULL) {
1717 printk(KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Bad alignment virtual address.\n"); 1736 printk(KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Bad alignment virtual address.\n");
@@ -1739,6 +1758,8 @@ static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int req
1739 buff[6] = (TW_BLOCK_SIZE >> 8) & 0xff; 1758 buff[6] = (TW_BLOCK_SIZE >> 8) & 0xff;
1740 buff[7] = TW_BLOCK_SIZE & 0xff; 1759 buff[7] = TW_BLOCK_SIZE & 0xff;
1741 1760
1761 tw_transfer_internal(tw_dev, request_id, buff, sizeof(buff));
1762
1742 return 0; 1763 return 0;
1743} /* End tw_scsiop_read_capacity_complete() */ 1764} /* End tw_scsiop_read_capacity_complete() */
1744 1765
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 68adc3cc8ad2..b3ae796eb624 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -430,7 +430,7 @@ config SCSI_IN2000
430source "drivers/scsi/megaraid/Kconfig.megaraid" 430source "drivers/scsi/megaraid/Kconfig.megaraid"
431 431
432config SCSI_SATA 432config SCSI_SATA
433 bool "Serial ATA (SATA) support" 433 tristate "Serial ATA (SATA) support"
434 depends on SCSI 434 depends on SCSI
435 help 435 help
436 This driver family supports Serial ATA host controllers 436 This driver family supports Serial ATA host controllers
@@ -1702,7 +1702,7 @@ config TT_DMA_EMUL
1702 1702
1703config MAC_SCSI 1703config MAC_SCSI
1704 bool "Macintosh NCR5380 SCSI" 1704 bool "Macintosh NCR5380 SCSI"
1705 depends on MAC && SCSI 1705 depends on MAC && SCSI=y
1706 help 1706 help
1707 This is the NCR 5380 SCSI controller included on most of the 68030 1707 This is the NCR 5380 SCSI controller included on most of the 68030
1708 based Macintoshes. If you have one of these say Y and read the 1708 based Macintoshes. If you have one of these say Y and read the
@@ -1723,7 +1723,7 @@ config SCSI_MAC_ESP
1723 1723
1724config MVME147_SCSI 1724config MVME147_SCSI
1725 bool "WD33C93 SCSI driver for MVME147" 1725 bool "WD33C93 SCSI driver for MVME147"
1726 depends on MVME147 && SCSI 1726 depends on MVME147 && SCSI=y
1727 help 1727 help
1728 Support for the on-board SCSI controller on the Motorola MVME147 1728 Support for the on-board SCSI controller on the Motorola MVME147
1729 single-board computer. 1729 single-board computer.
@@ -1764,7 +1764,7 @@ config SUN3_SCSI
1764 1764
1765config SUN3X_ESP 1765config SUN3X_ESP
1766 bool "Sun3x ESP SCSI" 1766 bool "Sun3x ESP SCSI"
1767 depends on SUN3X && SCSI 1767 depends on SUN3X && SCSI=y
1768 help 1768 help
1769 The ESP was an on-board SCSI controller used on Sun 3/80 1769 The ESP was an on-board SCSI controller used on Sun 3/80
1770 machines. Say Y here to compile in support for it. 1770 machines. Say Y here to compile in support for it.
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index bc91e7ce5e59..e40528185d48 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -15,11 +15,7 @@
15#define AAC_MAX_LUN (8) 15#define AAC_MAX_LUN (8)
16 16
17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
18/* 18#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)512)
19 * max_sectors is an unsigned short, otherwise limit is 0x100000000 / 512
20 * Linux has starvation problems if we permit larger than 4MB I/O ...
21 */
22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)8192)
23 19
24/* 20/*
25 * These macros convert from physical channels to virtual channels 21 * These macros convert from physical channels to virtual channels
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 2bd594267881..4ff29d7f5825 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -391,7 +391,8 @@ static int aac_slave_configure(struct scsi_device *sdev)
391 else 391 else
392 scsi_adjust_queue_depth(sdev, 0, 1); 392 scsi_adjust_queue_depth(sdev, 0, 1);
393 393
394 if (host->max_sectors < AAC_MAX_32BIT_SGBCOUNT) 394 if (!(((struct aac_dev *)host->hostdata)->adapter_info.options
395 & AAC_OPT_NEW_COMM))
395 blk_queue_max_segment_size(sdev->request_queue, 65536); 396 blk_queue_max_segment_size(sdev->request_queue, 65536);
396 397
397 return 0; 398 return 0;
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index c5623694d10f..e3b9692b9688 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -1105,6 +1105,7 @@ MODULE_AUTHOR("Jeff Garzik");
1105MODULE_DESCRIPTION("AHCI SATA low-level driver"); 1105MODULE_DESCRIPTION("AHCI SATA low-level driver");
1106MODULE_LICENSE("GPL"); 1106MODULE_LICENSE("GPL");
1107MODULE_DEVICE_TABLE(pci, ahci_pci_tbl); 1107MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
1108MODULE_VERSION(DRV_VERSION);
1108 1109
1109module_init(ahci_init); 1110module_init(ahci_init);
1110module_exit(ahci_exit); 1111module_exit(ahci_exit);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 4096d523d08d..c932b3b94490 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1339,14 +1339,12 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1339 } 1339 }
1340 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1340 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
1341 case AHC_DEV_Q_BASIC: 1341 case AHC_DEV_Q_BASIC:
1342 scsi_adjust_queue_depth(sdev, 1342 scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
1343 MSG_SIMPLE_TASK, 1343 scsi_activate_tcq(sdev, dev->openings + dev->active);
1344 dev->openings + dev->active);
1345 break; 1344 break;
1346 case AHC_DEV_Q_TAGGED: 1345 case AHC_DEV_Q_TAGGED:
1347 scsi_adjust_queue_depth(sdev, 1346 scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
1348 MSG_ORDERED_TASK, 1347 scsi_activate_tcq(sdev, dev->openings + dev->active);
1349 dev->openings + dev->active);
1350 break; 1348 break;
1351 default: 1349 default:
1352 /* 1350 /*
@@ -1355,9 +1353,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1355 * serially on the controller/device. This should 1353 * serially on the controller/device. This should
1356 * remove some latency. 1354 * remove some latency.
1357 */ 1355 */
1358 scsi_adjust_queue_depth(sdev, 1356 scsi_deactivate_tcq(sdev, 2);
1359 /*NON-TAGGED*/0,
1360 /*queue depth*/2);
1361 break; 1357 break;
1362 } 1358 }
1363} 1359}
@@ -1710,9 +1706,9 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
1710 spi_period(starget) = tinfo->curr.period; 1706 spi_period(starget) = tinfo->curr.period;
1711 spi_width(starget) = tinfo->curr.width; 1707 spi_width(starget) = tinfo->curr.width;
1712 spi_offset(starget) = tinfo->curr.offset; 1708 spi_offset(starget) = tinfo->curr.offset;
1713 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ; 1709 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ ? 1 : 0;
1714 spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ; 1710 spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ ? 1 : 0;
1715 spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ; 1711 spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ ? 1 : 0;
1716 spi_display_xfer_agreement(starget); 1712 spi_display_xfer_agreement(starget);
1717 break; 1713 break;
1718 } 1714 }
@@ -2502,12 +2498,14 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
2502 unsigned int ppr_options = tinfo->goal.ppr_options 2498 unsigned int ppr_options = tinfo->goal.ppr_options
2503 & ~MSG_EXT_PPR_DT_REQ; 2499 & ~MSG_EXT_PPR_DT_REQ;
2504 unsigned int period = tinfo->goal.period; 2500 unsigned int period = tinfo->goal.period;
2501 unsigned int width = tinfo->goal.width;
2505 unsigned long flags; 2502 unsigned long flags;
2506 struct ahc_syncrate *syncrate; 2503 struct ahc_syncrate *syncrate;
2507 2504
2508 if (dt) { 2505 if (dt) {
2509 period = 9; /* 12.5ns is the only period valid for DT */
2510 ppr_options |= MSG_EXT_PPR_DT_REQ; 2506 ppr_options |= MSG_EXT_PPR_DT_REQ;
2507 if (!width)
2508 ahc_linux_set_width(starget, 1);
2511 } else if (period == 9) 2509 } else if (period == 9)
2512 period = 10; /* if resetting DT, period must be >= 25ns */ 2510 period = 10; /* if resetting DT, period must be >= 25ns */
2513 2511
diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig
index 54b32868aaf7..13f23043c8a3 100644
--- a/drivers/scsi/arm/Kconfig
+++ b/drivers/scsi/arm/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config SCSI_ACORNSCSI_3 4config SCSI_ACORNSCSI_3
5 tristate "Acorn SCSI card (aka30) support" 5 tristate "Acorn SCSI card (aka30) support"
6 depends on ARCH_ACORN && SCSI 6 depends on ARCH_ACORN && SCSI && BROKEN
7 help 7 help
8 This enables support for the Acorn SCSI card (aka30). If you have an 8 This enables support for the Acorn SCSI card (aka30). If you have an
9 Acorn system with one of these, say Y. If unsure, say N. 9 Acorn system with one of these, say Y. If unsure, say N.
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index a2cfade2c1c6..d96ebf9d2228 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -32,7 +32,7 @@
32#include <linux/libata.h> 32#include <linux/libata.h>
33 33
34#define DRV_NAME "ata_piix" 34#define DRV_NAME "ata_piix"
35#define DRV_VERSION "1.03" 35#define DRV_VERSION "1.04"
36 36
37enum { 37enum {
38 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ 38 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 53b395534313..bd0e1b6be1ea 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -30,7 +30,7 @@
30#include <scsi/scsi_ioctl.h> 30#include <scsi/scsi_ioctl.h>
31#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
32#include <scsi/scsi_device.h> 32#include <scsi/scsi_device.h>
33#include <scsi/scsi_request.h> 33#include <scsi/scsi_eh.h>
34#include <scsi/scsi_dbg.h> 34#include <scsi/scsi_dbg.h>
35 35
36#define CH_DT_MAX 16 36#define CH_DT_MAX 16
@@ -180,17 +180,17 @@ static struct {
180 180
181/* ------------------------------------------------------------------- */ 181/* ------------------------------------------------------------------- */
182 182
183static int ch_find_errno(unsigned char *sense_buffer) 183static int ch_find_errno(struct scsi_sense_hdr *sshdr)
184{ 184{
185 int i,errno = 0; 185 int i,errno = 0;
186 186
187 /* Check to see if additional sense information is available */ 187 /* Check to see if additional sense information is available */
188 if (sense_buffer[7] > 5 && 188 if (scsi_sense_valid(sshdr) &&
189 sense_buffer[12] != 0) { 189 sshdr->asc != 0) {
190 for (i = 0; err[i].errno != 0; i++) { 190 for (i = 0; err[i].errno != 0; i++) {
191 if (err[i].sense == sense_buffer[ 2] && 191 if (err[i].sense == sshdr->sense_key &&
192 err[i].asc == sense_buffer[12] && 192 err[i].asc == sshdr->asc &&
193 err[i].ascq == sense_buffer[13]) { 193 err[i].ascq == sshdr->ascq) {
194 errno = -err[i].errno; 194 errno = -err[i].errno;
195 break; 195 break;
196 } 196 }
@@ -206,13 +206,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
206 void *buffer, unsigned buflength, 206 void *buffer, unsigned buflength,
207 enum dma_data_direction direction) 207 enum dma_data_direction direction)
208{ 208{
209 int errno, retries = 0, timeout; 209 int errno, retries = 0, timeout, result;
210 struct scsi_request *sr; 210 struct scsi_sense_hdr sshdr;
211 211
212 sr = scsi_allocate_request(ch->device, GFP_KERNEL);
213 if (NULL == sr)
214 return -ENOMEM;
215
216 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) 212 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
217 ? timeout_init : timeout_move; 213 ? timeout_init : timeout_move;
218 214
@@ -223,16 +219,17 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
223 __scsi_print_command(cmd); 219 __scsi_print_command(cmd);
224 } 220 }
225 221
226 scsi_wait_req(sr, cmd, buffer, buflength, 222 result = scsi_execute_req(ch->device, cmd, direction, buffer,
227 timeout * HZ, MAX_RETRIES); 223 buflength, &sshdr, timeout * HZ,
224 MAX_RETRIES);
228 225
229 dprintk("result: 0x%x\n",sr->sr_result); 226 dprintk("result: 0x%x\n",result);
230 if (driver_byte(sr->sr_result) & DRIVER_SENSE) { 227 if (driver_byte(result) & DRIVER_SENSE) {
231 if (debug) 228 if (debug)
232 scsi_print_req_sense(ch->name, sr); 229 scsi_print_sense_hdr(ch->name, &sshdr);
233 errno = ch_find_errno(sr->sr_sense_buffer); 230 errno = ch_find_errno(&sshdr);
234 231
235 switch(sr->sr_sense_buffer[2] & 0xf) { 232 switch(sshdr.sense_key) {
236 case UNIT_ATTENTION: 233 case UNIT_ATTENTION:
237 ch->unit_attention = 1; 234 ch->unit_attention = 1;
238 if (retries++ < 3) 235 if (retries++ < 3)
@@ -240,7 +237,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
240 break; 237 break;
241 } 238 }
242 } 239 }
243 scsi_release_request(sr);
244 return errno; 240 return errno;
245} 241}
246 242
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
1159void
1160scsi_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}
1182EXPORT_SYMBOL(scsi_print_sense_hdr);
1183
1159/* Print sense information */ 1184/* Print sense information */
1160void 1185void
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/dc395x.c b/drivers/scsi/dc395x.c
index 929170dcd3cb..600ba1202864 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -183,7 +183,7 @@
183 * cross a page boundy. 183 * cross a page boundy.
184 */ 184 */
185#define SEGMENTX_LEN (sizeof(struct SGentry)*DC395x_MAX_SG_LISTENTRY) 185#define SEGMENTX_LEN (sizeof(struct SGentry)*DC395x_MAX_SG_LISTENTRY)
186#define VIRTX_LEN (sizeof(void *) * DC395x_MAX_SG_LISTENTRY) 186
187 187
188struct SGentry { 188struct SGentry {
189 u32 address; /* bus! address */ 189 u32 address; /* bus! address */
@@ -235,7 +235,6 @@ struct ScsiReqBlk {
235 u8 sg_count; /* No of HW sg entries for this request */ 235 u8 sg_count; /* No of HW sg entries for this request */
236 u8 sg_index; /* Index of HW sg entry for this request */ 236 u8 sg_index; /* Index of HW sg entry for this request */
237 u32 total_xfer_length; /* Total number of bytes remaining to be transfered */ 237 u32 total_xfer_length; /* Total number of bytes remaining to be transfered */
238 void **virt_map;
239 unsigned char *virt_addr; /* Virtual address of current transfer position */ 238 unsigned char *virt_addr; /* Virtual address of current transfer position */
240 239
241 /* 240 /*
@@ -1022,14 +1021,14 @@ static void build_srb(struct scsi_cmnd *cmd, struct DeviceCtlBlk *dcb,
1022 reqlen, cmd->request_buffer, cmd->use_sg, 1021 reqlen, cmd->request_buffer, cmd->use_sg,
1023 srb->sg_count); 1022 srb->sg_count);
1024 1023
1024 srb->virt_addr = page_address(sl->page);
1025 for (i = 0; i < srb->sg_count; i++) { 1025 for (i = 0; i < srb->sg_count; i++) {
1026 u32 seglen = (u32)sg_dma_len(sl + i); 1026 u32 busaddr = (u32)sg_dma_address(&sl[i]);
1027 sgp[i].address = (u32)sg_dma_address(sl + i); 1027 u32 seglen = (u32)sl[i].length;
1028 sgp[i].address = busaddr;
1028 sgp[i].length = seglen; 1029 sgp[i].length = seglen;
1029 srb->total_xfer_length += seglen; 1030 srb->total_xfer_length += seglen;
1030 srb->virt_map[i] = kmap(sl[i].page);
1031 } 1031 }
1032 srb->virt_addr = srb->virt_map[0];
1033 sgp += srb->sg_count - 1; 1032 sgp += srb->sg_count - 1;
1034 1033
1035 /* 1034 /*
@@ -1976,7 +1975,6 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left)
1976 int segment = cmd->use_sg; 1975 int segment = cmd->use_sg;
1977 u32 xferred = srb->total_xfer_length - left; /* bytes transfered */ 1976 u32 xferred = srb->total_xfer_length - left; /* bytes transfered */
1978 struct SGentry *psge = srb->segment_x + srb->sg_index; 1977 struct SGentry *psge = srb->segment_x + srb->sg_index;
1979 void **virt = srb->virt_map;
1980 1978
1981 dprintkdbg(DBG_0, 1979 dprintkdbg(DBG_0,
1982 "sg_update_list: Transfered %i of %i bytes, %i remain\n", 1980 "sg_update_list: Transfered %i of %i bytes, %i remain\n",
@@ -2016,16 +2014,16 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left)
2016 2014
2017 /* We have to walk the scatterlist to find it */ 2015 /* We have to walk the scatterlist to find it */
2018 sg = (struct scatterlist *)cmd->request_buffer; 2016 sg = (struct scatterlist *)cmd->request_buffer;
2019 idx = 0;
2020 while (segment--) { 2017 while (segment--) {
2021 unsigned long mask = 2018 unsigned long mask =
2022 ~((unsigned long)sg->length - 1) & PAGE_MASK; 2019 ~((unsigned long)sg->length - 1) & PAGE_MASK;
2023 if ((sg_dma_address(sg) & mask) == (psge->address & mask)) { 2020 if ((sg_dma_address(sg) & mask) == (psge->address & mask)) {
2024 srb->virt_addr = virt[idx] + (psge->address & ~PAGE_MASK); 2021 srb->virt_addr = (page_address(sg->page)
2022 + psge->address -
2023 (psge->address & PAGE_MASK));
2025 return; 2024 return;
2026 } 2025 }
2027 ++sg; 2026 ++sg;
2028 ++idx;
2029 } 2027 }
2030 2028
2031 dprintkl(KERN_ERR, "sg_update_list: sg_to_virt failed\n"); 2029 dprintkl(KERN_ERR, "sg_update_list: sg_to_virt failed\n");
@@ -2151,7 +2149,7 @@ static void data_out_phase0(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb,
2151 DC395x_read32(acb, TRM_S1040_DMA_CXCNT)); 2149 DC395x_read32(acb, TRM_S1040_DMA_CXCNT));
2152 } 2150 }
2153 /* 2151 /*
2154 * calculate all the residue data that not yet transfered 2152 * calculate all the residue data that not yet tranfered
2155 * SCSI transfer counter + left in SCSI FIFO data 2153 * SCSI transfer counter + left in SCSI FIFO data
2156 * 2154 *
2157 * .....TRM_S1040_SCSI_COUNTER (24bits) 2155 * .....TRM_S1040_SCSI_COUNTER (24bits)
@@ -3269,7 +3267,6 @@ static void pci_unmap_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb)
3269 struct scsi_cmnd *cmd = srb->cmd; 3267 struct scsi_cmnd *cmd = srb->cmd;
3270 enum dma_data_direction dir = cmd->sc_data_direction; 3268 enum dma_data_direction dir = cmd->sc_data_direction;
3271 if (cmd->use_sg && dir != PCI_DMA_NONE) { 3269 if (cmd->use_sg && dir != PCI_DMA_NONE) {
3272 int i;
3273 /* unmap DC395x SG list */ 3270 /* unmap DC395x SG list */
3274 dprintkdbg(DBG_SG, "pci_unmap_srb: list=%08x(%05x)\n", 3271 dprintkdbg(DBG_SG, "pci_unmap_srb: list=%08x(%05x)\n",
3275 srb->sg_bus_addr, SEGMENTX_LEN); 3272 srb->sg_bus_addr, SEGMENTX_LEN);
@@ -3279,8 +3276,6 @@ static void pci_unmap_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb)
3279 dprintkdbg(DBG_SG, "pci_unmap_srb: segs=%i buffer=%p\n", 3276 dprintkdbg(DBG_SG, "pci_unmap_srb: segs=%i buffer=%p\n",
3280 cmd->use_sg, cmd->request_buffer); 3277 cmd->use_sg, cmd->request_buffer);
3281 /* unmap the sg segments */ 3278 /* unmap the sg segments */
3282 for (i = 0; i < srb->sg_count; i++)
3283 kunmap(virt_to_page(srb->virt_map[i]));
3284 pci_unmap_sg(acb->dev, 3279 pci_unmap_sg(acb->dev,
3285 (struct scatterlist *)cmd->request_buffer, 3280 (struct scatterlist *)cmd->request_buffer,
3286 cmd->use_sg, dir); 3281 cmd->use_sg, dir);
@@ -3327,7 +3322,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
3327 3322
3328 if (cmd->use_sg) { 3323 if (cmd->use_sg) {
3329 struct scatterlist* sg = (struct scatterlist *)cmd->request_buffer; 3324 struct scatterlist* sg = (struct scatterlist *)cmd->request_buffer;
3330 ptr = (struct ScsiInqData *)(srb->virt_map[0] + sg->offset); 3325 ptr = (struct ScsiInqData *)(page_address(sg->page) + sg->offset);
3331 } else { 3326 } else {
3332 ptr = (struct ScsiInqData *)(cmd->request_buffer); 3327 ptr = (struct ScsiInqData *)(cmd->request_buffer);
3333 } 3328 }
@@ -4262,9 +4257,8 @@ static void adapter_sg_tables_free(struct AdapterCtlBlk *acb)
4262 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN; 4257 const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN;
4263 4258
4264 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page) 4259 for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page)
4265 kfree(acb->srb_array[i].segment_x); 4260 if (acb->srb_array[i].segment_x)
4266 4261 kfree(acb->srb_array[i].segment_x);
4267 vfree(acb->srb_array[0].virt_map);
4268} 4262}
4269 4263
4270 4264
@@ -4280,12 +4274,9 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb)
4280 int srb_idx = 0; 4274 int srb_idx = 0;
4281 unsigned i = 0; 4275 unsigned i = 0;
4282 struct SGentry *ptr; 4276 struct SGentry *ptr;
4283 void **virt_array;
4284 4277
4285 for (i = 0; i < DC395x_MAX_SRB_CNT; i++) { 4278 for (i = 0; i < DC395x_MAX_SRB_CNT; i++)
4286 acb->srb_array[i].segment_x = NULL; 4279 acb->srb_array[i].segment_x = NULL;
4287 acb->srb_array[i].virt_map = NULL;
4288 }
4289 4280
4290 dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); 4281 dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages);
4291 while (pages--) { 4282 while (pages--) {
@@ -4306,19 +4297,6 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb)
4306 ptr + (i * DC395x_MAX_SG_LISTENTRY); 4297 ptr + (i * DC395x_MAX_SG_LISTENTRY);
4307 else 4298 else
4308 dprintkl(KERN_DEBUG, "No space for tmsrb SG table reserved?!\n"); 4299 dprintkl(KERN_DEBUG, "No space for tmsrb SG table reserved?!\n");
4309
4310 virt_array = vmalloc((DC395x_MAX_SRB_CNT + 1) * DC395x_MAX_SG_LISTENTRY * sizeof(void*));
4311
4312 if (!virt_array) {
4313 adapter_sg_tables_free(acb);
4314 return 1;
4315 }
4316
4317 for (i = 0; i < DC395x_MAX_SRB_CNT + 1; i++) {
4318 acb->srb_array[i].virt_map = virt_array;
4319 virt_array += DC395x_MAX_SG_LISTENTRY;
4320 }
4321
4322 return 0; 4300 return 0;
4323} 4301}
4324 4302
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index e2370529c632..7235f94f1191 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -907,9 +907,13 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
907 raptorFlag = TRUE; 907 raptorFlag = TRUE;
908 } 908 }
909 909
910 910 if (pci_request_regions(pDev, "dpt_i2o")) {
911 PERROR("dpti: adpt_config_hba: pci request region failed\n");
912 return -EINVAL;
913 }
911 base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); 914 base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size);
912 if (!base_addr_virt) { 915 if (!base_addr_virt) {
916 pci_release_regions(pDev);
913 PERROR("dpti: adpt_config_hba: io remap failed\n"); 917 PERROR("dpti: adpt_config_hba: io remap failed\n");
914 return -EINVAL; 918 return -EINVAL;
915 } 919 }
@@ -919,6 +923,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
919 if (!msg_addr_virt) { 923 if (!msg_addr_virt) {
920 PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n"); 924 PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n");
921 iounmap(base_addr_virt); 925 iounmap(base_addr_virt);
926 pci_release_regions(pDev);
922 return -EINVAL; 927 return -EINVAL;
923 } 928 }
924 } else { 929 } else {
@@ -932,6 +937,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
932 iounmap(msg_addr_virt); 937 iounmap(msg_addr_virt);
933 } 938 }
934 iounmap(base_addr_virt); 939 iounmap(base_addr_virt);
940 pci_release_regions(pDev);
935 return -ENOMEM; 941 return -ENOMEM;
936 } 942 }
937 memset(pHba, 0, sizeof(adpt_hba)); 943 memset(pHba, 0, sizeof(adpt_hba));
@@ -1027,6 +1033,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1027 up(&adpt_configuration_lock); 1033 up(&adpt_configuration_lock);
1028 1034
1029 iounmap(pHba->base_addr_virt); 1035 iounmap(pHba->base_addr_virt);
1036 pci_release_regions(pHba->pDev);
1030 if(pHba->msg_addr_virt != pHba->base_addr_virt){ 1037 if(pHba->msg_addr_virt != pHba->base_addr_virt){
1031 iounmap(pHba->msg_addr_virt); 1038 iounmap(pHba->msg_addr_virt);
1032 } 1039 }
diff --git a/drivers/scsi/ibmvscsi/srp.h b/drivers/scsi/ibmvscsi/srp.h
index 2ae5154fd89c..7d8e4c4accb9 100644
--- a/drivers/scsi/ibmvscsi/srp.h
+++ b/drivers/scsi/ibmvscsi/srp.h
@@ -35,7 +35,7 @@
35enum srp_types { 35enum srp_types {
36 SRP_LOGIN_REQ_TYPE = 0x00, 36 SRP_LOGIN_REQ_TYPE = 0x00,
37 SRP_LOGIN_RSP_TYPE = 0xC0, 37 SRP_LOGIN_RSP_TYPE = 0xC0,
38 SRP_LOGIN_REJ_TYPE = 0x80, 38 SRP_LOGIN_REJ_TYPE = 0xC2,
39 SRP_I_LOGOUT_TYPE = 0x03, 39 SRP_I_LOGOUT_TYPE = 0x03,
40 SRP_T_LOGOUT_TYPE = 0x80, 40 SRP_T_LOGOUT_TYPE = 0x80,
41 SRP_TSK_MGMT_TYPE = 0x01, 41 SRP_TSK_MGMT_TYPE = 0x01,
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 6dfcb4fbccdd..4cdd891781b1 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -133,10 +133,12 @@
133/* 6.10.00 - Remove 1G Addressing Limitations */ 133/* 6.10.00 - Remove 1G Addressing Limitations */
134/* 6.11.xx - Get VersionInfo buffer off the stack ! DDTS 60401 */ 134/* 6.11.xx - Get VersionInfo buffer off the stack ! DDTS 60401 */
135/* 6.11.xx - Make Logical Drive Info structure safe for DMA DDTS 60639 */ 135/* 6.11.xx - Make Logical Drive Info structure safe for DMA DDTS 60639 */
136/* 7.10.xx - Add highmem_io flag in SCSI Templete for 2.4 kernels */ 136/* 7.10.18 - Add highmem_io flag in SCSI Templete for 2.4 kernels */
137/* - Fix path/name for scsi_hosts.h include for 2.6 kernels */ 137/* - Fix path/name for scsi_hosts.h include for 2.6 kernels */
138/* - Fix sort order of 7k */ 138/* - Fix sort order of 7k */
139/* - Remove 3 unused "inline" functions */ 139/* - Remove 3 unused "inline" functions */
140/* 7.12.xx - Use STATIC functions whereever possible */
141/* - Clean up deprecated MODULE_PARM calls */
140/*****************************************************************************/ 142/*****************************************************************************/
141 143
142/* 144/*
@@ -207,8 +209,8 @@ module_param(ips, charp, 0);
207/* 209/*
208 * DRIVER_VER 210 * DRIVER_VER
209 */ 211 */
210#define IPS_VERSION_HIGH "7.10" 212#define IPS_VERSION_HIGH "7.12"
211#define IPS_VERSION_LOW ".18 " 213#define IPS_VERSION_LOW ".02 "
212 214
213#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__) 215#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
214#warning "This driver has only been tested on the x86/ia64/x86_64 platforms" 216#warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index 480e06f4d6ae..505e967013de 100644
--- a/drivers/scsi/ips.h
+++ b/drivers/scsi/ips.h
@@ -87,15 +87,14 @@
87 #define scsi_set_pci_device(sh,dev) (0) 87 #define scsi_set_pci_device(sh,dev) (0)
88 #endif 88 #endif
89 89
90 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 90 #ifndef IRQ_NONE
91 91 typedef void irqreturn_t;
92 #ifndef irqreturn_t
93 typedef void irqreturn_t;
94 #endif
95
96 #define IRQ_NONE 92 #define IRQ_NONE
97 #define IRQ_HANDLED 93 #define IRQ_HANDLED
98 #define IRQ_RETVAL(x) 94 #define IRQ_RETVAL(x)
95 #endif
96
97 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
99 #define IPS_REGISTER_HOSTS(SHT) scsi_register_module(MODULE_SCSI_HA,SHT) 98 #define IPS_REGISTER_HOSTS(SHT) scsi_register_module(MODULE_SCSI_HA,SHT)
100 #define IPS_UNREGISTER_HOSTS(SHT) scsi_unregister_module(MODULE_SCSI_HA,SHT) 99 #define IPS_UNREGISTER_HOSTS(SHT) scsi_unregister_module(MODULE_SCSI_HA,SHT)
101 #define IPS_ADD_HOST(shost,device) 100 #define IPS_ADD_HOST(shost,device)
@@ -123,6 +122,10 @@
123 #ifndef min 122 #ifndef min
124 #define min(x,y) ((x) < (y) ? x : y) 123 #define min(x,y) ((x) < (y) ? x : y)
125 #endif 124 #endif
125
126 #ifndef __iomem /* For clean compiles in earlier kernels without __iomem annotations */
127 #define __iomem
128 #endif
126 129
127 #define pci_dma_hi32(a) ((a >> 16) >> 16) 130 #define pci_dma_hi32(a) ((a >> 16) >> 16)
128 #define pci_dma_lo32(a) (a & 0xffffffff) 131 #define pci_dma_lo32(a) (a & 0xffffffff)
@@ -1206,13 +1209,13 @@ typedef struct {
1206 1209
1207#define IPS_VER_MAJOR 7 1210#define IPS_VER_MAJOR 7
1208#define IPS_VER_MAJOR_STRING "7" 1211#define IPS_VER_MAJOR_STRING "7"
1209#define IPS_VER_MINOR 10 1212#define IPS_VER_MINOR 12
1210#define IPS_VER_MINOR_STRING "10" 1213#define IPS_VER_MINOR_STRING "12"
1211#define IPS_VER_BUILD 18 1214#define IPS_VER_BUILD 02
1212#define IPS_VER_BUILD_STRING "18" 1215#define IPS_VER_BUILD_STRING "02"
1213#define IPS_VER_STRING "7.10.18" 1216#define IPS_VER_STRING "7.12.02"
1214#define IPS_RELEASE_ID 0x00020000 1217#define IPS_RELEASE_ID 0x00020000
1215#define IPS_BUILD_IDENT 731 1218#define IPS_BUILD_IDENT 761
1216#define IPS_LEGALCOPYRIGHT_STRING "(C) Copyright IBM Corp. 1994, 2002. All Rights Reserved." 1219#define IPS_LEGALCOPYRIGHT_STRING "(C) Copyright IBM Corp. 1994, 2002. All Rights Reserved."
1217#define IPS_ADAPTECCOPYRIGHT_STRING "(c) Copyright Adaptec, Inc. 2002 to 2004. All Rights Reserved." 1220#define IPS_ADAPTECCOPYRIGHT_STRING "(c) Copyright Adaptec, Inc. 2002 to 2004. All Rights Reserved."
1218#define IPS_DELLCOPYRIGHT_STRING "(c) Copyright Dell 2004. All Rights Reserved." 1221#define IPS_DELLCOPYRIGHT_STRING "(c) Copyright Dell 2004. All Rights Reserved."
@@ -1223,12 +1226,12 @@ typedef struct {
1223#define IPS_VER_SERVERAID2 "2.88.13" 1226#define IPS_VER_SERVERAID2 "2.88.13"
1224#define IPS_VER_NAVAJO "2.88.13" 1227#define IPS_VER_NAVAJO "2.88.13"
1225#define IPS_VER_SERVERAID3 "6.10.24" 1228#define IPS_VER_SERVERAID3 "6.10.24"
1226#define IPS_VER_SERVERAID4H "7.10.11" 1229#define IPS_VER_SERVERAID4H "7.12.02"
1227#define IPS_VER_SERVERAID4MLx "7.10.18" 1230#define IPS_VER_SERVERAID4MLx "7.12.02"
1228#define IPS_VER_SARASOTA "7.10.18" 1231#define IPS_VER_SARASOTA "7.12.02"
1229#define IPS_VER_MARCO "7.10.18" 1232#define IPS_VER_MARCO "7.12.02"
1230#define IPS_VER_SEBRING "7.10.18" 1233#define IPS_VER_SEBRING "7.12.02"
1231#define IPS_VER_KEYWEST "7.10.18" 1234#define IPS_VER_KEYWEST "7.12.02"
1232 1235
1233/* Compatability IDs for various adapters */ 1236/* Compatability IDs for various adapters */
1234#define IPS_COMPAT_UNKNOWN "" 1237#define IPS_COMPAT_UNKNOWN ""
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 73b1f72b7e43..f4e7dcb6492b 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2268,19 +2268,6 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2268 * spin_lock_irqsave(host_set lock) 2268 * spin_lock_irqsave(host_set lock)
2269 */ 2269 */
2270 2270
2271
2272
2273/**
2274 * ata_sg_init_one - Prepare a one-entry scatter-gather list.
2275 * @qc: Queued command
2276 * @buf: transfer buffer
2277 * @buflen: length of buf
2278 *
2279 * Builds a single-entry scatter-gather list to initiate a
2280 * transfer utilizing the specified buffer.
2281 *
2282 * LOCKING:
2283 */
2284void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 2271void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2285{ 2272{
2286 struct scatterlist *sg; 2273 struct scatterlist *sg;
@@ -2312,18 +2299,6 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2312 * spin_lock_irqsave(host_set lock) 2299 * spin_lock_irqsave(host_set lock)
2313 */ 2300 */
2314 2301
2315
2316/**
2317 * ata_sg_init - Assign a scatter gather list to a queued command
2318 * @qc: Queued command
2319 * @sg: Scatter-gather list
2320 * @n_elem: length of sg list
2321 *
2322 * Attaches a scatter-gather list to a queued command.
2323 *
2324 * LOCKING:
2325 */
2326
2327void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 2302void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
2328 unsigned int n_elem) 2303 unsigned int n_elem)
2329{ 2304{
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 794fb559efb0..6a75ec2187fd 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *host)
385 * appropriate place 385 * appropriate place
386 */ 386 */
387 host->host_failed--; 387 host->host_failed--;
388 INIT_LIST_HEAD(&host->eh_cmd_q);
388 389
389 DPRINTK("EXIT\n"); 390 DPRINTK("EXIT\n");
390 return 0; 391 return 0;
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index d90430bbb0de..3e7f4843020f 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -26,7 +26,7 @@
26#define __LIBATA_H__ 26#define __LIBATA_H__
27 27
28#define DRV_NAME "libata" 28#define DRV_NAME "libata"
29#define DRV_VERSION "1.11" /* must be exactly four chars */ 29#define DRV_VERSION "1.12" /* must be exactly four chars */
30 30
31struct ata_scsi_args { 31struct ata_scsi_args {
32 u16 *id; 32 u16 *id;
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 5c1d4411457a..919fb314ad10 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -40,7 +40,7 @@
40#include "sata_promise.h" 40#include "sata_promise.h"
41 41
42#define DRV_NAME "sata_promise" 42#define DRV_NAME "sata_promise"
43#define DRV_VERSION "1.01" 43#define DRV_VERSION "1.02"
44 44
45 45
46enum { 46enum {
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index 140cea05de3f..efd7d7a61135 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -468,7 +468,7 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
468 for (i = 0; i < last; i++) { 468 for (i = 0; i < last; i++) {
469 buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i])); 469 buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i]));
470 buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i])); 470 buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i]));
471 total_len += sg[i].length; 471 total_len += sg_dma_len(&sg[i]);
472 } 472 }
473 buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT); 473 buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT);
474 sgt_len = idx * 4; 474 sgt_len = idx * 4;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ae28bcb79242..895c9452be4c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1822,12 +1822,16 @@ EXPORT_SYMBOL(scsi_reset_provider);
1822int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, 1822int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
1823 struct scsi_sense_hdr *sshdr) 1823 struct scsi_sense_hdr *sshdr)
1824{ 1824{
1825 if (!sense_buffer || !sb_len || (sense_buffer[0] & 0x70) != 0x70) 1825 if (!sense_buffer || !sb_len)
1826 return 0; 1826 return 0;
1827 1827
1828 memset(sshdr, 0, sizeof(struct scsi_sense_hdr)); 1828 memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
1829 1829
1830 sshdr->response_code = (sense_buffer[0] & 0x7f); 1830 sshdr->response_code = (sense_buffer[0] & 0x7f);
1831
1832 if (!scsi_sense_valid(sshdr))
1833 return 0;
1834
1831 if (sshdr->response_code >= 0x72) { 1835 if (sshdr->response_code >= 0x72) {
1832 /* 1836 /*
1833 * descriptor format 1837 * descriptor format
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 946c31fa6466..b7fddac81347 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -88,25 +88,18 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)
88static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, 88static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
89 int timeout, int retries) 89 int timeout, int retries)
90{ 90{
91 struct scsi_request *sreq;
92 int result; 91 int result;
93 struct scsi_sense_hdr sshdr; 92 struct scsi_sense_hdr sshdr;
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 sreq = scsi_allocate_request(sdev, GFP_KERNEL); 96 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
98 if (!sreq) { 97 &sshdr, timeout, retries);
99 printk(KERN_WARNING "SCSI internal ioctl failed, no memory\n");
100 return -ENOMEM;
101 }
102
103 sreq->sr_data_direction = DMA_NONE;
104 scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
105 98
106 SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", sreq->sr_result)); 99 SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", result));
107 100
108 if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && 101 if ((driver_byte(result) & DRIVER_SENSE) &&
109 (scsi_request_normalize_sense(sreq, &sshdr))) { 102 (scsi_sense_valid(&sshdr))) {
110 switch (sshdr.sense_key) { 103 switch (sshdr.sense_key) {
111 case ILLEGAL_REQUEST: 104 case ILLEGAL_REQUEST:
112 if (cmd[0] == ALLOW_MEDIUM_REMOVAL) 105 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
@@ -125,7 +118,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
125 case UNIT_ATTENTION: 118 case UNIT_ATTENTION:
126 if (sdev->removable) { 119 if (sdev->removable) {
127 sdev->changed = 1; 120 sdev->changed = 1;
128 sreq->sr_result = 0; /* This is no longer considered an error */ 121 result = 0; /* This is no longer considered an error */
129 break; 122 break;
130 } 123 }
131 default: /* Fall through for non-removable media */ 124 default: /* Fall through for non-removable media */
@@ -135,15 +128,13 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
135 sdev->channel, 128 sdev->channel,
136 sdev->id, 129 sdev->id,
137 sdev->lun, 130 sdev->lun,
138 sreq->sr_result); 131 result);
139 scsi_print_req_sense(" ", sreq); 132 scsi_print_sense_hdr(" ", &sshdr);
140 break; 133 break;
141 } 134 }
142 } 135 }
143 136
144 result = sreq->sr_result;
145 SCSI_LOG_IOCTL(2, printk("IOCTL Releasing command\n")); 137 SCSI_LOG_IOCTL(2, printk("IOCTL Releasing command\n"));
146 scsi_release_request(sreq);
147 return result; 138 return result;
148} 139}
149 140
@@ -208,8 +199,8 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
208{ 199{
209 char *buf; 200 char *buf;
210 unsigned char cmd[MAX_COMMAND_SIZE]; 201 unsigned char cmd[MAX_COMMAND_SIZE];
202 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
211 char __user *cmd_in; 203 char __user *cmd_in;
212 struct scsi_request *sreq;
213 unsigned char opcode; 204 unsigned char opcode;
214 unsigned int inlen, outlen, cmdlen; 205 unsigned int inlen, outlen, cmdlen;
215 unsigned int needed, buf_needed; 206 unsigned int needed, buf_needed;
@@ -321,31 +312,23 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
321 break; 312 break;
322 } 313 }
323 314
324 sreq = scsi_allocate_request(sdev, GFP_KERNEL); 315 result = scsi_execute(sdev, cmd, data_direction, buf, needed,
325 if (!sreq) { 316 sense, timeout, retries, 0);
326 result = -EINTR;
327 goto error;
328 }
329
330 sreq->sr_data_direction = data_direction;
331 scsi_wait_req(sreq, cmd, buf, needed, timeout, retries);
332 317
333 /* 318 /*
334 * 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.
335 */ 320 */
336 result = sreq->sr_result;
337 if (result) { 321 if (result) {
338 int sb_len = sizeof(sreq->sr_sense_buffer); 322 int sb_len = sizeof(*sense);
339 323
340 sb_len = (sb_len > OMAX_SB_LEN) ? OMAX_SB_LEN : sb_len; 324 sb_len = (sb_len > OMAX_SB_LEN) ? OMAX_SB_LEN : sb_len;
341 if (copy_to_user(cmd_in, sreq->sr_sense_buffer, sb_len)) 325 if (copy_to_user(cmd_in, sense, sb_len))
342 result = -EFAULT; 326 result = -EFAULT;
343 } else { 327 } else {
344 if (copy_to_user(cmd_in, buf, outlen)) 328 if (copy_to_user(cmd_in, buf, outlen))
345 result = -EFAULT; 329 result = -EFAULT;
346 } 330 }
347 331
348 scsi_release_request(sreq);
349error: 332error:
350 kfree(buf); 333 kfree(buf);
351 return result; 334 return result;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 060010bccabc..77f2d444f7e0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -232,23 +232,6 @@ void scsi_do_req(struct scsi_request *sreq, const void *cmnd,
232} 232}
233EXPORT_SYMBOL(scsi_do_req); 233EXPORT_SYMBOL(scsi_do_req);
234 234
235static void scsi_wait_done(struct scsi_cmnd *cmd)
236{
237 struct request *req = cmd->request;
238 struct request_queue *q = cmd->device->request_queue;
239 unsigned long flags;
240
241 req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
242
243 spin_lock_irqsave(q->queue_lock, flags);
244 if (blk_rq_tagged(req))
245 blk_queue_end_tag(q, req);
246 spin_unlock_irqrestore(q->queue_lock, flags);
247
248 if (req->waiting)
249 complete(req->waiting);
250}
251
252/* This is the end routine we get to if a command was never attached 235/* This is the end routine we get to if a command was never attached
253 * to the request. Simply complete the request without changing 236 * to the request. Simply complete the request without changing
254 * rq_status; this will cause a DRIVER_ERROR. */ 237 * rq_status; this will cause a DRIVER_ERROR. */
@@ -263,21 +246,114 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer,
263 unsigned bufflen, int timeout, int retries) 246 unsigned bufflen, int timeout, int retries)
264{ 247{
265 DECLARE_COMPLETION(wait); 248 DECLARE_COMPLETION(wait);
266 249 int write = (sreq->sr_data_direction == DMA_TO_DEVICE);
267 sreq->sr_request->waiting = &wait; 250 struct request *req;
268 sreq->sr_request->rq_status = RQ_SCSI_BUSY; 251
269 sreq->sr_request->end_io = scsi_wait_req_end_io; 252 req = blk_get_request(sreq->sr_device->request_queue, write,
270 scsi_do_req(sreq, cmnd, buffer, bufflen, scsi_wait_done, 253 __GFP_WAIT);
271 timeout, retries); 254 if (bufflen && blk_rq_map_kern(sreq->sr_device->request_queue, req,
255 buffer, bufflen, __GFP_WAIT)) {
256 sreq->sr_result = DRIVER_ERROR << 24;
257 blk_put_request(req);
258 return;
259 }
260
261 req->flags |= REQ_NOMERGE;
262 req->waiting = &wait;
263 req->end_io = scsi_wait_req_end_io;
264 req->cmd_len = COMMAND_SIZE(((u8 *)cmnd)[0]);
265 req->sense = sreq->sr_sense_buffer;
266 req->sense_len = 0;
267 memcpy(req->cmd, cmnd, req->cmd_len);
268 req->timeout = timeout;
269 req->flags |= REQ_BLOCK_PC;
270 req->rq_disk = NULL;
271 blk_insert_request(sreq->sr_device->request_queue, req,
272 sreq->sr_data_direction == DMA_TO_DEVICE, NULL);
272 wait_for_completion(&wait); 273 wait_for_completion(&wait);
273 sreq->sr_request->waiting = NULL; 274 sreq->sr_request->waiting = NULL;
274 if (sreq->sr_request->rq_status != RQ_SCSI_DONE) 275 sreq->sr_result = req->errors;
276 if (req->errors)
275 sreq->sr_result |= (DRIVER_ERROR << 24); 277 sreq->sr_result |= (DRIVER_ERROR << 24);
276 278
277 __scsi_release_request(sreq); 279 blk_put_request(req);
278} 280}
281
279EXPORT_SYMBOL(scsi_wait_req); 282EXPORT_SYMBOL(scsi_wait_req);
280 283
284/**
285 * scsi_execute - insert request and wait for the result
286 * @sdev: scsi device
287 * @cmd: scsi command
288 * @data_direction: data direction
289 * @buffer: data buffer
290 * @bufflen: len of buffer
291 * @sense: optional sense buffer
292 * @timeout: request timeout in seconds
293 * @retries: number of times to retry request
294 * @flags: or into request flags;
295 *
296 * returns the req->errors value which is the the scsi_cmnd result
297 * field.
298 **/
299int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
300 int data_direction, void *buffer, unsigned bufflen,
301 unsigned char *sense, int timeout, int retries, int flags)
302{
303 struct request *req;
304 int write = (data_direction == DMA_TO_DEVICE);
305 int ret = DRIVER_ERROR << 24;
306
307 req = blk_get_request(sdev->request_queue, write, __GFP_WAIT);
308
309 if (bufflen && blk_rq_map_kern(sdev->request_queue, req,
310 buffer, bufflen, __GFP_WAIT))
311 goto out;
312
313 req->cmd_len = COMMAND_SIZE(cmd[0]);
314 memcpy(req->cmd, cmd, req->cmd_len);
315 req->sense = sense;
316 req->sense_len = 0;
317 req->timeout = timeout;
318 req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL | REQ_QUIET;
319
320 /*
321 * head injection *required* here otherwise quiesce won't work
322 */
323 blk_execute_rq(req->q, NULL, req, 1);
324
325 ret = req->errors;
326 out:
327 blk_put_request(req);
328
329 return ret;
330}
331EXPORT_SYMBOL(scsi_execute);
332
333
334int 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 int result;
340
341 if (sshdr) {
342 sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
343 if (!sense)
344 return DRIVER_ERROR << 24;
345 memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
346 }
347 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
348 sense, timeout, retries, 0);
349 if (sshdr)
350 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
351
352 kfree(sense);
353 return result;
354}
355EXPORT_SYMBOL(scsi_execute_req);
356
281/* 357/*
282 * Function: scsi_init_cmd_errh() 358 * Function: scsi_init_cmd_errh()
283 * 359 *
@@ -851,17 +927,20 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
851 scsi_requeue_command(q, cmd); 927 scsi_requeue_command(q, cmd);
852 return; 928 return;
853 } 929 }
854 printk(KERN_INFO "Device %s not ready.\n", 930 if (!(req->flags & REQ_QUIET))
855 req->rq_disk ? req->rq_disk->disk_name : ""); 931 dev_printk(KERN_INFO,
932 &cmd->device->sdev_gendev,
933 "Device not ready.\n");
856 cmd = scsi_end_request(cmd, 0, this_count, 1); 934 cmd = scsi_end_request(cmd, 0, this_count, 1);
857 return; 935 return;
858 case VOLUME_OVERFLOW: 936 case VOLUME_OVERFLOW:
859 printk(KERN_INFO "Volume overflow <%d %d %d %d> CDB: ", 937 if (!(req->flags & REQ_QUIET)) {
860 cmd->device->host->host_no, 938 dev_printk(KERN_INFO,
861 (int)cmd->device->channel, 939 &cmd->device->sdev_gendev,
862 (int)cmd->device->id, (int)cmd->device->lun); 940 "Volume overflow, CDB: ");
863 __scsi_print_command(cmd->data_cmnd); 941 __scsi_print_command(cmd->data_cmnd);
864 scsi_print_sense("", cmd); 942 scsi_print_sense("", cmd);
943 }
865 cmd = scsi_end_request(cmd, 0, block_bytes, 1); 944 cmd = scsi_end_request(cmd, 0, block_bytes, 1);
866 return; 945 return;
867 default: 946 default:
@@ -878,14 +957,13 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
878 return; 957 return;
879 } 958 }
880 if (result) { 959 if (result) {
881 printk(KERN_INFO "SCSI error : <%d %d %d %d> return code " 960 if (!(req->flags & REQ_QUIET)) {
882 "= 0x%x\n", cmd->device->host->host_no, 961 dev_printk(KERN_INFO, &cmd->device->sdev_gendev,
883 cmd->device->channel, 962 "SCSI error: return code = 0x%x\n", result);
884 cmd->device->id, 963
885 cmd->device->lun, result); 964 if (driver_byte(result) & DRIVER_SENSE)
886 965 scsi_print_sense("", cmd);
887 if (driver_byte(result) & DRIVER_SENSE) 966 }
888 scsi_print_sense("", cmd);
889 /* 967 /*
890 * Mark a single buffer as not uptodate. Queue the remainder. 968 * Mark a single buffer as not uptodate. Queue the remainder.
891 * We sometimes get this cruft in the event that a medium error 969 * We sometimes get this cruft in the event that a medium error
@@ -1020,6 +1098,12 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1020 return -EOPNOTSUPP; 1098 return -EOPNOTSUPP;
1021} 1099}
1022 1100
1101static void scsi_generic_done(struct scsi_cmnd *cmd)
1102{
1103 BUG_ON(!blk_pc_request(cmd->request));
1104 scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0);
1105}
1106
1023static int scsi_prep_fn(struct request_queue *q, struct request *req) 1107static int scsi_prep_fn(struct request_queue *q, struct request *req)
1024{ 1108{
1025 struct scsi_device *sdev = q->queuedata; 1109 struct scsi_device *sdev = q->queuedata;
@@ -1061,7 +1145,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1061 * these two cases differently. We differentiate by looking 1145 * these two cases differently. We differentiate by looking
1062 * at request->cmd, as this tells us the real story. 1146 * at request->cmd, as this tells us the real story.
1063 */ 1147 */
1064 if (req->flags & REQ_SPECIAL) { 1148 if (req->flags & REQ_SPECIAL && req->special) {
1065 struct scsi_request *sreq = req->special; 1149 struct scsi_request *sreq = req->special;
1066 1150
1067 if (sreq->sr_magic == SCSI_REQ_MAGIC) { 1151 if (sreq->sr_magic == SCSI_REQ_MAGIC) {
@@ -1073,7 +1157,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1073 cmd = req->special; 1157 cmd = req->special;
1074 } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { 1158 } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
1075 1159
1076 if(unlikely(specials_only)) { 1160 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) {
1077 if(specials_only == SDEV_QUIESCE || 1161 if(specials_only == SDEV_QUIESCE ||
1078 specials_only == SDEV_BLOCK) 1162 specials_only == SDEV_BLOCK)
1079 return BLKPREP_DEFER; 1163 return BLKPREP_DEFER;
@@ -1142,11 +1226,26 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1142 /* 1226 /*
1143 * Initialize the actual SCSI command for this request. 1227 * Initialize the actual SCSI command for this request.
1144 */ 1228 */
1145 drv = *(struct scsi_driver **)req->rq_disk->private_data; 1229 if (req->rq_disk) {
1146 if (unlikely(!drv->init_command(cmd))) { 1230 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1147 scsi_release_buffers(cmd); 1231 if (unlikely(!drv->init_command(cmd))) {
1148 scsi_put_command(cmd); 1232 scsi_release_buffers(cmd);
1149 return BLKPREP_KILL; 1233 scsi_put_command(cmd);
1234 return BLKPREP_KILL;
1235 }
1236 } else {
1237 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1238 if (rq_data_dir(req) == WRITE)
1239 cmd->sc_data_direction = DMA_TO_DEVICE;
1240 else if (req->data_len)
1241 cmd->sc_data_direction = DMA_FROM_DEVICE;
1242 else
1243 cmd->sc_data_direction = DMA_NONE;
1244
1245 cmd->transfersize = req->data_len;
1246 cmd->allowed = 3;
1247 cmd->timeout_per_command = req->timeout;
1248 cmd->done = scsi_generic_done;
1150 } 1249 }
1151 } 1250 }
1152 1251
@@ -1539,9 +1638,9 @@ void scsi_exit_queue(void)
1539 } 1638 }
1540} 1639}
1541/** 1640/**
1542 * __scsi_mode_sense - issue a mode sense, falling back from 10 to 1641 * scsi_mode_sense - issue a mode sense, falling back from 10 to
1543 * six bytes if necessary. 1642 * six bytes if necessary.
1544 * @sreq: SCSI request to fill in with the MODE_SENSE 1643 * @sdev: SCSI device to be queried
1545 * @dbd: set if mode sense will allow block descriptors to be returned 1644 * @dbd: set if mode sense will allow block descriptors to be returned
1546 * @modepage: mode page being requested 1645 * @modepage: mode page being requested
1547 * @buffer: request buffer (may not be smaller than eight bytes) 1646 * @buffer: request buffer (may not be smaller than eight bytes)
@@ -1549,26 +1648,34 @@ void scsi_exit_queue(void)
1549 * @timeout: command timeout 1648 * @timeout: command timeout
1550 * @retries: number of retries before failing 1649 * @retries: number of retries before failing
1551 * @data: returns a structure abstracting the mode header data 1650 * @data: returns a structure abstracting the mode header data
1651 * @sense: place to put sense data (or NULL if no sense to be collected).
1652 * must be SCSI_SENSE_BUFFERSIZE big.
1552 * 1653 *
1553 * Returns zero if unsuccessful, or the header offset (either 4 1654 * Returns zero if unsuccessful, or the header offset (either 4
1554 * or 8 depending on whether a six or ten byte command was 1655 * or 8 depending on whether a six or ten byte command was
1555 * issued) if successful. 1656 * issued) if successful.
1556 **/ 1657 **/
1557int 1658int
1558__scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage, 1659scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
1559 unsigned char *buffer, int len, int timeout, int retries, 1660 unsigned char *buffer, int len, int timeout, int retries,
1560 struct scsi_mode_data *data) { 1661 struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr) {
1561 unsigned char cmd[12]; 1662 unsigned char cmd[12];
1562 int use_10_for_ms; 1663 int use_10_for_ms;
1563 int header_length; 1664 int header_length;
1665 int result;
1666 struct scsi_sense_hdr my_sshdr;
1564 1667
1565 memset(data, 0, sizeof(*data)); 1668 memset(data, 0, sizeof(*data));
1566 memset(&cmd[0], 0, 12); 1669 memset(&cmd[0], 0, 12);
1567 cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */ 1670 cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */
1568 cmd[2] = modepage; 1671 cmd[2] = modepage;
1569 1672
1673 /* caller might not be interested in sense, but we need it */
1674 if (!sshdr)
1675 sshdr = &my_sshdr;
1676
1570 retry: 1677 retry:
1571 use_10_for_ms = sreq->sr_device->use_10_for_ms; 1678 use_10_for_ms = sdev->use_10_for_ms;
1572 1679
1573 if (use_10_for_ms) { 1680 if (use_10_for_ms) {
1574 if (len < 8) 1681 if (len < 8)
@@ -1586,36 +1693,31 @@ __scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage,
1586 header_length = 4; 1693 header_length = 4;
1587 } 1694 }
1588 1695
1589 sreq->sr_cmd_len = 0;
1590 memset(sreq->sr_sense_buffer, 0, sizeof(sreq->sr_sense_buffer));
1591 sreq->sr_data_direction = DMA_FROM_DEVICE;
1592
1593 memset(buffer, 0, len); 1696 memset(buffer, 0, len);
1594 1697
1595 scsi_wait_req(sreq, cmd, buffer, len, timeout, retries); 1698 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
1699 sshdr, timeout, retries);
1596 1700
1597 /* This code looks awful: what it's doing is making sure an 1701 /* This code looks awful: what it's doing is making sure an
1598 * ILLEGAL REQUEST sense return identifies the actual command 1702 * ILLEGAL REQUEST sense return identifies the actual command
1599 * byte as the problem. MODE_SENSE commands can return 1703 * byte as the problem. MODE_SENSE commands can return
1600 * ILLEGAL REQUEST if the code page isn't supported */ 1704 * ILLEGAL REQUEST if the code page isn't supported */
1601 1705
1602 if (use_10_for_ms && !scsi_status_is_good(sreq->sr_result) && 1706 if (use_10_for_ms && !scsi_status_is_good(result) &&
1603 (driver_byte(sreq->sr_result) & DRIVER_SENSE)) { 1707 (driver_byte(result) & DRIVER_SENSE)) {
1604 struct scsi_sense_hdr sshdr; 1708 if (scsi_sense_valid(sshdr)) {
1605 1709 if ((sshdr->sense_key == ILLEGAL_REQUEST) &&
1606 if (scsi_request_normalize_sense(sreq, &sshdr)) { 1710 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) {
1607 if ((sshdr.sense_key == ILLEGAL_REQUEST) &&
1608 (sshdr.asc == 0x20) && (sshdr.ascq == 0)) {
1609 /* 1711 /*
1610 * Invalid command operation code 1712 * Invalid command operation code
1611 */ 1713 */
1612 sreq->sr_device->use_10_for_ms = 0; 1714 sdev->use_10_for_ms = 0;
1613 goto retry; 1715 goto retry;
1614 } 1716 }
1615 } 1717 }
1616 } 1718 }
1617 1719
1618 if(scsi_status_is_good(sreq->sr_result)) { 1720 if(scsi_status_is_good(result)) {
1619 data->header_length = header_length; 1721 data->header_length = header_length;
1620 if(use_10_for_ms) { 1722 if(use_10_for_ms) {
1621 data->length = buffer[0]*256 + buffer[1] + 2; 1723 data->length = buffer[0]*256 + buffer[1] + 2;
@@ -1632,73 +1734,31 @@ __scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage,
1632 } 1734 }
1633 } 1735 }
1634 1736
1635 return sreq->sr_result; 1737 return result;
1636}
1637EXPORT_SYMBOL(__scsi_mode_sense);
1638
1639/**
1640 * scsi_mode_sense - issue a mode sense, falling back from 10 to
1641 * six bytes if necessary.
1642 * @sdev: scsi device to send command to.
1643 * @dbd: set if mode sense will disable block descriptors in the return
1644 * @modepage: mode page being requested
1645 * @buffer: request buffer (may not be smaller than eight bytes)
1646 * @len: length of request buffer.
1647 * @timeout: command timeout
1648 * @retries: number of retries before failing
1649 *
1650 * Returns zero if unsuccessful, or the header offset (either 4
1651 * or 8 depending on whether a six or ten byte command was
1652 * issued) if successful.
1653 **/
1654int
1655scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
1656 unsigned char *buffer, int len, int timeout, int retries,
1657 struct scsi_mode_data *data)
1658{
1659 struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
1660 int ret;
1661
1662 if (!sreq)
1663 return -1;
1664
1665 ret = __scsi_mode_sense(sreq, dbd, modepage, buffer, len,
1666 timeout, retries, data);
1667
1668 scsi_release_request(sreq);
1669
1670 return ret;
1671} 1738}
1672EXPORT_SYMBOL(scsi_mode_sense); 1739EXPORT_SYMBOL(scsi_mode_sense);
1673 1740
1674int 1741int
1675scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries) 1742scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries)
1676{ 1743{
1677 struct scsi_request *sreq;
1678 char cmd[] = { 1744 char cmd[] = {
1679 TEST_UNIT_READY, 0, 0, 0, 0, 0, 1745 TEST_UNIT_READY, 0, 0, 0, 0, 0,
1680 }; 1746 };
1747 struct scsi_sense_hdr sshdr;
1681 int result; 1748 int result;
1682 1749
1683 sreq = scsi_allocate_request(sdev, GFP_KERNEL); 1750 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, &sshdr,
1684 if (!sreq) 1751 timeout, retries);
1685 return -ENOMEM;
1686
1687 sreq->sr_data_direction = DMA_NONE;
1688 scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
1689 1752
1690 if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && sdev->removable) { 1753 if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) {
1691 struct scsi_sense_hdr sshdr;
1692 1754
1693 if ((scsi_request_normalize_sense(sreq, &sshdr)) && 1755 if ((scsi_sense_valid(&sshdr)) &&
1694 ((sshdr.sense_key == UNIT_ATTENTION) || 1756 ((sshdr.sense_key == UNIT_ATTENTION) ||
1695 (sshdr.sense_key == NOT_READY))) { 1757 (sshdr.sense_key == NOT_READY))) {
1696 sdev->changed = 1; 1758 sdev->changed = 1;
1697 sreq->sr_result = 0; 1759 result = 0;
1698 } 1760 }
1699 } 1761 }
1700 result = sreq->sr_result;
1701 scsi_release_request(sreq);
1702 return result; 1762 return result;
1703} 1763}
1704EXPORT_SYMBOL(scsi_test_unit_ready); 1764EXPORT_SYMBOL(scsi_test_unit_ready);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 076cbe3b5a05..19c9a232a754 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -111,15 +111,14 @@ MODULE_PARM_DESC(inq_timeout,
111 111
112/** 112/**
113 * scsi_unlock_floptical - unlock device via a special MODE SENSE command 113 * scsi_unlock_floptical - unlock device via a special MODE SENSE command
114 * @sreq: used to send the command 114 * @sdev: scsi device to send command to
115 * @result: area to store the result of the MODE SENSE 115 * @result: area to store the result of the MODE SENSE
116 * 116 *
117 * Description: 117 * Description:
118 * Send a vendor specific MODE SENSE (not a MODE SELECT) command using 118 * Send a vendor specific MODE SENSE (not a MODE SELECT) command.
119 * @sreq to unlock a device, storing the (unused) results into result.
120 * Called for BLIST_KEY devices. 119 * Called for BLIST_KEY devices.
121 **/ 120 **/
122static void scsi_unlock_floptical(struct scsi_request *sreq, 121static void scsi_unlock_floptical(struct scsi_device *sdev,
123 unsigned char *result) 122 unsigned char *result)
124{ 123{
125 unsigned char scsi_cmd[MAX_COMMAND_SIZE]; 124 unsigned char scsi_cmd[MAX_COMMAND_SIZE];
@@ -129,11 +128,10 @@ static void scsi_unlock_floptical(struct scsi_request *sreq,
129 scsi_cmd[1] = 0; 128 scsi_cmd[1] = 0;
130 scsi_cmd[2] = 0x2e; 129 scsi_cmd[2] = 0x2e;
131 scsi_cmd[3] = 0; 130 scsi_cmd[3] = 0;
132 scsi_cmd[4] = 0x2a; /* size */ 131 scsi_cmd[4] = 0x2a; /* size */
133 scsi_cmd[5] = 0; 132 scsi_cmd[5] = 0;
134 sreq->sr_cmd_len = 0; 133 scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL,
135 sreq->sr_data_direction = DMA_FROM_DEVICE; 134 SCSI_TIMEOUT, 3);
136 scsi_wait_req(sreq, scsi_cmd, result, 0x2a /* size */, SCSI_TIMEOUT, 3);
137} 135}
138 136
139/** 137/**
@@ -336,9 +334,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
336 unsigned long flags; 334 unsigned long flags;
337 const int size = sizeof(struct scsi_target) 335 const int size = sizeof(struct scsi_target)
338 + shost->transportt->target_size; 336 + shost->transportt->target_size;
339 struct scsi_target *starget = kmalloc(size, GFP_ATOMIC); 337 struct scsi_target *starget;
340 struct scsi_target *found_target; 338 struct scsi_target *found_target;
341 339
340 /*
341 * Obtain the real parent from the transport. The transport
342 * is allowed to fail (no error) if there is nothing at that
343 * target id.
344 */
345 if (shost->transportt->target_parent) {
346 spin_lock_irqsave(shost->host_lock, flags);
347 parent = shost->transportt->target_parent(shost, channel, id);
348 spin_unlock_irqrestore(shost->host_lock, flags);
349 if (!parent)
350 return NULL;
351 }
352
353 starget = kmalloc(size, GFP_KERNEL);
342 if (!starget) { 354 if (!starget) {
343 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 355 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
344 return NULL; 356 return NULL;
@@ -419,26 +431,25 @@ void scsi_target_reap(struct scsi_target *starget)
419 431
420/** 432/**
421 * scsi_probe_lun - probe a single LUN using a SCSI INQUIRY 433 * scsi_probe_lun - probe a single LUN using a SCSI INQUIRY
422 * @sreq: used to send the INQUIRY 434 * @sdev: scsi_device to probe
423 * @inq_result: area to store the INQUIRY result 435 * @inq_result: area to store the INQUIRY result
436 * @result_len: len of inq_result
424 * @bflags: store any bflags found here 437 * @bflags: store any bflags found here
425 * 438 *
426 * Description: 439 * Description:
427 * Probe the lun associated with @sreq using a standard SCSI INQUIRY; 440 * Probe the lun associated with @req using a standard SCSI INQUIRY;
428 * 441 *
429 * If the INQUIRY is successful, sreq->sr_result is zero and: the 442 * If the INQUIRY is successful, zero is returned and the
430 * INQUIRY data is in @inq_result; the scsi_level and INQUIRY length 443 * INQUIRY data is in @inq_result; the scsi_level and INQUIRY length
431 * are copied to the Scsi_Device at @sreq->sr_device (sdev); 444 * are copied to the Scsi_Device any flags value is stored in *@bflags.
432 * any flags value is stored in *@bflags.
433 **/ 445 **/
434static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, 446static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
435 int *bflags) 447 int result_len, int *bflags)
436{ 448{
437 struct scsi_device *sdev = sreq->sr_device; /* a bit ugly */
438 unsigned char scsi_cmd[MAX_COMMAND_SIZE]; 449 unsigned char scsi_cmd[MAX_COMMAND_SIZE];
439 int first_inquiry_len, try_inquiry_len, next_inquiry_len; 450 int first_inquiry_len, try_inquiry_len, next_inquiry_len;
440 int response_len = 0; 451 int response_len = 0;
441 int pass, count; 452 int pass, count, result;
442 struct scsi_sense_hdr sshdr; 453 struct scsi_sense_hdr sshdr;
443 454
444 *bflags = 0; 455 *bflags = 0;
@@ -461,28 +472,26 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
461 memset(scsi_cmd, 0, 6); 472 memset(scsi_cmd, 0, 6);
462 scsi_cmd[0] = INQUIRY; 473 scsi_cmd[0] = INQUIRY;
463 scsi_cmd[4] = (unsigned char) try_inquiry_len; 474 scsi_cmd[4] = (unsigned char) try_inquiry_len;
464 sreq->sr_cmd_len = 0;
465 sreq->sr_data_direction = DMA_FROM_DEVICE;
466 475
467 memset(inq_result, 0, try_inquiry_len); 476 memset(inq_result, 0, try_inquiry_len);
468 scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, 477
469 try_inquiry_len, 478 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
470 HZ/2 + HZ*scsi_inq_timeout, 3); 479 inq_result, try_inquiry_len, &sshdr,
480 HZ / 2 + HZ * scsi_inq_timeout, 3);
471 481
472 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 "
473 "with code 0x%x\n", 483 "with code 0x%x\n",
474 sreq->sr_result ? "failed" : "successful", 484 result ? "failed" : "successful", result));
475 sreq->sr_result));
476 485
477 if (sreq->sr_result) { 486 if (result) {
478 /* 487 /*
479 * not-ready to ready transition [asc/ascq=0x28/0x0] 488 * not-ready to ready transition [asc/ascq=0x28/0x0]
480 * or power-on, reset [asc/ascq=0x29/0x0], continue. 489 * or power-on, reset [asc/ascq=0x29/0x0], continue.
481 * INQUIRY should not yield UNIT_ATTENTION 490 * INQUIRY should not yield UNIT_ATTENTION
482 * but many buggy devices do so anyway. 491 * but many buggy devices do so anyway.
483 */ 492 */
484 if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && 493 if ((driver_byte(result) & DRIVER_SENSE) &&
485 scsi_request_normalize_sense(sreq, &sshdr)) { 494 scsi_sense_valid(&sshdr)) {
486 if ((sshdr.sense_key == UNIT_ATTENTION) && 495 if ((sshdr.sense_key == UNIT_ATTENTION) &&
487 ((sshdr.asc == 0x28) || 496 ((sshdr.asc == 0x28) ||
488 (sshdr.asc == 0x29)) && 497 (sshdr.asc == 0x29)) &&
@@ -493,7 +502,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
493 break; 502 break;
494 } 503 }
495 504
496 if (sreq->sr_result == 0) { 505 if (result == 0) {
497 response_len = (unsigned char) inq_result[4] + 5; 506 response_len = (unsigned char) inq_result[4] + 5;
498 if (response_len > 255) 507 if (response_len > 255)
499 response_len = first_inquiry_len; /* sanity */ 508 response_len = first_inquiry_len; /* sanity */
@@ -542,8 +551,8 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
542 551
543 /* If the last transfer attempt got an error, assume the 552 /* If the last transfer attempt got an error, assume the
544 * peripheral doesn't exist or is dead. */ 553 * peripheral doesn't exist or is dead. */
545 if (sreq->sr_result) 554 if (result)
546 return; 555 return -EIO;
547 556
548 /* Don't report any more data than the device says is valid */ 557 /* Don't report any more data than the device says is valid */
549 sdev->inquiry_len = min(try_inquiry_len, response_len); 558 sdev->inquiry_len = min(try_inquiry_len, response_len);
@@ -579,7 +588,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
579 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) 588 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1))
580 sdev->scsi_level++; 589 sdev->scsi_level++;
581 590
582 return; 591 return 0;
583} 592}
584 593
585/** 594/**
@@ -786,9 +795,8 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
786 void *hostdata) 795 void *hostdata)
787{ 796{
788 struct scsi_device *sdev; 797 struct scsi_device *sdev;
789 struct scsi_request *sreq;
790 unsigned char *result; 798 unsigned char *result;
791 int bflags, res = SCSI_SCAN_NO_RESPONSE; 799 int bflags, res = SCSI_SCAN_NO_RESPONSE, result_len = 256;
792 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 800 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
793 801
794 /* 802 /*
@@ -817,16 +825,13 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
817 sdev = scsi_alloc_sdev(starget, lun, hostdata); 825 sdev = scsi_alloc_sdev(starget, lun, hostdata);
818 if (!sdev) 826 if (!sdev)
819 goto out; 827 goto out;
820 sreq = scsi_allocate_request(sdev, GFP_ATOMIC); 828
821 if (!sreq) 829 result = kmalloc(result_len, GFP_ATOMIC |
822 goto out_free_sdev;
823 result = kmalloc(256, GFP_ATOMIC |
824 ((shost->unchecked_isa_dma) ? __GFP_DMA : 0)); 830 ((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
825 if (!result) 831 if (!result)
826 goto out_free_sreq; 832 goto out_free_sdev;
827 833
828 scsi_probe_lun(sreq, result, &bflags); 834 if (scsi_probe_lun(sdev, result, result_len, &bflags))
829 if (sreq->sr_result)
830 goto out_free_result; 835 goto out_free_result;
831 836
832 /* 837 /*
@@ -854,7 +859,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
854 if (res == SCSI_SCAN_LUN_PRESENT) { 859 if (res == SCSI_SCAN_LUN_PRESENT) {
855 if (bflags & BLIST_KEY) { 860 if (bflags & BLIST_KEY) {
856 sdev->lockable = 0; 861 sdev->lockable = 0;
857 scsi_unlock_floptical(sreq, result); 862 scsi_unlock_floptical(sdev, result);
858 } 863 }
859 if (bflagsp) 864 if (bflagsp)
860 *bflagsp = bflags; 865 *bflagsp = bflags;
@@ -862,8 +867,6 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
862 867
863 out_free_result: 868 out_free_result:
864 kfree(result); 869 kfree(result);
865 out_free_sreq:
866 scsi_release_request(sreq);
867 out_free_sdev: 870 out_free_sdev:
868 if (res == SCSI_SCAN_LUN_PRESENT) { 871 if (res == SCSI_SCAN_LUN_PRESENT) {
869 if (sdevp) { 872 if (sdevp) {
@@ -1056,8 +1059,8 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1056 unsigned int lun; 1059 unsigned int lun;
1057 unsigned int num_luns; 1060 unsigned int num_luns;
1058 unsigned int retries; 1061 unsigned int retries;
1062 int result;
1059 struct scsi_lun *lunp, *lun_data; 1063 struct scsi_lun *lunp, *lun_data;
1060 struct scsi_request *sreq;
1061 u8 *data; 1064 u8 *data;
1062 struct scsi_sense_hdr sshdr; 1065 struct scsi_sense_hdr sshdr;
1063 struct scsi_target *starget = scsi_target(sdev); 1066 struct scsi_target *starget = scsi_target(sdev);
@@ -1075,10 +1078,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1075 if (bflags & BLIST_NOLUN) 1078 if (bflags & BLIST_NOLUN)
1076 return 0; 1079 return 0;
1077 1080
1078 sreq = scsi_allocate_request(sdev, GFP_ATOMIC);
1079 if (!sreq)
1080 goto out;
1081
1082 sprintf(devname, "host %d channel %d id %d", 1081 sprintf(devname, "host %d channel %d id %d",
1083 sdev->host->host_no, sdev->channel, sdev->id); 1082 sdev->host->host_no, sdev->channel, sdev->id);
1084 1083
@@ -1096,7 +1095,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1096 lun_data = kmalloc(length, GFP_ATOMIC | 1095 lun_data = kmalloc(length, GFP_ATOMIC |
1097 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0)); 1096 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
1098 if (!lun_data) 1097 if (!lun_data)
1099 goto out_release_request; 1098 goto out;
1100 1099
1101 scsi_cmd[0] = REPORT_LUNS; 1100 scsi_cmd[0] = REPORT_LUNS;
1102 1101
@@ -1115,8 +1114,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1115 1114
1116 scsi_cmd[10] = 0; /* reserved */ 1115 scsi_cmd[10] = 0; /* reserved */
1117 scsi_cmd[11] = 0; /* control */ 1116 scsi_cmd[11] = 0; /* control */
1118 sreq->sr_cmd_len = 0;
1119 sreq->sr_data_direction = DMA_FROM_DEVICE;
1120 1117
1121 /* 1118 /*
1122 * We can get a UNIT ATTENTION, for example a power on/reset, so 1119 * We can get a UNIT ATTENTION, for example a power on/reset, so
@@ -1132,29 +1129,29 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1132 SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: Sending" 1129 SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: Sending"
1133 " REPORT LUNS to %s (try %d)\n", devname, 1130 " REPORT LUNS to %s (try %d)\n", devname,
1134 retries)); 1131 retries));
1135 scsi_wait_req(sreq, scsi_cmd, lun_data, length, 1132
1136 SCSI_TIMEOUT + 4*HZ, 3); 1133 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
1134 lun_data, length, &sshdr,
1135 SCSI_TIMEOUT + 4 * HZ, 3);
1136
1137 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"
1138 " %s (try %d) result 0x%x\n", sreq->sr_result 1138 " %s (try %d) result 0x%x\n", result
1139 ? "failed" : "successful", retries, 1139 ? "failed" : "successful", retries, result));
1140 sreq->sr_result)); 1140 if (result == 0)
1141 if (sreq->sr_result == 0)
1142 break; 1141 break;
1143 else if (scsi_request_normalize_sense(sreq, &sshdr)) { 1142 else if (scsi_sense_valid(&sshdr)) {
1144 if (sshdr.sense_key != UNIT_ATTENTION) 1143 if (sshdr.sense_key != UNIT_ATTENTION)
1145 break; 1144 break;
1146 } 1145 }
1147 } 1146 }
1148 1147
1149 if (sreq->sr_result) { 1148 if (result) {
1150 /* 1149 /*
1151 * The device probably does not support a REPORT LUN command 1150 * The device probably does not support a REPORT LUN command
1152 */ 1151 */
1153 kfree(lun_data); 1152 kfree(lun_data);
1154 scsi_release_request(sreq);
1155 return 1; 1153 return 1;
1156 } 1154 }
1157 scsi_release_request(sreq);
1158 1155
1159 /* 1156 /*
1160 * Get the length from the first four bytes of lun_data. 1157 * Get the length from the first four bytes of lun_data.
@@ -1228,8 +1225,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1228 kfree(lun_data); 1225 kfree(lun_data);
1229 return 0; 1226 return 0;
1230 1227
1231 out_release_request:
1232 scsi_release_request(sreq);
1233 out: 1228 out:
1234 /* 1229 /*
1235 * We are out of memory, don't try scanning any further. 1230 * We are out of memory, don't try scanning any further.
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 96243c7fe110..2cab556b6e82 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1024,6 +1024,23 @@ static int fc_rport_match(struct attribute_container *cont,
1024 return &i->rport_attr_cont.ac == cont; 1024 return &i->rport_attr_cont.ac == cont;
1025} 1025}
1026 1026
1027
1028/*
1029 * Must be called with shost->host_lock held
1030 */
1031static struct device *fc_target_parent(struct Scsi_Host *shost,
1032 int channel, uint id)
1033{
1034 struct fc_rport *rport;
1035
1036 list_for_each_entry(rport, &fc_host_rports(shost), peers)
1037 if ((rport->channel == channel) &&
1038 (rport->scsi_target_id == id))
1039 return &rport->dev;
1040
1041 return NULL;
1042}
1043
1027struct scsi_transport_template * 1044struct scsi_transport_template *
1028fc_attach_transport(struct fc_function_template *ft) 1045fc_attach_transport(struct fc_function_template *ft)
1029{ 1046{
@@ -1059,6 +1076,8 @@ fc_attach_transport(struct fc_function_template *ft)
1059 1076
1060 /* Transport uses the shost workq for scsi scanning */ 1077 /* Transport uses the shost workq for scsi scanning */
1061 i->t.create_work_queue = 1; 1078 i->t.create_work_queue = 1;
1079
1080 i->t.target_parent = fc_target_parent;
1062 1081
1063 /* 1082 /*
1064 * Setup SCSI Target Attributes. 1083 * Setup SCSI Target Attributes.
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 89f6b7feb9c2..ef577c8c2182 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -28,7 +28,7 @@
28#include "scsi_priv.h" 28#include "scsi_priv.h"
29#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
30#include <scsi/scsi_host.h> 30#include <scsi/scsi_host.h>
31#include <scsi/scsi_request.h> 31#include <scsi/scsi_cmnd.h>
32#include <scsi/scsi_eh.h> 32#include <scsi/scsi_eh.h>
33#include <scsi/scsi_transport.h> 33#include <scsi/scsi_transport.h>
34#include <scsi/scsi_transport_spi.h> 34#include <scsi/scsi_transport_spi.h>
@@ -106,27 +106,31 @@ static int sprint_frac(char *dest, int value, int denom)
106 return result; 106 return result;
107} 107}
108 108
109/* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions 109static int spi_execute(struct scsi_device *sdev, const void *cmd,
110 * resulting from (likely) bus and device resets */ 110 enum dma_data_direction dir,
111static void spi_wait_req(struct scsi_request *sreq, const void *cmd, 111 void *buffer, unsigned bufflen,
112 void *buffer, unsigned bufflen) 112 struct scsi_sense_hdr *sshdr)
113{ 113{
114 int i; 114 int i, result;
115 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
115 116
116 for(i = 0; i < DV_RETRIES; i++) { 117 for(i = 0; i < DV_RETRIES; i++) {
117 sreq->sr_request->flags |= REQ_FAILFAST; 118 result = scsi_execute(sdev, cmd, dir, buffer, bufflen,
118 119 sense, DV_TIMEOUT, /* retries */ 1,
119 scsi_wait_req(sreq, cmd, buffer, bufflen, 120 REQ_FAILFAST);
120 DV_TIMEOUT, /* retries */ 1); 121 if (result & DRIVER_SENSE) {
121 if (sreq->sr_result & DRIVER_SENSE) { 122 struct scsi_sense_hdr sshdr_tmp;
122 struct scsi_sense_hdr sshdr; 123 if (!sshdr)
123 124 sshdr = &sshdr_tmp;
124 if (scsi_request_normalize_sense(sreq, &sshdr) 125
125 && sshdr.sense_key == UNIT_ATTENTION) 126 if (scsi_normalize_sense(sense, sizeof(*sense),
127 sshdr)
128 && sshdr->sense_key == UNIT_ATTENTION)
126 continue; 129 continue;
127 } 130 }
128 break; 131 break;
129 } 132 }
133 return result;
130} 134}
131 135
132static struct { 136static struct {
@@ -546,13 +550,13 @@ enum spi_compare_returns {
546/* This is for read/write Domain Validation: If the device supports 550/* This is for read/write Domain Validation: If the device supports
547 * an echo buffer, we do read/write tests to it */ 551 * an echo buffer, we do read/write tests to it */
548static enum spi_compare_returns 552static enum spi_compare_returns
549spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer, 553spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
550 u8 *ptr, const int retries) 554 u8 *ptr, const int retries)
551{ 555{
552 struct scsi_device *sdev = sreq->sr_device;
553 int len = ptr - buffer; 556 int len = ptr - buffer;
554 int j, k, r; 557 int j, k, r, result;
555 unsigned int pattern = 0x0000ffff; 558 unsigned int pattern = 0x0000ffff;
559 struct scsi_sense_hdr sshdr;
556 560
557 const char spi_write_buffer[] = { 561 const char spi_write_buffer[] = {
558 WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0 562 WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
@@ -597,14 +601,12 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
597 } 601 }
598 602
599 for (r = 0; r < retries; r++) { 603 for (r = 0; r < retries; r++) {
600 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 604 result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE,
601 sreq->sr_data_direction = DMA_TO_DEVICE; 605 buffer, len, &sshdr);
602 spi_wait_req(sreq, spi_write_buffer, buffer, len); 606 if(result || !scsi_device_online(sdev)) {
603 if(sreq->sr_result || !scsi_device_online(sdev)) {
604 struct scsi_sense_hdr sshdr;
605 607
606 scsi_device_set_state(sdev, SDEV_QUIESCE); 608 scsi_device_set_state(sdev, SDEV_QUIESCE);
607 if (scsi_request_normalize_sense(sreq, &sshdr) 609 if (scsi_sense_valid(&sshdr)
608 && sshdr.sense_key == ILLEGAL_REQUEST 610 && sshdr.sense_key == ILLEGAL_REQUEST
609 /* INVALID FIELD IN CDB */ 611 /* INVALID FIELD IN CDB */
610 && sshdr.asc == 0x24 && sshdr.ascq == 0x00) 612 && sshdr.asc == 0x24 && sshdr.ascq == 0x00)
@@ -616,14 +618,13 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
616 return SPI_COMPARE_SKIP_TEST; 618 return SPI_COMPARE_SKIP_TEST;
617 619
618 620
619 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result); 621 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", result);
620 return SPI_COMPARE_FAILURE; 622 return SPI_COMPARE_FAILURE;
621 } 623 }
622 624
623 memset(ptr, 0, len); 625 memset(ptr, 0, len);
624 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 626 spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE,
625 sreq->sr_data_direction = DMA_FROM_DEVICE; 627 ptr, len, NULL);
626 spi_wait_req(sreq, spi_read_buffer, ptr, len);
627 scsi_device_set_state(sdev, SDEV_QUIESCE); 628 scsi_device_set_state(sdev, SDEV_QUIESCE);
628 629
629 if (memcmp(buffer, ptr, len) != 0) 630 if (memcmp(buffer, ptr, len) != 0)
@@ -635,25 +636,22 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
635/* This is for the simplest form of Domain Validation: a read test 636/* This is for the simplest form of Domain Validation: a read test
636 * on the inquiry data from the device */ 637 * on the inquiry data from the device */
637static enum spi_compare_returns 638static enum spi_compare_returns
638spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer, 639spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer,
639 u8 *ptr, const int retries) 640 u8 *ptr, const int retries)
640{ 641{
641 int r; 642 int r, result;
642 const int len = sreq->sr_device->inquiry_len; 643 const int len = sdev->inquiry_len;
643 struct scsi_device *sdev = sreq->sr_device;
644 const char spi_inquiry[] = { 644 const char spi_inquiry[] = {
645 INQUIRY, 0, 0, 0, len, 0 645 INQUIRY, 0, 0, 0, len, 0
646 }; 646 };
647 647
648 for (r = 0; r < retries; r++) { 648 for (r = 0; r < retries; r++) {
649 sreq->sr_cmd_len = 0; /* wait_req to fill in */
650 sreq->sr_data_direction = DMA_FROM_DEVICE;
651
652 memset(ptr, 0, len); 649 memset(ptr, 0, len);
653 650
654 spi_wait_req(sreq, spi_inquiry, ptr, len); 651 result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE,
652 ptr, len, NULL);
655 653
656 if(sreq->sr_result || !scsi_device_online(sdev)) { 654 if(result || !scsi_device_online(sdev)) {
657 scsi_device_set_state(sdev, SDEV_QUIESCE); 655 scsi_device_set_state(sdev, SDEV_QUIESCE);
658 return SPI_COMPARE_FAILURE; 656 return SPI_COMPARE_FAILURE;
659 } 657 }
@@ -674,12 +672,11 @@ spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
674} 672}
675 673
676static enum spi_compare_returns 674static enum spi_compare_returns
677spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr, 675spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr,
678 enum spi_compare_returns 676 enum spi_compare_returns
679 (*compare_fn)(struct scsi_request *, u8 *, u8 *, int)) 677 (*compare_fn)(struct scsi_device *, u8 *, u8 *, int))
680{ 678{
681 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 679 struct spi_internal *i = to_spi_internal(sdev->host->transportt);
682 struct scsi_device *sdev = sreq->sr_device;
683 struct scsi_target *starget = sdev->sdev_target; 680 struct scsi_target *starget = sdev->sdev_target;
684 int period = 0, prevperiod = 0; 681 int period = 0, prevperiod = 0;
685 enum spi_compare_returns retval; 682 enum spi_compare_returns retval;
@@ -687,7 +684,7 @@ spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,
687 684
688 for (;;) { 685 for (;;) {
689 int newperiod; 686 int newperiod;
690 retval = compare_fn(sreq, buffer, ptr, DV_LOOPS); 687 retval = compare_fn(sdev, buffer, ptr, DV_LOOPS);
691 688
692 if (retval == SPI_COMPARE_SUCCESS 689 if (retval == SPI_COMPARE_SUCCESS
693 || retval == SPI_COMPARE_SKIP_TEST) 690 || retval == SPI_COMPARE_SKIP_TEST)
@@ -733,9 +730,9 @@ spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,
733} 730}
734 731
735static int 732static int
736spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer) 733spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
737{ 734{
738 int l; 735 int l, result;
739 736
740 /* first off do a test unit ready. This can error out 737 /* first off do a test unit ready. This can error out
741 * because of reservations or some other reason. If it 738 * because of reservations or some other reason. If it
@@ -751,18 +748,16 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
751 }; 748 };
752 749
753 750
754 sreq->sr_cmd_len = 0;
755 sreq->sr_data_direction = DMA_NONE;
756
757 /* We send a set of three TURs to clear any outstanding 751 /* We send a set of three TURs to clear any outstanding
758 * unit attention conditions if they exist (Otherwise the 752 * unit attention conditions if they exist (Otherwise the
759 * buffer tests won't be happy). If the TUR still fails 753 * buffer tests won't be happy). If the TUR still fails
760 * (reservation conflict, device not ready, etc) just 754 * (reservation conflict, device not ready, etc) just
761 * skip the write tests */ 755 * skip the write tests */
762 for (l = 0; ; l++) { 756 for (l = 0; ; l++) {
763 spi_wait_req(sreq, spi_test_unit_ready, NULL, 0); 757 result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE,
758 NULL, 0, NULL);
764 759
765 if(sreq->sr_result) { 760 if(result) {
766 if(l >= 3) 761 if(l >= 3)
767 return 0; 762 return 0;
768 } else { 763 } else {
@@ -771,12 +766,10 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
771 } 766 }
772 } 767 }
773 768
774 sreq->sr_cmd_len = 0; 769 result = spi_execute(sdev, spi_read_buffer_descriptor,
775 sreq->sr_data_direction = DMA_FROM_DEVICE; 770 DMA_FROM_DEVICE, buffer, 4, NULL);
776
777 spi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4);
778 771
779 if (sreq->sr_result) 772 if (result)
780 /* Device has no echo buffer */ 773 /* Device has no echo buffer */
781 return 0; 774 return 0;
782 775
@@ -784,17 +777,16 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
784} 777}
785 778
786static void 779static void
787spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer) 780spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
788{ 781{
789 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 782 struct spi_internal *i = to_spi_internal(sdev->host->transportt);
790 struct scsi_device *sdev = sreq->sr_device;
791 struct scsi_target *starget = sdev->sdev_target; 783 struct scsi_target *starget = sdev->sdev_target;
792 int len = sdev->inquiry_len; 784 int len = sdev->inquiry_len;
793 /* first set us up for narrow async */ 785 /* first set us up for narrow async */
794 DV_SET(offset, 0); 786 DV_SET(offset, 0);
795 DV_SET(width, 0); 787 DV_SET(width, 0);
796 788
797 if (spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS) 789 if (spi_dv_device_compare_inquiry(sdev, buffer, buffer, DV_LOOPS)
798 != SPI_COMPARE_SUCCESS) { 790 != SPI_COMPARE_SUCCESS) {
799 SPI_PRINTK(starget, KERN_ERR, "Domain Validation Initial Inquiry Failed\n"); 791 SPI_PRINTK(starget, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
800 /* FIXME: should probably offline the device here? */ 792 /* FIXME: should probably offline the device here? */
@@ -806,7 +798,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
806 scsi_device_wide(sdev)) { 798 scsi_device_wide(sdev)) {
807 i->f->set_width(starget, 1); 799 i->f->set_width(starget, 1);
808 800
809 if (spi_dv_device_compare_inquiry(sreq, buffer, 801 if (spi_dv_device_compare_inquiry(sdev, buffer,
810 buffer + len, 802 buffer + len,
811 DV_LOOPS) 803 DV_LOOPS)
812 != SPI_COMPARE_SUCCESS) { 804 != SPI_COMPARE_SUCCESS) {
@@ -827,7 +819,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
827 819
828 len = 0; 820 len = 0;
829 if (scsi_device_dt(sdev)) 821 if (scsi_device_dt(sdev))
830 len = spi_dv_device_get_echo_buffer(sreq, buffer); 822 len = spi_dv_device_get_echo_buffer(sdev, buffer);
831 823
832 retry: 824 retry:
833 825
@@ -853,7 +845,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
853 845
854 if (len == 0) { 846 if (len == 0) {
855 SPI_PRINTK(starget, KERN_INFO, "Domain Validation skipping write tests\n"); 847 SPI_PRINTK(starget, KERN_INFO, "Domain Validation skipping write tests\n");
856 spi_dv_retrain(sreq, buffer, buffer + len, 848 spi_dv_retrain(sdev, buffer, buffer + len,
857 spi_dv_device_compare_inquiry); 849 spi_dv_device_compare_inquiry);
858 return; 850 return;
859 } 851 }
@@ -863,7 +855,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
863 len = SPI_MAX_ECHO_BUFFER_SIZE; 855 len = SPI_MAX_ECHO_BUFFER_SIZE;
864 } 856 }
865 857
866 if (spi_dv_retrain(sreq, buffer, buffer + len, 858 if (spi_dv_retrain(sdev, buffer, buffer + len,
867 spi_dv_device_echo_buffer) 859 spi_dv_device_echo_buffer)
868 == SPI_COMPARE_SKIP_TEST) { 860 == SPI_COMPARE_SKIP_TEST) {
869 /* OK, the stupid drive can't do a write echo buffer 861 /* OK, the stupid drive can't do a write echo buffer
@@ -886,16 +878,12 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
886void 878void
887spi_dv_device(struct scsi_device *sdev) 879spi_dv_device(struct scsi_device *sdev)
888{ 880{
889 struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
890 struct scsi_target *starget = sdev->sdev_target; 881 struct scsi_target *starget = sdev->sdev_target;
891 u8 *buffer; 882 u8 *buffer;
892 const int len = SPI_MAX_ECHO_BUFFER_SIZE*2; 883 const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
893 884
894 if (unlikely(!sreq))
895 return;
896
897 if (unlikely(scsi_device_get(sdev))) 885 if (unlikely(scsi_device_get(sdev)))
898 goto out_free_req; 886 return;
899 887
900 buffer = kmalloc(len, GFP_KERNEL); 888 buffer = kmalloc(len, GFP_KERNEL);
901 889
@@ -916,7 +904,7 @@ spi_dv_device(struct scsi_device *sdev)
916 904
917 SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n"); 905 SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n");
918 906
919 spi_dv_device_internal(sreq, buffer); 907 spi_dv_device_internal(sdev, buffer);
920 908
921 SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n"); 909 SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n");
922 910
@@ -931,8 +919,6 @@ spi_dv_device(struct scsi_device *sdev)
931 kfree(buffer); 919 kfree(buffer);
932 out_put: 920 out_put:
933 scsi_device_put(sdev); 921 scsi_device_put(sdev);
934 out_free_req:
935 scsi_release_request(sreq);
936} 922}
937EXPORT_SYMBOL(spi_dv_device); 923EXPORT_SYMBOL(spi_dv_device);
938 924
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 *);
125static void sd_end_flush(request_queue_t *, struct request *); 124static void sd_end_flush(request_queue_t *, struct request *);
126static int sd_prepare_flush(request_queue_t *, struct request *); 125static int sd_prepare_flush(request_queue_t *, struct request *);
127static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 126static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
128 struct scsi_request *SRpnt, unsigned char *buffer); 127 unsigned char *buffer);
129 128
130static struct scsi_driver sd_template = { 129static struct scsi_driver sd_template = {
131 .owner = THIS_MODULE, 130 .owner = THIS_MODULE,
@@ -682,19 +681,13 @@ not_present:
682 681
683static int sd_sync_cache(struct scsi_device *sdp) 682static 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
960static int media_not_present(struct scsi_disk *sdkp, struct scsi_request *srp) 951static 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 */
983static void 971static void
984sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, 972sd_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 */
1119static void 1097static void
1120sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 1098sd_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
1130repeat: 1109repeat:
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 */
1312static inline int 1286static inline int
1313sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage, 1287sd_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 */
1324static void 1300static void
1325sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, 1301sd_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 */
1380static void 1358static void
1381sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, 1359sd_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
1455bad_sense: 1434bad_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}
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 616c3f3e62fc..b1b69d738d08 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2970,23 +2970,22 @@ static void * dev_seq_start(struct seq_file *s, loff_t *pos)
2970{ 2970{
2971 struct sg_proc_deviter * it = kmalloc(sizeof(*it), GFP_KERNEL); 2971 struct sg_proc_deviter * it = kmalloc(sizeof(*it), GFP_KERNEL);
2972 2972
2973 s->private = it;
2973 if (! it) 2974 if (! it)
2974 return NULL; 2975 return NULL;
2976
2975 if (NULL == sg_dev_arr) 2977 if (NULL == sg_dev_arr)
2976 goto err1; 2978 return NULL;
2977 it->index = *pos; 2979 it->index = *pos;
2978 it->max = sg_last_dev(); 2980 it->max = sg_last_dev();
2979 if (it->index >= it->max) 2981 if (it->index >= it->max)
2980 goto err1; 2982 return NULL;
2981 return it; 2983 return it;
2982err1:
2983 kfree(it);
2984 return NULL;
2985} 2984}
2986 2985
2987static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos) 2986static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
2988{ 2987{
2989 struct sg_proc_deviter * it = (struct sg_proc_deviter *) v; 2988 struct sg_proc_deviter * it = s->private;
2990 2989
2991 *pos = ++it->index; 2990 *pos = ++it->index;
2992 return (it->index < it->max) ? it : NULL; 2991 return (it->index < it->max) ? it : NULL;
@@ -2994,7 +2993,7 @@ static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
2994 2993
2995static void dev_seq_stop(struct seq_file *s, void *v) 2994static void dev_seq_stop(struct seq_file *s, void *v)
2996{ 2995{
2997 kfree (v); 2996 kfree(s->private);
2998} 2997}
2999 2998
3000static int sg_proc_open_dev(struct inode *inode, struct file *file) 2999static int sg_proc_open_dev(struct inode *inode, struct file *file)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index f63d8c6c2a33..ce63fc8312dc 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -50,10 +50,10 @@
50#include <scsi/scsi_dbg.h> 50#include <scsi/scsi_dbg.h>
51#include <scsi/scsi_device.h> 51#include <scsi/scsi_device.h>
52#include <scsi/scsi_driver.h> 52#include <scsi/scsi_driver.h>
53#include <scsi/scsi_cmnd.h>
53#include <scsi/scsi_eh.h> 54#include <scsi/scsi_eh.h>
54#include <scsi/scsi_host.h> 55#include <scsi/scsi_host.h>
55#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */ 56#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */
56#include <scsi/scsi_request.h>
57 57
58#include "scsi_logging.h" 58#include "scsi_logging.h"
59#include "sr.h" 59#include "sr.h"
@@ -642,39 +642,27 @@ static void get_sectorsize(struct scsi_cd *cd)
642 unsigned char *buffer; 642 unsigned char *buffer;
643 int the_result, retries = 3; 643 int the_result, retries = 3;
644 int sector_size; 644 int sector_size;
645 struct scsi_request *SRpnt = NULL;
646 request_queue_t *queue; 645 request_queue_t *queue;
647 646
648 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 647 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
649 if (!buffer) 648 if (!buffer)
650 goto Enomem; 649 goto Enomem;
651 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
652 if (!SRpnt)
653 goto Enomem;
654 650
655 do { 651 do {
656 cmd[0] = READ_CAPACITY; 652 cmd[0] = READ_CAPACITY;
657 memset((void *) &cmd[1], 0, 9); 653 memset((void *) &cmd[1], 0, 9);
658 /* Mark as really busy */
659 SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
660 SRpnt->sr_cmd_len = 0;
661
662 memset(buffer, 0, 8); 654 memset(buffer, 0, 8);
663 655
664 /* Do the command and wait.. */ 656 /* Do the command and wait.. */
665 SRpnt->sr_data_direction = DMA_FROM_DEVICE; 657 the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
666 scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, 658 buffer, 8, NULL, SR_TIMEOUT,
667 8, SR_TIMEOUT, MAX_RETRIES); 659 MAX_RETRIES);
668 660
669 the_result = SRpnt->sr_result;
670 retries--; 661 retries--;
671 662
672 } while (the_result && retries); 663 } while (the_result && retries);
673 664
674 665
675 scsi_release_request(SRpnt);
676 SRpnt = NULL;
677
678 if (the_result) { 666 if (the_result) {
679 cd->capacity = 0x1fffff; 667 cd->capacity = 0x1fffff;
680 sector_size = 2048; /* A guess, just in case */ 668 sector_size = 2048; /* A guess, just in case */
@@ -730,8 +718,6 @@ out:
730Enomem: 718Enomem:
731 cd->capacity = 0x1fffff; 719 cd->capacity = 0x1fffff;
732 cd->device->sector_size = 2048; /* A guess, just in case */ 720 cd->device->sector_size = 2048; /* A guess, just in case */
733 if (SRpnt)
734 scsi_release_request(SRpnt);
735 goto out; 721 goto out;
736} 722}
737 723
@@ -739,8 +725,8 @@ static void get_capabilities(struct scsi_cd *cd)
739{ 725{
740 unsigned char *buffer; 726 unsigned char *buffer;
741 struct scsi_mode_data data; 727 struct scsi_mode_data data;
742 struct scsi_request *SRpnt;
743 unsigned char cmd[MAX_COMMAND_SIZE]; 728 unsigned char cmd[MAX_COMMAND_SIZE];
729 struct scsi_sense_hdr sshdr;
744 unsigned int the_result; 730 unsigned int the_result;
745 int retries, rc, n; 731 int retries, rc, n;
746 732
@@ -756,19 +742,11 @@ static void get_capabilities(struct scsi_cd *cd)
756 "" 742 ""
757 }; 743 };
758 744
759 /* allocate a request for the TEST_UNIT_READY */
760 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
761 if (!SRpnt) {
762 printk(KERN_WARNING "(get_capabilities:) Request allocation "
763 "failure.\n");
764 return;
765 }
766 745
767 /* allocate transfer buffer */ 746 /* allocate transfer buffer */
768 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 747 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
769 if (!buffer) { 748 if (!buffer) {
770 printk(KERN_ERR "sr: out of memory.\n"); 749 printk(KERN_ERR "sr: out of memory.\n");
771 scsi_release_request(SRpnt);
772 return; 750 return;
773 } 751 }
774 752
@@ -780,24 +758,19 @@ static void get_capabilities(struct scsi_cd *cd)
780 memset((void *)cmd, 0, MAX_COMMAND_SIZE); 758 memset((void *)cmd, 0, MAX_COMMAND_SIZE);
781 cmd[0] = TEST_UNIT_READY; 759 cmd[0] = TEST_UNIT_READY;
782 760
783 SRpnt->sr_cmd_len = 0; 761 the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
784 SRpnt->sr_sense_buffer[0] = 0; 762 0, &sshdr, SR_TIMEOUT,
785 SRpnt->sr_sense_buffer[2] = 0; 763 MAX_RETRIES);
786 SRpnt->sr_data_direction = DMA_NONE;
787
788 scsi_wait_req (SRpnt, (void *) cmd, buffer,
789 0, SR_TIMEOUT, MAX_RETRIES);
790 764
791 the_result = SRpnt->sr_result;
792 retries++; 765 retries++;
793 } while (retries < 5 && 766 } while (retries < 5 &&
794 (!scsi_status_is_good(the_result) || 767 (!scsi_status_is_good(the_result) ||
795 ((driver_byte(the_result) & DRIVER_SENSE) && 768 (scsi_sense_valid(&sshdr) &&
796 SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION))); 769 sshdr.sense_key == UNIT_ATTENTION)));
797 770
798 /* ask for mode page 0x2a */ 771 /* ask for mode page 0x2a */
799 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, 772 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
800 SR_TIMEOUT, 3, &data); 773 SR_TIMEOUT, 3, &data, NULL);
801 774
802 if (!scsi_status_is_good(rc)) { 775 if (!scsi_status_is_good(rc)) {
803 /* failed, drive doesn't have capabilities mode page */ 776 /* failed, drive doesn't have capabilities mode page */
@@ -805,7 +778,6 @@ static void get_capabilities(struct scsi_cd *cd)
805 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | 778 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
806 CDC_DVD | CDC_DVD_RAM | 779 CDC_DVD | CDC_DVD_RAM |
807 CDC_SELECT_DISC | CDC_SELECT_SPEED); 780 CDC_SELECT_DISC | CDC_SELECT_SPEED);
808 scsi_release_request(SRpnt);
809 kfree(buffer); 781 kfree(buffer);
810 printk("%s: scsi-1 drive\n", cd->cdi.name); 782 printk("%s: scsi-1 drive\n", cd->cdi.name);
811 return; 783 return;
@@ -865,7 +837,6 @@ static void get_capabilities(struct scsi_cd *cd)
865 cd->device->writeable = 1; 837 cd->device->writeable = 1;
866 } 838 }
867 839
868 scsi_release_request(SRpnt);
869 kfree(buffer); 840 kfree(buffer);
870} 841}
871 842
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 82d68fdb1548..6e45ac3c43c5 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -17,7 +17,7 @@
17#include <scsi/scsi_eh.h> 17#include <scsi/scsi_eh.h>
18#include <scsi/scsi_host.h> 18#include <scsi/scsi_host.h>
19#include <scsi/scsi_ioctl.h> 19#include <scsi/scsi_ioctl.h>
20#include <scsi/scsi_request.h> 20#include <scsi/scsi_cmnd.h>
21 21
22#include "sr.h" 22#include "sr.h"
23 23
@@ -84,41 +84,37 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
84 84
85int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) 85int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
86{ 86{
87 struct scsi_request *SRpnt;
88 struct scsi_device *SDev; 87 struct scsi_device *SDev;
89 struct request *req; 88 struct scsi_sense_hdr sshdr;
90 int result, err = 0, retries = 0; 89 int result, err = 0, retries = 0;
90 struct request_sense *sense = cgc->sense;
91 91
92 SDev = cd->device; 92 SDev = cd->device;
93 SRpnt = scsi_allocate_request(SDev, GFP_KERNEL); 93
94 if (!SRpnt) { 94 if (!sense) {
95 printk(KERN_ERR "Unable to allocate SCSI request in sr_do_ioctl"); 95 sense = kmalloc(sizeof(*sense), GFP_KERNEL);
96 err = -ENOMEM; 96 if (!sense) {
97 goto out; 97 err = -ENOMEM;
98 } 98 goto out;
99 SRpnt->sr_data_direction = cgc->data_direction; 99 }
100 }
100 101
101 retry: 102 retry:
102 if (!scsi_block_when_processing_errors(SDev)) { 103 if (!scsi_block_when_processing_errors(SDev)) {
103 err = -ENODEV; 104 err = -ENODEV;
104 goto out_free; 105 goto out;
105 } 106 }
106 107
107 scsi_wait_req(SRpnt, cgc->cmd, cgc->buffer, cgc->buflen, 108 memset(sense, 0, sizeof(*sense));
108 cgc->timeout, IOCTL_RETRIES); 109 result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
109 110 cgc->buffer, cgc->buflen, (char *)sense,
110 req = SRpnt->sr_request; 111 cgc->timeout, IOCTL_RETRIES, 0);
111 if (SRpnt->sr_buffer && req->buffer && SRpnt->sr_buffer != req->buffer) {
112 memcpy(req->buffer, SRpnt->sr_buffer, SRpnt->sr_bufflen);
113 kfree(SRpnt->sr_buffer);
114 SRpnt->sr_buffer = req->buffer;
115 }
116 112
117 result = SRpnt->sr_result; 113 scsi_normalize_sense((char *)sense, sizeof(*sense), &sshdr);
118 114
119 /* Minimal error checking. Ignore cases we know about, and report the rest. */ 115 /* Minimal error checking. Ignore cases we know about, and report the rest. */
120 if (driver_byte(result) != 0) { 116 if (driver_byte(result) != 0) {
121 switch (SRpnt->sr_sense_buffer[2] & 0xf) { 117 switch (sshdr.sense_key) {
122 case UNIT_ATTENTION: 118 case UNIT_ATTENTION:
123 SDev->changed = 1; 119 SDev->changed = 1;
124 if (!cgc->quiet) 120 if (!cgc->quiet)
@@ -128,8 +124,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
128 err = -ENOMEDIUM; 124 err = -ENOMEDIUM;
129 break; 125 break;
130 case NOT_READY: /* This happens if there is no disc in drive */ 126 case NOT_READY: /* This happens if there is no disc in drive */
131 if (SRpnt->sr_sense_buffer[12] == 0x04 && 127 if (sshdr.asc == 0x04 &&
132 SRpnt->sr_sense_buffer[13] == 0x01) { 128 sshdr.ascq == 0x01) {
133 /* sense: Logical unit is in process of becoming ready */ 129 /* sense: Logical unit is in process of becoming ready */
134 if (!cgc->quiet) 130 if (!cgc->quiet)
135 printk(KERN_INFO "%s: CDROM not ready yet.\n", cd->cdi.name); 131 printk(KERN_INFO "%s: CDROM not ready yet.\n", cd->cdi.name);
@@ -146,37 +142,33 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
146 if (!cgc->quiet) 142 if (!cgc->quiet)
147 printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name); 143 printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name);
148#ifdef DEBUG 144#ifdef DEBUG
149 scsi_print_req_sense("sr", SRpnt); 145 scsi_print_sense_hdr("sr", &sshdr);
150#endif 146#endif
151 err = -ENOMEDIUM; 147 err = -ENOMEDIUM;
152 break; 148 break;
153 case ILLEGAL_REQUEST: 149 case ILLEGAL_REQUEST:
154 err = -EIO; 150 err = -EIO;
155 if (SRpnt->sr_sense_buffer[12] == 0x20 && 151 if (sshdr.asc == 0x20 &&
156 SRpnt->sr_sense_buffer[13] == 0x00) 152 sshdr.ascq == 0x00)
157 /* sense: Invalid command operation code */ 153 /* sense: Invalid command operation code */
158 err = -EDRIVE_CANT_DO_THIS; 154 err = -EDRIVE_CANT_DO_THIS;
159#ifdef DEBUG 155#ifdef DEBUG
160 __scsi_print_command(cgc->cmd); 156 __scsi_print_command(cgc->cmd);
161 scsi_print_req_sense("sr", SRpnt); 157 scsi_print_sense_hdr("sr", &sshdr);
162#endif 158#endif
163 break; 159 break;
164 default: 160 default:
165 printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name); 161 printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name);
166 __scsi_print_command(cgc->cmd); 162 __scsi_print_command(cgc->cmd);
167 scsi_print_req_sense("sr", SRpnt); 163 scsi_print_sense_hdr("sr", &sshdr);
168 err = -EIO; 164 err = -EIO;
169 } 165 }
170 } 166 }
171 167
172 if (cgc->sense)
173 memcpy(cgc->sense, SRpnt->sr_sense_buffer, sizeof(*cgc->sense));
174
175 /* Wake up a process waiting for device */ 168 /* Wake up a process waiting for device */
176 out_free:
177 scsi_release_request(SRpnt);
178 SRpnt = NULL;
179 out: 169 out:
170 if (!cgc->sense)
171 kfree(sense);
180 cgc->stat = err; 172 cgc->stat = err;
181 return err; 173 return err;
182} 174}
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 5325cf0ab197..a93308ae9736 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4241,12 +4241,10 @@ static int __init init_st(void)
4241 do_create_driverfs_files(); 4241 do_create_driverfs_files();
4242 return 0; 4242 return 0;
4243 } 4243 }
4244 if (st_sysfs_class)
4245 class_destroy(st_sysfs_class);
4246 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0), 4244 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
4247
4248 ST_MAX_TAPE_ENTRIES); 4245 ST_MAX_TAPE_ENTRIES);
4249 } 4246 }
4247 class_destroy(st_sysfs_class);
4250 4248
4251 printk(KERN_ERR "Unable to get major %d for SCSI tapes\n", SCSI_TAPE_MAJOR); 4249 printk(KERN_ERR "Unable to get major %d for SCSI tapes\n", SCSI_TAPE_MAJOR);
4252 return 1; 4250 return 1;
@@ -4254,13 +4252,11 @@ static int __init init_st(void)
4254 4252
4255static void __exit exit_st(void) 4253static void __exit exit_st(void)
4256{ 4254{
4257 if (st_sysfs_class)
4258 class_destroy(st_sysfs_class);
4259 st_sysfs_class = NULL;
4260 do_remove_driverfs_files(); 4255 do_remove_driverfs_files();
4261 scsi_unregister_driver(&st_template.gendrv); 4256 scsi_unregister_driver(&st_template.gendrv);
4262 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0), 4257 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
4263 ST_MAX_TAPE_ENTRIES); 4258 ST_MAX_TAPE_ENTRIES);
4259 class_destroy(st_sysfs_class);
4264 kfree(scsi_tapes); 4260 kfree(scsi_tapes);
4265 printk(KERN_INFO "st: Unloaded.\n"); 4261 printk(KERN_INFO "st: Unloaded.\n");
4266} 4262}