aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/nsp32.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-15 19:51:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-15 19:51:54 -0400
commitbc06cffdec85d487c77109dffcd2f285bdc502d3 (patch)
treeadc6e6398243da87e66c56102840597a329183a0 /drivers/scsi/nsp32.c
parentd3502d7f25b22cfc9762bf1781faa9db1bb3be2e (diff)
parent9413d7b8aa777dd1fc7db9563ce5e80d769fe7b5 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (166 commits) [SCSI] ibmvscsi: convert to use the data buffer accessors [SCSI] dc395x: convert to use the data buffer accessors [SCSI] ncr53c8xx: convert to use the data buffer accessors [SCSI] sym53c8xx: convert to use the data buffer accessors [SCSI] ppa: coding police and printk levels [SCSI] aic7xxx_old: remove redundant GFP_ATOMIC from kmalloc [SCSI] i2o: remove redundant GFP_ATOMIC from kmalloc from device.c [SCSI] remove the dead CYBERSTORMIII_SCSI option [SCSI] don't build scsi_dma_{map,unmap} for !HAS_DMA [SCSI] Clean up scsi_add_lun a bit [SCSI] 53c700: Remove printk, which triggers because of low scsi clock on SNI RMs [SCSI] sni_53c710: Cleanup [SCSI] qla4xxx: Fix underrun/overrun conditions [SCSI] megaraid_mbox: use mutex instead of semaphore [SCSI] aacraid: add 51245, 51645 and 52245 adapters to documentation. [SCSI] qla2xxx: update version to 8.02.00-k1. [SCSI] qla2xxx: add support for NPIV [SCSI] stex: use resid for xfer len information [SCSI] Add Brownie 1200U3P to blacklist [SCSI] scsi.c: convert to use the data buffer accessors ...
Diffstat (limited to 'drivers/scsi/nsp32.c')
-rw-r--r--drivers/scsi/nsp32.c194
1 files changed, 37 insertions, 157 deletions
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 3e9765f0281d..7fed35372150 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -49,10 +49,6 @@
49#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
50#include <scsi/scsi_ioctl.h> 50#include <scsi/scsi_ioctl.h>
51 51
52#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
53# include <linux/blk.h>
54#endif
55
56#include "nsp32.h" 52#include "nsp32.h"
57 53
58 54
@@ -199,17 +195,9 @@ static int __init init_nsp32 (void);
199static void __exit exit_nsp32 (void); 195static void __exit exit_nsp32 (void);
200 196
201/* struct struct scsi_host_template */ 197/* struct struct scsi_host_template */
202#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
203static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); 198static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int);
204#else
205static int nsp32_proc_info (char *, char **, off_t, int, int, int);
206#endif
207 199
208#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
209static int nsp32_detect (struct pci_dev *pdev); 200static int nsp32_detect (struct pci_dev *pdev);
210#else
211static int nsp32_detect (struct scsi_host_template *);
212#endif
213static int nsp32_queuecommand(struct scsi_cmnd *, 201static int nsp32_queuecommand(struct scsi_cmnd *,
214 void (*done)(struct scsi_cmnd *)); 202 void (*done)(struct scsi_cmnd *));
215static const char *nsp32_info (struct Scsi_Host *); 203static const char *nsp32_info (struct Scsi_Host *);
@@ -296,15 +284,7 @@ static struct scsi_host_template nsp32_template = {
296 .eh_abort_handler = nsp32_eh_abort, 284 .eh_abort_handler = nsp32_eh_abort,
297 .eh_bus_reset_handler = nsp32_eh_bus_reset, 285 .eh_bus_reset_handler = nsp32_eh_bus_reset,
298 .eh_host_reset_handler = nsp32_eh_host_reset, 286 .eh_host_reset_handler = nsp32_eh_host_reset,
299#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74))
300 .detect = nsp32_detect,
301 .release = nsp32_release,
302#endif
303#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,2))
304 .use_new_eh_code = 1,
305#else
306/* .highmem_io = 1, */ 287/* .highmem_io = 1, */
307#endif
308}; 288};
309 289
310#include "nsp32_io.h" 290#include "nsp32_io.h"
@@ -739,7 +719,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt)
739 command = 0; 719 command = 0;
740 command |= (TRANSFER_GO | ALL_COUNTER_CLR); 720 command |= (TRANSFER_GO | ALL_COUNTER_CLR);
741 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { 721 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) {
742 if (SCpnt->request_bufflen > 0) { 722 if (scsi_bufflen(SCpnt) > 0) {
743 command |= BM_START; 723 command |= BM_START;
744 } 724 }
745 } else if (data->trans_method & NSP32_TRANSFER_MMIO) { 725 } else if (data->trans_method & NSP32_TRANSFER_MMIO) {
@@ -888,31 +868,28 @@ static int nsp32_reselection(struct scsi_cmnd *SCpnt, unsigned char newlun)
888static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) 868static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt)
889{ 869{
890 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 870 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
891 struct scatterlist *sgl; 871 struct scatterlist *sg;
892 nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; 872 nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt;
893 int num, i; 873 int num, i;
894 u32_le l; 874 u32_le l;
895 875
896 if (SCpnt->request_bufflen == 0) {
897 return TRUE;
898 }
899
900 if (sgt == NULL) { 876 if (sgt == NULL) {
901 nsp32_dbg(NSP32_DEBUG_SGLIST, "SGT == null"); 877 nsp32_dbg(NSP32_DEBUG_SGLIST, "SGT == null");
902 return FALSE; 878 return FALSE;
903 } 879 }
904 880
905 if (SCpnt->use_sg) { 881 num = scsi_dma_map(SCpnt);
906 sgl = (struct scatterlist *)SCpnt->request_buffer; 882 if (!num)
907 num = pci_map_sg(data->Pci, sgl, SCpnt->use_sg, 883 return TRUE;
908 SCpnt->sc_data_direction); 884 else if (num < 0)
909 for (i = 0; i < num; i++) { 885 return FALSE;
886 else {
887 scsi_for_each_sg(SCpnt, sg, num, i) {
910 /* 888 /*
911 * Build nsp32_sglist, substitute sg dma addresses. 889 * Build nsp32_sglist, substitute sg dma addresses.
912 */ 890 */
913 sgt[i].addr = cpu_to_le32(sg_dma_address(sgl)); 891 sgt[i].addr = cpu_to_le32(sg_dma_address(sg));
914 sgt[i].len = cpu_to_le32(sg_dma_len(sgl)); 892 sgt[i].len = cpu_to_le32(sg_dma_len(sg));
915 sgl++;
916 893
917 if (le32_to_cpu(sgt[i].len) > 0x10000) { 894 if (le32_to_cpu(sgt[i].len) > 0x10000) {
918 nsp32_msg(KERN_ERR, 895 nsp32_msg(KERN_ERR,
@@ -929,23 +906,6 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt)
929 /* set end mark */ 906 /* set end mark */
930 l = le32_to_cpu(sgt[num-1].len); 907 l = le32_to_cpu(sgt[num-1].len);
931 sgt[num-1].len = cpu_to_le32(l | SGTEND); 908 sgt[num-1].len = cpu_to_le32(l | SGTEND);
932
933 } else {
934 SCpnt->SCp.have_data_in = pci_map_single(data->Pci,
935 SCpnt->request_buffer, SCpnt->request_bufflen,
936 SCpnt->sc_data_direction);
937
938 sgt[0].addr = cpu_to_le32(SCpnt->SCp.have_data_in);
939 sgt[0].len = cpu_to_le32(SCpnt->request_bufflen | SGTEND); /* set end mark */
940
941 if (SCpnt->request_bufflen > 0x10000) {
942 nsp32_msg(KERN_ERR,
943 "can't transfer over 64KB at a time, size=0x%lx", SCpnt->request_bufflen);
944 return FALSE;
945 }
946 nsp32_dbg(NSP32_DEBUG_SGLIST, "single : addr 0x%lx len=0x%lx",
947 le32_to_cpu(sgt[0].addr),
948 le32_to_cpu(sgt[0].len ));
949 } 909 }
950 910
951 return TRUE; 911 return TRUE;
@@ -962,7 +922,7 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
962 "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x " 922 "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x "
963 "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", 923 "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x",
964 SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, 924 SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len,
965 SCpnt->use_sg, SCpnt->request_buffer, SCpnt->request_bufflen); 925 scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt));
966 926
967 if (data->CurrentSC != NULL) { 927 if (data->CurrentSC != NULL) {
968 nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); 928 nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request");
@@ -994,10 +954,10 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
994 data->CurrentSC = SCpnt; 954 data->CurrentSC = SCpnt;
995 SCpnt->SCp.Status = CHECK_CONDITION; 955 SCpnt->SCp.Status = CHECK_CONDITION;
996 SCpnt->SCp.Message = 0; 956 SCpnt->SCp.Message = 0;
997 SCpnt->resid = SCpnt->request_bufflen; 957 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
998 958
999 SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; 959 SCpnt->SCp.ptr = (char *)scsi_sglist(SCpnt);
1000 SCpnt->SCp.this_residual = SCpnt->request_bufflen; 960 SCpnt->SCp.this_residual = scsi_bufflen(SCpnt);
1001 SCpnt->SCp.buffer = NULL; 961 SCpnt->SCp.buffer = NULL;
1002 SCpnt->SCp.buffers_residual = 0; 962 SCpnt->SCp.buffers_residual = 0;
1003 963
@@ -1210,13 +1170,9 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1210 unsigned long flags; 1170 unsigned long flags;
1211 int ret; 1171 int ret;
1212 int handled = 0; 1172 int handled = 0;
1213
1214#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1215 struct Scsi_Host *host = data->Host; 1173 struct Scsi_Host *host = data->Host;
1174
1216 spin_lock_irqsave(host->host_lock, flags); 1175 spin_lock_irqsave(host->host_lock, flags);
1217#else
1218 spin_lock_irqsave(&io_request_lock, flags);
1219#endif
1220 1176
1221 /* 1177 /*
1222 * IRQ check, then enable IRQ mask 1178 * IRQ check, then enable IRQ mask
@@ -1312,7 +1268,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1312 } 1268 }
1313 1269
1314 if ((auto_stat & DATA_IN_PHASE) && 1270 if ((auto_stat & DATA_IN_PHASE) &&
1315 (SCpnt->resid > 0) && 1271 (scsi_get_resid(SCpnt) > 0) &&
1316 ((nsp32_read2(base, FIFO_REST_CNT) & FIFO_REST_MASK) != 0)) { 1272 ((nsp32_read2(base, FIFO_REST_CNT) & FIFO_REST_MASK) != 0)) {
1317 printk( "auto+fifo\n"); 1273 printk( "auto+fifo\n");
1318 //nsp32_pio_read(SCpnt); 1274 //nsp32_pio_read(SCpnt);
@@ -1333,7 +1289,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1333 nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", 1289 nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx",
1334 nsp32_read4(base, SAVED_SACK_CNT)); 1290 nsp32_read4(base, SAVED_SACK_CNT));
1335 1291
1336 SCpnt->resid = 0; /* all data transfered! */ 1292 scsi_set_resid(SCpnt, 0); /* all data transfered! */
1337 } 1293 }
1338 1294
1339 /* 1295 /*
@@ -1480,11 +1436,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1480 nsp32_write2(base, IRQ_CONTROL, 0); 1436 nsp32_write2(base, IRQ_CONTROL, 0);
1481 1437
1482 out2: 1438 out2:
1483#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1484 spin_unlock_irqrestore(host->host_lock, flags); 1439 spin_unlock_irqrestore(host->host_lock, flags);
1485#else
1486 spin_unlock_irqrestore(&io_request_lock, flags);
1487#endif
1488 1440
1489 nsp32_dbg(NSP32_DEBUG_INTR, "exit"); 1441 nsp32_dbg(NSP32_DEBUG_INTR, "exit");
1490 1442
@@ -1499,28 +1451,15 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1499 nsp32_dbg(NSP32_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\ 1451 nsp32_dbg(NSP32_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\
1500 } \ 1452 } \
1501 } while(0) 1453 } while(0)
1502static int nsp32_proc_info( 1454
1503#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 1455static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1504 struct Scsi_Host *host, 1456 off_t offset, int length, int inout)
1505#endif
1506 char *buffer,
1507 char **start,
1508 off_t offset,
1509 int length,
1510#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
1511 int hostno,
1512#endif
1513 int inout)
1514{ 1457{
1515 char *pos = buffer; 1458 char *pos = buffer;
1516 int thislength; 1459 int thislength;
1517 unsigned long flags; 1460 unsigned long flags;
1518 nsp32_hw_data *data; 1461 nsp32_hw_data *data;
1519#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
1520 int hostno; 1462 int hostno;
1521#else
1522 struct Scsi_Host *host;
1523#endif
1524 unsigned int base; 1463 unsigned int base;
1525 unsigned char mode_reg; 1464 unsigned char mode_reg;
1526 int id, speed; 1465 int id, speed;
@@ -1531,15 +1470,7 @@ static int nsp32_proc_info(
1531 return -EINVAL; 1470 return -EINVAL;
1532 } 1471 }
1533 1472
1534#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
1535 hostno = host->host_no; 1473 hostno = host->host_no;
1536#else
1537 /* search this HBA host */
1538 host = scsi_host_hn_get(hostno);
1539 if (host == NULL) {
1540 return -ESRCH;
1541 }
1542#endif
1543 data = (nsp32_hw_data *)host->hostdata; 1474 data = (nsp32_hw_data *)host->hostdata;
1544 base = host->io_port; 1475 base = host->io_port;
1545 1476
@@ -1626,25 +1557,8 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt)
1626 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 1557 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
1627 unsigned int base = SCpnt->device->host->io_port; 1558 unsigned int base = SCpnt->device->host->io_port;
1628 1559
1629 /* 1560 scsi_dma_unmap(SCpnt);
1630 * unmap pci
1631 */
1632 if (SCpnt->request_bufflen == 0) {
1633 goto skip;
1634 }
1635 1561
1636 if (SCpnt->use_sg) {
1637 pci_unmap_sg(data->Pci,
1638 (struct scatterlist *)SCpnt->request_buffer,
1639 SCpnt->use_sg, SCpnt->sc_data_direction);
1640 } else {
1641 pci_unmap_single(data->Pci,
1642 (u32)SCpnt->SCp.have_data_in,
1643 SCpnt->request_bufflen,
1644 SCpnt->sc_data_direction);
1645 }
1646
1647 skip:
1648 /* 1562 /*
1649 * clear TRANSFERCONTROL_BM_START 1563 * clear TRANSFERCONTROL_BM_START
1650 */ 1564 */
@@ -1800,7 +1714,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
1800 SCpnt->SCp.Message = 0; 1714 SCpnt->SCp.Message = 0;
1801 nsp32_dbg(NSP32_DEBUG_BUSFREE, 1715 nsp32_dbg(NSP32_DEBUG_BUSFREE,
1802 "normal end stat=0x%x resid=0x%x\n", 1716 "normal end stat=0x%x resid=0x%x\n",
1803 SCpnt->SCp.Status, SCpnt->resid); 1717 SCpnt->SCp.Status, scsi_get_resid(SCpnt));
1804 SCpnt->result = (DID_OK << 16) | 1718 SCpnt->result = (DID_OK << 16) |
1805 (SCpnt->SCp.Message << 8) | 1719 (SCpnt->SCp.Message << 8) |
1806 (SCpnt->SCp.Status << 0); 1720 (SCpnt->SCp.Status << 0);
@@ -1844,7 +1758,7 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen
1844 unsigned int restlen, sentlen; 1758 unsigned int restlen, sentlen;
1845 u32_le len, addr; 1759 u32_le len, addr;
1846 1760
1847 nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", SCpnt->resid); 1761 nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", scsi_get_resid(SCpnt));
1848 1762
1849 /* adjust saved SACK count with 4 byte start address boundary */ 1763 /* adjust saved SACK count with 4 byte start address boundary */
1850 s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; 1764 s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3;
@@ -1888,12 +1802,12 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen
1888 return; 1802 return;
1889 1803
1890 last: 1804 last:
1891 if (SCpnt->resid < sentlen) { 1805 if (scsi_get_resid(SCpnt) < sentlen) {
1892 nsp32_msg(KERN_ERR, "resid underflow"); 1806 nsp32_msg(KERN_ERR, "resid underflow");
1893 } 1807 }
1894 1808
1895 SCpnt->resid -= sentlen; 1809 scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) - sentlen);
1896 nsp32_dbg(NSP32_DEBUG_SGLIST, "new resid=0x%x", SCpnt->resid); 1810 nsp32_dbg(NSP32_DEBUG_SGLIST, "new resid=0x%x", scsi_get_resid(SCpnt));
1897 1811
1898 /* update hostdata and lun */ 1812 /* update hostdata and lun */
1899 1813
@@ -2022,7 +1936,7 @@ static void nsp32_restart_autoscsi(struct scsi_cmnd *SCpnt, unsigned short comma
2022 transfer = 0; 1936 transfer = 0;
2023 transfer |= (TRANSFER_GO | ALL_COUNTER_CLR); 1937 transfer |= (TRANSFER_GO | ALL_COUNTER_CLR);
2024 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { 1938 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) {
2025 if (SCpnt->request_bufflen > 0) { 1939 if (scsi_bufflen(SCpnt) > 0) {
2026 transfer |= BM_START; 1940 transfer |= BM_START;
2027 } 1941 }
2028 } else if (data->trans_method & NSP32_TRANSFER_MMIO) { 1942 } else if (data->trans_method & NSP32_TRANSFER_MMIO) {
@@ -2674,17 +2588,7 @@ static void nsp32_sack_negate(nsp32_hw_data *data)
2674 * 0x900-0xbff: (map same 0x800-0x8ff I/O port image repeatedly) 2588 * 0x900-0xbff: (map same 0x800-0x8ff I/O port image repeatedly)
2675 * 0xc00-0xfff: CardBus status registers 2589 * 0xc00-0xfff: CardBus status registers
2676 */ 2590 */
2677#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
2678#define DETECT_OK 0
2679#define DETECT_NG 1
2680#define PCIDEV pdev
2681static int nsp32_detect(struct pci_dev *pdev) 2591static int nsp32_detect(struct pci_dev *pdev)
2682#else
2683#define DETECT_OK 1
2684#define DETECT_NG 0
2685#define PCIDEV (data->Pci)
2686static int nsp32_detect(struct scsi_host_template *sht)
2687#endif
2688{ 2592{
2689 struct Scsi_Host *host; /* registered host structure */ 2593 struct Scsi_Host *host; /* registered host structure */
2690 struct resource *res; 2594 struct resource *res;
@@ -2697,11 +2601,7 @@ static int nsp32_detect(struct scsi_host_template *sht)
2697 /* 2601 /*
2698 * register this HBA as SCSI device 2602 * register this HBA as SCSI device
2699 */ 2603 */
2700#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
2701 host = scsi_host_alloc(&nsp32_template, sizeof(nsp32_hw_data)); 2604 host = scsi_host_alloc(&nsp32_template, sizeof(nsp32_hw_data));
2702#else
2703 host = scsi_register(sht, sizeof(nsp32_hw_data));
2704#endif
2705 if (host == NULL) { 2605 if (host == NULL) {
2706 nsp32_msg (KERN_ERR, "failed to scsi register"); 2606 nsp32_msg (KERN_ERR, "failed to scsi register");
2707 goto err; 2607 goto err;
@@ -2719,9 +2619,6 @@ static int nsp32_detect(struct scsi_host_template *sht)
2719 host->unique_id = data->BaseAddress; 2619 host->unique_id = data->BaseAddress;
2720 host->n_io_port = data->NumAddress; 2620 host->n_io_port = data->NumAddress;
2721 host->base = (unsigned long)data->MmioAddress; 2621 host->base = (unsigned long)data->MmioAddress;
2722#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,63))
2723 scsi_set_pci_device(host, PCIDEV);
2724#endif
2725 2622
2726 data->Host = host; 2623 data->Host = host;
2727 spin_lock_init(&(data->Lock)); 2624 spin_lock_init(&(data->Lock));
@@ -2776,7 +2673,7 @@ static int nsp32_detect(struct scsi_host_template *sht)
2776 /* 2673 /*
2777 * setup DMA 2674 * setup DMA
2778 */ 2675 */
2779 if (pci_set_dma_mask(PCIDEV, DMA_32BIT_MASK) != 0) { 2676 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) {
2780 nsp32_msg (KERN_ERR, "failed to set PCI DMA mask"); 2677 nsp32_msg (KERN_ERR, "failed to set PCI DMA mask");
2781 goto scsi_unregister; 2678 goto scsi_unregister;
2782 } 2679 }
@@ -2784,7 +2681,7 @@ static int nsp32_detect(struct scsi_host_template *sht)
2784 /* 2681 /*
2785 * allocate autoparam DMA resource. 2682 * allocate autoparam DMA resource.
2786 */ 2683 */
2787 data->autoparam = pci_alloc_consistent(PCIDEV, sizeof(nsp32_autoparam), &(data->auto_paddr)); 2684 data->autoparam = pci_alloc_consistent(pdev, sizeof(nsp32_autoparam), &(data->auto_paddr));
2788 if (data->autoparam == NULL) { 2685 if (data->autoparam == NULL) {
2789 nsp32_msg(KERN_ERR, "failed to allocate DMA memory"); 2686 nsp32_msg(KERN_ERR, "failed to allocate DMA memory");
2790 goto scsi_unregister; 2687 goto scsi_unregister;
@@ -2793,7 +2690,7 @@ static int nsp32_detect(struct scsi_host_template *sht)
2793 /* 2690 /*
2794 * allocate scatter-gather DMA resource. 2691 * allocate scatter-gather DMA resource.
2795 */ 2692 */
2796 data->sg_list = pci_alloc_consistent(PCIDEV, NSP32_SG_TABLE_SIZE, 2693 data->sg_list = pci_alloc_consistent(pdev, NSP32_SG_TABLE_SIZE,
2797 &(data->sg_paddr)); 2694 &(data->sg_paddr));
2798 if (data->sg_list == NULL) { 2695 if (data->sg_list == NULL) {
2799 nsp32_msg(KERN_ERR, "failed to allocate DMA memory"); 2696 nsp32_msg(KERN_ERR, "failed to allocate DMA memory");
@@ -2883,16 +2780,14 @@ static int nsp32_detect(struct scsi_host_template *sht)
2883 goto free_irq; 2780 goto free_irq;
2884 } 2781 }
2885 2782
2886#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 2783 ret = scsi_add_host(host, &pdev->dev);
2887 ret = scsi_add_host(host, &PCIDEV->dev);
2888 if (ret) { 2784 if (ret) {
2889 nsp32_msg(KERN_ERR, "failed to add scsi host"); 2785 nsp32_msg(KERN_ERR, "failed to add scsi host");
2890 goto free_region; 2786 goto free_region;
2891 } 2787 }
2892 scsi_scan_host(host); 2788 scsi_scan_host(host);
2893#endif 2789 pci_set_drvdata(pdev, host);
2894 pci_set_drvdata(PCIDEV, host); 2790 return 0;
2895 return DETECT_OK;
2896 2791
2897 free_region: 2792 free_region:
2898 release_region(host->io_port, host->n_io_port); 2793 release_region(host->io_port, host->n_io_port);
@@ -2901,22 +2796,19 @@ static int nsp32_detect(struct scsi_host_template *sht)
2901 free_irq(host->irq, data); 2796 free_irq(host->irq, data);
2902 2797
2903 free_sg_list: 2798 free_sg_list:
2904 pci_free_consistent(PCIDEV, NSP32_SG_TABLE_SIZE, 2799 pci_free_consistent(pdev, NSP32_SG_TABLE_SIZE,
2905 data->sg_list, data->sg_paddr); 2800 data->sg_list, data->sg_paddr);
2906 2801
2907 free_autoparam: 2802 free_autoparam:
2908 pci_free_consistent(PCIDEV, sizeof(nsp32_autoparam), 2803 pci_free_consistent(pdev, sizeof(nsp32_autoparam),
2909 data->autoparam, data->auto_paddr); 2804 data->autoparam, data->auto_paddr);
2910 2805
2911 scsi_unregister: 2806 scsi_unregister:
2912 scsi_host_put(host); 2807 scsi_host_put(host);
2913 2808
2914 err: 2809 err:
2915 return DETECT_NG; 2810 return 1;
2916} 2811}
2917#undef DETECT_OK
2918#undef DETECT_NG
2919#undef PCIDEV
2920 2812
2921static int nsp32_release(struct Scsi_Host *host) 2813static int nsp32_release(struct Scsi_Host *host)
2922{ 2814{
@@ -3516,11 +3408,7 @@ static int __devinit nsp32_probe(struct pci_dev *pdev, const struct pci_device_i
3516 3408
3517 pci_set_master(pdev); 3409 pci_set_master(pdev);
3518 3410
3519#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
3520 ret = nsp32_detect(pdev); 3411 ret = nsp32_detect(pdev);
3521#else
3522 ret = scsi_register_host(&nsp32_template);
3523#endif
3524 3412
3525 nsp32_msg(KERN_INFO, "irq: %i mmio: %p+0x%lx slot: %s model: %s", 3413 nsp32_msg(KERN_INFO, "irq: %i mmio: %p+0x%lx slot: %s model: %s",
3526 pdev->irq, 3414 pdev->irq,
@@ -3535,25 +3423,17 @@ static int __devinit nsp32_probe(struct pci_dev *pdev, const struct pci_device_i
3535 3423
3536static void __devexit nsp32_remove(struct pci_dev *pdev) 3424static void __devexit nsp32_remove(struct pci_dev *pdev)
3537{ 3425{
3538#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
3539 struct Scsi_Host *host = pci_get_drvdata(pdev); 3426 struct Scsi_Host *host = pci_get_drvdata(pdev);
3540#endif
3541 3427
3542 nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); 3428 nsp32_dbg(NSP32_DEBUG_REGISTER, "enter");
3543 3429
3544#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
3545 scsi_remove_host(host); 3430 scsi_remove_host(host);
3546 3431
3547 nsp32_release(host); 3432 nsp32_release(host);
3548 3433
3549 scsi_host_put(host); 3434 scsi_host_put(host);
3550#else
3551 scsi_unregister_host(&nsp32_template);
3552#endif
3553} 3435}
3554 3436
3555
3556
3557static struct pci_driver nsp32_driver = { 3437static struct pci_driver nsp32_driver = {
3558 .name = "nsp32", 3438 .name = "nsp32",
3559 .id_table = nsp32_pci_table, 3439 .id_table = nsp32_pci_table,