## Automatically generated incremental diff
## From:   linux-2.5.73-bk8
## To:     linux-2.5.73-bk9
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.5.73-bk8/Documentation/scsi/scsi_mid_low_api.txt linux-2.5.73-bk9/Documentation/scsi/scsi_mid_low_api.txt
--- linux-2.5.73-bk8/Documentation/scsi/scsi_mid_low_api.txt	2003-06-22 11:33:07.000000000 -0700
+++ linux-2.5.73-bk9/Documentation/scsi/scsi_mid_low_api.txt	2003-07-01 04:51:34.000000000 -0700
@@ -22,24 +22,26 @@
 a SCSI host and a PCI device is common but not required (e.g. with
 ISA or MCA adapters).]
 
-This version of the document roughly matches linux kernel version 2.5.68 .
-This document can be found in the Linux kernel source Documentation/scsi
-directory and is called scsi_mid_low_api.txt . A more recent copy may
-be found at http://www.torque.net/scsi/scsi_mid_low_api.txt.gz .
+The SCSI mid level isolates a LLD from other layers such as the SCSI
+upper layer drivers and the block layer.
+
+This version of the document roughly matches linux kernel version 2.5.73 .
 
 Documentation
 =============
-There is a SCSI documentation directory within the kernel source tree.
-That directory is typically /usr/src/linux/Documentation/scsi . Most
-documents are in plain (i.e. ASCII) text. This file can be found in that
-directory, named scsi_mid_low_api.txt . Many LLDs are documented there
-(e.g. aic7xxx.txt). The SCSI mid-level is briefly described in scsi.txt
-(with a url to a document describing the SCSI subsystem in the lk 2.4
-series). Two upper level drivers have documents in that directory:
-st.txt (SCSI tape driver) and scsi-generic.txt (for the sg driver).
+There is a SCSI documentation directory within the kernel source tree, 
+typically /usr/src/linux/Documentation/scsi . Most documents are in plain
+(i.e. ASCII) text. This file is named scsi_mid_low_api.txt and can be 
+found in that directory. A more recent copy of this document may be found
+at http://www.torque.net/scsi/scsi_mid_low_api.txt.gz . 
+Many LLDs are documented there (e.g. aic7xxx.txt). The SCSI mid-level is
+briefly described in scsi.txt which contains a url to a document 
+describing the SCSI subsystem in the lk 2.4 series. Two upper level 
+drivers have documents in that directory: st.txt (SCSI tape driver) and 
+scsi-generic.txt (for the sg driver).
 
-Some documentation (or urls) for LLDs may be in the C source code or
-in the same directory as the C source code. For example to find a url
+Some documentation (or urls) for LLDs may be found in the C source code
+or in the same directory as the C source code. For example to find a url
 about the USB mass storage driver see the 
 /usr/src/linux/drivers/usb/storage directory.
 
@@ -69,12 +71,12 @@
 one, similar to what was found in the lk 2.4 series, is based on hosts
 that are detected at HBA driver load time. This will be referred to
 the "passive" initialization model. The newer model allows HBAs to be
-hotplugged (and unplugged) while the driver is loaded and will be
+hot plugged (and unplugged) during the lifetime of the LLD and will be
 referred to as the "hotplug" initialization model. The newer model is
 preferred as it can handle both traditional SCSI equipment that is
-permanently connected as well as modern "SCSI" usb-storage devices
-(e.g. digital cameras) that are hotplugged. Both initialization models
-are discussed in the following sections.
+permanently connected as well as modern "SCSI" devices (e.g. USB or
+IEEE 1394 connected digital cameras) that are hotplugged. Both 
+initialization models are discussed in the following sections.
 
 A LLD interfaces to the SCSI subsystem several ways:
   a) directly invoking functions supplied by the mid level
@@ -90,21 +92,27 @@
 
 Those functions in group b) are listed in a section entitled "Interface
 functions" below. Their function pointers are placed in the members of
-"struct SHT", an instance of which is passed to scsi_register() [or
-scsi_register_host() in the passive initialization model]. Those interface
-functions that are not mandatory and that the LLD does not wish to supply
-should have NULL placed in the corresponding member of struct SHT.
-[Defining an instance of struct SHT at file scope will cause NULL to be 
-placed in function pointer members not explicitly initialized.]
-
-Those instances in group c) are slowly being removed as they tend to be
-"racy" especially in a hotplug environment.
+"struct scsi_host_template", an instance of which is passed to
+scsi_host_alloc() ** .  Those interface functions that the LLD does not 
+wish to supply should have NULL placed in the corresponding member of 
+struct scsi_host_template.  Defining an instance of struct 
+scsi_host_template at file scope will cause NULL to be  placed in function
+ pointer members not explicitly initialized.
+
+Those usages in group c) should be handled with care, especially in a
+"hotplug" environment. LLDs should be aware of the lifetime of instances
+that are shared with the mid level and other layers.
 
 All functions defined within a LLD and all data defined at file scope
 should be static. For example the slave_alloc() function in a LLD
 called "xxx" could be defined as 
 "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }"
 
+** the scsi_host_alloc() function is a replacement for the rather vaguely
+named scsi_register() function in most situations. The scsi_register()
+and scsi_unregister() functions remain to support legacy LLDs that use
+the passive initialization model.
+
 
 Hotplug initialization model
 ============================
@@ -116,13 +124,6 @@
 to control, the LLD will initialize the HBA and then register a new host
 with the SCSI mid level.
 
-Hot unplugging a HBA that controls a disk which is processing SCSI
-commands on a mounted file system is an ugly situation. Issues with
-this scenario are still being worked through. The primary concern is
-the stability of the kernel (specifically the block and SCSI subsystems)
-since the effected disk can be "cleaned up" the next time it is seen.
-In the sysfs model, a remove() callback indicates a HBA has disappeared.
-
 During LLD initialization the driver should register itself with the
 appropriate IO bus on which it expects to find HBA(s) (e.g. the PCI bus).
 This can probably be done via sysfs. Any driver parameters (especially
@@ -135,145 +136,198 @@
 This example shows the mid level scanning the newly introduced HBA for 3 
 scsi devices of which only the first 2 respond:
 
-[HBA PROBE]
+     HBA PROBE: assume 2 SCSI devices found in scan
 LLD                   mid level                    LLD
----                   ---------                    ---
-scsi_register()  -->
+===-------------------=========--------------------===------
+scsi_host_alloc()  -->
 scsi_add_host()  --------+
                          |
-		    slave_alloc()
+                    slave_alloc()
                     slave_configure() -->  scsi_adjust_queue_depth()
-			 |
-		    slave_alloc()
+                         |
+                    slave_alloc()
                     slave_configure()
-			 |
-		    slave_alloc()   **
-                    slave_destroy() **
+                         |
+                    slave_alloc()   ***
+                    slave_destroy() ***
+------------------------------------------------------------
 
 If the LLD wants to adjust the default queue settings, it can invoke
 scsi_adjust_queue_depth() in its slave_configure() routine.
 
-** For scsi devices that the mid level tries to scan but do not
-   respond, a slave_alloc(), slave_destroy() pair is called.
+*** For scsi devices that the mid level tries to scan but do not
+    respond, a slave_alloc(), slave_destroy() pair is called.
 
-Here is the corresponding sequence when a host (HBA) is being
-removed:
+When a HBA is being removed is could as part of an orderly shutdown
+associated with the LLD module being unloaded (e.g. with the "rmmod"
+command) or in response to a "hot unplug" indicated by sysfs()'s
+remove() callback being invoked. In either case, the sequence is the
+same:
 
-[HBA REMOVE]
+        HBA REMOVE: assume 2 SCSI devices attached
 LLD                      mid level                 LLD
----                      ---------                 ---
+===----------------------=========-----------------===------
 scsi_remove_host() ---------+
                             |
                      slave_destroy()
                      slave_destroy()
-                        release()     -->     scsi_unregister()
+scsi_host_put()
+------------------------------------------------------------
+                     
+It may be useful for a LLD to keep track of struct Scsi_Host instances
+(a pointer is returned by scsi_host_alloc()). Such instances are "owned"
+by the mid-level.  struct Scsi_Host instances are freed from
+scsi_host_put() when the reference count hits zero.
+
+Hot unplugging a HBA that controls a disk which is processing SCSI
+commands on a mounted file system is an interesting situation. Reference
+counting logic is being introduced into the mid level to cope with many
+of the issues involved. See the section on reference counting below.
+
+
+The hotplug concept may be extended to SCSI devices. Currently, when a
+HBA is added, the scsi_add_host() function causes a scan for SCSI devices
+attached to the HBA's SCSI transport. On newer SCSI transports the HBA
+may become aware of a new SCSI device _after_ the scan has completed.
+A LLD can use this sequence to make the mid level aware of a SCSI device:
 
-It is practical for a LLD to keep track of struct Scsi_Host instances
-(a pointer is returned by scsi_register() ) and struct scsi_device
-instances (a pointer is passed as the parameter to slave_alloc() and
-slave_configure() ). Both classes of instances are "owned" by the 
-mid-level. struct scsi_device instances are freed after slave_destroy().
-struct Scsi_Host instances are freed within scsi_unregister().
-
-TODO:
-Descriptions, are the following correct?
-[DEVICE hotplug]
+                 SCSI DEVICE hotplug
 LLD                   mid level                    LLD
----                   ---------                    ---
+===-------------------=========--------------------===------
 scsi_add_device()  ------+
                          |
-		    slave_alloc()
+                    slave_alloc()
                     slave_configure()   [--> scsi_adjust_queue_depth()]
+------------------------------------------------------------
 
-[DEVICE unplug]
+In a similar fashion, a LLD may become aware that a SCSI device has been
+removed (unplugged) or the connection to it has been interrupted. Some
+existing SCSI transports (e.g. SPI) may not become aware that a SCSI
+device has been removed until a subsequent SCSI command fails which will
+probably cause that device to be set offline by the mid level. A LLD that
+detects the removal of a SCSI device can instigate its removal from
+upper layers with this sequence:
+
+                  SCSI DEVICE hot unplug
 LLD                      mid level                 LLD
----                      ---------                 ---
+===----------------------=========-----------------===------
 scsi_set_device_offline()
 scsi_remove_device() -------+
                             |
                      slave_destroy()
+------------------------------------------------------------
 
+It may be useful for a LLD to keep track of struct scsi_device instances
+(a pointer is passed as the parameter to slave_alloc() and
+slave_configure() callbacks). Such instances are "owned" by the mid-level.
+struct scsi_device instances are freed after slave_destroy().
 
 
 Passive initialization model
 ============================
-LLD initialization (both built-in and module) and shutdown are "wired
-up" by passing function pointers to the module_init() and module_exit()
-macros respectively. In this model the function identified by "module_init"
-must call scsi_register_host() and the function identified by "module_exit"
-must call scsi_unregister_host().
-Most LLDs inherited from the lk 2.4 series include a file called
-"scsi_module.c" [yes the ".c" is a little surprising] in their
-source code. For that file to work a declaration like this is needed before
-it is included:
-    static struct SHT driver_template = DRIVER_TEMPLATE;
+These older LLDs include a file called "scsi_module.c" [yes the ".c" is a
+little surprising] in their source code. For that file to work an
+instance of struct scsi_host_template with the name "driver_template"
+needs to be defined. Here is a typical code sequence used in this model:
+    static struct scsi_host_template driver_template = {
+        ...
+    };
     #include "scsi_module.c"
 
-In this case "DRIVER_TEMPLATE" is defined to be a structure initializer
-that is placed in the driver header file by convention. It contains
-pointers to supported interface functions and other values.
+The scsi_module.c file contains two functions:
+  - init_this_scsi_driver() which is executed when the LLD is
+    initialized (i.e. boot time or module load time)
+  - exit_this_scsi_driver() which is executed when the LLD is shut
+    down (i.e. module unload time)
+Note: since these functions are tagged with __init and __exit qualifiers
+a LLD should not call them explicitly (since the kernel does that).
 
 Here is an example of an initialization sequence when two hosts are
 detected (so detect() returns 2) and the SCSI bus scan on each host
 finds 1 SCSI device (and a second device does not respond).
 
 LLD                      mid level                 LLD
----                      ---------                 ---
-scsi_register_host() -------+
+===----------------------=========-----------------===------
+init_this_scsi_driver() ----+
                             |
                          detect()  -----------------+
                             |                       |
                             |                scsi_register()
                             |                scsi_register()
                             |
-		      slave_alloc()
+                      slave_alloc()
                       slave_configure()  -->  scsi_adjust_queue_depth()
-		      slave_alloc()   **
-		      slave_destroy() **
+                      slave_alloc()   ***
+                      slave_destroy() ***
                             |
-		      slave_alloc()
+                      slave_alloc()
                       slave_configure()
-		      slave_alloc()   **
-		      slave_destroy() **
+                      slave_alloc()   ***
+                      slave_destroy() ***
+------------------------------------------------------------
 
 The mid level invokes scsi_adjust_queue_depth() with tagged queuing off and
 "cmd_per_lun" for that host as the queue length. These settings can be
 overridden by a slave_configure() supplied by the LLD.
 
-** For scsi devices that the mid level tries to scan but do not
-   respond, a slave_alloc(), slave_destroy() pair is called.
+*** For scsi devices that the mid level tries to scan but do not
+    respond, a slave_alloc(), slave_destroy() pair is called.
 
 Here is a LLD shutdown sequence:
 
 LLD                      mid level                 LLD
----                      ---------                 ---
-scsi_unregister_host() -----+
+===----------------------=========-----------------===------
+exit_this_scsi_driver() ----+
                             |
                      slave_destroy()
                         release()   -->   scsi_unregister()
                             |
                      slave_destroy()
                         release()   -->   scsi_unregister()
+------------------------------------------------------------
 
-slave_destroy() is optional. 
+A LLD need not define slave_destroy() (i.e. it is optional). 
 
 The shortcoming of the "passive initialization model" is that host
 registration and de-registration are (typically) tied to LLD initialization
 and shutdown. Once the LLD is initialized then a new host that appears
 (e.g. via hotplugging) cannot easily be added without a redundant
-driver shutdown and re-initialization.
+driver shutdown and re-initialization. It may be possible to write a LLD
+that uses both initialization models.
+
+
+Reference Counting
+==================
+The Scsi_Host structure has had reference counting infrastructure added.
+This effectively spreads the ownership of struct Scsi_Host instances
+across the various SCSI layers which use them. Previously such instances
+were exclusively owned by the mid level. LLDs would not usually need to
+directly manipulate these reference counts but there may be some cases
+where they do.
+
+There are 3 reference counting functions of interest associated with
+struct Scsi_Host:
+  - scsi_host_alloc(): returns a pointer to new instance of struct 
+        Scsi_Host which has its reference count ^^ set to 1
+  - scsi_host_get(): adds 1 to the reference count of the given instance
+  - scsi_host_put(): decrements 1 from the reference count of the given
+        instance. If the reference count reaches 0 then the given instance
+        is freed
+
+^^ struct Scsi_Host actually has 2 reference counts which are manipulated
+in parallel by these functions.
 
 
 Conventions
 ===========
-First, Linus's thoughts on C coding can be found in the file 
-Documentation/CodingStyle . 
+First, Linus Torvald's thoughts on C coding style can be found in the
+Documentation/CodingStyle file. 
 
 Next, there is a movement to "outlaw" typedefs introducing synonyms for 
-struct tags. Both can be still found in the SCSI subsystem, for example: 
-"typedef struct SHT { ...} Scsi_Host_Template;" in hosts.h . In this
-case "struct SHT" is preferred to "Scsi_Host_Template". [The poor naming
-example was chosen with malevolent intent.]
+struct tags. Both can be still found in the SCSI subsystem, but
+the typedefs have been moved to a single file, scsi_typedefs.h to
+make their future removal easier, for example: 
+"typedef struct scsi_host_template Scsi_Host_Template;"
 
 Also, C99 enhancements are encouraged to the extent they are supported
 by the relevant gcc compilers. So "//" style comments are encouraged
@@ -304,9 +358,11 @@
    scsi_bios_ptable - return copy of block device's partition table
    scsi_block_requests - prevent further commands being queued to given host
    scsi_delete_timer - cancel timer on a SCSI command.
+   scsi_host_alloc - return a new scsi_host instance whose refcount==1
+   scsi_host_get - increments Scsi_Host instance's refcount
+   scsi_host_put - decrements Scsi_Host instance's refcount (free if 0)
    scsi_partsize - parse partition table into cylinders, heads + sectors
    scsi_register - create and register a scsi host adapter instance.
-   scsi_register_host - register a low level host driver
    scsi_remove_device - detach and remove a SCSI device
    scsi_remove_host - detach and remove all SCSI devices owned by host
    scsi_report_bus_reset - report scsi _bus_ reset observed
@@ -316,8 +372,8 @@
    scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS
    scsi_track_queue_full - track successive QUEUE_FULL events 
    scsi_unblock_requests - allow further commands to be queued to given host
-   scsi_unregister - unregister and free memory used by host instance
-   scsi_unregister_host - unregister a low level host adapter driver
+   scsi_unregister - [calls scsi_host_put()]
+
 
 Details:
 
@@ -329,17 +385,17 @@
  * @lun:     logical unit number
  *
  *      Returns pointer to new struct scsi_device instance or 
- *	ERR_PTR(-ENODEV) (or some other bent pointer) if something is
- *	wrong (e.g. no lu responds at given address)
+ *      ERR_PTR(-ENODEV) (or some other bent pointer) if something is
+ *      wrong (e.g. no lu responds at given address)
  *
- *	Notes: This call is usually performed internally during a scsi
- *	bus scan when a HBA is added (i.e. scsi_add_host()). So it
- *	should only be called if the HBA becomes aware of a new scsi
- *	device (lu) after scsi_add_host() has completed. If successful
- *	this call we lead to slave_alloc() and slave_configure() callbacks
- *	into the LLD.
+ *      Notes: This call is usually performed internally during a scsi
+ *      bus scan when a HBA is added (i.e. scsi_add_host()). So it
+ *      should only be called if the HBA becomes aware of a new scsi
+ *      device (lu) after scsi_add_host() has completed. If successful
+ *      this call we lead to slave_alloc() and slave_configure() callbacks
+ *      into the LLD.
  *
- *	Defined in: drivers/scsi/scsi_scan.c
+ *      Defined in: drivers/scsi/scsi_scan.c
  **/
 struct scsi_device * scsi_add_device(struct Scsi_Host *shost, 
                                      unsigned int channel,
@@ -353,10 +409,10 @@
  *
  *      Returns 0 on success, negative errno of failure (e.g. -ENOMEM)
  *
- *	Notes: Only required in "hotplug initialization model" after a
- *	successful call to scsi_register().
+ *      Notes: Only required in "hotplug initialization model" after a
+ *      successful call to scsi_host_alloc().
  *
- *	Defined in: drivers/scsi/hosts.c
+ *      Defined in: drivers/scsi/hosts.c
  **/
 int scsi_add_host(struct Scsi_Host *shost, struct device * dev)
 
@@ -369,40 +425,40 @@
  *
  *      Returns nothing
  *
- *	Notes: Each scsi command has its own timer, and as it is added
- *	to the queue, we set up the timer. When the command completes, 
+ *      Notes: Each scsi command has its own timer, and as it is added
+ *      to the queue, we set up the timer. When the command completes, 
  *      we cancel the timer. A LLD can use this function to change
- *	the existing timeout value.
+ *      the existing timeout value.
  *
- *	Defined in: drivers/scsi/scsi_error.c
+ *      Defined in: drivers/scsi/scsi_error.c
  **/
-void scsi_add_timer(Scsi_Cmnd *scmd, int timeout, void (*complete)
-                    (Scsi_Cmnd *))
+void scsi_add_timer(struct scsi_cmnd *scmd, int timeout, 
+                    void (*complete)(struct scsi_cmnd *))
 
 
 /**
  * scsi_adjust_queue_depth - change the queue depth on a SCSI device
- * @SDpnt:	pointer to SCSI device to change queue depth on
- * @tagged:	0 - no tagged queuing
- *		MSG_SIMPLE_TAG - simple (unordered) tagged queuing
- *		MSG_ORDERED_TAG - ordered tagged queuing
- * @tags	Number of tags allowed if tagged queuing enabled,
- *		or number of commands the LLD can queue up
- *		in non-tagged mode (as per cmd_per_lun).
- *
- *	Returns nothing
- *
- * 	Notes: Can be invoked any time on a SCSI device controlled by this
- *	LLD. [Specifically during and after slave_configure() and prior to
- *	slave_destroy().] Can safely be invoked from interrupt code. Actual
- *	queue depth change may be delayed until the next command is being
- *	processed.
+ * @SDpnt:      pointer to SCSI device to change queue depth on
+ * @tagged:     0 - no tagged queuing
+ *              MSG_SIMPLE_TAG - simple (unordered) tagged queuing
+ *              MSG_ORDERED_TAG - ordered tagged queuing
+ * @tags        Number of tags allowed if tagged queuing enabled,
+ *              or number of commands the LLD can queue up
+ *              in non-tagged mode (as per cmd_per_lun).
  *
- *	Defined in: drivers/scsi/scsi.c [see source code for more notes]
+ *      Returns nothing
+ *
+ *      Notes: Can be invoked any time on a SCSI device controlled by this
+ *      LLD. [Specifically during and after slave_configure() and prior to
+ *      slave_destroy().] Can safely be invoked from interrupt code. Actual
+ *      queue depth change may be delayed until the next command is being
+ *      processed.
+ *
+ *      Defined in: drivers/scsi/scsi.c [see source code for more notes]
  *
  **/
 void scsi_adjust_queue_depth(struct scsi_device * SDpnt, int tagged, 
-			     int num_tags)
+                             int num_tags)
 
 
 /**
@@ -419,13 +475,13 @@
 
 /**
  * scsi_bios_ptable - return copy of block device's partition table
- * @dev:	pointer to block device
+ * @dev:        pointer to block device
  *
- *	Returns pointer to partition table, or NULL for failure
+ *      Returns pointer to partition table, or NULL for failure
  *
- *	Notes: Caller owns memory returned (free with kfree() )
+ *      Notes: Caller owns memory returned (free with kfree() )
  *
- *	Defined in: drivers/scsi/scsicam.c
+ *      Defined in: drivers/scsi/scsicam.c
  **/
 unsigned char *scsi_bios_ptable(struct block_device *dev)
 
@@ -435,12 +491,12 @@
  *
  * @SHpnt: pointer to host to block commands on
  *
- *	Returns nothing
+ *      Returns nothing
  *
- * 	Notes: There is no timer nor any other means by which the requests
- *	get unblocked other than the LLD calling scsi_unblock_requests().
+ *      Notes: There is no timer nor any other means by which the requests
+ *      get unblocked other than the LLD calling scsi_unblock_requests().
  *
- *	Defined in: drivers/scsi/scsi_lib.c
+ *      Defined in: drivers/scsi/scsi_lib.c
 **/
 void scsi_block_requests(struct Scsi_Host * SHpnt)
 
@@ -450,15 +506,64 @@
  * @scmd:    pointer to scsi command instance
  *
  *      Returns 1 if able to cancel timer else 0 (i.e. too late or already
- *	cancelled).
+ *      cancelled).
+ *
+ *      Notes: All commands issued by upper levels already have a timeout
+ *      associated with them. A LLD can use this function to cancel the
+ *      timer.
  *
- *	Notes: All commands issued by upper levels already have a timeout
- *	associated with them. A LLD can use this function to cancel the
- *	timer.
+ *      Defined in: drivers/scsi/scsi_error.c
+ **/
+int scsi_delete_timer(struct scsi_cmnd *scmd)
+
+
+/**
+ * scsi_host_alloc - create and register a scsi host adapter instance.
+ * @shost_tp:   pointer to scsi host template
+ * @xtr_bytes:  extra bytes to allocate in hostdata array (which is the
+ *              last member of the returned Scsi_Host instance)
  *
- *	Defined in: drivers/scsi/scsi_error.c
+ *      Returns pointer to new Scsi_Host instance or NULL on failure
+ *
+ *      Notes: When this call returns to the LLDD, the SCSI bus scan on
+ *      this host has _not_ yet been done.
+ *      The hostdata array (by default zero length) is a per host scratch 
+ *      area for the LLD.
+ *      Both associated refcounting objects have there refcount set to 1.
+ *
+ *      Defined in: drivers/scsi/hosts.c .
  **/
-int scsi_delete_timer(Scsi_Cmnd *scmd)
+struct Scsi_Host * scsi_host_alloc(struct scsi_host_template *, int xtr_bytes)
+
+
+/**
+ * scsi_host_get - increment Scsi_Host instance refcount
+ * @shost:   pointer to struct Scsi_Host instance
+ *
+ *      Returns nothing
+ *
+ *      Notes: Actually increments the counts in two sub-objects
+ *
+ *      Defined in: drivers/scsi/hosts.c
+ **/
+void scsi_host_get(struct Scsi_Host *shost)
+
+
+/**
+ * scsi_host_put - decrement Scsi_Host instance refcount, free if 0
+ * @shost:   pointer to struct Scsi_Host instance
+ *
+ *      Returns nothing
+ *
+ *      Notes: Actually decrements the counts in two sub-objects. If the
+ *      latter refcount reaches 0, the Scsi_Host instance is freed.
+ *      The LLD need not worry exactly when the Scsi_Host instance is
+ *      freed, it just shouldn't access the instance after it has balanced
+ *      out its refcount usage.
+ *
+ *      Defined in: drivers/scsi/hosts.c
+ **/
+void scsi_host_put(struct Scsi_Host *shost)
 
 
 /**
@@ -469,11 +574,11 @@
  * @hds: outputs number of heads calculated via this pointer
  * @secs: outputs number of sectors calculated via this pointer
  *
- *	Returns 0 on success, -1 on failure
+ *      Returns 0 on success, -1 on failure
  *
- *	Notes: Caller owns memory returned (free with kfree() )
+ *      Notes: Caller owns memory returned (free with kfree() )
  *
- *	Defined in: drivers/scsi/scsicam.c
+ *      Defined in: drivers/scsi/scsicam.c
  **/
 int scsi_partsize(unsigned char *buf, unsigned long capacity,
                   unsigned int *cyls, unsigned int *hds, unsigned int *secs)
@@ -483,51 +588,33 @@
  * scsi_register - create and register a scsi host adapter instance.
  * @shost_tp:   pointer to scsi host template
  * @xtr_bytes:  extra bytes to allocate in hostdata array (which is the
- *		last member of the returned Scsi_Host instance)
+ *              last member of the returned Scsi_Host instance)
  *
  *      Returns pointer to new Scsi_Host instance or NULL on failure
  *
- *	Notes: When this call returns to the LLDD, the SCSI bus scan on
- *	this host has _not_ yet been done.
- *	The hostdata array (by default zero length) is a per host scratch 
- *	area for the LLD.
- *
- *	Defined in: drivers/scsi/hosts.c .
- **/
-struct Scsi_Host * scsi_register(struct SHT *, int xtr_bytes)
-
-
-/**
- * scsi_register_host - register a low level host driver
- * @shost_tp:   pointer to a scsi host driver template
- *
- *      Returns 0 on Success, 1 on failure
- *
- *      Notes: Should only be invoked if the "passive initialization
- *	model" is being used. Notice this is a _driver_ rather than 
- *	HBA registration function. Most older drivers call this
- *	function by including the scsi_module.c file.
- *	This function is deprecated, use the "hotplug initialization
- *	model" instead.
+ *      Notes: When this call returns to the LLDD, the SCSI bus scan on
+ *      this host has _not_ yet been done.
+ *      The hostdata array (by default zero length) is a per host scratch 
+ *      area for the LLD.
  *
- *	Defined in: drivers/scsi/hosts.c .
+ *      Defined in: drivers/scsi/hosts.c .
  **/
-int scsi_register_host(Scsi_Host_Template *shost_tp)
+struct Scsi_Host * scsi_register(struct scsi_host_template *, int xtr_bytes)
 
 
 /**
  * scsi_remove_device - detach and remove a SCSI device
  * @sdev:      a pointer to a scsi device instance
  *
- *	Returns value: 0 on success, -EINVAL if device not attached
+ *      Returns value: 0 on success, -EINVAL if device not attached
  *
  *      Notes: If a LLD becomes aware that a scsi device (lu) has
- *	been removed but its host is still present then it can request
- *	the removal of that scsi device. If successful this call will
- *	lead to the slave_destroy() callback being invoked. sdev is an 
- *	invalid pointer after this call.
+ *      been removed but its host is still present then it can request
+ *      the removal of that scsi device. If successful this call will
+ *      lead to the slave_destroy() callback being invoked. sdev is an 
+ *      invalid pointer after this call.
  *
- *	Defined in: drivers/scsi/scsi_scan.c .
+ *      Defined in: drivers/scsi/scsi_scan.c .
  **/
 int scsi_remove_device(struct scsi_device *sdev)
 
@@ -536,13 +623,13 @@
  * scsi_remove_host - detach and remove all SCSI devices owned by host
  * @shost:      a pointer to a scsi host instance
  *
- *	Returns value: 0 on success, 1 on failure (e.g. LLD busy ??)
+ *      Returns value: 0 on success, 1 on failure (e.g. LLD busy ??)
  *
  *      Notes: Should only be invoked if the "hotplug initialization
- *	model" is being used. It should be called _prior_ to  
- *	scsi_unregister().
+ *      model" is being used. It should be called _prior_ to  
+ *      scsi_unregister().
  *
- *	Defined in: drivers/scsi/hosts.c .
+ *      Defined in: drivers/scsi/hosts.c .
  **/
 int scsi_remove_host(struct Scsi_Host *shost)
 
@@ -552,15 +639,15 @@
  * @shost: a pointer to a scsi host involved
  * @channel: channel (within) host on which scsi bus reset occurred
  *
- *	Returns nothing
+ *      Returns nothing
  *
  *      Notes: This only needs to be called if the reset is one which
- *	originates from an unknown location.  Resets originated by the 
- *	mid level itself don't need to call this, but there should be 
- *	no harm.  The main purpose of this is to make sure that a
- *	CHECK_CONDITION is properly treated.
+ *      originates from an unknown location.  Resets originated by the 
+ *      mid level itself don't need to call this, but there should be 
+ *      no harm.  The main purpose of this is to make sure that a
+ *      CHECK_CONDITION is properly treated.
  *
- *	Defined in: drivers/scsi/scsi_lib.c .
+ *      Defined in: drivers/scsi/scsi_lib.c .
  **/
 void scsi_report_bus_reset(struct Scsi_Host * shost, int channel)
 
@@ -570,7 +657,7 @@
  * @shost: a pointer to a scsi host instance
  * @pdev: pointer to device instance to assign
  *
- *	Returns nothing
+ *      Returns nothing
  *
  *      Defined in: drivers/scsi/hosts.h .
  **/
@@ -581,13 +668,13 @@
  * scsi_set_device_offline - set device offline then flush its queue
  * @sdev: a pointer to a scsi device instance to be set offline
  *
- *	Returns nothing
+ *      Returns nothing
  *
  *      Notes: Commands that are currently active on the scsi device have 
- *	       their timers cancelled and are transferred to the host's
- *	       "eh" list for cancellation. 
+ *             their timers cancelled and are transferred to the host's
+ *             "eh" list for cancellation. 
 
- *	Defined in: drivers/scsi/scsi.c .
+ *      Defined in: drivers/scsi/scsi.c .
  **/
 void scsi_set_device_offline(struct scsi_device * sdev)
 
@@ -596,10 +683,10 @@
  * scsi_to_pci_dma_dir - convert SCSI subsystem direction flag to PCI
  * @scsi_data_direction: SCSI subsystem direction flag
  *
- *	Returns PCI_DMA_TODEVICE given SCSI_DATA_WRITE,
- *		PCI_DMA_FROMDEVICE given SCSI_DATA_READ
- *		PCI_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
- *		else returns PCI_DMA_NONE
+ *      Returns PCI_DMA_TODEVICE given SCSI_DATA_WRITE,
+ *              PCI_DMA_FROMDEVICE given SCSI_DATA_READ
+ *              PCI_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
+ *              else returns PCI_DMA_NONE
  *
  *      Defined in: drivers/scsi/scsi.h .
  **/
@@ -610,10 +697,10 @@
  * scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS
  * @scsi_data_direction: SCSI subsystem direction flag
  *
- *	Returns SBUS_DMA_TODEVICE given SCSI_DATA_WRITE,
- *		SBUS_DMA_FROMDEVICE given SCSI_DATA_READ
- *		SBUS_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
- *		else returns SBUS_DMA_NONE
+ *      Returns SBUS_DMA_TODEVICE given SCSI_DATA_WRITE,
+ *              SBUS_DMA_FROMDEVICE given SCSI_DATA_READ
+ *              SBUS_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN
+ *              else returns SBUS_DMA_NONE
  *
  *      Defined in: drivers/scsi/scsi.h .
  **/
@@ -622,21 +709,21 @@
 
 /**
  * scsi_track_queue_full - track successive QUEUE_FULL events on given
- *			device to determine if and when there is a need
- *			to adjust the queue depth on the device.
+ *                      device to determine if and when there is a need
+ *                      to adjust the queue depth on the device.
  * @SDptr: pointer to SCSI device instance
  * @depth: Current number of outstanding SCSI commands on this device,
- *	   not counting the one returned as QUEUE_FULL.
+ *         not counting the one returned as QUEUE_FULL.
  *
  *      Returns 0  - no change needed
- *		>0 - adjust queue depth to this new depth
- *		-1 - drop back to untagged operation using host->cmd_per_lun
- *		     as the untagged command depth
+ *              >0 - adjust queue depth to this new depth
+ *              -1 - drop back to untagged operation using host->cmd_per_lun
+ *                   as the untagged command depth
  *
  *      Notes: LLDs may call this at any time and we will do "The Right
- *		Thing"; interrupt context safe. 
+ *              Thing"; interrupt context safe. 
  *
- *	Defined in: drivers/scsi/scsi.c .
+ *      Defined in: drivers/scsi/scsi.c .
  **/
 int scsi_track_queue_full(Scsi_Device *SDptr, int depth)
 
@@ -646,70 +733,48 @@
  *
  * @SHpnt: pointer to host to unblock commands on
  *
- *	Returns nothing
+ *      Returns nothing
  *
- * 	Defined in: drivers/scsi/scsi_lib.c .
+ *      Defined in: drivers/scsi/scsi_lib.c .
 **/
 void scsi_unblock_requests(struct Scsi_Host * SHpnt)
 
 
 /**
  * scsi_unregister - unregister and free memory used by host instance
- * @shp:	pointer to scsi host instance to unregister.
+ * @shp:        pointer to scsi host instance to unregister.
  *
- *	Returns nothing
+ *      Returns nothing
  *
  *      Notes: Should only be invoked if the "hotplug initialization
- *	model" is being used. It should be called _after_  
- *	scsi_remove_host(). The shp pointer is invalid after this call.
+ *      model" is being used. It should be called _after_  
+ *      scsi_remove_host(). The shp pointer is invalid after this call.
  *
- *	Defined in: drivers/scsi/hosts.c .
+ *      Defined in: drivers/scsi/hosts.c .
  **/
 void scsi_unregister(struct Scsi_Host * shp)
 
 
-/**
- * scsi_unregister_host - unregister a low level host adapter driver
- * @shost_tp:   scsi host template to unregister.
- *
- *	Returns 0 on Success, 1 on Failure
- *
- *      Notes: Should only be invoked if the "passive initialization
- *	model" is being used. Notice this is a _driver_ rather than 
- *	HBA deregistration function. So if there are multiple HBAs
- *	associated with the given template, they are each removed. Most 
- *	older drivers call this function by including the scsi_module.c
- *	file. This function is deprecated, use the "hotplug initialization
- *	model" instead.
- *
- *	Defined in: drivers/scsi/hosts.c .
- **/
-int scsi_unregister_host(Scsi_Host_Template *shost_tp)
-
 
 
 Interface Functions
 ===================
-Interface functions are supplied (defined) by LLDs and
-their function pointers are placed in an instance of struct SHT which
-is passed to scsi_register() [or scsi_register_host()]. Some
-are mandatory. Interface functions should be declared static. The 
+Interface functions are supplied (defined) by LLDs and their function
+pointers are placed in an instance of struct scsi_host_template which
+is passed to scsi_host_alloc() [or scsi_register() / init_this_scsi_driver()].
+Some are mandatory. Interface functions should be declared static. The
 accepted convention is that driver "xyz" will declare its slave_configure() 
 function as:
     static int xyz_slave_configure(struct scsi_device * sdev);
 
 A pointer to this function should be placed in the 'slave_configure' member
-of a "struct SHT" instance. A pointer to such an instance should
-passed to the mid level's scsi_register() [or scsi_register_host()].
+of a "struct scsi_host_template" instance. A pointer to such an instance
+should passed to the mid level's scsi_host_alloc() [or scsi_register() /
+init_this_scsi_driver()].
 
 The interface functions are also described in the hosts.h file immediately
-above their definition point in "struct SHT". In some cases more detail
-is given in hosts.h than below.
-
-Those interface functions marked "Required: yes" must be implemented
-by the LLD and a pointer to that function must be placed in the driver's
-"struct SHT" instance. Interface functions marked "Required: no" need not
-be implemented.
+above their definition point in "struct scsi_host_template". In some cases
+more detail is given in hosts.h than below.
 
 The interface functions are listed below in alphabetical order.
 
@@ -731,13 +796,14 @@
    slave_configure - driver fine tuning for given device after attach
    slave_destroy - given device is about to be shut down
 
+
 Details:
 
 /**
  *      bios_param - fetch head, sector, cylinder info for a disk
  *      @sdev: pointer to scsi device context (defined in scsi.h)
  *      @bdev: pointer to block device context (defined in fs.h)
- *	@capacity:  device size (in 512 byte sectors)
+ *      @capacity:  device size (in 512 byte sectors)
  *      @params: three element array to place output:
  *              params[0] number of heads (max 255)
  *              params[1] number of sectors (max 63)
@@ -745,8 +811,6 @@
  *
  *      Return value is ignored
  *
- *      Required: no
- *
  *      Locks: none
  *
  *      Notes: an arbitrary geometry (based on READ CAPACITY) is used
@@ -754,10 +818,10 @@
  *      pre-initialized with made up values just in case this function 
  *      doesn't output anything.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
     int bios_param(struct scsi_device * sdev, struct block_device *bdev,
-    		   sector_t capacity, int params[3]);
+                   sector_t capacity, int params[3])
 
 
 /**
@@ -768,18 +832,16 @@
  *      host_byte, driver_byte (status_byte is in the lsb). A value of
  *      0 is an unqualified success.
  *
- *      Required: if struct Scsi_Host::can_queue can ever by cleared (zero)
- *                then this function is required.
- *
  *      Locks: struct Scsi_Host::host_lock held on entry (with "irqsave")
  *             and is expected to be held on return.
  *
  *      Notes: Drivers tend to be dropping support for this function and
  *      supporting queuecommand() instead.
  *
- *	Defined in: LLD
+ *      Defined in: LLD (if struct Scsi_Host::can_queue can ever by cleared
+ *                       (zero) then this function is required)
  **/
-    int command(struct scsi_cmnd * scp);
+    int command(struct scsi_cmnd * scp)
 
 
 /**
@@ -789,9 +851,6 @@
  *      Returns number of hosts this driver wants to control. 0 means no
  *      suitable hosts found.
  *
- *      Required: yes, if "passive initialization mode" is used
- *		  [in "hotplug initialization mode" it is not invoked]
- *
  *      Locks: none held
  *
  *      Notes: First function called from the SCSI mid level on this
@@ -799,9 +858,10 @@
  *      For each host found, this method should call scsi_register() 
  *      [see hosts.c].
  *
- *	Defined in: LLD
+ *      Defined in: LLD (required if "passive initialization mode" is used,
+ *                       not invoked in "hotplug initialization mode")
  **/
-    int detect(struct SHT * shtp);
+    int detect(struct scsi_host_template * shtp)
 
 
 /**
@@ -810,17 +870,15 @@
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
- *      Required: no
- *
  *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry 
- *	and assumed to be held on return.
+ *      and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-     int eh_abort_handler(struct scsi_cmnd * scp);
+     int eh_abort_handler(struct scsi_cmnd * scp)
 
 
 /**
@@ -829,17 +887,15 @@
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
- *      Required: no
- *
  *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry 
- *	and assumed to be held on return.
+ *      and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-     int eh_bus_reset_handler(struct scsi_cmnd * scp);
+     int eh_bus_reset_handler(struct scsi_cmnd * scp)
 
 
 /**
@@ -848,17 +904,15 @@
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
- *      Required: no
- *
  *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
- *	and assumed to be held on return.
+ *      and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-     int eh_device_reset_handler(struct scsi_cmnd * scp);
+     int eh_device_reset_handler(struct scsi_cmnd * scp)
 
 
 /**
@@ -867,10 +921,8 @@
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
- *      Required: no
- *
  *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
- *	and assumed to be held on return.
+ *      and assumed to be held on return.
  *
  *      Notes: Invoked from scsi_eh thread. No other commands will be
  *      queued on current host during eh. 
@@ -879,9 +931,9 @@
  *      defined (or they all return FAILED) then the device in question 
  *      will be set offline whenever eh is invoked.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-     int eh_host_reset_handler(struct scsi_cmnd * scp);
+     int eh_host_reset_handler(struct scsi_cmnd * scp)
 
 
 /**
@@ -890,16 +942,14 @@
  *
  *      Returns TRUE if host unjammed, else FALSE.
  *
- *      Required: no
- *
  *      Locks: none
  *
- *      Notes: Invoked from scsi_eh thread. Driver supplied alternate to 
+ *      Notes: Invoked from scsi_eh thread. LLD supplied alternate to 
  *      scsi_unjam_host() found in scsi_error.c
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-     int eh_strategy_handler(struct Scsi_Host * shp);
+     int eh_strategy_handler(struct Scsi_Host * shp)
 
 
 /**
@@ -911,8 +961,6 @@
  *      manage the memory pointed to and maintain it, typically for the
  *      lifetime of this host.]
  *
- *      Required: no
- *
  *      Locks: none
  *
  *      Notes: Often supplies PCI or ISA information such as IO addresses
@@ -921,15 +969,15 @@
  *      (i.e. does not included embedded newlines).
  *      The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this
  *      function (or struct Scsi_Host::name if this function is not
- *	available).
- *      In a similar manner, scsi_register_host() outputs to the console
+ *      available).
+ *      In a similar manner, init_this_scsi_driver() outputs to the console
  *      each host's "info" (or name) for the driver it is registering.
  *      Also if proc_info() is not supplied, the output of this function
  *      is used instead.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-    const char * info(struct Scsi_Host * shp);
+    const char * info(struct Scsi_Host * shp)
 
 
 /**
@@ -944,8 +992,6 @@
  *      Returns negative "errno" value when there is a problem. 0 or a
  *      positive value indicates success and is returned to the user space.
  *
- *      Required: no
- *
  *      Locks: none
  *
  *      Notes: The SCSI subsystem uses a "trickle down" ioctl model.
@@ -958,11 +1004,11 @@
  *      However the mid level returns -EINVAL for unrecognized 'cmd'
  *      numbers when this function is not supplied by the driver.
  *      Unfortunately some applications expect -EINVAL and react badly
- *	when -ENOTTY is returned; stick with -EINVAL.
+ *      when -ENOTTY is returned; stick with -EINVAL.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-    int ioctl(struct scsi_device *sdp, int cmd, void *arg);
+    int ioctl(struct scsi_device *sdp, int cmd, void *arg)
 
 
 /**
@@ -983,16 +1029,14 @@
  *      Returns length when 1==writeto1_read0. Otherwise number of chars
  *      output to buffer past offset.
  *
- *      Required: no
- *
  *      Locks: none held
  *
  *      Notes: Driven from scsi_proc.c which interfaces to proc_fs
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-int proc_info(char * buffer, char ** start, off_t offset, 
-              int length, int hostno, int writeto1_read0);
+    int proc_info(char * buffer, char ** start, off_t offset, 
+                  int length, int hostno, int writeto1_read0)
 
 
 /**
@@ -1000,13 +1044,10 @@
  *      @scp: pointer to scsi command object
  *      @done: function pointer to be invoked on completion
  *
- *      Returns 1 if the adapter (host) is busy, else returns 0. One
- *		reason for an adapter to be busy is that the number
- *		of outstanding queued commands is already equal to
- *		struct Scsi_Host::can_queue .
- *
- *      Required: if struct Scsi_Host::can_queue is ever non-zero
- *                then this function is required.
+ *      Returns 0 on success and 1 if the LLD or the HBA is busy (i.e. run
+ *      out of resources to queue further commands). Other types of errors
+ *      are flagged by setting struct scsi_cmnd:result to an appropriate
+ *      value, invoking the 'done' callback, and then returning 0.
  *
  *      Locks: struct Scsi_Host::host_lock held on entry (with "irqsave")
  *             and is expected to be held on return.
@@ -1024,14 +1065,15 @@
  *      this case, it should be placed in scp->result before this function 
  *      returns.
  *      If a status of CHECK CONDITION is placed in "result" when the
- *	'done' callback is invoked, then the LLD driver should 
- *	perform autosense and fill in the struct scsi_cmnd::sense_buffer
- *	array.
+ *      'done' callback is invoked, then the LLD driver should 
+ *      perform autosense and fill in the struct scsi_cmnd::sense_buffer
+ *      array.
  *
- *	Defined in: LLD
+ *      Defined in: LLD (required if if struct Scsi_Host::can_queue is ever
+ *                       non-zero)
  **/
     int queuecommand(struct scsi_cmnd * scp, 
-		     void (*done)(struct scsi_cmnd *));
+                     void (*done)(struct scsi_cmnd *))
 
 
 /**
@@ -1040,100 +1082,91 @@
  *
  *      Return value ignored (could soon be a function returning void).
  *
- *      Required: yes (see notes)
- *
  *      Locks: none held
  *
- *      Notes: Invoked from mid level's scsi_unregister_host().
+ *      Notes: Invoked from scsi_module.c's exit_this_scsi_driver().
  *      LLD's implementation of this function should call 
- *	scsi_unregister(shp) prior to returning.
- *	If not supplied mid-level [in hosts.c] supplies its own
- *	implementation (see scsi_host_legacy_release()) which is for old
- *	ISA adapters so it is best not to use it.
+ *      scsi_unregister(shp) prior to returning.
+ *      Only needed for old-style host templates.
  *
- *	Defined in: LLD
+ *      Defined in: LLD (required in "passive initialization model",
+ *                       should not be defined in hotplug model)
  **/
-    int release(struct Scsi_Host * shp);
+    int release(struct Scsi_Host * shp)
 
 
 /**
- *      slave_alloc -	prior to any commands being sent to a new device 
- *			(i.e. just prior to scan) this call is made
+ *      slave_alloc -   prior to any commands being sent to a new device 
+ *                      (i.e. just prior to scan) this call is made
  *      @sdp: pointer to new device (about to be scanned)
  *
  *      Returns 0 if ok. Any other return is assumed to be an error and
- *	the device is ignored.
- *
- *      Required: no
+ *      the device is ignored.
  *
  *      Locks: none
  *
  *      Notes: Allows the driver to allocate any resources for a device
- *	prior to its initial scan. The corresponding scsi device may not
- *	exist but the mid level is just about to scan for it (i.e. send
- *	and INQUIRY command plus ...). If a device is found then
- *	slave_configure() will be called while if a device is not found
- *	slave_destroy() is called.
+ *      prior to its initial scan. The corresponding scsi device may not
+ *      exist but the mid level is just about to scan for it (i.e. send
+ *      and INQUIRY command plus ...). If a device is found then
+ *      slave_configure() will be called while if a device is not found
+ *      slave_destroy() is called.
  *      For more details see the hosts.h file.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-    int slave_alloc(struct scsi_device *sdp);
+    int slave_alloc(struct scsi_device *sdp)
 
 
 /**
  *      slave_configure - driver fine tuning for given device just after it
- *		       has been first scanned (i.e. it responded to an
- *		       INQUIRY)
+ *                     has been first scanned (i.e. it responded to an
+ *                     INQUIRY)
  *      @sdp: device that has just been attached
  *
  *      Returns 0 if ok. Any other return is assumed to be an error and
- *	the device is taken offline. [offline devices will _not_ have
- *	slave_destroy() called on them so clean up resources.]
- *
- *      Required: no
+ *      the device is taken offline. [offline devices will _not_ have
+ *      slave_destroy() called on them so clean up resources.]
  *
  *      Locks: none
  *
  *      Notes: Allows the driver to inspect the response to the initial
- *	INQUIRY done by the scanning code and take appropriate action.
- *	For more details see the hosts.h file.
+ *      INQUIRY done by the scanning code and take appropriate action.
+ *      For more details see the hosts.h file.
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-    int slave_configure(struct scsi_device *sdp);
+    int slave_configure(struct scsi_device *sdp)
 
 
 /**
  *      slave_destroy - given device is about to be shut down. All
- *			activity has ceased on this device.
+ *                      activity has ceased on this device.
  *      @sdp: device that is about to be shut down
  *
  *      Returns nothing
  *
- *      Required: no
- *
  *      Locks: none
  *
  *      Notes: Mid level structures for given device are still in place
- *	but are about to be torn down. Any per device resources allocated
- *	by this driver for given device should be freed now. No further
- *	commands will be sent for this sdp instance. [However the device
- *	could be re-attached in the future in which case a new instance
- *	of struct scsi_device would be supplied by future slave_alloc()
- *	and slave_configure() calls.]
+ *      but are about to be torn down. Any per device resources allocated
+ *      by this driver for given device should be freed now. No further
+ *      commands will be sent for this sdp instance. [However the device
+ *      could be re-attached in the future in which case a new instance
+ *      of struct scsi_device would be supplied by future slave_alloc()
+ *      and slave_configure() calls.]
  *
- *	Defined in: LLD
+ *      Optionally defined in: LLD
  **/
-    void slave_destroy(struct scsi_device *sdp);
+    void slave_destroy(struct scsi_device *sdp)
 
 
 
 Data Structures
 ===============
-struct SHT
-----------
-There is one "struct SHT" instance per LLD ***. It is
+struct scsi_host_template
+-------------------------
+There is one "struct scsi_host_template" instance per LLD ***. It is
 typically initialized as a file scope static in a driver's header file. That
 way members that are not explicitly initialized will be set to 0 or NULL.
 Member of interest:
@@ -1143,22 +1176,23 @@
                    by sysfs in one of its "drivers" directories. Hence
                    "proc_name" should only contain characters acceptable
                    to a Unix file name.
-   (*release)()  - should be defined by all LLDs as the default (legacy)
-                   implementation is only appropriate for ISA adapters).
+   (*queuecommand)() - primary callback that the mid level uses to inject
+                   SCSI commands into a LLD.
 The structure is defined and commented in hosts.h
 
 *** In extreme situations a single driver may have several instances
-    if it controls several different classes of hardware (e.g. the
-    advansys driver handles both ISA and PCI cards and has a separate
-    instance of struct SHT for each).
+    if it controls several different classes of hardware (e.g. a LLD
+    that handles both ISA and PCI cards and has a separate instance of
+    struct scsi_host_template for each class).
 
 struct Scsi_Host
 ----------------
 There is one struct Scsi_Host instance per host (HBA) that a LLD
 controls. The struct Scsi_Host structure has many members in common
-with "struct SHT". When a new struct Scsi_Host instance is created (in
-scsi_register() in hosts.c) those common members are initialized from
-the driver's struct SHT instance. Members of interest:
+with "struct scsi_host_template". When a new struct Scsi_Host instance
+is created (in scsi_host_alloc() in hosts.c) those common members are
+initialized from the driver's struct scsi_host_template instance. Members
+of interest:
     host_no      - system wide unique number that is used for identifying
                    this host. Issued in ascending order from 0 (and the
                    positioning can be influenced by the scsihosts
@@ -1172,7 +1206,7 @@
                    in a single SCSI command. 0 implies no maximum.
     cmd_per_lun  - maximum number of command that can be queued on devices
                    controlled by the host. Overridden by LLD calls to
-		   scsi_adjust_queue_depth().
+                   scsi_adjust_queue_depth().
     unchecked_isa_dma - 1->only use bottom 16 MB of ram (ISA DMA addressing
                    restriction), 0->can use full 32 bit (or better) DMA
                    address space
@@ -1180,22 +1214,22 @@
                      0->disallow SCSI command merging
     highmem_io   - 1->can DMA in to or out of high memory,
                    0->use bounce buffers if data is in high memory
-    hostt        - pointer to driver's struct SHT from which this
-                   struct Scsi_Host instance was spawned
+    hostt        - pointer to driver's struct scsi_host_template from which
+                   this struct Scsi_Host instance was spawned
     sh_list      - a double linked list of pointers to all struct Scsi_Host
                    instances (currently ordered by ascending host_no)
     my_devices   - a double linked list of pointers to struct scsi_device 
-		   instances that belong to this host.
+                   instances that belong to this host.
     hostdata[0]  - area reserved for LLD at end of struct Scsi_Host. Size
                    is set by the second argument (named 'xtr_bytes') to
-                   scsi_register().
+                   scsi_host_alloc() or scsi_register().
 The structure is defined in hosts.h
 
 struct scsi_device
 ------------------
 Generally, there is one instance of this structure for each SCSI logical unit
-on a host. Scsi devices are uniquely identified within a host by bus number,
-cahnnel number, target id and logical unit number (lun).
+on a host. Scsi devices connected to a host are uniquely identified by a
+channel number, target id and logical unit number (lun).
 The structure is defined in scsi.h
 
 struct scsi_cmnd
@@ -1211,7 +1245,7 @@
 Locks
 =====
 Each struct Scsi_Host instance has a spin_lock called struct 
-Scsi_Host::default_lock which is initialized in scsi_register() [found in 
+Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in 
 hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer
 is initialized to point at default_lock with the scsi_assign_lock() function.
 Thereafter lock and unlock operations performed by the mid level use the
@@ -1236,11 +1270,12 @@
        to perform an extra data in phase on such responses
     b) or, the LLD issuing a REQUEST SENSE command itself
 
-Either way, the mid level decides whether the LLD has 
-performed autosense by checking struct scsi_cmnd::sense_buffer[0] . If this
-byte has an upper nibble of 7 (or 0xf) then autosense is assumed to have 
-taken place. If it has another value (and this byte is initialized to 0
-before each command) then the mid level will issue a REQUEST SENSE command.
+Either way, when a status of CHECK CONDITION is detected, the mid level
+decides whether the LLD has performed autosense by checking struct 
+scsi_cmnd::sense_buffer[0] . If this byte has an upper nibble of 7 (or 0xf)
+then autosense is assumed to have taken place. If it has another value (and
+this byte is initialized to 0 before each command) then the mid level will
+issue a REQUEST SENSE command.
 
 In the presence of queued commands the "nexus" that maintains sense
 buffer data from the command that failed until a following REQUEST SENSE
@@ -1256,7 +1291,7 @@
 
 The older error handling mechanism has been removed. This means the
 LLD interface functions abort() and reset() have been removed.
-The struct SHT::use_new_eh_code flag has been removed.
+The struct scsi_host_template::use_new_eh_code flag has been removed.
 
 In the 2.4 series the SCSI subsystem configuration descriptions were 
 aggregated with the configuration descriptions from all other Linux 
@@ -1264,9 +1299,10 @@
 the SCSI subsystem now has its own (much smaller) drivers/scsi/Config.help
 file.
 
-Addition of slave_alloc(), slave_configure() and slave_destroy().
+struct SHT has been renamed to struct scsi_host_template.
 
-Addition of the "hotplug initialization model".
+Addition of the "hotplug initialization model" and many extra functions
+to support it.
 
 
 Credits
@@ -1275,11 +1311,11 @@
         Mike Anderson <andmike@us.ibm.com>
         James Bottomley <James.Bottomley@steeleye.com> 
         Patrick Mansfield <patmans@us.ibm.com> 
-	Christoph Hellwig <hch@infradead.org>
-	Doug Ledford <dledford@redhat.com>
+        Christoph Hellwig <hch@infradead.org>
+        Doug Ledford <dledford@redhat.com>
         Andries Brouwer <Andries.Brouwer@cwi.nl>
 
 
 Douglas Gilbert
 dgilbert@interlog.com
-29th April 2003
+18th June 2003
diff -urN linux-2.5.73-bk8/Makefile linux-2.5.73-bk9/Makefile
--- linux-2.5.73-bk8/Makefile	2003-07-01 04:51:29.000000000 -0700
+++ linux-2.5.73-bk9/Makefile	2003-07-01 04:51:34.000000000 -0700
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 73
-EXTRAVERSION = -bk8
+EXTRAVERSION = -bk9
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
diff -urN linux-2.5.73-bk8/arch/alpha/kernel/core_t2.c linux-2.5.73-bk9/arch/alpha/kernel/core_t2.c
--- linux-2.5.73-bk8/arch/alpha/kernel/core_t2.c	2003-06-22 11:32:31.000000000 -0700
+++ linux-2.5.73-bk9/arch/alpha/kernel/core_t2.c	2003-07-01 04:51:34.000000000 -0700
@@ -465,10 +465,17 @@
 	*(vulp)T2_HAE_1 = 0; mb(); /* Sparse MEM HAE */
 	*(vulp)T2_HAE_2 = 0; mb(); /* Sparse I/O HAE */
 	*(vulp)T2_HAE_3 = 0; mb(); /* Config Space HAE */
-#if 0
-	/* !!! DO NOT EVER TOUCH THIS !!! */
-	*(vulp)T2_HAE_4 = 0; mb(); /* Dense MEM HAE */
-#endif
+
+	/*
+	 * We also now zero out HAE_4, the dense memory HAE, so that
+	 * we need not account for its "offset" when accessing dense
+	 * memory resources which we allocated in our normal way. This
+	 * HAE would need to stay untouched were we to keep the SRM
+	 * resource settings.
+	 *
+	 * Thus we can now run standard X servers on SABLE/LYNX. :-)
+	 */
+	*(vulp)T2_HAE_4 = 0; mb();
 }
 
 void
diff -urN linux-2.5.73-bk8/arch/alpha/kernel/process.c linux-2.5.73-bk9/arch/alpha/kernel/process.c
--- linux-2.5.73-bk8/arch/alpha/kernel/process.c	2003-06-22 11:33:15.000000000 -0700
+++ linux-2.5.73-bk9/arch/alpha/kernel/process.c	2003-07-01 04:51:34.000000000 -0700
@@ -270,7 +270,7 @@
 	struct thread_info *childti = p->thread_info;
 	struct pt_regs * childregs;
 	struct switch_stack * childstack, *stack;
-	unsigned long stack_offset;
+	unsigned long stack_offset, settls;
 
 	stack_offset = PAGE_SIZE - sizeof(struct pt_regs);
 	if (!(regs->ps & 8))
@@ -279,6 +279,7 @@
 	  (stack_offset + PAGE_SIZE + (long) childti);
 		
 	*childregs = *regs;
+	settls = regs->r20;
 	childregs->r0 = 0;
 	childregs->r19 = 0;
 	childregs->r20 = 1;	/* OSF/1 has some strange fork() semantics.  */
@@ -292,14 +293,16 @@
 	childti->pcb.flags = 1;	/* set FEN, clear everything else */
 
 	/* Set a new TLS for the child thread?  Peek back into the
-	   syscall arguments that we saved on syscall entry.  */
+	   syscall arguments that we saved on syscall entry.  Oops,
+	   except we'd have clobbered it with the parent/child set
+	   of r20.  Read the saved copy.  */
 	/* Note: if CLONE_SETTLS is not set, then we must inherit the
 	   value from the parent, which will have been set by the block
 	   copy in dup_task_struct.  This is non-intuitive, but is
 	   required for proper operation in the case of a threaded
 	   application calling fork.  */
 	if (clone_flags & CLONE_SETTLS)
-		childti->pcb.unique = regs->r20;
+		childti->pcb.unique = settls;
 
 	return 0;
 }
diff -urN linux-2.5.73-bk8/arch/i386/mach-voyager/voyager_basic.c linux-2.5.73-bk9/arch/i386/mach-voyager/voyager_basic.c
--- linux-2.5.73-bk8/arch/i386/mach-voyager/voyager_basic.c	2003-06-22 11:32:38.000000000 -0700
+++ linux-2.5.73-bk9/arch/i386/mach-voyager/voyager_basic.c	2003-07-01 04:51:34.000000000 -0700
@@ -284,7 +284,6 @@
 {
 	__u8 dumpval __attribute__((unused)) = inb(0xf823);
 	__u8 swnmi __attribute__((unused)) = inb(0xf813);
-	extern void show_stack(unsigned long *);
 
 	/* FIXME: assume dump switch pressed */
 	/* check to see if the dump switch was pressed */
@@ -302,7 +301,7 @@
 		}
 	}
 	printk(KERN_ERR "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n", smp_processor_id());
-	show_stack(NULL);
+	show_stack(NULL, NULL);
 	show_state();
 }
 
diff -urN linux-2.5.73-bk8/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S linux-2.5.73-bk9/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S
--- linux-2.5.73-bk8/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S	2003-06-22 11:33:03.000000000 -0700
+++ linux-2.5.73-bk9/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S	2003-07-01 04:51:34.000000000 -0700
@@ -115,6 +115,8 @@
 	nop
 #endif
 
+
+#ifdef CONFIG_ROMFS_FS
 	/*
 	 *	Move ROM filesystem above bss :-)
 	 */
@@ -135,6 +137,11 @@
 	move.l	%d0, -(%a1)
 	cmp.l	%a0, %a2			/* Check if at end */
 	bne	_copy_romfs
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
 
 	/*
 	 *	Zero out the bss region.
diff -urN linux-2.5.73-bk8/arch/m68knommu/platform/5282/pit.c linux-2.5.73-bk9/arch/m68knommu/platform/5282/pit.c
--- linux-2.5.73-bk8/arch/m68knommu/platform/5282/pit.c	2003-06-22 11:33:08.000000000 -0700
+++ linux-2.5.73-bk9/arch/m68knommu/platform/5282/pit.c	2003-07-01 04:51:34.000000000 -0700
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/param.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <asm/irq.h>
 #include <asm/coldfire.h>
 #include <asm/mcfpit.h>
diff -urN linux-2.5.73-bk8/arch/m68knommu/platform/5307/config.c linux-2.5.73-bk9/arch/m68knommu/platform/5307/config.c
--- linux-2.5.73-bk8/arch/m68knommu/platform/5307/config.c	2003-06-22 11:32:33.000000000 -0700
+++ linux-2.5.73-bk9/arch/m68knommu/platform/5307/config.c	2003-07-01 04:51:34.000000000 -0700
@@ -102,9 +102,12 @@
 {
 	mcf_setimr(MCFSIM_IMR_MASKALL);
 
-#if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
-    defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
-    defined(CONFIG_CLEOPATRA)
+#if defined(CONFIG_BOOTPARAM)
+	strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
+	commandp[size-1] = 0;
+#elif defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
+      defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
+      defined(CONFIG_CLEOPATRA)
 	/* Copy command line from FLASH to local buffer... */
 	memcpy(commandp, (char *) 0xf0004000, size);
 	commandp[size-1] = 0;
diff -urN linux-2.5.73-bk8/arch/sparc64/prom/init.c linux-2.5.73-bk9/arch/sparc64/prom/init.c
--- linux-2.5.73-bk8/arch/sparc64/prom/init.c	2003-06-22 11:33:34.000000000 -0700
+++ linux-2.5.73-bk9/arch/sparc64/prom/init.c	2003-07-01 04:51:35.000000000 -0700
@@ -36,6 +36,7 @@
 	int ints[3];
 	int node;
 	int i = 0;
+	int bufadjust;
 
 	prom_vers = PROM_P1275;
 
@@ -63,9 +64,19 @@
 	if (strncmp (buffer, "OBP ", 4))
 		goto strange_version;
 
-	/* Version field is expected to be 'OBP xx.yy.zz date...' */
+	/*
+	 * Version field is expected to be 'OBP xx.yy.zz date...'
+	 * However, Sun can't stick to this format very well, so
+	 * we need to check for 'OBP  xx.yy.zz date...' and adjust
+	 * accordingly. -spot
+	 */
+
+	if (strncmp (buffer, "OBP  ", 5))
+		bufadjust = 4;
+	else
+		bufadjust = 5;
 
-	p = buffer + 4;
+	p = buffer + bufadjust;
 	while (p && isdigit(*p) && i < 3) {
 		ints[i++] = simple_strtoul(p, NULL, 0);
 		if ((p = strchr(p, '.')) != NULL)
@@ -77,7 +88,7 @@
 	prom_rev = ints[1];
 	prom_prev = (ints[0] << 16) | (ints[1] << 8) | ints[2];
 
-	printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + 4);
+	printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + bufadjust);
 
 	prom_meminit();
 
diff -urN linux-2.5.73-bk8/drivers/ide/setup-pci.c linux-2.5.73-bk9/drivers/ide/setup-pci.c
--- linux-2.5.73-bk8/drivers/ide/setup-pci.c	2003-06-22 11:32:42.000000000 -0700
+++ linux-2.5.73-bk9/drivers/ide/setup-pci.c	2003-07-01 04:51:36.000000000 -0700
@@ -702,8 +702,9 @@
 	 * Can we trust the reported IRQ?
 	 */
 	pciirq = dev->irq;
-	
-	if ((dev->class & ~(0xfa)) != ((PCI_CLASS_STORAGE_IDE << 8) | 5)) {
+
+	/* Is it an "IDE storage" device in non-PCI mode? */
+	if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) {
 		if (noisy)
 			printk(KERN_INFO "%s: not 100%% native mode: "
 				"will probe irqs later\n", d->name);
diff -urN linux-2.5.73-bk8/drivers/mtd/maps/pcmciamtd.c linux-2.5.73-bk9/drivers/mtd/maps/pcmciamtd.c
--- linux-2.5.73-bk8/drivers/mtd/maps/pcmciamtd.c	2003-06-22 11:32:33.000000000 -0700
+++ linux-2.5.73-bk9/drivers/mtd/maps/pcmciamtd.c	2003-07-01 04:51:37.000000000 -0700
@@ -1,5 +1,5 @@
 /*
- * $Id: pcmciamtd.c,v 1.47 2003/05/28 13:36:14 dwmw2 Exp $
+ * $Id: pcmciamtd.c,v 1.48 2003/06/24 07:14:38 spse Exp $
  *
  * pcmciamtd.c - MTD driver for PCMCIA flash memory cards
  *
@@ -43,33 +43,32 @@
 static const int debug = 0;
 #endif
 
-#define err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg)
-#define info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg)
-#define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
+#define err(format, arg...) printk(KERN_ERR "pcmciamtd: " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING "pcmciamtd: " format "\n" , ## arg)
 
 
 #define DRIVER_DESC	"PCMCIA Flash memory card driver"
-#define DRIVER_VERSION	"$Revision: 1.47 $"
+#define DRIVER_VERSION	"$Revision: 1.48 $"
 
 /* Size of the PCMCIA address space: 26 bits = 64 MB */
 #define MAX_PCMCIA_ADDR	0x4000000
 
 struct pcmciamtd_dev {
-	struct list_head list;
 	dev_link_t	link;		/* PCMCIA link */
+	dev_node_t	node;		/* device node */
 	caddr_t		win_base;	/* ioremapped address of PCMCIA window */
 	unsigned int	win_size;	/* size of window */
-	unsigned int	cardsize;	/* size of whole card */
 	unsigned int	offset;		/* offset into card the window currently points at */
 	struct map_info	pcmcia_map;
 	struct mtd_info	*mtd_info;
-	u8		vpp;
+	int		vpp;
 	char		mtd_name[sizeof(struct cistpl_vers_1_t)];
 };
 
 
 static dev_info_t dev_info = "pcmciamtd";
-static LIST_HEAD(dev_list);
+static dev_link_t *dev_list;
 
 /* Module parameters */
 
@@ -99,7 +98,7 @@
 MODULE_PARM(mem_speed, "i");
 MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns");
 MODULE_PARM(force_size, "i");
-MODULE_PARM_DESC(force_size, "Force size of card in MB (1-64)");
+MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)");
 MODULE_PARM(setvpp, "i");
 MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)");
 MODULE_PARM(vpp, "i");
@@ -116,6 +115,11 @@
 	memreq_t mrq;
 	int ret;
 
+	if(!(dev->link.state & DEV_PRESENT)) {
+		DEBUG(1, "device removed state = 0x%4.4X", dev->link.state);
+		return 0;
+	}
+
 	mrq.CardOffset = to & ~(dev->win_size-1);
 	if(mrq.CardOffset != dev->offset) {
 		DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x",
@@ -238,11 +242,16 @@
 
 /* read/write{8,16} copy_{from,to} routines with direct access */
 
+#define DEV_REMOVED(x)  (!(*(u_int *)x->map_priv_1 & DEV_PRESENT))
+
 static u8 pcmcia_read8(struct map_info *map, unsigned long ofs)
 {
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 	u8 d;
 
+	if(DEV_REMOVED(map))
+		return 0;
+
 	d = readb(win_base + ofs);
 	DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d);
 	return d;
@@ -254,6 +263,9 @@
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 	u16 d;
 
+	if(DEV_REMOVED(map))
+		return 0;
+
 	d = readw(win_base + ofs);
 	DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d);
 	return d;
@@ -264,6 +276,9 @@
 {
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 
+	if(DEV_REMOVED(map))
+		return;
+
 	DEBUG(3, "to = %p from = %lu len = %u", to, from, len);
 	memcpy_fromio(to, win_base + from, len);
 }
@@ -273,6 +288,9 @@
 {
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 
+	if(DEV_REMOVED(map))
+		return;
+
 	DEBUG(3, "adr = 0x%08lx (%p)  data = 0x%02x", adr, win_base + adr, d);
 	writeb(d, win_base + adr);
 }
@@ -282,6 +300,9 @@
 {
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 
+	if(DEV_REMOVED(map))
+		return;
+
 	DEBUG(3, "adr = 0x%08lx (%p)  data = 0x%04x", adr, win_base + adr, d);
 	writew(d, win_base + adr);
 }
@@ -291,6 +312,9 @@
 {
 	caddr_t win_base = (caddr_t)map->map_priv_2;
 
+	if(DEV_REMOVED(map))
+		return;
+
 	DEBUG(3, "to = %lu from = %p len = %u", to, from, len);
 	memcpy_toio(win_base + to, from, len);
 }
@@ -323,40 +347,18 @@
 static void pcmciamtd_release(u_long arg)
 {
 	dev_link_t *link = (dev_link_t *)arg;
-	struct pcmciamtd_dev *dev = NULL;
-	int ret;
-	struct list_head *temp1, *temp2;
+	struct pcmciamtd_dev *dev = link->priv;
 
 	DEBUG(3, "link = 0x%p", link);
-	/* Find device in list */
-	list_for_each_safe(temp1, temp2, &dev_list) {
-		dev = list_entry(temp1, struct pcmciamtd_dev, list);
-		if(link == &dev->link)
-			break;
-	}
-	if(link != &dev->link) {
-		DEBUG(1, "Cant find %p in dev_list", link);
-		return;
-	}
 
-	if(dev) {
-		if(dev->mtd_info) {
-			del_mtd_device(dev->mtd_info);
-			dev->mtd_info = NULL;
-			MOD_DEC_USE_COUNT;
-		}
-		if (link->win) {
-			if(dev->win_base) {
-				iounmap(dev->win_base);
-				dev->win_base = NULL;
-			}
-			CardServices(ReleaseWindow, link->win);
+	if (link->win) {
+		if(dev->win_base) {
+			iounmap(dev->win_base);
+			dev->win_base = NULL;
 		}
-		ret = CardServices(ReleaseConfiguration, link->handle);
-		if(ret != CS_SUCCESS)
-			cs_error(link->handle, ReleaseConfiguration, ret);
-			
+		CardServices(ReleaseWindow, link->win);
 	}
+	CardServices(ReleaseConfiguration, link->handle);
 	link->state &= ~DEV_CONFIG;
 }
 
@@ -465,7 +467,6 @@
 	if(force_size) {
 		dev->pcmcia_map.size = force_size << 20;
 		DEBUG(2, "size forced to %dM", force_size);
-
 	}
 
 	if(buswidth) {
@@ -580,9 +581,8 @@
 	}
 	DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x",
 	      dev, req.Base, dev->win_base, req.Size);
-	dev->cardsize = 0;
-	dev->offset = 0;
 
+	dev->offset = 0;
 	dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
 	dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
 
@@ -614,9 +614,6 @@
 		cs_error(link->handle, RequestConfiguration, ret);
 	}
 
-	link->dev = NULL;
-	link->state &= ~DEV_CONFIG_PENDING;
-
 	if(mem_type == 1) {
 		mtd = do_map_probe("map_ram", &dev->pcmcia_map);
 	} else if(mem_type == 2) {
@@ -640,7 +637,6 @@
 
 	dev->mtd_info = mtd;
 	mtd->owner = THIS_MODULE;
-	dev->cardsize = mtd->size;
 
 	if(new_name) {
 		int size = 0;
@@ -649,19 +645,19 @@
 		   size */
 		if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
 			size = mtd->size >> 10;
-			unit = 'K'; 
+			unit = 'K';
 		} else {
 			size = mtd->size >> 20;
 			unit = 'M';
 		}
-		sprintf(mtd->name, "%d%ciB %s", size, unit, "PCMCIA Memory card");
+		snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%d%ciB %s", size, unit, "PCMCIA Memory card");
 	}
 
 	/* If the memory found is fits completely into the mapped PCMCIA window,
 	   use the faster non-remapping read/write functions */
-	if(dev->cardsize <= dev->win_size) {
+	if(mtd->size <= dev->win_size) {
 		DEBUG(1, "Using non remapping memory functions");
-
+		dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state);
 		dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base;
 		dev->pcmcia_map.read8 = pcmcia_read8;
 		dev->pcmcia_map.read16 = pcmcia_read16;
@@ -671,16 +667,17 @@
 		dev->pcmcia_map.copy_to = pcmcia_copy_to;
 	}
 
-	MOD_INC_USE_COUNT;
 	if(add_mtd_device(mtd)) {
+		map_destroy(mtd);
 		dev->mtd_info = NULL;
-		MOD_DEC_USE_COUNT;
 		err("Couldnt register MTD device");
 		pcmciamtd_release((u_long)link);
 		return;
 	}
-	DEBUG(1, "mtd added @ %p mtd->priv = %p", mtd, mtd->priv);
-
+	snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
+	info("mtd%d: %s", mtd->index, mtd->name);
+	link->state &= ~DEV_CONFIG_PENDING;
+	link->dev = &dev->node;
 	return;
 
  cs_failed:
@@ -707,8 +704,14 @@
 	case CS_EVENT_CARD_REMOVAL:
 		DEBUG(2, "EVENT_CARD_REMOVAL");
 		link->state &= ~DEV_PRESENT;
-		if (link->state & DEV_CONFIG)
+		if (link->state & DEV_CONFIG) {
+			struct pcmciamtd_dev *dev = link->priv;
+			if(dev->mtd_info) {
+				del_mtd_device(dev->mtd_info);
+				info("mtd%d: Removed", dev->mtd_info->index);
+			}
 			mod_timer(&link->release, jiffies + HZ/20);
+		}
 		break;
 	case CS_EVENT_CARD_INSERTION:
 		DEBUG(2, "EVENT_CARD_INSERTION");
@@ -746,47 +749,23 @@
 
 static void pcmciamtd_detach(dev_link_t *link)
 {
-	int ret;
-	struct pcmciamtd_dev *dev = NULL;
-	struct list_head *temp1, *temp2;
-
 	DEBUG(3, "link=0x%p", link);
 
-	/* Find device in list */
-	list_for_each_safe(temp1, temp2, &dev_list) {
-		dev = list_entry(temp1, struct pcmciamtd_dev, list);
-		if(link == &dev->link)
-			break;
-	}
-	if(link != &dev->link) {
-		DEBUG(1, "Cant find %p in dev_list", link);
-		return;
-	}
-	
 	del_timer(&link->release);
 
-	if(!dev) {
-		DEBUG(3, "dev is NULL");
-		return;
-	}
-
-	if (link->state & DEV_CONFIG) {
-		//pcmciamtd_release((u_long)link);
-		DEBUG(3, "DEV_CONFIG set");
-		link->state |= DEV_STALE_LINK;
-		return;
+	if(link->state & DEV_CONFIG) {
+		pcmciamtd_release((u_long)link);
 	}
 
 	if (link->handle) {
+		int ret;
 		DEBUG(2, "Deregistering with card services");
 		ret = CardServices(DeregisterClient, link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
-	DEBUG(3, "Freeing dev (%p)", dev);
-	list_del(&dev->list);
-	link->priv = NULL;
-	kfree(dev);
+
+	link->state |= DEV_STALE_LINK;
 }
 
 
@@ -808,15 +787,18 @@
 	DEBUG(1, "dev=0x%p", dev);
 
 	memset(dev, 0, sizeof(*dev));
-	link = &dev->link; link->priv = dev;
+	link = &dev->link;
+	link->priv = dev;
 
+	init_timer(&link->release);
 	link->release.function = &pcmciamtd_release;
 	link->release.data = (u_long)link;
 
 	link->conf.Attributes = 0;
 	link->conf.IntType = INT_MEMORY;
 
-	list_add(&dev->list, &dev_list);
+	link->next = dev_list;
+	dev_list = link;
 
 	/* Register with Card Services */
 	client_reg.dev_info = &dev_info;
@@ -835,19 +817,21 @@
 		pcmciamtd_detach(link);
 		return NULL;
 	}
-
+	DEBUG(2, "link = %p", link);
 	return link;
 }
 
+
 static struct pcmcia_driver pcmciamtd_driver = {
-	.owner		= THIS_MODULE,
 	.drv		= {
-		.name	= "pcmciamtd",
+		.name	= "pcmciamtd"
 	},
 	.attach		= pcmciamtd_attach,
 	.detach		= pcmciamtd_detach,
+	.owner		= THIS_MODULE
 };
 
+
 static int __init init_pcmciamtd(void)
 {
 	info(DRIVER_DESC " " DRIVER_VERSION);
@@ -864,25 +848,41 @@
 		info("bad mem_type (%d), using default", mem_type);
 		mem_type = 0;
 	}
-
 	return pcmcia_register_driver(&pcmciamtd_driver);
 }
 
 
 static void __exit exit_pcmciamtd(void)
 {
-	struct list_head *temp1, *temp2;
-
 	DEBUG(1, DRIVER_DESC " unloading");
-
 	pcmcia_unregister_driver(&pcmciamtd_driver);
 
-	/* XXX: this really needs to move into generic code.. */
-	list_for_each_safe(temp1, temp2, &dev_list) {
-		dev_link_t *link = &list_entry(temp1, struct pcmciamtd_dev, list)->link;
-		if (link && (link->state & DEV_CONFIG)) {
-			pcmciamtd_release((u_long)link);
-			pcmciamtd_detach(link);
+	while(dev_list) {
+		dev_link_t *link = dev_list;
+
+		dev_list = link->next;
+		if (link) {
+			struct pcmciamtd_dev *dev = link->priv;
+			
+ 			if(dev) {
+				if(link->state & DEV_PRESENT) {
+					if (!(link->state & DEV_STALE_LINK)) {
+						pcmciamtd_detach(link);
+					}
+					link->state &= ~DEV_PRESENT;
+					if(dev->mtd_info) {
+						del_mtd_device(dev->mtd_info);
+						info("mtd%d: Removed",
+						     dev->mtd_info->index);
+					}
+				}
+				if(dev->mtd_info) {
+					DEBUG(2, "Destroying map for mtd%d",
+					      dev->mtd_info->index);
+					map_destroy(dev->mtd_info);
+				}
+				kfree(dev);
+			}
 		}
 	}
 }
diff -urN linux-2.5.73-bk8/drivers/pcmcia/cs.c linux-2.5.73-bk9/drivers/pcmcia/cs.c
--- linux-2.5.73-bk8/drivers/pcmcia/cs.c	2003-06-22 11:32:38.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/cs.c	2003-07-01 04:51:38.000000000 -0700
@@ -231,18 +231,6 @@
 
 ======================================================================*/
 
-static int register_callback(struct pcmcia_socket *s, void (*handler)(void *, unsigned int), void * info)
-{
-	int error;
-
-	if (handler && !try_module_get(s->ss_entry->owner))
-		return -ENODEV;
-	error = s->ss_entry->register_callback(s, handler, info);
-	if (!handler)
-		module_put(s->ss_entry->owner);
-	return error;
-}
-
 static int get_socket_status(struct pcmcia_socket *s, int *val)
 {
 	return s->ss_entry->get_status(s, val);
@@ -363,6 +351,7 @@
 
 	wait_for_completion(&socket->thread_done);
 	BUG_ON(!socket->thread);
+	pcmcia_parse_events(socket, SS_DETECT);
 
 	return 0;
 }
@@ -723,6 +712,9 @@
 {
 	int ret;
 
+	if (!try_module_get(skt->owner))
+		return CS_NO_CARD;
+
 	ret = socket_setup(skt, setup_delay);
 	if (ret == CS_SUCCESS) {
 #ifdef CONFIG_CARDBUS
@@ -733,8 +725,10 @@
 #endif
 		send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
 		skt->socket.flags &= ~SS_DEBOUNCED;
-	} else
+	} else {
 		socket_shutdown(skt);
+		module_put(skt->owner);
+	}
 
 	return ret;
 }
@@ -778,14 +772,55 @@
 			send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW);
 		}
 		skt->socket.flags &= ~SS_DEBOUNCED;
-	} else
+	} else {
+		unsigned int old_state = skt->state;
 		socket_shutdown(skt);
+		if (old_state & SOCKET_PRESENT)
+			module_put(skt->owner);
+	}
 
 	skt->state &= ~SOCKET_SUSPEND;
 
 	return CS_SUCCESS;
 }
 
+static void socket_remove(struct pcmcia_socket *skt)
+{
+	socket_shutdown(skt);
+	module_put(skt->owner);
+}
+
+/*
+ * Process a socket card detect status change.
+ *
+ * If we don't have a card already present, delay the detect event for
+ * about 20ms (to be on the safe side) before reading the socket status.
+ *
+ * Some i82365-based systems send multiple SS_DETECT events during card
+ * insertion, and the "card present" status bit seems to bounce.  This
+ * will probably be true with GPIO-based card detection systems after
+ * the product has aged.
+ */
+static void socket_detect_change(struct pcmcia_socket *skt)
+{
+	if (!(skt->state & SOCKET_SUSPEND)) {
+		int status;
+
+		if (!(skt->state & SOCKET_PRESENT)) {
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			schedule_timeout(cs_to_timeout(2));
+		}
+
+		get_socket_status(skt, &status);
+		if ((skt->state & SOCKET_PRESENT) &&
+		     !(status & SS_DETECT))
+			socket_remove(skt);
+		if (!(skt->state & SOCKET_PRESENT) &&
+		    (status & SS_DETECT))
+			socket_insert(skt);
+	}
+}
+
 static int pccardd(void *__skt)
 {
 	struct pcmcia_socket *skt = __skt;
@@ -809,17 +844,8 @@
 
 		if (events) {
 			down(&skt->skt_sem);
-			if (events & SS_DETECT && !(skt->state & SOCKET_SUSPEND)) {
-				int status;
-
-				get_socket_status(skt, &status);
-				if ((skt->state & SOCKET_PRESENT) &&
-				     !(status & SS_DETECT))
-					socket_shutdown(skt);
-				if (!(skt->state & SOCKET_PRESENT) &&
-				    (status & SS_DETECT))
-					socket_insert(skt);
-			}
+			if (events & SS_DETECT)
+				socket_detect_change(skt);
 			if (events & SS_BATDEAD)
 				send_event(skt, CS_EVENT_BATTERY_DEAD, CS_EVENT_PRI_LOW);
 			if (events & SS_BATWARN)
@@ -839,21 +865,17 @@
 	}
 	remove_wait_queue(&skt->thread_wait, &wait);
 
-	socket_shutdown(skt);
-
 	complete_and_exit(&skt->thread_done, 0);
 }
 
-static void parse_events(void *info, u_int events)
+void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
 {
-	struct pcmcia_socket *s = info;
-
 	spin_lock(&s->thread_lock);
 	s->thread_events |= events;
 	spin_unlock(&s->thread_lock);
 
 	wake_up(&s->thread_wait);
-} /* parse_events */
+} /* pcmcia_parse_events */
 
 
 /*======================================================================
@@ -1114,9 +1136,6 @@
 	handle->event_handler = NULL;
     }
 
-    if (--s->real_clients == 0)
-        register_callback(s, NULL, NULL);
-    
     return CS_SUCCESS;
 } /* deregister_client */
 
@@ -1531,11 +1550,6 @@
     if (client == NULL)
 	return CS_OUT_OF_RESOURCE;
 
-    if (++s->real_clients == 1) {
-	register_callback(s, &parse_events, s);
-	parse_events(s, SS_DETECT);
-    }
-
     *handle = client;
     client->state &= ~CLIENT_UNBOUND;
     client->Socket = s;
@@ -2213,7 +2227,7 @@
 		if (ret != 0)
 			break;
 
-		socket_shutdown(skt);
+		socket_remove(skt);
 		ret = CS_SUCCESS;
 	} while (0);
 	up(&skt->skt_sem);
@@ -2504,6 +2518,7 @@
 EXPORT_SYMBOL(dead_socket);
 EXPORT_SYMBOL(CardServices);
 EXPORT_SYMBOL(MTDHelperEntry);
+EXPORT_SYMBOL(pcmcia_parse_events);
 
 struct class pcmcia_socket_class = {
 	.name = "pcmcia_socket",
diff -urN linux-2.5.73-bk8/drivers/pcmcia/i82092.c linux-2.5.73-bk9/drivers/pcmcia/i82092.c
--- linux-2.5.73-bk8/drivers/pcmcia/i82092.c	2003-06-22 11:33:36.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/i82092.c	2003-07-01 04:51:38.000000000 -0700
@@ -64,10 +64,8 @@
 
 /* the pccard structure and its functions */
 static struct pccard_operations i82092aa_operations = {
-	.owner			= THIS_MODULE,
 	.init 		 	= i82092aa_init,
 	.suspend	   	= i82092aa_suspend,
-	.register_callback 	= i82092aa_register_callback,
 	.get_status		= i82092aa_get_status,
 	.get_socket		= i82092aa_get_socket,
 	.set_socket		= i82092aa_set_socket,
@@ -85,12 +83,6 @@
 				    3 = operational card */
 	int 	io_base; 	/* base io address of the socket */
 	
-	unsigned int pending_events; /* Pending events on this interface */
-	
-	void	(*handler)(void *info, u_int events); 
-				/* callback to the driver of the card */
-	void	*info;		/* to be passed to the handler */
-	
 	struct pcmcia_socket socket;
 	struct pci_dev *dev;	/* The PCI device for the socket */
 };
@@ -142,6 +134,7 @@
 		sockets[i].socket.map_size = 0x1000;
 		sockets[i].socket.irq_mask = 0;
 		sockets[i].socket.pci_irq  = dev->irq;
+		sockets[i].socket.owner = THIS_MODULE;
 
 		sockets[i].number = i;
 		
@@ -324,23 +317,6 @@
 
 /* Interrupt handler functionality */
 
-static void i82092aa_bh(void *dummy)
-{
-        unsigned int events;
-	int i;
-                
-        for (i=0; i < socket_count; i++) {
-        	events = xchg(&(sockets[i].pending_events),0);
-        	printk("events = %x \n",events);
-                if (sockets[i].handler)
-                	sockets[i].handler(sockets[i].info, events);
-	}
-}
-                                                                                                                                        
-
-static DECLARE_WORK(i82092aa_task, i82092aa_bh, NULL);
-        
-
 static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs)
 {
 	int i;
@@ -367,8 +343,7 @@
 			
 			csc = indirect_read(i,I365_CSC); /* card status change register */
 			
-			if ((csc==0) ||  /* no events on this socket */
-			   (sockets[i].handler==NULL)) /* no way to handle events */
+			if (csc==0)  /* no events on this socket */
 			   	continue;
 			handled = 1;
 			events = 0;
@@ -389,8 +364,7 @@
 			}
 			
 			if (events) {
-				sockets[i].pending_events |= events;
-				schedule_work(&i82092aa_task);
+				pcmcia_parse_events(&sockets[i].socket, events);
 			}
 			active |= events;
 		}
@@ -475,16 +449,6 @@
         return retval;
 }
        
-static int i82092aa_register_callback(struct pcmcia_socket *socket, void (*handler)(void *, unsigned int), void * info)
-{
-	unsigned int sock = container_of(socket, struct socket_info, socket)->number;
-	enter("i82092aa_register_callback");
-	sockets[sock].handler = handler;
-        sockets[sock].info = info;
-	leave("i82092aa_register_callback");
-	return 0;
-} /* i82092aa_register_callback */
-                                        
 static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
 {
 	unsigned int sock = container_of(socket, struct socket_info, socket)->number;
diff -urN linux-2.5.73-bk8/drivers/pcmcia/i82092aa.h linux-2.5.73-bk9/drivers/pcmcia/i82092aa.h
--- linux-2.5.73-bk8/drivers/pcmcia/i82092aa.h	2003-06-22 11:32:33.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/i82092aa.h	2003-07-01 04:51:38.000000000 -0700
@@ -35,7 +35,6 @@
 static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem);
 static int i82092aa_init(struct pcmcia_socket *socket);
 static int i82092aa_suspend(struct pcmcia_socket *socket);
-static int i82092aa_register_callback(struct pcmcia_socket *socket, void (*handler)(void *, unsigned int), void * info);
 
 #endif
 
diff -urN linux-2.5.73-bk8/drivers/pcmcia/i82365.c linux-2.5.73-bk9/drivers/pcmcia/i82365.c
--- linux-2.5.73-bk8/drivers/pcmcia/i82365.c	2003-06-22 11:33:16.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/i82365.c	2003-07-01 04:51:38.000000000 -0700
@@ -164,8 +164,6 @@
     ioaddr_t		ioaddr;
     u_short		psock;
     u_char		cs_irq, intr;
-    void		(*handler)(void *info, u_int events);
-    void		*info;
     union {
 	cirrus_state_t		cirrus;
 	vg46x_state_t		vg46x;
@@ -863,35 +861,6 @@
 
 /*====================================================================*/
 
-static u_int pending_events[8];
-static spinlock_t pending_event_lock = SPIN_LOCK_UNLOCKED;
-
-static void pcic_bh(void *dummy)
-{
-	u_int events;
-	int i;
-
-	for (i=0; i < sockets; i++) {
-		spin_lock_irq(&pending_event_lock);
-		events = pending_events[i];
-		pending_events[i] = 0;
-		spin_unlock_irq(&pending_event_lock);
-		/* 
-		SS_DETECT events need a small delay here. The reason for this is that 
-		the "is there a card" electronics need time to see the card after the
-		"we have a card coming in" electronics have seen it. 
-		*/
-		if (events & SS_DETECT) 
-			mdelay(4);
-		if (socket[i].handler)
-			socket[i].handler(socket[i].info, events);
-	}
-}
-
-static DECLARE_WORK(pcic_task, pcic_bh, NULL);
-
-static unsigned long last_detect_jiffies;
-
 static irqreturn_t pcic_interrupt(int irq, void *dev,
 				    struct pt_regs *regs)
 {
@@ -911,26 +880,12 @@
 	    handled = 1;
 	    ISA_LOCK(i, flags);
 	    csc = i365_get(i, I365_CSC);
-	    if ((csc == 0) || (!socket[i].handler) ||
-		(i365_get(i, I365_IDENT) & 0x70)) {
+	    if ((csc == 0) || (i365_get(i, I365_IDENT) & 0x70)) {
 		ISA_UNLOCK(i, flags);
 		continue;
 	    }
 	    events = (csc & I365_CSC_DETECT) ? SS_DETECT : 0;
-	    
-	    
-	    /* Several sockets will send multiple "new card detected"
-	       events in rapid succession. However, the rest of the pcmcia expects 
-	       only one such event. We just ignore these events by having a
-               timeout */
-
-	    if (events) {
-	    	if ((jiffies - last_detect_jiffies)<(HZ/20)) 
-	    		events = 0;
-	    	last_detect_jiffies = jiffies;
-	    	
-	    }
-	
+
 	    if (i365_get(i, I365_INTCTL) & I365_PC_IOCARD)
 		events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
 	    else {
@@ -941,12 +896,9 @@
 	    ISA_UNLOCK(i, flags);
 	    DEBUG(2, "i82365: socket %d event 0x%02x\n", i, events);
 
-	    if (events) {
-		    spin_lock(&pending_event_lock);
-		    pending_events[i] |= events;
-		    spin_unlock(&pending_event_lock);
-		    schedule_work(&pcic_task);
-	    }
+	    if (events)
+		pcmcia_parse_events(&socket[i].socket, events);
+
 	    active |= events;
 	}
 	if (!active) break;
@@ -968,16 +920,6 @@
 
 /*====================================================================*/
 
-static int pcic_register_callback(struct pcmcia_socket *s, void (*handler)(void *, unsigned int), void * info)
-{
-    unsigned int sock = container_of(s, struct i82365_socket, socket)->number;
-    socket[sock].handler = handler;
-    socket[sock].info = info;
-    return 0;
-} /* pcic_register_callback */
-
-/*====================================================================*/
-
 static int i365_get_status(u_short sock, u_int *value)
 {
     u_int status;
@@ -1400,10 +1342,8 @@
 }
 
 static struct pccard_operations pcic_operations = {
-	.owner			= THIS_MODULE,
 	.init			= pcic_init,
 	.suspend		= pcic_suspend,
-	.register_callback	= pcic_register_callback,
 	.get_status		= pcic_get_status,
 	.get_socket		= pcic_get_socket,
 	.set_socket		= pcic_set_socket,
@@ -1464,6 +1404,7 @@
     for (i = 0; i < sockets; i++) {
 	    socket[i].socket.dev.dev = &i82365_device.dev;
 	    socket[i].socket.ss_entry = &pcic_operations;
+	    socket[i].socket.owner = THIS_MODULE;
 	    socket[i].number = i;
 	    ret = pcmcia_register_socket(&socket[i].socket);	    
 	    if (ret && i--) {
diff -urN linux-2.5.73-bk8/drivers/pcmcia/sa11xx_core.c linux-2.5.73-bk9/drivers/pcmcia/sa11xx_core.c
--- linux-2.5.73-bk8/drivers/pcmcia/sa11xx_core.c	2003-06-22 11:32:35.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/sa11xx_core.c	2003-07-01 04:51:38.000000000 -0700
@@ -38,15 +38,13 @@
 #include <linux/init.h>
 #include <linux/config.h>
 #include <linux/cpufreq.h>
-#include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/kernel.h>
-#include <linux/workqueue.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
 #include <linux/notifier.h>
-#include <linux/version.h>
 #include <linux/interrupt.h>
+#include <linux/spinlock.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -263,29 +261,27 @@
 	return ret;
 }
 
+static spinlock_t status_lock = SPIN_LOCK_UNLOCKED;
 
-/* sa1100_pcmcia_task_handler()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Processes serviceable socket events using the "eventd" thread context.
- *
- * Event processing (specifically, the invocation of the Card Services event
- * callback) occurs in this thread rather than in the actual interrupt
- * handler due to the use of scheduling operations in the PCMCIA core.
+/* sa1100_check_status()
+ * ^^^^^^^^^^^^^^^^^^^^^
  */
-static void sa1100_pcmcia_task_handler(void *data)
+static void sa1100_check_status(struct sa1100_pcmcia_socket *skt)
 {
-	struct sa1100_pcmcia_socket *skt = data;
 	unsigned int events;
 
 	DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
 
 	do {
 		unsigned int status;
+		unsigned long flags;
 
 		status = sa1100_pcmcia_skt_state(skt);
 
+		spin_lock_irqsave(&status_lock, flags);
 		events = (status ^ skt->status) & skt->cs_state.csc_mask;
 		skt->status = status;
+		spin_unlock_irqrestore(&status_lock, flags);
 
 		DEBUG(2, "events: %s%s%s%s%s%s\n",
 			events == 0         ? "<NONE>"   : "",
@@ -295,8 +291,8 @@
 			events & SS_BATWARN ? "BATWARN " : "",
 			events & SS_STSCHG  ? "STSCHG "  : "");
 
-		if (events && skt->handler != NULL)
-			skt->handler(skt->handler_info, events);
+		if (events)
+			pcmcia_parse_events(&skt->socket, events);
 	} while (events);
 }
 
@@ -311,7 +307,7 @@
 
 	mod_timer(&skt->poll_timer, jiffies + SA1100_PCMCIA_POLL_PERIOD);
 
-	schedule_work(&skt->work);
+	sa1100_check_status(skt);
 }
 
 
@@ -330,44 +326,11 @@
 
 	DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
 
-	schedule_work(&skt->work);
+	sa1100_check_status(skt);
 
 	return IRQ_HANDLED;
 }
 
-/* sa1100_pcmcia_register_callback()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the register_callback() operation for the in-kernel
- * PCMCIA service (formerly SS_RegisterCallback in Card Services). If 
- * the function pointer `handler' is not NULL, remember the callback 
- * location in the state for `sock', and increment the usage counter 
- * for the driver module. (The callback is invoked from the interrupt
- * service routine, sa1100_pcmcia_interrupt(), to notify Card Services
- * of interesting events.) Otherwise, clear the callback pointer in the
- * socket state and decrement the module usage count.
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_register_callback(struct pcmcia_socket *sock,
-				void (*handler)(void *, unsigned int),
-				void *info)
-{
-	struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
-	if (handler) {
-		if (!try_module_get(skt->ops->owner))
-			return -ENODEV;
-		skt->handler_info = info;
-		skt->handler = handler;
-	} else {
-		skt->handler = NULL;
-		module_put(skt->ops->owner);
-	}
-
-	return 0;
-}
-
 
 /* sa1100_pcmcia_get_status()
  * ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -655,10 +618,8 @@
 
 
 static struct pccard_operations sa11xx_pcmcia_operations = {
-	.owner			= THIS_MODULE,
 	.init			= sa1100_pcmcia_sock_init,
 	.suspend		= sa1100_pcmcia_suspend,
-	.register_callback	= sa1100_pcmcia_register_callback,
 	.get_status		= sa1100_pcmcia_get_status,
 	.get_socket		= sa1100_pcmcia_get_socket,
 	.set_socket		= sa1100_pcmcia_set_socket,
@@ -765,10 +726,9 @@
 		memset(skt, 0, sizeof(*skt));
 
 		skt->socket.ss_entry = &sa11xx_pcmcia_operations;
+		skt->socket.owner = ops->owner;
 		skt->socket.dev.dev = dev;
 
-		INIT_WORK(&skt->work, sa1100_pcmcia_task_handler, skt);
-
 		init_timer(&skt->poll_timer);
 		skt->poll_timer.function = sa1100_pcmcia_poll_event;
 		skt->poll_timer.data = (unsigned long)skt;
diff -urN linux-2.5.73-bk8/drivers/pcmcia/sa11xx_core.h linux-2.5.73-bk9/drivers/pcmcia/sa11xx_core.h
--- linux-2.5.73-bk8/drivers/pcmcia/sa11xx_core.h	2003-06-22 11:32:59.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/sa11xx_core.h	2003-07-01 04:51:38.000000000 -0700
@@ -59,8 +59,6 @@
 
 	unsigned int		status;
 	socket_state_t		cs_state;
-	void			(*handler)(void *, unsigned int);
-	void			*handler_info;
 
 	unsigned short		spd_io[MAX_IO_WIN];
 	unsigned short		spd_mem[MAX_WIN];
@@ -75,7 +73,6 @@
 	unsigned int		irq_state;
 
 	struct timer_list	poll_timer;
-	struct work_struct	work;
 };
 
 struct pcmcia_low_level {
diff -urN linux-2.5.73-bk8/drivers/pcmcia/tcic.c linux-2.5.73-bk9/drivers/pcmcia/tcic.c
--- linux-2.5.73-bk8/drivers/pcmcia/tcic.c	2003-06-22 11:32:56.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/tcic.c	2003-07-01 04:51:38.000000000 -0700
@@ -116,8 +116,6 @@
 
 struct tcic_socket {
     u_short	psock;
-    void	(*handler)(void *info, u_int events);
-    void	*info;
     u_char	last_sstat;
     u_char	id;
     struct pcmcia_socket	socket;
@@ -433,10 +431,9 @@
     for (i = 0; i < sock; i++) {
 	if ((i == ignore) || is_active(i)) continue;
 	socket_table[sockets].psock = i;
-	socket_table[sockets].handler = NULL;
-	socket_table[sockets].info = NULL;
 	socket_table[sockets].id = get_tcic_id();
 
+	socket_table[sockets].socket.owner = THIS_MODULE;
 	/* only 16-bit cards, memory windows must be size-aligned */
 	/* No PCI or CardBus support */
 	socket_table[sockets].socket.features = SS_CAP_PCCARD | SS_CAP_MEM_ALIGN;
@@ -558,26 +555,6 @@
 
 /*====================================================================*/
 
-static u_int pending_events[2];
-static spinlock_t pending_event_lock = SPIN_LOCK_UNLOCKED;
-
-static void tcic_bh(void *dummy)
-{
-	u_int events;
-	int i;
-
-	for (i=0; i < sockets; i++) {
-		spin_lock_irq(&pending_event_lock);
-		events = pending_events[i];
-		pending_events[i] = 0;
-		spin_unlock_irq(&pending_event_lock);
-		if (socket_table[i].handler)
-			socket_table[i].handler(socket_table[i].info, events);
-	}
-}
-
-static DECLARE_WORK(tcic_task, tcic_bh, NULL);
-
 static irqreturn_t tcic_interrupt(int irq, void *dev, struct pt_regs *regs)
 {
     int i, quick = 0;
@@ -605,7 +582,7 @@
 	    tcic_setb(TCIC_ICSR, TCIC_ICSR_CLEAR);
 	    quick = 1;
 	}
-	if ((latch == 0) || (socket_table[psock].handler == NULL))
+	if (latch == 0)
 	    continue;
 	events = (latch & TCIC_SSTAT_CD) ? SS_DETECT : 0;
 	events |= (latch & TCIC_SSTAT_WP) ? SS_WRPROT : 0;
@@ -617,10 +594,7 @@
 	    events |= (latch & TCIC_SSTAT_LBAT2) ? SS_BATWARN : 0;
 	}
 	if (events) {
-		spin_lock(&pending_event_lock);
-		pending_events[i] |= events;
-		spin_unlock(&pending_event_lock);
-		schedule_work(&tcic_task);
+		pcmcia_parse_events(&socket_table[i].socket, events);
 	}
     }
 
@@ -645,16 +619,6 @@
 
 /*====================================================================*/
 
-static int tcic_register_callback(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info)
-{
-    u_short psock = container_of(sock, struct tcic_socket, socket)->psock;
-    socket_table[psock].handler = handler;
-    socket_table[psock].info = info;
-    return 0;
-} /* tcic_register_callback */
-
-/*====================================================================*/
-
 static int tcic_get_status(struct pcmcia_socket *sock, u_int *value)
 {
     u_short psock = container_of(sock, struct tcic_socket, socket)->psock;
@@ -915,10 +879,8 @@
 }
 
 static struct pccard_operations tcic_operations = {
-	.owner		   = THIS_MODULE,
 	.init		   = tcic_init,
 	.suspend	   = tcic_suspend,
-	.register_callback = tcic_register_callback,
 	.get_status	   = tcic_get_status,
 	.get_socket	   = tcic_get_socket,
 	.set_socket	   = tcic_set_socket,
diff -urN linux-2.5.73-bk8/drivers/pcmcia/yenta_socket.c linux-2.5.73-bk9/drivers/pcmcia/yenta_socket.c
--- linux-2.5.73-bk8/drivers/pcmcia/yenta_socket.c	2003-07-01 04:51:30.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/yenta_socket.c	2003-07-01 04:51:38.000000000 -0700
@@ -250,7 +250,6 @@
 
 	if (state->flags & SS_DEBOUNCED) {
 		/* The insertion debounce period has ended.  Clear any pending insertion events */
-		socket->events &= ~SS_DETECT;
 		state->flags &= ~SS_DEBOUNCED;		/* SS_DEBOUNCED is oneshot */
 	}
 	yenta_set_power(socket, state);
@@ -420,19 +419,6 @@
 }
 
 
-static void yenta_bh(void *data)
-{
-	struct yenta_socket *socket = data;
-	unsigned int events;
-
-	spin_lock_irq(&socket->event_lock);
-	events = socket->events;
-	socket->events = 0;
-	spin_unlock_irq(&socket->event_lock);
-	if (socket->handler)
-		socket->handler(socket->info, events);
-}
-
 static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	unsigned int events;
@@ -440,10 +426,7 @@
 
 	events = yenta_events(socket);
 	if (events) {
-		spin_lock(&socket->event_lock);
-		socket->events |= events;
-		spin_unlock(&socket->event_lock);
-		schedule_work(&socket->tq_task);
+		pcmcia_parse_events(&socket->socket, events);
 		return IRQ_HANDLED;
 	}
 	return IRQ_NONE;
@@ -771,21 +754,9 @@
 }
 
 
-static int yenta_register_callback(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info)
-{
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
-
-	socket->handler = handler;
-	socket->info = info;
-	return 0;
-}
-
-
 static struct pccard_operations yenta_socket_operations = {
-	.owner			= THIS_MODULE,
 	.init			= yenta_init,
 	.suspend		= yenta_suspend,
-	.register_callback	= yenta_register_callback,
 	.get_status		= yenta_get_status,
 	.get_socket		= yenta_get_socket,
 	.set_socket		= yenta_set_socket,
@@ -860,11 +831,11 @@
 	socket->socket.ss_entry = &yenta_socket_operations;
 	socket->socket.dev.dev = &dev->dev;
 	socket->socket.driver_data = socket;
+	socket->socket.owner = THIS_MODULE;
 
 	/* prepare struct yenta_socket */
 	socket->dev = dev;
 	pci_set_drvdata(dev, socket);
-	spin_lock_init(&socket->event_lock);
 
 	/*
 	 * Do some basic sanity checking..
@@ -907,8 +878,6 @@
 
 	/* We must finish initialization here */
 
-	INIT_WORK(&socket->tq_task, yenta_bh, socket);
-
 	if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, SA_SHIRQ, socket->dev->dev.name, socket)) {
 		/* No IRQ or request_irq failed. Poll */
 		socket->cb_irq = 0; /* But zero is a valid IRQ number. */
diff -urN linux-2.5.73-bk8/drivers/pcmcia/yenta_socket.h linux-2.5.73-bk9/drivers/pcmcia/yenta_socket.h
--- linux-2.5.73-bk8/drivers/pcmcia/yenta_socket.h	2003-06-22 11:32:40.000000000 -0700
+++ linux-2.5.73-bk9/drivers/pcmcia/yenta_socket.h	2003-07-01 04:51:38.000000000 -0700
@@ -99,11 +99,6 @@
 	struct pci_dev *dev;
 	int cb_irq, io_irq;
 	void *base;
-	void (*handler)(void *, unsigned int);
-	void *info;
-	spinlock_t event_lock;
-	unsigned int events;
-	struct work_struct tq_task;
 	struct timer_list poll_timer;
 
 	struct pcmcia_socket socket;
diff -urN linux-2.5.73-bk8/drivers/scsi/53c700.c linux-2.5.73-bk9/drivers/scsi/53c700.c
--- linux-2.5.73-bk8/drivers/scsi/53c700.c	2003-06-22 11:32:34.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/53c700.c	2003-07-01 04:51:38.000000000 -0700
@@ -133,7 +133,6 @@
 #include <asm/byteorder.h>
 #include <linux/blk.h>
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
 #include "scsi.h"
@@ -564,8 +563,7 @@
 {
 	if(SCp->sc_data_direction != SCSI_DATA_NONE &&
 	   SCp->sc_data_direction != SCSI_DATA_UNKNOWN) {
-		enum dma_data_direction direction = 
-			(enum dma_data_direction)scsi_to_pci_dma_dir(SCp->sc_data_direction);
+		enum dma_data_direction direction = SCp->sc_data_direction;
 		if(SCp->use_sg) {
 			dma_unmap_sg(hostdata->dev, SCp->buffer,
 				     SCp->use_sg, direction);
@@ -1842,7 +1840,7 @@
 	}
 
 	/* now build the scatter gather list */
-	direction = (enum dma_data_direction)scsi_to_pci_dma_dir(SCp->sc_data_direction);
+	direction = SCp->sc_data_direction;
 	if(move_ins != 0) {
 		int i;
 		int sg_count;
@@ -2039,8 +2037,15 @@
 	return 0;
 }
 
+/* NULL exit routine to keep modutils happy */
+STATIC void __exit
+NCR_700_exit(void)
+{
+}
+
 EXPORT_SYMBOL(NCR_700_detect);
 EXPORT_SYMBOL(NCR_700_release);
 EXPORT_SYMBOL(NCR_700_intr);
 
 module_init(NCR_700_init);
+module_exit(NCR_700_exit);
diff -urN linux-2.5.73-bk8/drivers/scsi/Kconfig linux-2.5.73-bk9/drivers/scsi/Kconfig
--- linux-2.5.73-bk8/drivers/scsi/Kconfig	2003-07-01 04:51:30.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/Kconfig	2003-07-01 04:51:38.000000000 -0700
@@ -978,26 +978,16 @@
 	  used on the add-in Bluefish, Barracuda & Shrike SCSI cards.
 	  Say Y here if you have one of these machines or cards.
 
-config SCSI_NCR53C8XX
-	tristate "NCR53C8XX SCSI support"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && SCSI_ZALON!=y && SCSI
-	---help---
-	  This is the BSD ncr driver adapted to Linux for the NCR53C8XX family
-	  of PCI-SCSI controllers.  This driver supports parity checking,
-	  tagged command queuing and fast synchronous data transfers up to 80
-	  MB/s with wide FAST-40 LVD devices and controllers.
-
-	  Recent versions of the 53C8XX chips are better supported by the
-	  option "SYM53C8XX SCSI support", below.
-
-	  Note: there is yet another driver for the 53c8xx family of
-	  controllers ("NCR53c7,8xx SCSI support" above).  If you want to use
-	  them both, you need to say M to both and build them as modules, but
-	  only one may be active at a time.  If you have a 53c8xx board, you
-	  probably do not want to use the "NCR53c7,8xx SCSI support".
+config SCSI_NCR_Q720
+	tristate "NCR Quad 720 MCA SCSI support"
+	depends on MCA && SCSI
+	help
+	  This is a driver for the MicroChannel Quad 720 card produced by
+	  NCR and commonly used in 345x/35xx/4100 class machines.  It always
+	  tries to negotiate sync and uses tag command queueing.
 
-	  Please read <file:Documentation/scsi/ncr53c8xx.txt> for more
-	  information.
+	  Unless you have an NCR manufactured machine, the chances are that
+	  you do not have this SCSI card, so say N.
 
 config SCSI_SYM53C8XX
 	tristate "SYM53C8XX SCSI support"
@@ -1027,8 +1017,8 @@
 	  information.
 
 config SCSI_NCR53C8XX_DEFAULT_TAGS
-	int "default tagged command queue depth"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON)
+	int "  default tagged command queue depth"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720)
 	default "8"
 	---help---
 	  "Tagged command queuing" is a feature of SCSI-2 which improves
@@ -1053,8 +1043,8 @@
 	  There is no safe option other than using good SCSI devices.
 
 config SCSI_NCR53C8XX_MAX_TAGS
-	int "maximum number of queued commands"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON)
+	int "  maximum number of queued commands"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720)
 	default "32"
 	---help---
 	  This option allows you to specify the maximum number of commands
@@ -1070,8 +1060,8 @@
 	  There is no safe option and the default answer is recommended.
 
 config SCSI_NCR53C8XX_SYNC
-	int "synchronous transfers frequency in MHz"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON)
+	int "  synchronous transfers frequency in MHz"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720)
 	default "20"
 	---help---
 	  The SCSI Parallel Interface-2 Standard defines 5 classes of transfer
@@ -1104,8 +1094,8 @@
 	  terminations and SCSI conformant devices.
 
 config SCSI_NCR53C8XX_PROFILE
-	bool "enable profiling"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON)
+	bool "  enable profiling"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720)
 	help
 	  This option allows you to enable profiling information gathering.
 	  These statistics are not very accurate due to the low frequency
@@ -1115,8 +1105,8 @@
 	  The normal answer therefore is N.
 
 config SCSI_NCR53C8XX_IOMAPPED
-	bool "use normal IO"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX) && !SCSI_ZALON
+	bool "  use normal IO"
+	depends on SCSI_SYM53C8XX && !(SCSI_ZALON || SCSI_NCR_Q720)
 	help
 	  If you say Y here, the driver will use normal IO, as opposed to
 	  memory mapped IO. Memory mapped IO has less latency than normal IO
@@ -1128,8 +1118,8 @@
 	  related problems.
 
 config SCSI_NCR53C8XX_PQS_PDS
-	bool "include support for the NCR PQS/PDS SCSI card"
-	depends on (SCSI_NCR53C8XX || SCSI_SYM53C8XX) && SCSI_SYM53C8XX
+	bool "  include support for the NCR PQS/PDS SCSI card"
+	depends on SCSI_SYM53C8XX
 	help
 	  Say Y here if you have a special SCSI adapter produced by NCR
 	  corporation called a PCI Quad SCSI or PCI Dual SCSI. You do not need
@@ -1140,8 +1130,8 @@
 	  The common answer here is N, but answering Y is safe.
 
 config SCSI_NCR53C8XX_NO_DISCONNECT
-	bool "not allow targets to disconnect"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON) && SCSI_NCR53C8XX_DEFAULT_TAGS=0
+	bool "  not allow targets to disconnect"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720) && SCSI_NCR53C8XX_DEFAULT_TAGS=0
 	help
 	  This option is only provided for safety if you suspect some SCSI
 	  device of yours to not support properly the target-disconnect
@@ -1150,8 +1140,8 @@
 	  than 1 device on a SCSI bus. The normal answer therefore is N.
 
 config SCSI_NCR53C8XX_SYMBIOS_COMPAT
-	bool "assume boards are SYMBIOS compatible (EXPERIMENTAL)"
-	depends on PCI && SCSI_SYM53C8XX_2!=y && (SCSI_NCR53C8XX || SCSI_SYM53C8XX || SCSI_ZALON) && EXPERIMENTAL
+	bool "  assume boards are SYMBIOS compatible (EXPERIMENTAL)"
+	depends on (SCSI_SYM53C8XX || SCSI_ZALON || SCSI_NCR_Q720 ) && EXPERIMENTAL
 	---help---
 	  This option allows you to enable some features depending on GPIO
 	  wiring. These General Purpose Input/Output pins can be used for
diff -urN linux-2.5.73-bk8/drivers/scsi/Makefile linux-2.5.73-bk9/drivers/scsi/Makefile
--- linux-2.5.73-bk8/drivers/scsi/Makefile	2003-06-22 11:33:08.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/Makefile	2003-07-01 04:51:38.000000000 -0700
@@ -68,6 +68,7 @@
 obj-$(CONFIG_SCSI_GENERIC_NCR5380_MMIO) += g_NCR5380_mmio.o
 obj-$(CONFIG_SCSI_NCR53C406A)	+= NCR53c406a.o
 obj-$(CONFIG_SCSI_NCR_D700)	+= NCR_D700.o 53c700.o
+obj-$(CONFIG_SCSI_NCR_Q720)	+= NCR_Q720_mod.o
 obj-$(CONFIG_SCSI_SYM53C416)	+= sym53c416.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)	+= qlogicfas.o
 obj-$(CONFIG_SCSI_QLOGIC_ISP)	+= qlogicisp.o 
@@ -81,7 +82,6 @@
 obj-$(CONFIG_SCSI_DTC3280)	+= dtc.o
 obj-$(CONFIG_SCSI_SYM53C8XX_2)	+= sym53c8xx_2/
 obj-$(CONFIG_SCSI_SYM53C8XX)	+= sym53c8xx.o 
-obj-$(CONFIG_SCSI_NCR53C8XX)	+= ncr53c8xx.o 
 obj-$(CONFIG_SCSI_ZALON)	+= zalon7xx.o
 obj-$(CONFIG_SCSI_EATA_PIO)	+= eata_pio.o
 obj-$(CONFIG_SCSI_7000FASST)	+= wd7000.o
@@ -133,7 +133,17 @@
 sr_mod-objs	:= sr.o sr_ioctl.o sr_vendor.o
 initio-objs	:= ini9100u.o i91uscsi.o
 a100u2w-objs	:= inia100.o i60uscsi.o
+ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
+		:= -DCONFIG_NCR53C8XX_PREFETCH \
+			-DCONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS \
+			-DCONFIG_SCSI_NCR53C8XX_NO_NVRAM \
+			-DSCSI_NCR_BIG_ENDIAN -DSIMULATED_INTFLY
+ncr53c8xx-flags-$(CONFIG_SCSI_NCR_Q720) \
+		:= -DCONFIG_SCSI_NCR53C8XX_NO_NVRAM \
+			-DSIMULATED_INTFLY
+CFLAGS_ncr53c8xx.o	:= $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m)
 zalon7xx-objs	:= zalon.o ncr53c8xx.o
+NCR_Q720_mod-objs	:= NCR_Q720.o ncr53c8xx.o
 cpqfc-objs	:= cpqfcTSinit.o cpqfcTScontrol.o cpqfcTSi2c.o \
 		   cpqfcTSworker.o cpqfcTStrigger.o
 
diff -urN linux-2.5.73-bk8/drivers/scsi/NCR_Q720.c linux-2.5.73-bk9/drivers/scsi/NCR_Q720.c
--- linux-2.5.73-bk8/drivers/scsi/NCR_Q720.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.73-bk9/drivers/scsi/NCR_Q720.c	2003-07-01 04:51:38.000000000 -0700
@@ -0,0 +1,354 @@
+/* -*- mode: c; c-basic-offset: 8 -*- */
+
+/* NCR Quad 720 MCA SCSI Driver
+ *
+ * Copyright (C) 2003 by James.Bottomley@HansenPartnership.com
+ */
+
+#include <linux/blkdev.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mca.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#include "scsi.h"
+#include "hosts.h"
+
+#include "ncr53c8xx.h"
+
+#include "NCR_Q720.h"
+
+static ncr_chip q720_chip __initdata = {
+	.device_id =	PSEUDO_720_ID,
+	.revision_id =	0x0f,
+	.name =		"720",
+	.burst_max =	3,
+	.offset_max =	8,
+	.nr_divisor =	4,
+	.features =	FE_WIDE | FE_DIFF | FE_VARCLK,
+};
+
+MODULE_AUTHOR("James Bottomley");
+MODULE_DESCRIPTION("NCR Quad 720 SCSI Driver");
+MODULE_LICENSE("GPL");
+
+#define NCR_Q720_VERSION		"0.9"
+
+/* We needs this helper because we have up to four hosts per struct device */
+struct NCR_Q720_private {
+	struct device		*dev;
+	__u32			mem_base;
+	__u32			phys_mem_base;
+	__u32			mem_size;
+	__u8			irq;
+	__u8			siops;
+	__u8			irq_enable;
+	struct Scsi_Host	*hosts[4];
+};
+
+Scsi_Host_Template NCR_Q720_tpnt = {
+	.module			= THIS_MODULE,
+	.proc_name		= "NCR_Q720",
+};
+
+static irqreturn_t
+NCR_Q720_intr(int irq, void *data, struct pt_regs * regs)
+{
+	struct NCR_Q720_private *p = (struct NCR_Q720_private *)data;
+	__u8 sir = (readb(p->mem_base + 0x0d) & 0xf0) >> 4;
+	__u8 siop;
+
+	sir |= ~p->irq_enable;
+
+	if(sir == 0xff)
+		return IRQ_NONE;
+
+
+	while((siop = ffz(sir)) < p->siops) {
+		sir |= 1<<siop;
+		ncr53c8xx_intr(irq, p->hosts[siop], regs);
+	}
+	return IRQ_HANDLED;
+}
+
+static int __init
+NCR_Q720_probe_one(struct NCR_Q720_private *p, int siop,
+		int irq, int slot, __u32 paddr, __u32 vaddr)
+{
+	ncr_device device;
+	__u8 scsi_id;
+	static int unit = 0;
+	__u8 scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1);
+	__u8 differential = readb(vaddr + NCR_Q720_SCSR_OFFSET) & 0x20;
+	__u8 version;
+
+	scsi_id = scsr1 >> 4;
+	/* enable burst length 16 (FIXME: should allow this) */
+	scsr1 |= 0x02;
+	/* force a siop reset */
+	scsr1 |= 0x04;
+	writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1);
+	udelay(10);
+	version = readb(vaddr + 0x18) >> 4;
+
+	memset(&device, 0, sizeof(ncr_device));
+		/* Initialise ncr_device structure with items required by ncr_attach. */
+	device.chip		= q720_chip;
+	device.chip.revision_id	= version;
+	device.host_id		= scsi_id;
+	device.dev		= p->dev;
+	device.slot.base	= paddr;
+	device.slot.base_c	= paddr;
+	device.slot.base_v	= vaddr;
+	device.slot.irq		= irq;
+	device.differential	= differential ? 2 : 0;
+	printk("Q720 probe unit %d (siop%d) at 0x%lx, diff = %d, vers = %d\n", unit, siop,
+	       (unsigned long)paddr, differential, version);
+
+	p->hosts[siop] = ncr_attach(&NCR_Q720_tpnt, unit++, &device);
+	
+	if (!p->hosts[siop]) 
+		goto fail;
+
+	p->irq_enable |= (1<<siop);
+	scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1);
+	/* clear the disable interrupt bit */
+	scsr1 &= ~0x01;
+	writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1);
+
+	scsi_add_host(p->hosts[siop], p->dev);
+
+	return 0;
+
+ fail:
+	return -ENODEV;
+}
+
+/* Detect a Q720 card.  Note, because of the setup --- the chips are
+ * essentially connectecd to the MCA bus independently, it is easier
+ * to set them up as two separate host adapters, rather than one
+ * adapter with two channels */
+static int __init
+NCR_Q720_probe(struct device *dev)
+{
+	struct NCR_Q720_private *p;
+	static int banner = 1;
+	struct mca_device *mca_dev = to_mca_device(dev);
+	int slot = mca_dev->slot;
+	int found = 0;
+	int irq, i, siops;
+	__u8 pos2, pos4, asr2, asr9, asr10;
+	__u16 io_base;
+	__u32 base_addr, mem_size;
+	__u32 mem_base;
+
+	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	memset(p, 0, sizeof(*p));
+	pos2 = mca_device_read_pos(mca_dev, 2);
+	/* enable device */
+	pos2 |=  NCR_Q720_POS2_BOARD_ENABLE | NCR_Q720_POS2_INTERRUPT_ENABLE;
+	mca_device_write_pos(mca_dev, 2, pos2);
+
+	io_base = (pos2 & NCR_Q720_POS2_IO_MASK) << NCR_Q720_POS2_IO_SHIFT;
+
+
+	if(banner) {
+		printk(KERN_NOTICE "NCR Q720: Driver Version " NCR_Q720_VERSION "\n"
+		       "NCR Q720:  Copyright (c) 2003 by James.Bottomley@HansenPartnership.com\n"
+		       "NCR Q720:\n");
+		banner = 0;
+	}
+	io_base = mca_device_transform_ioport(mca_dev, io_base);
+
+	/* OK, this is phase one of the bootstrap, we now know the
+	 * I/O space base address.  All the configuration registers
+	 * are mapped here (including pos) */
+
+	/* sanity check I/O mapping */
+	i = inb(io_base) | (inb(io_base+1)<<8);
+	if(i != NCR_Q720_MCA_ID) {
+		printk(KERN_ERR "NCR_Q720, adapter failed to I/O map registers correctly at 0x%x(0x%x)\n", io_base, i);
+		return -ENODEV;
+	}
+
+	/* Phase II, find the ram base and memory map the board register */
+	pos4 = inb(io_base + 4);
+	/* enable streaming data */
+	pos4 |= 0x01;
+	outb(pos4, io_base + 4);
+	base_addr = (pos4 & 0x7e) << 20;
+	base_addr += (pos4 & 0x80) << 23;
+	asr10 = inb(io_base + 0x12);
+	base_addr += (asr10 & 0x80) << 24;
+	base_addr += (asr10 & 0x70) << 23;
+
+	/* OK, got the base addr, now we need to find the ram size,
+	 * enable and map it */
+	asr9 = inb(io_base + 0x11);
+	i = (asr9 & 0xc0) >> 6;
+	if(i == 0)
+		mem_size = 1024;
+	else
+		mem_size = 1 << (19 + i);
+
+	/* enable the sram mapping */
+	asr9 |= 0x20;
+
+	/* disable the rom mapping */
+	asr9 &= ~0x10;
+
+	outb(asr9, io_base + 0x11);
+
+	if(!request_mem_region(base_addr, mem_size, "NCR_Q720")) {
+		printk(KERN_ERR "NCR_Q720: Failed to claim memory region 0x%lx\n-0x%lx",
+		       (unsigned long)base_addr,
+		       (unsigned long)(base_addr + mem_size));
+		goto out_free;
+	}
+	
+	mem_base = (__u32)ioremap(base_addr, mem_size);
+
+	/* now also enable accesses in asr 2 */
+	asr2 = inb(io_base + 0x0a);
+
+	asr2 |= 0x01;
+
+	outb(asr2, io_base + 0x0a);
+
+	/* get the number of SIOPs (this should be 2 or 4) */
+	siops = ((asr2 & 0xe0) >> 5) + 1;
+
+	/* sanity check mapping (again) */
+	i = readw(mem_base);
+	if(i != NCR_Q720_MCA_ID) {
+		printk(KERN_ERR "NCR_Q720, adapter failed to memory map registers correctly at 0x%lx(0x%x)\n", (unsigned long)base_addr, i);
+		goto out_release;
+	}
+
+	irq = readb(mem_base + 5) & 0x0f;
+	
+	
+	/* now do the bus related transforms */
+	irq = mca_device_transform_irq(mca_dev, irq);
+
+	printk(KERN_NOTICE "NCR Q720: found in slot %d  irq = %d  mem base = 0x%lx siops = %d\n", slot, irq, (unsigned long)base_addr, siops);
+	printk(KERN_NOTICE "NCR Q720: On board ram %dk\n", mem_size/1024);
+
+	p->dev = dev;
+	p->mem_base = mem_base;
+	p->phys_mem_base = base_addr;
+	p->mem_size = mem_size;
+	p->irq = irq;
+	p->siops = siops;
+
+	if (request_irq(irq, NCR_Q720_intr, SA_SHIRQ, "NCR_Q720", p)) {
+		printk(KERN_ERR "NCR_Q720: request irq %d failed\n", irq);
+		goto out_release;
+	}
+	/* disable all the siop interrupts */
+	for(i = 0; i < siops; i++) {
+		__u32 reg_scsr1 = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
+			+ i*NCR_Q720_SIOP_SHIFT + NCR_Q720_SCSR_OFFSET + 1;
+		__u8 scsr1 = readb(reg_scsr1);
+		scsr1 |= 0x01;
+		writeb(scsr1, reg_scsr1);
+	}
+
+	/* plumb in all 720 chips */
+	for (i = 0; i < siops; i++) {
+		__u32 siop_v_base = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
+			+ i*NCR_Q720_SIOP_SHIFT;
+		__u32 siop_p_base = base_addr + NCR_Q720_CHIP_REGISTER_OFFSET
+			+ i*NCR_Q720_SIOP_SHIFT;
+		__u16 port = io_base + NCR_Q720_CHIP_REGISTER_OFFSET
+			+ i*NCR_Q720_SIOP_SHIFT;
+		int err;
+
+		outb(0xff, port + 0x40);
+		outb(0x07, port + 0x41);
+		if ((err = NCR_Q720_probe_one(p, i, irq, slot,
+					      siop_p_base, siop_v_base)) != 0)
+			printk("Q720: SIOP%d: probe failed, error = %d\n",
+			       i, err);
+		else
+			found++;
+	}
+
+	if (!found) {
+		kfree(p);
+		return -ENODEV;
+	}
+
+	mca_device_set_claim(mca_dev, 1);
+	strlcpy(dev->name, "NCR_Q720", sizeof(dev->name));
+	dev_set_drvdata(dev, p);
+
+	return 0;
+
+ out_release:
+	iounmap((void *)mem_base);
+	release_mem_region(base_addr, mem_size);
+ out_free:
+	kfree(p);
+
+	return -ENODEV;
+}
+
+static void __exit
+NCR_Q720_remove_one(struct Scsi_Host *host)
+{
+	scsi_remove_host(host);
+	ncr53c8xx_release(host);
+}
+
+static int __exit
+NCR_Q720_remove(struct device *dev)
+{
+	struct NCR_Q720_private *p = dev_get_drvdata(dev);
+	int i;
+
+	for (i = 0; i < p->siops; i++)
+		if(p->hosts[i])
+			NCR_Q720_remove_one(p->hosts[i]);
+
+	iounmap((void *)p->mem_base);
+	release_mem_region(p->phys_mem_base, p->mem_size);
+	free_irq(p->irq, p);
+	kfree(p);
+	return 0;
+}
+
+static short NCR_Q720_id_table[] = { NCR_Q720_MCA_ID, 0 };
+
+struct mca_driver NCR_Q720_driver = {
+	.id_table = NCR_Q720_id_table,
+	.driver = {
+		.name		= "NCR_Q720",
+		.bus		= &mca_bus_type,
+		.probe		= NCR_Q720_probe,
+		.remove		= __devexit_p(NCR_Q720_remove),
+	},
+};
+
+static int __init
+NCR_Q720_init(void)
+{
+	return mca_register_driver(&NCR_Q720_driver);
+}
+
+static void __exit
+NCR_Q720_exit(void)
+{
+	mca_unregister_driver(&NCR_Q720_driver);
+	//scsi_sysfs_release_attributes(&NCR_Q720_driver_template);
+}
+
+module_init(NCR_Q720_init);
+module_exit(NCR_Q720_exit);
diff -urN linux-2.5.73-bk8/drivers/scsi/NCR_Q720.h linux-2.5.73-bk9/drivers/scsi/NCR_Q720.h
--- linux-2.5.73-bk8/drivers/scsi/NCR_Q720.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.73-bk9/drivers/scsi/NCR_Q720.h	2003-07-01 04:51:38.000000000 -0700
@@ -0,0 +1,28 @@
+/* -*- mode: c; c-basic-offset: 8 -*- */
+
+/* NCR Quad 720 MCA SCSI Driver
+ *
+ * Copyright (C) 2003 by James.Bottomley@HansenPartnership.com
+ */
+
+#ifndef _NCR_Q720_H
+#define _NCR_Q720_H
+
+/* The MCA identifier */
+#define NCR_Q720_MCA_ID		0x0720
+
+#define NCR_Q720_CLOCK_MHZ	30
+
+#define NCR_Q720_POS2_BOARD_ENABLE	0x01
+#define NCR_Q720_POS2_INTERRUPT_ENABLE	0x02
+#define NCR_Q720_POS2_PARITY_DISABLE	0x04
+#define NCR_Q720_POS2_IO_MASK		0xf8
+#define NCR_Q720_POS2_IO_SHIFT		8
+
+#define NCR_Q720_CHIP_REGISTER_OFFSET	0x200
+#define NCR_Q720_SCSR_OFFSET		0x070
+#define NCR_Q720_SIOP_SHIFT		0x080
+
+#endif
+
+
diff -urN linux-2.5.73-bk8/drivers/scsi/aacraid/aachba.c linux-2.5.73-bk9/drivers/scsi/aacraid/aachba.c
--- linux-2.5.73-bk8/drivers/scsi/aacraid/aachba.c	2003-06-22 11:32:43.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/aacraid/aachba.c	2003-07-01 04:51:38.000000000 -0700
@@ -39,25 +39,6 @@
 
 #include "aacraid.h"
 
-/*	SCSI Commands */
-/* TODO dmb - use the ones defined in include/scsi/scsi.h*/
-#define	SS_TEST			0x00	/* Test unit ready */
-#define SS_REZERO		0x01	/* Rezero unit */
-#define	SS_REQSEN		0x03	/* Request Sense */
-#define SS_REASGN		0x07	/* Reassign blocks */
-#define	SS_READ			0x08	/* Read 6   */
-#define	SS_WRITE		0x0A	/* Write 6  */
-#define	SS_INQUIR		0x12	/* inquiry */
-#define	SS_ST_SP		0x1B	/* Start/Stop unit */
-#define	SS_LOCK			0x1E	/* prevent/allow medium removal */
-#define SS_RESERV		0x16	/* Reserve */
-#define SS_RELES		0x17	/* Release */
-#define SS_MODESEN		0x1A	/* Mode Sense 6 */
-#define	SS_RDCAP		0x25	/* Read Capacity */
-#define	SM_READ			0x28	/* Read 10  */
-#define	SM_WRITE		0x2A	/* Write 10 */
-#define SS_SEEK			0x2B	/* Seek */
-
 /* values for inqd_pdt: Peripheral device type in plain English */
 #define	INQD_PDT_DA	0x00	/* Direct-access (DISK) device */
 #define	INQD_PDT_PROC	0x03	/* Processor device */
@@ -583,10 +564,10 @@
 				 scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 	readreply = (struct aac_read_reply *)fib_data(fibptr);
 	if (le32_to_cpu(readreply->status) == ST_OK)
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 	else {
 		printk(KERN_WARNING "read_callback: read failed, status = %d\n", readreply->status);
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 		set_sense((u8 *) &sense_data[cid],
 				    SENKEY_HW_ERR,
 				    SENCODE_INTERNAL_TARGET_FAILURE,
@@ -628,10 +609,10 @@
 
 	writereply = (struct aac_write_reply *) fib_data(fibptr);
 	if (le32_to_cpu(writereply->status) == ST_OK)
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 	else {
 		printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status);
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 		set_sense((u8 *) &sense_data[cid],
 				    SENKEY_HW_ERR,
 				    SENCODE_INTERNAL_TARGET_FAILURE,
@@ -658,7 +639,7 @@
 	/*
 	 *	Get block address and transfer length
 	 */
-	if (scsicmd->cmnd[0] == SS_READ)	/* 6 byte command */
+	if (scsicmd->cmnd[0] == READ_6)	/* 6 byte command */
 	{
 		dprintk((KERN_DEBUG "aachba: received a read(6) command on target %d.\n", cid));
 
@@ -748,7 +729,7 @@
 	/*
 	 *	For some reason, the Fib didn't queue, return QUEUE_FULL
 	 */
-	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL;
+	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
 	aac_io_done(scsicmd);
 	fib_complete(cmd_fibcontext);
 	fib_free(cmd_fibcontext);
@@ -768,7 +749,7 @@
 	/*
 	 *	Get block address and transfer length
 	 */
-	if (scsicmd->cmnd[0] == SS_WRITE)	/* 6 byte command */
+	if (scsicmd->cmnd[0] == WRITE_6)	/* 6 byte command */
 	{
 		lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
 		count = scsicmd->cmnd[4];
@@ -854,7 +835,7 @@
 	/*
 	 *	For some reason, the Fib didn't queue, return QUEUE_FULL
 	 */
-	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL;
+	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
 	aac_io_done(scsicmd);
 
 	fib_complete(cmd_fibcontext);
@@ -905,9 +886,9 @@
 			 */
 			if (fsa_dev_ptr->valid[cid] == 0) {
 				switch (scsicmd->cmnd[0]) {
-				case SS_INQUIR:
-				case SS_RDCAP:
-				case SS_TEST:
+				case INQUIRY:
+				case READ_CAPACITY:
+				case TEST_UNIT_READY:
 					spin_unlock_irq(host->host_lock);
 					probe_container(dev, cid);
 					spin_lock_irq(host->host_lock);
@@ -942,11 +923,11 @@
 	/*
 	 * else Command for the controller itself
 	 */
-	else if ((scsicmd->cmnd[0] != SS_INQUIR) &&	/* only INQUIRY & TUR cmnd supported for controller */
-		(scsicmd->cmnd[0] != SS_TEST)) 
+	else if ((scsicmd->cmnd[0] != INQUIRY) &&	/* only INQUIRY & TUR cmnd supported for controller */
+		(scsicmd->cmnd[0] != TEST_UNIT_READY)) 
 	{
 		dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 		set_sense((u8 *) &sense_data[cid],
 			    SENKEY_ILLEGAL,
 			    SENCODE_INVALID_COMMAND,
@@ -958,7 +939,7 @@
 
 	/* Handle commands here that don't really require going out to the adapter */
 	switch (scsicmd->cmnd[0]) {
-	case SS_INQUIR:
+	case INQUIRY:
 	{
 		struct inquiry_data *inq_data_ptr;
 
@@ -981,11 +962,11 @@
 			inq_data_ptr->inqd_pdt = INQD_PDT_PROC;	/* Processor device */
 		else
 			inq_data_ptr->inqd_pdt = INQD_PDT_DA;	/* Direct/random access device */
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 		return 0;
 	}
-	case SS_RDCAP:
+	case READ_CAPACITY:
 	{
 		int capacity;
 		char *cp;
@@ -1002,18 +983,34 @@
 		cp[6] = 2;
 		cp[7] = 0;
 
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 
 		return 0;
 	}
 
-	case SS_MODESEN:
+	case MODE_SENSE:
 	{
 		char *mode_buf;
 
 		dprintk((KERN_DEBUG "MODE SENSE command.\n"));
 		mode_buf = scsicmd->request_buffer;
+		mode_buf[0] = 3;	/* Mode data length */
+		mode_buf[1] = 0;	/* Medium type - default */
+		mode_buf[2] = 0;	/* Device-specific param, bit 8: 0/1 = write enabled/protected */
+		mode_buf[3] = 0;	/* Block descriptor length */
+
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+		__aac_io_done(scsicmd);
+
+		return 0;
+	}
+	case MODE_SENSE_10:
+	{
+		char *mode_buf;
+
+		dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n"));
+		mode_buf = scsicmd->request_buffer;
 		mode_buf[0] = 0;	/* Mode data length (MSB) */
 		mode_buf[1] = 6;	/* Mode data length (LSB) */
 		mode_buf[2] = 0;	/* Medium type - default */
@@ -1023,48 +1020,48 @@
 		mode_buf[6] = 0;	/* Block descriptor length (MSB) */
 		mode_buf[7] = 0;	/* Block descriptor length (LSB) */
 
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 
 		return 0;
 	}
-	case SS_REQSEN:
+	case REQUEST_SENSE:
 		dprintk((KERN_DEBUG "REQUEST SENSE command.\n"));
 		memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof (struct sense_data));
 		memset(&sense_data[cid], 0, sizeof (struct sense_data));
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 		return (0);
 
-	case SS_LOCK:
+	case ALLOW_MEDIUM_REMOVAL:
 		dprintk((KERN_DEBUG "LOCK command.\n"));
 		if (scsicmd->cmnd[4])
 			fsa_dev_ptr->locked[cid] = 1;
 		else
 			fsa_dev_ptr->locked[cid] = 0;
 
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 		return 0;
 	/*
 	 *	These commands are all No-Ops
 	 */
-	case SS_TEST:
-	case SS_RESERV:
-	case SS_RELES:
-	case SS_REZERO:
-	case SS_REASGN:
-	case SS_SEEK:
-	case SS_ST_SP:
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD;
+	case TEST_UNIT_READY:
+	case RESERVE:
+	case RELEASE:
+	case REZERO_UNIT:
+	case REASSIGN_BLOCKS:
+	case SEEK_10:
+	case START_STOP:
+		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 		__aac_io_done(scsicmd);
 		return (0);
 	}
 
 	switch (scsicmd->cmnd[0]) 
 	{
-		case SS_READ:
-		case SM_READ:
+		case READ_6:
+		case READ_10:
 			/*
 			 *	Hack to keep track of ordinal number of the device that
 			 *	corresponds to a container. Needed to convert
@@ -1081,8 +1078,8 @@
 			spin_lock_irq(host->host_lock);
 			return ret;
 
-		case SS_WRITE:
-		case SM_WRITE:
+		case WRITE_6:
+		case WRITE_10:
 			spin_unlock_irq(host->host_lock);
 			ret = aac_write(scsicmd, cid);
 			spin_lock_irq(host->host_lock);
@@ -1092,7 +1089,7 @@
 			 *	Unhandled commands
 			 */
 			printk(KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]);
-			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION;
+			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 			set_sense((u8 *) &sense_data[cid],
 				SENKEY_ILLEGAL, SENCODE_INVALID_COMMAND,
 			ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
@@ -1250,7 +1247,7 @@
 		printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
 		len = (srbreply->sense_data_size > sizeof(scsicmd->sense_buffer))?
 				sizeof(scsicmd->sense_buffer):srbreply->sense_data_size;
-		scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION;
+		scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 		memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
 	}
 
@@ -1373,7 +1370,7 @@
 	}
 	if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){  // Check Condition
 		int len;
-		scsicmd->result |= CHECK_CONDITION;
+		scsicmd->result |= SAM_STAT_CHECK_CONDITION;
 		len = (srbreply->sense_data_size > sizeof(scsicmd->sense_buffer))?
 				sizeof(scsicmd->sense_buffer):srbreply->sense_data_size;
 		printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", le32_to_cpu(srbreply->status), len);
@@ -1501,7 +1498,7 @@
 	/*
 	 *	For some reason, the Fib didn't queue, return QUEUE_FULL
 	 */
-	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL;
+	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
 	__aac_io_done(scsicmd);
 
 	fib_complete(cmd_fibcontext);
diff -urN linux-2.5.73-bk8/drivers/scsi/aha1740.c linux-2.5.73-bk9/drivers/scsi/aha1740.c
--- linux-2.5.73-bk8/drivers/scsi/aha1740.c	2003-06-22 11:32:37.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/aha1740.c	2003-07-01 04:51:38.000000000 -0700
@@ -8,6 +8,7 @@
  *
  *  This file is aha1740.c, written and
  *  Copyright (C) 1992,1993  Brad McLean
+ *  brad@saturn.gaylord.com or brad@bradpc.gaylord.com.
  *  
  *  Modifications to makecode and queuecommand
  *  for proper handling of multiple devices courteously
@@ -23,6 +24,9 @@
  *
  * Reworked for new_eh and new locking by Alan Cox <alan@redhat.com>
  *
+ * Converted to EISA and generic DMA APIs by Marc Zyngier
+ * <maz@wild-wind.fr.eu.org>, 4/2003.
+ *
  * For the avoidance of doubt the "preferred form" of this code is one which
  * is in an open non patent encumbered format. Where cryptographic key signing
  * forms part of the process of creating an executable the information
@@ -39,6 +43,10 @@
 #include <linux/ioport.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/eisa.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -58,478 +66,550 @@
 #define DEB(x)
 #endif
 
-/*
-static const char RCSid[] = "$Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/aha1740.c,v 1.1 1992/07/24 06:27:38 root Exp root $";
-*/
-
 struct aha1740_hostdata {
-    unsigned int slot;
-    unsigned int translation;
-    unsigned int last_ecb_used;
-    struct ecb ecb[AHA1740_ECBS];
+	struct eisa_device *edev;
+	unsigned int translation;
+	unsigned int last_ecb_used;
+	dma_addr_t ecb_dma_addr;
+	struct ecb ecb[AHA1740_ECBS];
+};
+
+struct aha1740_sg {
+	struct aha1740_chain sg_chain[AHA1740_SCATTER];
+	dma_addr_t sg_dma_addr;
+	dma_addr_t buf_dma_addr;
 };
 
 #define HOSTDATA(host) ((struct aha1740_hostdata *) &host->hostdata)
 
-static spinlock_t aha1740_lock = SPIN_LOCK_UNLOCKED;
+static inline struct ecb *ecb_dma_to_cpu (struct Scsi_Host *host,
+					  dma_addr_t dma)
+{
+	struct aha1740_hostdata *hdata = HOSTDATA (host);
+	dma_addr_t offset;
 
-/* One for each IRQ level (9-15) */
-static struct Scsi_Host * aha_host[8] = {NULL, };
+	offset = dma - hdata->ecb_dma_addr;
 
-static int aha1740_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset,
-		      int length, int inout)
+	return (struct ecb *)(((char *) hdata->ecb) + (unsigned int) offset);
+}
+
+static inline dma_addr_t ecb_cpu_to_dma (struct Scsi_Host *host, void *cpu)
 {
-    int len;
-    struct aha1740_hostdata *host;
+	struct aha1740_hostdata *hdata = HOSTDATA (host);
+	dma_addr_t offset;
+    
+	offset = (char *) cpu - (char *) hdata->ecb;
+
+	return hdata->ecb_dma_addr + offset;
+}
 
-    if (inout)
-	return-ENOSYS;
+static int aha1740_proc_info(struct Scsi_Host *shpnt, char *buffer,
+			     char **start, off_t offset,
+			     int length, int inout)
+{
+	int len;
+	struct aha1740_hostdata *host;
 
-    host = HOSTDATA(shpnt);
+	if (inout)
+		return-ENOSYS;
 
-    len = sprintf(buffer, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n"
-		  "Extended translation %sabled.\n",
-		  shpnt->io_port, shpnt->irq, host->slot,
-		  host->translation ? "en" : "dis");
+	host = HOSTDATA(shpnt);
 
-    if (offset > len) {
-	*start = buffer;
-	return 0;
-    }
+	len = sprintf(buffer, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n"
+		      "Extended translation %sabled.\n",
+		      shpnt->io_port, shpnt->irq, host->edev->slot,
+		      host->translation ? "en" : "dis");
+
+	if (offset > len) {
+		*start = buffer;
+		return 0;
+	}
 
-    *start = buffer + offset;
-    len -= offset;
-    if (len > length)
-	len = length;
-    return len;
+	*start = buffer + offset;
+	len -= offset;
+	if (len > length)
+		len = length;
+	return len;
 }
 
-
 static int aha1740_makecode(unchar *sense, unchar *status)
 {
-    struct statusword
-    {
-	ushort	don:1,	/* Command Done - No Error */
-		du:1,	/* Data underrun */
-	:1,	qf:1,	/* Queue full */
-		sc:1,	/* Specification Check */
-		dor:1,	/* Data overrun */
-		ch:1,	/* Chaining Halted */
-		intr:1,	/* Interrupt issued */
-		asa:1,	/* Additional Status Available */
-		sns:1,	/* Sense information Stored */
-	:1,	ini:1,	/* Initialization Required */
-		me:1,	/* Major error or exception */
-	:1,	eca:1,  /* Extended Contingent alliance */
-	:1;
-    } status_word;
-    int retval = DID_OK;
+	struct statusword
+	{
+		ushort	don:1,	/* Command Done - No Error */
+			du:1,	/* Data underrun */
+		    :1,	qf:1,	/* Queue full */
+		        sc:1,	/* Specification Check */
+		        dor:1,	/* Data overrun */
+		        ch:1,	/* Chaining Halted */
+		        intr:1,	/* Interrupt issued */
+		        asa:1,	/* Additional Status Available */
+		        sns:1,	/* Sense information Stored */
+		    :1,	ini:1,	/* Initialization Required */
+			me:1,	/* Major error or exception */
+		    :1,	eca:1,  /* Extended Contingent alliance */
+		    :1;
+	} status_word;
+	int retval = DID_OK;
 
-    status_word = * (struct statusword *) status;
+	status_word = * (struct statusword *) status;
 #ifdef DEBUG
-    printk("makecode from %x,%x,%x,%x %x,%x,%x,%x",
-	   status[0], status[1], status[2], status[3],
-	   sense[0], sense[1], sense[2], sense[3]);
+	printk("makecode from %x,%x,%x,%x %x,%x,%x,%x",
+	       status[0], status[1], status[2], status[3],
+	       sense[0], sense[1], sense[2], sense[3]);
 #endif
-    if (!status_word.don) /* Anything abnormal was detected */
-    {
-	if ( (status[1]&0x18) || status_word.sc ) /*Additional info available*/
-	{
-	    /* Use the supplied info for further diagnostics */
-	    switch ( status[2] )
-	    {
-	    case 0x12:
-		if ( status_word.dor )
-		    retval=DID_ERROR;	/* It's an Overrun */
-		/* If not overrun, assume underrun and ignore it! */
-	    case 0x00: /* No info, assume no error, should not occur */
-		break;
-	    case 0x11:
-	    case 0x21:
-		retval=DID_TIME_OUT;
-		break;
-	    case 0x0a:
-		retval=DID_BAD_TARGET;
-		break;
-	    case 0x04:
-	    case 0x05:
-		retval=DID_ABORT;
-		/* Either by this driver or the AHA1740 itself */
-		break;
-	    default:
-		retval=DID_ERROR; /* No further diagnostics possible */
-	    } 
+	if (!status_word.don) { /* Anything abnormal was detected */
+		if ( (status[1]&0x18) || status_word.sc ) {
+			/*Additional info available*/
+			/* Use the supplied info for further diagnostics */
+			switch ( status[2] ) {
+			case 0x12:
+				if ( status_word.dor )
+					retval=DID_ERROR; /* It's an Overrun */
+				/* If not overrun, assume underrun and
+				 * ignore it! */
+			case 0x00: /* No info, assume no error, should
+				    * not occur */
+				break;
+			case 0x11:
+			case 0x21:
+				retval=DID_TIME_OUT;
+				break;
+			case 0x0a:
+				retval=DID_BAD_TARGET;
+				break;
+			case 0x04:
+			case 0x05:
+				retval=DID_ABORT;
+				/* Either by this driver or the
+				 * AHA1740 itself */
+				break;
+			default:
+				retval=DID_ERROR; /* No further
+						   * diagnostics
+						   * possible */
+			}
+		} else {
+			/* Michael suggests, and Brad concurs: */
+			if ( status_word.qf ) {
+				retval = DID_TIME_OUT; /* forces a redo */
+				/* I think this specific one should
+				 * not happen -Brad */
+				printk("aha1740.c: WARNING: AHA1740 queue overflow!\n");
+			} else
+				if ( status[0]&0x60 ) {
+					 /* Didn't find a better error */
+					retval = DID_ERROR;
+				}
+			/* In any other case return DID_OK so for example
+			   CONDITION_CHECKS make it through to the appropriate
+			   device driver */
+		}
 	}
-	else
-	{ /* Michael suggests, and Brad concurs: */
-	    if ( status_word.qf )
-	    {
-		retval = DID_TIME_OUT; /* forces a redo */
-		/* I think this specific one should not happen -Brad */
-		printk("aha1740.c: WARNING: AHA1740 queue overflow!\n");
-	    }
-	    else if ( status[0]&0x60 )
-	    {
-		retval = DID_ERROR; /* Didn't find a better error */
-	    }
-	    /* In any other case return DID_OK so for example
-	       CONDITION_CHECKS make it through to the appropriate
-	       device driver */
-	}
-    }
-    /* Under all circumstances supply the target status -Michael */
-    return status[3] | retval << 16;
+	/* Under all circumstances supply the target status -Michael */
+	return status[3] | retval << 16;
 }
 
 static int aha1740_test_port(unsigned int base)
 {
-    char name[4], tmp;
-
-    /* Okay, look for the EISA ID's */
-    name[0]= 'A' -1 + ((tmp = inb(HID0(base))) >> 2); /* First character */
-    name[1]= 'A' -1 + ((tmp & 3) << 3);
-    name[1]+= ((tmp = inb(HID1(base))) >> 5)&0x7;	/* Second Character */
-    name[2]= 'A' -1 + (tmp & 0x1f);		/* Third Character */
-    name[3]=0;
-    tmp = inb(HID2(base));
-    if ( strcmp ( name, HID_MFG ) || inb(HID2(base)) != HID_PRD )
-	return 0;   /* Not an Adaptec 174x */
-
-/*  if ( inb(HID3(base)) != HID_REV )
-	printk("aha174x: Warning; board revision of %d; expected %d\n",
-	    inb(HID3(base)),HID_REV); */
-
-    if ( inb(EBCNTRL(base)) != EBCNTRL_VALUE )
-    {
-	printk("aha174x: Board detected, but EBCNTRL = %x, so disabled it.\n",
-	    inb(EBCNTRL(base)));
-	return 0;
-    }
-
-    if ( inb(PORTADR(base)) & PORTADDR_ENH )
-	return 1;   /* Okay, we're all set */
+	if ( inb(PORTADR(base)) & PORTADDR_ENH )
+		return 1;   /* Okay, we're all set */
 	
-    printk("aha174x: Board detected, but not in enhanced mode, so disabled it.\n");
-    return 0;
+	printk("aha174x: Board detected, but not in enhanced mode, so disabled it.\n");
+	return 0;
 }
 
 /* A "high" level interrupt handler */
 static irqreturn_t aha1740_intr_handle(int irq, void *dev_id,
-					struct pt_regs *regs)
+				       struct pt_regs *regs)
 {
-    struct Scsi_Host *host = aha_host[irq - 9];
-    void (*my_done)(Scsi_Cmnd *);
-    int errstatus, adapstat;
-    int number_serviced;
-    struct ecb *ecbptr;
-    Scsi_Cmnd *SCtmp;
-    unsigned int base;
-    unsigned long flags;
-    int handled = 0;
-
-    if (!host)
-	panic("aha1740.c: Irq from unknown host!\n");
-    spin_lock_irqsave(host->host_lock, flags);
-    base = host->io_port;
-    number_serviced = 0;
-
-    while(inb(G2STAT(base)) & G2STAT_INTPEND)
-    {
-	handled = 1;
-	DEB(printk("aha1740_intr top of loop.\n"));
-	adapstat = inb(G2INTST(base));
-	ecbptr = (struct ecb *) isa_bus_to_virt(inl(MBOXIN0(base)));
-	outb(G2CNTRL_IRST,G2CNTRL(base)); /* interrupt reset */
+	struct Scsi_Host *host = (struct Scsi_Host *) dev_id;
+        void (*my_done)(Scsi_Cmnd *);
+	int errstatus, adapstat;
+	int number_serviced;
+	struct ecb *ecbptr;
+	Scsi_Cmnd *SCtmp;
+	unsigned int base;
+	unsigned long flags;
+	int handled = 0;
+	struct aha1740_sg *sgptr;
+	struct eisa_device *edev;
+	
+	if (!host)
+		panic("aha1740.c: Irq from unknown host!\n");
+	spin_lock_irqsave(host->host_lock, flags);
+	base = host->io_port;
+	number_serviced = 0;
+	edev = HOSTDATA(host)->edev;
+
+	while(inb(G2STAT(base)) & G2STAT_INTPEND) {
+		handled = 1;
+		DEB(printk("aha1740_intr top of loop.\n"));
+		adapstat = inb(G2INTST(base));
+		ecbptr = ecb_dma_to_cpu (host, inl(MBOXIN0(base)));
+		outb(G2CNTRL_IRST,G2CNTRL(base)); /* interrupt reset */
       
-	switch ( adapstat & G2INTST_MASK )
-	{
-	case	G2INTST_CCBRETRY:
-	case	G2INTST_CCBERROR:
-	case	G2INTST_CCBGOOD:
-	    /* Host Ready -> Mailbox in complete */
-	    outb(G2CNTRL_HRDY,G2CNTRL(base));
-	    if (!ecbptr)
-	    {
-		printk("Aha1740 null ecbptr in interrupt (%x,%x,%x,%d)\n",
-		       inb(G2STAT(base)),adapstat,
-		       inb(G2INTST(base)), number_serviced++);
-		continue;
-	    }
-	    SCtmp = ecbptr->SCpnt;
-	    if (!SCtmp)
-	    {
-		printk("Aha1740 null SCtmp in interrupt (%x,%x,%x,%d)\n",
-		       inb(G2STAT(base)),adapstat,
-		       inb(G2INTST(base)), number_serviced++);
-		continue;
-	    }
-	    if (SCtmp->host_scribble)
-		kfree(SCtmp->host_scribble);
-	    /* Fetch the sense data, and tuck it away, in the required slot.
-	       The Adaptec automatically fetches it, and there is no
-	       guarantee that we will still have it in the cdb when we come
-	       back */
-	    if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR )
-	    {
-		memcpy(SCtmp->sense_buffer, ecbptr->sense, 
-		       sizeof(SCtmp->sense_buffer));
-		errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
-	    }
-	    else
-		errstatus = 0;
-	    DEB(if (errstatus) printk("aha1740_intr_handle: returning %6x\n",
-				      errstatus));
-	    SCtmp->result = errstatus;
-	    my_done = ecbptr->done;
-	    memset(ecbptr,0,sizeof(struct ecb)); 
-	    if ( my_done )
-		my_done(SCtmp);
-	    break;
-	case	G2INTST_HARDFAIL:
-	    printk(KERN_ALERT "aha1740 hardware failure!\n");
-	    panic("aha1740.c");	/* Goodbye */
-	case	G2INTST_ASNEVENT:
-	    printk("aha1740 asynchronous event: %02x %02x %02x %02x %02x\n",
-		   adapstat, inb(MBOXIN0(base)), inb(MBOXIN1(base)),
-		   inb(MBOXIN2(base)), inb(MBOXIN3(base))); /* Say What? */
-	    /* Host Ready -> Mailbox in complete */
-	    outb(G2CNTRL_HRDY,G2CNTRL(base));
-	    break;
-	case	G2INTST_CMDGOOD:
-	    /* set immediate command success flag here: */
-	    break;
-	case	G2INTST_CMDERROR:
-	    /* Set immediate command failure flag here: */
-	    break;
+		switch ( adapstat & G2INTST_MASK ) {
+		case	G2INTST_CCBRETRY:
+		case	G2INTST_CCBERROR:
+		case	G2INTST_CCBGOOD:
+			/* Host Ready -> Mailbox in complete */
+			outb(G2CNTRL_HRDY,G2CNTRL(base));
+			if (!ecbptr) {
+				printk("Aha1740 null ecbptr in interrupt (%x,%x,%x,%d)\n",
+				       inb(G2STAT(base)),adapstat,
+				       inb(G2INTST(base)), number_serviced++);
+				continue;
+			}
+			SCtmp = ecbptr->SCpnt;
+			if (!SCtmp) {
+				printk("Aha1740 null SCtmp in interrupt (%x,%x,%x,%d)\n",
+				       inb(G2STAT(base)),adapstat,
+				       inb(G2INTST(base)), number_serviced++);
+				continue;
+			}
+			sgptr = (struct aha1740_sg *) SCtmp->host_scribble;
+			if (SCtmp->use_sg) {
+				/* We used scatter-gather.
+				   Do the unmapping dance. */
+				dma_unmap_sg (&edev->dev,
+					      (struct scatterlist *) SCtmp->request_buffer,
+					      SCtmp->use_sg,
+					      SCtmp->sc_data_direction);
+			} else {
+				dma_unmap_single (&edev->dev,
+						  sgptr->buf_dma_addr,
+						  SCtmp->request_bufflen,
+						  DMA_BIDIRECTIONAL);
+			}
+	    
+			/* Free the sg block */
+			dma_free_coherent (&edev->dev,
+					   sizeof (struct aha1740_sg),
+					   SCtmp->host_scribble,
+					   sgptr->sg_dma_addr);
+	    
+			/* Fetch the sense data, and tuck it away, in
+			   the required slot.  The Adaptec
+			   automatically fetches it, and there is no
+			   guarantee that we will still have it in the
+			   cdb when we come back */
+			if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
+				memcpy(SCtmp->sense_buffer, ecbptr->sense, 
+				       sizeof(SCtmp->sense_buffer));
+				errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
+			} else
+				errstatus = 0;
+			DEB(if (errstatus)
+			    printk("aha1740_intr_handle: returning %6x\n",
+				   errstatus));
+			SCtmp->result = errstatus;
+			my_done = ecbptr->done;
+			memset(ecbptr,0,sizeof(struct ecb)); 
+			if ( my_done )
+				my_done(SCtmp);
+			break;
+			
+		case	G2INTST_HARDFAIL:
+			printk(KERN_ALERT "aha1740 hardware failure!\n");
+			panic("aha1740.c");	/* Goodbye */
+			
+		case	G2INTST_ASNEVENT:
+			printk("aha1740 asynchronous event: %02x %02x %02x %02x %02x\n",
+			       adapstat,
+			       inb(MBOXIN0(base)),
+			       inb(MBOXIN1(base)),
+			       inb(MBOXIN2(base)),
+			       inb(MBOXIN3(base))); /* Say What? */
+			/* Host Ready -> Mailbox in complete */
+			outb(G2CNTRL_HRDY,G2CNTRL(base));
+			break;
+			
+		case	G2INTST_CMDGOOD:
+			/* set immediate command success flag here: */
+			break;
+			
+		case	G2INTST_CMDERROR:
+			/* Set immediate command failure flag here: */
+			break;
+		}
+		number_serviced++;
 	}
-	number_serviced++;
-    }
 
-    spin_unlock_irqrestore(host->host_lock, flags);
-    return IRQ_RETVAL(handled);
+	spin_unlock_irqrestore(host->host_lock, flags);
+	return IRQ_RETVAL(handled);
 }
 
 static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
 {
-    unchar direction;
-    unchar *cmd = (unchar *) SCpnt->cmnd;
-    unchar target = SCpnt->device->id;
-    struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host);
-    unsigned long flags;
-    void *buff = SCpnt->request_buffer;
-    int bufflen = SCpnt->request_bufflen;
-    int ecbno;
-    DEB(int i);
-
-    if(*cmd == REQUEST_SENSE)
-    {
-	SCpnt->result = 0;
-	done(SCpnt); 
-	return 0;
-    }
+	unchar direction;
+	unchar *cmd = (unchar *) SCpnt->cmnd;
+	unchar target = SCpnt->device->id;
+	struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host);
+	unsigned long flags;
+	void *buff = SCpnt->request_buffer;
+	int bufflen = SCpnt->request_bufflen;
+	dma_addr_t sg_dma;
+	struct aha1740_sg *sgptr;
+	int ecbno;
+	DEB(int i);
+
+	if(*cmd == REQUEST_SENSE) {
+		SCpnt->result = 0;
+		done(SCpnt); 
+		return 0;
+	}
 
 #ifdef DEBUG
-    if (*cmd == READ_10 || *cmd == WRITE_10)
-	i = xscsi2int(cmd+2);
-    else if (*cmd == READ_6 || *cmd == WRITE_6)
-	i = scsi2int(cmd+2);
-    else
-	i = -1;
-    printk("aha1740_queuecommand: dev %d cmd %02x pos %d len %d ",
-	   target, *cmd, i, bufflen);
-    printk("scsi cmd:");
-    for (i = 0; i < SCpnt->cmd_len; i++) printk("%02x ", cmd[i]);
-    printk("\n");
+	if (*cmd == READ_10 || *cmd == WRITE_10)
+		i = xscsi2int(cmd+2);
+	else if (*cmd == READ_6 || *cmd == WRITE_6)
+		i = scsi2int(cmd+2);
+	else
+		i = -1;
+	printk("aha1740_queuecommand: dev %d cmd %02x pos %d len %d ",
+	       target, *cmd, i, bufflen);
+	printk("scsi cmd:");
+	for (i = 0; i < SCpnt->cmd_len; i++) printk("%02x ", cmd[i]);
+	printk("\n");
 #endif
 
-    /* locate an available ecb */
-
-    spin_lock_irqsave(&aha1740_lock, flags);
-    ecbno = host->last_ecb_used + 1;		/* An optimization */
-    if (ecbno >= AHA1740_ECBS)
-	ecbno = 0;
-    do {
-	if (!host->ecb[ecbno].cmdw)
-	    break;
-	ecbno++;
+	/* locate an available ecb */
+	spin_lock_irqsave(&SCpnt->device->host->host_lock, flags);
+	ecbno = host->last_ecb_used + 1; /* An optimization */
 	if (ecbno >= AHA1740_ECBS)
-	    ecbno = 0;
-    } while (ecbno != host->last_ecb_used);
+		ecbno = 0;
+	do {
+		if (!host->ecb[ecbno].cmdw)
+			break;
+		ecbno++;
+		if (ecbno >= AHA1740_ECBS)
+			ecbno = 0;
+	} while (ecbno != host->last_ecb_used);
 
-    if (host->ecb[ecbno].cmdw)
-	panic("Unable to find empty ecb for aha1740.\n");
+	if (host->ecb[ecbno].cmdw)
+		panic("Unable to find empty ecb for aha1740.\n");
 
-    host->ecb[ecbno].cmdw = AHA1740CMD_INIT;	/* SCSI Initiator Command
-						   doubles as reserved flag */
+	host->ecb[ecbno].cmdw = AHA1740CMD_INIT; /* SCSI Initiator Command
+						    doubles as reserved flag */
 
-    host->last_ecb_used = ecbno;    
-    spin_unlock_irqrestore(&aha1740_lock, flags);
+	host->last_ecb_used = ecbno;    
+	spin_unlock_irqrestore(&SCpnt->device->host->host_lock, flags);
 
 #ifdef DEBUG
-    printk("Sending command (%d %x)...", ecbno, done);
+	printk("Sending command (%d %x)...", ecbno, done);
 #endif
 
-    host->ecb[ecbno].cdblen = SCpnt->cmd_len;	/* SCSI Command Descriptor Block Length */
+	host->ecb[ecbno].cdblen = SCpnt->cmd_len; /* SCSI Command
+						   * Descriptor Block
+						   * Length */
 
-    direction = 0;
-    if (*cmd == READ_10 || *cmd == READ_6)
-	direction = 1;
-    else if (*cmd == WRITE_10 || *cmd == WRITE_6)
 	direction = 0;
-
-    memcpy(host->ecb[ecbno].cdb, cmd, SCpnt->cmd_len);
-
-    if (SCpnt->use_sg)
-    {
-	struct scatterlist * sgpnt;
-	struct aha1740_chain * cptr;
-	int i;
-	DEB(unsigned char * ptr);
-
-	host->ecb[ecbno].sg = 1;  /* SCSI Initiator Command  w/scatter-gather*/
-	SCpnt->host_scribble = (unsigned char *)kmalloc(512, GFP_KERNEL);
-	if(SCpnt->host_scribble == NULL)
-	{
+	if (*cmd == READ_10 || *cmd == READ_6)
+		direction = 1;
+	else if (*cmd == WRITE_10 || *cmd == WRITE_6)
+		direction = 0;
+
+	memcpy(host->ecb[ecbno].cdb, cmd, SCpnt->cmd_len);
+
+	SCpnt->host_scribble = dma_alloc_coherent (&host->edev->dev,
+						   sizeof (struct aha1740_sg),
+						   &sg_dma, GFP_ATOMIC);
+	if(SCpnt->host_scribble == NULL) {
 		printk(KERN_WARNING "aha1740: out of memory in queuecommand!\n");
 		return 1;
 	}
-	sgpnt = (struct scatterlist *) SCpnt->request_buffer;
-	cptr = (struct aha1740_chain *) SCpnt->host_scribble; 
-	for(i=0; i<SCpnt->use_sg; i++)
-	{
-	    cptr[i].datalen = sgpnt[i].length;
-	    cptr[i].dataptr = isa_virt_to_bus(page_address(sgpnt[i].page) + sgpnt[i].offset);
-	}
-	host->ecb[ecbno].datalen = SCpnt->use_sg * sizeof(struct aha1740_chain);
-	host->ecb[ecbno].dataptr = isa_virt_to_bus(cptr);
+	sgptr = (struct aha1740_sg *) SCpnt->host_scribble;
+	sgptr->sg_dma_addr = sg_dma;
+    
+	if (SCpnt->use_sg) {
+		struct scatterlist * sgpnt;
+		struct aha1740_chain * cptr;
+		int i, count;
+		DEB(unsigned char * ptr);
+
+		host->ecb[ecbno].sg = 1;  /* SCSI Initiator Command
+					   * w/scatter-gather*/
+		sgpnt = (struct scatterlist *) SCpnt->request_buffer;
+		cptr = sgptr->sg_chain;
+		count = dma_map_sg (&host->edev->dev, sgpnt, SCpnt->use_sg,
+				    SCpnt->sc_data_direction);
+		for(i=0; i < count; i++) {
+			cptr[i].datalen = sg_dma_len (sgpnt + i);
+			cptr[i].dataptr = sg_dma_address (sgpnt + i);
+		}
+		host->ecb[ecbno].datalen = count*sizeof(struct aha1740_chain);
+		host->ecb[ecbno].dataptr = sg_dma;
 #ifdef DEBUG
-	printk("cptr %x: ",cptr);
-	ptr = (unsigned char *) cptr;
-	for(i=0;i<24;i++) printk("%02x ", ptr[i]);
+		printk("cptr %x: ",cptr);
+		ptr = (unsigned char *) cptr;
+		for(i=0;i<24;i++) printk("%02x ", ptr[i]);
 #endif
-    }
-    else
-    {
-	SCpnt->host_scribble = NULL;
-	host->ecb[ecbno].datalen = bufflen;
-	host->ecb[ecbno].dataptr = isa_virt_to_bus(buff);
-    }
-    host->ecb[ecbno].lun = SCpnt->device->lun;
-    host->ecb[ecbno].ses = 1;	/* Suppress underrun errors */
-    host->ecb[ecbno].dir = direction;
-    host->ecb[ecbno].ars = 1;  /* Yes, get the sense on an error */
-    host->ecb[ecbno].senselen = 12;
-    host->ecb[ecbno].senseptr = isa_virt_to_bus(host->ecb[ecbno].sense);
-    host->ecb[ecbno].statusptr = isa_virt_to_bus(host->ecb[ecbno].status);
-    host->ecb[ecbno].done = done;
-    host->ecb[ecbno].SCpnt = SCpnt;
+	} else {
+		host->ecb[ecbno].datalen = bufflen;
+		sgptr->buf_dma_addr =  dma_map_single (&host->edev->dev,
+						       buff, bufflen,
+						       DMA_BIDIRECTIONAL);
+		host->ecb[ecbno].dataptr = sgptr->buf_dma_addr;
+	}
+	host->ecb[ecbno].lun = SCpnt->device->lun;
+	host->ecb[ecbno].ses = 1; /* Suppress underrun errors */
+	host->ecb[ecbno].dir = direction;
+	host->ecb[ecbno].ars = 1; /* Yes, get the sense on an error */
+	host->ecb[ecbno].senselen = 12;
+	host->ecb[ecbno].senseptr = ecb_cpu_to_dma (SCpnt->device->host,
+						    host->ecb[ecbno].sense);
+	host->ecb[ecbno].statusptr = ecb_cpu_to_dma (SCpnt->device->host,
+						     host->ecb[ecbno].status);
+	host->ecb[ecbno].done = done;
+	host->ecb[ecbno].SCpnt = SCpnt;
 #ifdef DEBUG
-    {
-	int i;
-	printk("aha1740_command: sending.. ");
-	for (i = 0; i < sizeof(host->ecb[ecbno]) - 10; i++)
-	    printk("%02x ", ((unchar *)&host->ecb[ecbno])[i]);
-    }
-    printk("\n");
+	{
+		int i;
+		printk("aha1740_command: sending.. ");
+		for (i = 0; i < sizeof(host->ecb[ecbno]) - 10; i++)
+			printk("%02x ", ((unchar *)&host->ecb[ecbno])[i]);
+	}
+	printk("\n");
 #endif
-    if (done)
-    { /*  The Adaptec Spec says the card is so fast that the loops will
-	  only be executed once in the code below. Even if this was true
-	  with the fastest processors when the spec was written, it doesn't
-	  seem to be true with todays fast processors. We print a warning
-	  if the code is executed more often than LOOPCNT_WARN. If this
-	  happens, it should be investigated. If the count reaches
-	  LOOPCNT_MAX, we assume something is broken; since there is no
-	  way to return an error (the return value is ignored by the
-	  mid-level scsi layer) we have to panic (and maybe that's the
-	  best thing we can do then anyhow). */
+	if (done) {
+	/* The Adaptec Spec says the card is so fast that the loops
+           will only be executed once in the code below. Even if this
+           was true with the fastest processors when the spec was
+           written, it doesn't seem to be true with todays fast
+           processors. We print a warning if the code is executed more
+           often than LOOPCNT_WARN. If this happens, it should be
+           investigated. If the count reaches LOOPCNT_MAX, we assume
+           something is broken; since there is no way to return an
+           error (the return value is ignored by the mid-level scsi
+           layer) we have to panic (and maybe that's the best thing we
+           can do then anyhow). */
 
 #define LOOPCNT_WARN 10		/* excessive mbxout wait -> syslog-msg */
 #define LOOPCNT_MAX 1000000	/* mbxout deadlock -> panic() after ~ 2 sec. */
-	int loopcnt;
-	unsigned int base = SCpnt->device->host->io_port;
-	DEB(printk("aha1740[%d] critical section\n",ecbno));
-
-	spin_lock_irqsave(&aha1740_lock, flags);
-	for (loopcnt = 0; ; loopcnt++) {
-	    if (inb(G2STAT(base)) & G2STAT_MBXOUT) break;
-	    if (loopcnt == LOOPCNT_WARN) {
-		printk("aha1740[%d]_mbxout wait!\n",ecbno);
-	    }
-	    if (loopcnt == LOOPCNT_MAX)
-		panic("aha1740.c: mbxout busy!\n");
-	}
-	outl(isa_virt_to_bus(host->ecb + ecbno), MBOXOUT0(base));
-	for (loopcnt = 0; ; loopcnt++) {
-	    if (! (inb(G2STAT(base)) & G2STAT_BUSY)) break;
-	    if (loopcnt == LOOPCNT_WARN) {
-		printk("aha1740[%d]_attn wait!\n",ecbno);
-	    }
-	    if (loopcnt == LOOPCNT_MAX)
-		panic("aha1740.c: attn wait failed!\n");
-	}
-	outb(ATTN_START | (target & 7), ATTN(base)); /* Start it up */
-	spin_unlock_irqrestore(&aha1740_lock, flags);
-	DEB(printk("aha1740[%d] request queued.\n",ecbno));
-    }
-    else
-	printk(KERN_ALERT "aha1740_queuecommand: done can't be NULL\n");
-    return 0;
+		int loopcnt;
+		unsigned int base = SCpnt->device->host->io_port;
+		DEB(printk("aha1740[%d] critical section\n",ecbno));
+
+		spin_lock_irqsave(&SCpnt->device->host->host_lock, flags);
+		for (loopcnt = 0; ; loopcnt++) {
+			if (inb(G2STAT(base)) & G2STAT_MBXOUT) break;
+			if (loopcnt == LOOPCNT_WARN) {
+				printk("aha1740[%d]_mbxout wait!\n",ecbno);
+			}
+			if (loopcnt == LOOPCNT_MAX)
+				panic("aha1740.c: mbxout busy!\n");
+		}
+		outl (ecb_cpu_to_dma (SCpnt->device->host, host->ecb + ecbno),
+		      MBOXOUT0(base));
+		for (loopcnt = 0; ; loopcnt++) {
+			if (! (inb(G2STAT(base)) & G2STAT_BUSY)) break;
+			if (loopcnt == LOOPCNT_WARN) {
+				printk("aha1740[%d]_attn wait!\n",ecbno);
+			}
+			if (loopcnt == LOOPCNT_MAX)
+				panic("aha1740.c: attn wait failed!\n");
+		}
+		outb(ATTN_START | (target & 7), ATTN(base)); /* Start it up */
+		spin_unlock_irqrestore(&SCpnt->device->host->host_lock, flags);
+		DEB(printk("aha1740[%d] request queued.\n",ecbno));
+	} else
+		printk(KERN_ALERT "aha1740_queuecommand: done can't be NULL\n");
+	return 0;
 }
 
 /* Query the board for its irq_level.  Nothing else matters
    in enhanced mode on an EISA bus. */
 
 static void aha1740_getconfig(unsigned int base, unsigned int *irq_level,
-		       unsigned int *translation)
+			      unsigned int *translation)
 {
-    static int intab[] = { 9, 10, 11, 12, 0, 14, 15, 0 };
+	static int intab[] = { 9, 10, 11, 12, 0, 14, 15, 0 };
 
-    *irq_level = intab[inb(INTDEF(base)) & 0x7];
-    *translation = inb(RESV1(base)) & 0x1;
-    outb(inb(INTDEF(base)) | 0x10, INTDEF(base));
+	*irq_level = intab[inb(INTDEF(base)) & 0x7];
+	*translation = inb(RESV1(base)) & 0x1;
+	outb(inb(INTDEF(base)) | 0x10, INTDEF(base));
 }
 
-static int aha1740_detect(Scsi_Host_Template * tpnt)
+static int aha1740_biosparam(struct scsi_device *sdev,
+			     struct block_device *dev,
+			     sector_t capacity, int* ip)
 {
-    int count = 0, slot;
+	int size = capacity;
+	int extended = HOSTDATA(sdev->host)->translation;
 
-    DEB(printk("aha1740_detect: \n"));
+	DEB(printk("aha1740_biosparam\n"));
+	if (extended && (ip[2] > 1024))	{
+		ip[0] = 255;
+		ip[1] = 63;
+		ip[2] = size / (255 * 63);
+	} else {
+		ip[0] = 64;
+		ip[1] = 32;
+		ip[2] = size >> 11;
+	}
+	return 0;
+}
+
+static int aha1740_eh_abort_handler (Scsi_Cmnd *dummy)
+{
+/*
+ * From Alan Cox :
+ * The AHA1740 has firmware handled abort/reset handling. The "head in
+ * sand" kernel code is correct for once 8)
+ *
+ * So we define a dummy handler just to keep the kernel SCSI code as
+ * quiet as possible...
+ */
 
-    for ( slot=MINEISA; slot <= MAXEISA; slot++ )
-    {
+	return 0;
+}
+
+static Scsi_Host_Template aha1740_template = {
+	.module           = THIS_MODULE,
+	.proc_name        = "aha1740",
+	.proc_info        = aha1740_proc_info,
+	.name             = "Adaptec 174x (EISA)",
+	.queuecommand     = aha1740_queuecommand,
+	.bios_param       = aha1740_biosparam,
+	.can_queue        = AHA1740_ECBS,
+	.this_id          = 7,
+	.sg_tablesize     = AHA1740_SCATTER,
+	.cmd_per_lun      = AHA1740_CMDLUN,
+	.use_clustering   = ENABLE_CLUSTERING,
+	.eh_abort_handler = aha1740_eh_abort_handler,
+};
+
+static int aha1740_probe (struct device *dev)
+{
 	int slotbase;
 	unsigned int irq_level, translation;
 	struct Scsi_Host *shpnt;
 	struct aha1740_hostdata *host;
-	slotbase = SLOTBASE(slot);
-	/*
-	 * The ioports for eisa boards are generally beyond that used in the
-	 * check/allocate region code, but this may change at some point,
-	 * so we go through the motions.
-	 */
-	if (!request_region(slotbase, SLOTSIZE, "aha1740"))  /* See if in use */
-	    continue;
+	struct eisa_device *edev = to_eisa_device (dev);
+
+	DEB(printk("aha1740_probe: \n"));
+	
+	slotbase = edev->base_addr + EISA_VENDOR_ID_OFFSET;
+	if (!request_region(slotbase, SLOTSIZE, "aha1740")) /* See if in use */
+		return -EBUSY;
 	if (!aha1740_test_port(slotbase))
-	    goto err_release;
+		goto err_release;
 	aha1740_getconfig(slotbase,&irq_level,&translation);
 	if ((inb(G2STAT(slotbase)) &
-	     (G2STAT_MBXOUT|G2STAT_BUSY)) != G2STAT_MBXOUT)
-	{	/* If the card isn't ready, hard reset it */
-	    outb(G2CNTRL_HRST, G2CNTRL(slotbase));
-	    outb(0, G2CNTRL(slotbase));
+	     (G2STAT_MBXOUT|G2STAT_BUSY)) != G2STAT_MBXOUT) {
+		/* If the card isn't ready, hard reset it */
+		outb(G2CNTRL_HRST, G2CNTRL(slotbase));
+		outb(0, G2CNTRL(slotbase));
 	}
-	printk(KERN_INFO "Configuring aha174x at IO:%x, IRQ %d\n", slotbase, irq_level);
+	printk(KERN_INFO "Configuring %s at IO:%x, IRQ %d\n",
+	       dev->name, slotbase, irq_level);
 	printk(KERN_INFO "aha174x: Extended translation %sabled.\n",
 	       translation ? "en" : "dis");
-	DEB(printk("aha1740_detect: enable interrupt channel %d\n",irq_level));
-	if (request_irq(irq_level,aha1740_intr_handle,0,"aha1740",NULL)) {
-	    printk("Unable to allocate IRQ for adaptec controller.\n");
-	    goto err_release;
-	}
-	shpnt = scsi_register(tpnt, sizeof(struct aha1740_hostdata));
+	shpnt = scsi_host_alloc(&aha1740_template,
+			      sizeof(struct aha1740_hostdata));
 	if(shpnt == NULL)
-		goto err_free_irq;
+		goto err_release;
 
 	shpnt->base = 0;
 	shpnt->io_port = slotbase;
@@ -537,70 +617,80 @@
 	shpnt->irq = irq_level;
 	shpnt->dma_channel = 0xff;
 	host = HOSTDATA(shpnt);
-	host->slot = slot;
+	host->edev = edev;
 	host->translation = translation;
-	aha_host[irq_level - 9] = shpnt;
-	count++;
-	continue;
-
-    err_free_irq:
-	free_irq(irq_level, aha1740_intr_handle);
-    err_release:
+	host->ecb_dma_addr = dma_map_single (&edev->dev, host->ecb,
+					     sizeof (host->ecb),
+					     DMA_BIDIRECTIONAL);
+	if (!host->ecb_dma_addr) {
+		printk (KERN_ERR "aha1740_probe: Couldn't map ECB, giving up\n");
+		scsi_unregister (shpnt);
+		goto err_release;
+	}
+	
+	DEB(printk("aha1740_probe: enable interrupt channel %d\n",irq_level));
+	if (request_irq(irq_level,aha1740_intr_handle,0,"aha1740",shpnt)) {
+		printk(KERN_ERR "aha1740_probe: Unable to allocate IRQ %d.\n",
+		       irq_level);
+		goto err_release;
+	}
+
+	eisa_set_drvdata (edev, shpnt);
+	scsi_add_host (shpnt, dev);
+	return 0;
+
+ err_release:
 	release_region(slotbase, SLOTSIZE);
-    }
-    return count;
+
+	return -ENODEV;
 }
 
-static int aha1740_release(struct Scsi_Host *shost)
+static __devexit int aha1740_remove (struct device *dev)
 {
-	if (shost->irq)
-		free_irq(shost->irq, NULL);
-	if (shost->io_port && shost->n_io_port)
-		release_region(shost->io_port, shost->n_io_port);
-	scsi_unregister(shost);
+	struct Scsi_Host *shpnt = dev->driver_data;
+	struct aha1740_hostdata *host = HOSTDATA (shpnt);
+
+	if (scsi_remove_host (shpnt))
+		return -EBUSY;
+	
+	free_irq (shpnt->irq, shpnt);
+	dma_unmap_single (dev, host->ecb_dma_addr,
+			  sizeof (host->ecb), DMA_BIDIRECTIONAL);
+	release_region (shpnt->io_port, SLOTSIZE);
+
+	scsi_host_put (shpnt);
+	
 	return 0;
 }
 
-static int aha1740_biosparam(struct scsi_device *sdev, struct block_device *dev,
-		sector_t capacity, int* ip)
-{
-    int size = capacity;
-    int extended = HOSTDATA(sdev->host)->translation;
+static struct eisa_device_id aha1740_ids[] = {
+	{ "ADP0000" },		/* 1740  */
+	{ "ADP0001" },		/* 1740A */
+	{ "ADP0002" },		/* 1742A */
+	{ "ADP0400" },		/* 1744  */
+	{ "" }
+};
+
+static struct eisa_driver aha1740_driver = {
+	.id_table = aha1740_ids,
+	.driver   = {
+		.name    = "aha1740",
+		.probe   = aha1740_probe,
+		.remove  = __devexit_p (aha1740_remove),
+	},
+};
 
-    DEB(printk("aha1740_biosparam\n"));
-    if (extended && (ip[2] > 1024))
-    {
-	ip[0] = 255;
-	ip[1] = 63;
-	ip[2] = size / (255 * 63);
-    }
-    else
-    {
-	ip[0] = 64;
-	ip[1] = 32;
-	ip[2] = size >> 11;
-    }
-    return 0;
+static __init int aha1740_init (void)
+{
+	return eisa_driver_register (&aha1740_driver);
 }
 
-MODULE_LICENSE("GPL");
+static __exit void aha1740_exit (void)
+{
+	eisa_driver_unregister (&aha1740_driver);
+}
 
-static Scsi_Host_Template driver_template = {
-	.proc_name		= "aha1740",
-	.proc_info		= aha1740_proc_info,
-	.name			= "Adaptec 174x (EISA)",
-	.detect			= aha1740_detect,
-	.release		= aha1740_release,
-	.queuecommand		= aha1740_queuecommand,
-	.bios_param		= aha1740_biosparam,
-	.can_queue		= AHA1740_ECBS,
-	.this_id		= 7, 
-	.sg_tablesize		= AHA1740_SCATTER,
-	.cmd_per_lun		= AHA1740_CMDLUN, 
-	.use_clustering		= ENABLE_CLUSTERING,
-};
-#include "scsi_module.c"
+module_init (aha1740_init);
+module_exit (aha1740_exit);
 
-/* Okay, you made it all the way through.  As of this writing, 3/31/93, I'm
-brad@saturn.gaylord.com or brad@bradpc.gaylord.com.  I'll try to help as time
-permits if you have any trouble with this driver.  Happy Linuxing! */
+MODULE_LICENSE("GPL");
diff -urN linux-2.5.73-bk8/drivers/scsi/aha1740.h linux-2.5.73-bk9/drivers/scsi/aha1740.h
--- linux-2.5.73-bk8/drivers/scsi/aha1740.h	2003-06-22 11:32:56.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/aha1740.h	2003-07-01 04:51:38.000000000 -0700
@@ -12,11 +12,6 @@
 
 #include <linux/types.h>
 
-/* Eisa Enhanced mode operation - slot locating and addressing */
-#define MINEISA 1		/* I don't have an EISA Spec to know these ranges, so I */
-#define MAXEISA 8		/* Just took my machine's specifications.  Adjust to fit. */
-		    /* I just saw an ad, and bumped this from 6 to 8 */
-#define	SLOTBASE(x)	((x << 12) + 0xc80)
 #define SLOTSIZE	0x5c
 
 /* EISA configuration registers & values */
@@ -152,11 +147,6 @@
 #define AHA1740CMD_RINQ  0x0a	/* Read Host Adapter Inquiry Data */
 #define AHA1740CMD_TARG  0x10	/* Target SCSI Command */
 
-static int aha1740_detect(Scsi_Host_Template *);
-static int aha1740_command(Scsi_Cmnd *);
-static int aha1740_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
-static int aha1740_biosparam(struct scsi_device *, struct block_device *, sector_t, int *);
-
 #define AHA1740_ECBS 32
 #define AHA1740_SCATTER 16
 #define AHA1740_CMDLUN 1
diff -urN linux-2.5.73-bk8/drivers/scsi/dc395x.c linux-2.5.73-bk9/drivers/scsi/dc395x.c
--- linux-2.5.73-bk8/drivers/scsi/dc395x.c	2003-06-22 11:32:33.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/dc395x.c	2003-07-01 04:51:38.000000000 -0700
@@ -59,6 +59,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <linux/pci.h>
 
 /*---------------------------------------------------------------------------
                                   Features
diff -urN linux-2.5.73-bk8/drivers/scsi/hosts.c linux-2.5.73-bk9/drivers/scsi/hosts.c
--- linux-2.5.73-bk8/drivers/scsi/hosts.c	2003-06-22 11:32:31.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/hosts.c	2003-07-01 04:51:39.000000000 -0700
@@ -82,6 +82,13 @@
 			sht->info ? sht->info(shost) : sht->name);
 
 	error = scsi_sysfs_add_host(shost, dev);
+
+	if (!shost->can_queue) {
+		printk(KERN_ERR "%s: can_queue = 0 no longer supported\n",
+				sht->name);
+		error = -EINVAL;
+	}
+
 	if (!error) {
 		scsi_proc_host_add(shost);
 		scsi_scan_host(shost);
@@ -187,7 +194,7 @@
 	shost->use_blk_tcq = sht->use_blk_tcq;
 	shost->highmem_io = sht->highmem_io;
 
-	if (!sht->max_host_blocked)
+	if (sht->max_host_blocked)
 		shost->max_host_blocked = sht->max_host_blocked;
 	else
 		shost->max_host_blocked = SCSI_DEFAULT_HOST_BLOCKED;
diff -urN linux-2.5.73-bk8/drivers/scsi/hosts.h linux-2.5.73-bk9/drivers/scsi/hosts.h
--- linux-2.5.73-bk8/drivers/scsi/hosts.h	2003-06-22 11:32:39.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/hosts.h	2003-07-01 04:51:39.000000000 -0700
@@ -26,29 +26,9 @@
 
 #include <linux/config.h>
 #include <linux/proc_fs.h>
-#include <linux/types.h>
 
 #include <scsi/scsi_host.h>
 
-struct scsi_driver {
-	struct module		*owner;
-	struct device_driver	gendrv;
-
-	int (*init_command)(struct scsi_cmnd *);
-	void (*rescan)(struct device *);
-};
-#define to_scsi_driver(drv) \
-	container_of((drv), struct scsi_driver, gendrv)
-
-extern int scsi_register_driver(struct device_driver *);
-#define scsi_unregister_driver(drv) \
-	driver_unregister(drv);
-
-extern int scsi_register_interface(struct class_interface *);
-#define scsi_unregister_interface(intf) \
-	class_interface_unregister(intf)
-
-
 /**
  * scsi_find_device - find a device given the host
  * @shost:	SCSI host pointer
diff -urN linux-2.5.73-bk8/drivers/scsi/ibmmca.c linux-2.5.73-bk9/drivers/scsi/ibmmca.c
--- linux-2.5.73-bk8/drivers/scsi/ibmmca.c	2003-06-22 11:32:32.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/ibmmca.c	2003-07-01 04:51:39.000000000 -0700
@@ -2379,7 +2379,6 @@
 {
 	int len = 0;
 	int i, id, lun, host_index;
-	struct Scsi_Host *shpnt;
 	unsigned long flags;
 	int max_pun;
 
@@ -2452,11 +2451,6 @@
 	return len;
 }
 
-static void ibmmca_scsi_setup(char *str, int *ints)
-{
-	internal_ibmmca_scsi_setup(str, ints);
-}
-
 static int option_setup(char *str)
 {
 	int ints[IM_MAX_HOSTS];
diff -urN linux-2.5.73-bk8/drivers/scsi/ibmmca.h linux-2.5.73-bk9/drivers/scsi/ibmmca.h
--- linux-2.5.73-bk8/drivers/scsi/ibmmca.h	2003-06-22 11:32:58.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/ibmmca.h	2003-07-01 04:51:39.000000000 -0700
@@ -13,7 +13,6 @@
 /* Interfaces to the midlevel Linux SCSI driver */
 static int ibmmca_detect (Scsi_Host_Template *);
 static int ibmmca_release (struct Scsi_Host *);
-static int ibmmca_command (Scsi_Cmnd *);
 static int ibmmca_queuecommand (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
 static int ibmmca_abort (Scsi_Cmnd *);
 static int ibmmca_host_reset (Scsi_Cmnd *);
diff -urN linux-2.5.73-bk8/drivers/scsi/ips.c linux-2.5.73-bk9/drivers/scsi/ips.c
--- linux-2.5.73-bk8/drivers/scsi/ips.c	2003-06-22 11:32:28.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/ips.c	2003-07-01 04:51:39.000000000 -0700
@@ -7009,10 +7009,10 @@
      * are guaranteed to be < 4G.
      */
     if ( IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) &&
-         !pci_set_dma_mask(ha->pcidev, (u64)0xffffffffffffffff)) {
+         !pci_set_dma_mask(ha->pcidev, 0xffffffffffffffffULL)) {
        (ha)->flags |= IPS_HA_ENH_SG;
     } else {
-       if ( pci_set_dma_mask(ha->pcidev, (u64)0xffffffff) != 0 ) { 
+       if ( pci_set_dma_mask(ha->pcidev, 0xffffffffULL) != 0 ) { 
           printk(KERN_WARNING "Unable to set DMA Mask\n");
           return ips_abort_init(ha, index);
        }
diff -urN linux-2.5.73-bk8/drivers/scsi/lasi700.c linux-2.5.73-bk9/drivers/scsi/lasi700.c
--- linux-2.5.73-bk8/drivers/scsi/lasi700.c	2003-06-22 11:32:32.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/lasi700.c	2003-07-01 04:51:39.000000000 -0700
@@ -76,6 +76,7 @@
 	.name =		"Lasi SCSI",
 	.id_table =	lasi700_scsi_tbl,
 	.probe =	lasi700_driver_callback,
+	.remove =	__devexit_p(lasi700_driver_remove),
 };
 
 static int __init
@@ -97,12 +98,6 @@
 	}
 	memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
 
-	if (!request_mem_region(base, 64, dev->dev.name)) {
-		printk(KERN_ERR "%s: Failed to claim memory region\n",
-		       dev->dev.name);
-		goto out_kfree;
-	}
-
 	hostdata->dev = &dev->dev;
 	dma_set_mask(&dev->dev, 0xffffffffUL);
 	hostdata->base = base;
@@ -122,7 +117,7 @@
 
 	host = NCR_700_detect(&lasi700_template, hostdata);
 	if (!host)
-		goto out_release_mem_region;
+		goto out_kfree;
 
 	host->irq = dev->irq;
 	if (request_irq(dev->irq, NCR_700_intr, SA_SHIRQ,
@@ -132,33 +127,33 @@
 		goto out_put_host;
 	}
 
+	dev_set_drvdata(&dev->dev, host);
 	scsi_add_host(host, &dev->dev);
+
 	return 0;
 
  out_put_host:
 	scsi_host_put(host);
- out_release_mem_region:
-	release_mem_region(base, 64);
+
  out_kfree:
 	kfree(hostdata);
-	return 1;
+	return -ENODEV;
 }
 
-#if 0
-static int
-lasi700_release(struct Scsi_Host *host)
+static int __exit
+lasi700_driver_remove(struct parisc_device *dev)
 {
-	struct D700_Host_Parameters *hostdata = 
-		(struct D700_Host_Parameters *)host->hostdata[0];
+	struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
+	struct NCR_700_Host_Parameters *hostdata = 
+		(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
+	scsi_remove_host(host);
 	NCR_700_release(host);
-	kfree(hostdata);
 	free_irq(host->irq, host);
-	release_mem_region(host->base, 64);
-	unregister_parisc_driver(&lasi700_driver);
-	return 1;
+	kfree(hostdata);
+
+	return 0;
 }
-#endif
 
 static int __init
 lasi700_init(void)
@@ -166,4 +161,12 @@
 	return register_parisc_driver(&lasi700_driver);
 }
 
+static void __exit
+lasi700_exit(void)
+{
+	unregister_parisc_driver(&lasi700_driver);
+	scsi_sysfs_release_attributes(&lasi700_template);
+}
+
 module_init(lasi700_init);
+module_exit(lasi700_exit);
diff -urN linux-2.5.73-bk8/drivers/scsi/lasi700.h linux-2.5.73-bk9/drivers/scsi/lasi700.h
--- linux-2.5.73-bk8/drivers/scsi/lasi700.h	2003-06-22 11:32:33.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/lasi700.h	2003-07-01 04:51:39.000000000 -0700
@@ -25,9 +25,8 @@
 #ifndef _LASI700_H
 #define _LASI700_H
 
-static int lasi700_detect(Scsi_Host_Template *);
 static int lasi700_driver_callback(struct parisc_device *dev);
-static int lasi700_release(struct Scsi_Host *host);
+static int lasi700_driver_remove(struct parisc_device *dev);
 
 #define LASI_710_SVERSION	0x082
 #define LASI_700_SVERSION	0x071
diff -urN linux-2.5.73-bk8/drivers/scsi/megaraid.c linux-2.5.73-bk9/drivers/scsi/megaraid.c
--- linux-2.5.73-bk8/drivers/scsi/megaraid.c	2003-06-22 11:32:27.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/megaraid.c	2003-07-01 04:51:39.000000000 -0700
@@ -40,6 +40,7 @@
 #include <linux/module.h>
 #include <linux/list.h>
 #include <linux/interrupt.h>
+#include <linux/pci.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
diff -urN linux-2.5.73-bk8/drivers/scsi/ncr53c8xx.c linux-2.5.73-bk9/drivers/scsi/ncr53c8xx.c
--- linux-2.5.73-bk8/drivers/scsi/ncr53c8xx.c	2003-06-22 11:32:39.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/ncr53c8xx.c	2003-07-01 04:51:39.000000000 -0700
@@ -82,7 +82,7 @@
 **	    Etc...
 **
 **	Supported NCR/SYMBIOS chips:
-**		53C720		(Wide,   Fast SCSI-2, HP Zalon)
+**		53C720		(Wide,   Fast SCSI-2, intfly problems)
 **		53C810		(8 bits, Fast SCSI-2, no rom BIOS) 
 **		53C815		(8 bits, Fast SCSI-2, on board rom BIOS)
 **		53C820		(Wide,   Fast SCSI-2, no rom BIOS)
@@ -173,31 +173,6 @@
 #endif
 #endif
 
-/*
-**	Define the BSD style u_int32 and u_int64 type.
-**	Are in fact u_int32_t and u_int64_t :-)
-*/
-typedef u32 u_int32;
-typedef u64 u_int64;
-typedef	u_long		vm_offset_t;
-
-#ifdef __hppa__
-/*
- * Yuck.  Current plan is to use ncr58c8xx.c for non-pci big endian
- * chips, and sym53c8xx.c for pci little endian chips.  Define this
- * here so it gets seen by sym53c8xx_defs.h, pulled in via ncr53c8xx.h.
- */
-#define SCSI_NCR_BIG_ENDIAN
-/* INTFLY interrupts don't always seem to get serviced atm..... */
-#define SIMULATED_INTFLY
-#endif
-
-#if defined(CONFIG_SCSI_ZALON) || defined(CONFIG_SCSI_ZALON_MODULE)
-#define ENABLE_SCSI_ZALON
-#include <asm/parisc-device.h>
-#include "zalon.h"
-#endif
-
 #include "ncr53c8xx.h"
 
 /*
@@ -215,6 +190,12 @@
 
 #include "sym53c8xx_comm.h"
 
+int ncr53c8xx_slave_configure(Scsi_Device *device);
+int ncr53c8xx_bus_reset(Scsi_Cmnd *cmd);
+int ncr53c8xx_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *));
+const char *ncr53c8xx_info (struct Scsi_Host *host);
+
+
 /*==========================================================
 **
 **	The CCB done queue uses an array of CCB virtual 
@@ -397,7 +378,6 @@
 
 #define ScsiResult(host_code, scsi_code) (((host_code) << 16) + ((scsi_code) & 0x7f))
 
-static irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
 static void ncr53c8xx_timeout(unsigned long np);
 static int ncr53c8xx_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
 			int length, int func);
@@ -1245,7 +1225,7 @@
 **	return from the subroutine.
 */
 
-#ifdef ENABLE_SCSI_ZALON
+#ifdef CONFIG_NCR53C8XX_PREFETCH
 #define PREFETCH_FLUSH_CNT	2
 #define PREFETCH_FLUSH		SCR_CALL, PADDRH (wait_dma),
 #else
@@ -1419,8 +1399,6 @@
 static	void	ncr_usercmd	(ncb_p np);
 #endif
 
-static int ncr_attach (Scsi_Host_Template *tpnt, int unit, ncr_device *device);
-
 static void insert_into_waiting_list(ncb_p np, Scsi_Cmnd *cmd);
 static Scsi_Cmnd *retrieve_from_waiting_list(int to_remove, ncb_p np, Scsi_Cmnd *cmd);
 static void process_waiting_list(ncb_p np, int sts);
@@ -3236,7 +3214,7 @@
  *	ctest4 for others.
  */
 #define burst_code(dmode, ctest0, ctest4, ctest5) \
-	(np->device_id == PSEUDO_ZALON_720_ID) ? \
+	(np->device_id == PSEUDO_720_ID) ? \
 	(ctest0) & 0x80? 0 : (((dmode) & 0xc0) >> 6) + 1 : \
 	(ctest4) & 0x80? 0 : (((dmode) & 0xc0) >> 6) + ((ctest5) & 0x04) + 1
 
@@ -3245,7 +3223,7 @@
  */
 static inline void ncr_init_burst(ncb_p np, u_char bc)
 {
-	u_char *be = (np->device_id == PSEUDO_ZALON_720_ID) ?
+	u_char *be = (np->device_id == PSEUDO_720_ID) ?
 		&np->rv_ctest0 : &np->rv_ctest4;
 	*be		&= ~0x80;
 	np->rv_dmode	&= ~(0x3 << 6);
@@ -3646,7 +3624,7 @@
 **	start the timer daemon.
 */
 
-static int __init 
+struct Scsi_Host * __init 
 ncr_attach (Scsi_Host_Template *tpnt, int unit, ncr_device *device)
 {
         struct host_data *host_data;
@@ -3656,7 +3634,22 @@
 	ncr_nvram *nvram = device->nvram;
 	int i;
 
-#ifndef ENABLE_SCSI_ZALON
+#ifdef SCSI_NCR_PROC_INFO_SUPPORT
+	tpnt->proc_info		= ncr53c8xx_proc_info,
+#endif
+	tpnt->info 		= ncr53c8xx_info;
+	tpnt->queuecommand	= ncr53c8xx_queue_command;
+	tpnt->slave_configure	= ncr53c8xx_slave_configure;
+	tpnt->eh_bus_reset_handler	= ncr53c8xx_bus_reset;
+	tpnt->can_queue		= SCSI_NCR_CAN_QUEUE;
+	tpnt->this_id		= 7;
+	tpnt->sg_tablesize	= SCSI_NCR_SG_TABLESIZE;
+	tpnt->cmd_per_lun	= SCSI_NCR_CMD_PER_LUN;
+	tpnt->use_clustering	= DISABLE_CLUSTERING;
+
+	if(device->differential)
+		driver_setup.diff_support = device->differential;
+
 	printk(KERN_INFO "ncr53c%s-%d: rev 0x%x on pci bus %d device %d function %d "
 #ifdef __sparc__
 		"irq %s\n",
@@ -3671,12 +3664,11 @@
 #else
 		device->slot.irq);
 #endif
-#endif
 
 	/*
 	**	Allocate host_data structure
 	*/
-        if (!(instance = scsi_register(tpnt, sizeof(*host_data))))
+        if (!(instance = scsi_host_alloc(tpnt, sizeof(*host_data))))
 	        goto attach_error;
 	host_data = (struct host_data *) instance->hostdata;
 
@@ -3744,7 +3736,11 @@
 	np->paddr2	= (np->features & FE_RAM)? device->slot.base_2 : 0;
 
 #ifndef SCSI_NCR_IOMAPPED
-	np->vaddr = remap_pci_mem(device->slot.base_c, (u_long) 128);
+	if(device->slot.base_v)
+		np->vaddr = device->slot.base_v;
+	else
+		np->vaddr = remap_pci_mem(device->slot.base_c, (u_long) 128);
+
 	if (!np->vaddr) {
 		printk(KERN_ERR
 			"%s: can't map memory mapped IO region\n",ncr_name(np));
@@ -3763,16 +3759,14 @@
 
 	np->reg = (struct ncr_reg*) np->vaddr;
 
-#endif /* !defined SCSI_NCR_IOMAPPED */
+#else
 
 	/*
 	**	Try to map the controller chip into iospace.
 	*/
 
-#ifndef ENABLE_SCSI_ZALON
-	request_region(device->slot.io_port, 128, "ncr53c8xx");
-#endif
 	np->base_io = device->slot.io_port;
+#endif /* !defined SCSI_NCR_IOMAPPED */
 
 #ifdef SCSI_NCR_NVRAM_SUPPORT
 	if (nvram) {
@@ -3898,24 +3892,6 @@
 	**	Install the interrupt handler.
 	*/
 
-	if (request_irq(device->slot.irq, ncr53c8xx_intr,
-			((driver_setup.irqm & 0x10) ? 0 : SA_SHIRQ) |
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
-			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
-#else
-			0,
-#endif
-			"ncr53c8xx", np)) {
-#ifdef __sparc__
-		printk(KERN_ERR "%s: request irq %s failure\n",
-			ncr_name(np), __irq_itoa(device->slot.irq));
-#else
-		printk(KERN_ERR "%s: request irq %d failure\n",
-			ncr_name(np), device->slot.irq);
-#endif
-		goto attach_error;
-	}
-
 	np->irq = device->slot.irq;
 
 	/*
@@ -3981,40 +3957,13 @@
 
 	NCR_UNLOCK_NCB(np, flags);
 
-	return 0;
+	return instance;
 
 attach_error:
-	if (!instance) return -1;
+	if (!instance) return NULL;
 	printk(KERN_INFO "%s: detaching...\n", ncr_name(np));
 	if (!np)
 		goto unregister;
-#ifndef SCSI_NCR_IOMAPPED
-	if (np->vaddr) {
-#ifdef DEBUG_NCR53C8XX
-		printk(KERN_DEBUG "%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128);
-#endif
-		unmap_pci_mem((vm_offset_t) np->vaddr, (u_long) 128);
-	}
-#endif /* !SCSI_NCR_IOMAPPED */
-	if (np->base_io) {
-#ifdef DEBUG_NCR53C8XX
-		printk(KERN_DEBUG "%s: releasing IO region %x[%d]\n", ncr_name(np), np->base_io, 128);
-#endif
-#ifndef ENABLE_SCSI_ZALON
-		release_region(np->base_io, 128);
-#endif
-	}
-	if (np->irq) {
-#ifdef DEBUG_NCR53C8XX
-#ifdef __sparc__
-	printk(KERN_INFO "%s: freeing irq %s\n", ncr_name(np),
-	       __irq_itoa(np->irq));
-#else
-	printk(KERN_INFO "%s: freeing irq %d\n", ncr_name(np), np->irq);
-#endif
-#endif
-		free_irq(np->irq, np);
-	}
 	if (np->scripth0)
 		m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH");
 	if (np->script0)
@@ -4024,9 +3973,9 @@
 	m_free_dma(np, sizeof(struct ncb), "NCB");
 
 unregister:
-	scsi_unregister(instance);
+	scsi_host_put(instance);
 
-        return -1;
+        return NULL;
 }
 
 
@@ -4823,7 +4772,7 @@
 	**	properly set IRQ mode, prior to resetting the bus.
 	*/
 	OUTB (nc_stest3, TE);
-	if (np->device_id != PSEUDO_ZALON_720_ID)
+	if (np->device_id != PSEUDO_720_ID)
 		OUTB (nc_dcntl, (np->rv_dcntl & IRQM));
 	OUTB (nc_scntl1, CRST);
 	UDELAY (200);
@@ -5061,19 +5010,6 @@
 	OUTW (nc_sien , 0);
 	OUTB (nc_dien , 0);
 
-/*
-**	Free irq
-*/
-
-#ifdef DEBUG_NCR53C8XX
-#ifdef __sparc__
-	printk("%s: freeing irq %s\n", ncr_name(np), __irq_itoa(np->irq));
-#else
-	printk("%s: freeing irq %d\n", ncr_name(np), np->irq);
-#endif
-#endif
-	free_irq(np->irq, np);
-
 	/*
 	**	Reset NCR chip
 	**	Restore bios setting for automatic clock detection.
@@ -5094,24 +5030,6 @@
 	ncr_selectclock(np, np->sv_scntl3);
 
 	/*
-	**	Release Memory mapped IO region and IO mapped region
-	*/
-
-#ifndef SCSI_NCR_IOMAPPED
-#ifdef DEBUG_NCR53C8XX
-	printk("%s: releasing memory mapped IO region %lx[%d]\n", ncr_name(np), (u_long) np->vaddr, 128);
-#endif
-	unmap_pci_mem((vm_offset_t) np->vaddr, (u_long) 128);
-#endif /* !SCSI_NCR_IOMAPPED */
-
-#ifdef DEBUG_NCR53C8XX
-	printk("%s: releasing IO region %x[%d]\n", ncr_name(np), np->base_io, 128);
-#endif
-#ifndef ENABLE_SCSI_ZALON
-	release_region(np->base_io, 128);
-#endif
-
-	/*
 	**	Free allocated ccb(s)
 	*/
 
@@ -8634,7 +8552,7 @@
 		f1 = ncrgetfreq (np, 11);
 		f2 = ncrgetfreq (np, 11);
 
-		if (bootverbose)
+		if(bootverbose)
 			printk ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2);
 
 		if (f1 > f2) f1 = f2;		/* trust lower result	*/
@@ -8774,10 +8692,12 @@
 **   routine for each host that uses this IRQ.
 */
 
-static irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
+irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
 {
      unsigned long flags;
-     ncb_p np = (ncb_p) dev_id;
+     struct Scsi_Host *shost = (struct Scsi_Host *)dev_id;
+     struct host_data *host_data = (struct host_data *)shost->hostdata;
+     ncb_p np = host_data->ncb;
      Scsi_Cmnd *done_list;
 
 #ifdef DEBUG_NCR53C8XX
@@ -9188,7 +9108,7 @@
 	if (len)
 		return -EINVAL;
 	else {
-		long flags;
+		unsigned long flags;
 
 		NCR_LOCK_NCB(np, flags);
 		ncr_usercmd (np);
@@ -9335,7 +9255,7 @@
 */
 
 static u_short	ncr_chip_ids[]   __initdata = {
-	PSEUDO_ZALON_720_ID,
+	PSEUDO_720_ID,
 	PCI_DEVICE_ID_NCR_53C810,
 	PCI_DEVICE_ID_NCR_53C815,
 	PCI_DEVICE_ID_NCR_53C820,
@@ -9350,73 +9270,6 @@
 	PCI_DEVICE_ID_NCR_53C1510D
 };
 
-#ifdef ENABLE_SCSI_ZALON
-/* Attach a 53c720 interfaced via Zalon chip on HP boxes.  */
-int zalon_attach(Scsi_Host_Template *tpnt, unsigned long io_port,
-		struct parisc_device *dev, int irq, int unit)
-{
-	u_short device_id;
-	u_char revision;
-	int i;
-	ncr_chip *chip;
-	ncr_device device;
-
-	tpnt->proc_name = NAME53C8XX;
-	tpnt->proc_info = ncr53c8xx_proc_info;
-
-#if	defined(SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT) && defined(MODULE)
-	if (ncr53c8xx)
-		ncr53c8xx_setup(ncr53c8xx);
-#endif
-
-#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
-	ncr_debug = driver_setup.debug;
-#endif
-	if (initverbose >= 2)
-		ncr_print_driver_setup();
-
-	memset(&device, 0, sizeof(ncr_device));
-	chip = 0;
-	device_id = PSEUDO_ZALON_720_ID;
-	revision = 0;
-	for (i = 0; i < sizeof(ncr_chip_table)/sizeof(ncr_chip_table[0]); i++) {		if (device_id != ncr_chip_table[i].device_id)
-			continue;
-		chip = &device.chip;
-		memcpy(chip, &ncr_chip_table[i], sizeof(*chip));
-		chip->revision_id = revision;
-		break;
-	}
-
-	if (!chip) {
-		printk(NAME53C8XX ": not initializing, device not supported\n");		return -1;
-	}
-
-	/* Fix some features according to driver setup. */
-	driver_setup.diff_support = 2;
-
-	/* The following three are needed before any other access. */
-	writeb(0x20, io_port + 0x38); /* DCNTL_REG,  EA  */
-	writeb(0x04, io_port + 0x1b); /* CTEST0_REG, EHP */
-	writeb(0x80, io_port + 0x22); /* CTEST4_REG, MUX */
-
-	/* Initialise ncr_device structure with items required by ncr_attach. */
-	device.host_id		= driver_setup.host_id;
-	device.dev		= &dev->dev;
-	device.slot.bus		= 0;
-	device.slot.device_fn	= 0;
-	device.slot.base	= (u_long)io_port;
-	device.slot.base_c	= (u_long)io_port;
-	device.slot.base_2	= 0;
-	device.slot.base_2_c	= 0;
-	device.slot.io_port	= io_port;
-	device.slot.irq		= irq;
-	device.attach_done	= 0;
-
-	printk(KERN_INFO NAME53C8XX ": 53c%s detected\n", device.chip.name);
-
-	return ncr_attach(tpnt, unit, &device);
-}
-#endif
 
 /*==========================================================
 **
@@ -9445,33 +9298,3 @@
 {
 	return SCSI_NCR_DRIVER_NAME;
 }
-
-/*
-**	Module stuff
-*/
-MODULE_LICENSE("GPL");
-
-static Scsi_Host_Template driver_template =  {
-#ifdef ENABLE_SCSI_ZALON
-	.proc_name		= "zalon720",
-	.detect			= zalon7xx_detect,
-	.release		= zalon7xx_release,
-#else
-	.proc_name		= NAME53C8XX,
-	.detect			= ncr53c8xx_detect,
-	.release		= ncr53c8xx_release,
-#endif
-#ifdef SCSI_NCR_PROC_INFO_SUPPORT
-	.proc_info		= ncr53c8xx_proc_info,
-#endif
-	.info			= ncr53c8xx_info,
-	.queuecommand		= ncr53c8xx_queue_command,
-	.slave_configure	= ncr53c8xx_slave_configure,
-	.eh_bus_reset_handler	= ncr53c8xx_bus_reset,
-	.can_queue		= SCSI_NCR_CAN_QUEUE,
-	.this_id		= 7,
-	.sg_tablesize		= SCSI_NCR_SG_TABLESIZE,
-	.cmd_per_lun		= SCSI_NCR_CMD_PER_LUN,
-	.use_clustering		= DISABLE_CLUSTERING,
-};
-#include "scsi_module.c"
diff -urN linux-2.5.73-bk8/drivers/scsi/ncr53c8xx.h linux-2.5.73-bk9/drivers/scsi/ncr53c8xx.h
--- linux-2.5.73-bk8/drivers/scsi/ncr53c8xx.h	2003-06-22 11:32:41.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/ncr53c8xx.h	2003-07-01 04:51:39.000000000 -0700
@@ -42,6 +42,79 @@
 #ifndef NCR53C8XX_H
 #define NCR53C8XX_H
 
+/*
+**	Define the BSD style u_int32 and u_int64 type.
+**	Are in fact u_int32_t and u_int64_t :-)
+*/
+typedef u32 u_int32;
+typedef u64 u_int64;
+typedef	u_long		vm_offset_t;
+
 #include "sym53c8xx_defs.h"
 
+/*==========================================================
+**
+**	Structures used by the detection routine to transmit 
+**	device configuration to the attach function.
+**
+**==========================================================
+*/
+typedef struct {
+	int	bus;
+	u_char	device_fn;
+	u_long	base;
+	u_long	base_2;
+	u_long	io_port;
+	u_long	base_c;
+	u_long	base_2_c;
+	u_long	base_v;
+	u_long	base_2_v;
+	int	irq;
+/* port and reg fields to use INB, OUTB macros */
+	u_long	base_io;
+	volatile struct ncr_reg	*reg;
+} ncr_slot;
+
+/*==========================================================
+**
+**	Structure used to store the NVRAM content.
+**
+**==========================================================
+*/
+typedef struct {
+	int type;
+#define	SCSI_NCR_SYMBIOS_NVRAM	(1)
+#define	SCSI_NCR_TEKRAM_NVRAM	(2)
+#ifdef	SCSI_NCR_NVRAM_SUPPORT
+	union {
+		Symbios_nvram Symbios;
+		Tekram_nvram Tekram;
+	} data;
+#endif
+} ncr_nvram;
+
+/*==========================================================
+**
+**	Structure used by detection routine to save data on 
+**	each detected board for attach.
+**
+**==========================================================
+*/
+typedef struct {
+	struct device  *dev;
+	ncr_slot  slot;
+	ncr_chip  chip;
+	ncr_nvram *nvram;
+	u_char host_id;
+#ifdef	SCSI_NCR_PQS_PDS_SUPPORT
+	u_char pqs_pds;
+#endif
+	__u8 differential;
+	int attach_done;
+} ncr_device;
+
+extern struct Scsi_Host *ncr_attach (Scsi_Host_Template *tpnt, int unit, ncr_device *device);
+extern int ncr53c8xx_release(struct Scsi_Host *host);
+irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
+
 #endif /* NCR53C8XX_H */
diff -urN linux-2.5.73-bk8/drivers/scsi/nsp32.c linux-2.5.73-bk9/drivers/scsi/nsp32.c
--- linux-2.5.73-bk8/drivers/scsi/nsp32.c	2003-06-22 11:32:41.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/nsp32.c	2003-07-01 04:51:39.000000000 -0700
@@ -283,7 +283,6 @@
 static int nsp32_eh_abort(Scsi_Cmnd *);
 static int nsp32_eh_bus_reset(Scsi_Cmnd *);
 static int nsp32_eh_host_reset(Scsi_Cmnd *);
-static int nsp32_reset(Scsi_Cmnd *, unsigned int);
 static int nsp32_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
 static int __devinit nsp32_probe(struct pci_dev *, const struct pci_device_id *);
 static void __devexit nsp32_remove(struct pci_dev *);
@@ -1854,18 +1853,6 @@
 }
 
 
-/*
- * error handler
- */
-static int nsp32_reset(Scsi_Cmnd *SCpnt, unsigned int reset_flags)
-{
-	nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%p why=%d\n", SCpnt, reset_flags);
-
-	nsp32_eh_bus_reset(SCpnt);
-
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
-}
-
 static int nsp32_eh_abort(Scsi_Cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
diff -urN linux-2.5.73-bk8/drivers/scsi/osst.c linux-2.5.73-bk9/drivers/scsi/osst.c
--- linux-2.5.73-bk8/drivers/scsi/osst.c	2003-06-22 11:32:44.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/osst.c	2003-07-01 04:51:39.000000000 -0700
@@ -63,6 +63,7 @@
 
 #include "scsi.h"
 #include "hosts.h"
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>
 
 #define ST_KILOBYTE 1024
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi.c linux-2.5.73-bk9/drivers/scsi/scsi.c
--- linux-2.5.73-bk8/drivers/scsi/scsi.c	2003-06-22 11:32:46.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi.c	2003-07-01 04:51:39.000000000 -0700
@@ -139,7 +139,7 @@
 		sreq->sr_device = sdev;
 		sreq->sr_host = sdev->host;
 		sreq->sr_magic = SCSI_REQ_MAGIC;
-		sreq->sr_data_direction = SCSI_DATA_UNKNOWN;
+		sreq->sr_data_direction = DMA_BIDIRECTIONAL;
 	}
 
 	return sreq;
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi.h linux-2.5.73-bk9/drivers/scsi/scsi.h
--- linux-2.5.73-bk8/drivers/scsi/scsi.h	2003-06-22 11:32:38.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi.h	2003-07-01 04:51:39.000000000 -0700
@@ -25,54 +25,6 @@
 #include <scsi/scsi.h>
 
 /*
- * These are the values that the SCpnt->sc_data_direction and 
- * SRpnt->sr_data_direction can take.  These need to be set
- * The SCSI_DATA_UNKNOWN value is essentially the default.
- * In the event that the command creator didn't bother to
- * set a value, you will see SCSI_DATA_UNKNOWN.
- */
-#define SCSI_DATA_UNKNOWN       0
-#define SCSI_DATA_WRITE         1
-#define SCSI_DATA_READ          2
-#define SCSI_DATA_NONE          3
-
-#ifdef CONFIG_PCI
-#include <linux/pci.h>
-#if ((SCSI_DATA_UNKNOWN == PCI_DMA_BIDIRECTIONAL) && (SCSI_DATA_WRITE == PCI_DMA_TODEVICE) && (SCSI_DATA_READ == PCI_DMA_FROMDEVICE) && (SCSI_DATA_NONE == PCI_DMA_NONE))
-#define scsi_to_pci_dma_dir(scsi_dir)	((int)(scsi_dir))
-#else
-extern __inline__ int scsi_to_pci_dma_dir(unsigned char scsi_dir)
-{
-        if (scsi_dir == SCSI_DATA_UNKNOWN)
-                return PCI_DMA_BIDIRECTIONAL;
-        if (scsi_dir == SCSI_DATA_WRITE)
-                return PCI_DMA_TODEVICE;
-        if (scsi_dir == SCSI_DATA_READ)
-                return PCI_DMA_FROMDEVICE;
-        return PCI_DMA_NONE;
-}
-#endif
-#endif
-
-#if defined(CONFIG_SBUS) && !defined(CONFIG_SUN3) && !defined(CONFIG_SUN3X)
-#include <asm/sbus.h>
-#if ((SCSI_DATA_UNKNOWN == SBUS_DMA_BIDIRECTIONAL) && (SCSI_DATA_WRITE == SBUS_DMA_TODEVICE) && (SCSI_DATA_READ == SBUS_DMA_FROMDEVICE) && (SCSI_DATA_NONE == SBUS_DMA_NONE))
-#define scsi_to_sbus_dma_dir(scsi_dir)	((int)(scsi_dir))
-#else
-extern __inline__ int scsi_to_sbus_dma_dir(unsigned char scsi_dir)
-{
-        if (scsi_dir == SCSI_DATA_UNKNOWN)
-                return SBUS_DMA_BIDIRECTIONAL;
-        if (scsi_dir == SCSI_DATA_WRITE)
-                return SBUS_DMA_TODEVICE;
-        if (scsi_dir == SCSI_DATA_READ)
-                return SBUS_DMA_FROMDEVICE;
-        return SBUS_DMA_NONE;
-}
-#endif
-#endif
-
-/*
  * Some defs, in case these are not defined elsewhere.
  */
 #ifndef TRUE
@@ -228,6 +180,21 @@
 					     struct class_device_attribute *attr);
 
 /*
+ * Legacy dma direction interfaces.
+ *
+ * This assumes the pci/sbus dma mapping flags have the same numercial
+ * values as the generic dma-mapping ones.  Currently they have but there's
+ * no way to check.  Better don't use these interfaces!
+ */
+#define SCSI_DATA_UNKNOWN	(DMA_BIDIRECTIONAL)
+#define SCSI_DATA_WRITE		(DMA_TO_DEVICE)
+#define SCSI_DATA_READ		(DMA_FROM_DEVICE)
+#define SCSI_DATA_NONE		(DMA_NONE)
+
+#define scsi_to_pci_dma_dir(scsi_dir)	((int)(scsi_dir))
+#define scsi_to_sbus_dma_dir(scsi_dir)	((int)(scsi_dir))
+
+/*
  * This is the crap from the old error handling code.  We have it in a special
  * place so that we can more easily delete it later on.
  */
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_error.c linux-2.5.73-bk9/drivers/scsi/scsi_error.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_error.c	2003-06-22 11:32:28.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_error.c	2003-07-01 04:51:39.000000000 -0700
@@ -532,14 +532,14 @@
 static int scsi_request_sense(struct scsi_cmnd *scmd)
 {
 	static unsigned char generic_sense[6] =
-	{REQUEST_SENSE, 0, 0, 0, 254, 0};
+	{REQUEST_SENSE, 0, 0, 0, 252, 0};
 	unsigned char *scsi_result;
 	int saved_result;
 	int rtn;
 
 	memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));
 
-	scsi_result = kmalloc(254, GFP_ATOMIC | (scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0);
+	scsi_result = kmalloc(252, GFP_ATOMIC | (scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0);
 
 
 	if (unlikely(!scsi_result)) {
@@ -555,14 +555,14 @@
 	 * address (db).  0 is not a valid sense code. 
 	 */
 	memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
-	memset(scsi_result, 0, 254);
+	memset(scsi_result, 0, 252);
 
 	saved_result = scmd->result;
 	scmd->request_buffer = scsi_result;
-	scmd->request_bufflen = 254;
+	scmd->request_bufflen = 252;
 	scmd->use_sg = 0;
 	scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
-	scmd->sc_data_direction = SCSI_DATA_READ;
+	scmd->sc_data_direction = DMA_FROM_DEVICE;
 	scmd->underflow = 0;
 
 	rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
@@ -742,7 +742,7 @@
 	scmd->use_sg = 0;
 	scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
 	scmd->underflow = 0;
-	scmd->sc_data_direction = SCSI_DATA_NONE;
+	scmd->sc_data_direction = DMA_NONE;
 
 	rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
 
@@ -1338,7 +1338,7 @@
 
 	if (unlikely(!sreq)) {
 		printk(KERN_ERR "%s: request allocate failed,"
-		       "prevent media removal cmd not sent", __FUNCTION__);
+		       "prevent media removal cmd not sent\n", __FUNCTION__);
 		return;
 	}
 
@@ -1348,7 +1348,7 @@
 	sreq->sr_cmnd[3] = 0;
 	sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT;
 	sreq->sr_cmnd[5] = 0;
-	sreq->sr_data_direction = SCSI_DATA_NONE;
+	sreq->sr_data_direction = DMA_NONE;
 	sreq->sr_bufflen = 0;
 	sreq->sr_buffer = NULL;
 	sreq->sr_allowed = 5;
@@ -1723,7 +1723,7 @@
 
 	scmd->cmd_len			= 0;
 
-	scmd->sc_data_direction	= SCSI_DATA_UNKNOWN;
+	scmd->sc_data_direction		= DMA_BIDIRECTIONAL;
 	scmd->sc_request		= NULL;
 	scmd->sc_magic			= SCSI_CMND_MAGIC;
 
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_ioctl.c linux-2.5.73-bk9/drivers/scsi/scsi_ioctl.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_ioctl.c	2003-06-22 11:33:32.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_ioctl.c	2003-07-01 04:51:39.000000000 -0700
@@ -104,7 +104,7 @@
 		return -ENOMEM;
 	}
 
-	sreq->sr_data_direction = SCSI_DATA_NONE;
+	sreq->sr_data_direction = DMA_NONE;
         scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
 
 	SCSI_LOG_IOCTL(2, printk("Ioctl returned  0x%x\n", sreq->sr_result));
@@ -258,19 +258,19 @@
 			return -ENOMEM;
 		memset(buf, 0, buf_needed);
 		if (inlen == 0) {
-			data_direction = SCSI_DATA_READ;
+			data_direction = DMA_FROM_DEVICE;
 		} else if (outlen == 0 ) {
-			data_direction = SCSI_DATA_WRITE;
+			data_direction = DMA_TO_DEVICE;
 		} else {
 			/*
 			 * Can this ever happen?
 			 */
-			data_direction = SCSI_DATA_UNKNOWN;
+			data_direction = DMA_BIDIRECTIONAL;
 		}
 
 	} else {
 		buf = NULL;
-		data_direction = SCSI_DATA_NONE;
+		data_direction = DMA_NONE;
 	}
 
 	/*
@@ -322,7 +322,7 @@
 	}
 
 	sreq = scsi_allocate_request(sdev);
-        if (sreq) {
+        if (!sreq) {
                 result = -EINTR;
                 goto error;
         }
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_lib.c linux-2.5.73-bk9/drivers/scsi/scsi_lib.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_lib.c	2003-06-22 11:32:45.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_lib.c	2003-07-01 04:51:39.000000000 -0700
@@ -18,6 +18,7 @@
 
 #include "scsi.h"
 #include "hosts.h"
+#include <scsi/scsi_driver.h>
 
 #include "scsi_priv.h"
 #include "scsi_logging.h"
@@ -1094,14 +1095,17 @@
 			return 0;
 		}
 	}
-	if (!list_empty(&sdev->starved_entry))
-		return 0;
 	if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
 	    shost->host_blocked || shost->host_self_blocked) {
-		list_add_tail(&sdev->starved_entry, &shost->starved_list);
+		if (list_empty(&sdev->starved_entry))
+			list_add_tail(&sdev->starved_entry, &shost->starved_list);
 		return 0;
 	}
 
+	/* We're OK to process the command, so we can't be starved */
+	if (!list_empty(&sdev->starved_entry))
+		list_del_init(&sdev->starved_entry);
+
 	return 1;
 }
 
@@ -1128,6 +1132,7 @@
 	 * the host is no longer able to accept any more requests.
 	 */
 	while (!blk_queue_plugged(q)) {
+		int rtn;
 		/*
 		 * get next queueable request.  We do this early to make sure
 		 * that the request is fully prepared even if we cannot 
@@ -1181,8 +1186,17 @@
 		/*
 		 * Dispatch the command to the low-level driver.
 		 */
-		scsi_dispatch_cmd(cmd);
+		rtn = scsi_dispatch_cmd(cmd);
 		spin_lock_irq(q->queue_lock);
+		if(rtn) {
+			/* we're refusing the command; because of
+			 * the way locks get dropped, we need to 
+			 * check here if plugging is required */
+			if(sdev->device_busy == 0)
+				blk_plug_device(q);
+
+			break;
+		}
 	}
 
 	return;
@@ -1203,6 +1217,8 @@
 		blk_queue_end_tag(q, req);
 	__elv_add_request(q, req, 0, 0);
 	sdev->device_busy--;
+	if(sdev->device_busy == 0)
+		blk_plug_device(q);
 }
 
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
@@ -1336,3 +1352,127 @@
 		kmem_cache_destroy(sgp->slab);
 	}
 }
+/**
+ *	__scsi_mode_sense - issue a mode sense, falling back from 10 to 
+ *		six bytes if necessary.
+ *	@sreq:	SCSI request to fill in with the MODE_SENSE
+ *	@dbd:	set if mode sense will allow block descriptors to be returned
+ *	@modepage: mode page being requested
+ *	@buffer: request buffer (may not be smaller than eight bytes)
+ *	@len:	length of request buffer.
+ *	@timeout: command timeout
+ *	@retries: number of retries before failing
+ *	@data: returns a structure abstracting the mode header data
+ *
+ *	Returns zero if unsuccessful, or the header offset (either 4
+ *	or 8 depending on whether a six or ten byte command was
+ *	issued) if successful.
+ **/
+int
+__scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage,
+		  unsigned char *buffer, int len, int timeout, int retries,
+		  struct scsi_mode_data *data) {
+	unsigned char cmd[12];
+	int use_10_for_ms;
+	int header_length;
+
+	memset(data, 0, sizeof(*data));
+	memset(&cmd[0], 0, 12);
+	cmd[1] = dbd & 0x18;	/* allows DBD and LLBA bits */
+	cmd[2] = modepage;
+
+ retry:
+	use_10_for_ms = sreq->sr_device->use_10_for_ms;
+
+	if (use_10_for_ms) {
+		if (len < 8)
+			len = 8;
+
+		cmd[0] = MODE_SENSE_10;
+		cmd[8] = len;
+		header_length = 8;
+	} else {
+		if (len < 4)
+			len = 4;
+
+		cmd[0] = MODE_SENSE;
+		cmd[4] = len;
+		header_length = 4;
+	}
+
+	sreq->sr_cmd_len = 0;
+	sreq->sr_sense_buffer[0] = 0;
+	sreq->sr_sense_buffer[2] = 0;
+	sreq->sr_data_direction = DMA_FROM_DEVICE;
+
+	memset(buffer, 0, len);
+
+	scsi_wait_req(sreq, cmd, buffer, len, timeout, retries);
+
+	/* This code looks awful: what it's doing is making sure an
+	 * ILLEGAL REQUEST sense return identifies the actual command
+	 * byte as the problem.  MODE_SENSE commands can return
+	 * ILLEGAL REQUEST if the code page isn't supported */
+	if (use_10_for_ms && ! scsi_status_is_good(sreq->sr_result) &&
+	    (driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
+	    sreq->sr_sense_buffer[2] == ILLEGAL_REQUEST &&
+	    (sreq->sr_sense_buffer[4] & 0x40) == 0x40 &&
+	    sreq->sr_sense_buffer[5] == 0 &&
+	    sreq->sr_sense_buffer[6] == 0 ) {
+		sreq->sr_device->use_10_for_ms = 0;
+		goto retry;
+	}
+
+	if(scsi_status_is_good(sreq->sr_result)) {
+		data->header_length = header_length;
+		if(use_10_for_ms) {
+			data->length = buffer[0]*256 + buffer[1];
+			data->medium_type = buffer[2];
+			data->device_specific = buffer[3];
+			data->longlba = buffer[4] & 0x01;
+			data->block_descriptor_length = buffer[6]*256
+				+ buffer[7];
+		} else {
+			data->length = buffer[0];
+			data->medium_type = buffer[1];
+			data->device_specific = buffer[3];
+			data->block_descriptor_length = buffer[4];
+		}
+	}
+
+	return sreq->sr_result;
+}
+
+/**
+ *	scsi_mode_sense - issue a mode sense, falling back from 10 to 
+ *		six bytes if necessary.
+ *	@sdev:	scsi device to send command to.
+ *	@dbd:	set if mode sense will disable block descriptors in the return
+ *	@modepage: mode page being requested
+ *	@buffer: request buffer (may not be smaller than eight bytes)
+ *	@len:	length of request buffer.
+ *	@timeout: command timeout
+ *	@retries: number of retries before failing
+ *
+ *	Returns zero if unsuccessful, or the header offset (either 4
+ *	or 8 depending on whether a six or ten byte command was
+ *	issued) if successful.
+ **/
+int
+scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
+		unsigned char *buffer, int len, int timeout, int retries,
+		struct scsi_mode_data *data)
+{
+	struct scsi_request *sreq = scsi_allocate_request(sdev);
+	int ret;
+
+	if (!sreq)
+		return -1;
+
+	ret = __scsi_mode_sense(sreq, dbd, modepage, buffer, len,
+				timeout, retries, data);
+
+	scsi_release_request(sreq);
+
+	return ret;
+}
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_scan.c linux-2.5.73-bk9/drivers/scsi/scsi_scan.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_scan.c	2003-06-22 11:33:07.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_scan.c	2003-07-01 04:51:39.000000000 -0700
@@ -33,6 +33,7 @@
 
 #include "scsi.h"
 #include "hosts.h"
+#include <scsi/scsi_driver.h>
 
 #include "scsi_priv.h"
 #include "scsi_logging.h"
@@ -116,7 +117,7 @@
 	scsi_cmd[4] = 0x2a;	/* size */
 	scsi_cmd[5] = 0;
 	sreq->sr_cmd_len = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
+	sreq->sr_data_direction = DMA_FROM_DEVICE;
 	scsi_wait_req(sreq, scsi_cmd, result, 0x2a /* size */, SCSI_TIMEOUT, 3);
 }
 
@@ -333,7 +334,7 @@
 	scsi_cmd[0] = INQUIRY;
 	scsi_cmd[4] = 36;	/* issue conservative alloc_length */
 	sreq->sr_cmd_len = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
+	sreq->sr_data_direction = DMA_FROM_DEVICE;
 
 	memset(inq_result, 0, 36);
 	scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, 36,
@@ -379,7 +380,7 @@
 		scsi_cmd[0] = INQUIRY;
 		scsi_cmd[4] = (unsigned char) possible_inq_resp_len;
 		sreq->sr_cmd_len = 0;
-		sreq->sr_data_direction = SCSI_DATA_READ;
+		sreq->sr_data_direction = DMA_FROM_DEVICE;
 		/*
 		 * re-zero inq_result just to be safe.
 		 */
@@ -940,7 +941,7 @@
 	scsi_cmd[10] = 0;	/* reserved */
 	scsi_cmd[11] = 0;	/* control */
 	sreq->sr_cmd_len = 0;
-	sreq->sr_data_direction = SCSI_DATA_READ;
+	sreq->sr_data_direction = DMA_FROM_DEVICE;
 
 	/*
 	 * We can get a UNIT ATTENTION, for example a power on/reset, so
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_syms.c linux-2.5.73-bk9/drivers/scsi/scsi_syms.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_syms.c	2003-06-22 11:32:45.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_syms.c	2003-07-01 04:51:39.000000000 -0700
@@ -19,6 +19,7 @@
 #include <asm/dma.h>
 
 #include "scsi.h"
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>
 #include "hosts.h"
 #include "scsi_logging.h"
@@ -86,6 +87,9 @@
 EXPORT_SYMBOL(scsi_remove_device);
 EXPORT_SYMBOL(scsi_set_device_offline);
 
+EXPORT_SYMBOL(__scsi_mode_sense);
+EXPORT_SYMBOL(scsi_mode_sense);
+
 /*
  * This symbol is for the highlevel drivers (e.g. sg) only.
  */
diff -urN linux-2.5.73-bk8/drivers/scsi/scsi_sysfs.c linux-2.5.73-bk9/drivers/scsi/scsi_sysfs.c
--- linux-2.5.73-bk8/drivers/scsi/scsi_sysfs.c	2003-06-22 11:32:36.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/scsi_sysfs.c	2003-07-01 04:51:39.000000000 -0700
@@ -195,19 +195,13 @@
 sdev_rw_attr_bit (online);
 
 static ssize_t
-show_rescan_field (struct device *dev, char *buf)
-{
-	return 0; 
-}
-
-static ssize_t
 store_rescan_field (struct device *dev, const char *buf, size_t count) 
 {
 	scsi_rescan_device(dev);
-	return 0;
+	return count;
 }
 
-static DEVICE_ATTR(rescan, S_IRUGO | S_IWUSR, show_rescan_field, store_rescan_field)
+static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field)
 
 /* Default template for device attributes.  May NOT be modified */
 struct device_attribute *scsi_sysfs_sdev_attrs[] = {
@@ -388,30 +382,36 @@
  *
  * returns zero if successful or error if not
  **/
-int scsi_sysfs_modify_shost_attribute(struct class_device_attribute ***class_attrs,
-				      struct class_device_attribute *attr)
+int scsi_sysfs_modify_shost_attribute(
+			struct class_device_attribute ***class_attrs,
+			struct class_device_attribute *attr)
 {
-	int modify = 0;
+	int modify = -1;
 	int num_attrs;
 
 	if(*class_attrs == NULL)
 		*class_attrs = scsi_sysfs_shost_attrs;
 
 	for(num_attrs=0; (*class_attrs)[num_attrs] != NULL; num_attrs++)
-		if(strcmp((*class_attrs)[num_attrs]->attr.name, attr->attr.name) == 0)
+		if(strcmp((*class_attrs)[num_attrs]->attr.name,
+				attr->attr.name) == 0)
 			modify = num_attrs;
 
-	if(*class_attrs == scsi_sysfs_shost_attrs || !modify) {
+	if(*class_attrs == scsi_sysfs_shost_attrs || modify < 0) {
 		/* note: need space for null at the end as well */
-		struct class_device_attribute **tmp_attrs = kmalloc(sizeof(struct class_device_attribute)*(num_attrs + (modify ? 1 : 2)), GFP_KERNEL);
+		struct class_device_attribute **tmp_attrs =
+				kmalloc(sizeof(*tmp_attrs) *
+					  (num_attrs + (modify >= 0 ? 1 : 2)),
+					GFP_KERNEL);
 		if(tmp_attrs == NULL)
 			return -ENOMEM;
-		memcpy(tmp_attrs, *class_attrs, sizeof(struct class_device_attribute)*num_attrs);
+		memcpy(tmp_attrs, *class_attrs, sizeof(*tmp_attrs) *
+				(num_attrs + 1));
 		if(*class_attrs != scsi_sysfs_shost_attrs)
 			kfree(*class_attrs);
 		*class_attrs = tmp_attrs;
 	}
-	if(modify) {
+	if(modify >= 0) {
 		/* spare the caller from having to copy things it's
 		 * not interested in */
 		struct class_device_attribute *old_attr =
@@ -444,27 +444,32 @@
 int scsi_sysfs_modify_sdev_attribute(struct device_attribute ***dev_attrs,
 				     struct device_attribute *attr)
 {
-	int modify = 0;
+	int modify = -1;
 	int num_attrs;
 
 	if(*dev_attrs == NULL)
 		*dev_attrs = scsi_sysfs_sdev_attrs;
 
 	for(num_attrs=0; (*dev_attrs)[num_attrs] != NULL; num_attrs++)
-		if(strcmp((*dev_attrs)[num_attrs]->attr.name, attr->attr.name) == 0)
+		if(strcmp((*dev_attrs)[num_attrs]->attr.name,
+				attr->attr.name) == 0)
 			modify = num_attrs;
 
-	if(*dev_attrs == scsi_sysfs_sdev_attrs || !modify) {
+	if(*dev_attrs == scsi_sysfs_sdev_attrs || modify < 0) {
 		/* note: need space for null at the end as well */
-		struct device_attribute **tmp_attrs = kmalloc(sizeof(struct device_attribute)*(num_attrs + (modify ? 1 : 2)), GFP_KERNEL);
+		struct device_attribute **tmp_attrs =
+				kmalloc(sizeof(*tmp_attrs) *
+					  (num_attrs + (modify >= 0 ? 1 : 2)),
+					GFP_KERNEL);
 		if(tmp_attrs == NULL)
 			return -ENOMEM;
-		memcpy(tmp_attrs, *dev_attrs, sizeof(struct device_attribute)*num_attrs);
+		memcpy(tmp_attrs, *dev_attrs, sizeof(*tmp_attrs) *
+				(num_attrs + 1));
 		if(*dev_attrs != scsi_sysfs_sdev_attrs)
 			kfree(*dev_attrs);
 		*dev_attrs = tmp_attrs;
 	}
-	if(modify) {
+	if(modify >= 0) {
 		/* spare the caller from having to copy things it's
 		 * not interested in */
 		struct device_attribute *old_attr =
diff -urN linux-2.5.73-bk8/drivers/scsi/sd.c linux-2.5.73-bk9/drivers/scsi/sd.c
--- linux-2.5.73-bk8/drivers/scsi/sd.c	2003-06-22 11:33:06.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sd.c	2003-07-01 04:51:39.000000000 -0700
@@ -49,6 +49,8 @@
 
 #include "scsi.h"
 #include "hosts.h"
+
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsicam.h>
 
@@ -161,11 +163,11 @@
 
 		memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
 		if (rq_data_dir(rq) == WRITE)
-			SCpnt->sc_data_direction = SCSI_DATA_WRITE;
+			SCpnt->sc_data_direction = DMA_TO_DEVICE;
 		else if (rq->data_len)
-			SCpnt->sc_data_direction = SCSI_DATA_READ;
+			SCpnt->sc_data_direction = DMA_FROM_DEVICE;
 		else
-			SCpnt->sc_data_direction = SCSI_DATA_NONE;
+			SCpnt->sc_data_direction = DMA_NONE;
 
 		this_count = rq->data_len;
 		if (rq->timeout)
@@ -251,10 +253,10 @@
 			return 0;
 		}
 		SCpnt->cmnd[0] = WRITE_6;
-		SCpnt->sc_data_direction = SCSI_DATA_WRITE;
+		SCpnt->sc_data_direction = DMA_TO_DEVICE;
 	} else if (rq_data_dir(SCpnt->request) == READ) {
 		SCpnt->cmnd[0] = READ_6;
-		SCpnt->sc_data_direction = SCSI_DATA_READ;
+		SCpnt->sc_data_direction = DMA_FROM_DEVICE;
 	} else {
 		printk(KERN_ERR "sd: Unknown command %lx\n", 
 		       SCpnt->request->flags);
@@ -790,7 +792,7 @@
 			SRpnt->sr_cmd_len = 0;
 			SRpnt->sr_sense_buffer[0] = 0;
 			SRpnt->sr_sense_buffer[2] = 0;
-			SRpnt->sr_data_direction = SCSI_DATA_NONE;
+			SRpnt->sr_data_direction = DMA_NONE;
 
 			scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer,
 				       0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES);
@@ -850,7 +852,7 @@
 				SRpnt->sr_sense_buffer[0] = 0;
 				SRpnt->sr_sense_buffer[2] = 0;
 
-				SRpnt->sr_data_direction = SCSI_DATA_NONE;
+				SRpnt->sr_data_direction = DMA_NONE;
 				scsi_wait_req(SRpnt, (void *)cmd, 
 					      (void *) buffer, 0/*512*/, 
 					      SD_TIMEOUT, SD_MAX_RETRIES);
@@ -915,7 +917,7 @@
 		SRpnt->sr_cmd_len = 0;
 		SRpnt->sr_sense_buffer[0] = 0;
 		SRpnt->sr_sense_buffer[2] = 0;
-		SRpnt->sr_data_direction = SCSI_DATA_READ;
+		SRpnt->sr_data_direction = DMA_FROM_DEVICE;
 
 		scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
 			      longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES);
@@ -1062,40 +1064,12 @@
 }
 
 /* called with buffer of length 512 */
-static int
+static inline int
 sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage,
-		 unsigned char *buffer, int len) {
-	unsigned char cmd[12];
-
-	memset((void *) &cmd[0], 0, 12);
-	cmd[1] = dbd;
-	cmd[2] = modepage;
-
-	if (SRpnt->sr_device->use_10_for_ms) {
-		if (len < 8)
-			len = 8;
-
-		cmd[0] = MODE_SENSE_10;
-		cmd[8] = len;
-	} else {
-		if (len < 4)
-			len = 4;
-
-		cmd[0] = MODE_SENSE;
-		cmd[4] = len;
-	}
-
-	SRpnt->sr_cmd_len = 0;
-	SRpnt->sr_sense_buffer[0] = 0;
-	SRpnt->sr_sense_buffer[2] = 0;
-	SRpnt->sr_data_direction = SCSI_DATA_READ;
-
-	memset((void *) buffer, 0, len);
-
-	scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
-		      len, SD_TIMEOUT, SD_MAX_RETRIES);
-
-	return SRpnt->sr_result;
+		 unsigned char *buffer, int len, struct scsi_mode_data *data)
+{
+	return __scsi_mode_sense(SRpnt, dbd, modepage, buffer, len,
+				 SD_TIMEOUT, SD_MAX_RETRIES, data);
 }
 
 /*
@@ -1106,33 +1080,34 @@
 sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
 		   struct scsi_request *SRpnt, unsigned char *buffer) {
 	int res;
+	struct scsi_mode_data data;
 
 	/*
 	 * First attempt: ask for all pages (0x3F), but only 4 bytes.
 	 * We have to start carefully: some devices hang if we ask
 	 * for more than is available.
 	 */
-	res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4);
+	res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data);
 
 	/*
 	 * Second attempt: ask for page 0
 	 * When only page 0 is implemented, a request for page 3F may return
 	 * Sense Key 5: Illegal Request, Sense Code 24: Invalid field in CDB.
 	 */
-	if (res)
-		res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4);
+	if (!scsi_status_is_good(res))
+		res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data);
 
 	/*
 	 * Third attempt: ask 255 bytes, as we did earlier.
 	 */
-	if (res)
-		res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255);
+	if (!scsi_status_is_good(res))
+		res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, &data);
 
-	if (res) {
+	if (!scsi_status_is_good(res)) {
 		printk(KERN_WARNING
 		       "%s: test WP failed, assume Write Enabled\n", diskname);
 	} else {
-		sdkp->write_prot = ((buffer[2] & 0x80) != 0);
+		sdkp->write_prot = ((data.device_specific & 0x80) != 0);
 		printk(KERN_NOTICE "%s: Write Protect is %s\n", diskname,
 		       sdkp->write_prot ? "on" : "off");
 		printk(KERN_DEBUG "%s: Mode Sense: %02x %02x %02x %02x\n",
@@ -1149,43 +1124,45 @@
 		   struct scsi_request *SRpnt, unsigned char *buffer) {
 	int len = 0, res;
 
-	const int dbd = 0x08;	   /* DBD */
+	const int dbd = 0;	   /* DBD */
 	const int modepage = 0x08; /* current values, cache page */
+	struct scsi_mode_data data;
+
 
 	/* cautiously ask */
-	res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4);
+	res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, 4, &data);
 
-	if (res == 0) {
+	if (scsi_status_is_good(res)) {
 		/* that went OK, now ask for the proper length */
-		len = buffer[0] + 1;
+		len = data.length;
 		if (len > 128)
 			len = 128;
-		res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer, len);
+		res = sd_do_mode_sense(SRpnt, dbd, modepage, buffer,
+				       len, &data);
 	}
 
-	if (res == 0 && buffer[3] + 6 < len) {
+	if (scsi_status_is_good(res)) {
 		const char *types[] = {
 			"write through", "none", "write back",
 			"write back, no read (daft)"
 		};
 		int ct = 0;
-		int offset = buffer[3] + 4; /* start of mode page */
+		int offset = data.header_length +
+			data.block_descriptor_length + 2;
 
-		sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0);
-		sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0);
+		sdkp->WCE = ((buffer[offset] & 0x04) != 0);
+		sdkp->RCD = ((buffer[offset] & 0x01) != 0);
 
 		ct =  sdkp->RCD + 2*sdkp->WCE;
 
 		printk(KERN_NOTICE "SCSI device %s: drive cache: %s\n",
 		       diskname, types[ct]);
 	} else {
-		if (res == 0 ||
-		    (status_byte(res) == CHECK_CONDITION
-		     && (SRpnt->sr_sense_buffer[0] & 0x70) == 0x70
+		if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70
 		     && (SRpnt->sr_sense_buffer[2] & 0x0f) == ILLEGAL_REQUEST
 		     /* ASC 0x24 ASCQ 0x00: Invalid field in CDB */
 		     && SRpnt->sr_sense_buffer[12] == 0x24
-		     && SRpnt->sr_sense_buffer[13] == 0x00)) {
+		     && SRpnt->sr_sense_buffer[13] == 0x00) {
 			printk(KERN_NOTICE "%s: cache data unavailable\n",
 			       diskname);
 		} else {
@@ -1417,7 +1394,7 @@
 		return;
 	}
 
-	sreq->sr_data_direction = SCSI_DATA_NONE;
+	sreq->sr_data_direction = DMA_NONE;
 	for (retries = 3; retries > 0; --retries) {
 		unsigned char cmd[10] = { 0 };
 
diff -urN linux-2.5.73-bk8/drivers/scsi/seagate.c linux-2.5.73-bk9/drivers/scsi/seagate.c
--- linux-2.5.73-bk8/drivers/scsi/seagate.c	2003-06-22 11:32:43.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/seagate.c	2003-07-01 04:51:39.000000000 -0700
@@ -266,20 +266,6 @@
 #define WRITE_CONTROL(d) { isa_writeb((d), st0x_cr_sr); }
 #define WRITE_DATA(d) { isa_writeb((d), st0x_dr); }
 
-static void st0x_setup (char *str, int *ints)
-{
-	controller_type = SEAGATE;
-	base_address = ints[1];
-	irq = ints[2];
-}
-
-static void tmc8xx_setup (char *str, int *ints)
-{
-	controller_type = FD;
-	base_address = ints[1];
-	irq = ints[2];
-}
-
 #ifndef OVERRIDE
 static unsigned int seagate_bases[] = {
 	0xc8000, 0xca000, 0xcc000,
diff -urN linux-2.5.73-bk8/drivers/scsi/seagate.h linux-2.5.73-bk9/drivers/scsi/seagate.h
--- linux-2.5.73-bk8/drivers/scsi/seagate.h	2003-06-22 11:33:08.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/seagate.h	2003-07-01 04:51:39.000000000 -0700
@@ -10,7 +10,6 @@
 #define SEAGATE_H
 
 static int seagate_st0x_detect(Scsi_Host_Template *);
-static int seagate_st0x_command(Scsi_Cmnd *);
 static int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
 
 static int seagate_st0x_abort(Scsi_Cmnd *);
diff -urN linux-2.5.73-bk8/drivers/scsi/sg.c linux-2.5.73-bk9/drivers/scsi/sg.c
--- linux-2.5.73-bk8/drivers/scsi/sg.c	2003-06-22 11:32:43.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sg.c	2003-07-01 04:51:39.000000000 -0700
@@ -64,6 +64,7 @@
 #include <linux/blk.h>
 #include "scsi.h"
 #include "hosts.h"
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/sg.h>
 
diff -urN linux-2.5.73-bk8/drivers/scsi/sr.c linux-2.5.73-bk9/drivers/scsi/sr.c
--- linux-2.5.73-bk8/drivers/scsi/sr.c	2003-07-01 04:51:30.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sr.c	2003-07-01 04:51:39.000000000 -0700
@@ -48,6 +48,8 @@
 
 #include "scsi.h"
 #include "hosts.h"
+
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>	/* For the door lock/unlock commands */
 
 #include "scsi_logging.h"
@@ -660,9 +662,9 @@
 
 static void get_capabilities(struct scsi_cd *cd)
 {
-	struct cdrom_generic_command cgc;
 	unsigned char *buffer;
 	int rc, n;
+	struct scsi_mode_data data;
 
 	static char *loadmech[] =
 	{
@@ -681,18 +683,10 @@
 		printk(KERN_ERR "sr: out of memory.\n");
 		return;
 	}
-	memset(&cgc, 0, sizeof(struct cdrom_generic_command));
-	cgc.cmd[0] = MODE_SENSE;
-	cgc.cmd[2] = 0x2a;
-	cgc.cmd[4] = 128;
-	cgc.buffer = buffer;
-	cgc.buflen = 128;
-	cgc.quiet = 1;
-	cgc.data_direction = SCSI_DATA_READ;
-	cgc.timeout = SR_TIMEOUT;
-	rc = sr_do_ioctl(cd, &cgc);
+	rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
+			     SR_TIMEOUT, 3, &data);
 
-	if (rc) {
+	if (!scsi_status_is_good(rc)) {
 		/* failed, drive doesn't have capabilities mode page */
 		cd->cdi.speed = 1;
 		cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
@@ -702,7 +696,7 @@
 		printk("%s: scsi-1 drive\n", cd->cdi.name);
 		return;
 	}
-	n = buffer[3] + 4;
+	n = data.header_length + data.block_descriptor_length;
 	cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
 	cd->readcd_known = 1;
 	cd->readcd_cdda = buffer[n + 5] & 0x01;
diff -urN linux-2.5.73-bk8/drivers/scsi/st.c linux-2.5.73-bk9/drivers/scsi/st.c
--- linux-2.5.73-bk8/drivers/scsi/st.c	2003-06-22 11:32:57.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/st.c	2003-07-01 04:51:39.000000000 -0700
@@ -58,6 +58,8 @@
 
 #include "scsi.h"
 #include "hosts.h"
+
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_ioctl.h>
 
 #define ST_KILOBYTE 1024
diff -urN linux-2.5.73-bk8/drivers/scsi/sym53c416.h linux-2.5.73-bk9/drivers/scsi/sym53c416.h
--- linux-2.5.73-bk8/drivers/scsi/sym53c416.h	2003-06-22 11:33:05.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sym53c416.h	2003-07-01 04:51:39.000000000 -0700
@@ -25,7 +25,6 @@
 static int sym53c416_detect(Scsi_Host_Template *);
 static const char *sym53c416_info(struct Scsi_Host *);
 static int sym53c416_release(struct Scsi_Host *);
-static int sym53c416_command(Scsi_Cmnd *);
 static int sym53c416_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
 static int sym53c416_abort(Scsi_Cmnd *);
 static int sym53c416_host_reset(Scsi_Cmnd *);
diff -urN linux-2.5.73-bk8/drivers/scsi/sym53c8xx_2/sym_glue.c linux-2.5.73-bk9/drivers/scsi/sym53c8xx_2/sym_glue.c
--- linux-2.5.73-bk8/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-06-22 11:33:37.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-07-01 04:51:39.000000000 -0700
@@ -295,12 +295,8 @@
 #ifndef SYM_LINUX_DYNAMIC_DMA_MAPPING
 typedef u_long		bus_addr_t;
 #else
-#if	SYM_CONF_DMA_ADDRESSING_MODE > 0
-typedef dma64_addr_t	bus_addr_t;
-#else
 typedef dma_addr_t	bus_addr_t;
 #endif
-#endif
 
 /*
  *  Used by the eh thread to wait for command completion.
@@ -1863,7 +1859,7 @@
 #if   SYM_CONF_DMA_ADDRESSING_MODE == 1
 #define	PciDmaMask	0xffffffffff
 #elif SYM_CONF_DMA_ADDRESSING_MODE == 2
-#define	PciDmaMask	0xffffffffffffffff
+#define	PciDmaMask	0xffffffffffffffffULL
 #endif
 	if (np->features & FE_DAC) {
 		if (!pci_set_dma_mask(np->s.device, PciDmaMask)) {
@@ -2753,14 +2749,6 @@
 		/* This one is guaranteed by AC to do nothing :-) */
 		if (pci_enable_device(pcidev))
 			continue;
-		/* Some HW as the HP LH4 may report twice PCI devices */
-		for (i = 0; i < count ; i++) {
-			if (devtbl[i].s.bus       == PciBusNumber(pcidev) && 
-			    devtbl[i].s.device_fn == PciDeviceFn(pcidev))
-				break;
-		}
-		if (i != count)	/* Ignore this device if we already have it */
-			continue;
 		devp = &devtbl[count];
 		devp->host_id = SYM_SETUP_HOST_ID;
 		devp->attach_done = 0;
diff -urN linux-2.5.73-bk8/drivers/scsi/sym53c8xx_2/sym_hipd.c linux-2.5.73-bk9/drivers/scsi/sym53c8xx_2/sym_hipd.c
--- linux-2.5.73-bk8/drivers/scsi/sym53c8xx_2/sym_hipd.c	2003-06-22 11:32:28.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sym53c8xx_2/sym_hipd.c	2003-07-01 04:51:39.000000000 -0700
@@ -4641,7 +4641,10 @@
 		case M_IGN_RESIDUE:
 			if (DEBUG_FLAGS & DEBUG_POINTER)
 				sym_print_msg(cp,"ign wide residue", np->msgin);
-			sym_modify_dp(np, tp, cp, -1);
+			if (cp->host_flags & HF_SENSE)
+				OUTL_DSP (SCRIPTA_BA (np, clrack));
+			else
+				sym_modify_dp(np, tp, cp, -1);
 			return;
 		case M_REJECT:
 			if (INB (HS_PRT) == HS_NEGOTIATE)
diff -urN linux-2.5.73-bk8/drivers/scsi/sym53c8xx_comm.h linux-2.5.73-bk9/drivers/scsi/sym53c8xx_comm.h
--- linux-2.5.73-bk8/drivers/scsi/sym53c8xx_comm.h	2003-06-22 11:32:55.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sym53c8xx_comm.h	2003-07-01 04:51:39.000000000 -0700
@@ -795,7 +795,7 @@
 		dma_addr_t daddr;
 		vp = (m_addr_t) dma_alloc_coherent(mp->bush,
 						PAGE_SIZE<<MEMO_PAGE_ORDER,
-						&daddr, GFP_KERNEL);
+						&daddr, GFP_ATOMIC);
 		if (vp) {
 			int hc = VTOB_HASH_CODE(vp);
 			vbp->vaddr = vp;
@@ -1100,66 +1100,6 @@
 
 /*==========================================================
 **
-**	Structures used by the detection routine to transmit 
-**	device configuration to the attach function.
-**
-**==========================================================
-*/
-typedef struct {
-	int	bus;
-	u_char	device_fn;
-	u_long	base;
-	u_long	base_2;
-	u_long	io_port;
-	u_long	base_c;
-	u_long	base_2_c;
-	int	irq;
-/* port and reg fields to use INB, OUTB macros */
-	u_long	base_io;
-	volatile struct ncr_reg	*reg;
-} ncr_slot;
-
-/*==========================================================
-**
-**	Structure used to store the NVRAM content.
-**
-**==========================================================
-*/
-typedef struct {
-	int type;
-#define	SCSI_NCR_SYMBIOS_NVRAM	(1)
-#define	SCSI_NCR_TEKRAM_NVRAM	(2)
-#ifdef	SCSI_NCR_NVRAM_SUPPORT
-	union {
-		Symbios_nvram Symbios;
-		Tekram_nvram Tekram;
-	} data;
-#endif
-} ncr_nvram;
-
-/*==========================================================
-**
-**	Structure used by detection routine to save data on 
-**	each detected board for attach.
-**
-**==========================================================
-*/
-typedef struct {
-	device_t  dev;
-	ncr_slot  slot;
-	ncr_chip  chip;
-	ncr_nvram *nvram;
-	u_char host_id;
-#ifdef	SCSI_NCR_PQS_PDS_SUPPORT
-	u_char pqs_pds;
-#endif
-	int attach_done;
-} ncr_device;
-
-static int ncr_attach (Scsi_Host_Template *tpnt, int unit, ncr_device *device);
-
-/*==========================================================
-**
 **	NVRAM detection and reading.
 **	 
 **	Currently supported:
diff -urN linux-2.5.73-bk8/drivers/scsi/sym53c8xx_defs.h linux-2.5.73-bk9/drivers/scsi/sym53c8xx_defs.h
--- linux-2.5.73-bk8/drivers/scsi/sym53c8xx_defs.h	2003-06-22 11:33:07.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/sym53c8xx_defs.h	2003-07-01 04:51:39.000000000 -0700
@@ -85,7 +85,7 @@
 /*
  *	No more an option, enabled by default.
  */
-#ifndef ENABLE_SCSI_ZALON
+#ifndef CONFIG_SCSI_NCR53C8XX_NO_NVRAM
 # ifndef CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT
 #  define CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT
 # endif
@@ -188,10 +188,6 @@
 #define	SCSI_NCR_IOMAPPED
 #define SCSI_NCR_PCI_MEM_NOT_SUPPORTED
 #endif
-#elif defined(__sparc__)
-#undef SCSI_NCR_IOMAPPED
-#elif defined(__hppa__) && defined(ENABLE_SCSI_ZALON)
-#undef SCSI_NCR_IOMAPPED
 #endif
 
 /*
@@ -532,7 +528,6 @@
  */
 
 #if defined(SCSI_NCR_IOMAPPED)
-
 /*
  *  IO mapped only input / ouput
  */
@@ -593,7 +588,7 @@
 
 #else
 
-#ifdef ENABLE_SCSI_ZALON
+#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
 /* Only 8 or 32 bit transfers allowed */
 #define INW_OFF(o)		(readb((char *)np->reg + ncr_offw(o)) << 8 | readb((char *)np->reg + ncr_offw(o) + 1))
 #else
@@ -601,7 +596,7 @@
 #endif
 #define INL_OFF(o)		readl_raw((char *)np->reg + (o))
 
-#ifdef ENABLE_SCSI_ZALON
+#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
 /* Only 8 or 32 bit transfers allowed */
 #define OUTW_OFF(o, val)	do { writeb((char)((val) >> 8), (char *)np->reg + ncr_offw(o)); writeb((char)(val), (char *)np->reg + ncr_offw(o) + 1); } while (0)
 #else
@@ -654,8 +649,8 @@
 **	NCR53C8XX Device Ids
 */
 
-#ifndef PSEUDO_ZALON_720_ID
-#define PSEUDO_ZALON_720_ID 0x5a00
+#ifndef PSEUDO_720_ID
+#define PSEUDO_720_ID 0x5a00
 #endif
 
 #ifndef PCI_DEVICE_ID_NCR_53C810
@@ -785,7 +780,7 @@
 
 #define SCSI_NCR_CHIP_TABLE						\
 {									\
- {PSEUDO_ZALON_720_ID, 0x0f, "720",  3,  8, 4,				\
+ {PSEUDO_720_ID, 0x0f, "720",  3,  8, 4,				\
  FE_WIDE|FE_DIFF|FE_EHP|FE_MUX|FE_EA}					\
  ,									\
  {PCI_DEVICE_ID_NCR_53C810, 0x0f, "810",  4,  8, 4,			\
@@ -860,7 +855,7 @@
  */
 #define SCSI_NCR_CHIP_IDS		\
 {					\
-	PSEUDO_ZALON_720_ID,		\
+	PSEUDO_720_ID,		\
 	PCI_DEVICE_ID_NCR_53C810,	\
 	PCI_DEVICE_ID_NCR_53C815,	\
 	PCI_DEVICE_ID_NCR_53C820,	\
diff -urN linux-2.5.73-bk8/drivers/scsi/zalon.c linux-2.5.73-bk9/drivers/scsi/zalon.c
--- linux-2.5.73-bk8/drivers/scsi/zalon.c	2003-06-22 11:32:58.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/zalon.c	2003-07-01 04:51:39.000000000 -0700
@@ -24,30 +24,24 @@
 #include "scsi.h"
 #include "hosts.h"
 
-/*
- * **      Define the BSD style u_int32 and u_int64 type.
- * **      Are in fact u_int32_t and u_int64_t :-)
- * */
-typedef u32 u_int32;
-typedef u64 u_int64;
-typedef u_long          vm_offset_t;
+#include "ncr53c8xx.h"
 
 #include "zalon.h"
 
+MODULE_AUTHOR("Richard Hirst");
+MODULE_DESCRIPTION("Bluefish/Zalon 720 SCSI Driver");
+MODULE_LICENSE("GPL");
+
+static ncr_chip zalon720_chip __initdata = {
+	.device_id =	PSEUDO_720_ID,
+	.revision_id =	0x0f,
+	.name =		"720",
+	.burst_max =	3,
+	.offset_max =	8,
+	.nr_divisor =	4,
+	.features =	FE_WIDE | FE_DIFF | FE_EHP| FE_MUX | FE_EA,
+};
 
-/* hosts_* are kluges to pass info between the zalon7xx_detected()
-** and the register_parisc_driver() callbacks.
-*/
-static Scsi_Host_Template *hosts_tptr;
-static int hosts_used=0;
-static int zalon_id = 0;
-
-extern int zalon_attach(Scsi_Host_Template *tpnt,
-			unsigned long base_addr,
-			struct parisc_device *dev,
-			int irq_vector,
-			int unit
-			);
 
 
 #if 0
@@ -81,6 +75,11 @@
 }
 #endif
 
+static Scsi_Host_Template zalon7xx_template = {
+	.module		= THIS_MODULE,
+	.proc_name	= "zalon7xx",
+};
+
 static int __init
 zalon_scsi_callback(struct parisc_device *dev)
 {
@@ -88,6 +87,10 @@
 	u32 zalon_vers;
 	int irq;
 	unsigned long zalon = dev->hpa;
+	unsigned long io_port = zalon + GSC_SCSI_ZALON_OFFSET;
+	static int unit = 0;
+	struct Scsi_Host *host;
+	ncr_device device;
 
 	__raw_writel(CMD_RESET, zalon + IO_MODULE_IO_COMMAND);
 	while (!(__raw_readl(zalon + IO_MODULE_IO_STATUS) & IOSTATUS_RY))
@@ -112,17 +115,43 @@
 	if ( zalon_vers == 0)
 		printk(KERN_WARNING "%s: Zalon 1.1 or earlier\n", __FUNCTION__);
 
-	/*
-	**  zalon_attach: returns -1 on failure, 0 on success
-	*/
-	hosts_used = zalon_attach(hosts_tptr, dev->hpa + GSC_SCSI_ZALON_OFFSET,
-			dev, irq, zalon_id);
+	memset(&device, 0, sizeof(ncr_device));
+
+	/* The following three are needed before any other access. */
+	writeb(0x20, io_port + 0x38); /* DCNTL_REG,  EA  */
+	writeb(0x04, io_port + 0x1b); /* CTEST0_REG, EHP */
+	writeb(0x80, io_port + 0x22); /* CTEST4_REG, MUX */
+
+	/* Initialise ncr_device structure with items required by ncr_attach. */
+	device.chip		= zalon720_chip;
+	device.host_id		= 7;
+	device.dev		= &dev->dev;
+	device.slot.base	= (u_long)io_port;
+	device.slot.base_c	= (u_long)io_port;
+	device.slot.irq		= irq;
+	device.differential	= 2;
+
+	host = ncr_attach(&zalon7xx_template, unit, &device);
+	if(!host)
+		goto fail;
+
+	strlcpy(dev->dev.name, "zalon7xx", sizeof(dev->dev.name));
+
+	if(request_irq(irq, ncr53c8xx_intr, SA_SHIRQ, dev->dev.name, host)) {
+		printk(KERN_ERR "%s: irq problem with %d, detaching\n ",
+		       dev->dev.name, irq);
+		goto fail;
+	}
+
+	unit++;
+
+	dev_set_drvdata(&dev->dev, host);
 
-	if (hosts_used == 0)
-		zalon_id++;
+	scsi_add_host(host, &dev->dev);
 
-	hosts_used = (hosts_used == 0);
-	return (hosts_used == 0);
+	return 0;
+ fail:
+	return -ENODEV;
 }
 
 static struct parisc_device_id zalon_tbl[] = {
@@ -132,30 +161,35 @@
 
 MODULE_DEVICE_TABLE(parisc, zalon_tbl);
 
+static int __exit zalon_remove(struct parisc_device *dev)
+{
+	struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
+	int irq = host->irq;
+
+	scsi_remove_host(host);
+	ncr53c8xx_release(host);
+	free_irq(irq, host);
+
+	return 0;
+}
+	
+
 static struct parisc_driver zalon_driver = {
 	.name =		"GSC SCSI (Zalon)",
 	.id_table =	zalon_tbl,
 	.probe =	zalon_scsi_callback,
+	.remove =	__devexit_p(zalon_remove),
 };
 
-int zalon7xx_detect(Scsi_Host_Template *tpnt)
+static int __init zalon7xx_init(void)
 {
-	/* "pass" the parameter to the callback functions */
-	hosts_tptr = tpnt;
-	hosts_used = 0;
-
-	/* claim all zalon cards. */
-	register_parisc_driver(&zalon_driver);
-
-	/* Check if any callbacks actually found/claimed anything. */
-	return (hosts_used != 0);
+	return register_parisc_driver(&zalon_driver);
 }
 
-extern int ncr53c8xx_release(struct Scsi_Host *host);
-
-int zalon7xx_release(struct Scsi_Host *host)
+static void __exit zalon7xx_exit(void)
 {
-	ncr53c8xx_release(host);
 	unregister_parisc_driver(&zalon_driver);
-	return 1;
 }
+
+module_init(zalon7xx_init);
+module_exit(zalon7xx_exit);
diff -urN linux-2.5.73-bk8/drivers/scsi/zalon.h linux-2.5.73-bk9/drivers/scsi/zalon.h
--- linux-2.5.73-bk8/drivers/scsi/zalon.h	2003-06-22 11:32:55.000000000 -0700
+++ linux-2.5.73-bk9/drivers/scsi/zalon.h	2003-07-01 04:51:39.000000000 -0700
@@ -2,21 +2,8 @@
 #define ZALON7XX_H
 
 #include <linux/types.h>
-
-#include "sym53c8xx_defs.h"
-
-extern int zalon7xx_detect(Scsi_Host_Template *);
-
 #include <scsi/scsicam.h>
 
-extern struct proc_dir_entry proc_scsi_zalon7xx;
-
-/* borrowed from drivers/scsi/ncr53c8xx.h */
-int zalon7xx_detect(Scsi_Host_Template *tpnt);
-const char *ncr53c8xx_info(struct Scsi_Host *host);
-int ncr53c8xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-int zalon7xx_release(struct Scsi_Host *);
-
 #define GSC_SCSI_ZALON_OFFSET 0x800
 
 #define IO_MODULE_EIM		(1*4)
diff -urN linux-2.5.73-bk8/include/asm-i386/pci.h linux-2.5.73-bk9/include/asm-i386/pci.h
--- linux-2.5.73-bk8/include/asm-i386/pci.h	2003-06-22 11:32:42.000000000 -0700
+++ linux-2.5.73-bk9/include/asm-i386/pci.h	2003-07-01 04:51:40.000000000 -0700
@@ -82,14 +82,6 @@
 	flush_write_buffers();
 }
 
-/* These macros should be used after a pci_map_sg call has been done
- * to get bus addresses of each of the SG entries and their lengths.
- * You should only work with the number of sg entries pci_map_sg
- * returns.
- */
-#define sg_dma_address(sg)	((sg)->dma_address)
-#define sg_dma_len(sg)		((sg)->length)
-
 #define HAVE_PCI_MMAP
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 			       enum pci_mmap_state mmap_state, int write_combine);
diff -urN linux-2.5.73-bk8/include/asm-i386/scatterlist.h linux-2.5.73-bk9/include/asm-i386/scatterlist.h
--- linux-2.5.73-bk8/include/asm-i386/scatterlist.h	2003-06-22 11:32:44.000000000 -0700
+++ linux-2.5.73-bk9/include/asm-i386/scatterlist.h	2003-07-01 04:51:40.000000000 -0700
@@ -8,6 +8,14 @@
     unsigned int	length;
 };
 
+/* These macros should be used after a pci_map_sg call has been done
+ * to get bus addresses of each of the SG entries and their lengths.
+ * You should only work with the number of sg entries pci_map_sg
+ * returns.
+ */
+#define sg_dma_address(sg)	((sg)->dma_address)
+#define sg_dma_len(sg)		((sg)->length)
+
 #define ISA_DMA_THRESHOLD (0x00ffffff)
 
 #endif /* !(_I386_SCATTERLIST_H) */
diff -urN linux-2.5.73-bk8/include/linux/if_ether.h linux-2.5.73-bk9/include/linux/if_ether.h
--- linux-2.5.73-bk8/include/linux/if_ether.h	2003-06-22 11:32:57.000000000 -0700
+++ linux-2.5.73-bk9/include/linux/if_ether.h	2003-07-01 04:51:40.000000000 -0700
@@ -67,6 +67,7 @@
 #define ETH_P_ATMFATE	0x8884		/* Frame-based ATM Transport
 					 * over Ethernet
 					 */
+#define ETH_P_EDP2	0x88A2		/* Coraid EDP2			*/
 
 /*
  *	Non DIX types. Won't clash for 1500 types.
diff -urN linux-2.5.73-bk8/include/linux/xfrm.h linux-2.5.73-bk9/include/linux/xfrm.h
--- linux-2.5.73-bk8/include/linux/xfrm.h	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/include/linux/xfrm.h	2003-07-01 04:51:40.000000000 -0700
@@ -155,6 +155,7 @@
 struct xfrm_usersa_info {
 	struct xfrm_selector		sel;
 	struct xfrm_id			id;
+	xfrm_address_t			saddr;
 	struct xfrm_lifetime_cfg	lft;
 	struct xfrm_lifetime_cur	curlft;
 	struct xfrm_stats		stats;
diff -urN linux-2.5.73-bk8/include/net/ipv6.h linux-2.5.73-bk9/include/net/ipv6.h
--- linux-2.5.73-bk8/include/net/ipv6.h	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/include/net/ipv6.h	2003-07-01 04:51:41.000000000 -0700
@@ -101,6 +101,8 @@
 	__u32		identification;
 };
 
+#define	IP6_MF	0x0001
+
 #ifdef __KERNEL__
 
 #include <net/sock.h>
diff -urN linux-2.5.73-bk8/include/net/xfrm.h linux-2.5.73-bk9/include/net/xfrm.h
--- linux-2.5.73-bk8/include/net/xfrm.h	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/include/net/xfrm.h	2003-07-01 04:51:41.000000000 -0700
@@ -767,7 +767,8 @@
 					  unsigned short family);
 extern int xfrm_state_check_expire(struct xfrm_state *x);
 extern void xfrm_state_insert(struct xfrm_state *x);
-extern int xfrm_state_replace(struct xfrm_state *x, int excl);
+extern int xfrm_state_add(struct xfrm_state *x);
+extern int xfrm_state_update(struct xfrm_state *x);
 extern int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb);
 extern struct xfrm_state *xfrm_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto, unsigned short family);
 extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
diff -urN linux-2.5.73-bk8/include/pcmcia/ss.h linux-2.5.73-bk9/include/pcmcia/ss.h
--- linux-2.5.73-bk8/include/pcmcia/ss.h	2003-06-22 11:33:18.000000000 -0700
+++ linux-2.5.73-bk9/include/pcmcia/ss.h	2003-07-01 04:51:41.000000000 -0700
@@ -119,7 +119,6 @@
 struct pcmcia_socket;
 
 struct pccard_operations {
-	struct module *owner;
 	int (*init)(struct pcmcia_socket *sock);
 	int (*suspend)(struct pcmcia_socket *sock);
 	int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
@@ -169,6 +168,7 @@
 struct region_t;
 
 struct pcmcia_socket {
+	struct module			*owner;
 	spinlock_t			lock;
 	struct pccard_operations *	ss_entry;
 	socket_state_t			socket;
@@ -235,6 +235,7 @@
 
 
 
+extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
 extern int pcmcia_register_socket(struct pcmcia_socket *socket);
 extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
 
diff -urN linux-2.5.73-bk8/include/scsi/scsi_cmnd.h linux-2.5.73-bk9/include/scsi/scsi_cmnd.h
--- linux-2.5.73-bk8/include/scsi/scsi_cmnd.h	2003-06-22 11:32:59.000000000 -0700
+++ linux-2.5.73-bk9/include/scsi/scsi_cmnd.h	2003-07-01 04:51:41.000000000 -0700
@@ -1,6 +1,7 @@
 #ifndef _SCSI_SCSI_CMND_H
 #define _SCSI_SCSI_CMND_H
 
+#include <linux/dma-mapping.h>
 #include <linux/list.h>
 #include <linux/types.h>
 
@@ -71,8 +72,8 @@
 
 	unsigned char cmd_len;
 	unsigned char old_cmd_len;
-	unsigned char sc_data_direction;
-	unsigned char sc_old_data_direction;
+	enum dma_data_direction sc_data_direction;
+	enum dma_data_direction sc_old_data_direction;
 
 	/* These elements define the operation we are about to perform */
 #define MAX_COMMAND_SIZE	16
diff -urN linux-2.5.73-bk8/include/scsi/scsi_device.h linux-2.5.73-bk9/include/scsi/scsi_device.h
--- linux-2.5.73-bk8/include/scsi/scsi_device.h	2003-06-22 11:32:31.000000000 -0700
+++ linux-2.5.73-bk9/include/scsi/scsi_device.h	2003-07-01 04:51:41.000000000 -0700
@@ -7,6 +7,7 @@
 
 struct request_queue;
 struct scsi_cmnd;
+struct scsi_mode_data;
 
 
 struct scsi_device {
@@ -103,4 +104,8 @@
 
 extern int scsi_set_medium_removal(struct scsi_device *, char);
 
+extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
+			   unsigned char *buffer, int len, int timeout,
+			   int retries, struct scsi_mode_data *data);
+
 #endif /* _SCSI_SCSI_DEVICE_H */
diff -urN linux-2.5.73-bk8/include/scsi/scsi_driver.h linux-2.5.73-bk9/include/scsi/scsi_driver.h
--- linux-2.5.73-bk8/include/scsi/scsi_driver.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.73-bk9/include/scsi/scsi_driver.h	2003-07-01 04:51:41.000000000 -0700
@@ -0,0 +1,27 @@
+#ifndef _SCSI_SCSI_DRIVER_H
+#define _SCSI_SCSI_DRIVER_H
+
+#include <linux/device.h>
+
+struct module;
+
+
+struct scsi_driver {
+	struct module		*owner;
+	struct device_driver	gendrv;
+
+	int (*init_command)(struct scsi_cmnd *);
+	void (*rescan)(struct device *);
+};
+#define to_scsi_driver(drv) \
+	container_of((drv), struct scsi_driver, gendrv)
+
+extern int scsi_register_driver(struct device_driver *);
+#define scsi_unregister_driver(drv) \
+	driver_unregister(drv);
+
+extern int scsi_register_interface(struct class_interface *);
+#define scsi_unregister_interface(intf) \
+	class_interface_unregister(intf)
+
+#endif /* _SCSI_SCSI_DRIVER_H */
diff -urN linux-2.5.73-bk8/include/scsi/scsi_request.h linux-2.5.73-bk9/include/scsi/scsi_request.h
--- linux-2.5.73-bk8/include/scsi/scsi_request.h	2003-06-22 11:33:33.000000000 -0700
+++ linux-2.5.73-bk9/include/scsi/scsi_request.h	2003-07-01 04:51:41.000000000 -0700
@@ -32,7 +32,7 @@
 	unsigned sr_bufflen;	/* Size of data buffer */
 	void *sr_buffer;		/* Data buffer */
 	int sr_allowed;
-	unsigned char sr_data_direction;
+	enum dma_data_direction sr_data_direction;
 	unsigned char sr_cmd_len;
 	unsigned char sr_cmnd[MAX_COMMAND_SIZE];
 	void (*sr_done) (struct scsi_cmnd *);	/* Mid-level done function */
@@ -55,4 +55,19 @@
 			void (*done) (struct scsi_cmnd *),
 			int timeout, int retries);
 
+struct scsi_mode_data {
+	__u16	length;
+	__u16	block_descriptor_length;
+	__u8	medium_type;
+	__u8	device_specific;
+	__u8	header_length;
+	__u8	longlba:1;
+};
+
+extern int __scsi_mode_sense(struct scsi_request *SRpnt, int dbd,
+			     int modepage, unsigned char *buffer, int len,
+			     int timeout, int retries,
+			     struct scsi_mode_data *data);
+
+
 #endif /* _SCSI_SCSI_REQUEST_H */
diff -urN linux-2.5.73-bk8/mm/mmap.c linux-2.5.73-bk9/mm/mmap.c
--- linux-2.5.73-bk8/mm/mmap.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/mm/mmap.c	2003-07-01 04:51:41.000000000 -0700
@@ -846,7 +846,7 @@
 			ret = is_hugepage_only_range(addr, len);
 		}
 		if (ret)
-			return ret;
+			return -EINVAL;
 		return addr;
 	}
 
diff -urN linux-2.5.73-bk8/net/ipv6/ip6_flowlabel.c linux-2.5.73-bk9/net/ipv6/ip6_flowlabel.c
--- linux-2.5.73-bk8/net/ipv6/ip6_flowlabel.c	2003-06-22 11:32:37.000000000 -0700
+++ linux-2.5.73-bk9/net/ipv6/ip6_flowlabel.c	2003-07-01 04:51:41.000000000 -0700
@@ -19,6 +19,7 @@
 #include <linux/in6.h>
 #include <linux/route.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 
 #include <net/sock.h>
 
@@ -554,66 +555,132 @@
 
 #ifdef CONFIG_PROC_FS
 
+struct ip6fl_iter_state {
+	int bucket;
+};
 
-static int ip6_fl_read_proc(char *buffer, char **start, off_t offset,
-			    int length, int *eof, void *data)
-{
-	off_t pos=0;
-	off_t begin=0;
-	int len=0;
-	int i, k;
-	struct ip6_flowlabel *fl;
+#define ip6fl_seq_private(seq)	((struct ip6fl_iter_state *)&(seq)->private)
 
-	len+= sprintf(buffer,"Label S Owner  Users  Linger Expires  "
-		      "Dst                              Opt\n");
+static struct ip6_flowlabel *ip6fl_get_first(struct seq_file *seq)
+{
+	struct ip6_flowlabel *fl = NULL;
+	struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
 
-	read_lock_bh(&ip6_fl_lock);
-	for (i=0; i<=FL_HASH_MASK; i++) {
-		for (fl = fl_ht[i]; fl; fl = fl->next) {
-			len+=sprintf(buffer+len,"%05X %-1d %-6d %-6d %-6d %-8ld ",
-				     (unsigned)ntohl(fl->label),
-				     fl->share,
-				     (unsigned)fl->owner,
-				     atomic_read(&fl->users),
-				     fl->linger/HZ,
-				     (long)(fl->expires - jiffies)/HZ);
-
-			for (k=0; k<16; k++)
-				len+=sprintf(buffer+len, "%02x", fl->dst.s6_addr[k]);
-			buffer[len++]=' ';
-			len+=sprintf(buffer+len, "%-4d", fl->opt ? fl->opt->opt_nflen : 0);
-			buffer[len++]='\n';
-
-			pos=begin+len;
-			if(pos<offset) {
-				len=0;
-				begin=pos;
-			}
-			if(pos>offset+length)
-				goto done;
+	for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) {
+		if (fl_ht[state->bucket]) {
+			fl = fl_ht[state->bucket];
+			break;
 		}
 	}
-	*eof = 1;
+	return fl;
+}
 
-done:
+static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flowlabel *fl)
+{
+	struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
+
+	fl = fl->next;
+	while (!fl) {
+		if (++state->bucket <= FL_HASH_MASK)
+			fl = fl_ht[state->bucket];
+	}
+	return fl;
+}
+
+static struct ip6_flowlabel *ip6fl_get_idx(struct seq_file *seq, loff_t pos)
+{
+	struct ip6_flowlabel *fl = ip6fl_get_first(seq);
+	if (fl)
+		while (pos && (fl = ip6fl_get_next(seq, fl)) != NULL)
+			--pos;
+	return pos ? NULL : fl;
+}
+
+static void *ip6fl_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	read_lock_bh(&ip6_fl_lock);
+	return *pos ? ip6fl_get_idx(seq, *pos) : (void *)1;
+}
+
+static void *ip6fl_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	struct ip6_flowlabel *fl;
+
+	if (v == (void *)1)
+		fl = ip6fl_get_first(seq);
+	else
+		fl = ip6fl_get_next(seq, v);
+	++*pos;
+	return fl;
+}
+
+static void ip6fl_seq_stop(struct seq_file *seq, void *v)
+{
 	read_unlock_bh(&ip6_fl_lock);
-	*start=buffer+(offset-begin);
-	len-=(offset-begin);
-	if(len>length)
-		len=length;
-	if(len<0)
-		len=0;
-	return len;
 }
+
+static void ip6fl_fl_seq_show(struct seq_file *seq, struct ip6_flowlabel *fl)
+{
+	while(fl) {
+		seq_printf(seq,
+			   "%05X %-1d %-6d %-6d %-6d %-8ld "
+			   "%02x%02x%02x%02x%02x%02x%02x%02x "
+			   "%-4d\n",
+			   (unsigned)ntohl(fl->label),
+			   fl->share,
+			   (unsigned)fl->owner,
+			   atomic_read(&fl->users),
+			   fl->linger/HZ,
+			   (long)(fl->expires - jiffies)/HZ,
+			   NIP6(fl->dst),
+			   fl->opt ? fl->opt->opt_nflen : 0);
+		fl = fl->next;
+	}
+}
+
+static int ip6fl_seq_show(struct seq_file *seq, void *v)
+{
+	if (v == (void *)1)
+		seq_printf(seq, "Label S Owner  Users  Linger Expires  "
+				"Dst                              Opt\n");
+	else
+		ip6fl_fl_seq_show(seq, v);
+	return 0;
+}
+
+static struct seq_operations ip6fl_seq_ops = {
+	.start	=	ip6fl_seq_start,
+	.next	=	ip6fl_seq_next,
+	.stop	=	ip6fl_seq_stop,
+	.show	=	ip6fl_seq_show,
+};
+
+static int ip6fl_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &ip6fl_seq_ops);
+}
+
+static struct file_operations ip6fl_seq_fops = {
+	.owner		=	THIS_MODULE,
+	.open		=	ip6fl_seq_open,
+	.read		=	seq_read,
+	.llseek		=	seq_lseek,
+	.release	=	seq_release,
+};
 #endif
 
 
 void ip6_flowlabel_init()
 {
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *p;
+#endif
 	init_timer(&ip6_fl_gc_timer);
 	ip6_fl_gc_timer.function = ip6_fl_gc;
 #ifdef CONFIG_PROC_FS
-	create_proc_read_entry("net/ip6_flowlabel", 0, 0, ip6_fl_read_proc, NULL);
+	p = create_proc_entry("ip6_flowlabel", S_IRUGO, proc_net);
+	if (p)
+		p->proc_fops = &ip6fl_seq_fops;
 #endif
 }
 
@@ -621,6 +688,6 @@
 {
 	del_timer(&ip6_fl_gc_timer);
 #ifdef CONFIG_PROC_FS
-	remove_proc_entry("net/ip6_flowlabel", 0);
+	proc_net_remove("ip6_flowlabel");
 #endif
 }
diff -urN linux-2.5.73-bk8/net/ipv6/ip6_output.c linux-2.5.73-bk9/net/ipv6/ip6_output.c
--- linux-2.5.73-bk8/net/ipv6/ip6_output.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/ipv6/ip6_output.c	2003-07-01 04:51:41.000000000 -0700
@@ -984,7 +984,7 @@
 		ipv6_select_ident(skb, fh);
 		fh->nexthdr = nexthdr;
 		fh->reserved = 0;
-		fh->frag_off = htons(0x0001);
+		fh->frag_off = htons(IP6_MF);
 		frag_id = fh->identification;
 
 		first_len = skb_pagelen(skb);
@@ -1004,9 +1004,9 @@
 				offset += skb->len - hlen - sizeof(struct frag_hdr);
 				fh->nexthdr = nexthdr;
 				fh->reserved = 0;
-				if (frag->next != NULL)
-					offset |= 0x0001;
 				fh->frag_off = htons(offset);
+				if (frag->next != NULL)
+					fh->frag_off |= htons(IP6_MF);
 				fh->identification = frag_id;
 				frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
 				ip6_copy_metadata(frag, skb);
@@ -1113,7 +1113,9 @@
 			BUG();
 		left -= len;
 
-		fh->frag_off = htons( left > 0 ?  (offset | 0x0001) : offset);
+		fh->frag_off = htons(offset);
+		if (left > 0)
+			fh->frag_off |= htons(IP6_MF);
 		frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
 
 		ptr += len;
diff -urN linux-2.5.73-bk8/net/ipv6/reassembly.c linux-2.5.73-bk9/net/ipv6/reassembly.c
--- linux-2.5.73-bk8/net/ipv6/reassembly.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/ipv6/reassembly.c	2003-07-01 04:51:41.000000000 -0700
@@ -435,7 +435,7 @@
  				     csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0));
 
 	/* Is this the final fragment? */
-	if (!(fhdr->frag_off & htons(0x0001))) {
+	if (!(fhdr->frag_off & htons(IP6_MF))) {
 		/* If we already have some bits beyond end
 		 * or have different end, the segment is corrupted.
 		 */
diff -urN linux-2.5.73-bk8/net/key/af_key.c linux-2.5.73-bk9/net/key/af_key.c
--- linux-2.5.73-bk8/net/key/af_key.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/key/af_key.c	2003-07-01 04:51:41.000000000 -0700
@@ -1221,7 +1221,11 @@
 	if (IS_ERR(x))
 		return PTR_ERR(x);
 
-	err = xfrm_state_replace(x, hdr->sadb_msg_type == SADB_ADD);
+	if (hdr->sadb_msg_type == SADB_ADD)
+		err = xfrm_state_add(x);
+	else
+		err = xfrm_state_update(x);
+
 	if (err < 0) {
 		x->km.state = XFRM_STATE_DEAD;
 		xfrm_state_put(x);
diff -urN linux-2.5.73-bk8/net/netsyms.c linux-2.5.73-bk9/net/netsyms.c
--- linux-2.5.73-bk8/net/netsyms.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/netsyms.c	2003-07-01 04:51:41.000000000 -0700
@@ -306,7 +306,8 @@
 EXPORT_SYMBOL(__xfrm_state_destroy);
 EXPORT_SYMBOL(xfrm_state_find);
 EXPORT_SYMBOL(xfrm_state_insert);
-EXPORT_SYMBOL(xfrm_state_replace);
+EXPORT_SYMBOL(xfrm_state_add);
+EXPORT_SYMBOL(xfrm_state_update);
 EXPORT_SYMBOL(xfrm_state_check_expire);
 EXPORT_SYMBOL(xfrm_state_check_space);
 EXPORT_SYMBOL(xfrm_state_lookup);
diff -urN linux-2.5.73-bk8/net/xfrm/xfrm_input.c linux-2.5.73-bk9/net/xfrm/xfrm_input.c
--- linux-2.5.73-bk8/net/xfrm/xfrm_input.c	2003-06-22 11:32:31.000000000 -0700
+++ linux-2.5.73-bk9/net/xfrm/xfrm_input.c	2003-07-01 04:51:41.000000000 -0700
@@ -18,7 +18,7 @@
 	kmem_cache_free(sp->pool, sp);
 }
 
-/* Fetch spi and seq frpm ipsec header */
+/* Fetch spi and seq from ipsec header */
 
 int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
 {
diff -urN linux-2.5.73-bk8/net/xfrm/xfrm_state.c linux-2.5.73-bk9/net/xfrm/xfrm_state.c
--- linux-2.5.73-bk8/net/xfrm/xfrm_state.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/xfrm/xfrm_state.c	2003-07-01 04:51:41.000000000 -0700
@@ -395,49 +395,110 @@
 	spin_unlock_bh(&xfrm_state_lock);
 }
 
-int xfrm_state_replace(struct xfrm_state *x, int excl)
+int xfrm_state_add(struct xfrm_state *x)
 {
 	struct xfrm_state_afinfo *afinfo;
 	struct xfrm_state *x1;
 	int err;
 
 	afinfo = xfrm_state_get_afinfo(x->props.family);
-	x1 = NULL;
+	if (unlikely(afinfo == NULL))
+		return -EAFNOSUPPORT;
 
 	spin_lock_bh(&xfrm_state_lock);
 
-	if (afinfo) {
-		x1 = afinfo->state_lookup(&x->id.daddr, x->id.spi, x->id.proto);
-		if (!x1) {
-			x1 = afinfo->find_acq(
-				x->props.mode, x->props.reqid, x->id.proto,
-				&x->id.daddr, &x->props.saddr, 0);
-			if (x1 && x1->id.spi != x->id.spi && x1->id.spi) {
-				xfrm_state_put(x1);
-				x1 = NULL;
-			}
-		}
-
-		if (x1 && (excl ? x1->id.spi : xfrm_state_kern(x1))) {
+	x1 = afinfo->state_lookup(&x->id.daddr, x->id.spi, x->id.proto);
+	if (!x1) {
+		x1 = afinfo->find_acq(
+			x->props.mode, x->props.reqid, x->id.proto,
+			&x->id.daddr, &x->props.saddr, 0);
+		if (x1 && x1->id.spi != x->id.spi && x1->id.spi) {
 			xfrm_state_put(x1);
 			x1 = NULL;
-			err = -EEXIST;
-			goto out;
 		}
 	}
 
+	if (x1 && x1->id.spi) {
+		xfrm_state_put(x1);
+		x1 = NULL;
+		err = -EEXIST;
+		goto out;
+	}
+
 	__xfrm_state_insert(x);
 	err = 0;
 
 out:
 	spin_unlock_bh(&xfrm_state_lock);
+	xfrm_state_put_afinfo(afinfo);
 
 	if (x1) {
 		xfrm_state_delete(x1);
 		xfrm_state_put(x1);
 	}
 
+	return err;
+}
+
+int xfrm_state_update(struct xfrm_state *x)
+{
+	struct xfrm_state_afinfo *afinfo;
+	struct xfrm_state *x1;
+	int err;
+
+	afinfo = xfrm_state_get_afinfo(x->props.family);
+	if (unlikely(afinfo == NULL))
+		return -EAFNOSUPPORT;
+
+	spin_lock_bh(&xfrm_state_lock);
+	x1 = afinfo->state_lookup(&x->id.daddr, x->id.spi, x->id.proto);
+
+	err = -ESRCH;
+	if (!x1)
+		goto out;
+
+	if (xfrm_state_kern(x1)) {
+		xfrm_state_put(x1);
+		err = -EEXIST;
+		goto out;
+	}
+
+	if (x1->km.state == XFRM_STATE_ACQ) {
+		__xfrm_state_insert(x);
+		x = NULL;
+	}
+	err = 0;
+
+out:
+	spin_unlock_bh(&xfrm_state_lock);
 	xfrm_state_put_afinfo(afinfo);
+
+	if (err)
+		return err;
+
+	if (!x) {
+		xfrm_state_delete(x1);
+		xfrm_state_put(x1);
+		return 0;
+	}
+
+	err = -EINVAL;
+	spin_lock_bh(&x1->lock);
+	if (likely(x1->km.state == XFRM_STATE_VALID)) {
+		memcpy(x1->encap, x->encap, sizeof(*x1->encap));
+		memcpy(&x1->lft, &x->lft, sizeof(x1->lft));
+		x1->km.dying = 0;
+		err = 0;
+	}
+	spin_unlock_bh(&x1->lock);
+
+	if (!mod_timer(&x1->timer, jiffies + HZ))
+		xfrm_state_hold(x1);
+	if (x1->curlft.use_time)
+		xfrm_state_check_expire(x1);
+
+	xfrm_state_put(x1);
+
 	return err;
 }
 
diff -urN linux-2.5.73-bk8/net/xfrm/xfrm_user.c linux-2.5.73-bk9/net/xfrm/xfrm_user.c
--- linux-2.5.73-bk8/net/xfrm/xfrm_user.c	2003-07-01 04:51:31.000000000 -0700
+++ linux-2.5.73-bk9/net/xfrm/xfrm_user.c	2003-07-01 04:51:41.000000000 -0700
@@ -200,7 +200,7 @@
 	x->props.replay_window = p->replay_window;
 	x->props.reqid = p->reqid;
 	x->props.family = p->family;
-	x->props.saddr = x->sel.saddr;
+	x->props.saddr = p->saddr;
 }
 
 static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p,
@@ -260,7 +260,11 @@
 	if (!x)
 		return err;
 
-	err = xfrm_state_replace(x, nlh->nlmsg_type == XFRM_MSG_NEWSA);
+	if (nlh->nlmsg_type == XFRM_MSG_NEWSA)
+		err = xfrm_state_add(x);
+	else
+		err = xfrm_state_update(x);
+
 	if (err < 0) {
 		x->km.state = XFRM_STATE_DEAD;
 		xfrm_state_put(x);
@@ -296,6 +300,7 @@
 	memcpy(&p->lft, &x->lft, sizeof(p->lft));
 	memcpy(&p->curlft, &x->curlft, sizeof(p->curlft));
 	memcpy(&p->stats, &x->stats, sizeof(p->stats));
+	p->saddr = x->props.saddr;
 	p->mode = x->props.mode;
 	p->replay_window = x->props.replay_window;
 	p->reqid = x->props.reqid;
