diff -urpNX build-tools/dontdiff linux-2.5.75/drivers/scsi/sym53c8xx_2/sym_glue.c linux-2.5.75-willy/drivers/scsi/sym53c8xx_2/sym_glue.c
--- linux-2.5.75/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-07-10 14:15:45.000000000 -0600
+++ linux-2.5.75-willy/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-07-16 14:34:47.000000000 -0600
@@ -57,35 +57,6 @@
 #define NAME53C		"sym53c"
 #define NAME53C8XX	"sym53c8xx"
 
-/*
- *  Simple Wrapper to kernel PCI bus interface.
- */
-
-typedef struct pci_dev *pcidev_t;
-#define PCIDEV_NULL		(0)
-#define PciBusNumber(d)		(d)->bus->number
-#define PciDeviceFn(d)		(d)->devfn
-#define PciVendorId(d)		(d)->vendor
-#define PciDeviceId(d)		(d)->device
-#define PciIrqLine(d)		(d)->irq
-
-static u_long __init
-pci_get_base_cookie(struct pci_dev *pdev, int index)
-{
-	u_long base;
-
-#if LINUX_VERSION_CODE > LinuxVersionCode(2,3,12)
-	base = pdev->resource[index].start;
-#else
-	base = pdev->base_address[index];
-#if BITS_PER_LONG > 32
-	if ((base & 0x7) == 0x4)
-		base |= (((u_long)pdev->base_address[++index]) << 32);
-#endif
-#endif
-	return (base & ~0x7ul);
-}
-
 static int __init
 pci_get_base_address(struct pci_dev *pdev, int index, u_long *base)
 {
@@ -95,7 +66,7 @@ pci_get_base_address(struct pci_dev *pde
 	pci_read_config_dword(pdev, PCI_BAR_OFFSET(index), &tmp);
 	*base = tmp;
 	++index;
-	if ((tmp & 0x7) == 0x4) {
+	if ((tmp & 0x7) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
 #if BITS_PER_LONG > 32
 		pci_read_config_dword(pdev, PCI_BAR_OFFSET(index), &tmp);
 		*base |= (((u_long)tmp) << 32);
@@ -106,14 +77,6 @@ pci_get_base_address(struct pci_dev *pde
 #undef PCI_BAR_OFFSET
 }
 
-#if LINUX_VERSION_CODE  < LinuxVersionCode(2,4,0)
-#define pci_enable_device(pdev)		(0)
-#endif
-
-#if LINUX_VERSION_CODE  < LinuxVersionCode(2,4,4)
-#define scsi_set_pci_device(inst, pdev)	do { ;} while (0)
-#endif
-
 /*
  *  Insert a delay in micro-seconds and milli-seconds.
  */
@@ -235,53 +198,8 @@ static void __init pci_unmap_mem(u_long 
  */
 static struct Scsi_Host	*first_host = NULL;
 
-/*
- *  /proc directory entry and proc_info.
- */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-static struct proc_dir_entry proc_scsi_sym53c8xx = {
-    PROC_SCSI_SYM53C8XX, 9, NAME53C8XX,
-    S_IFDIR | S_IRUGO | S_IXUGO, 2
-};
-#endif
-
-/*
- *  Transfer direction
- *
- *  Until some linux kernel version near 2.3.40, low-level scsi 
- *  drivers were not told about data transfer direction.
- */
-#if LINUX_VERSION_CODE > LinuxVersionCode(2, 3, 40)
-
 #define scsi_data_direction(cmd)	(cmd->sc_data_direction)
 
-#else
-
-static __inline__ int scsi_data_direction(Scsi_Cmnd *cmd)
-{
-	int direction;
-
-	switch((int) cmd->cmnd[0]) {
-	case 0x08:  /*	READ(6)				08 */
-	case 0x28:  /*	READ(10)			28 */
-	case 0xA8:  /*	READ(12)			A8 */
-		direction = SCSI_DATA_READ;
-		break;
-	case 0x0A:  /*	WRITE(6)			0A */
-	case 0x2A:  /*	WRITE(10)			2A */
-	case 0xAA:  /*	WRITE(12)			AA */
-		direction = SCSI_DATA_WRITE;
-		break;
-	default:
-		direction = SCSI_DATA_UNKNOWN;
-		break;
-	}
-
-	return direction;
-}
-
-#endif
-
 /*
  *  Driver host data structure.
  */
@@ -305,7 +223,7 @@ typedef dma_addr_t	bus_addr_t;
 struct sym_eh_wait {
 	struct semaphore sem;
 	struct timer_list timer;
-	void (*old_done)(Scsi_Cmnd *);
+	void (*old_done)(struct scsi_cmnd *);
 	int to_do;
 	int timed_out;
 };
@@ -325,7 +243,7 @@ struct sym_ucmd {		/* Override the SCSI 
 typedef struct sym_ucmd *ucmd_p;
 
 #define SYM_UCMD_PTR(cmd)  ((ucmd_p)(&(cmd)->SCp))
-#define SYM_SCMD_PTR(ucmd) sym_que_entry(ucmd, Scsi_Cmnd, SCp)
+#define SYM_SCMD_PTR(ucmd) sym_que_entry(ucmd, struct scsi_cmnd, SCp)
 #define SYM_SOFTC_PTR(cmd) (((struct host_data *)cmd->device->host->hostdata)->ncb)
 
 /*
@@ -367,7 +285,7 @@ typedef struct sym_ucmd *ucmd_p;
 #define bus_sg_dma_address(sc)	sg_dma_address(sc)
 #define bus_sg_dma_len(sc)	sg_dma_len(sc)
 
-static void __unmap_scsi_data(pcidev_t pdev, Scsi_Cmnd *cmd)
+static void __unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
 
@@ -383,7 +301,7 @@ static void __unmap_scsi_data(pcidev_t p
 	SYM_UCMD_PTR(cmd)->data_mapped = 0;
 }
 
-static bus_addr_t __map_scsi_single_data(pcidev_t pdev, Scsi_Cmnd *cmd)
+static bus_addr_t __map_scsi_single_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	bus_addr_t mapping;
 	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
@@ -398,7 +316,7 @@ static bus_addr_t __map_scsi_single_data
 	return mapping;
 }
 
-static int __map_scsi_sg_data(pcidev_t pdev, Scsi_Cmnd *cmd)
+static int __map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	int use_sg;
 	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
@@ -412,7 +330,7 @@ static int __map_scsi_sg_data(pcidev_t p
 	return use_sg;
 }
 
-static void __sync_scsi_data(pcidev_t pdev, Scsi_Cmnd *cmd)
+static void __sync_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
 
@@ -441,14 +359,14 @@ static void __sync_scsi_data(pcidev_t pd
 /*
  *  Complete a pending CAM CCB.
  */
-void sym_xpt_done(hcb_p np, Scsi_Cmnd *ccb)
+void sym_xpt_done(hcb_p np, struct scsi_cmnd *ccb)
 {
 	sym_remque(&SYM_UCMD_PTR(ccb)->link_cmdq);
 	unmap_scsi_data(np, ccb);
 	ccb->scsi_done(ccb);
 }
 
-void sym_xpt_done2(hcb_p np, Scsi_Cmnd *ccb, int cam_status)
+void sym_xpt_done2(hcb_p np, struct scsi_cmnd *ccb, int cam_status)
 {
 	sym_set_cam_status(ccb, cam_status);
 	sym_xpt_done(np, ccb);
@@ -460,7 +378,7 @@ void sym_xpt_done2(hcb_p np, Scsi_Cmnd *
  */
 void sym_print_addr (ccb_p cp)
 {
-	Scsi_Cmnd *cmd = cp->cam_ccb;
+	struct scsi_cmnd *cmd = cp->cam_ccb;
 	if (cmd)
 		printf("%s:%d:%d:", sym_name(SYM_SOFTC_PTR(cmd)),
 		       cmd->device->id,cmd->device->lun);
@@ -521,7 +439,7 @@ static int sym_xerr_cam_status(int cam_s
  */
 void sym_set_cam_result_error(hcb_p np, ccb_p cp, int resid)
 {
-	Scsi_Cmnd *csio = cp->cam_ccb;
+	struct scsi_cmnd *csio = cp->cam_ccb;
 	u_int cam_status, scsi_status, drv_status;
 
 	drv_status  = 0;
@@ -581,9 +499,7 @@ void sym_set_cam_result_error(hcb_p np, 
 		 */
 		cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status);
 	}
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,99)
 	csio->resid = resid;
-#endif
 	csio->result = (drv_status << 24) + (cam_status << 16) + scsi_status;
 }
 
@@ -591,7 +507,7 @@ void sym_set_cam_result_error(hcb_p np, 
 /*
  *  Called on successfull INQUIRY response.
  */
-void sym_sniff_inquiry(hcb_p np, Scsi_Cmnd *cmd, int resid)
+void sym_sniff_inquiry(hcb_p np, struct scsi_cmnd *cmd, int resid)
 {
 	int retv;
 
@@ -612,7 +528,7 @@ void sym_sniff_inquiry(hcb_p np, Scsi_Cm
  *  Build the scatter/gather array for an I/O.
  */
 
-static int sym_scatter_no_sglist(hcb_p np, ccb_p cp, Scsi_Cmnd *cmd)
+static int sym_scatter_no_sglist(hcb_p np, ccb_p cp, struct scsi_cmnd *cmd)
 {
 	struct sym_tblmove *data = &cp->phys.data[SYM_CONF_MAX_SG-1];
 	int segment;
@@ -634,7 +550,7 @@ static int sym_scatter_no_sglist(hcb_p n
 	return segment;
 }
 
-static int sym_scatter(hcb_p np, ccb_p cp, Scsi_Cmnd *cmd)
+static int sym_scatter(hcb_p np, ccb_p cp, struct scsi_cmnd *cmd)
 {
 	int segment;
 	int use_sg = (int) cmd->use_sg;
@@ -671,9 +587,9 @@ static int sym_scatter(hcb_p np, ccb_p c
 /*
  *  Queue a SCSI command.
  */
-static int sym_queue_command(hcb_p np, Scsi_Cmnd *ccb)
+static int sym_queue_command(hcb_p np, struct scsi_cmnd *ccb)
 {
-/*	Scsi_Device        *device    = ccb->device; */
+/*	struct scsi_device        *device    = ccb->device; */
 	tcb_p	tp;
 	lcb_p	lp;
 	ccb_p	cp;
@@ -736,7 +652,7 @@ static int sym_queue_command(hcb_p np, S
 /*
  *  Setup buffers and pointers that address the CDB.
  */
-static int __inline sym_setup_cdb(hcb_p np, Scsi_Cmnd *ccb, ccb_p cp)
+static int __inline sym_setup_cdb(hcb_p np, struct scsi_cmnd *ccb, ccb_p cp)
 {
 	u32	cmd_ba;
 	int	cmd_len;
@@ -762,7 +678,7 @@ static int __inline sym_setup_cdb(hcb_p 
 /*
  *  Setup pointers that address the data and start the I/O.
  */
-int sym_setup_data_and_start(hcb_p np, Scsi_Cmnd *csio, ccb_p cp)
+int sym_setup_data_and_start(hcb_p np, struct scsi_cmnd *csio, ccb_p cp)
 {
 	int dir;
 	tcb_p tp = &np->target[cp->target];
@@ -841,20 +757,6 @@ static void sym_timer (hcb_p np)
 {
 	u_long	thistime = ktime_get(0);
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2, 4, 0)
-	/*
-	 *  If release process in progress, let's go
-	 *  Set the release stage from 1 to 2 to synchronize
-	 *  with the release process.
-	 */
-
-	if (np->s.release_stage) {
-		if (np->s.release_stage == 1)
-			np->s.release_stage = 2;
-		return;
-	}
-#endif
-
 	/*
 	 *  Restart the timer.
 	 */
@@ -933,7 +835,7 @@ void sym_log_bus_error(hcb_p np)
  */
 static void sym_requeue_awaiting_cmds(hcb_p np)
 {
-	Scsi_Cmnd *cmd;
+	struct scsi_cmnd *cmd;
 	ucmd_p ucp = SYM_UCMD_PTR(cmd);
 	SYM_QUEHEAD tmp_cmdq;
 	int sts;
@@ -954,7 +856,7 @@ static void sym_requeue_awaiting_cmds(hc
 /*
  *  Linux entry point of the queuecommand() function
  */
-int sym53c8xx_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
+int sym53c8xx_queue_command (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 {
 	hcb_p  np  = SYM_SOFTC_PTR(cmd);
 	ucmd_p ucp = SYM_UCMD_PTR(cmd);
@@ -1066,7 +968,7 @@ static void sym53c8xx_timer(unsigned lon
 /*
  *  Our general completion handler.
  */
-static void __sym_eh_done(Scsi_Cmnd *cmd, int timed_out)
+static void __sym_eh_done(struct scsi_cmnd *cmd, int timed_out)
 {
 	struct sym_eh_wait *ep = SYM_UCMD_PTR(cmd)->eh_wait;
 	if (!ep)
@@ -1091,18 +993,18 @@ static void __sym_eh_done(Scsi_Cmnd *cmd
 /*
  *  scsi_done() alias when error recovery is in progress. 
  */
-static void sym_eh_done(Scsi_Cmnd *cmd) { __sym_eh_done(cmd, 0); }
+static void sym_eh_done(struct scsi_cmnd *cmd) { __sym_eh_done(cmd, 0); }
 
 /*
  *  Some timeout handler to avoid waiting too long.
  */
-static void sym_eh_timeout(u_long p) { __sym_eh_done((Scsi_Cmnd *)p, 1); }
+static void sym_eh_timeout(u_long p) { __sym_eh_done((struct scsi_cmnd *)p, 1); }
 
 /*
  *  Generic method for our eh processing.
  *  The 'op' argument tells what we have to do.
  */
-static int sym_eh_handler(int op, char *opname, Scsi_Cmnd *cmd)
+static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
 {
 	hcb_p np = SYM_SOFTC_PTR(cmd);
 	SYM_QUEHEAD *qp;
@@ -1146,11 +1048,7 @@ prepare:
 		goto finish;
 		break;
 	case SYM_EH_DO_WAIT:
-#if LINUX_VERSION_CODE > LinuxVersionCode(2,3,0)
 		init_MUTEX_LOCKED(&ep->sem);
-#else
-		ep->sem = MUTEX_LOCKED;
-#endif
 		/* fall through */
 	case SYM_EH_DO_COMPLETE:
 		ep->old_done = cmd->scsi_done;
@@ -1214,22 +1112,22 @@ finish:
 /*
  * Error handlers called from the eh thread (one thread per HBA).
  */
-int sym53c8xx_eh_abort_handler(Scsi_Cmnd *cmd)
+int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
 {
 	return sym_eh_handler(SYM_EH_ABORT, "ABORT", cmd);
 }
 
-int sym53c8xx_eh_device_reset_handler(Scsi_Cmnd *cmd)
+int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd)
 {
 	return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd);
 }
 
-int sym53c8xx_eh_bus_reset_handler(Scsi_Cmnd *cmd)
+int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 {
 	return sym_eh_handler(SYM_EH_BUS_RESET, "BUS RESET", cmd);
 }
 
-int sym53c8xx_eh_host_reset_handler(Scsi_Cmnd *cmd)
+int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd)
 {
 	return sym_eh_handler(SYM_EH_HOST_RESET, "HOST RESET", cmd);
 }
@@ -1326,7 +1224,7 @@ static int device_queue_depth(hcb_p np, 
  * Linux entry point for device queue sizing.
  */
 int
-sym53c8xx_slave_configure(Scsi_Device *device)
+sym53c8xx_slave_configure(struct scsi_device *device)
 {
 	struct Scsi_Host *host = device->host;
 	hcb_p np;
@@ -1848,10 +1746,6 @@ static void sym_free_resources(hcb_p np)
 #ifdef SYM_LINUX_DYNAMIC_DMA_MAPPING
 static int sym_setup_bus_dma_mask(hcb_p np)
 {
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,3)
-	if (!pci_dma_supported(np->s.device, 0xffffffffUL))
-		goto out_err32;
-#else
 #if   SYM_CONF_DMA_ADDRESSING_MODE == 0
 	if (pci_set_dma_mask(np->s.device, 0xffffffffUL))
 		goto out_err32;
@@ -1874,7 +1768,6 @@ static int sym_setup_bus_dma_mask(hcb_p 
 	}
 #undef	PciDmaMask
 #endif
-#endif
 	return 0;
 
 out_err32:
@@ -1894,7 +1787,7 @@ out_err32:
  *  start the timer daemon.
  */
 static int __init 
-sym_attach (Scsi_Host_Template *tpnt, int unit, sym_device *dev)
+sym_attach (struct scsi_host_template *tpnt, int unit, sym_device *dev)
 {
         struct host_data *host_data;
 	hcb_p np = 0;
@@ -1929,7 +1822,7 @@ sym_attach (Scsi_Host_Template *tpnt, in
 	/*
 	 *	Allocate host_data structure
 	 */
-        if (!(instance = scsi_register(tpnt, sizeof(*host_data))))
+        if (!(instance = scsi_host_alloc(tpnt, sizeof(*host_data))))
 	        goto attach_failed;
 	host_data = (struct host_data *) instance->hostdata;
 
@@ -1955,6 +1848,8 @@ sym_attach (Scsi_Host_Template *tpnt, in
 	host_data->ncb = np;
 	np->s.host = instance;
 
+	pci_set_drvdata(dev->pdev, np);
+
 	SYM_INIT_LOCK_HCB(np);
 
 	/*
@@ -2101,11 +1996,7 @@ sym_attach (Scsi_Host_Template *tpnt, in
 	instance->max_id	= np->maxwide ? 16 : 8;
 	instance->max_lun	= SYM_CONF_MAX_LUN;
 #ifndef SYM_CONF_IOMAPPED
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,29)
 	instance->base		= (unsigned long) np->s.mmio_va;
-#else
-	instance->base		= (char *) np->s.mmio_va;
-#endif
 #endif
 	instance->irq		= np->s.irq;
 	instance->unique_id	= np->s.io_port;
@@ -2115,9 +2006,7 @@ sym_attach (Scsi_Host_Template *tpnt, in
 	instance->cmd_per_lun	= SYM_CONF_MAX_TAG;
 	instance->can_queue	= (SYM_CONF_MAX_START-2);
 	instance->sg_tablesize	= SYM_CONF_MAX_SG;
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
 	instance->max_cmd_len	= 16;
-#endif
 	instance->highmem_io	= 1;
 
 	SYM_UNLOCK_HCB(np, flags);
@@ -2128,6 +2017,7 @@ sym_attach (Scsi_Host_Template *tpnt, in
 	 *  Now let the generic SCSI driver
 	 *  look for the SCSI devices on the bus ..
 	 */
+	scsi_add_host(instance, &dev->pdev->dev);
 	return 0;
 
 attach_failed:
@@ -2366,60 +2256,9 @@ int __init sym53c8xx_setup(char *str)
 	return 1;
 }
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,13)
 #ifndef MODULE
 __setup("sym53c8xx=", sym53c8xx_setup);
 #endif
-#endif
-
-#ifdef	SYM_CONF_PQS_PDS_SUPPORT
-/*
- *  Detect all NCR PQS/PDS boards and keep track of their bus nr.
- *
- *  The NCR PQS or PDS card is constructed as a DEC bridge
- *  behind which sit a proprietary NCR memory controller and
- *  four or two 53c875s as separate devices.  In its usual mode
- *  of operation, the 875s are slaved to the memory controller
- *  for all transfers.  We can tell if an 875 is part of a
- *  PQS/PDS or not since if it is, it will be on the same bus
- *  as the memory controller.  To operate with the Linux
- *  driver, the memory controller is disabled and the 875s
- *  freed to function independently.  The only wrinkle is that
- *  the preset SCSI ID (which may be zero) must be read in from
- *  a special configuration space register of the 875
- */
-#ifndef SYM_CONF_MAX_PQS_BUS
-#define SYM_CONF_MAX_PQS_BUS 16
-#endif
-static int pqs_bus[SYM_CONF_MAX_PQS_BUS] __initdata = { 0 };
-
-static void __init sym_detect_pqs_pds(void)
-{
-	short index;
-	pcidev_t dev = PCIDEV_NULL;
-
-	for(index=0; index < SYM_CONF_MAX_PQS_BUS; index++) {
-		u_char tmp;
-
-		dev = pci_find_device(0x101a, 0x0009, dev);
-		if (dev == PCIDEV_NULL) {
-			pqs_bus[index] = -1;
-			break;
-		}
-		printf_info(NAME53C8XX ": NCR PQS/PDS memory controller detected on bus %d\n", PciBusNumber(dev));
-		pci_read_config_byte(dev, 0x44, &tmp);
-		/* bit 1: allow individual 875 configuration */
-		tmp |= 0x2;
-		pci_write_config_byte(dev, 0x44, tmp);
-		pci_read_config_byte(dev, 0x45, &tmp);
-		/* bit 2: drive individual 875 interrupts to the bus */
-		tmp |= 0x4;
-		pci_write_config_byte(dev, 0x45, tmp);
-
-		pqs_bus[index] = PciBusNumber(dev);
-	}
-}
-#endif /* SYM_CONF_PQS_PDS_SUPPORT */
 
 /*
  *  Read and check the PCI configuration for any detected NCR 
@@ -2427,7 +2266,7 @@ static void __init sym_detect_pqs_pds(vo
  *  been detected.
  */
 static int __init
-sym53c8xx_pci_init(Scsi_Host_Template *tpnt, pcidev_t pdev, sym_device *device)
+sym53c8xx_pci_init(struct pci_dev *pdev, sym_device *device)
 {
 	u_short vendor_id, device_id, command, status_reg;
 	u_char cache_line_size;
@@ -2435,34 +2274,30 @@ sym53c8xx_pci_init(Scsi_Host_Template *t
 	u_char pci_fix_up = SYM_SETUP_PCI_FIX_UP;
 	u_char revision;
 	u_int irq;
-	u_long base, base_2, base_io; 
+	u_long base, base_2; 
 	u_long base_c, base_2_c, io_port; 
 	int i;
 	sym_chip *chip;
 
 	/* Choose some short name for this device */
-	sprintf(device->s.inst_name, "sym.%d.%d.%d",
-		PciBusNumber(pdev),
-		(int) (PciDeviceFn(pdev) & 0xf8) >> 3,
-		(int) (PciDeviceFn(pdev) & 7));
+	sprintf(device->s.inst_name, "sym.%d.%d.%d", pdev->bus->number,
+			PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
 
 	/*
 	 *  Read needed minimal info from the PCI config space.
 	 */
-	vendor_id = PciVendorId(pdev);
-	device_id = PciDeviceId(pdev);
-	irq	  = PciIrqLine(pdev);
+	vendor_id = pdev->vendor;
+	device_id = pdev->device;
+	irq	  = pdev->irq;
 
-	i = pci_get_base_address(pdev, 0, &base_io);
-	io_port = pci_get_base_cookie(pdev, 0);
+	io_port = pdev->resource[0].start;
 
-	base_c = pci_get_base_cookie(pdev, i);
-	i = pci_get_base_address(pdev, i, &base);
+	base_c = pdev->resource[1].start;
+	i = pci_get_base_address(pdev, 1, &base);
 
-	base_2_c = pci_get_base_cookie(pdev, i);
-	(void) pci_get_base_address(pdev, i, &base_2);
+	base_2_c = pdev->resource[i].start;
+	pci_get_base_address(pdev, i, &base_2);
 
-	io_port &= PCI_BASE_ADDRESS_IO_MASK;
 	base	&= PCI_BASE_ADDRESS_MEM_MASK;
 	base_2	&= PCI_BASE_ADDRESS_MEM_MASK;
 
@@ -2471,9 +2306,9 @@ sym53c8xx_pci_init(Scsi_Host_Template *t
 	/*
 	 *  If user excluded this chip, donnot initialize it.
 	 */
-	if (base_io) {
+	if (io_port) {
 		for (i = 0 ; i < 8 ; i++) {
-			if (sym_driver_setup.excludes[i] == base_io)
+			if (sym_driver_setup.excludes[i] == io_port)
 				return -1;
 		}
 	}
@@ -2635,8 +2470,8 @@ sym53c8xx_pci_init(Scsi_Host_Template *t
 	 *  Initialise device structure with items required by sym_attach.
 	 */
 	device->pdev		= pdev;
-	device->s.bus		= PciBusNumber(pdev);
-	device->s.device_fn	= PciDeviceFn(pdev);
+	device->s.bus		= pdev->bus->number;
+	device->s.device_fn	= pdev->devfn;
 	device->s.base		= base;
 	device->s.base_2	= base_2;
 	device->s.base_c	= base_c;
@@ -2648,26 +2483,7 @@ sym53c8xx_pci_init(Scsi_Host_Template *t
 	return 0;
 }
 
-/*
- *  List of supported NCR chip ids
- */
-static u_short sym_chip_ids[] __initdata	= {
-	PCI_ID_SYM53C810,
-	PCI_ID_SYM53C815,
-	PCI_ID_SYM53C825,
-	PCI_ID_SYM53C860,
-	PCI_ID_SYM53C875,
-	PCI_ID_SYM53C875_2,
-	PCI_ID_SYM53C885,
-	PCI_ID_SYM53C875A,
-	PCI_ID_SYM53C895,
-	PCI_ID_SYM53C896,
-	PCI_ID_SYM53C895A,
-	PCI_ID_LSI53C1510D,
- 	PCI_ID_LSI53C1010,
- 	PCI_ID_LSI53C1010_2
-};
-
+#if 0
 /*
  *  Detect all 53c8xx hosts and then attach them.
  *
@@ -2678,9 +2494,9 @@ static u_short sym_chip_ids[] __initdata
  *  If no NVRAM is found or data appears invalid attach boards in 
  *  the order they are detected.
  */
-int __init sym53c8xx_detect(Scsi_Host_Template *tpnt)
+int __init sym53c8xx_detect(struct scsi_host_template *tpnt)
 {
-	pcidev_t pcidev;
+	struct pci_dev *pcidev;
 	int i, j, chips, hosts, count;
 	int attach_count = 0;
 	sym_device *devtbl, *devp;
@@ -2732,7 +2548,7 @@ if (sym53c8xx)
 #endif
 	j = 0;
 	count = 0;
-	pcidev = PCIDEV_NULL;
+	pcidev = NULL;
 	while (1) {
 		char *msg = "";
 		if (count >= hosts)
@@ -2742,7 +2558,7 @@ if (sym53c8xx)
 		i = sym_driver_setup.reverse_probe ? chips - 1 - j : j;
 		pcidev = pci_find_device(PCI_VENDOR_ID_NCR, sym_chip_ids[i],
 					 pcidev);
-		if (pcidev == PCIDEV_NULL) {
+		if (pcidev == NULL) {
 			++j;
 			continue;
 		}
@@ -2751,8 +2567,7 @@ if (sym53c8xx)
 			continue;
 		devp = &devtbl[count];
 		devp->host_id = SYM_SETUP_HOST_ID;
-		devp->attach_done = 0;
-		if (sym53c8xx_pci_init(tpnt, pcidev, devp)) {
+		if (sym53c8xx_pci_init(pcidev, devp)) {
 			continue;
 		}
 		++count;
@@ -2784,7 +2599,7 @@ if (sym53c8xx)
 		 */
 		for(i = 0; i < SYM_CONF_MAX_PQS_BUS && pqs_bus[i] != -1; i++) {
 			u_char tmp;
-			if (pqs_bus[i] == PciBusNumber(pcidev)) {
+			if (pqs_bus[i] == pcidev->bus->number) {
 				pci_read_config_byte(pcidev, 0x84, &tmp);
 				devp->pqs_pds = 1;
 				devp->host_id = tmp;
@@ -2863,7 +2678,7 @@ next:
 
 	return attach_count;
 }
-
+#endif
 
 
 /*
@@ -2878,32 +2693,7 @@ static int sym_detach(hcb_p np)
 {
 	printk("%s: detaching ...\n", sym_name(np));
 
-	/*
-	 *  Try to delete the timer.
-	 *  In the unlikely situation where this failed,
-	 *  try to synchronize with the timer handler.
-	 */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2, 4, 0)
-	np->s.release_stage = 1;
-	if (!del_timer(&np->s.timer)) {
-		int i = 1000;
-		int k = 1;
-		while (1) {
-			u_long flags;
-			SYM_LOCK_HCB(np, flags);
-			k = np->s.release_stage;
-			SYM_UNLOCK_HCB(np, flags);
-			if (k == 2 || !--i)
-				break;
-			MDELAY(5);
-		}
-		if (!i)
-			printk("%s: failed to kill timer!\n", sym_name(np));
-	}
-	np->s.release_stage = 2;
-#else
-	(void)del_timer_sync(&np->s.timer);
-#endif
+	del_timer_sync(&np->s.timer);
 
 	/*
 	 *  Reset NCR chip.
@@ -2923,27 +2713,26 @@ static int sym_detach(hcb_p np)
 	return 1;
 }
 
+#if 0
 int sym53c8xx_release(struct Scsi_Host *host)
 {
      sym_detach(((struct host_data *) host->hostdata)->ncb);
 
      return 0;
 }
+#endif
 
-/*
- * For bigots to keep silent. :)
- */
-#ifdef MODULE_LICENSE
 MODULE_LICENSE("Dual BSD/GPL");
-#endif
 
 /*
  * Driver host template.
  */
-static Scsi_Host_Template driver_template = {
+static struct scsi_host_template sym2_template = {
 	.name			= "sym53c8xx",
+#if 0
 	.detect			= sym53c8xx_detect,
 	.release		= sym53c8xx_release,
+#endif
 	.info			= sym53c8xx_info, 
 	.queuecommand		= sym53c8xx_queue_command,
 	.slave_configure	= sym53c8xx_slave_configure,
@@ -2956,11 +2745,176 @@ static Scsi_Host_Template driver_templat
 	.highmem_io		= 1,
 #ifdef SYM_LINUX_PROC_INFO_SUPPORT
 	.proc_info		= sym53c8xx_proc_info,
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-	.proc_dir		= &proc_scsi_sym53c8xx,
-#else
 	.proc_name		= NAME53C8XX,
 #endif
+};
+
+#ifdef _SYM_CONF_PQS_PDS_SUPPORT
+#if 0
+/*
+ *  Detect all NCR PQS/PDS boards and keep track of their bus nr.
+ *
+ *  The NCR PQS or PDS card is constructed as a DEC bridge
+ *  behind which sit a proprietary NCR memory controller and
+ *  four or two 53c875s as separate devices.  In its usual mode
+ *  of operation, the 875s are slaved to the memory controller
+ *  for all transfers.  We can tell if an 875 is part of a
+ *  PQS/PDS or not since if it is, it will be on the same bus
+ *  as the memory controller.  To operate with the Linux
+ *  driver, the memory controller is disabled and the 875s
+ *  freed to function independently.  The only wrinkle is that
+ *  the preset SCSI ID (which may be zero) must be read in from
+ *  a special configuration space register of the 875
+ */
+#ifndef SYM_CONF_MAX_PQS_BUS
+#define SYM_CONF_MAX_PQS_BUS 16
 #endif
+static int pqs_bus[SYM_CONF_MAX_PQS_BUS] __initdata = { 0 };
+
+static void __init sym_detect_pqs_pds(void)
+{
+	short index;
+	struct pci_dev *dev = NULL;
+
+	for(index=0; index < SYM_CONF_MAX_PQS_BUS; index++) {
+		u_char tmp;
+
+		dev = pci_find_device(0x101a, 0x0009, dev);
+		if (dev == NULL) {
+			pqs_bus[index] = -1;
+			break;
+		}
+		printf_info(NAME53C8XX ": NCR PQS/PDS memory controller detected on bus %d\n", dev->bus->number);
+		pci_read_config_byte(dev, 0x44, &tmp);
+		/* bit 1: allow individual 875 configuration */
+		tmp |= 0x2;
+		pci_write_config_byte(dev, 0x44, tmp);
+		pci_read_config_byte(dev, 0x45, &tmp);
+		/* bit 2: drive individual 875 interrupts to the bus */
+		tmp |= 0x4;
+		pci_write_config_byte(dev, 0x45, tmp);
+
+		pqs_bus[index] = dev->bus->number;
+	}
+}
+#endif
+
+static int pqs_probe()
+{
+}
+
+static void pqs_remove()
+{
+}
+
+static struct pci_device_id pqs_id_table[] __devinitdata = {
+	{ 0x101a, 0x0009, },
 };
-#include "../scsi_module.c"
+
+MODULE_DEVICE_TABLE(pci, pqs_id_table);
+
+static struct pci_driver pqs_driver = {
+	.name		= NAME53C8XX " (PQS)",
+	.id_table	= pqs_id_table,
+	.probe		= pqs_probe,
+	.remove		= __devexit_p(pqs_remove),
+};
+#endif /* PQS */
+
+static int attach_count;
+
+static int __devinit sym2_probe(struct pci_dev *pdev,
+				const struct pci_device_id *ent)
+{
+	sym_device sym_dev;
+	sym_nvram nvram;
+
+	sym_dev.host_id = SYM_SETUP_HOST_ID;
+	if (sym53c8xx_pci_init(pdev, &sym_dev))
+		return -ENODEV;
+	printk(KERN_INFO "%s: 53c%s detected\n", sym_name(&sym_dev), sym_dev.chip.name);
+
+	sym_dev.nvram = &nvram;
+	nvram.type = 0;
+#if SYM_CONF_NVRAM_SUPPORT
+	sym_get_nvram(&sym_dev, &nvram);
+#endif
+
+	if (sym_attach(&sym2_template, attach_count, &sym_dev))
+		return -ENODEV;
+
+	attach_count++;
+	return 0;
+}
+
+static void __devexit sym2_remove(struct pci_dev *pdev)
+{
+	sym_detach(pci_get_drvdata(pdev));
+	attach_count--;
+}
+
+static struct pci_device_id sym2_id_table[] __devinitdata = {
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C810,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C820,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, /* new */
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C825,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C815,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C810AP,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, /* new */
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C860,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1510,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C896,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C895,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C885,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C875,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C1510,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, /* new */
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C895A,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C875A,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1010_33,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1010_66,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C875J,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+};
+
+MODULE_DEVICE_TABLE(pci, sym2_id_table);
+
+static struct pci_driver sym2_driver = {
+	.name		= NAME53C8XX,
+	.id_table	= sym2_id_table,
+	.probe		= sym2_probe,
+	.remove		= __devexit_p(sym2_remove),
+};
+
+static int __init sym2_init(void)
+{
+#ifdef _SYM_CONF_PQS_PDS_SUPPORT
+	pci_register_driver(&pqs_driver);
+#endif
+	pci_register_driver(&sym2_driver);
+	return 0;
+}
+
+static void __exit sym2_exit(void)
+{
+	pci_unregister_driver(&sym2_driver);
+#ifdef _SYM_CONF_PQS_PDS_SUPPORT
+	pci_unregister_driver(&pqs_driver);
+#endif
+}
+
+module_init(sym2_init);
+module_exit(sym2_exit);
diff -urpNX build-tools/dontdiff linux-2.5.75/drivers/scsi/sym53c8xx_2/sym_glue.h linux-2.5.75-willy/drivers/scsi/sym53c8xx_2/sym_glue.h
--- linux-2.5.75/drivers/scsi/sym53c8xx_2/sym_glue.h	2003-07-10 14:15:35.000000000 -0600
+++ linux-2.5.75-willy/drivers/scsi/sym53c8xx_2/sym_glue.h	2003-07-15 15:12:35.000000000 -0600
@@ -57,20 +57,10 @@
 #define SYM_CONF_DMA_ADDRESSING_MODE 2
 #endif
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-#include <linux/version.h>
-#if	LINUX_VERSION_CODE < LinuxVersionCode(2, 2, 0)
-#error	"This driver requires a kernel version not lower than 2.2.0"
-#endif
-
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
 #include <linux/spinlock.h>
-#else
-#include <asm/spinlock.h>
-#endif
 #include <linux/delay.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
@@ -91,29 +81,11 @@
 #endif
 #include <linux/init.h>
 
-#ifndef	__init
-#define	__init
-#endif
-#ifndef	__initdata
-#define	__initdata
-#endif
-
 #include "../scsi.h"
 #include "../hosts.h"
 
 #include <linux/types.h>
 
-/*
- *  Define BITS_PER_LONG for earlier linux versions.
- */
-#ifndef	BITS_PER_LONG
-#if (~0UL) == 0xffffffffUL
-#define	BITS_PER_LONG	32
-#else
-#define	BITS_PER_LONG	64
-#endif
-#endif
-
 typedef	u_long	vm_offset_t;
 
 #ifndef bcopy
@@ -139,9 +111,7 @@ typedef	u_long	vm_offset_t;
 /*
  * Configuration addendum for Linux.
  */
-#if	LINUX_VERSION_CODE >= LinuxVersionCode(2,3,47)
 #define	SYM_LINUX_DYNAMIC_DMA_MAPPING
-#endif
 
 #define	SYM_CONF_TIMER_INTERVAL		((HZ+1)/2)
 
@@ -472,9 +442,6 @@ struct sym_shcb {
 	u_long		lasttime;
 	u_long		settle_time;	/* Resetting the SCSI BUS	*/
 	u_char		settle_time_valid;
-#if LINUX_VERSION_CODE < LinuxVersionCode(2, 4, 0)
-	u_char		release_stage;	/* Synchronisation on release	*/
-#endif
 };
 
 /*
@@ -647,9 +614,7 @@ static __inline void sym_set_cam_result_
 {
 	Scsi_Cmnd *cmd = cp->cam_ccb;
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,99)
 	cmd->resid = resid;
-#endif
 	cmd->result = (((DID_OK) << 16) + ((cp->ssss_status) & 0x7f));
 }
 void sym_set_cam_result_error(hcb_p np, ccb_p cp, int resid);
