]> git.neil.brown.name Git - history.git/commitdiff
Import 2.1.102pre1 2.1.102pre1
authorLinus Torvalds <torvalds@linuxfoundation.org>
Fri, 23 Nov 2007 20:15:30 +0000 (15:15 -0500)
committerLinus Torvalds <torvalds@linuxfoundation.org>
Fri, 23 Nov 2007 20:15:30 +0000 (15:15 -0500)
68 files changed:
CREDITS
Documentation/Changes
Documentation/joystick.txt
MAINTAINERS
Makefile
README
arch/arm/boot/tools/build.c [deleted file]
arch/arm/kernel/dec21285.c
arch/arm/kernel/entry-common.S
arch/arm/lib/extractinfo.perl [deleted file]
arch/arm/mm/fault-armo.c
arch/i386/kernel/smp.c
arch/m68k/kernel/m68k_ksyms.c
arch/mips/kernel/process.c
arch/mips/mm/r4xx0.c
arch/mips/sgi/kernel/indy_sc.c
arch/ppc/kernel/prep_time.c
arch/ppc/lib/string.S
arch/sparc64/solaris/fs.c
drivers/block/Config.in
drivers/block/ide.c
drivers/block/nbd.c
drivers/char/cyclades.c
drivers/char/joystick.c
drivers/char/mem.c
drivers/char/misc.c
drivers/fc4/Config.in
drivers/fc4/soc.c
drivers/isdn/isdn_net.c
drivers/net/8390.c
drivers/net/8390.h
drivers/sbus/audio/cs4231.c
drivers/scsi/53c7,8xx.c
drivers/scsi/53c7xx.c
drivers/scsi/AM53C974.c
drivers/scsi/AM53C974.h
drivers/scsi/NCR5380.c
drivers/scsi/NCR53c406a.c
drivers/scsi/advansys.c
drivers/scsi/aha152x.c
drivers/scsi/eata.c
drivers/scsi/fdomain.c
drivers/scsi/g_NCR5380.c
drivers/scsi/gdth.c
drivers/scsi/ibmmca.c
drivers/scsi/in2000.c
drivers/scsi/scsi.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_obsolete.c
drivers/scsi/scsiiom.c
drivers/scsi/seagate.c
drivers/scsi/u14-34f.c
drivers/scsi/wd33c93.c
drivers/scsi/wd7000.c
fs/buffer.c
fs/ext2/balloc.c
fs/ext2/ialloc.c
fs/filesystems.c
fs/open.c
fs/super.c
include/asm-i386/current.h
include/asm-ppc/serial.h
include/linux/capability.h
include/linux/fs.h
include/linux/joystick.h
include/linux/quotaops.h
kernel/sys.c
net/802/hippi.c

diff --git a/CREDITS b/CREDITS
index 662f569f0faa8d80602ac398daaa2f245fec37b5..2ff4a3358a8bf700f54ed03fa97cb7f896174c18 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -1279,6 +1279,16 @@ S: Matlock
 S: Derbyshire DE4 3RL
 S: United Kingdom
 
+N: Russell Nelson
+E: nelson@crynwr.com
+W: http://www.crynwr.com/~nelson
+P: 1024/83942741 FF 68 EE 27 A0 5A AA C3  F5 DC 05 62 BD 5B 20 2F
+D: Author of cs89x0, maintainer of kernel changelog through 1.3.3
+D: Wrote many packet drivers, from which some Ethernet drivers are derived.
+S: 521 Pleasant Valley Rd.
+S: Potsdam, NY 13676
+S: USA
+
 N: Michael Neuffer
 E: mike@i-Connect.Net
 E: neuffer@goofy.zdv.uni-mainz.de
index 1da1ddf7ee8cb3a00f331d287fe22faf9c71f9cc..0a95b69fc48ece12465f32ef7bdf3e2b65963ae1 100644 (file)
@@ -33,7 +33,7 @@ http://cyberbuzz.gatech.edu/kaboom/linux/ as well.
    Also, don't forget http://www.linuxhq.com/ for all your Linux kernel
 needs.
 
-Last updated: May 5, 1998
+Last updated: May 9, 1998
 Current Author: Chris Ricker (kaboom@gatech.edu).
 
 Current Minimal Requirements
@@ -45,7 +45,7 @@ running, the suggested command should tell you.
 
 - Kernel modules        modutils-2.1.85         ; insmod -V
 - Gnu C                 2.7.2.3                 ; gcc --version
-- Binutils              2.8.1.0.              ; ld -v
+- Binutils              2.8.1.0.23              ; ld -v
 - Linux C Library       5.4.44                  ; ls -l /lib/libc.so.*
 - Dynamic Linker (ld.so) 1.9.5                   ; ldd --version
 - Linux C++ Library     2.7.2.8                 ; ls -l /usr/lib/libg++.so.*
@@ -59,7 +59,7 @@ running, the suggested command should tell you.
 - NFS                    0.4.21                  ; showmount --version
 - Bash                   1.14.7                  ; bash -version
 - Ncpfs                  2.1.1                   ; ncpmount -v
-- Pcmcia-cs              3.0.0
+- Pcmcia-cs              May 4, 1998
 - PPP                    2.3.5                   ; pppd -v
 
 Upgrade notes
@@ -127,11 +127,13 @@ Binutils
 to find out the proper way to upgrade it.  No, the instruction to "rm
 `which encaps`" is not a joke.
 
-The last public release of the binutils 2.8.x series is 2.8.1.0.23. 
-Binutils 2.8.1.0.25 to 2.9.1.0.2 are all very buggy; do not use them. 
-Binutils 2.9.1 (note the absence of a suffix) is all right, and binutils
-2.9.1.0.3 (and presumably later revisions) will probably work, too. 
-Stick with 2.8.1.0.23 to be safe. 
+   The last public release of the binutils 2.8.x series was 2.8.1.0.23.
+Binutils 2.8.1.0.25 to 2.9.1.0.2 are beta releases, and are known to be
+very buggy.  Binutils 2.9.1 (note the absence of a suffix) from the FSF
+should work, and binutils 2.9.1.0.3 and later releases are also good.
+Either use binutils-2.8.1.0.23 or binutils-2.9.1.0.4 or later.  Glibc2
+users should especially try to use the 2.9.1.0.x releases, as they
+resolve known issues with glibc2 and binutils-2.8.x releases.
 
 Gnu C
 =====
@@ -273,13 +275,24 @@ Where to get the files
 Binutils
 ========
 
-The 2.8.1.0.1 release:
+The 2.8.1.0.23 release:
 ftp://tsx-11.mit.edu/pub/linux/packages/GCC/binutils-2.8.1.0.23.bin.tar.gz
 ftp://sunsite.unc.edu/pub/Linux/GCC/binutils-2.8.1.0.23.bin.tar.gz
 Installation notes:
 ftp://tsx-11.mit.edu/pub/linux/packages/GCC/release.binutils-2.8.1.0.23
 ftp://sunsite.unc.edu/pub/Linux/GCC/release.binutils-2.8.1.0.23
 
+The 2.9.1.0.4 release:
+ftp://tsx-11.mit.edu/pub/linux/packages/GCC/binutils-2.9.1.0.4-glibc.x86.tar.gz
+ftp://tsx-11.mit.edu/pub/linux/packages/GCC/binutils-2.9.1.0.4-libc5.x86.tar.gz
+ftp://tsx-11.mit.edu/pub/linux/packages/GCC/binutils-2.9.1.0.4.tar.gz
+ftp://sunsite.unc.edu/pub/Linux/GCC/binutils-2.9.1.0.4-glibc.x86.tar.gz
+ftp://sunsite.unc.edu/pub/Linux/GCC/binutils-2.9.1.0.4-libc5.x86.tar.gz
+ftp://sunsite.unc.edu/pub/Linux/GCC/binutils-2.9.1.0.4.tar.gz
+Installation notes:
+ftp://tsx-11.mit.edu/pub/linux/packages/GCC/release.binutils-2.9.1.0.4
+ftp://sunsite.unc.edu/pub/Linux/GCC/release.binutils-2.9.1.0.4
+
 Gnu C
 =====
 
index eada60d0df76cd348cb37e24cd88bfa1af9227aa..672d0ecfa52b9e3cb5c8e0415a27a6f482a8388f 100644 (file)
@@ -1,5 +1,5 @@
-                      PC Joystick driver v1.0.6 beta
-        (c) 1997 Vojtech Pavlik <vojtech@atrey.karlin.mff.cuni.cz>
+                       PC Joystick driver v1.0.9
+       (c) 1997 Vojtech Pavlik <vojtech@atrey.karlin.mff.cuni.cz>
 ----------------------------------------------------------------------------
 
 1. Intro
@@ -8,20 +8,22 @@
 resistor based) and digital (switch based) joysticks connected via the PC
 game port. It can support up to 2 joysticks.
 
-  Because the joystick driver is still in its beta stage I'm very interested
-in any problems you encounter while using it. Bug reports and success
-stories are also welcome.
+  Should you encounter any problems while using the driver, or joysticks
+this driver can't make complete use of, I'm very interested in hearing about
+them. Bug reports and success stories are also welcome.
 
 2. Usage
 ~~~~~~~~
   If you enable the joystick driver in the kernel configuration, all
-connected joysticks should be found automatically. If that doesn't work, you
-can pass the joystick driver the following kernel command line arguments:
+connected joysticks should be found automatically. The driver can detect
+standard two-axis two-button, and three-axis four-button joysticks only. If
+that isn't your case, you can pass the joystick driver the following kernel
+command line arguments:
 
 js=0xXX,0xYY
 
   Where XX and YY are bit masks for the two joysticks, with the bits
-representing:
+representing which buttons and axes of the joystick are present:
 
 Bit | Explanation
 -----------------
@@ -34,9 +36,6 @@ Bit | Explanation
  6  | Button 2
  7  | Button 3
 
-  These bitmasks are ANDed with what's found by the driver and the result is
-used. 
-
   Another method of using the driver is loading it as a module. For that,
 select `M' for this driver in the kernel configuration and insert the
 module:
@@ -53,23 +52,19 @@ options joystick js=0xXX,0xYY
 create the device files using mknod (man mknod for more info):
 
 mknod /dev/js0 c 15 0
-mknod /dev/js1 c 15 1 
+mknod /dev/js1 c 15 1
 
 3. Calibration
 ~~~~~~~~~~~~~~
   As of version 1.0 the calibration routines used in the joystick driver are
 worth using. The idea of calibration is that you have to calibrate the
 joystick only once, and then set the calibration at boot-time, thus removing
-the need of re-calibrating it in each program that uses it. 
+the need of re-calibrating it in each program that uses it.
 
   For calibration, use the jscal program, contained in the joystick package
 which is available at:
 
-ftp://atrey.karlin.mff.cuni.cz/pub/local/vojtech/joystick/joystick-1.0.6.tar.gz
-
-And soon also at:
-
-ftp://sunsite.unc.edu/pub/Linux/kernel/patches/console/joystick-1.0.6.tar.gz
+ftp://atrey.karlin.mff.cuni.cz/pub/linux/joystick/joystick-1.0.9.tar.gz
 
 4. Programming Interface
 ~~~~~~~~~~~~~~~~~~~~~~~~
@@ -88,65 +83,65 @@ be dropped in the future.
   Thanks to the following authors that contributed to the joystick driver
 development:
 
-     0.1-0.5           Arthur C. Smith <asmith@cbnewsd.att.com>
-     0.5               Eyal Lebedinsky <eyal@eyal.emu.id.au>
-     0.6               Jeff Tranter    <tranter@software.mitel.com>
-     0.7               Carlos Puchol   <cpg@cs.utexas.edu>
-     0.7.1-0.8         Matt Rhoten     <mrhoten@oz.net>
-     0.7.3             Dan Fandrich    <dan@fch.wimsey.bc.ca>
-     0.7.3             Sverker Wilberg <sverkerw@manila.docs.uu.se>
-     0.8               Hal Maney       <maney@norden.com>
-     0.8               Bernd Schmidt   <crux@pool.informatik.rwth-aachen.de>
-     0.9               Alan Cox        <alan@cymru.net>
-     0.9.0-1.0.6       Vojtech Pavlik  <vojtech@atrey.karlin.mff.cuni.cz>
+      0.1-0.5          Arthur C. Smith <asmith@cbnewsd.att.com>
+      0.5              Eyal Lebedinsky <eyal@eyal.emu.id.au>
+      0.6              Jeff Tranter    <tranter@software.mitel.com>
+      0.7              Carlos Puchol   <cpg@cs.utexas.edu>
+      0.7.1-0.8                Matt Rhoten     <mrhoten@oz.net>
+      0.7.3            Dan Fandrich    <dan@fch.wimsey.bc.ca>
+      0.7.3            Sverker Wilberg <sverkerw@manila.docs.uu.se>
+      0.8              Hal Maney       <maney@norden.com>
+      0.8              Bernd Schmidt   <crux@pool.informatik.rwth-aachen.de>
+      0.9              Alan Cox        <alan@lxorguk.ukuu.org.uk>
+      0.9.0-1.0.9      Vojtech Pavlik  <vojtech@atrey.karlin.mff.cuni.cz>
 
 6. Change Log
 ~~~~~~~~~~~~~
   The current (1.0.x) version was originally based on the 0.7.3 version of
 the joystick driver, which caused some inconsistencies in version numbering.
-The following log documents all changes done to the driver by various
+The following log documents all changes done to the driver by the above
 contributors:
 
-Version 0.1    Original version 
+Version 0.1    Original version
                Works but lacks multi-joystick support
 Version 0.2    Added multi-joystick support (minor 0 and 1)
-               Added delay between measuring joystick axis
-               Added scaling ioctl
+               Added delay between measuring joystick axis
+               Added scaling ioctl
 Version 0.3    Modified scaling to use ints to prevent kernel
-               panics 8-)
+               panics 8-)
 Version 0.4    Linux 0.99.6 and fixed race condition in js_read.
-               After looking at a schematic of a joystick card
-               it became apparent that any write to the joystick
-               port started ALL the joystick one shots. If the
-               one that we are reading is short enough and the
-               first one to be read, the second one will return
-               bad data if its one shot has not expired when
-               the joystick port is written for the second time.
-               Thus solves the mystery delay problem in 0.2!
+               After looking at a schematic of a joystick card
+               it became apparent that any write to the joystick
+               port started ALL the joystick one shots. If the
+               one that we are reading is short enough and the
+               first one to be read, the second one will return
+               bad data if its one shot has not expired when
+               the joystick port is written for the second time.
+               Thus solves the mystery delay problem in 0.2!
 Version 0.5    Upgraded the driver to the 0.99.9 kernel, added
-               joystick support to the make config options,
-               updated the driver to return the buttons as
-               positive logic, and read both axis at once
-               and added some new ioctls.
+               joystick support to the make config options,
+               updated the driver to return the buttons as
+               positive logic, and read both axis at once
+               and added some new ioctls.
 Version 0.6    Made necessary changes to work with 0.99.15
-               kernel (and hopefully 1.0). Also did some
-               cleanup: indented code, fixed some typos, wrote
-               man page, etc ...
-Version 0.7    Support for modules         
+               kernel (and hopefully 1.0). Also did some
+               cleanup: indented code, fixed some typos, wrote
+               man page, etc ...
+Version 0.7    Support for modules
 Version 0.7.1  Fix bug in reading button state of js1
-               Add include so module compiles under recent kernels
+               Add include so module compiles under recent kernels
 Version 0.7.3  Include directives changed for joystick.h
-               Separated out joystick detection/counting, cleanup
-               Fix for detection of 3-axis joysticks
-               Better detection announcement
-               Added I/O port registration, cleaned up code
+               Separated out joystick detection/counting, cleanup
+               Fix for detection of 3-axis joysticks
+               Better detection announcement
+               Added I/O port registration, cleaned up code
 Version 0.8    New read loop
-               Cleaned up #includes to allow #include of joystick.h with
-               gcc -Wall and from g++
-               Made js_init fail if it finds zero joysticks
-               General source/comment cleanup
-               Use of MOD_(INC|DEC)_USE_COUNT
-               Changes to compile correctly under 1.3 in kernel or as module
+               Cleaned up #includes to allow #include of joystick.h with
+               gcc -Wall and from g++
+               Made js_init fail if it finds zero joysticks
+               General source/comment cleanup
+               Use of MOD_(INC|DEC)_USE_COUNT
+               Changes to compile correctly under 1.3 in kernel or as module
 Version 0.9    Ported to 2.1.x
                Reformatted to resemble Linux coding standard
                Removed semaphore bug (we can dump the lot I think)
@@ -156,51 +151,63 @@ Version 0.9       Ported to 2.1.x
                Removed 'save_busy'. Just set busy to 1.
 Version 0.9.0  Based on 0.7.3
                New read function that allows two axes to have the same value
-               New joystick calibration code
-               Real support for 3-axis joysticks       
-               CPU speed independent timeouts
-               Reads may happen even for unwhole record size => cat /dev/js0 works
-               Correct error for lseek
-               /dev/js? can be read simultaneously by several processes
+               New joystick calibration code
+               Real support for 3-axis joysticks
+               CPU speed independent timeouts
+               Reads may happen even for unwhole record size => cat /dev/js0 works
+               Correct error for lseek
+               /dev/js? can be read simultaneously by several processes
 Version 0.9.1  IOCTLs now obey general Linux IOCTL rules ('j' letter assigned)
-               Use of verify_area result codes
+               Use of verify_area result codes
                Fuzz correction added
-               Semaphore and many cli()'s removed
-               Fix for TurboFire joysticks - read buttons always
-               Fix for broken joysticks - return with -ENODEV only if joystick
-               completely disconnected
-               Fix in read function to allow zero results 
-               Broken line correction added for broken joysticks (eg. JB-500)
-               Timeouts back separated for easier setting
-               Some fixes and cleanups in read function
+               Semaphore and many cli()'s removed
+               Fix for TurboFire joysticks - read buttons always
+               Fix for broken joysticks - return with -ENODEV only if joystick
+               completely disconnected
+               Fix in read function to allow zero results
+               Broken line correction added for broken joysticks (eg. JB-500)
+               Timeouts back separated for easier setting
+               Some fixes and cleanups in read function
 Version 0.9.2  Fixed a typo causing nothing to be working
 Version 1.0.0  Event approach started
 Version 1.0.1  Complete rewrite
                Compiles but doesn't work
 Version 1.0.2  Works, many bugs fixed, more yet to come
 Version 1.0.3  Tail cutting logic changes & fixes
-               Fix in js_do_bh - no more zero values for axes
-               Lost event changes & fixes
+               Fix in js_do_bh - no more zero values for axes
+               Lost event changes & fixes
 Version 1.0.4  Kernel command line & module configuration support
-               Better cli()/sti() handling
-               Linux 2.1.25 select => poll changes
+               Better cli()/sti() handling
+               Linux 2.1.25 select => poll changes
 Version 1.0.5  Fixes in calibration routines
                Better jscal
 Version 1.0.6  Backward compatibility with old js driver added
-               Init value after recalibration bug fixed
+               Init value after recalibration bug fixed
                Using KERN_* printk() codes
-               Finally leaving ALPHA and going beta
-               Cosmetic changes
+               Finally leaving ALPHA and going beta
+               Cosmetic changes
+Version 1.0.7  Readme update
+               Linux 2.1.89 poll update
+               Compatibility mode fix - refresh data after open
+               Cosmetic changes & cleanup
+Version 1.0.8  Changing the __u16 data to __s16 in event packet
+               The range is now -32727..0..32767
+               Broken line correction needs 2 coefs less
+               Fix to report number of buttons correctly
+               Removed various trailing spaces
+Version 1.0.9  Fix for compatibility mode - don't do correction
+               Fix max number of module parameters
 
 7. To do
 ~~~~~~~~
   Sooner or later I'll get to these:
 
-               Backport & create patches for 2.0
-               Try using Pentium timers for better precision
-               Create patches for most common programs using joystick
-               Support for cards with hw calibration (Gravis Ultrasound, QuickShot)
-               Support for multiport cards (QuickShot 4-joy board)
-               Support for multiaxis, multibutton joysticks (Gravis Firebird)
-               Support for MS digital joystick
+               Make an optional read routine using Pentium timers for better precision (*)
+               Support for hats and more buttons ala CH Flightstick (*)
+               Support for hats ala TM FCS (*)
+               Include support for MS SideWinder digital mode (*)
+               Create patches for most common programs using joystick
+               Support for cards with HW speed compensation
+               Support for more than one joystick port
 
+ (*) - Already in the development 1.1 version.
index ff3cf95e2e3a1a665b8fc989e62311b216a6b1fb..4768e833b0655f863efde01b3e4dfac0c68e3753 100644 (file)
@@ -84,7 +84,7 @@ S:    Maintained
 
 8390 NETWORK DRIVERS [WD80x3/SMC-ELITE, SMC-ULTRA, NE2000, 3C503, etc.]
 P:     Paul Gortmaker
-M      gpg109@rsphy1.anu.edu.au
+M:     gpg109@rsphy1.anu.edu.au
 L:     linux-net@vger.rutgers.edu
 S:     Maintained
 W:     http://rsphy1.anu.edu.au/~gpg109/ne2000.html
index 9f1cecdf7eca77cd791438043f6e72bda84dad54..29c3da83fbf7398610111df5b0db9dd57724eeda 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 2
 PATCHLEVEL = 1
-SUBLEVEL = 101
+SUBLEVEL = 102
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)
 
@@ -87,10 +87,6 @@ SVGA_MODE=   -DSVGA_MODE=NORMAL_VGA
 
 CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 
-ifdef CONFIG_CPP
-CFLAGS := $(CFLAGS) -x c++
-endif
-
 ifdef SMP
 CFLAGS += -D__SMP__
 AFLAGS += -D__SMP__
diff --git a/README b/README
index 0eeb9ff85bdacc24aaecfad0bf2c31fa64e37abf..fee680d31345dbcd1f19f80313b07318eb1d9c21 100644 (file)
--- a/README
+++ b/README
@@ -40,7 +40,7 @@ ON WHAT HARDWARE DOES IT RUN?
 
   Linux was first developed for 386/486-based PCs.  These days it also
   runs on DEC Alphas, SUN Sparcs, M68000 machines (like Atari and Amiga),
-  MIPS and PowerPC.
+  MIPS, PowerPC, and others.
 
 DOCUMENTATION:
 
@@ -68,12 +68,17 @@ INSTALLING the kernel:
    to get it all put in place. Replace "XX" with the version number of the
    latest kernel.
 
- - You can also upgrade between 2.1.xx releases by patching.  To install
-   by patching, get all the newer patch files and do
+ - You can also upgrade between 2.1.xx releases by patching.  Patches are
+   distributed in the traditional gzip and the new bzip2 format.  To
+   install by patching, get all the newer patch files and do
 
                cd /usr/src
                gzip -cd patchXX.gz | patch -p0
 
+   or
+               cd /usr/src
+               bzip2 -dc patchXX.bz2 | patch -p0
+
    (repeat xx for all versions bigger than the version of your current
    source tree, _in_order_) and you should be ok.  You may want to remove
    the backup files (xxx~ or xxx.orig), and make sure that there are no
@@ -190,7 +195,11 @@ COMPILING the kernel:
 
  - Keep a backup kernel handy in case something goes wrong.  This is 
    especially true for the development releases, since each new release
-   contains new code which has not been debugged. 
+   contains new code which has not been debugged.  Make sure you keep a
+   backup of the modules corresponding to that kernel, as well.  If you
+   are installing a new kernel with the same version number as your
+   working kernel, make a backup of your modules directory before you
+   do a "make modules_install".
 
  - In order to boot your new kernel, you'll need to copy the kernel
    image (found in /usr/src/linux/arch/i386/boot/zImage after compilation)
@@ -206,8 +215,8 @@ COMPILING the kernel:
    If you boot Linux from the hard drive, chances are you use LILO which
    uses the kernel image as specified in the file /etc/lilo.conf.  The
    kernel image file is usually /vmlinuz, or /zImage, or /etc/zImage. 
-   To use the new kernel, copy the new image over the old one (save a
-   backup of the original!).  Then, you MUST RERUN LILO to update the
+   To use the new kernel, save a copy of the old image and copy the new
+   image over the old one.  Then, you MUST RERUN LILO to update the
    loading map!! If you don't, you won't be able to boot the new kernel
    image. 
 
diff --git a/arch/arm/boot/tools/build.c b/arch/arm/boot/tools/build.c
deleted file mode 100644 (file)
index ac12975..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <a.out.h>
-
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned long u32;
-
-void die(const char * str, ...)
-{
-       va_list args;
-       va_start(args, str);
-       vfprintf(stderr, str, args);
-       fputc('\n', stderr);
-       exit (1);
-}
-
-int main(int argc, char **argv)
-{
-       void *data;
-       struct exec ex;
-       FILE *f;
-       int totlen;
-
-       if (argc < 2) {
-               fprintf(stderr, "Usage: build kernel-name\n");
-               exit(1);
-       }
-
-       f = fopen(argv[1], "rb");
-       if (!f)
-               die("Unable to open `%s': %m", argv[1]);
-
-       fread(&ex, 1, sizeof(ex), f);
-
-       if(N_MAGIC(ex) == ZMAGIC) {
-               fseek(f, 4096, SEEK_SET);
-               totlen = ex.a_text + ex.a_data;
-       } else
-       if(N_MAGIC(ex) == QMAGIC) {
-               unsigned long my_header;
-               
-               fseek(f, 4, SEEK_SET);
-
-               my_header = 0xea000006;
-
-               fwrite(&my_header, 4, 1, stdout);
-
-               totlen = ex.a_text + ex.a_data - 4;
-       } else {
-               fprintf(stderr, "Unacceptable a.out header on kernel\n");
-               fclose(f);
-               exit(1);
-       }
-
-       fprintf(stderr, "Kernel is %dk (%dk text, %dk data, %dk bss)\n",
-               (ex.a_text + ex.a_data + ex.a_bss)/1024,
-                ex.a_text/1024, ex.a_data/1024, ex.a_bss/1024);
-
-       data = malloc(totlen);
-       fread(data, 1, totlen, f);
-       fwrite(data, 1, totlen, stdout);
-
-       free(data);
-       fclose(f);
-       fflush(stdout);
-       return 0;
-}
index e520b07e2e701e6a785522e2c552ba3a6822f033..5a9f4e51b03fa2a22186a1c07700fa14fb4bf8c2 100644 (file)
@@ -3,7 +3,6 @@
  *
  * Copyright (C) 1998 Russell King
  */
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/init.h>
index b6011f22a9cfff1b9078b08dec2c99594846a43b..c7d6a41f69d9475380cc37b4f97788686672f0a9 100644 (file)
@@ -2,6 +2,8 @@
  * All exits to user mode from the kernel go through this code.
  */
 
+#include <linux/config.h>
+
                .globl  ret_from_sys_call
 
                .globl  SYMBOL_NAME(fpreturn)
diff --git a/arch/arm/lib/extractinfo.perl b/arch/arm/lib/extractinfo.perl
deleted file mode 100644 (file)
index d1f2efa..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-
-$OBJDUMP=$ARGV[0];
-
-sub swapdata {
-       local ($num) = @_;
-
-       return substr($num, 6, 2).substr($num, 4, 2).substr ($num, 2, 2).substr ($num, 0, 2);
-}
-
-open (DATA, $OBJDUMP.' --full-contents --section=.data getconsdata.o | grep \'^ 00\' |') ||
-       die ('Cant objdump!');
-while (<DATA>) {
-       ($addr, $data0, $data1, $data2, $data3) = split (' ');
-       $dat[hex($addr)] = hex(&swapdata($data0));
-       $dat[hex($addr)+4] = hex(&swapdata($data1));
-       $dat[hex($addr)+8] = hex(&swapdata($data2));
-       $dat[hex($addr)+12] = hex(&swapdata($data3));
-}
-close (DATA);
-
-open (DATA, $OBJDUMP.' --syms getconsdata.o |') || die ('Cant objdump!');
-while (<DATA>) {
-       /elf32/ && ( $elf = 1 );
-       /a.out/ && ( $aout = 1 );
-       next if ($aout && ! / 07 /);
-       next if ($elf && ! (/^00...... g/ && /.data/));
-       next if (!$aout && !$elf);
-
-       ($addr, $flags, $sect, $a1, $a2, $a3, $name) = split (' ') if $aout;
-       $nam[hex($addr)] = substr($name, 1) if $aout;
-       if ($elf) {
-               chomp;
-               $addr = substr ($_, 0, 8);
-               $name = substr ($_, 32);
-               $nam[hex($addr)] = $name;
-       }
-}
-close (DATA);
-
-print "/*\n * *** THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT! ***\n */\n";
-for ($i = 0; $i < hex($addr)+12; $i ++) {
-       print "unsigned long $nam[$i] = $dat[$i];\n" if $dat[$i];
-       print "#define __HAS_$nam[$i]\n" if $dat[$i];
-}
index 0ffe78ac932d40f26183c7ccd16210d531fd367c..d4e2860c8bc3163ef56a384193f97260a6083df3 100644 (file)
@@ -5,6 +5,7 @@
  *  Modifications for ARM processor (c) 1995, 1996 Russell King
  */
 
+#include <linux/config.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/head.h>
index ec7ee88c4cb445e5399c847a1adeeb2491cc7e75..afd991976cdd9161c72eacb93106dc6e67625021 100644 (file)
@@ -1564,7 +1564,7 @@ __initfunc(static unsigned int get_8254_timer_count (void))
  * APIC double write bug.
  */
 
-#define APIC_DIVISOR 1
+#define APIC_DIVISOR 16
 
 void setup_APIC_timer (unsigned int clocks)
 {
@@ -1588,7 +1588,7 @@ void setup_APIC_timer (unsigned int clocks)
         */
        tmp_value = apic_read(APIC_TDCR);
        apic_write(APIC_TDCR , (tmp_value & ~APIC_TDR_DIV_1 )
-                                | APIC_TDR_DIV_1);
+                                | APIC_TDR_DIV_16);
 
        tmp_value = apic_read(APIC_TMICT);
        apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
index 54755fa2c384ed9610949c929ca3a8311218ce4e..d78d6cba9f95377b3ed75c1a52fa6689372e2a2b 100644 (file)
@@ -1,3 +1,4 @@
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/linkage.h>
 #include <linux/sched.h>
index 1f783d334feacbd5f7cb58d600be95b9b7fe1a00..aec2b86f05c35afbc703c6968c8a2271ba3eb35e 100644 (file)
@@ -9,7 +9,6 @@
  *
  * $Id: process.c,v 1.10 1998/05/04 09:17:53 ralf Exp $
  */
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
index cc949c1583d418591a600163070dded7ae328127..cfd3d4ba941cf91ee3eb9a32455724aebe08ec39 100644 (file)
@@ -11,6 +11,7 @@
  *  - many of the bug workarounds are not efficient at all, but at
  *    least they are functional ...
  */
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
index 348a53e503815a77df67df0c90ed29e5dc5b84b0..4fa5af822400e34cd66dbf66412ac165212978bc 100644 (file)
@@ -6,7 +6,6 @@
  *
  * $Id: indy_sc.c,v 1.4 1998/05/04 09:12:57 ralf Exp $
  */
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
index d3af36a8a187e9dac0e051afd8af64b1741afb6b..b4a7759f994d9599064a2a5b2f1cca8bf2feccf7 100644 (file)
@@ -8,7 +8,6 @@
  *  copied and modified from intel version
  *
  */
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
index 1b401f51204412aa0aa083a249410d293f6190c5..cc59aaa819b1bc9fe020a9914849350178515ef2 100644 (file)
@@ -8,6 +8,7 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
+#include <linux/config.h>
 #include "../kernel/ppc_asm.tmpl"
 #include <asm/processor.h>
 #include <asm/errno.h>
index 6df97c7c46f538e0e09bae442c8d752f44045bac..7df391ceb43891a9cda667e7c5b4c5b8e8ecb284 100644 (file)
@@ -523,7 +523,7 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
                newattrs.ia_mode &= ~S_ISGID;
                newattrs.ia_valid |= ATTR_MODE;
        }
-       DQUOT_TRANSFER(dentry, newattrs);
+       error = DQUOT_TRANSFER(dentry, &newattrs);
 out:
        return error;
 }
index ac4a41162412934e95d912322aef685b6f4909d3..a112e819a775a97bf542a42cdb85d1fa2282d6ad 100644 (file)
@@ -2,7 +2,7 @@
 # Block device driver configuration
 #
 mainmenu_option next_comment
-comment 'Floppy, IDE, and other block devices'
+comment 'Block devices'
 
 tristate 'Normal floppy disk support' CONFIG_BLK_DEV_FD
 tristate 'Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support' CONFIG_BLK_DEV_IDE
index 6bd198ec1e308576b646f75aca8e2912d8dd126e..106d6ffa31c1fc5f1b28b29b53ed66161765d0ab 100644 (file)
@@ -1333,6 +1333,7 @@ void ide_timer_expiry (unsigned long data)
        }
        hwgroup->busy = 1;      /* should already be "1" */
        hwgroup->handler = NULL;
+       del_timer(&hwgroup->timer);
        if (hwgroup->poll_timeout != 0) {       /* polling in progress? */
                IDE_SPIN_UNLOCK_IRQRESTORE("ide_timer_expiry3", &hwgroup->spinlock, flags);
                handler(drive);
@@ -1348,7 +1349,6 @@ void ide_timer_expiry (unsigned long data)
                IDE_SPIN_UNLOCK_IRQRESTORE("ide_timer_expiry5", &hwgroup->spinlock, flags);
                ide_error(drive, "irq timeout", GET_STAT());
        }
-       del_timer(&hwgroup->timer);
        start_next_request(hwgroup, 0);
 }
 
index cd733884c223c0d029646b70b9a86a468c93f945..9ceed9fe25846ae11fa62f1242e6f662d07a186a 100644 (file)
@@ -316,6 +316,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
        struct nbd_device *lo;
        int dev, error;
 
+       /* Anyone capable of this syscall can do *real bad* things */
+
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
        if (!inode)
@@ -423,6 +425,11 @@ int nbd_init(void)
 {
        int i;
 
+       if (sizeof(struct nbd_request) != 24) {
+               printk(KERN_CRIT "Sizeof nbd_request needs to be 24 in order to work!\n" );
+               return -EIO;
+       }
+
        if (register_blkdev(MAJOR_NR, "nbd", &nbd_fops)) {
                printk("Unable to get major number %d for NBD\n",
                       MAJOR_NR);
index 9f51607fe63d7504a81432357f110c51f2558147..9b6464e34de177e2e2678b3c236557f85ecb3610 100644 (file)
@@ -3382,7 +3382,7 @@ set_serial_info(struct cyclades_port * info,
     copy_from_user(&new_serial,new_info,sizeof(new_serial));
     old_info = *info;
 
-    if (!suser()) {
+    if (!capable(CAP_SYS_ADMIN)) {
             if ((new_serial.close_delay != info->close_delay) ||
                (new_serial.baud_base != info->baud) ||
                ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
index 2dbab35e574528c5af07369ee16b736c8b223238..25a7c2b47d5d52b2b6ac5501cb3b8c196efbcb3f 100644 (file)
@@ -1,13 +1,12 @@
 /*
- *  $Id: joystick.c,v 1.6 1998/03/30 11:10:43 mj Exp $
- *
- *  Copyright (C) 1997, 1998 Vojtech Pavlik
+ * linux/drivers/char/joystick.c  Version 1.0.9
+ * Copyright (C) 1996-1998 Vojtech Pavlik
  */
 
 /*
- *  This is joystick driver for Linux. It supports up to two analog joysticks
- *  on a PC compatible machine. See Documentation/joystick.txt for changelog
- *  and credits.
+ * This is joystick driver for Linux. It supports up to two analog joysticks
+ * on a PC compatible machine. See Documentation/joystick.txt for changelog
+ * and credits.
  */
 
 #include <linux/init.h>
 #define JS_BH_MIN_PERIOD       HZ/25           /* axis min valid time (40 ms) */
 #define JS_BH_MAX_PERIOD       HZ/25*2         /* axis max valid time (80 ms) */
 
-#define JS_FIFO_SIZE           16              /* number of FIFO entries */
+#define JS_FIFO_SIZE           16              /* number of FIFO entries */
 #define JS_BUFF_SIZE           32              /* output buffer size */
-#define JS_RETRIES             4               /* number of retries */ 
-#define JS_DEF_PREC                          /* initial precision for all axes */
+#define JS_RETRIES             4               /* number of retries */
+#define JS_DEF_PREC            16              /* initial precision for all axes */
 
 #define JS_NUM                 2               /* number of joysticks */
 
@@ -44,7 +43,7 @@
 #define PIT_DATA               0x40            /* timer 0 data port */
 #define JS_PORT                0x201           /* joystick port */
 
-#define JS_TRIGGER             0xff            /* triggers one-shots */
+#define JS_TRIGGER             0xff            /* triggers one-shots */
 #define PIT_READ_TIMER         0x00            /* to read timer 0 */
 
 #define DELTA(X,Y,Z)   ((X)-(Y)+(((X)>=(Y))?0:Z))                              /* cyclic delta */
@@ -101,7 +100,7 @@ static unsigned int js_buttons = 0;
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@atrey.karlin.mff.cuni.cz>");
 MODULE_SUPPORTED_DEVICE("js");
-MODULE_PARM(js, "0-1b");
+MODULE_PARM(js, "1-2b");
 
 static char js[] = {0, 0};
 
@@ -113,7 +112,7 @@ static char js[] = {0, 0};
 static inline int get_pit(void)
 {
        int t, flags;
-       
+
        save_flags(flags);
        cli();
        outb(PIT_READ_TIMER, PIT_MODE);
@@ -146,36 +145,34 @@ static int js_correct(int value, struct js_corr *corr)
        int t;
 
        if (corr->type == JS_CORR_NONE) return value;
-       t = value > corr->coef[0] ? (value < corr->coef[1] ? corr->coef[0] : value - corr->coef[1] + corr->coef[0]) : value;
-       if (t == corr->coef[0]) return 32768;
+       t = value > corr->coef[0] ? (value < corr->coef[1] ? 0 : value - corr->coef[1]) : value - corr->coef[0];
 
        switch (corr->type) {
        case JS_CORR_BROKEN:
-               t = t < corr->coef[0] ? ((corr->coef[2] * t) >> 14) + corr->coef[3] :
-                                       ((corr->coef[4] * t) >> 14) + corr->coef[5];
+               t = t < 0 ? ((corr->coef[2] * t) >> 14) : ((corr->coef[3] * t) >> 14);
                break;
-       default: 
+       default:
                return 0;
        }
 
-       if (t < 0) return 0;
-        if (t > 65535) return 65535;
+       if (t < -32767) return -32767;
+       if (t >  32767) return  32767;
 
-        return t;
+       return t;
 }
 
 /*
- * js_compare() compares two close axis values and decides 
+ * js_compare() compares two close axis values and decides
  * whether they are "same".
  */
 
 static int js_compare(int x, int y, int prec)
 {
-       return (x < y + prec) && (y < x + prec); 
+       return (x < y + prec) && (y < x + prec);
 }
 
 /*
- * js_probe() probes for joysticks 
+ * js_probe() probes for joysticks
  */
 
 inline int js_probe(void)
@@ -193,10 +190,10 @@ inline int js_probe(void)
        } else
        switch (t & JS_AXES) {
                case 0x0c: jsd[0].exist = 0x33; jsd[1].exist = 0x00; break;     /* joystick 0 connected */
-               case 0x03: jsd[0].exist = 0x00; jsd[1].exist = 0xcc; break;     /* joystick 1 connected */
+               case 0x03: jsd[0].exist = 0xcc; jsd[1].exist = 0x00; break;     /* joystick 1 connected */
                case 0x04: jsd[0].exist = 0xfb; jsd[1].exist = 0x00; break;     /* 3-axis joystick connected */
                case 0x00: jsd[0].exist = 0x33; jsd[1].exist = 0xcc; break;     /* joysticks 0 and 1 connected */
-               default:   jsd[0].exist = 0x00; jsd[1].exist = 0x00; return -1; /* no joysticks */      
+               default:   jsd[0].exist = 0x00; jsd[1].exist = 0x00; return -1; /* no joysticks */
        }
 
        js_axes_exist = (jsd[0].exist | jsd[1].exist) & JS_AXES;
@@ -205,7 +202,7 @@ inline int js_probe(void)
        return 0;
 }
 
-/* 
+/*
  * js_do_timer() controls the action by adding entries to the event
  * fifo each time a button changes its state or axis valid time
  * expires.
@@ -223,7 +220,7 @@ static void js_do_timer(unsigned long data)
                        js_mark_time = jiffies;
                        mark_bh(JS_BH);
                }
-       } 
+       }
        else
        if ((jiffies > js_bh_time + JS_BH_MAX_PERIOD) && !js_mark_time) {
                js_mark_time = jiffies;
@@ -257,7 +254,7 @@ static void js_add_event(int i, __u32 time, __u8 type, __u8 number, __u16 value)
 static void js_sync_buff(void)
 {
        int i;
-       
+
        for (i = 0; i < JS_NUM; i++)
        if (jsd[i].list)
        if (jsd[i].bhead != jsd[i].ahead)       {
@@ -266,12 +263,12 @@ static void js_sync_buff(void)
                        curl = jsd[i].list;
                        while (curl) {
                                if (ROT(jsd[i].bhead, curl->tail, jsd[i].ahead) || (curl->tail == jsd[i].bhead)) {
-                                       curl->tail = jsd[i].ahead;                              
+                                       curl->tail = jsd[i].ahead;
                                        curl->startup = jsd[i].exist;
                                }
                                curl = curl->next;
                        }
-                       jsd[i].tail = jsd[i].ahead;             
+                       jsd[i].tail = jsd[i].ahead;
                }
                jsd[i].bhead = jsd[i].ahead;
                wake_up_interruptible(&jsd[i].wait);
@@ -316,8 +313,8 @@ static void js_do_bh(void)
                        cli();                                          /* no interrupts */
                        outb(JS_TRIGGER, JS_PORT);                      /* trigger one-shots */
                        outb(PIT_READ_TIMER, PIT_MODE);                 /* read timer */
-                       t = (t1l = inb(PIT_DATA)) | 
-                           (t1h = inb(PIT_DATA)) << 8; 
+                       t = (t1l = inb(PIT_DATA)) |
+                           (t1h = inb(PIT_DATA)) << 8;
                        restore_flags(flags);
 
                        do {
@@ -328,7 +325,7 @@ static void js_do_bh(void)
                                        joy_state = (joy_state << 8) | jss;
                                        i++;
                                }
-                               
+
                                cli();
                                outb(PIT_READ_TIMER, PIT_MODE);
                                t1l = inb(PIT_DATA);
@@ -341,15 +338,15 @@ static void js_do_bh(void)
  * Process the gathered axis data in joy_state.
  */
 
-                       joy_state ^= ((joy_state >> 8) | 0xff000000L);  /* More magic */
+                       joy_state ^= ((joy_state >> 8) | 0xff000000L);  /* More magic */
 
                        for (; i > 0; i--) {
                                for (j = 0; j < 4; j++)
                                if (joy_state & js_axes_exist & (1 << j)) {
-                                       jsm = js_correct(DELTA_TX(t, t_low, t_high), &js_axis[j].corr);
+                                       jsm = DELTA_TX(t, t_low, t_high);
                                        if (!js_compare(jsm, js_axis[j].value, js_axis[j].corr.prec)) {
                                                if (jsm < js_axis[j].value || !retries)
-                                                        js_axis[j].value = jsm;
+                                                       js_axis[j].value = jsm;
                                                again = 1;
                                        }
                                }
@@ -358,7 +355,7 @@ static void js_do_bh(void)
                                t_high = t_high >> 8;
                        }
 
-               } while (retries++ < JS_RETRIES && again); 
+               } while (retries++ < JS_RETRIES && again);
 
 /*
  * Check if joystick lost.
@@ -390,8 +387,9 @@ static void js_do_bh(void)
                        k = 0;
                        for (j = 0; j < 4; j++)
                        if ((1 << j) & jsd[i].exist) {
-                               if (!js_compare(js_axis[j].value, old_axis[j], js_axis[j].corr.prec))
-                                       js_add_event(i, js_mark_time, JS_EVENT_AXIS, k, js_axis[j].value);
+                               if ((t = js_correct(js_axis[j].value, &js_axis[j].corr)) !=
+                                       js_correct(old_axis[j], &js_axis[j].corr))
+                                       js_add_event(i, js_mark_time, JS_EVENT_AXIS, k, t);
                                k++;
                        }
                }
@@ -448,7 +446,7 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
        unsigned long blocks = count / sizeof(struct js_event);
        unsigned long i = 0, j;
        int t, u = curl->tail;
-        int retval = 0;
+       int retval = 0;
 
 /*
  * Check user data.
@@ -474,13 +472,13 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
 
 
        if ((GOF(curl->tail) == jsd[minor].ahead && !curl->startup && count != sizeof(struct JS_DATA_TYPE))
-            || (curl->startup && !js_bh_time)) {
+               || (curl->startup && !js_bh_time)) {
 
                add_wait_queue(&jsd[minor].wait, &wait);
                current->state = TASK_INTERRUPTIBLE;
 
                while ((GOF(curl->tail) == jsd[minor].ahead && !curl->startup && count != sizeof(struct JS_DATA_TYPE))
-                      || (curl->startup && !js_bh_time)) {
+                       || (curl->startup && !js_bh_time)) {
 
                        if (file->f_flags & O_NONBLOCK) {
                                retval = -EAGAIN;
@@ -501,7 +499,7 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
        }
 
        if (retval) return retval;
-       
+
 /*
  * Do the i/o.
  */
@@ -519,15 +517,15 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
                                if (curl->startup & (1 << j)) {
                                        tmpevent.type = JS_EVENT_AXIS | JS_EVENT_INIT;
                                        tmpevent.number = t;
-                                       tmpevent.value = js_axis[j].value;
-                                       if (copy_to_user(&buff[i], &tmpevent, sizeof(struct js_event)))
+                                       tmpevent.value = js_correct(js_axis[j].value, &js_axis[j].corr);
+                               if (copy_to_user(&buff[i], &tmpevent, sizeof(struct js_event)))
                                                retval = -EFAULT;
                                        if (put_user((__u32)((jiffies - curl->time) * (1000/HZ)), &buff[i].time))
                                                retval = -EFAULT;
                                        curl->startup &= ~(1 << j);
                                        i++;
                                }
-                               t++;    
+                               t++;
                        }
 
 /*
@@ -541,14 +539,14 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
                                        tmpevent.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
                                        tmpevent.number = t;
                                        tmpevent.value = (js_buttons >> j) & 1;
-                                       if (copy_to_user(&buff[i], &tmpevent, sizeof(struct js_event)))
+                                       if (copy_to_user(&buff[i], &tmpevent, sizeof(struct js_event)))
                                                retval = -EFAULT;
                                        if (put_user((__u32)((jiffies - curl->time) * (1000/HZ)), &buff[i].time))
                                                retval = -EFAULT;
                                        curl->startup &= ~(1 << j);
                                        i++;
                                }
-                               t++;    
+                               t++;
                        }
                }
 
@@ -564,7 +562,7 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
                        curl->tail = t;
                        i++;
                }
-       
+
        }
 
        else
@@ -609,7 +607,7 @@ static ssize_t js_read(struct file *file, char *buf, size_t count, loff_t *ppos)
                }
                if (!curl) jsd[minor].tail = t;
        }
-       
+
        return retval ? retval : i*sizeof(struct js_event);
 }
 
@@ -624,19 +622,16 @@ static unsigned int js_poll(struct file *file, poll_table *wait)
        curl = file->private_data;
 
        poll_wait(file, &jsd[minor].wait, wait);
-       if (GOF(curl->tail) != jsd[minor].ahead) 
+       if (GOF(curl->tail) != jsd[minor].ahead)
                return POLLIN | POLLRDNORM;
-        return 0;
+       return 0;
 }
 
 /*
  * js_ioctl handles misc ioctl calls.
  */
 
-static int js_ioctl(struct inode *inode,
-                    struct file *file,
-                    unsigned int cmd,
-                    unsigned long arg)
+static int js_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
 {
        unsigned int minor = MINOR(inode->i_rdev);
        int i, j;
@@ -672,7 +667,7 @@ static int js_ioctl(struct inode *inode,
                j = 0;
                for (i = 0; i < 4; i++)
                if ((1 << i) & jsd[minor].exist) {
-                       if (copy_to_user((void *) arg + j * sizeof(struct js_corr), &js_axis[i].corr, 
+                       if (copy_to_user((void *) arg + j * sizeof(struct js_corr), &js_axis[i].corr,
                                sizeof(struct js_corr))) return -EFAULT;
                        j++;
                }
@@ -680,7 +675,7 @@ static int js_ioctl(struct inode *inode,
        default:
                return -EINVAL;
        }
-       
+
        return 0;
 }
 
@@ -701,14 +696,14 @@ static int js_open(struct inode *inode, struct file *file)
                return -ENODEV;
        if (!jsd[minor].exist) {
                js_probe();
-               if (jsd[minor].exist) printk(KERN_INFO "js%d: %d-axis joystick at %#x\n", 
-                       minor,  count_bits(jsd[minor].exist & JS_AXES), JS_PORT);
+               if (jsd[minor].exist) printk(KERN_INFO "js%d: %d-axis %d-button joystick at %#x\n",
+                       minor, count_bits(jsd[minor].exist & JS_AXES), count_bits(jsd[minor].exist & JS_BUTTONS), JS_PORT);
                else return -ENODEV;
        }
 
        MOD_INC_USE_COUNT;
 
-       if (!jsd[0].list && !jsd[1].list) { 
+       if (!jsd[0].list && !jsd[1].list) {
                js_timer.expires = jiffies + JS_TIMER_PERIOD;
                add_timer(&js_timer);
        }
@@ -789,7 +784,7 @@ __initfunc(void js_setup(char *str, int *ints))
 
 {
        js[0] = ((ints[0] > 0) ? ints[1] : 0 );
-        js[1] = ((ints[0] > 1) ? ints[2] : 0 );
+       js[1] = ((ints[0] > 1) ? ints[2] : 0 );
 }
 #endif
 
@@ -799,7 +794,7 @@ __initfunc(void js_setup(char *str, int *ints))
  */
 
 #ifdef MODULE
-int init_module(void) 
+int init_module(void)
 #else
 __initfunc(int js_init(void))
 #endif
@@ -823,7 +818,7 @@ __initfunc(int js_init(void))
 
        for (i = 0; i < JS_NUM; i++) {
                if (jsd[i].exist) printk(KERN_INFO "js%d: %d-axis %d-button joystick at %#x\n",
-                        i,  count_bits(jsd[i].exist & JS_AXES), count_bits(jsd[i].exist & JS_AXES), JS_PORT);
+                       i, count_bits(jsd[i].exist & JS_AXES), count_bits(jsd[i].exist & JS_BUTTONS), JS_PORT);
                jsd[i].ahead = jsd[i].bhead = 0;
                jsd[i].tail = JS_BUFF_SIZE - 1;
                jsd[i].list = NULL;
@@ -832,7 +827,7 @@ __initfunc(int js_init(void))
        }
 
        for (i = 0; i < 4; i++) {
-               js_axis[i].corr.type = JS_CORR_NONE; 
+               js_axis[i].corr.type = JS_CORR_NONE;
                js_axis[i].corr.prec = JS_DEF_PREC;
        }
 
@@ -841,7 +836,7 @@ __initfunc(int js_init(void))
        enable_bh(JS_BH);
        init_timer(&js_timer);
        js_timer.function = js_do_timer;
-               
+
        return 0;
 }
 
index 3ddffff0be2a33e056d0cb96378e71aa8add9c84..23147e7a5b11c913c7f53e1195ec4701dafacb33 100644 (file)
@@ -32,9 +32,6 @@ void soundcard_init(void);
 #ifdef CONFIG_ISDN
 int isdn_init(void);
 #endif
-#ifdef CONFIG_PCWATCHDOG
-int pcwatchdog_init(void);
-#endif
 #ifdef CONFIG_VIDEO_DEV
 extern int videodev_init(void);
 #endif
index 751a84d7bdb49c9bd66937bfc3742cae8749fd13..4cd1831f7e45f2d38340e0b702c1e4a4b34b013d 100644 (file)
@@ -81,9 +81,7 @@ extern int dsp56k_init(void);
 extern int nvram_init(void);
 extern int radio_init(void);
 extern void hfmodem_init(void);
-#ifdef CONFIG_PC110_PAD
 extern int pc110pad_init(void);
-#endif
 
 #ifdef CONFIG_PROC_FS
 static int misc_read_proc(char *buf, char **start, off_t offset,
index 52597561e96466998c97e41fee9cf0aa28172d7a..5a66741f4f8ffd5809c52b52f208e1e80e2b9b69 100644 (file)
@@ -9,9 +9,10 @@ if [ ! "$CONFIG_FC4" = "n" ]; then
   comment 'FC4 drivers'
   tristate 'Sun SOC/Sbus' CONFIG_FC4_SOC m
   comment 'FC4 targets'
-  dep_tristate 'SparcSTORAGE Array 100 and 200 series' CONFIG_SCSI_PLUTO "$CONFIG_SCSI"
+  dep_tristate 'SparcSTORAGE Array 100 and 200 series' CONFIG_SCSI_PLUTO $CONFIG_SCSI
 else
   define_bool CONFIG_FC4_SOC n
   define_bool CONFIG_SCSI_PLUTO n
 fi
 endmenu
+
index 1db437b3fa70cbc0d61065541fabfb1ca883c1bc..e3d66038ca52dbb94bdc4ad3a4c26fb20db3e63f 100644 (file)
@@ -304,14 +304,17 @@ update_out:
 static void soc_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
        u32 cmd;
+       unsigned long flags;
        register struct soc *s = (struct soc *)dev_id;
 
+       spin_lock_irqsave(&io_request_lock, flags);
        cmd = s->regs->cmd;
        for (; (cmd = SOC_INTR (s, cmd)); cmd = s->regs->cmd) {
                if (cmd & SOC_CMD_RSP_Q1) soc_unsolicited (s);
                if (cmd & SOC_CMD_RSP_Q0) soc_solicited (s);
                if (cmd & SOC_CMD_REQ_QALL) soc_request (s, cmd);
        }
+       spin_unlock_irqrestore(&io_request_lock, flags);
 }
 
 #define TOKEN(proto, port, token) (((proto)<<12)|(token)|(port))
index 46b460370803d1f952009e339c6c5d2d917bf2b7..3dd80173c590a94a8e82ea6e8309df274a816cf8 100644 (file)
@@ -1764,6 +1764,8 @@ isdn_net_init(struct device *ndev)
        ndev->type = ARPHRD_ETHER;
        ndev->addr_len = ETH_ALEN;
 
+       ndev->tx_queue_len = 10; /* for clients without MPPP 5 is better.  */
+
        for (i = 0; i < ETH_ALEN; i++)
                ndev->broadcast[i] = 0xff;
 
index 761e3660eede0ff6003880fc32ef1b0daa6d850e..278db25278fd21a3a9cddd3a728c85784f3a6d4a 100644 (file)
@@ -45,7 +45,6 @@
 static const char *version =
     "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
index 07ebd6b1af4762d92c29440d22d9bb6319910e52..1366ff75d3595c74ae306c6ca69727d9f92741dd 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef _8390_h
 #define _8390_h
 
+#include <linux/config.h>
 #include <linux/if_ether.h>
 #include <linux/ioport.h>
 #include <linux/skbuff.h>
index f4b1e0d0b805d8012be001893567d7b8b16eef13..c0616020131993c2a5f2eb70ff8c1c936c6f1f15 100644 (file)
@@ -14,7 +14,6 @@
  * The APC DMA controller support unfortunately is not documented. Thanks, Sun
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
index 2aad6a7f9ca030ae32a2cca46cc6b1026f00f7ee..e8e12da6fc9f394a8f22bbb7d274a008def86028 100644 (file)
@@ -1891,7 +1891,7 @@ NCR53c8xx_run_tests (struct Scsi_Host *host) {
        printk ("scsi%d : test 1", host->host_no);
        NCR53c7x0_write32 (DSP_REG, start);
        printk (" started\n");
-       sti();
+       restore_flags(flags);
 
        /* 
         * This is currently a .5 second timeout, since (in theory) no slow 
@@ -1983,7 +1983,7 @@ NCR53c8xx_run_tests (struct Scsi_Host *host) {
            hostdata->state = STATE_RUNNING;
            NCR53c7x0_write32 (DSA_REG, virt_to_bus(dsa));
            NCR53c7x0_write32 (DSP_REG, start);
-           sti();
+           restore_flags(flags);
 
            timeout = jiffies + 5 * HZ; /* arbitrary */
            while ((hostdata->test_completed == -1) && jiffies < timeout)
@@ -5737,7 +5737,7 @@ NCR53c7xx_reset (Scsi_Cmnd *cmd, unsigned int reset_flags) {
        disable(host);
     else if (hostdata->resets != -1)
        --hostdata->resets;
-    sti();
+    restore_flags(flags);
     for (; nuke_list; nuke_list = tmp) {
        tmp = (Scsi_Cmnd *) nuke_list->SCp.buffer;
        nuke_list->result = DID_RESET << 16;
@@ -6193,7 +6193,7 @@ return_outstanding_commands (struct Scsi_Host *host, int free, int issue) {
            printk ("scsi%d : loop detected in running list!\n", host->host_no);
            break;
        } else {
-           printk ("The sti() implicit in a printk() prevents hangs\n");
+           printk ("Duh? Bad things happening in the NCR driver\n");
            break;
        }
 
index be68e101d3eb12c798323b50b8d53ed21ed243e5..ba0e93ca71dfac3c578ac87135a1fe833547ed84 100644 (file)
@@ -1620,7 +1620,7 @@ NCR53c7xx_run_tests (struct Scsi_Host *host) {
            NCR53c7x0_write8 (DCNTL_REG, hostdata->saved_dcntl | DCNTL_SSM |
                                                DCNTL_STD);
        printk (" started\n");
-       sti();
+       restore_flags(flags);
 
        /* 
         * This is currently a .5 second timeout, since (in theory) no slow 
@@ -1715,7 +1715,7 @@ NCR53c7xx_run_tests (struct Scsi_Host *host) {
            if (hostdata->options & OPTION_DEBUG_TRACE)
                NCR53c7x0_write8 (DCNTL_REG, hostdata->saved_dcntl |
                                DCNTL_SSM | DCNTL_STD);
-           sti();
+           restore_flags(flags);
 
            timeout = jiffies + 5 * HZ; /* arbitrary */
            while ((hostdata->test_completed == -1) && jiffies < timeout)
@@ -5372,7 +5372,7 @@ NCR53c7xx_reset (Scsi_Cmnd *cmd, unsigned int reset_flags) {
        disable(host);
     else if (hostdata->resets != -1)
        --hostdata->resets;
-    sti();
+    restore_flags(flags);
     for (; nuke_list; nuke_list = tmp) {
        tmp = (Scsi_Cmnd *) nuke_list->SCp.buffer;
        nuke_list->result = DID_RESET << 16;
@@ -5828,7 +5828,7 @@ return_outstanding_commands (struct Scsi_Host *host, int free, int issue) {
            printk ("scsi%d : loop detected in running list!\n", host->host_no);
            break;
        } else {
-           printk ("The sti() implicit in a printk() prevents hangs\n");
+           printk ("Duh? Bad things happening in the NCR driver\n");
            break;
        }
 
index 2f5fb197d868c9264eb746492cf573c3d9a21e9d..61f78a8317a1718d013cc81d31d06c40399b7d6e 100644 (file)
 #include "sd.h"
 
 /* AM53/79C974 (PCscsi) driver release 0.5
- *
+
  * The architecture and much of the code of this device
  * driver was originally developed by Drew Eckhardt for
  * the NCR5380. The following copyrights apply:
  *  For the architecture and all pieces of code which can also be found 
  *    in the NCR5380 device driver:
  *   Copyright 1993, Drew Eckhardt
- *     Visionary Computing 
- *     (Unix and Linux consulting and custom programming)
- *     drew@colorado.edu
- *     +1 (303) 666-5836
+ *      Visionary Computing 
+ *      (Unix and Linux consulting and custom programming)
+ *      drew@colorado.edu
+ *      +1 (303) 666-5836
  *
  *  The AM53C974_nobios_detect code was originally developed by
  *   Robin Cutshaw (robin@xfree86.org) and is used here in a 
  */
 
 #ifdef AM53C974_DEBUG
- #define DEB(x) x
- #ifdef AM53C974_DEBUG_KEYWAIT
-   #define KEYWAIT() AM53C974_keywait()
-  #else
-   #define KEYWAIT()
-  #endif
- #ifdef AM53C974_DEBUG_INIT
-   #define DEB_INIT(x) x
-  #else
-   #define DEB_INIT(x)
-  #endif
- #ifdef AM53C974_DEBUG_MSG
-   #define DEB_MSG(x) x
-  #else
-   #define DEB_MSG(x)
-  #endif
- #ifdef AM53C974_DEB_RESEL
-   #define DEB_RESEL(x) x
-  #else
-   #define DEB_RESEL(x)
-  #endif
- #ifdef AM53C974_DEBUG_QUEUE
-  #define DEB_QUEUE(x) x
-  #define LIST(x,y) {printk("LINE:%d   Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); }
-  #define REMOVE(w,x,y,z) {printk("LINE:%d   Removing: %p->%p  %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); }
- #else
-  #define DEB_QUEUE(x)
-  #define LIST(x,y)
-  #define REMOVE(w,x,y,z)
- #endif
- #ifdef AM53C974_DEBUG_INFO
-   #define DEB_INFO(x) x
-  #else
-   #define DEB_INFO(x)
-  #endif
- #ifdef AM53C974_DEBUG_LINKED
-   #define DEB_LINKED(x) x
-  #else
-   #define DEB_LINKED(x)
-  #endif
- #ifdef AM53C974_DEBUG_INTR
-   #define DEB_INTR(x) x
-  #else
-   #define DEB_INTR(x)
-  #endif
+#define DEB(x) x
+#ifdef AM53C974_DEBUG_KEYWAIT
+#define KEYWAIT() AM53C974_keywait()
+#else
+#define KEYWAIT()
+#endif
+#ifdef AM53C974_DEBUG_INIT
+#define DEB_INIT(x) x
+#else
+#define DEB_INIT(x)
+#endif
+#ifdef AM53C974_DEBUG_MSG
+#define DEB_MSG(x) x
 #else
- #define DEB_INIT(x)
- #define DEB(x)
- #define DEB_QUEUE(x)
- #define LIST(x,y)
- #define REMOVE(w,x,y,z)
- #define DEB_INFO(x)
- #define DEB_LINKED(x)
- #define DEB_INTR(x)
- #define DEB_MSG(x)
- #define DEB_RESEL(x)
- #define KEYWAIT()
+#define DEB_MSG(x)
+#endif
+#ifdef AM53C974_DEB_RESEL
+#define DEB_RESEL(x) x
+#else
+#define DEB_RESEL(x)
+#endif
+#ifdef AM53C974_DEBUG_QUEUE
+#define DEB_QUEUE(x) x
+#define LIST(x,y) {printk("LINE:%d   Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); }
+#define REMOVE(w,x,y,z) {printk("LINE:%d   Removing: %p->%p  %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); }
+#else
+#define DEB_QUEUE(x)
+#define LIST(x,y)
+#define REMOVE(w,x,y,z)
+#endif
+#ifdef AM53C974_DEBUG_INFO
+#define DEB_INFO(x) x
+#else
+#define DEB_INFO(x)
+#endif
+#ifdef AM53C974_DEBUG_LINKED
+#define DEB_LINKED(x) x
+#else
+#define DEB_LINKED(x)
+#endif
+#ifdef AM53C974_DEBUG_INTR
+#define DEB_INTR(x) x
+#else
+#define DEB_INTR(x)
+#endif
+#else
+#define DEB_INIT(x)
+#define DEB(x)
+#define DEB_QUEUE(x)
+#define LIST(x,y)
+#define REMOVE(w,x,y,z)
+#define DEB_INFO(x)
+#define DEB_LINKED(x)
+#define DEB_INTR(x)
+#define DEB_MSG(x)
+#define DEB_RESEL(x)
+#define KEYWAIT()
+#endif
+#ifdef AM53C974_DEBUG_ABORT
+#define DEB_ABORT(x) x
+#else
+#define DEB_ABORT(x)
 #endif
- #ifdef AM53C974_DEBUG_ABORT
-   #define DEB_ABORT(x) x
-  #else
-   #define DEB_ABORT(x)
-  #endif
 
 #ifdef VERBOSE_AM53C974_DEBUG
 #define VDEB(x) x
 * Sync. negotiation is disabled by default and will be enabled for those targets which *
 * are specified in the LILO override                                                   *
 ****************************************************************************************/
-#define DEFAULT_SYNC_NEGOTIATION_ENABLED 0 /* 0 or 1 */
-#define DEFAULT_RATE                    5 /* MHz, min: 3; max: 10 */
-#define DEFAULT_SYNC_OFFSET             0 /* bytes, min: 0; max: 15; use 0 for async. mode */
+#define DEFAULT_SYNC_NEGOTIATION_ENABLED 0     /* 0 or 1 */
+#define DEFAULT_RATE                    5      /* MHz, min: 3; max: 10 */
+#define DEFAULT_SYNC_OFFSET             0      /* bytes, min: 0; max: 15; use 0 for async. mode */
 
 /***************************************************************************************
 * If defined, don't allow targets to disconnect during commands.  This will reduce     *
 /* #define AM53C974_OPTION_DEBUG_PROBE_ONLY */
 
 /* special options/constants */
-#define DEF_CLK                 40   /* chip clock freq. in MHz */
-#define MIN_PERIOD               4   /* for negotiation: min. number of clocks per cycle */
-#define MAX_PERIOD              13   /* for negotiation: max. number of clocks per cycle */
-#define MAX_OFFSET              15   /* for negotiation: max. offset (0=async) */
-
-#define DEF_SCSI_TIMEOUT        245  /* STIMREG value, 40 Mhz */
-#define DEF_STP                 8    /* STPREG value assuming 5.0 MB/sec, FASTCLK, FASTSCSI */
-#define DEF_SOF_RAD             0    /* REQ/ACK deassertion delay */
-#define DEF_SOF_RAA             0    /* REQ/ACK assertion delay */
-#define DEF_ETM                 0    /* CNTLREG1, ext. timing mode */
-#define DEF_PERE                1    /* CNTLREG1, parity error reporting */
-#define DEF_CLKF                0    /* CLKFREG,  0=40 Mhz */
-#define DEF_ENF                 1    /* CNTLREG2, enable features */
-#define DEF_ADIDCHK             0    /* CNTLREG3, additional ID check */
-#define DEF_FASTSCSI            1    /* CNTLREG3, fast SCSI */
-#define DEF_FASTCLK             1    /* CNTLREG3, fast clocking, 5 MB/sec at 40MHz chip clk */
-#define DEF_GLITCH              1    /* CNTLREG4, glitch eater, 0=12ns, 1=35ns, 2=25ns, 3=off */
-#define DEF_PWD                 0    /* CNTLREG4, reduced power feature */
-#define DEF_RAE                 0    /* CNTLREG4, RAE active negation on REQ, ACK only */
-#define DEF_RADE                1    /* 1CNTLREG4, active negation on REQ, ACK and data */
+#define DEF_CLK                 40     /* chip clock freq. in MHz */
+#define MIN_PERIOD               4     /* for negotiation: min. number of clocks per cycle */
+#define MAX_PERIOD              13     /* for negotiation: max. number of clocks per cycle */
+#define MAX_OFFSET              15     /* for negotiation: max. offset (0=async) */
+
+#define DEF_SCSI_TIMEOUT        245    /* STIMREG value, 40 Mhz */
+#define DEF_STP                 8      /* STPREG value assuming 5.0 MB/sec, FASTCLK, FASTSCSI */
+#define DEF_SOF_RAD             0      /* REQ/ACK deassertion delay */
+#define DEF_SOF_RAA             0      /* REQ/ACK assertion delay */
+#define DEF_ETM                 0      /* CNTLREG1, ext. timing mode */
+#define DEF_PERE                1      /* CNTLREG1, parity error reporting */
+#define DEF_CLKF                0      /* CLKFREG,  0=40 Mhz */
+#define DEF_ENF                 1      /* CNTLREG2, enable features */
+#define DEF_ADIDCHK             0      /* CNTLREG3, additional ID check */
+#define DEF_FASTSCSI            1      /* CNTLREG3, fast SCSI */
+#define DEF_FASTCLK             1      /* CNTLREG3, fast clocking, 5 MB/sec at 40MHz chip clk */
+#define DEF_GLITCH              1      /* CNTLREG4, glitch eater, 0=12ns, 1=35ns, 2=25ns, 3=off */
+#define DEF_PWD                 0      /* CNTLREG4, reduced power feature */
+#define DEF_RAE                 0      /* CNTLREG4, RAE active negation on REQ, ACK only */
+#define DEF_RADE                1      /* 1CNTLREG4, active negation on REQ, ACK and data */
 
 /*** SCSI block ***/
-#define CTCLREG                        0x00    /* r    current transf. count, low byte    */
-#define CTCMREG                        0x04    /* r    current transf. count, middle byte */
-#define CTCHREG                        0x38    /* r    current transf. count, high byte   */
-#define STCLREG                        0x00    /* w    start transf. count, low byte      */
-#define STCMREG                        0x04    /* w    start transf. count, middle byte   */
-#define STCHREG                        0x38    /* w    start transf. count, high byte     */
-#define FFREG                  0x08    /* rw   SCSI FIFO reg.                     */
-#define STIMREG                        0x14    /* w    SCSI timeout reg.                  */
-
-#define SDIDREG                        0x10    /* w    SCSI destination ID reg.           */
-#define SDIREG_MASK            0x07    /* mask                                    */
-
-#define STPREG                 0x18    /* w    synchronous transf. period reg.    */
-#define STPREG_STP             0x1F    /* synchr. transfer period                 */
-
-#define CLKFREG                        0x24    /* w    clock factor reg.                  */
-#define CLKFREG_MASK           0x07    /* mask                                    */
-
-#define CMDREG                 0x0C    /* rw   SCSI command reg.                  */
-#define CMDREG_DMA             0x80    /* set DMA mode (set together with opcodes below) */
-#define CMDREG_IT              0x10    /* information transfer                    */
-#define CMDREG_ICCS            0x11    /* initiator command complete steps        */
-#define CMDREG_MA              0x12    /* message accepted                        */
-#define CMDREG_TPB             0x98    /* transfer pad bytes, DMA mode only       */
-#define CMDREG_SATN            0x1A    /* set ATN                                 */
-#define CMDREG_RATN            0x1B    /* reset ATN                               */
-#define CMDREG_SOAS            0x41    /* select without ATN steps                */
-#define CMDREG_SAS             0x42    /* select with ATN steps (1 msg byte)      */
-#define CMDREG_SASS            0x43    /* select with ATN and stop steps          */
-#define CMDREG_ESR             0x44    /* enable selection/reselection            */
-#define CMDREG_DSR             0x45    /* disable selection/reselection           */
+#define CTCLREG                        0x00    /* r      current transf. count, low byte    */
+#define CTCMREG                        0x04    /* r      current transf. count, middle byte */
+#define CTCHREG                        0x38    /* r      current transf. count, high byte   */
+#define STCLREG                        0x00    /* w      start transf. count, low byte      */
+#define STCMREG                        0x04    /* w      start transf. count, middle byte   */
+#define STCHREG                        0x38    /* w      start transf. count, high byte     */
+#define FFREG                  0x08    /* rw     SCSI FIFO reg.                     */
+#define STIMREG                        0x14    /* w      SCSI timeout reg.                  */
+
+#define SDIDREG                        0x10    /* w      SCSI destination ID reg.           */
+#define SDIREG_MASK            0x07    /* mask                                      */
+
+#define STPREG                 0x18    /* w      synchronous transf. period reg.    */
+#define STPREG_STP             0x1F    /* synchr. transfer period                   */
+
+#define CLKFREG                        0x24    /* w      clock factor reg.                  */
+#define CLKFREG_MASK           0x07    /* mask                                      */
+
+#define CMDREG                 0x0C    /* rw     SCSI command reg.                  */
+#define CMDREG_DMA             0x80    /* set DMA mode (set together with opcodes below) */
+#define CMDREG_IT              0x10    /* information transfer              */
+#define CMDREG_ICCS            0x11    /* initiator command complete steps          */
+#define CMDREG_MA              0x12    /* message accepted                          */
+#define CMDREG_TPB             0x98    /* transfer pad bytes, DMA mode only         */
+#define CMDREG_SATN            0x1A    /* set ATN                                   */
+#define CMDREG_RATN            0x1B    /* reset ATN                                 */
+#define CMDREG_SOAS            0x41    /* select without ATN steps                  */
+#define CMDREG_SAS             0x42    /* select with ATN steps (1 msg byte)        */
+#define CMDREG_SASS            0x43    /* select with ATN and stop steps            */
+#define CMDREG_ESR             0x44    /* enable selection/reselection      */
+#define CMDREG_DSR             0x45    /* disable selection/reselection     */
 #define CMDREG_SA3S            0x46    /* select with ATN 3 steps  (3 msg bytes)  */
-#define CMDREG_NOP             0x00    /* no operation                            */
-#define CMDREG_CFIFO           0x01    /* clear FIFO                              */
-#define CMDREG_RDEV            0x02    /* reset device                            */
-#define CMDREG_RBUS            0x03    /* reset SCSI bus                          */
+#define CMDREG_NOP             0x00    /* no operation                      */
+#define CMDREG_CFIFO           0x01    /* clear FIFO                                */
+#define CMDREG_RDEV            0x02    /* reset device                      */
+#define CMDREG_RBUS            0x03    /* reset SCSI bus                            */
 
-#define STATREG                        0x10    /* r    SCSI status reg.                   */
-#define STATREG_INT            0x80    /* SCSI interrupt condition detected       */
+#define STATREG                        0x10    /* r      SCSI status reg.                   */
+#define STATREG_INT            0x80    /* SCSI interrupt condition detected         */
 #define STATREG_IOE            0x40    /* SCSI illegal operation error detected   */
-#define STATREG_PE             0x20    /* SCSI parity error detected              */
-#define STATREG_CTZ            0x10    /* CTC reg decremented to zero             */
-#define STATREG_MSG            0x04    /* SCSI MSG phase (latched?)               */
-#define STATREG_CD             0x02    /* SCSI C/D phase (latched?)               */
-#define STATREG_IO             0x01    /* SCSI I/O phase (latched?)               */
-#define STATREG_PHASE           0x07    /* SCSI phase mask                        */
-
-#define INSTREG                        0x14    /* r    interrupt status reg.              */
-#define INSTREG_SRST           0x80    /* SCSI reset detected                     */
-#define INSTREG_ICMD           0x40    /* SCSI invalid command detected           */
-#define INSTREG_DIS            0x20    /* target disconnected or sel/resel timeout*/
+#define STATREG_PE             0x20    /* SCSI parity error detected                */
+#define STATREG_CTZ            0x10    /* CTC reg decremented to zero               */
+#define STATREG_MSG            0x04    /* SCSI MSG phase (latched?)                 */
+#define STATREG_CD             0x02    /* SCSI C/D phase (latched?)                 */
+#define STATREG_IO             0x01    /* SCSI I/O phase (latched?)                 */
+#define STATREG_PHASE           0x07   /* SCSI phase mask                           */
+
+#define INSTREG                        0x14    /* r      interrupt status reg.              */
+#define INSTREG_SRST           0x80    /* SCSI reset detected                       */
+#define INSTREG_ICMD           0x40    /* SCSI invalid command detected     */
+#define INSTREG_DIS            0x20    /* target disconnected or sel/resel timeout */
 #define INSTREG_SR             0x10    /* device on bus has service request       */
-#define INSTREG_SO             0x08    /* successful operation                    */
-#define INSTREG_RESEL          0x04    /* device reselected as initiator          */
-
-#define ISREG                  0x18    /* r    internal state reg.                */
-#define ISREG_SOF              0x08    /* synchronous offset flag (act. low)      */
-#define ISREG_IS               0x07    /* status of intermediate op.              */
-#define ISREG_OK_NO_STOP        0x04    /* selection successful                    */
-#define ISREG_OK_STOP           0x01    /* selection successful                    */
-
-#define CFIREG                 0x1C    /* r    current FIFO/internal state reg.   */
-#define CFIREG_IS              0xE0    /* status of intermediate op.              */
-#define CFIREG_CF              0x1F    /* number of bytes in SCSI FIFO            */
-
-#define SOFREG                 0x1C    /* w    synchr. offset reg.                */
-#define SOFREG_RAD             0xC0    /* REQ/ACK deassertion delay (sync.)       */
-#define SOFREG_RAA             0x30    /* REQ/ACK assertion delay (sync.)         */
-#define SOFREG_SO              0x0F    /* synch. offset (sync.)                   */
-
-#define CNTLREG1               0x20    /* rw   control register one               */
-#define CNTLREG1_ETM           0x80    /* set extended timing mode                */
-#define CNTLREG1_DISR          0x40    /* disable interrupt on SCSI reset         */
-#define CNTLREG1_PERE          0x10    /* enable parity error reporting           */
-#define CNTLREG1_SID           0x07    /* host adapter SCSI ID                    */
-
-#define CNTLREG2               0x2C    /* rw   control register two               */
-#define CNTLREG2_ENF           0x40    /* enable features                         */
-
-#define CNTLREG3               0x30    /* rw   control register three             */
-#define CNTLREG3_ADIDCHK       0x80    /* additional ID check                     */
-#define CNTLREG3_FASTSCSI      0x10    /* fast SCSI                               */
-#define CNTLREG3_FASTCLK       0x08    /* fast SCSI clocking                      */
-
-#define CNTLREG4               0x34    /* rw   control register four              */
-#define CNTLREG4_GLITCH                0xC0    /* glitch eater                            */
-#define CNTLREG4_PWD           0x20    /* reduced power feature                   */
-#define CNTLREG4_RAE           0x08    /* write only, active negot. ctrl.         */
-#define CNTLREG4_RADE          0x04    /* active negot. ctrl.                     */
-#define CNTLREG4_RES           0x10    /* reserved bit, must be 1                 */
+#define INSTREG_SO             0x08    /* successful operation                      */
+#define INSTREG_RESEL          0x04    /* device reselected as initiator    */
+
+#define ISREG                  0x18    /* r      internal state reg.                */
+#define ISREG_SOF              0x08    /* synchronous offset flag (act. low)        */
+#define ISREG_IS               0x07    /* status of intermediate op.                */
+#define ISREG_OK_NO_STOP        0x04   /* selection successful                    */
+#define ISREG_OK_STOP           0x01   /* selection successful                    */
+
+#define CFIREG                 0x1C    /* r      current FIFO/internal state reg.   */
+#define CFIREG_IS              0xE0    /* status of intermediate op.                */
+#define CFIREG_CF              0x1F    /* number of bytes in SCSI FIFO              */
+
+#define SOFREG                 0x1C    /* w      synchr. offset reg.                */
+#define SOFREG_RAD             0xC0    /* REQ/ACK deassertion delay (sync.)         */
+#define SOFREG_RAA             0x30    /* REQ/ACK assertion delay (sync.)           */
+#define SOFREG_SO              0x0F    /* synch. offset (sync.)             */
+
+#define CNTLREG1               0x20    /* rw     control register one               */
+#define CNTLREG1_ETM           0x80    /* set extended timing mode                  */
+#define CNTLREG1_DISR          0x40    /* disable interrupt on SCSI reset           */
+#define CNTLREG1_PERE          0x10    /* enable parity error reporting     */
+#define CNTLREG1_SID           0x07    /* host adapter SCSI ID                      */
+
+#define CNTLREG2               0x2C    /* rw     control register two               */
+#define CNTLREG2_ENF           0x40    /* enable features                           */
+
+#define CNTLREG3               0x30    /* rw     control register three             */
+#define CNTLREG3_ADIDCHK       0x80    /* additional ID check                       */
+#define CNTLREG3_FASTSCSI      0x10    /* fast SCSI                                 */
+#define CNTLREG3_FASTCLK       0x08    /* fast SCSI clocking                        */
+
+#define CNTLREG4               0x34    /* rw     control register four              */
+#define CNTLREG4_GLITCH                0xC0    /* glitch eater                              */
+#define CNTLREG4_PWD           0x20    /* reduced power feature             */
+#define CNTLREG4_RAE           0x08    /* write only, active negot. ctrl.           */
+#define CNTLREG4_RADE          0x04    /* active negot. ctrl.                       */
+#define CNTLREG4_RES           0x10    /* reserved bit, must be 1                   */
 
 /*** DMA block ***/
-#define DMACMD                 0x40    /* rw   command                            */
+#define DMACMD                 0x40    /* rw     command                            */
 #define DMACMD_DIR             0x80    /* transfer direction (1=read from device) */
-#define DMACMD_INTE_D          0x40    /* DMA transfer interrupt enable           */
-#define DMACMD_INTE_P          0x20    /* page transfer interrupt enable          */
-#define DMACMD_MDL             0x10    /* map to memory descriptor list           */
-#define DMACMD_DIAG            0x04    /* diagnostics, set to 0                   */
-#define DMACMD_IDLE            0x00    /* idle cmd                                */
-#define DMACMD_BLAST           0x01    /* flush FIFO to memory                    */
-#define DMACMD_ABORT           0x02    /* terminate DMA                           */
-#define DMACMD_START           0x03    /* start DMA                               */
-
-#define DMASTATUS              0x54    /* r    status register                    */
-#define DMASTATUS_BCMPLT       0x20    /* BLAST complete                          */
-#define DMASTATUS_SCSIINT      0x10    /* SCSI interrupt pending                  */
-#define DMASTATUS_DONE         0x08    /* DMA transfer terminated                 */
-#define DMASTATUS_ABORT                0x04    /* DMA transfer aborted                    */
-#define DMASTATUS_ERROR                0x02    /* DMA transfer error                      */
-#define DMASTATUS_PWDN         0x02    /* power down indicator                    */
-
-#define DMASTC                 0x44    /* rw   starting transfer count            */
-#define DMASPA                 0x48    /* rw   starting physical address          */
-#define DMAWBC                 0x4C    /* r    working byte counter               */
-#define DMAWAC                 0x50    /* r    working address counter            */
-#define DMASMDLA               0x58    /* rw   starting MDL address               */
-#define DMAWMAC                        0x5C    /* r    working MDL counter                */
+#define DMACMD_INTE_D          0x40    /* DMA transfer interrupt enable     */
+#define DMACMD_INTE_P          0x20    /* page transfer interrupt enable            */
+#define DMACMD_MDL             0x10    /* map to memory descriptor list     */
+#define DMACMD_DIAG            0x04    /* diagnostics, set to 0             */
+#define DMACMD_IDLE            0x00    /* idle cmd                                  */
+#define DMACMD_BLAST           0x01    /* flush FIFO to memory                      */
+#define DMACMD_ABORT           0x02    /* terminate DMA                     */
+#define DMACMD_START           0x03    /* start DMA                                 */
+
+#define DMASTATUS              0x54    /* r      status register                    */
+#define DMASTATUS_BCMPLT       0x20    /* BLAST complete                    */
+#define DMASTATUS_SCSIINT      0x10    /* SCSI interrupt pending            */
+#define DMASTATUS_DONE         0x08    /* DMA transfer terminated                   */
+#define DMASTATUS_ABORT                0x04    /* DMA transfer aborted                      */
+#define DMASTATUS_ERROR                0x02    /* DMA transfer error                        */
+#define DMASTATUS_PWDN         0x02    /* power down indicator                      */
+
+#define DMASTC                 0x44    /* rw     starting transfer count            */
+#define DMASPA                 0x48    /* rw     starting physical address          */
+#define DMAWBC                 0x4C    /* r      working byte counter               */
+#define DMAWAC                 0x50    /* r      working address counter            */
+#define DMASMDLA               0x58    /* rw     starting MDL address               */
+#define DMAWMAC                        0x5C    /* r      working MDL counter                */
 
 /*** SCSI phases ***/
 #define PHASE_MSGIN             0x07
 
 #define AM53C974_poll_int()             { do { statreg = AM53C974_read_8(STATREG); } \
                                              while (!(statreg & STATREG_INT)) ; \
-                                          AM53C974_read_8(INSTREG) ; } /* clear int */
+                                          AM53C974_read_8(INSTREG) ; } /* clear int */
 #define AM53C974_cfifo()               (AM53C974_read_8(CFIREG) & CFIREG_CF)
 
 /* These are "special" values for the tag parameter passed to AM53C974_select. */
-#define TAG_NEXT       -1      /* Use next free tag */
+#define TAG_NEXT       -1      /* Use next free tag */
 #define TAG_NONE       -2      /* Establish I_T_L nexus instead of I_T_L_Q
-                                * even on SCSI-II devices */
+                                  * even on SCSI-II devices */
 
 /************ LILO overrides *************/
 typedef struct _override_t {
-    int host_scsi_id;                  /* SCSI id of the bus controller */
-    int target_scsi_id;                 /* SCSI id of target */
-    int max_rate;                      /* max. transfer rate */
-    int max_offset;                    /* max. sync. offset, 0 = asynchronous */
-    } override_t;
+       int host_scsi_id;       /* SCSI id of the bus controller */
+       int target_scsi_id;     /* SCSI id of target */
+       int max_rate;           /* max. transfer rate */
+       int max_offset;         /* max. sync. offset, 0 = asynchronous */
+} override_t;
 
 
 #ifdef AM53C974_DEBUG
 static void AM53C974_print_phase(struct Scsi_Host *instance);
 static void AM53C974_print_queues(struct Scsi_Host *instance);
-#endif /* AM53C974_DEBUG */
+#endif                         /* AM53C974_DEBUG */
 static void AM53C974_print(struct Scsi_Host *instance);
 static void AM53C974_keywait(void);
-static __inline__ int AM53C974_pci_detect(Scsi_Host_Template *tpnt);
-static int AM53C974_init(Scsi_Host_Template *tpnt, struct pci_dev *pdev);
+static __inline__ int AM53C974_pci_detect(Scsi_Host_Template * tpnt);
+static int AM53C974_init(Scsi_Host_Template * tpnt, struct pci_dev *pdev);
 static void AM53C974_config_after_reset(struct Scsi_Host *instance);
-static __inline__ void initialize_SCp(Scsi_Cmnd *cmd);
+static __inline__ void initialize_SCp(Scsi_Cmnd * cmd);
 static __inline__ void run_main(void);
-static void AM53C974_main (void);
+static void AM53C974_main(void);
 static void AM53C974_intr(int irq, void *dev_id, struct pt_regs *regs);
 static void do_AM53C974_intr(int irq, void *dev_id, struct pt_regs *regs);
-static void AM53C974_intr_disconnect(struct Scsi_Host *instance); 
+static void AM53C974_intr_disconnect(struct Scsi_Host *instance);
 static int AM53C974_sync_neg(struct Scsi_Host *instance, int target, unsigned char *msg);
 static __inline__ void AM53C974_set_async(struct Scsi_Host *instance, int target);
 static __inline__ void AM53C974_set_sync(struct Scsi_Host *instance, int target);
-static void AM53C974_information_transfer(struct Scsi_Host *instance, 
-                                          unsigned char statreg, unsigned char isreg,
-                                          unsigned char instreg, unsigned char cfifo,
-                                          unsigned char dmastatus);
-static int AM53C974_message(struct Scsi_Host *instance, Scsi_Cmnd *cmd, unsigned char msg);
-static void AM53C974_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag);
+static void AM53C974_information_transfer(struct Scsi_Host *instance,
+                             unsigned char statreg, unsigned char isreg,
+                             unsigned char instreg, unsigned char cfifo,
+                                         unsigned char dmastatus);
+static int AM53C974_message(struct Scsi_Host *instance, Scsi_Cmnd * cmd, unsigned char msg);
+static void AM53C974_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag);
 static void AM53C974_intr_reselect(struct Scsi_Host *instance, unsigned char statreg);
-static  __inline__ void AM53C974_transfer_dma(struct Scsi_Host *instance, short dir,
-                                              unsigned long length, char *data);
-static void AM53C974_dma_blast(struct Scsi_Host *instance, unsigned char dmastatus, 
-                               unsigned char statreg);
+static __inline__ void AM53C974_transfer_dma(struct Scsi_Host *instance, short dir,
+                                      unsigned long length, char *data);
+static void AM53C974_dma_blast(struct Scsi_Host *instance, unsigned char dmastatus,
+                              unsigned char statreg);
 static void AM53C974_intr_bus_reset(struct Scsi_Host *instance);
 
 static struct Scsi_Host *first_instance = NULL;
@@ -385,9 +385,12 @@ static Scsi_Host_Template *the_template = NULL;
 static struct Scsi_Host *first_host = NULL;    /* Head of list of AMD boards */
 static volatile int main_running = 0;
 static int commandline_current = 0;
-override_t overrides[7] = { {-1, 0, 0, 0}, };   /* LILO overrides */
+override_t overrides[7] =
+{
+       {-1, 0, 0, 0},};        /* LILO overrides */
 
-struct proc_dir_entry proc_scsi_am53c974 = {
+struct proc_dir_entry proc_scsi_am53c974 =
+{
        PROC_SCSI_AM53C974, 8, "am53c974",
        S_IFDIR | S_IRUGO | S_IXUGO, 2
 };
@@ -396,12 +399,30 @@ struct proc_dir_entry proc_scsi_am53c974 = {
 static int deb_stop = 1;
 
 static struct {
-    unsigned char value;
-    char *name;
+       unsigned char value;
+       char *name;
 } phases[] = {
-{PHASE_DATAOUT, "DATAOUT"}, {PHASE_DATAIN, "DATAIN"}, {PHASE_CMDOUT, "CMDOUT"},
-{PHASE_STATIN, "STATIN"}, {PHASE_MSGOUT, "MSGOUT"}, {PHASE_MSGIN, "MSGIN"},
-{PHASE_RES_0, "RESERVED 0"}, {PHASE_RES_1, "RESERVED 1"}};
+
+       {
+               PHASE_DATAOUT, "DATAOUT"
+       }, {
+               PHASE_DATAIN, "DATAIN"
+       }, {
+               PHASE_CMDOUT, "CMDOUT"
+       },
+       {
+               PHASE_STATIN, "STATIN"
+       }, {
+               PHASE_MSGOUT, "MSGOUT"
+       }, {
+               PHASE_MSGIN, "MSGIN"
+       },
+       {
+               PHASE_RES_0, "RESERVED 0"
+       }, {
+               PHASE_RES_1, "RESERVED 1"
+       }
+};
 
 /************************************************************************** 
  * Function : void AM53C974_print_phase(struct Scsi_Host *instance)
@@ -412,19 +433,19 @@ static struct {
  **************************************************************************/
 static void AM53C974_print_phase(struct Scsi_Host *instance)
 {
-AM53C974_local_declare();
-unsigned char statreg, latched;
-int           i;
-AM53C974_setio(instance);
-
-latched = (AM53C974_read_8(CNTLREG2)) & CNTLREG2_ENF;
-statreg = AM53C974_read_8(STATREG);
-for (i = 0; (phases[i].value != PHASE_RES_1) && 
-     (phases[i].value != (statreg & STATREG_PHASE)); ++i); 
-if (latched)
-   printk("scsi%d : phase %s, latched at end of last command\n", instance->host_no, phases[i].name);
-  else
-   printk("scsi%d : phase %s, real time\n", instance->host_no, phases[i].name);
+       AM53C974_local_declare();
+       unsigned char statreg, latched;
+       int i;
+       AM53C974_setio(instance);
+
+       latched = (AM53C974_read_8(CNTLREG2)) & CNTLREG2_ENF;
+       statreg = AM53C974_read_8(STATREG);
+       for (i = 0; (phases[i].value != PHASE_RES_1) &&
+            (phases[i].value != (statreg & STATREG_PHASE)); ++i);
+       if (latched)
+               printk("scsi%d : phase %s, latched at end of last command\n", instance->host_no, phases[i].name);
+       else
+               printk("scsi%d : phase %s, real time\n", instance->host_no, phases[i].name);
 }
 
 /**************************************************************************
@@ -436,42 +457,48 @@ if (latched)
  **************************************************************************/
 static void AM53C974_print_queues(struct Scsi_Host *instance)
 {
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-Scsi_Cmnd *ptr;
-
-printk("AM53C974: coroutine is%s running.\n", main_running ? "" : "n't");
-    
-cli();
-    
-if (!hostdata->connected) {
-   printk ("scsi%d: no currently connected command\n", instance->host_no); } 
-  else {
-   print_Scsi_Cmnd ((Scsi_Cmnd *)hostdata->connected); }
-if (!hostdata->sel_cmd) {
-   printk ("scsi%d: no currently arbitrating command\n", instance->host_no); } 
-  else {
-   print_Scsi_Cmnd ((Scsi_Cmnd *)hostdata->sel_cmd); }
-
-printk ("scsi%d: issue_queue ", instance->host_no);
-if (!hostdata->issue_queue)
-   printk("empty\n");
-  else {
-   printk(":\n");
-   for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *)ptr->host_scribble) 
-       print_Scsi_Cmnd (ptr); }
-
-printk ("scsi%d: disconnected_queue ", instance->host_no);
-if (!hostdata->disconnected_queue)
-   printk("empty\n");
-  else {
-   printk(":\n");
-   for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *)ptr->host_scribble) 
-       print_Scsi_Cmnd (ptr); }
-    
-sti();
+       unsigned long flags;
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       Scsi_Cmnd *ptr;
+
+       printk("AM53C974: coroutine is%s running.\n", main_running ? "" : "n't");
+
+       save_flags(flags);
+       cli();
+
+       if (!hostdata->connected) {
+               printk("scsi%d: no currently connected command\n", instance->host_no);
+       } else {
+               print_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected);
+       }
+       if (!hostdata->sel_cmd) {
+               printk("scsi%d: no currently arbitrating command\n", instance->host_no);
+       } else {
+               print_Scsi_Cmnd((Scsi_Cmnd *) hostdata->sel_cmd);
+       }
+
+       printk("scsi%d: issue_queue ", instance->host_no);
+       if (!hostdata->issue_queue)
+               printk("empty\n");
+       else {
+               printk(":\n");
+               for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
+                       print_Scsi_Cmnd(ptr);
+       }
+
+       printk("scsi%d: disconnected_queue ", instance->host_no);
+       if (!hostdata->disconnected_queue)
+               printk("empty\n");
+       else {
+               printk(":\n");
+               for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
+                       print_Scsi_Cmnd(ptr);
+       }
+
+       restore_flags(flags);
 }
 
-#endif /* AM53C974_DEBUG */
+#endif                         /* AM53C974_DEBUG */
 
 /**************************************************************************
  * Function : void AM53C974_print(struct Scsi_Host *instance)
@@ -482,39 +509,42 @@ sti();
  **************************************************************************/
 static void AM53C974_print(struct Scsi_Host *instance)
 {
-AM53C974_local_declare();
-unsigned long ctcreg, dmastc, dmaspa, dmawbc, dmawac;
-unsigned char cmdreg, statreg, isreg, cfireg, cntlreg[4], dmacmd, dmastatus;
-AM53C974_setio(instance);
-
-cli();
-ctcreg = AM53C974_read_8(CTCHREG) << 16;
-ctcreg |= AM53C974_read_8(CTCMREG) << 8;
-ctcreg |= AM53C974_read_8(CTCLREG);
-cmdreg = AM53C974_read_8(CMDREG);
-statreg = AM53C974_read_8(STATREG);
-isreg = AM53C974_read_8(ISREG);
-cfireg = AM53C974_read_8(CFIREG);
-cntlreg[0] = AM53C974_read_8(CNTLREG1);
-cntlreg[1] = AM53C974_read_8(CNTLREG2);
-cntlreg[2] = AM53C974_read_8(CNTLREG3);
-cntlreg[3] = AM53C974_read_8(CNTLREG4);
-dmacmd = AM53C974_read_8(DMACMD);
-dmastc = AM53C974_read_32(DMASTC);
-dmaspa = AM53C974_read_32(DMASPA);
-dmawbc = AM53C974_read_32(DMAWBC);
-dmawac = AM53C974_read_32(DMAWAC);
-dmastatus = AM53C974_read_8(DMASTATUS);
-sti();
-
-printk("AM53C974 register dump:\n");
-printk("IO base: 0x%04lx; CTCREG: 0x%04lx; CMDREG: 0x%02x; STATREG: 0x%02x; ISREG: 0x%02x\n",
-       io_port, ctcreg, cmdreg, statreg, isreg);
-printk("CFIREG: 0x%02x; CNTLREG1-4: 0x%02x; 0x%02x; 0x%02x; 0x%02x\n",
-        cfireg, cntlreg[0], cntlreg[1], cntlreg[2], cntlreg[3]);
-printk("DMACMD: 0x%02x; DMASTC: 0x%04lx; DMASPA: 0x%04lx\n", dmacmd, dmastc, dmaspa);
-printk("DMAWBC: 0x%04lx; DMAWAC: 0x%04lx; DMASTATUS: 0x%02x\n", dmawbc, dmawac, dmastatus);
-printk("---------------------------------------------------------\n");
+       AM53C974_local_declare();
+       unsigned long flags;
+       unsigned long ctcreg, dmastc, dmaspa, dmawbc, dmawac;
+       unsigned char cmdreg, statreg, isreg, cfireg, cntlreg[4], dmacmd,
+        dmastatus;
+       AM53C974_setio(instance);
+
+       save_flags(flags);
+       cli();
+       ctcreg = AM53C974_read_8(CTCHREG) << 16;
+       ctcreg |= AM53C974_read_8(CTCMREG) << 8;
+       ctcreg |= AM53C974_read_8(CTCLREG);
+       cmdreg = AM53C974_read_8(CMDREG);
+       statreg = AM53C974_read_8(STATREG);
+       isreg = AM53C974_read_8(ISREG);
+       cfireg = AM53C974_read_8(CFIREG);
+       cntlreg[0] = AM53C974_read_8(CNTLREG1);
+       cntlreg[1] = AM53C974_read_8(CNTLREG2);
+       cntlreg[2] = AM53C974_read_8(CNTLREG3);
+       cntlreg[3] = AM53C974_read_8(CNTLREG4);
+       dmacmd = AM53C974_read_8(DMACMD);
+       dmastc = AM53C974_read_32(DMASTC);
+       dmaspa = AM53C974_read_32(DMASPA);
+       dmawbc = AM53C974_read_32(DMAWBC);
+       dmawac = AM53C974_read_32(DMAWAC);
+       dmastatus = AM53C974_read_8(DMASTATUS);
+       restore_flags(flags);
+
+       printk("AM53C974 register dump:\n");
+       printk("IO base: 0x%04lx; CTCREG: 0x%04lx; CMDREG: 0x%02x; STATREG: 0x%02x; ISREG: 0x%02x\n",
+              io_port, ctcreg, cmdreg, statreg, isreg);
+       printk("CFIREG: 0x%02x; CNTLREG1-4: 0x%02x; 0x%02x; 0x%02x; 0x%02x\n",
+              cfireg, cntlreg[0], cntlreg[1], cntlreg[2], cntlreg[3]);
+       printk("DMACMD: 0x%02x; DMASTC: 0x%04lx; DMASPA: 0x%04lx\n", dmacmd, dmastc, dmaspa);
+       printk("DMAWBC: 0x%04lx; DMAWAC: 0x%04lx; DMASTATUS: 0x%02x\n", dmawbc, dmawac, dmastatus);
+       printk("---------------------------------------------------------\n");
 }
 
 /**************************************************************************
@@ -527,19 +557,23 @@ printk("---------------------------------------------------------\n");
 **************************************************************************/
 static void AM53C974_keywait(void)
 {
+       unsigned long flags;
 #ifdef AM53C974_DEBUG
-int key;
+       int key;
 
-if (!deb_stop) return;
+       if (!deb_stop)
+               return;
 #endif
 
-cli();
-while ((inb_p(0x64) & 0x01) != 0x01) ;
+       save_flags(flags);
+       cli();
+       while ((inb_p(0x64) & 0x01) != 0x01);
 #ifdef AM53C974_DEBUG
-key = inb(0x60);
-if (key == 0x93) deb_stop = 0;  /* don't stop if 'r' was pressed */
+       key = inb(0x60);
+       if (key == 0x93)
+               deb_stop = 0;   /* don't stop if 'r' was pressed */
 #endif
-sti();
+       restore_flags(flags);
 }
 
 /**************************************************************************
@@ -555,26 +589,26 @@ sti();
 ***************************************************************************/
 void AM53C974_setup(char *str, int *ints)
 {
-if (ints[0] < 4) 
-   printk("AM53C974_setup: wrong number of parameters;\n correct syntax is: AM53C974=host-scsi-id, target-scsi-id, max-rate, max-offset\n");
-  else {
-   if (commandline_current < (sizeof(overrides) / sizeof(override_t))) {
-      if ((ints[1] < 0) || (ints[1] > 7) ||
-          (ints[2] < 0) || (ints[2] > 7) ||
-          (ints[1] == ints[2]) ||
-          (ints[3] < (DEF_CLK / MAX_PERIOD)) || (ints[3] > (DEF_CLK / MIN_PERIOD)) ||
-          (ints[4] < 0) || (ints[4] > MAX_OFFSET))
-         printk("AM53C974_setup: illegal parameter\n");
-        else {
-         overrides[commandline_current].host_scsi_id = ints[1];
-         overrides[commandline_current].target_scsi_id = ints[2];
-         overrides[commandline_current].max_rate = ints[3];
-         overrides[commandline_current].max_offset = ints[4];
-         commandline_current++; }
-      }
-     else
-      printk("AM53C974_setup: too many overrides\n");
-   }
+       if (ints[0] < 4)
+               printk("AM53C974_setup: wrong number of parameters;\n correct syntax is: AM53C974=host-scsi-id, target-scsi-id, max-rate, max-offset\n");
+       else {
+               if (commandline_current < (sizeof(overrides) / sizeof(override_t))) {
+                       if ((ints[1] < 0) || (ints[1] > 7) ||
+                           (ints[2] < 0) || (ints[2] > 7) ||
+                           (ints[1] == ints[2]) ||
+                           (ints[3] < (DEF_CLK / MAX_PERIOD)) || (ints[3] > (DEF_CLK / MIN_PERIOD)) ||
+                           (ints[4] < 0) || (ints[4] > MAX_OFFSET))
+                               printk("AM53C974_setup: illegal parameter\n");
+                       else {
+                               overrides[commandline_current].host_scsi_id = ints[1];
+                               overrides[commandline_current].target_scsi_id = ints[2];
+                               overrides[commandline_current].max_rate = ints[3];
+                               overrides[commandline_current].max_offset = ints[4];
+                               commandline_current++;
+                       }
+               } else
+                       printk("AM53C974_setup: too many overrides\n");
+       }
 }
 
 #if defined (CONFIG_PCI)
@@ -587,30 +621,32 @@ if (ints[0] < 4)
 * 
 * Returns : number of host adapters detected
 **************************************************************************/
-static __inline__ int AM53C974_pci_detect(Scsi_Host_Template *tpnt)
+static __inline__ int AM53C974_pci_detect(Scsi_Host_Template * tpnt)
 {
-int count = 0;        /* number of boards detected */
-struct pci_dev *pdev = NULL;
-unsigned short command;
-
-while ((pdev = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SCSI, pdev))) {
-    pci_read_config_word(pdev, PCI_COMMAND, &command);
-
-    /* check whether device is I/O mapped -- should be */
-    if (!(command & PCI_COMMAND_IO)) continue;
-
-    /* PCI Spec 2.1 states that it is either the driver's or the PCI card's responsibility
-       to set the PCI Master Enable Bit if needed. 
-       (from Mark Stockton <marks@schooner.sys.hou.compaq.com>) */
-    if (!(command & PCI_COMMAND_MASTER)) {
-       command |= PCI_COMMAND_MASTER;
-       printk("PCI Master Bit has not been set. Setting...\n");
-       pci_write_config_word(pdev, PCI_COMMAND, command); }
-
-    /* everything seems OK now, so initialize */
-    if (AM53C974_init(tpnt, pdev)) count++ ;
-    }
-return (count);
+       int count = 0;          /* number of boards detected */
+       struct pci_dev *pdev = NULL;
+       unsigned short command;
+
+       while ((pdev = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SCSI, pdev))) {
+               pci_read_config_word(pdev, PCI_COMMAND, &command);
+
+               /* check whether device is I/O mapped -- should be */
+               if (!(command & PCI_COMMAND_IO))
+                       continue;
+
+               /* PCI Spec 2.1 states that it is either the driver's or the PCI card's responsibility
+                  to set the PCI Master Enable Bit if needed. 
+                  (from Mark Stockton <marks@schooner.sys.hou.compaq.com>) */
+               if (!(command & PCI_COMMAND_MASTER)) {
+                       command |= PCI_COMMAND_MASTER;
+                       printk("PCI Master Bit has not been set. Setting...\n");
+                       pci_write_config_word(pdev, PCI_COMMAND, command);
+               }
+               /* everything seems OK now, so initialize */
+               if (AM53C974_init(tpnt, pdev))
+                       count++;
+       }
+       return (count);
 }
 #endif
 
@@ -623,17 +659,17 @@ return (count);
 * 
 * Returns : number of host adapters detected
 **************************************************************************/
-__initfunc(int AM53C974_detect(Scsi_Host_Template *tpnt))
+__initfunc(int AM53C974_detect(Scsi_Host_Template * tpnt))
 {
-int count = 0;        /* number of boards detected */
+       int count = 0;          /* number of boards detected */
 
-tpnt->proc_dir = &proc_scsi_am53c974;
+       tpnt->proc_dir = &proc_scsi_am53c974;
 
 #if defined (CONFIG_PCI)
-if (pci_present())
-   count = AM53C974_pci_detect(tpnt);
+       if (pci_present())
+               count = AM53C974_pci_detect(tpnt);
 #endif
-return (count);
+       return (count);
 }
 
 /**************************************************************************
@@ -650,97 +686,100 @@ return (count);
 *       set up by the BIOS (as reflected by contents of register CNTLREG1).
 *       This is the only BIOS assistance we need.
 **************************************************************************/
-__initfunc(static int AM53C974_init(Scsi_Host_Template *tpnt, struct pci_dev *pdev))
+__initfunc(static int AM53C974_init(Scsi_Host_Template * tpnt, struct pci_dev *pdev))
 {
-AM53C974_local_declare();
-int                      i, j;
-struct Scsi_Host         *instance, *search;
-struct AM53C974_hostdata *hostdata;
+       AM53C974_local_declare();
+       int i, j;
+       struct Scsi_Host *instance, *search;
+       struct AM53C974_hostdata *hostdata;
 
 #ifdef AM53C974_OPTION_DEBUG_PROBE_ONLY
-   printk ("AM53C974: probe only enabled, aborting initialization\n");
-   return 0;
+       printk("AM53C974: probe only enabled, aborting initialization\n");
+       return 0;
 #endif
 
-instance = scsi_register(tpnt, sizeof(struct AM53C974_hostdata));
-hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-instance->base = NULL;
-instance->io_port = pdev->base_address[0] & PCI_BASE_ADDRESS_IO_MASK;
-instance->irq = pdev->irq;
-instance->dma_channel = -1;
-AM53C974_setio(instance);
+       instance = scsi_register(tpnt, sizeof(struct AM53C974_hostdata));
+       hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       instance->base = NULL;
+       instance->io_port = pdev->base_address[0] & PCI_BASE_ADDRESS_IO_MASK;
+       instance->irq = pdev->irq;
+       instance->dma_channel = -1;
+       AM53C974_setio(instance);
 
 #ifdef AM53C974_SCSI_ID
-instance->this_id = AM53C974_SCSI_ID;
-AM53C974_write_8(CNTLREG1, instance->this_id & CNTLREG1_SID);
+       instance->this_id = AM53C974_SCSI_ID;
+       AM53C974_write_8(CNTLREG1, instance->this_id & CNTLREG1_SID);
 #else
-instance->this_id = AM53C974_read_8(CNTLREG1) & CNTLREG1_SID;
-if (instance->this_id != 7) 
-   printk("scsi%d: WARNING: unusual hostadapter SCSI id %d; please verify!\n", 
-          instance->host_no, instance->this_id);
+       instance->this_id = AM53C974_read_8(CNTLREG1) & CNTLREG1_SID;
+       if (instance->this_id != 7)
+               printk("scsi%d: WARNING: unusual hostadapter SCSI id %d; please verify!\n",
+                      instance->host_no, instance->this_id);
 #endif
 
-for (i = 0; i < sizeof(hostdata->msgout); i++) {
-    hostdata->msgout[i] = NOP;
-    hostdata->last_message[i] = NOP; }
-for (i = 0; i < 8; i++) {
-    hostdata->busy[i] = 0;
-    hostdata->sync_per[i] = DEF_STP;
-    hostdata->sync_off[i] = 0;
-    hostdata->sync_neg[i] = 0;
-    hostdata->sync_en[i] = DEFAULT_SYNC_NEGOTIATION_ENABLED;
-    hostdata->max_rate[i] = DEFAULT_RATE;
-    hostdata->max_offset[i] = DEFAULT_SYNC_OFFSET; }
+       for (i = 0; i < sizeof(hostdata->msgout); i++) {
+               hostdata->msgout[i] = NOP;
+               hostdata->last_message[i] = NOP;
+       }
+       for (i = 0; i < 8; i++) {
+               hostdata->busy[i] = 0;
+               hostdata->sync_per[i] = DEF_STP;
+               hostdata->sync_off[i] = 0;
+               hostdata->sync_neg[i] = 0;
+               hostdata->sync_en[i] = DEFAULT_SYNC_NEGOTIATION_ENABLED;
+               hostdata->max_rate[i] = DEFAULT_RATE;
+               hostdata->max_offset[i] = DEFAULT_SYNC_OFFSET;
+       }
 
 /* overwrite defaults by LILO overrides */
-for (i = 0; i < commandline_current; i++) {
-    if (overrides[i].host_scsi_id == instance->this_id) {
-       j = overrides[i].target_scsi_id;
-       hostdata->sync_en[j] = 1;
-       hostdata->max_rate[j] = overrides[i].max_rate;
-       hostdata->max_offset[j] = overrides[i].max_offset; 
-       }
-    }
-
-hostdata->sel_cmd = NULL;
-hostdata->connected = NULL;
-hostdata->issue_queue = NULL;
-hostdata->disconnected_queue = NULL;
-hostdata->in_reset = 0;
-hostdata->aborted = 0;
-hostdata->selecting = 0;
-hostdata->disconnecting = 0;
-hostdata->dma_busy = 0;
+       for (i = 0; i < commandline_current; i++) {
+               if (overrides[i].host_scsi_id == instance->this_id) {
+                       j = overrides[i].target_scsi_id;
+                       hostdata->sync_en[j] = 1;
+                       hostdata->max_rate[j] = overrides[i].max_rate;
+                       hostdata->max_offset[j] = overrides[i].max_offset;
+               }
+       }
+
+       hostdata->sel_cmd = NULL;
+       hostdata->connected = NULL;
+       hostdata->issue_queue = NULL;
+       hostdata->disconnected_queue = NULL;
+       hostdata->in_reset = 0;
+       hostdata->aborted = 0;
+       hostdata->selecting = 0;
+       hostdata->disconnecting = 0;
+       hostdata->dma_busy = 0;
 
 /* Set up an interrupt handler if we aren't already sharing an IRQ with another board */
-for (search = first_host; 
-     search && ( ((the_template != NULL) && (search->hostt != the_template)) || 
-                 (search->irq != instance->irq) || (search == instance) );
-     search = search->next);
-if (!search) {
-   if (request_irq(instance->irq, do_AM53C974_intr, SA_INTERRUPT, "AM53C974", NULL)) {
-      printk("scsi%d: IRQ%d not free, detaching\n", instance->host_no, instance->irq);
-      scsi_unregister(instance);
-      return 0; } 
-   }
-  else {
-   printk("scsi%d: using interrupt handler previously installed for scsi%d\n",
-         instance->host_no, search->host_no); }
-
-if (!the_template) {
-   the_template = instance->hostt;
-   first_instance = instance; }
-
+       for (search = first_host;
+            search && (((the_template != NULL) && (search->hostt != the_template)) ||
+                (search->irq != instance->irq) || (search == instance));
+            search = search->next);
+       if (!search) {
+               if (request_irq(instance->irq, do_AM53C974_intr, SA_INTERRUPT, "AM53C974", NULL)) {
+                       printk("scsi%d: IRQ%d not free, detaching\n", instance->host_no, instance->irq);
+                       scsi_unregister(instance);
+                       return 0;
+               }
+       } else {
+               printk("scsi%d: using interrupt handler previously installed for scsi%d\n",
+                      instance->host_no, search->host_no);
+       }
+
+       if (!the_template) {
+               the_template = instance->hostt;
+               first_instance = instance;
+       }
 /* do hard reset */
-AM53C974_write_8(CMDREG, CMDREG_RDEV);     /* reset device */
-udelay(5);
-AM53C974_write_8(CMDREG, CMDREG_NOP);
-AM53C974_write_8(CNTLREG1, CNTLREG1_DISR | instance->this_id); 
-AM53C974_write_8(CMDREG, CMDREG_RBUS);     /* reset SCSI bus */
-udelay(10);
-AM53C974_config_after_reset(instance);
-udelay(500000);
-return(1);
+       AM53C974_write_8(CMDREG, CMDREG_RDEV);  /* reset device */
+       udelay(5);
+       AM53C974_write_8(CMDREG, CMDREG_NOP);
+       AM53C974_write_8(CNTLREG1, CNTLREG1_DISR | instance->this_id);
+       AM53C974_write_8(CMDREG, CMDREG_RBUS);  /* reset SCSI bus */
+       udelay(10);
+       AM53C974_config_after_reset(instance);
+       udelay(500000);
+       return (1);
 }
 
 /*********************************************************************
@@ -754,21 +793,21 @@ return(1);
 **********************************************************************/
 static void AM53C974_config_after_reset(struct Scsi_Host *instance)
 {
-AM53C974_local_declare(); 
-AM53C974_setio(instance);
+       AM53C974_local_declare();
+       AM53C974_setio(instance);
 
 /* clear SCSI FIFO */
-AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
 
 /* configure device */
-AM53C974_write_8(STIMREG, DEF_SCSI_TIMEOUT);
-AM53C974_write_8(STPREG, DEF_STP & STPREG_STP);
-AM53C974_write_8(SOFREG, (DEF_SOF_RAD<<6) | (DEF_SOF_RAA<<4));
-AM53C974_write_8(CLKFREG, DEF_CLKF & CLKFREG_MASK);
-AM53C974_write_8(CNTLREG1, (DEF_ETM<<7) | CNTLREG1_DISR | (DEF_PERE<<4) | instance->this_id);
-AM53C974_write_8(CNTLREG2, (DEF_ENF<<6));
-AM53C974_write_8(CNTLREG3, (DEF_ADIDCHK<<7) | (DEF_FASTSCSI<<4) | (DEF_FASTCLK<<3));
-AM53C974_write_8(CNTLREG4, (DEF_GLITCH<<6) | (DEF_PWD<<5) | (DEF_RAE<<3) | (DEF_RADE<<2) | CNTLREG4_RES);
+       AM53C974_write_8(STIMREG, DEF_SCSI_TIMEOUT);
+       AM53C974_write_8(STPREG, DEF_STP & STPREG_STP);
+       AM53C974_write_8(SOFREG, (DEF_SOF_RAD << 6) | (DEF_SOF_RAA << 4));
+       AM53C974_write_8(CLKFREG, DEF_CLKF & CLKFREG_MASK);
+       AM53C974_write_8(CNTLREG1, (DEF_ETM << 7) | CNTLREG1_DISR | (DEF_PERE << 4) | instance->this_id);
+       AM53C974_write_8(CNTLREG2, (DEF_ENF << 6));
+       AM53C974_write_8(CNTLREG3, (DEF_ADIDCHK << 7) | (DEF_FASTSCSI << 4) | (DEF_FASTCLK << 3));
+       AM53C974_write_8(CNTLREG4, (DEF_GLITCH << 6) | (DEF_PWD << 5) | (DEF_RAE << 3) | (DEF_RADE << 2) | CNTLREG4_RES);
 }
 
 /***********************************************************************
@@ -782,12 +821,12 @@ AM53C974_write_8(CNTLREG4, (DEF_GLITCH<<6) | (DEF_PWD<<5) | (DEF_RAE<<3) | (DEF_
 ************************************************************************/
 const char *AM53C974_info(struct Scsi_Host *instance)
 {
-static char       info[100];
+       static char info[100];
 
-sprintf(info, "AM53/79C974 PCscsi driver rev. %d.%d; host I/O address: 0x%x; irq: %d\n", 
-        AM53C974_DRIVER_REVISION_MAJOR, AM53C974_DRIVER_REVISION_MINOR,
-        instance->io_port, instance->irq);
-return (info);
+       sprintf(info, "AM53/79C974 PCscsi driver rev. %d.%d; host I/O address: 0x%x; irq: %d\n",
+         AM53C974_DRIVER_REVISION_MAJOR, AM53C974_DRIVER_REVISION_MINOR,
+               instance->io_port, instance->irq);
+       return (info);
 }
 
 /************************************************************************** 
@@ -800,10 +839,10 @@ return (info);
 *                                                                         *
 * Returns :status, see hosts.h for details                                *
 ***************************************************************************/
-int AM53C974_command(Scsi_Cmnd *SCpnt)
+int AM53C974_command(Scsi_Cmnd * SCpnt)
 {
-DEB(printk("AM53C974_command called\n"));
-return 0;
+       DEB(printk("AM53C974_command called\n"));
+       return 0;
 }
 
 /**************************************************************************
@@ -816,18 +855,19 @@ return 0;
 *                                                                         *
 * Returns : nothing                                                       *
 **************************************************************************/
-static __inline__ void initialize_SCp(Scsi_Cmnd *cmd)
+static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
 {
-if (cmd->use_sg) {
-   cmd->SCp.buffer = (struct scatterlist *)cmd->buffer;
-   cmd->SCp.buffers_residual = cmd->use_sg - 1;
-   cmd->SCp.ptr = (char *)cmd->SCp.buffer->address;
-   cmd->SCp.this_residual = cmd->SCp.buffer->length; }
-  else {
-   cmd->SCp.buffer = NULL;
-   cmd->SCp.buffers_residual = 0;
-   cmd->SCp.ptr = (char *)cmd->request_buffer;
-   cmd->SCp.this_residual = cmd->request_bufflen; }
+       if (cmd->use_sg) {
+               cmd->SCp.buffer = (struct scatterlist *) cmd->buffer;
+               cmd->SCp.buffers_residual = cmd->use_sg - 1;
+               cmd->SCp.ptr = (char *) cmd->SCp.buffer->address;
+               cmd->SCp.this_residual = cmd->SCp.buffer->length;
+       } else {
+               cmd->SCp.buffer = NULL;
+               cmd->SCp.buffers_residual = 0;
+               cmd->SCp.ptr = (char *) cmd->request_buffer;
+               cmd->SCp.this_residual = cmd->request_bufflen;
+       }
 }
 
 /**************************************************************************
@@ -845,15 +885,16 @@ if (cmd->use_sg) {
 **************************************************************************/
 static __inline__ void run_main(void)
 {
-cli();
-if (!main_running) {
-   /* main_running is cleared in AM53C974_main once it can't do 
-      more work, and AM53C974_main exits with interrupts disabled. */
-   main_running = 1;
-   AM53C974_main();
-   sti(); }
-  else 
-   sti();
+       unsigned long flags;
+       save_flags(flags);
+       cli();
+       if (!main_running) {
+               /* main_running is cleared in AM53C974_main once it can't do 
+                  more work, and AM53C974_main exits with interrupts disabled. */
+               main_running = 1;
+               AM53C974_main();
+       }
+       restore_flags(flags);
 }
 
 /************************************************************************** 
@@ -871,44 +912,48 @@ if (!main_running) {
 *      twiddling done to the host specific fields of cmd.  If the 
 *      main coroutine is not running, it is restarted.
 **************************************************************************/
-int AM53C974_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
+int AM53C974_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
 {
-struct Scsi_Host         *instance = cmd->host;
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-Scsi_Cmnd                *tmp;
-
-cli();
-DEB_QUEUE(printk(SEPARATOR_LINE));
-DEB_QUEUE(printk("scsi%d: AM53C974_queue_command called\n", instance->host_no));
-DEB_QUEUE(printk("cmd=%02x target=%02x lun=%02x bufflen=%d use_sg = %02x\n", 
-          cmd->cmnd[0], cmd->target, cmd->lun, cmd->request_bufflen, cmd->use_sg));
+       unsigned long flags;
+       struct Scsi_Host *instance = cmd->host;
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       Scsi_Cmnd *tmp;
+
+       save_flags(flags);
+       cli();
+       DEB_QUEUE(printk(SEPARATOR_LINE));
+       DEB_QUEUE(printk("scsi%d: AM53C974_queue_command called\n", instance->host_no));
+       DEB_QUEUE(printk("cmd=%02x target=%02x lun=%02x bufflen=%d use_sg = %02x\n",
+                        cmd->cmnd[0], cmd->target, cmd->lun, cmd->request_bufflen, cmd->use_sg));
 
 /* We use the host_scribble field as a pointer to the next command in a queue */
-cmd->host_scribble = NULL;
-cmd->scsi_done = done;
-cmd->result = 0;
-cmd->device->disconnect = 0;
+       cmd->host_scribble = NULL;
+       cmd->scsi_done = done;
+       cmd->result = 0;
+       cmd->device->disconnect = 0;
 
 /* Insert the cmd into the issue queue. Note that REQUEST SENSE 
  * commands are added to the head of the queue since any command will
  * clear the contingent allegiance condition that exists and the 
  * sense data is only guaranteed to be valid while the condition exists. */
-if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
-   LIST(cmd, hostdata->issue_queue);
-   cmd->host_scribble = (unsigned char *)hostdata->issue_queue;
-   hostdata->issue_queue = cmd; }
-  else {
-   for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; tmp->host_scribble; 
-       tmp = (Scsi_Cmnd *)tmp->host_scribble);
-   LIST(cmd, tmp);
-   tmp->host_scribble = (unsigned char *)cmd; }
-
-DEB_QUEUE(printk("scsi%d : command added to %s of queue\n", instance->host_no,
-         (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"));
+       if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
+               LIST(cmd, hostdata->issue_queue);
+               cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
+               hostdata->issue_queue = cmd;
+       } else {
+               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble;
+                    tmp = (Scsi_Cmnd *) tmp->host_scribble);
+               LIST(cmd, tmp);
+               tmp->host_scribble = (unsigned char *) cmd;
+       }
+
+       DEB_QUEUE(printk("scsi%d : command added to %s of queue\n", instance->host_no,
+                    (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"));
 
 /* Run the coroutine if it isn't already running. */
-run_main();
-return 0;
+       run_main();
+       restore_flags(flags);
+       return 0;
 }
 
 /**************************************************************************
@@ -921,61 +966,65 @@ return 0;
  * 
  * NOTE : AM53C974_main exits with interrupts *disabled*, the caller should 
  *  reenable them.  This prevents reentrancy and kernel stack overflow.
- **************************************************************************/  
+ **************************************************************************/
 static void AM53C974_main(void)
 {
-AM53C974_local_declare(); 
-Scsi_Cmnd                *tmp, *prev;
-struct Scsi_Host         *instance;
-struct AM53C974_hostdata *hostdata;
-int                      done;
+       AM53C974_local_declare();
+       unsigned long flags;
+       Scsi_Cmnd *tmp, *prev;
+       struct Scsi_Host *instance;
+       struct AM53C974_hostdata *hostdata;
+       int done;
 
 /* We run (with interrupts disabled) until we're sure that none of 
  * the host adapters have anything that can be done, at which point 
  * we set main_running to 0 and exit. */
 
-do {
-   cli(); /* Freeze request queues */
-   done = 1;
-   for (instance = first_instance; instance && instance->hostt == the_template;
-        instance = instance->next) {
-       hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-       AM53C974_setio(instance);
-       /* start to select target if we are not connected and not in the 
-          selection process */
-       if (!hostdata->connected && !hostdata->sel_cmd) {
-          /* Search through the issue_queue for a command destined for a target 
-             that is not busy. */
-          for (tmp = (Scsi_Cmnd *)hostdata->issue_queue, prev = NULL; tmp; 
-               prev = tmp, tmp = (Scsi_Cmnd *)tmp->host_scribble) {
-             /*  When we find one, remove it from the issue queue. */
-             if (!(hostdata->busy[tmp->target] & (1 << tmp->lun))) {
-                if (prev) {
-                   REMOVE(prev, (Scsi_Cmnd *)(prev->host_scribble), tmp,
-                           (Scsi_Cmnd *)(tmp->host_scribble));
-                   prev->host_scribble = tmp->host_scribble; } 
-                   else {
-                   REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble);
-                   hostdata->issue_queue = (Scsi_Cmnd *)tmp->host_scribble; }
-                tmp->host_scribble = NULL;
-
-                 /* go into selection mode, disable reselection and wait for
-                    SO interrupt which will continue with the selection process */
-                 hostdata->selecting = 1;
-                 hostdata->sel_cmd = tmp;
-                 AM53C974_write_8(CMDREG, CMDREG_DSR); 
-                 break;                 
-                } /* if target/lun is not busy */
-
-             } /* for */
-          } /* if (!hostdata->connected) */
-         else {                
-          DEB(printk("main: connected; cmd = 0x%lx, sel_cmd = 0x%lx\n",
-                 (long)hostdata->connected, (long)hostdata->sel_cmd));
-         }
-       } /* for instance */
-   } while (!done);
-main_running = 0;
+       save_flags(flags);
+       cli();          /* Freeze request queues */
+       do {
+               done = 1;
+               for (instance = first_instance; instance && instance->hostt == the_template;
+                    instance = instance->next) {
+                       hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+                       AM53C974_setio(instance);
+                       /* start to select target if we are not connected and not in the 
+                          selection process */
+                       if (!hostdata->connected && !hostdata->sel_cmd) {
+                               /* Search through the issue_queue for a command destined for a target 
+                                  that is not busy. */
+                               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp;
+                                    prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) {
+                                       /*  When we find one, remove it from the issue queue. */
+                                       if (!(hostdata->busy[tmp->target] & (1 << tmp->lun))) {
+                                               if (prev) {
+                                                       REMOVE(prev, (Scsi_Cmnd *) (prev->host_scribble), tmp,
+                                                              (Scsi_Cmnd *) (tmp->host_scribble));
+                                                       prev->host_scribble = tmp->host_scribble;
+                                               } else {
+                                                       REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble);
+                                                       hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble;
+                                               }
+                                               tmp->host_scribble = NULL;
+
+                                               /* go into selection mode, disable reselection and wait for
+                                                  SO interrupt which will continue with the selection process */
+                                               hostdata->selecting = 1;
+                                               hostdata->sel_cmd = tmp;
+                                               AM53C974_write_8(CMDREG, CMDREG_DSR);
+                                               break;
+                                       }       /* if target/lun is not busy */
+                               }       /* for */
+                       }
+                       /* if (!hostdata->connected) */ 
+                       else {
+                               DEB(printk("main: connected; cmd = 0x%lx, sel_cmd = 0x%lx\n",
+                                          (long) hostdata->connected, (long) hostdata->sel_cmd));
+                       }
+               }               /* for instance */
+       } while (!done);
+       main_running = 0;
+       restore_flags(flags);
 }
 
 /************************************************************************
@@ -989,11 +1038,11 @@ main_running = 0;
 ************************************************************************/
 static void do_AM53C974_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
-unsigned long flags;
+       unsigned long flags;
 
-spin_lock_irqsave(&io_request_lock, flags);
-AM53C974_intr(irq, dev_id, regs);
-spin_unlock_irqrestore(&io_request_lock, flags);
+       spin_lock_irqsave(&io_request_lock, flags);
+       AM53C974_intr(irq, dev_id, regs);
+       spin_unlock_irqrestore(&io_request_lock, flags);
 }
 
 /************************************************************************
@@ -1007,230 +1056,251 @@ spin_unlock_irqrestore(&io_request_lock, flags);
 ************************************************************************/
 static void AM53C974_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
-AM53C974_local_declare(); 
-struct Scsi_Host         *instance;
-struct AM53C974_hostdata *hostdata;
-unsigned char            cmdreg, dmastatus, statreg, isreg, instreg, cfifo;
+       AM53C974_local_declare();
+       struct Scsi_Host *instance;
+       struct AM53C974_hostdata *hostdata;
+       unsigned char cmdreg, dmastatus, statreg, isreg, instreg, cfifo;
 
 /* find AM53C974 hostadapter responsible for this interrupt */
-for (instance = first_instance; instance; instance = instance->next)
-    if ((instance->irq == irq) && (instance->hostt == the_template)) goto FOUND;
-sti();
-return;
+       for (instance = first_instance; instance; instance = instance->next)
+               if ((instance->irq == irq) && (instance->hostt == the_template))
+                       goto FOUND;
+       return;
 
 /* found; now decode and process */
-FOUND:
-hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-AM53C974_setio(instance);
-dmastatus = AM53C974_read_8(DMASTATUS);
+       FOUND:
+           hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       AM53C974_setio(instance);
+       dmastatus = AM53C974_read_8(DMASTATUS);
 
-DEB_INTR(printk(SEPARATOR_LINE));
-DEB_INTR(printk("AM53C974 interrupt; dmastatus=0x%02x\n", dmastatus));
-KEYWAIT();
+       DEB_INTR(printk(SEPARATOR_LINE));
+       DEB_INTR(printk("AM53C974 interrupt; dmastatus=0x%02x\n", dmastatus));
+       KEYWAIT();
 
 /*** DMA related interrupts ***/
-if (hostdata->connected && (dmastatus & (DMASTATUS_ERROR | DMASTATUS_PWDN | 
-                                         DMASTATUS_ABORT))) {
-   /* DMA error or POWERDOWN */
-   printk("scsi%d: DMA error or powerdown; dmastatus: 0x%02x\n",
-          instance->host_no, dmastatus);
+       if (hostdata->connected && (dmastatus & (DMASTATUS_ERROR | DMASTATUS_PWDN |
+                                                DMASTATUS_ABORT))) {
+               /* DMA error or POWERDOWN */
+               printk("scsi%d: DMA error or powerdown; dmastatus: 0x%02x\n",
+                      instance->host_no, dmastatus);
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   panic("scsi%d: cannot recover\n", instance->host_no); }
-
-if (hostdata->connected && (dmastatus & DMASTATUS_DONE)) {     
-   /* DMA transfer done */
-   unsigned long residual;
-   cli();
-   if (!(AM53C974_read_8(DMACMD) & DMACMD_DIR)) {
-      do {
-         dmastatus = AM53C974_read_8(DMASTATUS);
-         residual  = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
-                    (AM53C974_read_8(CTCHREG) << 16);
-         residual += AM53C974_read_8(CFIREG) & CFIREG_CF;
-         } while (!(dmastatus & DMASTATUS_SCSIINT) && residual);
-      residual = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
-                 (AM53C974_read_8(CTCHREG) << 16);
-      residual += AM53C974_read_8(CFIREG) & CFIREG_CF;
-      }
-     else
-      residual = 0;
-   hostdata->connected->SCp.ptr += hostdata->connected->SCp.this_residual - residual;
-   hostdata->connected->SCp.this_residual = residual;
-
-   AM53C974_write_8(DMACMD, DMACMD_IDLE);
-
-   /* if service request missed before, process it now (ugly) */
-   if (hostdata->dma_busy) {
-      hostdata->dma_busy = 0;
-      cmdreg = AM53C974_read_8(CMDREG);
-      statreg = AM53C974_read_8(STATREG);
-      isreg = AM53C974_read_8(ISREG);
-      instreg = AM53C974_read_8(INSTREG);
-      cfifo = AM53C974_cfifo();
-      AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo,
-                                    dmastatus); }
-   sti();
-   }
-   
-if (!(dmastatus & DMASTATUS_SCSIINT)) {
-   sti();
-   return; }
-
+               panic("scsi%d: cannot recover\n", instance->host_no);
+       }
+       if (hostdata->connected && (dmastatus & DMASTATUS_DONE)) {
+               /* DMA transfer done */
+               unsigned long residual;
+               unsigned long flags;
+               save_flags(flags);
+               cli();
+               if (!(AM53C974_read_8(DMACMD) & DMACMD_DIR)) {
+                       do {
+                               dmastatus = AM53C974_read_8(DMASTATUS);
+                               residual = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
+                                   (AM53C974_read_8(CTCHREG) << 16);
+                               residual += AM53C974_read_8(CFIREG) & CFIREG_CF;
+                       } while (!(dmastatus & DMASTATUS_SCSIINT) && residual);
+                       residual = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
+                           (AM53C974_read_8(CTCHREG) << 16);
+                       residual += AM53C974_read_8(CFIREG) & CFIREG_CF;
+               } else
+                       residual = 0;
+               hostdata->connected->SCp.ptr += hostdata->connected->SCp.this_residual - residual;
+               hostdata->connected->SCp.this_residual = residual;
+
+               AM53C974_write_8(DMACMD, DMACMD_IDLE);
+
+               /* if service request missed before, process it now (ugly) */
+               if (hostdata->dma_busy) {
+                       hostdata->dma_busy = 0;
+                       cmdreg = AM53C974_read_8(CMDREG);
+                       statreg = AM53C974_read_8(STATREG);
+                       isreg = AM53C974_read_8(ISREG);
+                       instreg = AM53C974_read_8(INSTREG);
+                       cfifo = AM53C974_cfifo();
+                       AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo,
+                                                     dmastatus);
+               }
+               restore_flags(flags);
+       }
+       if (!(dmastatus & DMASTATUS_SCSIINT)) {
+               return;
+       }
 /*** SCSI related interrupts ***/
-cmdreg = AM53C974_read_8(CMDREG);
-statreg = AM53C974_read_8(STATREG);
-isreg = AM53C974_read_8(ISREG);
-instreg = AM53C974_read_8(INSTREG);
-cfifo = AM53C974_cfifo();
+       cmdreg = AM53C974_read_8(CMDREG);
+       statreg = AM53C974_read_8(STATREG);
+       isreg = AM53C974_read_8(ISREG);
+       instreg = AM53C974_read_8(INSTREG);
+       cfifo = AM53C974_cfifo();
 
-DEB_INTR(printk("scsi%d: statreg: 0x%02x; isreg: 0x%02x; instreg: 0x%02x; cfifo: 0x%02x\n",
-                instance->host_no, statreg, isreg, instreg, cfifo));
+       DEB_INTR(printk("scsi%d: statreg: 0x%02x; isreg: 0x%02x; instreg: 0x%02x; cfifo: 0x%02x\n",
+                    instance->host_no, statreg, isreg, instreg, cfifo));
 
-if (statreg & STATREG_PE) {
-   /* parity error */
+       if (statreg & STATREG_PE) {
+               /* parity error */
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   printk("scsi%d : PARITY error\n", instance->host_no);
-   if (hostdata->connected) hostdata->sync_off[hostdata->connected->target] = 0; /* setup asynchronous transfer */
-   hostdata->aborted = 1; }
-
-if (statreg & STATREG_IOE) {
-   /* illegal operation error */
+               printk("scsi%d : PARITY error\n", instance->host_no);
+               if (hostdata->connected)
+                       hostdata->sync_off[hostdata->connected->target] = 0;    /* setup asynchronous transfer */
+               hostdata->aborted = 1;
+       }
+       if (statreg & STATREG_IOE) {
+               /* illegal operation error */
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   printk("scsi%d : ILLEGAL OPERATION error\n", instance->host_no);
-   printk("cmdreg:  0x%02x; dmacmd:  0x%02x; statreg: 0x%02x; \n"
-          "isreg:   0x%02x; instreg: 0x%02x; cfifo:   0x%02x\n",
-           cmdreg, AM53C974_read_8(DMACMD), statreg, isreg, instreg, cfifo); }
-if (hostdata->in_reset && (instreg & INSTREG_SRST)) {
-   /* RESET INTERRUPT */
+               printk("scsi%d : ILLEGAL OPERATION error\n", instance->host_no);
+               printk("cmdreg:  0x%02x; dmacmd:  0x%02x; statreg: 0x%02x; \n"
+                  "isreg:   0x%02x; instreg: 0x%02x; cfifo:   0x%02x\n",
+                      cmdreg, AM53C974_read_8(DMACMD), statreg, isreg, instreg, cfifo);
+       }
+       if (hostdata->in_reset && (instreg & INSTREG_SRST)) {
+               unsigned long flags;
+               /* RESET INTERRUPT */
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   DEB(printk("Bus reset interrupt received\n"));
-   AM53C974_intr_bus_reset(instance);
-   cli();
-   if (hostdata->connected) {
-      hostdata->connected->result = DID_RESET << 16;
-      hostdata->connected->scsi_done((Scsi_Cmnd *)hostdata->connected);
-      hostdata->connected = NULL; }
-     else { 
-      if (hostdata->sel_cmd) {
-         hostdata->sel_cmd->result = DID_RESET << 16;
-         hostdata->sel_cmd->scsi_done((Scsi_Cmnd *)hostdata->sel_cmd);
-         hostdata->sel_cmd = NULL; }
-      }
-   sti();
-   if (hostdata->in_reset == 1) goto EXIT;
-     else return;
-   }
-
-if (instreg & INSTREG_ICMD) {
-   /* INVALID COMMAND INTERRUPT */
+               DEB(printk("Bus reset interrupt received\n"));
+               AM53C974_intr_bus_reset(instance);
+               save_flags(flags);
+               cli();
+               if (hostdata->connected) {
+                       hostdata->connected->result = DID_RESET << 16;
+                       hostdata->connected->scsi_done((Scsi_Cmnd *) hostdata->connected);
+                       hostdata->connected = NULL;
+               } else {
+                       if (hostdata->sel_cmd) {
+                               hostdata->sel_cmd->result = DID_RESET << 16;
+                               hostdata->sel_cmd->scsi_done((Scsi_Cmnd *) hostdata->sel_cmd);
+                               hostdata->sel_cmd = NULL;
+                       }
+               }
+               restore_flags(flags);
+               if (hostdata->in_reset == 1)
+                       goto EXIT;
+               else
+                       return;
+       }
+       if (instreg & INSTREG_ICMD) {
+               /* INVALID COMMAND INTERRUPT */
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   printk("scsi%d: Invalid command interrupt\n", instance->host_no);
-   printk("cmdreg:  0x%02x; dmacmd:  0x%02x; statreg: 0x%02x; dmastatus: 0x%02x; \n"
-          "isreg:   0x%02x; instreg: 0x%02x; cfifo:   0x%02x\n",
-           cmdreg, AM53C974_read_8(DMACMD), statreg, dmastatus, isreg, instreg, cfifo);
-   panic("scsi%d: cannot recover\n", instance->host_no); }
-
-if (instreg & INSTREG_DIS) {
-   /* DISCONNECT INTERRUPT */
-   DEB_INTR(printk("Disconnect interrupt received; "));
-   cli();
-   AM53C974_intr_disconnect(instance);
-   sti();
-   goto EXIT; }
-
-if (instreg & INSTREG_RESEL) {
-   /* RESELECTION INTERRUPT */
-   DEB_INTR(printk("Reselection interrupt received\n"));
-   cli();
-   AM53C974_intr_reselect(instance, statreg);
-   sti();
-   goto EXIT; }
-
-if (instreg & INSTREG_SO) {
-   DEB_INTR(printk("Successful operation interrupt received\n"));
-   if (hostdata->selecting) {
-      DEB_INTR(printk("DSR completed, starting select\n"));
-      cli();
-      AM53C974_select(instance, (Scsi_Cmnd *)hostdata->sel_cmd,
-                          (hostdata->sel_cmd->cmnd[0] == REQUEST_SENSE) ? 
-                                                  TAG_NONE : TAG_NEXT);
-      hostdata->selecting = 0;
-      AM53C974_set_sync(instance, hostdata->sel_cmd->target);
-      sti();
-      return; }
-
-   if (hostdata->sel_cmd != NULL) {
-      if ( ((isreg & ISREG_IS) != ISREG_OK_NO_STOP) &&
-           ((isreg & ISREG_IS) != ISREG_OK_STOP) ) {
-         /* UNSUCCESSFUL SELECTION */
-         DEB_INTR(printk("unsuccessful selection\n"));
-         cli();
-         hostdata->dma_busy = 0;
-        LIST(hostdata->sel_cmd, hostdata->issue_queue);
-        hostdata->sel_cmd->host_scribble = (unsigned char *)hostdata->issue_queue;
-         hostdata->issue_queue = hostdata->sel_cmd;
-         hostdata->sel_cmd = NULL;
-         hostdata->selecting = 0;
-         sti();
-         goto EXIT; }
-        else {
-         /* SUCCESSFUL SELECTION */
-         DEB(printk("successful selection; cmd=0x%02lx\n", (long)hostdata->sel_cmd));
-         cli();
-         hostdata->dma_busy = 0;
-         hostdata->disconnecting = 0;
-         hostdata->connected = hostdata->sel_cmd;
-         hostdata->sel_cmd = NULL;
-         hostdata->selecting = 0;
+               printk("scsi%d: Invalid command interrupt\n", instance->host_no);
+               printk("cmdreg:  0x%02x; dmacmd:  0x%02x; statreg: 0x%02x; dmastatus: 0x%02x; \n"
+                  "isreg:   0x%02x; instreg: 0x%02x; cfifo:   0x%02x\n",
+                      cmdreg, AM53C974_read_8(DMACMD), statreg, dmastatus, isreg, instreg, cfifo);
+               panic("scsi%d: cannot recover\n", instance->host_no);
+       }
+       if (instreg & INSTREG_DIS) {
+               unsigned long flags;
+               /* DISCONNECT INTERRUPT */
+               DEB_INTR(printk("Disconnect interrupt received; "));
+               save_flags(flags);
+               cli();
+               AM53C974_intr_disconnect(instance);
+               restore_flags(flags);
+               goto EXIT;
+       }
+       if (instreg & INSTREG_RESEL) {
+               unsigned long flags;
+               /* RESELECTION INTERRUPT */
+               DEB_INTR(printk("Reselection interrupt received\n"));
+               save_flags(flags);
+               cli();
+               AM53C974_intr_reselect(instance, statreg);
+               restore_flags(flags);
+               goto EXIT;
+       }
+       if (instreg & INSTREG_SO) {
+               DEB_INTR(printk("Successful operation interrupt received\n"));
+               if (hostdata->selecting) {
+                       unsigned long flags;
+                       DEB_INTR(printk("DSR completed, starting select\n"));
+                       save_flags(flags);
+                       cli();
+                       AM53C974_select(instance, (Scsi_Cmnd *) hostdata->sel_cmd,
+                         (hostdata->sel_cmd->cmnd[0] == REQUEST_SENSE) ?
+                                       TAG_NONE : TAG_NEXT);
+                       hostdata->selecting = 0;
+                       AM53C974_set_sync(instance, hostdata->sel_cmd->target);
+                       restore_flags(flags);
+                       return;
+               }
+               if (hostdata->sel_cmd != NULL) {
+                       if (((isreg & ISREG_IS) != ISREG_OK_NO_STOP) &&
+                           ((isreg & ISREG_IS) != ISREG_OK_STOP)) {
+                               unsigned long flags;
+                               /* UNSUCCESSFUL SELECTION */
+                               DEB_INTR(printk("unsuccessful selection\n"));
+                               save_flags(flags);
+                               cli();
+                               hostdata->dma_busy = 0;
+                               LIST(hostdata->sel_cmd, hostdata->issue_queue);
+                               hostdata->sel_cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
+                               hostdata->issue_queue = hostdata->sel_cmd;
+                               hostdata->sel_cmd = NULL;
+                               hostdata->selecting = 0;
+                               restore_flags(flags);
+                               goto EXIT;
+                       } else {
+                               unsigned long flags;
+                               /* SUCCESSFUL SELECTION */
+                               DEB(printk("successful selection; cmd=0x%02lx\n", (long) hostdata->sel_cmd));
+                               save_flags(flags);
+                               cli();
+                               hostdata->dma_busy = 0;
+                               hostdata->disconnecting = 0;
+                               hostdata->connected = hostdata->sel_cmd;
+                               hostdata->sel_cmd = NULL;
+                               hostdata->selecting = 0;
 #ifdef SCSI2
-         if (!hostdata->connected->device->tagged_queue)
-#endif    
-            hostdata->busy[hostdata->connected->target] |= (1 << hostdata->connected->lun);
-         /* very strange -- use_sg is sometimes nonzero for request sense commands !! */
-         if ((hostdata->connected->cmnd[0] == REQUEST_SENSE) && hostdata->connected->use_sg) {
-            DEB(printk("scsi%d: REQUEST_SENSE command with nonzero use_sg\n", instance->host_no));
-            KEYWAIT();
-            hostdata->connected->use_sg = 0; }
-         initialize_SCp((Scsi_Cmnd *)hostdata->connected);
-         hostdata->connected->SCp.phase = PHASE_CMDOUT;
-         AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
-         sti();
-         return; }
-      }
-     else {
-      cli();
-      AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
-      sti();
-      return; }
-   }
-    
-if (instreg & INSTREG_SR) {
-   DEB_INTR(printk("Service request interrupt received, "));
-   if (hostdata->connected) {
-      DEB_INTR(printk("calling information_transfer\n"));
-      cli();
-      AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
-      sti(); }
-     else {
-      printk("scsi%d: weird: service request when no command connected\n", instance->host_no);
-      AM53C974_write_8(CMDREG, CMDREG_CFIFO); }   /* clear FIFO */
-   return;
-   }
-
-EXIT:
-  DEB_INTR(printk("intr: starting main\n"));
-  run_main();
-  DEB_INTR(printk("end of intr\n"));
+                               if (!hostdata->connected->device->tagged_queue)
+#endif
+                                       hostdata->busy[hostdata->connected->target] |= (1 << hostdata->connected->lun);
+                               /* very strange -- use_sg is sometimes nonzero for request sense commands !! */
+                               if ((hostdata->connected->cmnd[0] == REQUEST_SENSE) && hostdata->connected->use_sg) {
+                                       DEB(printk("scsi%d: REQUEST_SENSE command with nonzero use_sg\n", instance->host_no));
+                                       KEYWAIT();
+                                       hostdata->connected->use_sg = 0;
+                               }
+                               initialize_SCp((Scsi_Cmnd *) hostdata->connected);
+                               hostdata->connected->SCp.phase = PHASE_CMDOUT;
+                               AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
+                               restore_flags(flags);
+                               return;
+                       }
+               } else {
+                       unsigned long flags;
+                       save_flags(flags);
+                       cli();
+                       AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
+                       restore_flags(flags);
+                       return;
+               }
+       }
+       if (instreg & INSTREG_SR) {
+               DEB_INTR(printk("Service request interrupt received, "));
+               if (hostdata->connected) {
+                       unsigned long flags;
+                       DEB_INTR(printk("calling information_transfer\n"));
+                       save_flags(flags);
+                       cli();
+                       AM53C974_information_transfer(instance, statreg, isreg, instreg, cfifo, dmastatus);
+                       restore_flags(flags);
+               } else {
+                       printk("scsi%d: weird: service request when no command connected\n", instance->host_no);
+                       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+               }               /* clear FIFO */
+               return;
+       }
+       EXIT:
+           DEB_INTR(printk("intr: starting main\n"));
+       run_main();
+       DEB_INTR(printk("end of intr\n"));
 }
 
 /************************************************************************** 
@@ -1242,114 +1312,120 @@ EXIT:
 * 
 * Returns : nothing
 **************************************************************************/
-static void AM53C974_intr_disconnect(struct Scsi_Host *instance) 
+static void AM53C974_intr_disconnect(struct Scsi_Host *instance)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-Scsi_Cmnd                *cmd;
-AM53C974_setio(instance);
-
-if (hostdata->sel_cmd != NULL) {
-   /* normal selection timeout, typical for nonexisting targets */
-   cmd = (Scsi_Cmnd *)hostdata->sel_cmd;
-   DEB_INTR(printk("bad target\n"));
-   cmd->result = DID_BAD_TARGET << 16;
-   goto EXIT_FINISHED; }
-
-if (!hostdata->connected) {
-   /* can happen if controller was reset, a device tried to reconnect,
-      failed and disconnects now */
-   AM53C974_write_8(CMDREG, CMDREG_CFIFO);
-   return; }
-
-if (hostdata->disconnecting) {
-   /* target sent disconnect message, so we are prepared */
-   cmd = (Scsi_Cmnd *)hostdata->connected;
-   AM53C974_set_async(instance, cmd->target);
-   DEB_INTR(printk("scsi%d : disc. from cmnd %d for ta %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-   if (cmd->device->disconnect) {
-      /* target wants to reselect later */
-      DEB_INTR(printk("ok, re-enabling selection\n"));
-      LIST(cmd,hostdata->disconnected_queue);
-      cmd->host_scribble = (unsigned char *)hostdata->disconnected_queue;
-      hostdata->disconnected_queue = cmd;
-      DEB_QUEUE(printk("scsi%d : command for target %d lun %d this %d was moved from connected to"
-                      "  the disconnected_queue\n", instance->host_no, cmd->target,
-                        cmd->lun, hostdata->disconnected_queue->SCp.this_residual));
-      DEB_QUEUE(AM53C974_print_queues(instance));
-      goto EXIT_UNFINISHED; }
-     else {
-      /* target does not want to reselect later, we are really finished */
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       Scsi_Cmnd *cmd;
+       AM53C974_setio(instance);
+
+       if (hostdata->sel_cmd != NULL) {
+               /* normal selection timeout, typical for nonexisting targets */
+               cmd = (Scsi_Cmnd *) hostdata->sel_cmd;
+               DEB_INTR(printk("bad target\n"));
+               cmd->result = DID_BAD_TARGET << 16;
+               goto EXIT_FINISHED;
+       }
+       if (!hostdata->connected) {
+               /* can happen if controller was reset, a device tried to reconnect,
+                  failed and disconnects now */
+               AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+               return;
+       }
+       if (hostdata->disconnecting) {
+               /* target sent disconnect message, so we are prepared */
+               cmd = (Scsi_Cmnd *) hostdata->connected;
+               AM53C974_set_async(instance, cmd->target);
+               DEB_INTR(printk("scsi%d : disc. from cmnd %d for ta %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               if (cmd->device->disconnect) {
+                       /* target wants to reselect later */
+                       DEB_INTR(printk("ok, re-enabling selection\n"));
+                       LIST(cmd, hostdata->disconnected_queue);
+                       cmd->host_scribble = (unsigned char *) hostdata->disconnected_queue;
+                       hostdata->disconnected_queue = cmd;
+                       DEB_QUEUE(printk("scsi%d : command for target %d lun %d this %d was moved from connected to"
+                                        "  the disconnected_queue\n", instance->host_no, cmd->target,
+                                        cmd->lun, hostdata->disconnected_queue->SCp.this_residual));
+                       DEB_QUEUE(AM53C974_print_queues(instance));
+                       goto EXIT_UNFINISHED;
+               } else {
+                       /* target does not want to reselect later, we are really finished */
 #ifdef AM53C974_DEBUG
-      if (cmd->cmnd[0] == REQUEST_SENSE) {
-        int i;
-        printk("Request sense data dump:\n");
-        for (i = 0; i < cmd->request_bufflen; i++) {
-             printk("%02x ", *((char *)(cmd->request_buffer) + i));
-             if (i && !(i % 16)) printk("\n"); }
-        printk("\n"); }
+                       if (cmd->cmnd[0] == REQUEST_SENSE) {
+                               int i;
+                               printk("Request sense data dump:\n");
+                               for (i = 0; i < cmd->request_bufflen; i++) {
+                                       printk("%02x ", *((char *) (cmd->request_buffer) + i));
+                                       if (i && !(i % 16))
+                                               printk("\n");
+                               }
+                               printk("\n");
+                       }
 #endif
-      goto EXIT_FINISHED; } /* !cmd->device->disconnect */
-   } /* if (hostdata->disconnecting) */
-
-/* no disconnect message received; unexpected disconnection */
-cmd = (Scsi_Cmnd *)hostdata->connected;
-if (cmd) {
+                       goto EXIT_FINISHED;
+               }               /* !cmd->device->disconnect */
+       }                       /* if (hostdata->disconnecting) */
+       /* no disconnect message received; unexpected disconnection */
+       cmd = (Scsi_Cmnd *) hostdata->connected;
+       if (cmd) {
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-   AM53C974_set_async(instance, cmd->target);
-   printk("scsi%d: Unexpected disconnect; phase: %d; target: %d; this_residual: %d; buffers_residual: %d; message: %d\n",
-           instance->host_no, cmd->SCp.phase, cmd->target, cmd->SCp.this_residual, cmd->SCp.buffers_residual,
-           cmd->SCp.Message);
-   printk("cmdreg: 0x%02x; statreg: 0x%02x; isreg: 0x%02x; cfifo: 0x%02x\n",
-          AM53C974_read_8(CMDREG), AM53C974_read_8(STATREG), AM53C974_read_8(ISREG),
-           AM53C974_read_8(CFIREG) & CFIREG_CF);
-
-    if ((hostdata->last_message[0] == EXTENDED_MESSAGE) && 
-        (hostdata->last_message[2] == EXTENDED_SDTR)) {
-        /* sync. negotiation was aborted, setup asynchronous transfer with target */
-        hostdata->sync_off[cmd->target] = 0; }
-   if (hostdata->aborted || hostdata->msgout[0] == ABORT)
-      cmd->result = DID_ABORT << 16;
-     else
-      cmd->result = DID_ERROR << 16;
-   goto EXIT_FINISHED; }
-
-EXIT_FINISHED:
-hostdata->aborted = 0;
-hostdata->msgout[0] = NOP;
-hostdata->sel_cmd = NULL;
-hostdata->connected = NULL;
-hostdata->selecting = 0;
-hostdata->disconnecting = 0;
-hostdata->dma_busy = 0;
-hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
-AM53C974_write_8(CMDREG, CMDREG_CFIFO);
-DEB(printk("disconnect; issue_queue: 0x%lx, disconnected_queue: 0x%lx\n", 
-       (long)hostdata->issue_queue, (long)hostdata->disconnected_queue));
-cmd->scsi_done(cmd);
-
-if (!hostdata->selecting) {
-   AM53C974_set_async(instance, cmd->target); 
-   AM53C974_write_8(CMDREG, CMDREG_ESR); } /* allow reselect */
-return;
-
-EXIT_UNFINISHED:
-hostdata->msgout[0] = NOP;
-hostdata->sel_cmd = NULL;
-hostdata->connected = NULL;
-hostdata->aborted = 0;
-hostdata->selecting = 0;
-hostdata->disconnecting = 0;
-hostdata->dma_busy = 0;
-DEB(printk("disconnect; issue_queue: 0x%lx, disconnected_queue: 0x%lx\n", 
-       (long)hostdata->issue_queue, (long)hostdata->disconnected_queue));
-if (!hostdata->selecting) {
-   AM53C974_set_async(instance, cmd->target); 
-   AM53C974_write_8(CMDREG, CMDREG_ESR); } /* allow reselect */
-return;
+               AM53C974_set_async(instance, cmd->target);
+               printk("scsi%d: Unexpected disconnect; phase: %d; target: %d; this_residual: %d; buffers_residual: %d; message: %d\n",
+                      instance->host_no, cmd->SCp.phase, cmd->target, cmd->SCp.this_residual, cmd->SCp.buffers_residual,
+                      cmd->SCp.Message);
+               printk("cmdreg: 0x%02x; statreg: 0x%02x; isreg: 0x%02x; cfifo: 0x%02x\n",
+                      AM53C974_read_8(CMDREG), AM53C974_read_8(STATREG), AM53C974_read_8(ISREG),
+                      AM53C974_read_8(CFIREG) & CFIREG_CF);
+
+               if ((hostdata->last_message[0] == EXTENDED_MESSAGE) &&
+                   (hostdata->last_message[2] == EXTENDED_SDTR)) {
+                       /* sync. negotiation was aborted, setup asynchronous transfer with target */
+                       hostdata->sync_off[cmd->target] = 0;
+               }
+               if (hostdata->aborted || hostdata->msgout[0] == ABORT)
+                       cmd->result = DID_ABORT << 16;
+               else
+                       cmd->result = DID_ERROR << 16;
+               goto EXIT_FINISHED;
+       }
+       EXIT_FINISHED:
+           hostdata->aborted = 0;
+       hostdata->msgout[0] = NOP;
+       hostdata->sel_cmd = NULL;
+       hostdata->connected = NULL;
+       hostdata->selecting = 0;
+       hostdata->disconnecting = 0;
+       hostdata->dma_busy = 0;
+       hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
+       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+       DEB(printk("disconnect; issue_queue: 0x%lx, disconnected_queue: 0x%lx\n",
+                  (long) hostdata->issue_queue, (long) hostdata->disconnected_queue));
+       cmd->scsi_done(cmd);
+
+       if (!hostdata->selecting) {
+               AM53C974_set_async(instance, cmd->target);
+               AM53C974_write_8(CMDREG, CMDREG_ESR);
+       }                       /* allow reselect */
+       return;
+
+       EXIT_UNFINISHED:
+           hostdata->msgout[0] = NOP;
+       hostdata->sel_cmd = NULL;
+       hostdata->connected = NULL;
+       hostdata->aborted = 0;
+       hostdata->selecting = 0;
+       hostdata->disconnecting = 0;
+       hostdata->dma_busy = 0;
+       DEB(printk("disconnect; issue_queue: 0x%lx, disconnected_queue: 0x%lx\n",
+                  (long) hostdata->issue_queue, (long) hostdata->disconnected_queue));
+       if (!hostdata->selecting) {
+               AM53C974_set_async(instance, cmd->target);
+               AM53C974_write_8(CMDREG, CMDREG_ESR);
+       }                       /* allow reselect */
+       return;
 }
 
 /************************************************************************** 
@@ -1367,41 +1443,43 @@ return;
 *
 * Note: we assume here that fastclk is enabled
 **************************************************************************/
-static int AM53C974_sync_neg(struct Scsi_Host *instance, int target, unsigned char *msg) 
+static int AM53C974_sync_neg(struct Scsi_Host *instance, int target, unsigned char *msg)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-int                      period, offset, i, rate, rate_rem;
-AM53C974_setio(instance);
-
-period = (DEF_CLK * msg[3] * 8 + 1000) / 2000;
-if (period < MIN_PERIOD) {
-    period = MIN_PERIOD;
-    hostdata->msgout[3] = period / 4; }
-   else
-    if (period > MAX_PERIOD) {
-       period = MAX_PERIOD;
-       hostdata->msgout[3] = period / 4; }
-      else
-       hostdata->msgout[3] = msg[3];
-offset = msg[4]; 
-if (offset > MAX_OFFSET) offset = MAX_OFFSET;
-hostdata->msgout[4] = offset;
-hostdata->sync_per[target] = period;
-hostdata->sync_off[target] = offset;
-for (i = 0; i < 3; i++) hostdata->msgout[i] = msg[i];
-if ((hostdata->msgout[3] != msg[3]) || (msg[4] != offset)) return(1);
-
-rate = DEF_CLK / period;
-rate_rem = 10 * (DEF_CLK - period * rate) / period;
-
-if (offset)
-   printk("\ntarget %d: rate=%d.%d Mhz, synchronous, sync offset=%d bytes\n",
-          target, rate, rate_rem, offset);
-  else
-   printk("\ntarget %d: rate=%d.%d Mhz, asynchronous\n", target, rate, rate_rem);
-
-return(0);
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       int period, offset, i, rate, rate_rem;
+       AM53C974_setio(instance);
+
+       period = (DEF_CLK * msg[3] * 8 + 1000) / 2000;
+       if (period < MIN_PERIOD) {
+               period = MIN_PERIOD;
+               hostdata->msgout[3] = period / 4;
+       } else if (period > MAX_PERIOD) {
+               period = MAX_PERIOD;
+               hostdata->msgout[3] = period / 4;
+       } else
+               hostdata->msgout[3] = msg[3];
+       offset = msg[4];
+       if (offset > MAX_OFFSET)
+               offset = MAX_OFFSET;
+       hostdata->msgout[4] = offset;
+       hostdata->sync_per[target] = period;
+       hostdata->sync_off[target] = offset;
+       for (i = 0; i < 3; i++)
+               hostdata->msgout[i] = msg[i];
+       if ((hostdata->msgout[3] != msg[3]) || (msg[4] != offset))
+               return (1);
+
+       rate = DEF_CLK / period;
+       rate_rem = 10 * (DEF_CLK - period * rate) / period;
+
+       if (offset)
+               printk("\ntarget %d: rate=%d.%d Mhz, synchronous, sync offset=%d bytes\n",
+                      target, rate, rate_rem, offset);
+       else
+               printk("\ntarget %d: rate=%d.%d Mhz, asynchronous\n", target, rate, rate_rem);
+
+       return (0);
 }
 
 /************************************************************************** 
@@ -1416,12 +1494,12 @@ return(0);
 **************************************************************************/
 static __inline__ void AM53C974_set_async(struct Scsi_Host *instance, int target)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-AM53C974_setio(instance);
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       AM53C974_setio(instance);
 
-AM53C974_write_8(STPREG, hostdata->sync_per[target]);
-AM53C974_write_8(SOFREG, (DEF_SOF_RAD<<6) | (DEF_SOF_RAA<<4));
+       AM53C974_write_8(STPREG, hostdata->sync_per[target]);
+       AM53C974_write_8(SOFREG, (DEF_SOF_RAD << 6) | (DEF_SOF_RAA << 4));
 }
 
 /************************************************************************** 
@@ -1436,13 +1514,13 @@ AM53C974_write_8(SOFREG, (DEF_SOF_RAD<<6) | (DEF_SOF_RAA<<4));
 **************************************************************************/
 static __inline__ void AM53C974_set_sync(struct Scsi_Host *instance, int target)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-AM53C974_setio(instance);
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       AM53C974_setio(instance);
 
-AM53C974_write_8(STPREG, hostdata->sync_per[target]);
-AM53C974_write_8(SOFREG, (SOFREG_SO & hostdata->sync_off[target]) | 
-                (DEF_SOF_RAD<<6) | (DEF_SOF_RAA<<4));
+       AM53C974_write_8(STPREG, hostdata->sync_per[target]);
+       AM53C974_write_8(SOFREG, (SOFREG_SO & hostdata->sync_off[target]) |
+                        (DEF_SOF_RAD << 6) | (DEF_SOF_RAA << 4));
 }
 
 /***********************************************************************
@@ -1462,151 +1540,164 @@ AM53C974_write_8(SOFREG, (SOFREG_SO & hostdata->sync_off[target]) |
 *                                                                      *
 * Returns : nothing                                                    *
 ************************************************************************/
-static void AM53C974_information_transfer(struct Scsi_Host *instance, 
-                                          unsigned char statreg, unsigned char isreg,
-                                          unsigned char instreg, unsigned char cfifo,
-                                          unsigned char dmastatus)
+static void AM53C974_information_transfer(struct Scsi_Host *instance,
+                             unsigned char statreg, unsigned char isreg,
+                             unsigned char instreg, unsigned char cfifo,
+                                         unsigned char dmastatus)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-Scsi_Cmnd                *cmd = (Scsi_Cmnd *)hostdata->connected;
-int                      ret, i, len, residual=-1;
-AM53C974_setio(instance);
-
-DEB_INFO(printk(SEPARATOR_LINE));
-switch (statreg & STATREG_PHASE) {     /* scsi phase */
-  case PHASE_DATAOUT:
-    DEB_INFO(printk("Dataout phase; cmd=0x%lx, sel_cmd=0x%lx, this_residual=%d, buffers_residual=%d\n",
-                    (long)hostdata->connected, (long)hostdata->sel_cmd, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
-    cmd->SCp.phase = PHASE_DATAOUT;
-    goto PHASE_DATA_IO;
-
-  case PHASE_DATAIN:
-    DEB_INFO(printk("Datain phase; cmd=0x%lx, sel_cmd=0x%lx, this_residual=%d, buffers_residual=%d\n",
-                     (long)hostdata->connected, (long)hostdata->sel_cmd, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
-    cmd->SCp.phase = PHASE_DATAIN;
-    PHASE_DATA_IO:
-    if (hostdata->aborted) {
-       AM53C974_write_8(DMACMD, DMACMD_IDLE);
-       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
-       AM53C974_write_8(CMDREG, CMDREG_SATN);
-       return; }
-    if ((!cmd->SCp.this_residual) && cmd->SCp.buffers_residual) {
-       cmd->SCp.buffer++;
-       cmd->SCp.buffers_residual--;
-       cmd->SCp.ptr = (unsigned char *)cmd->SCp.buffer->address;
-       cmd->SCp.this_residual = cmd->SCp.buffer->length; }
-    if (cmd->SCp.this_residual) {
-       if (!(AM53C974_read_8(DMACMD) & DMACMD_START)) {
-          hostdata->dma_busy = 0;
-          AM53C974_transfer_dma(instance, statreg & STATREG_IO,
-                                (unsigned long)cmd->SCp.this_residual,
-                                cmd->SCp.ptr); }
-         else
-          hostdata->dma_busy = 1;
-       }
-    return;
-
-  case PHASE_MSGIN:
-    DEB_INFO(printk("Message-In phase; cmd=0x%lx, sel_cmd=0x%lx\n",
-                    (long)hostdata->connected, (long)hostdata->sel_cmd));
-    AM53C974_set_async(instance, cmd->target);
-    if (cmd->SCp.phase == PHASE_DATAIN)
-       AM53C974_dma_blast(instance, dmastatus, statreg);
-    if ((cmd->SCp.phase == PHASE_DATAOUT) && (AM53C974_read_8(DMACMD) & DMACMD_START)) {
-       AM53C974_write_8(DMACMD, DMACMD_IDLE);
-       residual = cfifo + (AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
-                          (AM53C974_read_8(CTCHREG) << 16));
-       cmd->SCp.ptr += cmd->SCp.this_residual - residual;
-       cmd->SCp.this_residual = residual;
-       if (cfifo) { AM53C974_write_8(CMDREG, CMDREG_CFIFO); cfifo = 0; }
-       }
-    if (cmd->SCp.phase == PHASE_STATIN) {
-       while ((AM53C974_read_8(CFIREG) & CFIREG_CF) < 2) ;
-       cmd->SCp.Status = AM53C974_read_8(FFREG);
-       cmd->SCp.Message = AM53C974_read_8(FFREG); 
-       DEB_INFO(printk("Message-In phase; status=0x%02x, message=0x%02x\n",
-                       cmd->SCp.Status, cmd->SCp.Message));
-       ret = AM53C974_message(instance, cmd, cmd->SCp.Message); }
-      else {
-       if (!cfifo) {
-          AM53C974_write_8(CMDREG, CMDREG_IT); 
-          AM53C974_poll_int();
-          cmd->SCp.Message = AM53C974_read_8(FFREG);
-          }
-       ret = AM53C974_message(instance, cmd, cmd->SCp.Message);
-       }
-    cmd->SCp.phase = PHASE_MSGIN;
-    AM53C974_set_sync(instance, cmd->target);
-    break;
-  case PHASE_MSGOUT:
-    DEB_INFO(printk("Message-Out phase; cfifo=%d; msgout[0]=0x%02x\n",
-                    AM53C974_read_8(CFIREG) & CFIREG_CF, hostdata->msgout[0]));
-    AM53C974_write_8(DMACMD, DMACMD_IDLE);
-    AM53C974_set_async(instance, cmd->target);
-    for (i = 0; i < sizeof(hostdata->last_message); i++) 
-        hostdata->last_message[i] = hostdata->msgout[i];
-    if ((hostdata->msgout[0] == 0) || INSIDE(hostdata->msgout[0], 0x02, 0x1F) || 
-        INSIDE(hostdata->msgout[0], 0x80, 0xFF)) 
-       len = 1;
-      else {
-       if (hostdata->msgout[0] == EXTENDED_MESSAGE) {
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
+       int ret, i, len, residual = -1;
+       AM53C974_setio(instance);
+
+       DEB_INFO(printk(SEPARATOR_LINE));
+       switch (statreg & STATREG_PHASE) {      /* scsi phase */
+               case PHASE_DATAOUT:
+                   DEB_INFO(printk("Dataout phase; cmd=0x%lx, sel_cmd=0x%lx, this_residual=%d, buffers_residual=%d\n",
+                                   (long) hostdata->connected, (long) hostdata->sel_cmd, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
+               cmd->SCp.phase = PHASE_DATAOUT;
+               goto PHASE_DATA_IO;
+
+               case PHASE_DATAIN:
+                   DEB_INFO(printk("Datain phase; cmd=0x%lx, sel_cmd=0x%lx, this_residual=%d, buffers_residual=%d\n",
+                                   (long) hostdata->connected, (long) hostdata->sel_cmd, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
+               cmd->SCp.phase = PHASE_DATAIN;
+               PHASE_DATA_IO:
+                   if (hostdata->aborted) {
+                       AM53C974_write_8(DMACMD, DMACMD_IDLE);
+                       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+                       return;
+               }
+               if ((!cmd->SCp.this_residual) && cmd->SCp.buffers_residual) {
+                       cmd->SCp.buffer++;
+                       cmd->SCp.buffers_residual--;
+                       cmd->SCp.ptr = (unsigned char *) cmd->SCp.buffer->address;
+                       cmd->SCp.this_residual = cmd->SCp.buffer->length;
+               }
+               if (cmd->SCp.this_residual) {
+                       if (!(AM53C974_read_8(DMACMD) & DMACMD_START)) {
+                               hostdata->dma_busy = 0;
+                               AM53C974_transfer_dma(instance, statreg & STATREG_IO,
+                                 (unsigned long) cmd->SCp.this_residual,
+                                                     cmd->SCp.ptr);
+                       } else
+                               hostdata->dma_busy = 1;
+               }
+               return;
+
+               case PHASE_MSGIN:
+                   DEB_INFO(printk("Message-In phase; cmd=0x%lx, sel_cmd=0x%lx\n",
+                 (long) hostdata->connected, (long) hostdata->sel_cmd));
+               AM53C974_set_async(instance, cmd->target);
+               if (cmd->SCp.phase == PHASE_DATAIN)
+                       AM53C974_dma_blast(instance, dmastatus, statreg);
+               if ((cmd->SCp.phase == PHASE_DATAOUT) && (AM53C974_read_8(DMACMD) & DMACMD_START)) {
+                       AM53C974_write_8(DMACMD, DMACMD_IDLE);
+                       residual = cfifo + (AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
+                                      (AM53C974_read_8(CTCHREG) << 16));
+                       cmd->SCp.ptr += cmd->SCp.this_residual - residual;
+                       cmd->SCp.this_residual = residual;
+                       if (cfifo) {
+                               AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+                               cfifo = 0;
+                       }
+               }
+               if (cmd->SCp.phase == PHASE_STATIN) {
+                       while ((AM53C974_read_8(CFIREG) & CFIREG_CF) < 2);
+                       cmd->SCp.Status = AM53C974_read_8(FFREG);
+                       cmd->SCp.Message = AM53C974_read_8(FFREG);
+                       DEB_INFO(printk("Message-In phase; status=0x%02x, message=0x%02x\n",
+                                    cmd->SCp.Status, cmd->SCp.Message));
+                       ret = AM53C974_message(instance, cmd, cmd->SCp.Message);
+               } else {
+                       if (!cfifo) {
+                               AM53C974_write_8(CMDREG, CMDREG_IT);
+                               AM53C974_poll_int();
+                               cmd->SCp.Message = AM53C974_read_8(FFREG);
+                       }
+                       ret = AM53C974_message(instance, cmd, cmd->SCp.Message);
+               }
+               cmd->SCp.phase = PHASE_MSGIN;
+               AM53C974_set_sync(instance, cmd->target);
+               break;
+               case PHASE_MSGOUT:
+                   DEB_INFO(printk("Message-Out phase; cfifo=%d; msgout[0]=0x%02x\n",
+                                   AM53C974_read_8(CFIREG) & CFIREG_CF, hostdata->msgout[0]));
+               AM53C974_write_8(DMACMD, DMACMD_IDLE);
+               AM53C974_set_async(instance, cmd->target);
+               for (i = 0; i < sizeof(hostdata->last_message); i++)
+                       hostdata->last_message[i] = hostdata->msgout[i];
+               if ((hostdata->msgout[0] == 0) || INSIDE(hostdata->msgout[0], 0x02, 0x1F) ||
+                   INSIDE(hostdata->msgout[0], 0x80, 0xFF))
+                       len = 1;
+               else {
+                       if (hostdata->msgout[0] == EXTENDED_MESSAGE) {
 #ifdef AM53C974_DEBUG_INFO
-          printk("Extended message dump:\n");
-          for (i = 0; i < hostdata->msgout[1] + 2; i++) {
-              printk("%02x ", hostdata->msgout[i]);
-              if (i && !(i % 16)) printk("\n"); }
-          printk("\n");
+                               printk("Extended message dump:\n");
+                               for (i = 0; i < hostdata->msgout[1] + 2; i++) {
+                                       printk("%02x ", hostdata->msgout[i]);
+                                       if (i && !(i % 16))
+                                               printk("\n");
+                               }
+                               printk("\n");
 #endif
-          len = hostdata->msgout[1] + 2; }
-         else
-          len = 2;
-       }
-    for (i = 0; i < len; i++) AM53C974_write_8(FFREG, hostdata->msgout[i]);
-    AM53C974_write_8(CMDREG, CMDREG_IT);
-    cmd->SCp.phase = PHASE_MSGOUT;
-    hostdata->msgout[0] = NOP;
-    AM53C974_set_sync(instance, cmd->target);
-    break;
-
-  case PHASE_CMDOUT:
-    DEB_INFO(printk("Command-Out phase\n"));
-    AM53C974_set_async(instance, cmd->target);
-    for (i = 0; i < cmd->cmd_len; i++) AM53C974_write_8(FFREG, cmd->cmnd[i]);
-    AM53C974_write_8(CMDREG, CMDREG_IT);
-    cmd->SCp.phase = PHASE_CMDOUT;
-    AM53C974_set_sync(instance, cmd->target);
-    break;
-
-  case PHASE_STATIN:
-    DEB_INFO(printk("Status phase\n"));
-    if (cmd->SCp.phase == PHASE_DATAIN)
-       AM53C974_dma_blast(instance, dmastatus, statreg);
-    AM53C974_set_async(instance, cmd->target);
-    if (cmd->SCp.phase == PHASE_DATAOUT) {
-       unsigned long residual;
-
-       if (AM53C974_read_8(DMACMD) & DMACMD_START) {
-          AM53C974_write_8(DMACMD, DMACMD_IDLE);
-          residual = cfifo + (AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
-                              (AM53C974_read_8(CTCHREG) << 16));
-          cmd->SCp.ptr += cmd->SCp.this_residual - residual;
-          cmd->SCp.this_residual = residual; }
-       if (cfifo) { AM53C974_write_8(CMDREG, CMDREG_CFIFO); cfifo = 0; }
-       }
-    cmd->SCp.phase = PHASE_STATIN;
-    AM53C974_write_8(CMDREG, CMDREG_ICCS);  /* command complete */
-    break;
-
-  case PHASE_RES_0:
-  case PHASE_RES_1:
+                               len = hostdata->msgout[1] + 2;
+                       } else
+                               len = 2;
+               }
+               for (i = 0; i < len; i++)
+                       AM53C974_write_8(FFREG, hostdata->msgout[i]);
+               AM53C974_write_8(CMDREG, CMDREG_IT);
+               cmd->SCp.phase = PHASE_MSGOUT;
+               hostdata->msgout[0] = NOP;
+               AM53C974_set_sync(instance, cmd->target);
+               break;
+
+               case PHASE_CMDOUT:
+                   DEB_INFO(printk("Command-Out phase\n"));
+               AM53C974_set_async(instance, cmd->target);
+               for (i = 0; i < cmd->cmd_len; i++)
+                       AM53C974_write_8(FFREG, cmd->cmnd[i]);
+               AM53C974_write_8(CMDREG, CMDREG_IT);
+               cmd->SCp.phase = PHASE_CMDOUT;
+               AM53C974_set_sync(instance, cmd->target);
+               break;
+
+               case PHASE_STATIN:
+                   DEB_INFO(printk("Status phase\n"));
+               if (cmd->SCp.phase == PHASE_DATAIN)
+                       AM53C974_dma_blast(instance, dmastatus, statreg);
+               AM53C974_set_async(instance, cmd->target);
+               if (cmd->SCp.phase == PHASE_DATAOUT) {
+                       unsigned long residual;
+
+                       if (AM53C974_read_8(DMACMD) & DMACMD_START) {
+                               AM53C974_write_8(DMACMD, DMACMD_IDLE);
+                               residual = cfifo + (AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
+                                      (AM53C974_read_8(CTCHREG) << 16));
+                               cmd->SCp.ptr += cmd->SCp.this_residual - residual;
+                               cmd->SCp.this_residual = residual;
+                       }
+                       if (cfifo) {
+                               AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+                               cfifo = 0;
+                       }
+               }
+               cmd->SCp.phase = PHASE_STATIN;
+               AM53C974_write_8(CMDREG, CMDREG_ICCS);  /* command complete */
+               break;
+
+               case PHASE_RES_0:
+                   case PHASE_RES_1:
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+                   deb_stop = 1;
 #endif
-    DEB_INFO(printk("Reserved phase\n"));
-    break;
-  }
-KEYWAIT();
+               DEB_INFO(printk("Reserved phase\n"));
+               break;
+       }
+       KEYWAIT();
 }
 
 /******************************************************************************
@@ -1621,21 +1712,21 @@ KEYWAIT();
 * 
 * Returns : 1 on success, 0 on failure.
 **************************************************************************/
-static int AM53C974_message(struct Scsi_Host *instance, Scsi_Cmnd *cmd,
-                            unsigned char msg)
+static int AM53C974_message(struct Scsi_Host *instance, Scsi_Cmnd * cmd,
+                           unsigned char msg)
 {
-AM53C974_local_declare(); 
-static unsigned char     extended_msg[10];
-unsigned char            statreg;
-int                      len, ret = 0;
-unsigned char            *p;
+       AM53C974_local_declare();
+       static unsigned char extended_msg[10];
+       unsigned char statreg;
+       int len, ret = 0;
+       unsigned char *p;
 #ifdef AM53C974_DEBUG_MSG
-int                      j;
+       int j;
 #endif
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-AM53C974_setio(instance);
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       AM53C974_setio(instance);
 
-DEB_MSG(printk(SEPARATOR_LINE));
+       DEB_MSG(printk(SEPARATOR_LINE));
 
 /* Linking lets us reduce the time required to get the 
  * next command out to the device, hopefully this will
@@ -1644,206 +1735,217 @@ DEB_MSG(printk(SEPARATOR_LINE));
  * In the current implementation proposal, low level drivers
  * merely have to start the next command, pointed to by 
  * next_link, done() is called as with unlinked commands. */
-switch (msg) {
+       switch (msg) {
 #ifdef LINKED
-  case LINKED_CMD_COMPLETE:
-  case LINKED_FLG_CMD_COMPLETE:
-    /* Accept message by releasing ACK */
-    DEB_LINKED(printk("scsi%d : target %d lun %d linked command complete.\n",
-                       instance->host_no, cmd->target, cmd->lun));
-    /* Sanity check : A linked command should only terminate with
-     * one of these messages if there are more linked commands available. */
-    if (!cmd->next_link) {
-       printk("scsi%d : target %d lun %d linked command complete, no next_link\n"
-              instance->host_no, cmd->target, cmd->lun);
-       hostdata->aborted = 1;
-       AM53C974_write_8(CMDREG, CMDREG_SATN);
-       AM53C974_write_8(CMDREG, CMDREG_MA);
-       break; }
-    if (hostdata->aborted) {
-       DEB_ABORT(printk("ATN set for cmnd %d upon reception of LINKED_CMD_COMPLETE or"
-                        "LINKED_FLG_CMD_COMPLETE message\n", cmd->cmnd[0]));
-       AM53C974_write_8(CMDREG, CMDREG_SATN); }
-    AM53C974_write_8(CMDREG, CMDREG_MA);
-
-    initialize_SCp(cmd->next_link);
-    /* The next command is still part of this process */
-    cmd->next_link->tag = cmd->tag;
-    cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 
-    DEB_LINKED(printk("scsi%d : target %d lun %d linked request done, calling scsi_done().\n",
-                     instance->host_no, cmd->target, cmd->lun));
-    cmd->scsi_done(cmd);
-    cmd = hostdata->connected;
-    break;
-
-#endif /* def LINKED */
-
-  case ABORT:
-  case COMMAND_COMPLETE: 
-    DEB_MSG(printk("scsi%d: command complete message received; cmd %d for target %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-    hostdata->disconnecting = 1;
-    cmd->device->disconnect = 0;
-
-    /* I'm not sure what the correct thing to do here is : 
-     * 
-     * If the command that just executed is NOT a request 
-     * sense, the obvious thing to do is to set the result
-     * code to the values of the stored parameters.
-     * If it was a REQUEST SENSE command, we need some way 
-     * to differentiate between the failure code of the original
-     * and the failure code of the REQUEST sense - the obvious
-     * case is success, where we fall through and leave the result
-     * code unchanged.
-     * 
-     * The non-obvious place is where the REQUEST SENSE failed  */
-    if (cmd->cmnd[0] != REQUEST_SENSE) 
-       cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 
-      else if (cmd->SCp.Status != GOOD)
-       cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);                 
-    if (hostdata->aborted) {
-       AM53C974_write_8(CMDREG, CMDREG_SATN);
-       AM53C974_write_8(CMDREG, CMDREG_MA);
-       DEB_ABORT(printk("ATN set for cmnd %d upon reception of ABORT or"
-                        "COMMAND_COMPLETE message\n", cmd->cmnd[0]));
-       break; }
-    if ((cmd->cmnd[0] != REQUEST_SENSE) && (cmd->SCp.Status == CHECK_CONDITION)) {
-       DEB_MSG(printk("scsi%d : performing request sense\n", instance->host_no));
-       cmd->cmnd[0] = REQUEST_SENSE;
-       cmd->cmnd[1] &= 0xe0;
-       cmd->cmnd[2] = 0;
-       cmd->cmnd[3] = 0;
-       cmd->cmnd[4] = sizeof(cmd->sense_buffer);
-       cmd->cmnd[5] = 0;
-       cmd->SCp.buffer = NULL;
-       cmd->SCp.buffers_residual = 0;
-       cmd->SCp.ptr = (char *)cmd->sense_buffer;
-       cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
-       LIST(cmd,hostdata->issue_queue);
-       cmd->host_scribble = (unsigned char *)hostdata->issue_queue;
-       hostdata->issue_queue = (Scsi_Cmnd *)cmd;
-       DEB_MSG(printk("scsi%d : REQUEST SENSE added to head of issue queue\n",instance->host_no));
-       }
-
-    /* Accept message by clearing ACK */
-    AM53C974_write_8(CMDREG, CMDREG_MA);
-    break;
-               
-  case MESSAGE_REJECT:
-    DEB_MSG(printk("scsi%d: reject message received; cmd %d for target %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-    switch (hostdata->last_message[0]) {
-      case EXTENDED_MESSAGE:
-        if (hostdata->last_message[2] == EXTENDED_SDTR) {
-           /* sync. negotiation was rejected, setup asynchronous transfer with target */
-           printk("\ntarget %d: rate=%d Mhz, asynchronous (sync. negotiation rejected)\n",
-                  cmd->target,  DEF_CLK / DEF_STP);
-           hostdata->sync_off[cmd->target] = 0;
-           hostdata->sync_per[cmd->target] = DEF_STP; }
-        break;
-      case HEAD_OF_QUEUE_TAG:
-      case ORDERED_QUEUE_TAG:
-      case SIMPLE_QUEUE_TAG:
-        cmd->device->tagged_queue = 0;
-        hostdata->busy[cmd->target] |= (1 << cmd->lun);
-        break;
-      default:
-        break;
-      }
-    if (hostdata->aborted) AM53C974_write_8(CMDREG, CMDREG_SATN);
-    AM53C974_write_8(CMDREG, CMDREG_MA);
-    break;
-       
-  case DISCONNECT:
-    DEB_MSG(printk("scsi%d: disconnect message received; cmd %d for target %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-    cmd->device->disconnect = 1;
-    hostdata->disconnecting = 1;
-    AM53C974_write_8(CMDREG, CMDREG_MA); /* Accept message by clearing ACK */
-    break;
-               
-  case SAVE_POINTERS:
-  case RESTORE_POINTERS:
-    DEB_MSG(printk("scsi%d: save/restore pointers message received; cmd %d for target %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-    /* The SCSI data pointer is *IMPLICITLY* saved on a disconnect
-     * operation, in violation of the SCSI spec so we can safely 
-     * ignore SAVE/RESTORE pointers calls.
-     *
-     * Unfortunately, some disks violate the SCSI spec and 
-     * don't issue the required SAVE_POINTERS message before
-     * disconnecting, and we have to break spec to remain 
-     * compatible. */
-    if (hostdata->aborted) {
-       DEB_ABORT(printk("ATN set for cmnd %d upon reception of SAVE/REST. POINTERS message\n",
-                         cmd->cmnd[0]));
-       AM53C974_write_8(CMDREG, CMDREG_SATN); }
-    AM53C974_write_8(CMDREG, CMDREG_MA);
-    break;
-
-  case EXTENDED_MESSAGE:
-    DEB_MSG(printk("scsi%d: extended message received; cmd %d for target %d, lun %d\n",
-                  instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
-   /* Extended messages are sent in the following format :
-    * Byte     
-    * 0                  EXTENDED_MESSAGE == 1
-    * 1                  length (includes one byte for code, doesn't include first two bytes)
-    * 2          code
-    * 3..length+1 arguments
-    */
-   /* BEWARE!! THIS CODE IS EXTREMELY UGLY */
-    extended_msg[0] = EXTENDED_MESSAGE;
-    AM53C974_read_8(INSTREG) ; /* clear int */
-    AM53C974_write_8(CMDREG, CMDREG_MA);  /* ack. msg byte, then wait for SO */  
-    AM53C974_poll_int();
-    /* get length */
-    AM53C974_write_8(CMDREG, CMDREG_IT); 
-    AM53C974_poll_int();
-    AM53C974_write_8(CMDREG, CMDREG_MA);  /* ack. msg byte, then wait for SO */   
-    AM53C974_poll_int();
-    extended_msg[1] = len = AM53C974_read_8(FFREG); /* get length */
-    p = extended_msg+2;
-    /* read the remaining (len) bytes */
-    while (len) {
-      AM53C974_write_8(CMDREG, CMDREG_IT); 
-      AM53C974_poll_int();
-      if (len > 1) {
-         AM53C974_write_8(CMDREG, CMDREG_MA);  /* ack. msg byte, then wait for SO */   
-         AM53C974_poll_int(); }
-      *p = AM53C974_read_8(FFREG);
-      p++; len--; }
+               case LINKED_CMD_COMPLETE:
+                   case LINKED_FLG_CMD_COMPLETE:
+               /* Accept message by releasing ACK */
+                   DEB_LINKED(printk("scsi%d : target %d lun %d linked command complete.\n",
+                             instance->host_no, cmd->target, cmd->lun));
+               /* Sanity check : A linked command should only terminate with
+                * one of these messages if there are more linked commands available. */
+               if (!cmd->next_link) {
+                       printk("scsi%d : target %d lun %d linked command complete, no next_link\n"
+                              instance->host_no, cmd->target, cmd->lun);
+                       hostdata->aborted = 1;
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+                       AM53C974_write_8(CMDREG, CMDREG_MA);
+                       break;
+               }
+               if (hostdata->aborted) {
+                       DEB_ABORT(printk("ATN set for cmnd %d upon reception of LINKED_CMD_COMPLETE or"
+                                        "LINKED_FLG_CMD_COMPLETE message\n", cmd->cmnd[0]));
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+               }
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+
+               initialize_SCp(cmd->next_link);
+               /* The next command is still part of this process */
+               cmd->next_link->tag = cmd->tag;
+               cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
+               DEB_LINKED(printk("scsi%d : target %d lun %d linked request done, calling scsi_done().\n",
+                             instance->host_no, cmd->target, cmd->lun));
+               cmd->scsi_done(cmd);
+               cmd = hostdata->connected;
+               break;
+
+#endif                         /* def LINKED */
+
+               case ABORT:
+                   case COMMAND_COMPLETE:
+                   DEB_MSG(printk("scsi%d: command complete message received; cmd %d for target %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               hostdata->disconnecting = 1;
+               cmd->device->disconnect = 0;
+
+               /* I'm not sure what the correct thing to do here is : 
+
+                * If the command that just executed is NOT a request 
+                * sense, the obvious thing to do is to set the result
+                * code to the values of the stored parameters.
+                * If it was a REQUEST SENSE command, we need some way 
+                * to differentiate between the failure code of the original
+                * and the failure code of the REQUEST sense - the obvious
+                * case is success, where we fall through and leave the result
+                * code unchanged.
+                * 
+                * The non-obvious place is where the REQUEST SENSE failed  */
+               if (cmd->cmnd[0] != REQUEST_SENSE)
+                       cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
+               else if (cmd->SCp.Status != GOOD)
+                       cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
+               if (hostdata->aborted) {
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+                       AM53C974_write_8(CMDREG, CMDREG_MA);
+                       DEB_ABORT(printk("ATN set for cmnd %d upon reception of ABORT or"
+                           "COMMAND_COMPLETE message\n", cmd->cmnd[0]));
+                       break;
+               }
+               if ((cmd->cmnd[0] != REQUEST_SENSE) && (cmd->SCp.Status == CHECK_CONDITION)) {
+                       DEB_MSG(printk("scsi%d : performing request sense\n", instance->host_no));
+                       cmd->cmnd[0] = REQUEST_SENSE;
+                       cmd->cmnd[1] &= 0xe0;
+                       cmd->cmnd[2] = 0;
+                       cmd->cmnd[3] = 0;
+                       cmd->cmnd[4] = sizeof(cmd->sense_buffer);
+                       cmd->cmnd[5] = 0;
+                       cmd->SCp.buffer = NULL;
+                       cmd->SCp.buffers_residual = 0;
+                       cmd->SCp.ptr = (char *) cmd->sense_buffer;
+                       cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
+                       LIST(cmd, hostdata->issue_queue);
+                       cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
+                       hostdata->issue_queue = (Scsi_Cmnd *) cmd;
+                       DEB_MSG(printk("scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no));
+               }
+               /* Accept message by clearing ACK */
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+               break;
+
+               case MESSAGE_REJECT:
+                   DEB_MSG(printk("scsi%d: reject message received; cmd %d for target %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               switch (hostdata->last_message[0]) {
+                       case EXTENDED_MESSAGE:
+                           if (hostdata->last_message[2] == EXTENDED_SDTR) {
+                               /* sync. negotiation was rejected, setup asynchronous transfer with target */
+                               printk("\ntarget %d: rate=%d Mhz, asynchronous (sync. negotiation rejected)\n",
+                                      cmd->target, DEF_CLK / DEF_STP);
+                               hostdata->sync_off[cmd->target] = 0;
+                               hostdata->sync_per[cmd->target] = DEF_STP;
+                       }
+                       break;
+                       case HEAD_OF_QUEUE_TAG:
+                           case ORDERED_QUEUE_TAG:
+                           case SIMPLE_QUEUE_TAG:
+                           cmd->device->tagged_queue = 0;
+                       hostdata->busy[cmd->target] |= (1 << cmd->lun);
+                       break;
+                       default:
+                           break;
+               }
+               if (hostdata->aborted)
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+               break;
+
+               case DISCONNECT:
+                   DEB_MSG(printk("scsi%d: disconnect message received; cmd %d for target %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               cmd->device->disconnect = 1;
+               hostdata->disconnecting = 1;
+               AM53C974_write_8(CMDREG, CMDREG_MA);    /* Accept message by clearing ACK */
+               break;
+
+               case SAVE_POINTERS:
+                   case RESTORE_POINTERS:
+                   DEB_MSG(printk("scsi%d: save/restore pointers message received; cmd %d for target %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               /* The SCSI data pointer is *IMPLICITLY* saved on a disconnect
+                * operation, in violation of the SCSI spec so we can safely 
+                * ignore SAVE/RESTORE pointers calls.
+                *
+                * Unfortunately, some disks violate the SCSI spec and 
+                * don't issue the required SAVE_POINTERS message before
+                * disconnecting, and we have to break spec to remain 
+                * compatible. */
+               if (hostdata->aborted) {
+                       DEB_ABORT(printk("ATN set for cmnd %d upon reception of SAVE/REST. POINTERS message\n",
+                                        cmd->cmnd[0]));
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
+               }
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+               break;
+
+               case EXTENDED_MESSAGE:
+                   DEB_MSG(printk("scsi%d: extended message received; cmd %d for target %d, lun %d\n",
+               instance->host_no, cmd->cmnd[0], cmd->target, cmd->lun));
+               /* Extended messages are sent in the following format :
+                * Byte    
+                * 0           EXTENDED_MESSAGE == 1
+                * 1           length (includes one byte for code, doesn't include first two bytes)
+                * 2           code
+                * 3..length+1 arguments
+                */
+               /* BEWARE!! THIS CODE IS EXTREMELY UGLY */
+               extended_msg[0] = EXTENDED_MESSAGE;
+               AM53C974_read_8(INSTREG);       /* clear int */
+               AM53C974_write_8(CMDREG, CMDREG_MA);    /* ack. msg byte, then wait for SO */
+               AM53C974_poll_int();
+               /* get length */
+               AM53C974_write_8(CMDREG, CMDREG_IT);
+               AM53C974_poll_int();
+               AM53C974_write_8(CMDREG, CMDREG_MA);    /* ack. msg byte, then wait for SO */
+               AM53C974_poll_int();
+               extended_msg[1] = len = AM53C974_read_8(FFREG);         /* get length */
+               p = extended_msg + 2;
+               /* read the remaining (len) bytes */
+               while (len) {
+                       AM53C974_write_8(CMDREG, CMDREG_IT);
+                       AM53C974_poll_int();
+                       if (len > 1) {
+                               AM53C974_write_8(CMDREG, CMDREG_MA);    /* ack. msg byte, then wait for SO */
+                               AM53C974_poll_int();
+                       }
+                       *p = AM53C974_read_8(FFREG);
+                       p++;
+                       len--;
+               }
 
 #ifdef AM53C974_DEBUG_MSG
-    printk("scsi%d: received extended message: ", instance->host_no);
-    for (j = 0; j < extended_msg[1] + 2; j++) {
-        printk("0x%02x ", extended_msg[j]);
-        if (j && !(j % 16)) printk("\n"); }
-    printk("\n");
+               printk("scsi%d: received extended message: ", instance->host_no);
+               for (j = 0; j < extended_msg[1] + 2; j++) {
+                       printk("0x%02x ", extended_msg[j]);
+                       if (j && !(j % 16))
+                               printk("\n");
+               }
+               printk("\n");
 #endif
 
-    /* check message */
-    if (extended_msg[2] == EXTENDED_SDTR)
-       ret = AM53C974_sync_neg(instance, cmd->target, extended_msg);
-    if (ret || hostdata->aborted) AM53C974_write_8(CMDREG, CMDREG_SATN);
+               /* check message */
+               if (extended_msg[2] == EXTENDED_SDTR)
+                       ret = AM53C974_sync_neg(instance, cmd->target, extended_msg);
+               if (ret || hostdata->aborted)
+                       AM53C974_write_8(CMDREG, CMDREG_SATN);
 
-    AM53C974_write_8(CMDREG, CMDREG_MA); 
-    break;
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+               break;
 
-  default:
-    printk("scsi%d: unknown message 0x%02x received\n",instance->host_no, msg);
+               default:
+                   printk("scsi%d: unknown message 0x%02x received\n", instance->host_no, msg);
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+               deb_stop = 1;
 #endif
-    /* reject message */
-    hostdata->msgout[0] = MESSAGE_REJECT; 
-    AM53C974_write_8(CMDREG, CMDREG_SATN);
-    AM53C974_write_8(CMDREG, CMDREG_MA);
-    return(0);
-    break;
-
-  } /* switch (msg) */
-KEYWAIT();
-return(1);
+               /* reject message */
+               hostdata->msgout[0] = MESSAGE_REJECT;
+               AM53C974_write_8(CMDREG, CMDREG_SATN);
+               AM53C974_write_8(CMDREG, CMDREG_MA);
+               return (0);
+               break;
+
+       }                       /* switch (msg) */
+       KEYWAIT();
+       return (1);
 }
 
 /************************************************************************** 
@@ -1863,79 +1965,81 @@ return(1);
 * Note: this function initializes the selection process, which is continued 
 *       in the interrupt handler
 **************************************************************************/
-static void AM53C974_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
+static void AM53C974_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-unsigned char            cfifo, tmp[3];
-unsigned int             i, len, cmd_size = COMMAND_SIZE(cmd->cmnd[0]);
-AM53C974_setio(instance);
-
-cfifo = AM53C974_cfifo();
-if (cfifo) {
-   printk("scsi%d: select error; %d residual bytes in FIFO\n", instance->host_no, cfifo);
-   AM53C974_write_8(CMDREG, CMDREG_CFIFO); /* clear FIFO */
-   }                  
-
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       unsigned char cfifo, tmp[3];
+       unsigned int i, len, cmd_size = COMMAND_SIZE(cmd->cmnd[0]);
+       AM53C974_setio(instance);
+
+       cfifo = AM53C974_cfifo();
+       if (cfifo) {
+               printk("scsi%d: select error; %d residual bytes in FIFO\n", instance->host_no, cfifo);
+               AM53C974_write_8(CMDREG, CMDREG_CFIFO);         /* clear FIFO */
+       }
 #ifdef AM53C974_PROHIBIT_DISCONNECT
-tmp[0] = IDENTIFY(0, cmd->lun);
+       tmp[0] = IDENTIFY(0, cmd->lun);
 #else
-tmp[0] = IDENTIFY(1, cmd->lun);
+       tmp[0] = IDENTIFY(1, cmd->lun);
 #endif
 
 #ifdef SCSI2
-if (cmd->device->tagged_queue && (tag != TAG_NONE)) {
-   tmp[1] = SIMPLE_QUEUE_TAG;
-   if (tag == TAG_NEXT) {
-      /* 0 is TAG_NONE, used to imply no tag for this command */
-      if (cmd->device->current_tag == 0) cmd->device->current_tag = 1;
-      cmd->tag = cmd->device->current_tag;
-      cmd->device->current_tag++; }
-     else  
-      cmd->tag = (unsigned char)tag;
-   tmp[2] = cmd->tag;
-   hostdata->last_message[0] = SIMPLE_QUEUE_TAG;
-   len = 3;
-   AM53C974_write_8(FFREG, tmp[0]);
-   AM53C974_write_8(FFREG, tmp[1]);
-   AM53C974_write_8(FFREG, tmp[2]);
-   }
-  else
-#endif /* def SCSI2 */
-   {
-   len = 1;
-   AM53C974_write_8(FFREG, tmp[0]);
-   cmd->tag = 0; }
+       if (cmd->device->tagged_queue && (tag != TAG_NONE)) {
+               tmp[1] = SIMPLE_QUEUE_TAG;
+               if (tag == TAG_NEXT) {
+                       /* 0 is TAG_NONE, used to imply no tag for this command */
+                       if (cmd->device->current_tag == 0)
+                               cmd->device->current_tag = 1;
+                       cmd->tag = cmd->device->current_tag;
+                       cmd->device->current_tag++;
+               } else
+                       cmd->tag = (unsigned char) tag;
+               tmp[2] = cmd->tag;
+               hostdata->last_message[0] = SIMPLE_QUEUE_TAG;
+               len = 3;
+               AM53C974_write_8(FFREG, tmp[0]);
+               AM53C974_write_8(FFREG, tmp[1]);
+               AM53C974_write_8(FFREG, tmp[2]);
+       } else
+#endif                         /* def SCSI2 */
+       {
+               len = 1;
+               AM53C974_write_8(FFREG, tmp[0]);
+               cmd->tag = 0;
+       }
 
 /* in case of an inquiry or req. sense command with no sync. neg performed yet, we start
    sync negotiation via start stops and transfer the command in cmdout phase */
-if (((cmd->cmnd[0] == INQUIRY) || (cmd->cmnd[0] == REQUEST_SENSE)) &&
-    !(hostdata->sync_neg[cmd->target]) && hostdata->sync_en[cmd->target]) {
-   hostdata->sync_neg[cmd->target] = 1;
-   hostdata->msgout[0] = EXTENDED_MESSAGE;
-   hostdata->msgout[1] = 3;
-   hostdata->msgout[2] = EXTENDED_SDTR;
-   hostdata->msgout[3] = 250 / (int)hostdata->max_rate[cmd->target];
-   hostdata->msgout[4] = hostdata->max_offset[cmd->target];
-   len += 5; }
-
-AM53C974_write_8(SDIDREG, SDIREG_MASK & cmd->target);       /* setup dest. id  */
-AM53C974_write_8(STIMREG, DEF_SCSI_TIMEOUT);                /* setup timeout reg */
-switch (len) {
-  case 1:
-   for (i = 0; i < cmd_size; i++) AM53C974_write_8(FFREG, cmd->cmnd[i]);
-   AM53C974_write_8(CMDREG, CMDREG_SAS);                    /* select with ATN, 1 msg byte */
-   hostdata->msgout[0] = NOP;
-   break;
-  case 3:
-   for (i = 0; i < cmd_size; i++) AM53C974_write_8(FFREG, cmd->cmnd[i]);
-   AM53C974_write_8(CMDREG, CMDREG_SA3S);                   /* select with ATN, 3 msg bytes */
-   hostdata->msgout[0] = NOP;
-   break;
-  default:
-   AM53C974_write_8(CMDREG, CMDREG_SASS);   /* select with ATN, stop steps; continue in message out phase */
-   break;
-  }
+       if (((cmd->cmnd[0] == INQUIRY) || (cmd->cmnd[0] == REQUEST_SENSE)) &&
+           !(hostdata->sync_neg[cmd->target]) && hostdata->sync_en[cmd->target]) {
+               hostdata->sync_neg[cmd->target] = 1;
+               hostdata->msgout[0] = EXTENDED_MESSAGE;
+               hostdata->msgout[1] = 3;
+               hostdata->msgout[2] = EXTENDED_SDTR;
+               hostdata->msgout[3] = 250 / (int) hostdata->max_rate[cmd->target];
+               hostdata->msgout[4] = hostdata->max_offset[cmd->target];
+               len += 5;
+       }
+       AM53C974_write_8(SDIDREG, SDIREG_MASK & cmd->target);   /* setup dest. id  */
+       AM53C974_write_8(STIMREG, DEF_SCSI_TIMEOUT);    /* setup timeout reg */
+       switch (len) {
+       case 1:
+               for (i = 0; i < cmd_size; i++)
+                       AM53C974_write_8(FFREG, cmd->cmnd[i]);
+               AM53C974_write_8(CMDREG, CMDREG_SAS);   /* select with ATN, 1 msg byte */
+               hostdata->msgout[0] = NOP;
+               break;
+       case 3:
+               for (i = 0; i < cmd_size; i++)
+                       AM53C974_write_8(FFREG, cmd->cmnd[i]);
+               AM53C974_write_8(CMDREG, CMDREG_SA3S);  /* select with ATN, 3 msg bytes */
+               hostdata->msgout[0] = NOP;
+               break;
+               default:
+                   AM53C974_write_8(CMDREG, CMDREG_SASS);      /* select with ATN, stop steps; continue in message out phase */
+               break;
+       }
 }
 
 /************************************************************************** 
@@ -1952,59 +2056,65 @@ switch (len) {
 **************************************************************************/
 static void AM53C974_intr_reselect(struct Scsi_Host *instance, unsigned char statreg)
 {
-AM53C974_local_declare(); 
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-unsigned char            cfifo, msg[3], lun, t, target = 0;
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       unsigned char cfifo, msg[3], lun, t, target = 0;
 #ifdef SCSI2
unsigned                char tag;
      unsigned char tag;
 #endif
-Scsi_Cmnd                *tmp = NULL, *prev;
-AM53C974_setio(instance);
-
-cfifo = AM53C974_cfifo();
-
-if (hostdata->selecting) {
-   /* caught reselect interrupt in selection process;
-      put selecting command back into the issue queue and continue with the
-      reselecting command */
-   DEB_RESEL(printk("AM53C974_intr_reselect: in selection process\n"));
-   LIST(hostdata->sel_cmd, hostdata->issue_queue);
-   hostdata->sel_cmd->host_scribble = (unsigned char *)hostdata->issue_queue;
-   hostdata->issue_queue = hostdata->sel_cmd;
-   hostdata->sel_cmd = NULL;
-   hostdata->selecting = 0; }
-
+       Scsi_Cmnd *tmp = NULL, *prev;
+       AM53C974_setio(instance);
+
+       cfifo = AM53C974_cfifo();
+
+       if (hostdata->selecting) {
+               /* caught reselect interrupt in selection process;
+                  put selecting command back into the issue queue and continue with the
+                  reselecting command */
+               DEB_RESEL(printk("AM53C974_intr_reselect: in selection process\n"));
+               LIST(hostdata->sel_cmd, hostdata->issue_queue);
+               hostdata->sel_cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
+               hostdata->issue_queue = hostdata->sel_cmd;
+               hostdata->sel_cmd = NULL;
+               hostdata->selecting = 0;
+       }
 /* 2 bytes must be in the FIFO now */
-if (cfifo != 2) {
-   printk("scsi %d: error: %d bytes in fifo, 2 expected\n", instance->host_no, cfifo);
-   hostdata->aborted = 1;
-   goto EXIT_ABORT; }
-
+       if (cfifo != 2) {
+               printk("scsi %d: error: %d bytes in fifo, 2 expected\n", instance->host_no, cfifo);
+               hostdata->aborted = 1;
+               goto EXIT_ABORT;
+       }
 /* determine target which reselected */
-t = AM53C974_read_8(FFREG);
-if (!(t & (1 << instance->this_id))) {
-   printk("scsi %d: error: invalid host id\n", instance->host_no);
-   hostdata->aborted = 1;
-   goto EXIT_ABORT; }
-t ^= (1 << instance->this_id);
-target = 0; while (t != 1) { t >>= 1; target++; }
-DEB_RESEL(printk("scsi %d: reselect; target: %d\n", instance->host_no, target));
-      
-if (hostdata->aborted) goto EXIT_ABORT;
-
-if ((statreg & STATREG_PHASE) != PHASE_MSGIN) {
-   printk("scsi %d: error: upon reselection interrupt not in MSGIN\n", instance->host_no);
-   hostdata->aborted = 1;
-   goto EXIT_ABORT; }
-
-msg[0] = AM53C974_read_8(FFREG);
-if (!msg[0] & 0x80) {
-   printk("scsi%d: error: expecting IDENTIFY message, got ", instance->host_no);
-   print_msg(msg);
-   hostdata->aborted = 1;
-   goto EXIT_ABORT; }
-
-lun = (msg[0] & 0x07);
+       t = AM53C974_read_8(FFREG);
+       if (!(t & (1 << instance->this_id))) {
+               printk("scsi %d: error: invalid host id\n", instance->host_no);
+               hostdata->aborted = 1;
+               goto EXIT_ABORT;
+       }
+       t ^= (1 << instance->this_id);
+       target = 0;
+       while (t != 1) {
+               t >>= 1;
+               target++;
+       }
+       DEB_RESEL(printk("scsi %d: reselect; target: %d\n", instance->host_no, target));
+
+       if (hostdata->aborted)
+               goto EXIT_ABORT;
+
+       if ((statreg & STATREG_PHASE) != PHASE_MSGIN) {
+               printk("scsi %d: error: upon reselection interrupt not in MSGIN\n", instance->host_no);
+               hostdata->aborted = 1;
+               goto EXIT_ABORT;
+       }
+       msg[0] = AM53C974_read_8(FFREG);
+       if (!msg[0] & 0x80) {
+               printk("scsi%d: error: expecting IDENTIFY message, got ", instance->host_no);
+               print_msg(msg);
+               hostdata->aborted = 1;
+               goto EXIT_ABORT;
+       }
+       lun = (msg[0] & 0x07);
 
 /* We need to add code for SCSI-II to track which devices have
  * I_T_L_Q nexuses established, and which have simple I_T_L
@@ -2015,52 +2125,53 @@ lun = (msg[0] & 0x07);
 
 /* Find the command corresponding to the I_T_L or I_T_L_Q  nexus we 
  * just reestablished, and remove it from the disconnected queue. */
-for (tmp = (Scsi_Cmnd *)hostdata->disconnected_queue, prev = NULL; 
-     tmp; prev = tmp, tmp = (Scsi_Cmnd *)tmp->host_scribble) 
-    if ((target == tmp->target) && (lun == tmp->lun) 
+       for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL;
+            tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
+               if ((target == tmp->target) && (lun == tmp->lun)
 #ifdef SCSI2
-         && (tag == tmp->tag) 
+                   && (tag == tmp->tag)
 #endif
-       ) {
-       if (prev) {
-         REMOVE(prev, (Scsi_Cmnd *)(prev->host_scribble), tmp,
-                 (Scsi_Cmnd *)(tmp->host_scribble));
-         prev->host_scribble = tmp->host_scribble; } 
-         else {
-         REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble);
-         hostdata->disconnected_queue = (Scsi_Cmnd *)tmp->host_scribble; }
-       tmp->host_scribble = NULL;
-       hostdata->connected = tmp;
-       break; }
-
-if (!tmp) {
+                   ) {
+                       if (prev) {
+                               REMOVE(prev, (Scsi_Cmnd *) (prev->host_scribble), tmp,
+                                    (Scsi_Cmnd *) (tmp->host_scribble));
+                               prev->host_scribble = tmp->host_scribble;
+                       } else {
+                               REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble);
+                               hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble;
+                       }
+                       tmp->host_scribble = NULL;
+                       hostdata->connected = tmp;
+                       break;
+               }
+       if (!tmp) {
 #ifdef SCSI2
-   printk("scsi%d: warning : target %d lun %d tag %d not in disconnect_queue.\n",
-         instance->host_no, target, lun, tag);
+               printk("scsi%d: warning : target %d lun %d tag %d not in disconnect_queue.\n",
+                      instance->host_no, target, lun, tag);
 #else
-   printk("scsi%d: warning : target %d lun %d not in disconnect_queue.\n",
-         instance->host_no, target, lun);
+               printk("scsi%d: warning : target %d lun %d not in disconnect_queue.\n",
+                      instance->host_no, target, lun);
 #endif
-   /* Since we have an established nexus that we can't do anything with, we must abort it. */
-   hostdata->aborted = 1;
-   DEB(AM53C974_keywait());
-   goto EXIT_ABORT; }
-  else
-   goto EXIT_OK;
-
-EXIT_ABORT: 
-AM53C974_write_8(CMDREG, CMDREG_SATN);
-AM53C974_write_8(CMDREG, CMDREG_MA);
-return;
-
-EXIT_OK:
-DEB_RESEL(printk("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
-         instance->host_no, target, tmp->lun, tmp->tag));
-AM53C974_set_sync(instance, target);
-AM53C974_write_8(SDIDREG, SDIREG_MASK & target);       /* setup dest. id  */
-AM53C974_write_8(CMDREG, CMDREG_MA);
-hostdata->dma_busy = 0;
-hostdata->connected->SCp.phase = PHASE_CMDOUT;
+               /* Since we have an established nexus that we can't do anything with, we must abort it. */
+               hostdata->aborted = 1;
+               DEB(AM53C974_keywait());
+               goto EXIT_ABORT;
+       } else
+               goto EXIT_OK;
+
+       EXIT_ABORT:
+           AM53C974_write_8(CMDREG, CMDREG_SATN);
+       AM53C974_write_8(CMDREG, CMDREG_MA);
+       return;
+
+       EXIT_OK:
+           DEB_RESEL(printk("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
+                        instance->host_no, target, tmp->lun, tmp->tag));
+       AM53C974_set_sync(instance, target);
+       AM53C974_write_8(SDIDREG, SDIREG_MASK & target);        /* setup dest. id  */
+       AM53C974_write_8(CMDREG, CMDREG_MA);
+       hostdata->dma_busy = 0;
+       hostdata->connected->SCp.phase = PHASE_CMDOUT;
 }
 
 /************************************************************************** 
@@ -2078,20 +2189,20 @@ hostdata->connected->SCp.phase = PHASE_CMDOUT;
 * Returns : nothing
 **************************************************************************/
 static __inline__ void AM53C974_transfer_dma(struct Scsi_Host *instance, short dir,
-                                             unsigned long length, char *data)
+                                       unsigned long length, char *data)
 {
-AM53C974_local_declare();
-AM53C974_setio(instance);
-
-AM53C974_write_8(CMDREG, CMDREG_NOP);
-AM53C974_write_8(DMACMD, (dir << 7) | DMACMD_INTE_D);  /* idle command */
-AM53C974_write_8(STCLREG, (unsigned char)(length & 0xff));
-AM53C974_write_8(STCMREG, (unsigned char)((length & 0xff00) >> 8));
-AM53C974_write_8(STCHREG, (unsigned char)((length & 0xff0000) >> 16));
-AM53C974_write_32(DMASTC, length & 0xffffff);
-AM53C974_write_32(DMASPA, virt_to_bus(data));
-AM53C974_write_8(CMDREG, CMDREG_IT | CMDREG_DMA);
-AM53C974_write_8(DMACMD, (dir << 7) | DMACMD_INTE_D | DMACMD_START);
+       AM53C974_local_declare();
+       AM53C974_setio(instance);
+
+       AM53C974_write_8(CMDREG, CMDREG_NOP);
+       AM53C974_write_8(DMACMD, (dir << 7) | DMACMD_INTE_D);   /* idle command */
+       AM53C974_write_8(STCLREG, (unsigned char) (length & 0xff));
+       AM53C974_write_8(STCMREG, (unsigned char) ((length & 0xff00) >> 8));
+       AM53C974_write_8(STCHREG, (unsigned char) ((length & 0xff0000) >> 16));
+       AM53C974_write_32(DMASTC, length & 0xffffff);
+       AM53C974_write_32(DMASPA, virt_to_bus(data));
+       AM53C974_write_8(CMDREG, CMDREG_IT | CMDREG_DMA);
+       AM53C974_write_8(DMACMD, (dir << 7) | DMACMD_INTE_D | DMACMD_START);
 }
 
 /************************************************************************** 
@@ -2107,41 +2218,45 @@ AM53C974_write_8(DMACMD, (dir << 7) | DMACMD_INTE_D | DMACMD_START);
 * Returns : nothing
 **************************************************************************/
 static void AM53C974_dma_blast(struct Scsi_Host *instance, unsigned char dmastatus,
-                               unsigned char statreg)
+                              unsigned char statreg)
 {
-AM53C974_local_declare();
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-unsigned long            ctcreg;
-int                      dir = statreg & STATREG_IO;
-int                      cfifo, pio, i = 0;
-AM53C974_setio(instance);
-
-do {
-   cfifo = AM53C974_cfifo();
-   i++;
-   } while (cfifo && (i < 50000));
-pio = (i == 50000) ? 1: 0;
-
-if (statreg & STATREG_CTZ) { AM53C974_write_8(DMACMD, DMACMD_IDLE); return; }
-
-if (dmastatus & DMASTATUS_DONE) { AM53C974_write_8(DMACMD, DMACMD_IDLE); return; }
-
-AM53C974_write_8(DMACMD, ((dir << 7) & DMACMD_DIR) | DMACMD_BLAST);
-while(!(AM53C974_read_8(DMASTATUS) & DMASTATUS_BCMPLT)) ;
-AM53C974_write_8(DMACMD, DMACMD_IDLE);
-
-if (pio) {
-   /* transfer residual bytes via PIO */
-   unsigned char *wac = (unsigned char *)AM53C974_read_32(DMAWAC);
-   printk("pio mode, residual=%d\n", AM53C974_read_8(CFIREG) & CFIREG_CF);
-   while (AM53C974_read_8(CFIREG) & CFIREG_CF) *(wac++) = AM53C974_read_8(FFREG);
-   }
-
-ctcreg = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
-         (AM53C974_read_8(CTCHREG) << 16);
-
-hostdata->connected->SCp.ptr += hostdata->connected->SCp.this_residual - ctcreg;
-hostdata->connected->SCp.this_residual = ctcreg;
+       AM53C974_local_declare();
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       unsigned long ctcreg;
+       int dir = statreg & STATREG_IO;
+       int cfifo, pio, i = 0;
+       AM53C974_setio(instance);
+
+       do {
+               cfifo = AM53C974_cfifo();
+               i++;
+       } while (cfifo && (i < 50000));
+       pio = (i == 50000) ? 1 : 0;
+
+       if (statreg & STATREG_CTZ) {
+               AM53C974_write_8(DMACMD, DMACMD_IDLE);
+               return;
+       }
+       if (dmastatus & DMASTATUS_DONE) {
+               AM53C974_write_8(DMACMD, DMACMD_IDLE);
+               return;
+       }
+       AM53C974_write_8(DMACMD, ((dir << 7) & DMACMD_DIR) | DMACMD_BLAST);
+       while (!(AM53C974_read_8(DMASTATUS) & DMASTATUS_BCMPLT));
+       AM53C974_write_8(DMACMD, DMACMD_IDLE);
+
+       if (pio) {
+               /* transfer residual bytes via PIO */
+               unsigned char *wac = (unsigned char *) AM53C974_read_32(DMAWAC);
+               printk("pio mode, residual=%d\n", AM53C974_read_8(CFIREG) & CFIREG_CF);
+               while (AM53C974_read_8(CFIREG) & CFIREG_CF)
+                       *(wac++) = AM53C974_read_8(FFREG);
+       }
+       ctcreg = AM53C974_read_8(CTCLREG) | (AM53C974_read_8(CTCMREG) << 8) |
+           (AM53C974_read_8(CTCHREG) << 16);
+
+       hostdata->connected->SCp.ptr += hostdata->connected->SCp.this_residual - ctcreg;
+       hostdata->connected->SCp.this_residual = ctcreg;
 }
 
 /************************************************************************** 
@@ -2155,15 +2270,15 @@ hostdata->connected->SCp.this_residual = ctcreg;
 **************************************************************************/
 static void AM53C974_intr_bus_reset(struct Scsi_Host *instance)
 {
-AM53C974_local_declare();
-unsigned char cntlreg1;
-AM53C974_setio(instance);
+       AM53C974_local_declare();
+       unsigned char cntlreg1;
+       AM53C974_setio(instance);
 
-AM53C974_write_8(CMDREG, CMDREG_CFIFO);
-AM53C974_write_8(CMDREG, CMDREG_NOP);
+       AM53C974_write_8(CMDREG, CMDREG_CFIFO);
+       AM53C974_write_8(CMDREG, CMDREG_NOP);
 
-cntlreg1 = AM53C974_read_8(CNTLREG1);
-AM53C974_write_8(CNTLREG1, cntlreg1 | CNTLREG1_DISR);
+       cntlreg1 = AM53C974_read_8(CNTLREG1);
+       AM53C974_write_8(CNTLREG1, cntlreg1 | CNTLREG1_DISR);
 }
 
 /**************************************************************************
@@ -2177,97 +2292,101 @@ AM53C974_write_8(CNTLREG1, cntlreg1 | CNTLREG1_DISR);
 *
 * Returns : 0 - success, -1 on failure.
  **************************************************************************/
-int AM53C974_abort(Scsi_Cmnd *cmd)
+int AM53C974_abort(Scsi_Cmnd * cmd)
 {
-AM53C974_local_declare();
-struct Scsi_Host         *instance = cmd->host;
-struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-Scsi_Cmnd                *tmp, **prev;
+       AM53C974_local_declare();
+       unsigned long flags;
+       struct Scsi_Host *instance = cmd->host;
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       Scsi_Cmnd *tmp, **prev;
 
 #ifdef AM53C974_DEBUG
-   deb_stop = 1;
+       deb_stop = 1;
 #endif
-cli();
-AM53C974_setio(instance);
+       save_flags(flags);
+       cli();
+       AM53C974_setio(instance);
 
-DEB_ABORT(printk(SEPARATOR_LINE));
-DEB_ABORT(printk("scsi%d : AM53C974_abort called -- trouble starts!!\n", instance->host_no));
-DEB_ABORT(AM53C974_print(instance));
-DEB_ABORT(AM53C974_keywait());
+       DEB_ABORT(printk(SEPARATOR_LINE));
+       DEB_ABORT(printk("scsi%d : AM53C974_abort called -- trouble starts!!\n", instance->host_no));
+       DEB_ABORT(AM53C974_print(instance));
+       DEB_ABORT(AM53C974_keywait());
 
 /* Case 1 : If the command is the currently executing command, 
-            we'll set the aborted flag and return control so that the
-            information transfer routine can exit cleanly. */
-if ((hostdata->connected == cmd) || (hostdata->sel_cmd == cmd)) {
-   DEB_ABORT(printk("scsi%d: aborting connected command\n", instance->host_no));
-   hostdata->aborted = 1;
-   hostdata->msgout[0] = ABORT;
-   sti();
-   return(SCSI_ABORT_PENDING); }
-
+   we'll set the aborted flag and return control so that the
+   information transfer routine can exit cleanly. */
+       if ((hostdata->connected == cmd) || (hostdata->sel_cmd == cmd)) {
+               DEB_ABORT(printk("scsi%d: aborting connected command\n", instance->host_no));
+               hostdata->aborted = 1;
+               hostdata->msgout[0] = ABORT;
+               restore_flags(flags);
+               return (SCSI_ABORT_PENDING);
+       }
 /* Case 2 : If the command hasn't been issued yet,
-            we simply remove it from the issue queue. */
-for (prev = (Scsi_Cmnd **)&(hostdata->issue_queue), 
-     tmp = (Scsi_Cmnd *)hostdata->issue_queue; tmp; 
-     prev = (Scsi_Cmnd **)&(tmp->host_scribble),
-     tmp = (Scsi_Cmnd *)tmp->host_scribble) {
-    if (cmd == tmp) {
-       DEB_ABORT(printk("scsi%d : abort removed command from issue queue.\n", instance->host_no));
-       REMOVE(5, *prev, tmp, tmp->host_scribble);
-       (*prev) = (Scsi_Cmnd *)tmp->host_scribble;
-       tmp->host_scribble = NULL;
-       tmp->result = DID_ABORT << 16;
-       sti();
-       tmp->done(tmp);
-       return(SCSI_ABORT_SUCCESS); }
+   we simply remove it from the issue queue. */
+       for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue),
+            tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp;
+            prev = (Scsi_Cmnd **) & (tmp->host_scribble),
+            tmp = (Scsi_Cmnd *) tmp->host_scribble) {
+               if (cmd == tmp) {
+                       DEB_ABORT(printk("scsi%d : abort removed command from issue queue.\n", instance->host_no));
+                       REMOVE(5, *prev, tmp, tmp->host_scribble);
+                       (*prev) = (Scsi_Cmnd *) tmp->host_scribble;
+                       tmp->host_scribble = NULL;
+                       tmp->result = DID_ABORT << 16;
+                       restore_flags(flags);
+                       tmp->done(tmp);
+                       return (SCSI_ABORT_SUCCESS);
+               }
 #ifdef AM53C974_DEBUG_ABORT
-      else {
-       if (prev == (Scsi_Cmnd **)tmp) 
-          printk("scsi%d : LOOP\n", instance->host_no); 
-       }
+               else {
+                       if (prev == (Scsi_Cmnd **) tmp)
+                               printk("scsi%d : LOOP\n", instance->host_no);
+               }
 #endif
-    }
+       }
+
 /* Case 3 : If any commands are connected, we're going to fail the abort
- *         and let the high level SCSI driver retry at a later time or 
- *         issue a reset.
+ *        and let the high level SCSI driver retry at a later time or 
+ *          issue a reset.
  *
- *         Timeouts, and therefore aborted commands, will be highly unlikely
+ *          Timeouts, and therefore aborted commands, will be highly unlikely
  *          and handling them cleanly in this situation would make the common
- *         case of noresets less efficient, and would pollute our code.  So,
- *         we fail. */
-if (hostdata->connected || hostdata->sel_cmd) {
-   DEB_ABORT(printk("scsi%d : abort failed, other command connected.\n", instance->host_no));
-   sti();
-   return(SCSI_ABORT_NOT_RUNNING); }
-
+ *          case of noresets less efficient, and would pollute our code.  So,
+ *          we fail. */
+       if (hostdata->connected || hostdata->sel_cmd) {
+               DEB_ABORT(printk("scsi%d : abort failed, other command connected.\n", instance->host_no));
+               restore_flags(flags);
+               return (SCSI_ABORT_NOT_RUNNING);
+       }
 /* Case 4: If the command is currently disconnected from the bus, and 
- *        there are no connected commands, we reconnect the I_T_L or 
- *        I_T_L_Q nexus associated with it, go into message out, and send 
+ *       there are no connected commands, we reconnect the I_T_L or 
+ *         I_T_L_Q nexus associated with it, go into message out, and send 
  *         an abort message. */
-for (tmp = (Scsi_Cmnd *)hostdata->disconnected_queue; tmp; 
-     tmp = (Scsi_Cmnd *)tmp->host_scribble) {
-     if (cmd == tmp) {
-        DEB_ABORT(printk("scsi%d: aborting disconnected command\n", instance->host_no));
-        hostdata->aborted = 1;
-        hostdata->msgout[0] = ABORT;
-        hostdata->selecting = 1;
-        hostdata->sel_cmd = tmp;
-        AM53C974_write_8(CMDREG, CMDREG_DSR);
-        sti();
-        return(SCSI_ABORT_PENDING); }
-     }
+       for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp;
+            tmp = (Scsi_Cmnd *) tmp->host_scribble) {
+               if (cmd == tmp) {
+                       DEB_ABORT(printk("scsi%d: aborting disconnected command\n", instance->host_no));
+                       hostdata->aborted = 1;
+                       hostdata->msgout[0] = ABORT;
+                       hostdata->selecting = 1;
+                       hostdata->sel_cmd = tmp;
+                       AM53C974_write_8(CMDREG, CMDREG_DSR);
+                       restore_flags(flags);
+                       return (SCSI_ABORT_PENDING);
+               }
+       }
 
 /* Case 5 : If we reached this point, the command was not found in any of 
- *         the queues.
+ *        the queues.
  *
  * We probably reached this point because of an unlikely race condition
  * between the command completing successfully and the abortion code,
  * so we won't panic, but we will notify the user in case something really
  * broke. */
-DEB_ABORT(printk("scsi%d : abort failed, command not found.\n", instance->host_no));
-sti();
-return(SCSI_ABORT_NOT_RUNNING);
+       DEB_ABORT(printk("scsi%d : abort failed, command not found.\n", instance->host_no));
+       restore_flags(flags);
+       return (SCSI_ABORT_NOT_RUNNING);
 }
 
 /************************************************************************** 
@@ -2281,51 +2400,54 @@ return(SCSI_ABORT_NOT_RUNNING);
 * 
 * FIXME(eric) the reset_flags are ignored.
 **************************************************************************/
-int AM53C974_reset(Scsi_Cmnd *cmd, unsigned int reset_flags)
+int AM53C974_reset(Scsi_Cmnd * cmd, unsigned int reset_flags)
 {
-    AM53C974_local_declare();
-    int                      i;
-    struct Scsi_Host         *instance = cmd->host;
-    struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *)instance->hostdata;
-    AM53C974_setio(instance);
-    
-    cli();
-    DEB(printk("AM53C974_reset called; "));
-    
-    printk("AM53C974_reset called\n");
-    AM53C974_print(instance);
-    AM53C974_keywait();
-    
+       AM53C974_local_declare();
+       unsigned long flags;
+       int i;
+       struct Scsi_Host *instance = cmd->host;
+       struct AM53C974_hostdata *hostdata = (struct AM53C974_hostdata *) instance->hostdata;
+       AM53C974_setio(instance);
+
+       save_flags(flags);
+       cli();
+       DEB(printk("AM53C974_reset called; "));
+
+       printk("AM53C974_reset called\n");
+       AM53C974_print(instance);
+       AM53C974_keywait();
+
 /* do hard reset */
-    AM53C974_write_8(CMDREG, CMDREG_RDEV);
-    AM53C974_write_8(CMDREG, CMDREG_NOP);
-    hostdata->msgout[0] = NOP;
-    for (i = 0; i < 8; i++) {
-       hostdata->busy[i] = 0;
-       hostdata->sync_per[i] = DEF_STP;
-       hostdata->sync_off[i] = 0;
-       hostdata->sync_neg[i] = 0; }
-    hostdata->last_message[0] = NOP;
-    hostdata->sel_cmd = NULL;
-    hostdata->connected = NULL;
-    hostdata->issue_queue = NULL;
-    hostdata->disconnected_queue = NULL;
-    hostdata->in_reset = 0;
-    hostdata->aborted = 0;
-    hostdata->selecting = 0;
-    hostdata->disconnecting = 0;
-    hostdata->dma_busy = 0;
-    
+       AM53C974_write_8(CMDREG, CMDREG_RDEV);
+       AM53C974_write_8(CMDREG, CMDREG_NOP);
+       hostdata->msgout[0] = NOP;
+       for (i = 0; i < 8; i++) {
+               hostdata->busy[i] = 0;
+               hostdata->sync_per[i] = DEF_STP;
+               hostdata->sync_off[i] = 0;
+               hostdata->sync_neg[i] = 0;
+       }
+       hostdata->last_message[0] = NOP;
+       hostdata->sel_cmd = NULL;
+       hostdata->connected = NULL;
+       hostdata->issue_queue = NULL;
+       hostdata->disconnected_queue = NULL;
+       hostdata->in_reset = 0;
+       hostdata->aborted = 0;
+       hostdata->selecting = 0;
+       hostdata->disconnecting = 0;
+       hostdata->dma_busy = 0;
+
 /* reset bus */
-    AM53C974_write_8(CNTLREG1, CNTLREG1_DISR | instance->this_id); /* disable interrupt upon SCSI RESET */
-    AM53C974_write_8(CMDREG, CMDREG_RBUS);     /* reset SCSI bus */
-    udelay(40);
-    AM53C974_config_after_reset(instance);
-    
-    sti();
-    cmd->result = DID_RESET << 16;
-    cmd->scsi_done(cmd);
-    return SCSI_ABORT_SUCCESS;
+       AM53C974_write_8(CNTLREG1, CNTLREG1_DISR | instance->this_id);  /* disable interrupt upon SCSI RESET */
+       AM53C974_write_8(CMDREG, CMDREG_RBUS);  /* reset SCSI bus */
+       udelay(40);
+       AM53C974_config_after_reset(instance);
+
+       restore_flags(flags);
+       cmd->result = DID_RESET << 16;
+       cmd->scsi_done(cmd);
+       return SCSI_ABORT_SUCCESS;
 }
 
 
@@ -2334,8 +2456,7 @@ int AM53C974_reset(Scsi_Cmnd *cmd, unsigned int reset_flags)
  *
  * Release resources allocated for a single AM53C974 adapter.
  */
-int
-AM53C974_release(struct Scsi_Host *shp)
+int AM53C974_release(struct Scsi_Host *shp)
 {
        free_irq(shp->irq, NULL);
        scsi_unregister(shp);
index f4542c778aef55230231321a83ef2ac5517b2c08..41aa5e7a17b0659a2e1ed4ca9647cb8e36d903ad 100644 (file)
@@ -1,14 +1,14 @@
 /* AM53/79C974 (PCscsi) driver release 0.5
- *
+
  * The architecture and much of the code of this device
  * driver was originally developed by Drew Eckhardt for
  * the NCR5380. The following copyrights apply:
  *  For the architecture and all parts similar to the NCR5380:
  *    Copyright 1993, Drew Eckhardt
- *     Visionary Computing 
- *     (Unix and Linux consulting and custom programming)
- *     drew@colorado.edu
- *     +1 (303) 666-5836
+ *      Visionary Computing 
+ *      (Unix and Linux consulting and custom programming)
+ *      drew@colorado.edu
+ *      +1 (303) 666-5836
  *
  *  The AM53C974_nobios_detect code was originally developed by
  *   Robin Cutshaw (robin@xfree86.org) and is used here in a 
 #include <scsi/scsicam.h>
 
 struct AM53C974_hostdata {
-    volatile unsigned       in_reset:1;          /* flag, says bus reset pending */
-    volatile unsigned       aborted:1;           /* flag, says aborted */
-    volatile unsigned       selecting:1;         /* selection started, but not yet finished */
-    volatile unsigned       disconnecting: 1;    /* disconnection started, but not yet finished */
-    volatile unsigned       dma_busy:1;          /* dma busy when service request for info transfer received */
-    volatile unsigned  char msgout[10];          /* message to output in MSGOUT_PHASE */
-    volatile unsigned  char last_message[10];  /* last message OUT */
-    volatile Scsi_Cmnd      *issue_queue;      /* waiting to be issued */
-    volatile Scsi_Cmnd      *disconnected_queue;       /* waiting for reconnect */
-    volatile Scsi_Cmnd      *sel_cmd;            /* command for selection */
-    volatile Scsi_Cmnd      *connected;                /* currently connected command */
-    volatile unsigned  char busy[8];           /* index = target, bit = lun */
-    unsigned  char sync_per[8];         /* synchronous transfer period (in effect) */
-    unsigned  char sync_off[8];         /* synchronous offset (in effect) */
-    unsigned  char sync_neg[8];         /* sync. negotiation performed (in effect) */
-    unsigned  char sync_en[8];          /* sync. negotiation performed (in effect) */
-    unsigned  char max_rate[8];         /* max. transfer rate (setup) */
-    unsigned  char max_offset[8];       /* max. sync. offset (setup), only valid if corresponding sync_en is nonzero */
-    };
+       volatile unsigned in_reset:1;   /* flag, says bus reset pending */
+       volatile unsigned aborted:1;    /* flag, says aborted */
+       volatile unsigned selecting:1;  /* selection started, but not yet finished */
+       volatile unsigned disconnecting: 1;     /* disconnection started, but not yet finished */
+       volatile unsigned dma_busy:1;   /* dma busy when service request for info transfer received */
+       volatile unsigned char msgout[10];      /* message to output in MSGOUT_PHASE */
+       volatile unsigned char last_message[10];        /* last message OUT */
+       volatile Scsi_Cmnd *issue_queue;        /* waiting to be issued */
+       volatile Scsi_Cmnd *disconnected_queue;         /* waiting for reconnect */
+       volatile Scsi_Cmnd *sel_cmd;    /* command for selection */
+       volatile Scsi_Cmnd *connected;  /* currently connected command */
+       volatile unsigned char busy[8];         /* index = target, bit = lun */
+       unsigned char sync_per[8];      /* synchronous transfer period (in effect) */
+       unsigned char sync_off[8];      /* synchronous offset (in effect) */
+       unsigned char sync_neg[8];      /* sync. negotiation performed (in effect) */
+       unsigned char sync_en[8];       /* sync. negotiation performed (in effect) */
+       unsigned char max_rate[8];      /* max. transfer rate (setup) */
+       unsigned char max_offset[8];    /* max. sync. offset (setup), only valid if corresponding sync_en is nonzero */
+};
 
 extern struct proc_dir_entry proc_scsi_am53c974;
 
@@ -71,14 +71,13 @@ extern struct proc_dir_entry proc_scsi_am53c974;
     }
 
 void AM53C974_setup(char *str, int *ints);
-int AM53C974_detect(Scsi_Host_Template *tpnt);
+int AM53C974_detect(Scsi_Host_Template * tpnt);
 int AM53C974_release(struct Scsi_Host *shp);
-int AM53C974_biosparm(Disk *disk, int dev, int *info_array);
+int AM53C974_biosparm(Disk * disk, int dev, int *info_array);
 const char *AM53C974_info(struct Scsi_Host *);
-int AM53C974_command(Scsi_Cmnd *SCpnt);
-int AM53C974_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *));
-int AM53C974_abort(Scsi_Cmnd *cmd);
-int AM53C974_reset (Scsi_Cmnd *cmd, unsigned int);
-
-#endif /* AM53C974_H */
+int AM53C974_command(Scsi_Cmnd * SCpnt);
+int AM53C974_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *));
+int AM53C974_abort(Scsi_Cmnd * cmd);
+int AM53C974_reset(Scsi_Cmnd * cmd, unsigned int);
 
+#endif                         /* AM53C974_H */
index 2a339f426b2f9507a5e98d20cf4f385874d8e154..2588bf3299e08d300fd37be6677229120920fa68 100644 (file)
@@ -3,16 +3,16 @@
 #endif
 /* 
  * NCR 5380 generic driver routines.  These should make it *trivial*
- *     to implement 5380 SCSI drivers under Linux with a non-trantor
- *     architecture.
+ *      to implement 5380 SCSI drivers under Linux with a non-trantor
+ *      architecture.
  *
- *     Note that these routines also work with NR53c400 family chips.
+ *      Note that these routines also work with NR53c400 family chips.
  *
  * Copyright 1993, Drew Eckhardt
- *     Visionary Computing 
- *     (Unix and Linux consulting and custom programming)
- *     drew@colorado.edu
- *     +1 (303) 666-5836
+ *      Visionary Computing 
+ *      (Unix and Linux consulting and custom programming)
+ *      drew@colorado.edu
+ *      +1 (303) 666-5836
  *
  * DISTRIBUTION RELEASE 6. 
  *
@@ -31,7 +31,7 @@
 
 /*
  * $Log: NCR5380.c,v $
- * Revision 1.7  1996/3/2      Ray Van Tassle (rayvt@comm.mot.com)
+ * Revision 1.7  1996/3/2       Ray Van Tassle (rayvt@comm.mot.com)
  * added proc_info
  * added support needed for DTC 3180/3280
  * fixed a couple of bugs
@@ -68,7 +68,7 @@
  * 3.  Test USLEEP code 
  *
  * 4.  Test SCSI-II tagged queueing (I have no devices which support 
- *     tagged queueing)
+ *      tagged queueing)
  *
  * 5.  Test linked command handling code after Eric is ready with 
  *      the high level code.
  *
  * These macros control options : 
  * AUTOPROBE_IRQ - if defined, the NCR5380_probe_irq() function will be 
- *     defined.
+ *      defined.
  * 
  * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
- *     for commands that return with a CHECK CONDITION status. 
+ *      for commands that return with a CHECK CONDITION status. 
  *
  * DIFFERENTIAL - if defined, NCR53c81 chips will use external differential
- *     transceivers. 
+ *      transceivers. 
  *
  * DONT_USE_INTR - if defined, never use interrupts, even if we probe or
- *     override-configure an IRQ.
+ *      override-configure an IRQ.
  *
  * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
- *     bytes at a time.  Since interrupts are disabled by default during
- *     these transfers, we might need this to give reasonable interrupt
- *     service time if the transfer size gets too large.
+ *      bytes at a time.  Since interrupts are disabled by default during
+ *      these transfers, we might need this to give reasonable interrupt
+ *      service time if the transfer size gets too large.
  *
  * LINKED - if defined, linked commands are supported.
  *
  * REAL_DMA - if defined, REAL DMA is used during the data transfer phases.
  *
  * REAL_DMA_POLL - if defined, REAL DMA is used but the driver doesn't
- *     rely on phase mismatch and EOP interrupts to determine end 
- *     of phase.
+ *      rely on phase mismatch and EOP interrupts to determine end 
+ *      of phase.
  *
  * SCSI2 - if defined, SCSI-2 tagged queuing is used where possible
  *
  * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  You
- *         only really want to use this if you're having a problem with
- *         dropped characters during high speed communications, and even
- *         then, you're going to be better off twiddling with transfersize
- *         in the high level code.
+ *          only really want to use this if you're having a problem with
+ *          dropped characters during high speed communications, and even
+ *          then, you're going to be better off twiddling with transfersize
+ *          in the high level code.
  *
  * USLEEP - if defined, on devices that aren't disconnecting from the 
- *     bus, we will go to sleep so that the CPU can get real work done 
- *     when we run a command that won't complete immediately.
+ *      bus, we will go to sleep so that the CPU can get real work done 
+ *      when we run a command that won't complete immediately.
  *
  * Note that if USLEEP is defined, NCR5380_TIMER *must* also be
  * defined.
  *
  * These macros MUST be defined :
  * NCR5380_local_declare() - declare any local variables needed for your
- *     transfer routines.
+ *      transfer routines.
  *
  * NCR5380_setup(instance) - initialize any local variables needed from a given
- *     instance of the host adapter for NCR5380_{read,write,pread,pwrite}
+ *      instance of the host adapter for NCR5380_{read,write,pread,pwrite}
  * 
  * NCR5380_read(register)  - read from the specified register
  *
  * NCR5380_write(register, value) - write to the specific register 
  *
  * NCR5380_implementation_fields  - additional fields needed for this 
- *     specific implementation of the NCR5380
+ *      specific implementation of the NCR5380
  *
  * Either real DMA *or* pseudo DMA may be implemented
  * REAL functions : 
  * NCR5380_REAL_DMA should be defined if real DMA is to be used.
  * Note that the DMA setup functions should return the number of bytes 
- *     that they were able to program the controller for.
+ *      that they were able to program the controller for.
  *
  * Also note that generic i386/PC versions of these macros are 
- *     available as NCR5380_i386_dma_write_setup,
- *     NCR5380_i386_dma_read_setup, and NCR5380_i386_dma_residual.
+ *      available as NCR5380_i386_dma_write_setup,
+ *      NCR5380_i386_dma_read_setup, and NCR5380_i386_dma_residual.
  *
  * NCR5380_dma_write_setup(instance, src, count) - initialize
  * NCR5380_dma_read_setup(instance, dst, count) - initialize
  * code finishes, NCR5380_print_options should be called.
  */
 
-static int do_abort (struct Scsi_Host *host);
-static void do_reset (struct Scsi_Host *host);
+static int do_abort(struct Scsi_Host *host);
+static void do_reset(struct Scsi_Host *host);
 static struct Scsi_Host *first_instance = NULL;
 static Scsi_Host_Template *the_template = NULL;
 
@@ -313,49 +313,112 @@ static Scsi_Host_Template *the_template = NULL;
  * Function : void initialize_SCp(Scsi_Cmnd *cmd)
  *
  * Purpose : initialize the saved data pointers for cmd to point to the 
- *     start of the buffer.
+ *      start of the buffer.
  *
  * Inputs : cmd - Scsi_Cmnd structure to have pointers reset.
  */
 
-static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) {
-    /* 
-     * Initialize the Scsi Pointer field so that all of the commands in the 
-     * various queues are valid.
-     */
-
-    if (cmd->use_sg) {
-       cmd->SCp.buffer = (struct scatterlist *) cmd->buffer;
-       cmd->SCp.buffers_residual = cmd->use_sg - 1;
-       cmd->SCp.ptr = (char *) cmd->SCp.buffer->address;
-       cmd->SCp.this_residual = cmd->SCp.buffer->length;
-    } else {
-       cmd->SCp.buffer = NULL;
-       cmd->SCp.buffers_residual = 0;
-       cmd->SCp.ptr = (char *) cmd->request_buffer;
-       cmd->SCp.this_residual = cmd->request_bufflen;
-    }
+static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
+{
+       /* 
+        * Initialize the Scsi Pointer field so that all of the commands in the 
+        * various queues are valid.
+        */
+
+       if (cmd->use_sg) {
+               cmd->SCp.buffer = (struct scatterlist *) cmd->buffer;
+               cmd->SCp.buffers_residual = cmd->use_sg - 1;
+               cmd->SCp.ptr = (char *) cmd->SCp.buffer->address;
+               cmd->SCp.this_residual = cmd->SCp.buffer->length;
+       } else {
+               cmd->SCp.buffer = NULL;
+               cmd->SCp.buffers_residual = 0;
+               cmd->SCp.ptr = (char *) cmd->request_buffer;
+               cmd->SCp.this_residual = cmd->request_bufflen;
+       }
 }
 
 #include <linux/delay.h>
 
 #ifdef NDEBUG
 static struct {
-    unsigned char mask;
-    const char * name;} 
-signals[] = {{ SR_DBP, "PARITY"}, { SR_RST, "RST" }, { SR_BSY, "BSY" }, 
-    { SR_REQ, "REQ" }, { SR_MSG, "MSG" }, { SR_CD,  "CD" }, { SR_IO, "IO" }, 
-    { SR_SEL, "SEL" }, {0, NULL}}, 
-basrs[] = {{BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL}},
-icrs[] = {{ICR_ASSERT_RST, "ASSERT RST"},{ICR_ASSERT_ACK, "ASSERT ACK"},
-    {ICR_ASSERT_BSY, "ASSERT BSY"}, {ICR_ASSERT_SEL, "ASSERT SEL"}, 
-    {ICR_ASSERT_ATN, "ASSERT ATN"}, {ICR_ASSERT_DATA, "ASSERT DATA"}, 
-    {0, NULL}},
-mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"}, 
-    {MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, {MR_ENABLE_PAR_INTR, 
-    "MODE PARITY INTR"}, {MR_MONITOR_BSY, "MODE MONITOR BSY"},
-    {MR_DMA_MODE, "MODE DMA"}, {MR_ARBITRATE, "MODE ARBITRATION"}, 
-    {0, NULL}};
+       unsigned char mask;
+       const char *name;
+} signals[] = { {
+
+               SR_DBP, "PARITY"
+}, {
+       SR_RST, "RST"
+}, {
+       SR_BSY, "BSY"
+},
+{
+       SR_REQ, "REQ"
+}, {
+       SR_MSG, "MSG"
+}, {
+       SR_CD, "CD"
+}, {
+       SR_IO, "IO"
+},
+{
+       SR_SEL, "SEL"
+}, {
+       0, NULL
+}
+},
+
+basrs[] = { {
+               BASR_ATN, "ATN"
+}, {
+       BASR_ACK, "ACK"
+}, {
+       0, NULL
+}
+},
+
+icrs[] = { {
+               ICR_ASSERT_RST, "ASSERT RST"
+}, {
+       ICR_ASSERT_ACK, "ASSERT ACK"
+},
+{
+       ICR_ASSERT_BSY, "ASSERT BSY"
+}, {
+       ICR_ASSERT_SEL, "ASSERT SEL"
+},
+{
+       ICR_ASSERT_ATN, "ASSERT ATN"
+}, {
+       ICR_ASSERT_DATA, "ASSERT DATA"
+},
+{
+       0, NULL
+}
+},
+
+mrs[] = { {
+               MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"
+}, {
+       MR_TARGET, "MODE TARGET"
+},
+{
+       MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"
+}, {
+       MR_ENABLE_PAR_INTR,
+           "MODE PARITY INTR"
+}, {
+       MR_MONITOR_BSY, "MODE MONITOR BSY"
+},
+{
+       MR_DMA_MODE, "MODE DMA"
+}, {
+       MR_ARBITRATE, "MODE ARBITRATION"
+},
+{
+       0, NULL
+}
+};
 
 /*
  * Function : void NCR5380_print(struct Scsi_Host *instance)
@@ -365,43 +428,62 @@ mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"},
  * Input : instance - which NCR5380
  */
 
-static void NCR5380_print(struct Scsi_Host *instance) {
-    NCR5380_local_declare();
-    unsigned char status, data, basr, mr, icr, i;
-    NCR5380_setup(instance);
-    cli();
-    data = NCR5380_read(CURRENT_SCSI_DATA_REG);
-    status = NCR5380_read(STATUS_REG);
-    mr = NCR5380_read(MODE_REG);
-    icr = NCR5380_read(INITIATOR_COMMAND_REG);
-    basr = NCR5380_read(BUS_AND_STATUS_REG);
-    sti();
-    printk("STATUS_REG: %02x ", status);
-    for (i = 0; signals[i].mask ; ++i) 
-       if (status & signals[i].mask)
-           printk(",%s", signals[i].name);
-    printk("\nBASR: %02x ", basr);
-    for (i = 0; basrs[i].mask ; ++i) 
-       if (basr & basrs[i].mask)
-           printk(",%s", basrs[i].name);
-    printk("\nICR: %02x ", icr);
-    for (i = 0; icrs[i].mask; ++i) 
-       if (icr & icrs[i].mask)
-           printk(",%s", icrs[i].name);
-    printk("\nMODE: %02x ", mr);
-    for (i = 0; mrs[i].mask; ++i) 
-       if (mr & mrs[i].mask)
-           printk(",%s", mrs[i].name);
-    printk("\n");
+static void NCR5380_print(struct Scsi_Host *instance)
+{
+       NCR5380_local_declare();
+       unsigned long flags;
+       unsigned char status, data, basr, mr, icr, i;
+       NCR5380_setup(instance);
+       save_flags(flags);
+       cli();
+       data = NCR5380_read(CURRENT_SCSI_DATA_REG);
+       status = NCR5380_read(STATUS_REG);
+       mr = NCR5380_read(MODE_REG);
+       icr = NCR5380_read(INITIATOR_COMMAND_REG);
+       basr = NCR5380_read(BUS_AND_STATUS_REG);
+       restore_flags(flags);
+       printk("STATUS_REG: %02x ", status);
+       for (i = 0; signals[i].mask; ++i)
+               if (status & signals[i].mask)
+                       printk(",%s", signals[i].name);
+       printk("\nBASR: %02x ", basr);
+       for (i = 0; basrs[i].mask; ++i)
+               if (basr & basrs[i].mask)
+                       printk(",%s", basrs[i].name);
+       printk("\nICR: %02x ", icr);
+       for (i = 0; icrs[i].mask; ++i)
+               if (icr & icrs[i].mask)
+                       printk(",%s", icrs[i].name);
+       printk("\nMODE: %02x ", mr);
+       for (i = 0; mrs[i].mask; ++i)
+               if (mr & mrs[i].mask)
+                       printk(",%s", mrs[i].name);
+       printk("\n");
 }
 
 static struct {
-    unsigned char value;
-    const char *name;
+       unsigned char value;
+       const char *name;
 } phases[] = {
-{PHASE_DATAOUT, "DATAOUT"}, {PHASE_DATAIN, "DATAIN"}, {PHASE_CMDOUT, "CMDOUT"},
-{PHASE_STATIN, "STATIN"}, {PHASE_MSGOUT, "MSGOUT"}, {PHASE_MSGIN, "MSGIN"},
-{PHASE_UNKNOWN, "UNKNOWN"}};
+
+       {
+               PHASE_DATAOUT, "DATAOUT"
+       }, {
+               PHASE_DATAIN, "DATAIN"
+       }, {
+               PHASE_CMDOUT, "CMDOUT"
+       },
+       {
+               PHASE_STATIN, "STATIN"
+       }, {
+               PHASE_MSGOUT, "MSGOUT"
+       }, {
+               PHASE_MSGIN, "MSGIN"
+       },
+       {
+               PHASE_UNKNOWN, "UNKNOWN"
+       }
+};
 
 /* 
  * Function : void NCR5380_print_phase(struct Scsi_Host *instance)
@@ -411,21 +493,22 @@ static struct {
  * Input : instance - which NCR5380
  */
 
-static void NCR5380_print_phase(struct Scsi_Host *instance) {
-    NCR5380_local_declare();
-    unsigned char status;
-    int i;
-    NCR5380_setup(instance);
-
-    status = NCR5380_read(STATUS_REG);
-    if (!(status & SR_REQ)) 
-       printk("scsi%d : REQ not asserted, phase unknown.\n", 
-           instance->host_no);
-    else {
-       for (i = 0; (phases[i].value != PHASE_UNKNOWN) && 
-           (phases[i].value != (status & PHASE_MASK)); ++i); 
-       printk("scsi%d : phase %s\n", instance->host_no, phases[i].name);
-    }
+static void NCR5380_print_phase(struct Scsi_Host *instance)
+{
+       NCR5380_local_declare();
+       unsigned char status;
+       int i;
+       NCR5380_setup(instance);
+
+       status = NCR5380_read(STATUS_REG);
+       if (!(status & SR_REQ))
+               printk("scsi%d : REQ not asserted, phase unknown.\n",
+                      instance->host_no);
+       else {
+               for (i = 0; (phases[i].value != PHASE_UNKNOWN) &&
+                    (phases[i].value != (status & PHASE_MASK)); ++i);
+               printk("scsi%d : phase %s\n", instance->host_no, phases[i].name);
+       }
 }
 #endif
 
@@ -454,24 +537,26 @@ static volatile int main_running = 0;
  * Function : run_main(void)
  * 
  * Purpose : insure that the coroutine is running and will process our 
- *     request.  main_running is checked/set here (in an inline function)
- *     rather than in NCR5380_main itself to reduce the chances of stack
- *     overflow.
+ *      request.  main_running is checked/set here (in an inline function)
+ *      rather than in NCR5380_main itself to reduce the chances of stack
+ *      overflow.
  *
  */
 
-static __inline__ void run_main(void) {
-    cli();
-    if (!main_running) {
-       main_running = 1;
-       NCR5380_main();
-       /* 
-        * main_running is cleared in NCR5380_main once it can't do 
-        * more work, and NCR5380_main exits with interrupts disabled.
-        */
-       sti();
-    } else 
-       sti();
+static __inline__ void run_main(void)
+{
+       unsigned long flags;
+       save_flags(flags);
+       cli();
+       if (!main_running) {
+               main_running = 1;
+               NCR5380_main();
+               /* 
+                * main_running is cleared in NCR5380_main once it can't do 
+                * more work, and NCR5380_main exits with interrupts disabled.
+                */
+       }
+       restore_flags(flags);
 }
 
 #ifdef USLEEP
@@ -498,116 +583,123 @@ static __inline__ void run_main(void) {
 #define USLEEP_POLL (200*HZ/1000)
 #endif
 
-static struct Scsi_Host * expires_first = NULL;
+static struct Scsi_Host *expires_first = NULL;
 
 /* 
  * Function : int should_disconnect (unsigned char cmd)
  *
  * Purpose : decide weather a command would normally disconnect or 
- *     not, since if it won't disconnect we should go to sleep.
+ *      not, since if it won't disconnect we should go to sleep.
  *
  * Input : cmd - opcode of SCSI command
  *
  * Returns : DISCONNECT_LONG if we should disconnect for a really long 
- *     time (ie always, sleep, look for REQ active, sleep), 
- *     DISCONNECT_TIME_TO_DATA if we would only disconnect for a normal
- *     time-to-data delay, DISCONNECT_NONE if this command would return
- *     immediately.
+ *      time (ie always, sleep, look for REQ active, sleep), 
+ *      DISCONNECT_TIME_TO_DATA if we would only disconnect for a normal
+ *      time-to-data delay, DISCONNECT_NONE if this command would return
+ *      immediately.
  *
  *      Future sleep algorithms based on time to data can exploit 
  *      something like this so they can differentiate between "normal" 
- *     (ie, read, write, seek) and unusual commands (ie, * format).
+ *      (ie, read, write, seek) and unusual commands (ie, * format).
  *
  * Note : We don't deal with commands that handle an immediate disconnect,
  *        
  */
 
-static int should_disconnect (unsigned char cmd) {
-    switch (cmd) {
-    case READ_6:
-    case WRITE_6:
-    case SEEK_6:
-    case READ_10:
-    case WRITE_10:
-    case SEEK_10:
-       return DISCONNECT_TIME_TO_DATA;
-    case FORMAT_UNIT:
-    case SEARCH_HIGH:
-    case SEARCH_LOW:
-    case SEARCH_EQUAL:
-       return DISCONNECT_LONG;
-    default:
-       return DISCONNECT_NONE;
-    }
+static int should_disconnect(unsigned char cmd)
+{
+       switch (cmd) {
+               case READ_6:
+                   case WRITE_6:
+                   case SEEK_6:
+                   case READ_10:
+                   case WRITE_10:
+                   case SEEK_10:
+                   return DISCONNECT_TIME_TO_DATA;
+               case FORMAT_UNIT:
+                   case SEARCH_HIGH:
+                   case SEARCH_LOW:
+                   case SEARCH_EQUAL:
+                   return DISCONNECT_LONG;
+               default:
+                   return DISCONNECT_NONE;
+       }
 }
 
 /*
  * Assumes instance->time_expires has been set in higher level code.
  */
 
-static int NCR5380_set_timer (struct Scsi_Host *instance) {
-    struct Scsi_Host *tmp, **prev;
-    
-    cli();
-    if (((struct NCR5380_hostdata *) (instance->host_data))->next_timer) {
-       sti();
-       return -1;
-    }
-
-    for (prev = &expires_first, tmp = expires_first; tmp; 
-       prev = &(((struct NCR5380_hostdata *) tmp->host_data)->next_timer), 
-       tmp = ((struct NCR5380_hostdata *) tmp->host_data)->next_timer)
-       if (instance->time_expires < tmp->time_expires) 
-           break;
-          
-    instance->next_timer = tmp;
-    *prev = instance;
-    timer_table[NCR5380_TIMER].expires = expires_first->time_expires;
-    timer_active |= 1 << NCR5380_TIMER;
-    sti();
-    return 0;
-}    
+static int NCR5380_set_timer(struct Scsi_Host *instance)
+{
+       unsigned long flags;
+       struct Scsi_Host *tmp, **prev;
+
+       save_flags(flags);
+       cli();
+       if (((struct NCR5380_hostdata *) (instance->host_data))->next_timer) {
+               restore_flags(flags);
+               return -1;
+       }
+       for (prev = &expires_first, tmp = expires_first; tmp;
+            prev = &(((struct NCR5380_hostdata *) tmp->host_data)->next_timer),
+         tmp = ((struct NCR5380_hostdata *) tmp->host_data)->next_timer)
+               if (instance->time_expires < tmp->time_expires)
+                       break;
+
+       instance->next_timer = tmp;
+       *prev = instance;
+       timer_table[NCR5380_TIMER].expires = expires_first->time_expires;
+       timer_active |= 1 << NCR5380_TIMER;
+       restore_flags(flags);
+       return 0;
+}
 
 /* Doing something about unwanted reentrancy here might be useful */
-void NCR5380_timer_fn(void) {
-    struct Scsi_Host *instance;
-    cli();
-    for (; expires_first && expires_first->time_expires >= jiffies; ) {
-       instance = ((NCR5380_hostdata *) expires_first->host_data)->
-           expires_next;
-       ((NCR5380_hostdata *) expires_first->host_data)->expires_next = 
-           NULL;
-       ((NCR5380_hostdata *) expires_first->host_data)->time_expires = 
-           0;
-       expires_first = instance;
-    }
-
-    if (expires_first) {
-       timer_table[NCR5380_TIMER].expires = ((NCR5380_hostdata *) 
-           expires_first->host_data)->time_expires;
-       timer_active |= (1 << NCR5380_TIMER);
-    } else {
-       timer_table[NCR5380_TIMER].expires = 0;
-       timer_active &= ~(1 << MCR5380_TIMER);
-    }
-    sti();
-
-    run_main();
+void NCR5380_timer_fn(void)
+{
+       unsigned long flags;
+       struct Scsi_Host *instance;
+       save_flags(flags);
+       cli();
+       for (; expires_first && expires_first->time_expires >= jiffies;) {
+               instance = ((NCR5380_hostdata *) expires_first->host_data)->
+                   expires_next;
+               ((NCR5380_hostdata *) expires_first->host_data)->expires_next =
+                   NULL;
+               ((NCR5380_hostdata *) expires_first->host_data)->time_expires =
+                   0;
+               expires_first = instance;
+       }
+
+       if (expires_first) {
+               timer_table[NCR5380_TIMER].expires = ((NCR5380_hostdata *)
+                                expires_first->host_data)->time_expires;
+               timer_active |= (1 << NCR5380_TIMER);
+       } else {
+               timer_table[NCR5380_TIMER].expires = 0;
+               timer_active &= ~(1 << MCR5380_TIMER);
+       }
+       restore_flags(flags);
+
+       run_main();
 }
-#endif /* def USLEEP */
+#endif                         /* def USLEEP */
 
-static inline void NCR5380_all_init (void) {
-    static int done = 0;
-    if (!done) {
+static inline void NCR5380_all_init(void)
+{
+       static int done = 0;
+       if (!done) {
 #if (NDEBUG & NDEBUG_INIT)
-       printk("scsi : NCR5380_all_init()\n");
+               printk("scsi : NCR5380_all_init()\n");
 #endif
-       done = 1;
+               done = 1;
 #ifdef USLEEP
-       timer_table[NCR5380_TIMER].expires = 0;
-       timer_table[NCR5380_TIMER].fn = NCR5380_timer_fn;
+               timer_table[NCR5380_TIMER].expires = 0;
+               timer_table[NCR5380_TIMER].fn = NCR5380_timer_fn;
 #endif
-    }
+       }
 }
 
 #ifdef AUTOPROBE_IRQ
@@ -627,25 +719,27 @@ static inline void NCR5380_all_init (void) {
 
 static int probe_irq __initdata = 0;
 
-__initfunc(static void probe_intr (int irq, void *dev_id, struct pt_regs * regs)) {
-    probe_irq = irq;
-};
+__initfunc(static void probe_intr(int irq, void *dev_id, struct pt_regs *regs))
+{
+       probe_irq = irq;
+}
 
-__initfunc(static int NCR5380_probe_irq (struct Scsi_Host *instance, int possible)) {
-    NCR5380_local_declare();
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
-        instance->hostdata;
-    unsigned long timeout;
-    int trying_irqs, i, mask;
-    NCR5380_setup(instance);
+__initfunc(static int NCR5380_probe_irq(struct Scsi_Host *instance, int possible))
+{
+       NCR5380_local_declare();
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+       instance->hostdata;
+       unsigned long timeout;
+       int trying_irqs, i, mask;
+       NCR5380_setup(instance);
 
-    for (trying_irqs = i = 0, mask = 1; i < 16; ++i, mask <<= 1) 
-       if ((mask & possible) &&  (request_irq(i, &probe_intr, SA_INTERRUPT, "NCR-probe", NULL) 
-           == 0)) 
-           trying_irqs |= mask;
+       for (trying_irqs = i = 0, mask = 1; i < 16; ++i, mask <<= 1)
+               if ((mask & possible) && (request_irq(i, &probe_intr, SA_INTERRUPT, "NCR-probe", NULL)
+                                         == 0))
+                       trying_irqs |= mask;
 
-    timeout = jiffies + (250*HZ/1000);
-    probe_irq = IRQ_NONE;
+       timeout = jiffies + (250 * HZ / 1000);
+       probe_irq = IRQ_NONE;
 
 /*
  * A interrupt is triggered whenever BSY = false, SEL = true
@@ -657,101 +751,103 @@ __initfunc(static int NCR5380_probe_irq (struct Scsi_Host *instance, int possibl
  * to zero.
  */
 
-    NCR5380_write(TARGET_COMMAND_REG, 0);
-    NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-    NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | 
-       ICR_ASSERT_SEL);
+       NCR5380_write(TARGET_COMMAND_REG, 0);
+       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+       NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA |
+                     ICR_ASSERT_SEL);
 
-    while (probe_irq == IRQ_NONE && jiffies < timeout)
-       barrier();
+       while (probe_irq == IRQ_NONE && jiffies < timeout)
+               barrier();
 
-    NCR5380_write(SELECT_ENABLE_REG, 0);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+       NCR5380_write(SELECT_ENABLE_REG, 0);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
-    for (i = 0, mask = 1; i < 16; ++i, mask <<= 1)
-       if (trying_irqs & mask) 
-           free_irq(i, NULL);
+       for (i = 0, mask = 1; i < 16; ++i, mask <<= 1)
+               if (trying_irqs & mask)
+                       free_irq(i, NULL);
 
-    return probe_irq;
+       return probe_irq;
 }
-#endif /* AUTOPROBE_IRQ */
+#endif                         /* AUTOPROBE_IRQ */
+
 /*
  * Function : void NCR58380_print_options (struct Scsi_Host *instance)
  *
  * Purpose : called by probe code indicating the NCR5380 driver
- *          options that were selected.
+ *           options that were selected.
  *
  * Inputs : instance, pointer to this instance.  Unused.
  */
 
-__initfunc(static void NCR5380_print_options (struct Scsi_Host *instance)) {
-    printk(" generic options"
+__initfunc(static void NCR5380_print_options(struct Scsi_Host *instance))
+{
+       printk(" generic options"
 #ifdef AUTOPROBE_IRQ
-    " AUTOPROBE_IRQ"
+              " AUTOPROBE_IRQ"
 #endif
-#ifdef AUTOSENSE 
-    " AUTOSENSE"
+#ifdef AUTOSENSE
+              " AUTOSENSE"
 #endif
 #ifdef DIFFERENTIAL
-    " DIFFERENTIAL"
+              " DIFFERENTIAL"
 #endif
 #ifdef REAL_DMA
-    " REAL DMA"
+              " REAL DMA"
 #endif
 #ifdef REAL_DMA_POLL
-    " REAL DMA POLL"
+              " REAL DMA POLL"
 #endif
 #ifdef PARITY
-    " PARITY"
+              " PARITY"
 #endif
 #ifdef PSEUDO_DMA
-    " PSEUDO DMA"
+              " PSEUDO DMA"
 #endif
 #ifdef SCSI2
-    " SCSI-2"
+              " SCSI-2"
 #endif
 #ifdef UNSAFE
-    " UNSAFE "
+              " UNSAFE "
 #endif
-    );
+           );
 #ifdef USLEEP
-    printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
+       printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
 #endif
-    printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
-    if (((struct NCR5380_hostdata *)instance->hostdata)->flags & FLAG_NCR53C400) {
-       printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
-    }
+       printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
+       if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) {
+               printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
+       }
 }
 
 /*
  * Function : void NCR5380_print_status (struct Scsi_Host *instance)
  *
  * Purpose : print commands in the various queues, called from
- *     NCR5380_abort and NCR5380_debug to aid debugging.
+ *      NCR5380_abort and NCR5380_debug to aid debugging.
  *
  * Inputs : instance, pointer to this instance.  
  */
 
-static void NCR5380_print_status (struct Scsi_Host *instance) {
-   static char pr_bfr[512];
-   char *start;
-   int len;
+static void NCR5380_print_status(struct Scsi_Host *instance)
+{
+       static char pr_bfr[512];
+       char *start;
+       int len;
+
+       printk("NCR5380 : coroutine is%s running.\n",
+              main_running ? "" : "n't");
 
-    printk("NCR5380 : coroutine is%s running.\n",
-       main_running ? "" : "n't");
-    
 #ifdef NDEBUG
-    NCR5380_print (instance);
-    NCR5380_print_phase (instance);
+       NCR5380_print(instance);
+       NCR5380_print_phase(instance);
 #endif
 
-   len = NCR5380_proc_info(pr_bfr, &start, 0, sizeof(pr_bfr),
-                       instance->host_no, 0);
-   pr_bfr[len] = 0;
-   printk("\n%s\n", pr_bfr);
-  }
+       len = NCR5380_proc_info(pr_bfr, &start, 0, sizeof(pr_bfr),
+                               instance->host_no, 0);
+       pr_bfr[len] = 0;
+       printk("\n%s\n", pr_bfr);
+}
 
 /******************************************/
 /*
@@ -765,126 +861,130 @@ static void NCR5380_print_status (struct Scsi_Host *instance) {
  * inout: TRUE - user is writing; FALSE - user is reading
  *
  * Return the number of bytes read from or written
-*/
+ */
 
 #undef SPRINTF
 #define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0)
 static
-char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
+char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length);
 static
-char *lprint_command (unsigned char *cmd, char *pos, char *buffer, int len);
+char *lprint_command(unsigned char *cmd, char *pos, char *buffer, int len);
 static
 char *lprint_opcode(int opcode, char *pos, char *buffer, int length);
 
 #ifndef NCR5380_proc_info
 static
 #endif
-int NCR5380_proc_info (
-     char *buffer, char **start,off_t offset,
-     int length,int hostno,int inout)
+int NCR5380_proc_info(
+                            char *buffer, char **start, off_t offset,
+                            int length, int hostno, int inout)
 {
-   char *pos = buffer;
-   struct Scsi_Host *instance;
-   struct NCR5380_hostdata *hostdata;
-   Scsi_Cmnd *ptr;
-
-   for (instance = first_instance; instance &&
-        instance->host_no != hostno; instance=instance->next)
-        ;
-   if (!instance)
-      return(-ESRCH);
-   hostdata = (struct NCR5380_hostdata *)instance->hostdata;
-
-   if (inout) { /* Has data been written to the file ? */
+       unsigned long flags;
+       char *pos = buffer;
+       struct Scsi_Host *instance;
+       struct NCR5380_hostdata *hostdata;
+       Scsi_Cmnd *ptr;
+
+       for (instance = first_instance; instance &&
+            instance->host_no != hostno; instance = instance->next);
+       if (!instance)
+               return (-ESRCH);
+       hostdata = (struct NCR5380_hostdata *) instance->hostdata;
+
+       if (inout) {            /* Has data been written to the file ? */
 #ifdef DTC_PUBLIC_RELEASE
-        dtc_wmaxi = dtc_maxi = 0;
+               dtc_wmaxi = dtc_maxi = 0;
 #endif
 #ifdef PAS16_PUBLIC_RELEASE
-        pas_wmaxi = pas_maxi = 0;
+               pas_wmaxi = pas_maxi = 0;
 #endif
-      return(-ENOSYS);  /* Currently this is a no-op */
-   }
-   SPRINTF("NCR5380 core release=%d.   ", NCR5380_PUBLIC_RELEASE);
-   if (((struct NCR5380_hostdata *)instance->hostdata)->flags & FLAG_NCR53C400)
-        SPRINTF("ncr53c400 release=%d.  ", NCR53C400_PUBLIC_RELEASE);
+               return (-ENOSYS);       /* Currently this is a no-op */
+       }
+       SPRINTF("NCR5380 core release=%d.   ", NCR5380_PUBLIC_RELEASE);
+       if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400)
+               SPRINTF("ncr53c400 release=%d.  ", NCR53C400_PUBLIC_RELEASE);
 #ifdef DTC_PUBLIC_RELEASE
-   SPRINTF("DTC 3180/3280 release %d", DTC_PUBLIC_RELEASE);
+       SPRINTF("DTC 3180/3280 release %d", DTC_PUBLIC_RELEASE);
 #endif
 #ifdef T128_PUBLIC_RELEASE
-   SPRINTF("T128 release %d", T128_PUBLIC_RELEASE);
+       SPRINTF("T128 release %d", T128_PUBLIC_RELEASE);
 #endif
 #ifdef GENERIC_NCR5380_PUBLIC_RELEASE
-   SPRINTF("Generic5380 release %d", GENERIC_NCR5380_PUBLIC_RELEASE);
+       SPRINTF("Generic5380 release %d", GENERIC_NCR5380_PUBLIC_RELEASE);
 #endif
 #ifdef PAS16_PUBLIC_RELEASE
-SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
+       SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
 #endif
 
-   SPRINTF("\nBase Addr: 0x%05lX    ", (long)instance->base);
-   SPRINTF("io_port: %04x      ", (int)instance->io_port);
-   if (instance->irq == IRQ_NONE)
-      SPRINTF("IRQ: None.\n");
-   else
-      SPRINTF("IRQ: %d.\n", instance->irq);
+       SPRINTF("\nBase Addr: 0x%05lX    ", (long) instance->base);
+       SPRINTF("io_port: %04x      ", (int) instance->io_port);
+       if (instance->irq == IRQ_NONE)
+               SPRINTF("IRQ: None.\n");
+       else
+               SPRINTF("IRQ: %d.\n", instance->irq);
 
 #ifdef DTC_PUBLIC_RELEASE
-   SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n",
-        dtc_wmaxi, dtc_maxi);
+       SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n",
+               dtc_wmaxi, dtc_maxi);
 #endif
 #ifdef PAS16_PUBLIC_RELEASE
-   SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n",
-        pas_wmaxi, pas_maxi);
-#endif
-    cli();
-    SPRINTF("NCR5380 : coroutine is%s running.\n", main_running ? "" : "n't");
-    if (!hostdata->connected)
-      SPRINTF("scsi%d: no currently connected command\n", instance->host_no);
-   else
-      pos = lprint_Scsi_Cmnd ((Scsi_Cmnd *) hostdata->connected,
-        pos, buffer, length);
-   SPRINTF("scsi%d: issue_queue\n", instance->host_no);
-   for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr;
-        ptr = (Scsi_Cmnd *) ptr->host_scribble)
-        pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
-
-   SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
-   for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
-        ptr = (Scsi_Cmnd *) ptr->host_scribble)
-        pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
-
-   sti();
-   *start=buffer;
-  if (pos - buffer < offset)
-    return 0;
-  else if (pos - buffer - offset < length)
-    return pos - buffer - offset;
-  return length;
+       SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n",
+               pas_wmaxi, pas_maxi);
+#endif
+       save_flags(flags);
+       cli();
+       SPRINTF("NCR5380 : coroutine is%s running.\n", main_running ? "" : "n't");
+       if (!hostdata->connected)
+               SPRINTF("scsi%d: no currently connected command\n", instance->host_no);
+       else
+               pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected,
+                                      pos, buffer, length);
+       SPRINTF("scsi%d: issue_queue\n", instance->host_no);
+       for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr;
+            ptr = (Scsi_Cmnd *) ptr->host_scribble)
+               pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
+
+       SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
+       for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
+            ptr = (Scsi_Cmnd *) ptr->host_scribble)
+               pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
+
+       restore_flags(flags);
+       *start = buffer;
+       if (pos - buffer < offset)
+               return 0;
+       else if (pos - buffer - offset < length)
+               return pos - buffer - offset;
+       return length;
 }
 
-static 
-char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length) {
-   SPRINTF("scsi%d : destination target %d, lun %d\n",
-        cmd->host->host_no, cmd->target, cmd->lun);
-   SPRINTF("        command = ");
-   pos = lprint_command (cmd->cmnd, pos, buffer, length);
-   return (pos);
+static
+char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length)
+{
+       SPRINTF("scsi%d : destination target %d, lun %d\n",
+               cmd->host->host_no, cmd->target, cmd->lun);
+       SPRINTF("        command = ");
+       pos = lprint_command(cmd->cmnd, pos, buffer, length);
+       return (pos);
 }
 
-static 
-char *lprint_command (unsigned char *command,
-     char *pos, char *buffer, int length) {
-   int i, s;
-   pos = lprint_opcode(command[0], pos, buffer, length);
-   for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
-      SPRINTF("%02x ", command[i]);
-   SPRINTF("\n");
-   return(pos);
+static
+char *lprint_command(unsigned char *command,
+                    char *pos, char *buffer, int length)
+{
+       int i, s;
+       pos = lprint_opcode(command[0], pos, buffer, length);
+       for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
+               SPRINTF("%02x ", command[i]);
+       SPRINTF("\n");
+       return (pos);
 }
 
-static 
-char *lprint_opcode(int opcode, char *pos, char *buffer, int length) {
-   SPRINTF("%2d (0x%02x)", opcode, opcode);
-   return(pos);
+static
+char *lprint_opcode(int opcode, char *pos, char *buffer, int length)
+{
+       SPRINTF("%2d (0x%02x)", opcode, opcode);
+       return (pos);
 }
 
 
@@ -892,152 +992,152 @@ char *lprint_opcode(int opcode, char *pos, char *buffer, int length) {
  * Function : void NCR5380_init (struct Scsi_Host *instance, flags)
  *
  * Purpose : initializes *instance and corresponding 5380 chip,
- *     with flags OR'd into the initial flags value.
+ *      with flags OR'd into the initial flags value.
  *
  * Inputs : instance - instantiation of the 5380 driver.  
  *
  * Notes : I assume that the host, hostno, and id bits have been
- *     set correctly.  I don't care about the irq and other fields. 
+ *      set correctly.  I don't care about the irq and other fields. 
  * 
  */
 
-__initfunc(static void NCR5380_init (struct Scsi_Host *instance, int flags)) {
-    NCR5380_local_declare();
-    int i, pass;
-    unsigned long timeout;
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) 
+__initfunc(static void NCR5380_init(struct Scsi_Host *instance, int flags))
+{
+       NCR5380_local_declare();
+       int i, pass;
+       unsigned long timeout;
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
        instance->hostdata;
 
-    /* 
-     * On NCR53C400 boards, NCR5380 registers are mapped 8 past 
-     * the base address.
-     */
+       /* 
+        * On NCR53C400 boards, NCR5380 registers are mapped 8 past 
+        * the base address.
+        */
 
 #ifdef NCR53C400
-    if (flags & FLAG_NCR53C400)
-       instance->NCR5380_instance_name += NCR53C400_address_adjust;
+       if (flags & FLAG_NCR53C400)
+               instance->NCR5380_instance_name += NCR53C400_address_adjust;
 #endif
 
-    NCR5380_setup(instance);
+       NCR5380_setup(instance);
 
-    NCR5380_all_init();
+       NCR5380_all_init();
 
-    hostdata->aborted = 0;
-    hostdata->id_mask = 1 << instance->this_id;
-    for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
-       if (i > hostdata->id_mask)
-           hostdata->id_higher_mask |= i;
-    for (i = 0; i < 8; ++i)
-       hostdata->busy[i] = 0;
+       hostdata->aborted = 0;
+       hostdata->id_mask = 1 << instance->this_id;
+       for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
+               if (i > hostdata->id_mask)
+                       hostdata->id_higher_mask |= i;
+       for (i = 0; i < 8; ++i)
+               hostdata->busy[i] = 0;
 #ifdef REAL_DMA
-    hostdata->dmalen = 0;
+       hostdata->dmalen = 0;
 #endif
-    hostdata->targets_present = 0;
-    hostdata->connected = NULL;
-    hostdata->issue_queue = NULL;
-    hostdata->disconnected_queue = NULL;
+       hostdata->targets_present = 0;
+       hostdata->connected = NULL;
+       hostdata->issue_queue = NULL;
+       hostdata->disconnected_queue = NULL;
 #ifdef NCR5380_STATS
-    for (i = 0; i < 8; ++i) {
-       hostdata->time_read[i] = 0;
-       hostdata->time_write[i] = 0;
-       hostdata->bytes_read[i] = 0;
-       hostdata->bytes_write[i] = 0;
-    }
-    hostdata->timebase = 0;
-    hostdata->pendingw = 0;
-    hostdata->pendingr = 0;
-#endif
-
-    /* The CHECK code seems to break the 53C400. Will check it later maybe */
-    if (flags & FLAG_NCR53C400)
-       hostdata->flags = FLAG_HAS_LAST_BYTE_SENT | flags;
-    else
-       hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT | flags;
-
-    if (!the_template) {
-       the_template = instance->hostt;
-       first_instance = instance;
-    }
-       
+       for (i = 0; i < 8; ++i) {
+               hostdata->time_read[i] = 0;
+               hostdata->time_write[i] = 0;
+               hostdata->bytes_read[i] = 0;
+               hostdata->bytes_write[i] = 0;
+       }
+       hostdata->timebase = 0;
+       hostdata->pendingw = 0;
+       hostdata->pendingr = 0;
+#endif
 
+       /* The CHECK code seems to break the 53C400. Will check it later maybe */
+       if (flags & FLAG_NCR53C400)
+               hostdata->flags = FLAG_HAS_LAST_BYTE_SENT | flags;
+       else
+               hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT | flags;
+
+       if (!the_template) {
+               the_template = instance->hostt;
+               first_instance = instance;
+       }
 #ifdef USLEEP
-    hostdata->time_expires = 0;
-    hostdata->next_timer = NULL;
+       hostdata->time_expires = 0;
+       hostdata->next_timer = NULL;
 #endif
 
 #ifndef AUTOSENSE
-    if ((instance->cmd_per_lun > 1) || instance->can_queue > 1)) 
-        printk("scsi%d : WARNING : support for multiple outstanding commands enabled\n"
-               "         without AUTOSENSE option, contingent allegiance conditions may\n"
+       if ((instance->cmd_per_lun > 1) || instance->can_queue > 1)
+               )
+                   printk("scsi%d : WARNING : support for multiple outstanding commands enabled\n"
+                          "         without AUTOSENSE option, contingent allegiance conditions may\n"
                "         be incorrectly cleared.\n", instance->host_no);
-#endif /* def AUTOSENSE */
+#endif                         /* def AUTOSENSE */
 
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-    NCR5380_write(MODE_REG, MR_BASE);
-    NCR5380_write(TARGET_COMMAND_REG, 0);
-    NCR5380_write(SELECT_ENABLE_REG, 0);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+       NCR5380_write(MODE_REG, MR_BASE);
+       NCR5380_write(TARGET_COMMAND_REG, 0);
+       NCR5380_write(SELECT_ENABLE_REG, 0);
 
 #ifdef NCR53C400
-    if (hostdata->flags & FLAG_NCR53C400) {
-       NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE);
-    }
-#endif
-
-    /* 
-     * Detect and correct bus wedge problems.
-     *
-     * If the system crashed, it may have crashed in a state 
-     * where a SCSI command was still executing, and the 
-     * SCSI bus is not in a BUS FREE STATE.
-     *
-     * If this is the case, we'll try to abort the currently
-     * established nexus which we know nothing about, and that
-     * failing, do a hard reset of the SCSI bus 
-     */
-
-    for (pass = 1; (NCR5380_read(STATUS_REG) & SR_BSY) &&
-         pass <= 6 ; ++pass) {
-       switch (pass) {
-       case 1:
-       case 3:
-       case 5:
-           printk("scsi%d: SCSI bus busy, waiting up to five seconds\n",
-               instance->host_no);
-           timeout = jiffies + 5*HZ;
-           while (jiffies < timeout && (NCR5380_read(STATUS_REG) & SR_BSY));
-           break;
-       case 2:
-           printk("scsi%d: bus busy, attempting abort\n",
-               instance->host_no);
-           do_abort (instance);
-           break;
-       case 4:
-           printk("scsi%d: bus busy, attempting reset\n",
-               instance->host_no);
-           do_reset (instance);
-           break;
-       case 6:
-           printk("scsi%d: bus locked solid or invalid override\n",
-               instance->host_no);
+       if (hostdata->flags & FLAG_NCR53C400) {
+               NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE);
+       }
+#endif
+
+       /* 
+        * Detect and correct bus wedge problems.
+        *
+        * If the system crashed, it may have crashed in a state 
+        * where a SCSI command was still executing, and the 
+        * SCSI bus is not in a BUS FREE STATE.
+        *
+        * If this is the case, we'll try to abort the currently
+        * established nexus which we know nothing about, and that
+        * failing, do a hard reset of the SCSI bus 
+        */
+
+       for (pass = 1; (NCR5380_read(STATUS_REG) & SR_BSY) &&
+            pass <= 6; ++pass) {
+               switch (pass) {
+               case 1:
+               case 3:
+               case 5:
+                       printk("scsi%d: SCSI bus busy, waiting up to five seconds\n",
+                              instance->host_no);
+                       timeout = jiffies + 5 * HZ;
+                       while (jiffies < timeout && (NCR5380_read(STATUS_REG) & SR_BSY));
+                       break;
+               case 2:
+                       printk("scsi%d: bus busy, attempting abort\n",
+                              instance->host_no);
+                       do_abort(instance);
+                       break;
+               case 4:
+                       printk("scsi%d: bus busy, attempting reset\n",
+                              instance->host_no);
+                       do_reset(instance);
+                       break;
+               case 6:
+                       printk("scsi%d: bus locked solid or invalid override\n",
+                              instance->host_no);
+               }
        }
-    }
 }
 
 /* 
  * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, 
- *     void (*done)(Scsi_Cmnd *)) 
+ *      void (*done)(Scsi_Cmnd *)) 
  *
  * Purpose :  enqueues a SCSI command
  *
  * Inputs : cmd - SCSI command, done - function called on completion, with
- *     a pointer to the command descriptor.
+ *      a pointer to the command descriptor.
  * 
  * Returns : 0
  *
  * Side effects : 
  *      cmd is added to the per instance issue_queue, with minor 
- *     twiddling done to the host specific fields of cmd.  If the 
- *     main coroutine is not running, it is restarted.
+ *      twiddling done to the host specific fields of cmd.  If the 
+ *      main coroutine is not running, it is restarted.
  *
  */
 
@@ -1045,237 +1145,239 @@ __initfunc(static void NCR5380_init (struct Scsi_Host *instance, int flags)) {
 #ifndef NCR5380_queue_command
 static
 #endif
-int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) {
-    struct Scsi_Host *instance = cmd->host;
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
-       instance->hostdata;
-    Scsi_Cmnd *tmp;
+int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) {
+       struct Scsi_Host *instance = cmd->host;
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+        instance->hostdata;
+       Scsi_Cmnd *tmp;
 
 #if (NDEBUG & NDEBUG_NO_WRITE)
-    switch (cmd->cmnd[0]) {
-    case WRITE_6:
-    case WRITE_10:
-       printk("scsi%d : WRITE attempted with NO_WRITE debugging flag set\n",
-           instance->host_no);
-       cmd->result = (DID_ERROR << 16);
-       done(cmd);
-       return 0;
-    }
-#endif /* (NDEBUG & NDEBUG_NO_WRITE) */
+       switch (cmd->cmnd[0]) {
+               case WRITE_6:
+                   case WRITE_10:
+                   printk("scsi%d : WRITE attempted with NO_WRITE debugging flag set\n",
+                          instance->host_no);
+               cmd->result = (DID_ERROR << 16);
+               done(cmd);
+               return 0;
+       }
+#endif                         /* (NDEBUG & NDEBUG_NO_WRITE) */
 
 #ifdef NCR5380_STATS
-# if 0
-    if (!hostdata->connected && !hostdata->issue_queue &&
-       !hostdata->disconnected_queue) {
-       hostdata->timebase = jiffies;
-    }
-# endif
-# ifdef NCR5380_STAT_LIMIT
-    if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
-# endif
-       switch (cmd->cmnd[0])
-       {
-           case WRITE:
-           case WRITE_6:
-           case WRITE_10:
-               hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase);
-               hostdata->bytes_write[cmd->target] += cmd->request_bufflen;
-               hostdata->pendingw++;
-               break;
-           case READ:
-           case READ_6:
-           case READ_10:
-               hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase);
-               hostdata->bytes_read[cmd->target] += cmd->request_bufflen;
-               hostdata->pendingr++;
-               break;
+#if 0
+       if (!hostdata->connected && !hostdata->issue_queue &&
+           !hostdata->disconnected_queue) {
+               hostdata->timebase = jiffies;
        }
 #endif
+#ifdef NCR5380_STAT_LIMIT
+       if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
+#endif
+               switch (cmd->cmnd[0]) {
+                       case WRITE:
+                           case WRITE_6:
+                           case WRITE_10:
+                           hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase);
+                       hostdata->bytes_write[cmd->target] += cmd->request_bufflen;
+                       hostdata->pendingw++;
+                       break;
+                       case READ:
+                           case READ_6:
+                           case READ_10:
+                           hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase);
+                       hostdata->bytes_read[cmd->target] += cmd->request_bufflen;
+                       hostdata->pendingr++;
+                       break;
+               }
+#endif
 
-    /* 
-     * We use the host_scribble field as a pointer to the next command  
-     * in a queue 
-     */
+       /* 
+        * We use the host_scribble field as a pointer to the next command  
+        * in a queue 
+        */
 
-    cmd->host_scribble = NULL;
-    cmd->scsi_done = done;
+       cmd->host_scribble = NULL;
+       cmd->scsi_done = done;
 
-    cmd->result = 0;
+       cmd->result = 0;
 
 
-    /* 
-     * Insert the cmd into the issue queue. Note that REQUEST SENSE 
-     * commands are added to the head of the queue since any command will
-     * clear the contingent allegiance condition that exists and the 
-     * sense data is only guaranteed to be valid while the condition exists.
-     */
+       /* 
+        * Insert the cmd into the issue queue. Note that REQUEST SENSE 
+        * commands are added to the head of the queue since any command will
+        * clear the contingent allegiance condition that exists and the 
+        * sense data is only guaranteed to be valid while the condition exists.
+        */
 
-    cli();
-    if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
-       LIST(cmd, hostdata->issue_queue);
-       cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
-       hostdata->issue_queue = cmd;
-    } else {
-       for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; 
-               tmp = (Scsi_Cmnd *) tmp->host_scribble);
-       LIST(cmd, tmp);
-       tmp->host_scribble = (unsigned char *) cmd;
-    }
+       cli();
+       if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
+               LIST(cmd, hostdata->issue_queue);
+               cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
+               hostdata->issue_queue = cmd;
+       } else {
+               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble;
+                    tmp = (Scsi_Cmnd *) tmp->host_scribble);
+               LIST(cmd, tmp);
+               tmp->host_scribble = (unsigned char *) cmd;
+       }
 #if (NDEBUG & NDEBUG_QUEUES)
-    printk("scsi%d : command added to %s of queue\n", instance->host_no,
-       (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail");
+       printk("scsi%d : command added to %s of queue\n", instance->host_no,
+              (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail");
 #endif
 
 /* Run the coroutine if it isn't already running. */
-    run_main();
-    return 0;
+       run_main();
+       return 0;
 }
 
 /*
  * Function : NCR5380_main (void) 
  *
  * Purpose : NCR5380_main is a coroutine that runs as long as more work can 
- *     be done on the NCR5380 host adapters in a system.  Both 
- *     NCR5380_queue_command() and NCR5380_intr() will try to start it 
- *     in case it is not running.
+ *      be done on the NCR5380 host adapters in a system.  Both 
+ *      NCR5380_queue_command() and NCR5380_intr() will try to start it 
+ *      in case it is not running.
  * 
  * NOTE : NCR5380_main exits with interrupts *disabled*, the caller should 
  *  reenable them.  This prevents reentrancy and kernel stack overflow.
- */    
-    
-static void NCR5380_main (void) {
-    Scsi_Cmnd *tmp, *prev;
-    struct Scsi_Host *instance;
-    struct NCR5380_hostdata *hostdata;
-    int done;
-
-    /*
-     * We run (with interrupts disabled) until we're sure that none of 
-     * the host adapters have anything that can be done, at which point 
-     * we set main_running to 0 and exit.
-     *
-     * Interrupts are enabled before doing various other internal 
-     * instructions, after we've decided that we need to run through
-     * the loop again.
-     *
-     * this should prevent any race conditions.
-     */
-
-    do {
-       cli(); /* Freeze request queues */
-       done = 1;
-       for (instance = first_instance; instance && 
-           instance->hostt == the_template; instance=instance->next) {
-           hostdata = (struct NCR5380_hostdata *) instance->hostdata;
-           cli();
-           if (!hostdata->connected) {
+ */
+
+static void NCR5380_main(void) {
+       Scsi_Cmnd *tmp, *prev;
+       struct Scsi_Host *instance;
+       struct NCR5380_hostdata *hostdata;
+       int done;
+
+       /*
+        * We run (with interrupts disabled) until we're sure that none of 
+        * the host adapters have anything that can be done, at which point 
+        * we set main_running to 0 and exit.
+        *
+        * Interrupts are enabled before doing various other internal 
+        * instructions, after we've decided that we need to run through
+        * the loop again.
+        *
+        * this should prevent any race conditions.
+        */
+
+       do {
+               cli();          /* Freeze request queues */
+               done = 1;
+               for (instance = first_instance; instance &&
+                    instance->hostt == the_template; instance = instance->next) {
+                       unsigned long flags;
+                        hostdata = (struct NCR5380_hostdata *) instance->hostdata;
+                        save_flags(flags);
+                        cli();
+                       if (!hostdata->connected) {
 #if (NDEBUG & NDEBUG_MAIN)
-               printk("scsi%d : not connected\n", instance->host_no);
+                               printk("scsi%d : not connected\n", instance->host_no);
 #endif
-               /*
-                * Search through the issue_queue for a command destined
-                * for a target that's not busy.
-                */
+                               /*
+                                * Search through the issue_queue for a command destined
+                                * for a target that's not busy.
+                                */
 #if (NDEBUG & NDEBUG_LISTS)
-               for (tmp= (Scsi_Cmnd *) hostdata->issue_queue, prev=NULL; tmp && (tmp != prev); prev=tmp, tmp=(Scsi_Cmnd*)tmp->host_scribble)
-                   ;
-                   /*printk("%p  ", tmp);*/
-               if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/
+                               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp && (tmp != prev); prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble);
+                               /*printk("%p  ", tmp); */
+                               if ((tmp == prev) && tmp)
+                                       printk(" LOOP\n");      /* else printk("\n"); */
 #endif
-               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, 
-                   prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) 
-                   tmp->host_scribble) {
+                               for (tmp = (Scsi_Cmnd *) hostdata->issue_queue,
+                                    prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *)
+                                    tmp->host_scribble) {
 
 #if (NDEBUG & NDEBUG_LISTS)
-                   if (prev != tmp)
-                       printk("MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->target, hostdata->busy[tmp->target], tmp->lun);
-#endif
-                   /*  When we find one, remove it from the issue queue. */
-                   if (!(hostdata->busy[tmp->target] & (1 << tmp->lun))) {
-                       if (prev) {
-                           REMOVE(prev,prev->host_scribble,tmp,tmp->host_scribble);
-                           prev->host_scribble = tmp->host_scribble;
-                       } else {
-                           REMOVE(-1,hostdata->issue_queue,tmp,tmp->host_scribble);
-                           hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble;
-                       }
-                       tmp->host_scribble = NULL;
-
-                       /* reenable interrupts after finding one */
-                       sti();
-
-                       /* 
-                        * Attempt to establish an I_T_L nexus here. 
-                        * On success, instance->hostdata->connected is set.
-                        * On failure, we must add the command back to the
-                        *   issue queue so we can keep trying. 
-                        */
+                                       if (prev != tmp)
+                                               printk("MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->target, hostdata->busy[tmp->target], tmp->lun);
+#endif
+                                       /*  When we find one, remove it from the issue queue. */
+                                       if (!(hostdata->busy[tmp->target] & (1 << tmp->lun))) {
+                                               if (prev) {
+                                                       REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
+                                                       prev->host_scribble = tmp->host_scribble;
+                                               } else {
+                                                       REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble);
+                                                       hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble;
+                                               }
+                                               tmp->host_scribble = NULL;
+
+                                               /* reenable interrupts after finding one */
+                                               restore_flags(flags);
+
+                                               /* 
+                                                * Attempt to establish an I_T_L nexus here. 
+                                                * On success, instance->hostdata->connected is set.
+                                                * On failure, we must add the command back to the
+                                                *   issue queue so we can keep trying. 
+                                                */
 #if (NDEBUG & (NDEBUG_MAIN | NDEBUG_QUEUES))
-                       printk("scsi%d : main() : command for target %d lun %d removed from issue_queue\n",
-                           instance->host_no, tmp->target, tmp->lun);
-#endif
-               
-                       /*
-                        * A successful selection is defined as one that 
-                        * leaves us with the command connected and 
-                        * in hostdata->connected, OR has terminated the
-                        * command.
-                        *
-                        * With successful commands, we fall through
-                        * and see if we can do an information transfer,
-                        * with failures we will restart.
-                        */
-
-                       if (!NCR5380_select(instance, tmp, 
-                       /* 
-                        * REQUEST SENSE commands are issued without tagged
-                        * queueing, even on SCSI-II devices because the 
-                        * contingent allegiance condition exists for the 
-                        * entire unit.
-                        */
-                           (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : 
-                           TAG_NEXT)) {
-                           break;
-                       } else {
-                           cli();
-                           LIST(tmp, hostdata->issue_queue);
-                           tmp->host_scribble = (unsigned char *) 
-                               hostdata->issue_queue;
-                           hostdata->issue_queue = tmp;
-                           done = 0;
-                           sti();
+                                               printk("scsi%d : main() : command for target %d lun %d removed from issue_queue\n",
+                                                      instance->host_no, tmp->target, tmp->lun);
+#endif
+
+                                               /*
+                                                * A successful selection is defined as one that 
+                                                * leaves us with the command connected and 
+                                                * in hostdata->connected, OR has terminated the
+                                                * command.
+                                                *
+                                                * With successful commands, we fall through
+                                                * and see if we can do an information transfer,
+                                                * with failures we will restart.
+                                                */
+
+                                               if (!NCR5380_select(instance, tmp,
+                                               /* 
+                                                * REQUEST SENSE commands are issued without tagged
+                                                * queueing, even on SCSI-II devices because the 
+                                                * contingent allegiance condition exists for the 
+                                                * entire unit.
+                                                */
+                                                                   (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE :
+                                                            TAG_NEXT)) {
+                                                       break;
+                                               } else {
+                                                       unsigned long flags;
+                                                       save_flags(flags);
+                                                       cli();
+                                                       LIST(tmp, hostdata->issue_queue);
+                                                       tmp->host_scribble = (unsigned char *)
+                                                           hostdata->issue_queue;
+                                                       hostdata->issue_queue = tmp;
+                                                       done = 0;
+                                                       restore_flags(flags);
 #if (NDEBUG & (NDEBUG_MAIN | NDEBUG_QUEUES))
-                       printk("scsi%d : main(): select() failed, returned to issue_queue\n",
-                           instance->host_no);
-#endif
-                       }
-                   } /* if target/lun is not busy */
-               } /* for */
-           } /* if (!hostdata->connected) */
-               
-           if (hostdata->connected 
+                                                       printk("scsi%d : main(): select() failed, returned to issue_queue\n",
+                                                              instance->host_no);
+#endif
+                                               }
+                                       }       /* if target/lun is not busy */
+                               }       /* for */
+                       }       /* if (!hostdata->connected) */
+                       if (hostdata->connected
 #ifdef REAL_DMA
-               && !hostdata->dmalen
+                           && !hostdata->dmalen
 #endif
 #ifdef USLEEP
-               && (!hostdata->time_expires || hostdata->time_expires >= jiffies)
+                           && (!hostdata->time_expires || hostdata->time_expires >= jiffies)
 #endif
-               ) {
-               sti();
+                           ) {
+                               restore_flags(flags);
 #if (NDEBUG & NDEBUG_MAIN)
-               printk("scsi%d : main() : performing information transfer\n",
-                       instance->host_no);
+                               printk("scsi%d : main() : performing information transfer\n",
+                                      instance->host_no);
 #endif
-               NCR5380_information_transfer(instance);
+                               NCR5380_information_transfer(instance);
 #if (NDEBUG & NDEBUG_MAIN)
-               printk("scsi%d : main() : done set false\n", instance->host_no);
-#endif
-               done = 0;
-           } else 
-               break;
-       } /* for instance */
-    } while (!done);
-    main_running = 0;
+                               printk("scsi%d : main() : done set false\n", instance->host_no);
+#endif
+                               done = 0;
+                       } else
+                               break;
+               }               /* for instance */
+       } while (!done);
+       main_running = 0;
 }
 
 #ifndef DONT_USE_INTR
@@ -1286,489 +1388,481 @@ static void NCR5380_main (void) {
  * Function : void NCR5380_intr (int irq)
  * 
  * Purpose : handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses
- *     from the disconnected queue, and restarting NCR5380_main() 
- *     as required.
+ *      from the disconnected queue, and restarting NCR5380_main() 
+ *      as required.
  *
  * Inputs : int irq, irq that caused this interrupt.
  *
  */
 
-static void NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs) {
-    NCR5380_local_declare(); 
-    struct Scsi_Host *instance;
-    int done;
-    unsigned char basr;
+static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) {
+       NCR5380_local_declare();
+       struct Scsi_Host *instance;
+       int done;
+       unsigned char basr;
+       unsigned long flags;
+
+        save_flags(flags);
+        cli();
 #if (NDEBUG & NDEBUG_INTR)
-    printk("scsi : NCR5380 irq %d triggered\n", irq);
-#endif
-    do {
-       done = 1;
-       for (instance = first_instance; instance && (instance->hostt == 
-           the_template); instance = instance->next)
-           if (instance->irq == irq) {
-               
-               /* Look for pending interrupts */
-               NCR5380_setup(instance);
-               basr = NCR5380_read(BUS_AND_STATUS_REG);
-               /* XXX dispatch to appropriate routine if found and done=0 */
-               if (basr & BASR_IRQ) {
+        printk("scsi : NCR5380 irq %d triggered\n", irq);
+#endif
+       do {
+               done = 1;
+               for (instance = first_instance; instance && (instance->hostt ==
+                               the_template); instance = instance->next)
+                       if (instance->irq == irq) {
+
+                               /* Look for pending interrupts */
+                               NCR5380_setup(instance);
+                               basr = NCR5380_read(BUS_AND_STATUS_REG);
+                               /* XXX dispatch to appropriate routine if found and done=0 */
+                               if (basr & BASR_IRQ) {
 #if (NDEBUG & NDEBUG_INTR)
-                   NCR5380_print(instance);
+                                       NCR5380_print(instance);
 #endif
-                   if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == 
-                       (SR_SEL | SR_IO)) {
-                       done = 0;
-                       sti();
+                                       if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) ==
+                                           (SR_SEL | SR_IO)) {
+                                               done = 0;
+                                               restore_flags(flags);
 #if (NDEBUG & NDEBUG_INTR)
-                       printk("scsi%d : SEL interrupt\n", instance->host_no);
+                                               printk("scsi%d : SEL interrupt\n", instance->host_no);
 #endif
-                       NCR5380_reselect(instance);
-                       (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-                   } else if (basr & BASR_PARITY_ERROR) {
+                                               NCR5380_reselect(instance);
+                                               (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+                                       } else if (basr & BASR_PARITY_ERROR) {
 #if (NDEBUG & NDEBUG_INTR)
-                       printk("scsi%d : PARITY interrupt\n", instance->host_no);
+                                               printk("scsi%d : PARITY interrupt\n", instance->host_no);
 #endif
-                       (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-                   } else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
+                                               (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+                                       } else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
 #if (NDEBUG & NDEBUG_INTR)
-                       printk("scsi%d : RESET interrupt\n", instance->host_no);
+                                               printk("scsi%d : RESET interrupt\n", instance->host_no);
 #endif
-                       (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-                   } else {
+                                               (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+                                       } else {
 /*  
  * XXX the rest of the interrupt conditions should *only* occur during a 
  * DMA transfer, which I haven't gotten around to fixing yet.
  */
 
 #if defined(REAL_DMA)
-                   /*
-                    * We should only get PHASE MISMATCH and EOP interrupts
-                    * if we have DMA enabled, so do a sanity check based on
-                    * the current setting of the MODE register.
-                    */
-
-                       if ((NCR5380_read(MODE_REG) & MR_DMA) && ((basr & 
-                           BASR_END_DMA_TRANSFER) || 
-                           !(basr & BASR_PHASE_MATCH))) {
-                           int transfered;
-
-                           if (!hostdata->connected) 
-                               panic("scsi%d : received end of DMA interrupt with no connected cmd\n",
-                                   instance->hostno);
-
-                           transfered = (hostdata->dmalen - NCR5380_dma_residual(instance));
-                           hostdata->connected->SCp.this_residual -= transferred;
-                           hostdata->connected->SCp.ptr += transferred;
-                           hostdata->dmalen = 0;
-
-                           (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+                                               /*
+                                                * We should only get PHASE MISMATCH and EOP interrupts
+                                                * if we have DMA enabled, so do a sanity check based on
+                                                * the current setting of the MODE register.
+                                                */
+
+                                               if ((NCR5380_read(MODE_REG) & MR_DMA) && ((basr &
+                                               BASR_END_DMA_TRANSFER) ||
+                                                                                         !(basr & BASR_PHASE_MATCH))) {
+                                                       int transfered;
+
+                                                       if (!hostdata->connected)
+                                                               panic("scsi%d : received end of DMA interrupt with no connected cmd\n",
+                                                                     instance->hostno);
+
+                                                       transfered = (hostdata->dmalen - NCR5380_dma_residual(instance));
+                                                       hostdata->connected->SCp.this_residual -= transferred;
+                                                       hostdata->connected->SCp.ptr += transferred;
+                                                       hostdata->dmalen = 0;
+
+                                                       (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 #if NCR_TIMEOUT
-                           {
-                             unsigned long timeout = jiffies + NCR_TIMEOUT;
-
-                             while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK
-                                    && jiffies < timeout)
-                               ;
-                             if (jiffies >= timeout)
-                               printk("scsi%d: timeout at NCR5380.c:%d\n", 
-                                   host->host_no, __LINE__);
-                           }
-#else /* NCR_TIMEOUT */
-                           while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK);
-#endif
-
-                           NCR5380_write(MODE_REG, MR_BASE);
-                           NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                       }
+                                                       {
+                                                               unsigned long timeout = jiffies + NCR_TIMEOUT;
+
+                                                               while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK
+                                                                      && jiffies < timeout);
+                                                               if (jiffies >= timeout)
+                                                                       printk("scsi%d: timeout at NCR5380.c:%d\n",
+                                                                              host->host_no, __LINE__);
+                                                       }
+#else                          /* NCR_TIMEOUT */
+                                                       while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK);
+#endif
+
+                                                       NCR5380_write(MODE_REG, MR_BASE);
+                                                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                               }
 #else
 #if (NDEBUG & NDEBUG_INTR)
-                   printk("scsi : unknown interrupt, BASR 0x%X, MR 0x%X, SR 0x%x\n", basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG));
+                                               printk("scsi : unknown interrupt, BASR 0x%X, MR 0x%X, SR 0x%x\n", basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG));
 #endif
-                   (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+                                               (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 #endif
-                   } 
-               } /* if BASR_IRQ */
-               if (!done) 
-                   run_main();
-           } /* if (instance->irq == irq) */
-    } while (!done);
+                                       }
+                               }       /* if BASR_IRQ */
+                               if (!done)
+                                       run_main();
+                       }       /* if (instance->irq == irq) */
+       } while (!done);
 }
 
 
-static void do_NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs) {
-    unsigned long flags;
+static void do_NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) {
+       unsigned long flags;
 
-    spin_lock_irqsave(&io_request_lock, flags);
-    NCR5380_intr(irq, dev_id, regs);
-    spin_unlock_irqrestore(&io_request_lock, flags);
+        spin_lock_irqsave(&io_request_lock, flags);
+        NCR5380_intr(irq, dev_id, regs);
+        spin_unlock_irqrestore(&io_request_lock, flags);
 }
 
 #endif
 
 #ifdef NCR5380_STATS
-static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
-{
-# ifdef NCR5380_STAT_LIMIT
-    if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
-# endif
-       switch (cmd->cmnd[0])
-       {
-           case WRITE:
-           case WRITE_6:
-           case WRITE_10:
-               hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase);
-               /*hostdata->bytes_write[cmd->target] += cmd->request_bufflen;*/
-               hostdata->pendingw--;
-               break;
-           case READ:
-           case READ_6:
-           case READ_10:
-               hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase);
-               /*hostdata->bytes_read[cmd->target] += cmd->request_bufflen;*/
-               hostdata->pendingr--;
-               break;
-       }
+static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) {
+#ifdef NCR5380_STAT_LIMIT
+       if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
+#endif
+               switch (cmd->cmnd[0]) {
+                       case WRITE:
+                           case WRITE_6:
+                           case WRITE_10:
+                           hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase);
+                       /*hostdata->bytes_write[cmd->target] += cmd->request_bufflen; */
+                       hostdata->pendingw--;
+                       break;
+                       case READ:
+                       case READ_6:
+                       case READ_10:
+                       hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase);
+                       /*hostdata->bytes_read[cmd->target] += cmd->request_bufflen; */
+                       hostdata->pendingr--;
+                       break;
+               }
 }
 #endif
-
 /* 
  * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 
- *     int tag);
+ *      int tag);
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
- *     including ARBITRATION, SELECTION, and initial message out for 
- *     IDENTIFY and queue messages. 
+ *      including ARBITRATION, SELECTION, and initial message out for 
+ *      IDENTIFY and queue messages. 
  *
  * Inputs : instance - instantiation of the 5380 driver on which this 
- *     target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for 
- *     new tag, TAG_NONE for untagged queueing, otherwise set to the tag for 
- *     the command that is presently connected.
+ *      target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for 
+ *      new tag, TAG_NONE for untagged queueing, otherwise set to the tag for 
+ *      the command that is presently connected.
  * 
  * Returns : -1 if selection could not execute for some reason,
- *     0 if selection succeeded or failed because the target 
- *     did not respond.
+ *      0 if selection succeeded or failed because the target 
+ *      did not respond.
  *
  * Side effects : 
- *     If bus busy, arbitration failed, etc, NCR5380_select() will exit 
- *             with registers as they should have been on entry - ie
- *             SELECT_ENABLE will be set appropriately, the NCR5380
- *             will cease to drive any SCSI bus signals.
+ *      If bus busy, arbitration failed, etc, NCR5380_select() will exit 
+ *              with registers as they should have been on entry - ie
+ *              SELECT_ENABLE will be set appropriately, the NCR5380
+ *              will cease to drive any SCSI bus signals.
  *
- *     If successful : I_T_L or I_T_L_Q nexus will be established, 
- *             instance->connected will be set to cmd.  
- *             SELECT interrupt will be disabled.
+ *      If successful : I_T_L or I_T_L_Q nexus will be established, 
+ *              instance->connected will be set to cmd.  
+ *              SELECT interrupt will be disabled.
  *
- *     If failed (no target) : cmd->scsi_done() will be called, and the 
- *             cmd->result host byte set to DID_BAD_TARGET.
+ *      If failed (no target) : cmd->scsi_done() will be called, and the 
+ *              cmd->result host byte set to DID_BAD_TARGET.
  */
+static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) {
+       NCR5380_local_declare();
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
+       unsigned char tmp[3], phase;
+       unsigned char *data;
+       int len;
+       unsigned long timeout;
+       unsigned long flags;
+
+        NCR5380_setup(instance);
+
+        hostdata->restart_select = 0;
+#if defined (NDEBUG) && (NDEBUG & NDEBUG_ARBITRATION)
+        NCR5380_print(instance);
+        printk("scsi%d : starting arbitration, id = %d\n", instance->host_no,
+               instance->this_id);
+#endif
+        save_flags(flags);
+        cli();
 
-static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
-    int tag) {
-    NCR5380_local_declare();
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata*) 
-       instance->hostdata;
-    unsigned char tmp[3], phase;
-    unsigned char *data;
-    int len;
-    unsigned long timeout;
-    NCR5380_setup(instance);
-
-    hostdata->restart_select = 0;
-#if defined (NDEBUG) && (NDEBUG & NDEBUG_ARBITRATION) 
-    NCR5380_print(instance);
-    printk("scsi%d : starting arbitration, id = %d\n", instance->host_no,
-       instance->this_id);
-#endif
-    cli(); 
+       /* 
+        * Set the phase bits to 0, otherwise the NCR5380 won't drive the 
+        * data bus during SELECTION.
+        */
 
-    /* 
-     * Set the phase bits to 0, otherwise the NCR5380 won't drive the 
-     * data bus during SELECTION.
-     */
+        NCR5380_write(TARGET_COMMAND_REG, 0);
 
-    NCR5380_write(TARGET_COMMAND_REG, 0);
 
+       /* 
+        * Start arbitration.
+        */
 
-    /* 
-     * Start arbitration.
-     */
-    
-    NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
-    NCR5380_write(MODE_REG, MR_ARBITRATE);
+        NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
+        NCR5380_write(MODE_REG, MR_ARBITRATE);
 
-    sti();
+        restore_flags(flags);
 
-    /* Wait for arbitration logic to complete */
+       /* Wait for arbitration logic to complete */
 #if NCR_TIMEOUT
-    {
-      unsigned long timeout = jiffies + 2*NCR_TIMEOUT;
-
-      while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
-          && jiffies < timeout)
-       ;
-      if (jiffies >= timeout)
-      {
-       printk("scsi: arbitration timeout at %d\n", __LINE__);
-       NCR5380_write(MODE_REG, MR_BASE);
-       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-       return -1;
-      }
-    }
-#else /* NCR_TIMEOUT */
-    while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS));
+       {
+               unsigned long timeout = jiffies + 2 * NCR_TIMEOUT;
+
+               while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
+                      && jiffies < timeout);
+               if (jiffies >= timeout) {
+                       printk("scsi: arbitration timeout at %d\n", __LINE__);
+                       NCR5380_write(MODE_REG, MR_BASE);
+                       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                       return -1;
+               }
+       }
+#else                          /* NCR_TIMEOUT */
+       while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS));
 #endif
 
-#if (NDEBUG & NDEBUG_ARBITRATION) 
-    printk("scsi%d : arbitration complete\n", instance->host_no);
+#if (NDEBUG & NDEBUG_ARBITRATION)
+        printk("scsi%d : arbitration complete\n", instance->host_no);
 /* Avoid GCC 2.4.5 asm needs to many reloads error */
-    __asm__("nop");
+        __asm__("nop");
 #endif
 
-    /* 
-     * The arbitration delay is 2.2us, but this is a minimum and there is 
-     * no maximum so we can safely sleep for ceil(2.2) usecs to accommodate
-     * the integral nature of udelay().
-     *
-     */
+       /* 
+        * The arbitration delay is 2.2us, but this is a minimum and there is 
+        * no maximum so we can safely sleep for ceil(2.2) usecs to accommodate
+        * the integral nature of udelay().
+        *
+        */
 
-    udelay(3);
+        udelay(3);
 
-    /* Check for lost arbitration */
-    if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
-       (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) ||
-       (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) {
-       NCR5380_write(MODE_REG, MR_BASE); 
+       /* Check for lost arbitration */
+       if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
+            (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) ||
+         (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) {
+               NCR5380_write(MODE_REG, MR_BASE);
 #if (NDEBUG & NDEBUG_ARBITRATION)
-    printk("scsi%d : lost arbitration, deasserting MR_ARBITRATE\n", 
-       instance->host_no);
+               printk("scsi%d : lost arbitration, deasserting MR_ARBITRATE\n",
+                      instance->host_no);
 #endif
-       return -1;
-    }
+               return -1;
+       }
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_SEL);
 
+       if (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) {
+               NCR5380_write(MODE_REG, MR_BASE);
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+#if (NDEBUG & NDEBUG_ARBITRATION)
+               printk("scsi%d : lost arbitration, deasserting ICR_ASSERT_SEL\n",
+                      instance->host_no);
+#endif
+               return -1;
+       }
+       /* 
+        * Again, bus clear + bus settle time is 1.2us, however, this is 
+        * a minimum so we'll udelay ceil(1.2)
+        */
 
+       udelay(2);
 
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_SEL);
-    
-    if (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) {
-       NCR5380_write(MODE_REG, MR_BASE);
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 #if (NDEBUG & NDEBUG_ARBITRATION)
-    printk("scsi%d : lost arbitration, deasserting ICR_ASSERT_SEL\n", 
-       instance->host_no);
+       printk("scsi%d : won arbitration\n", instance->host_no);
 #endif
-       return -1;
-    }
 
-    /* 
-     * Again, bus clear + bus settle time is 1.2us, however, this is 
-     * a minimum so we'll udelay ceil(1.2)
-     */
 
-    udelay(2); 
+       /* 
+        * Now that we have won arbitration, start Selection process, asserting 
+        * the host and target ID's on the SCSI bus.
+        */
+
+       NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->target)));
 
-#if (NDEBUG & NDEBUG_ARBITRATION)
-    printk("scsi%d : won arbitration\n", instance->host_no);
-#endif
-
-
-    /* 
-     * Now that we have won arbitration, start Selection process, asserting 
-     * the host and target ID's on the SCSI bus.
-     */
-
-    NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->target)));
-
-    /* 
-     * Raise ATN while SEL is true before BSY goes false from arbitration,
-     * since this is the only way to guarantee that we'll get a MESSAGE OUT
-     * phase immediately after selection.
-     */
-
-    NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY | 
-       ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL ));
-    NCR5380_write(MODE_REG, MR_BASE);
-
-    /* 
-     * Reselect interrupts must be turned off prior to the dropping of BSY,
-     * otherwise we will trigger an interrupt.
-     */
-    NCR5380_write(SELECT_ENABLE_REG, 0);
-
-    /*
-     * The initiator shall then wait at least two deskew delays and release 
-     * the BSY signal.
-     */
-    udelay(1);        /* wingel -- wait two bus deskew delay >2*45ns */
-
-    /* Reset BSY */
-    NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA | 
-       ICR_ASSERT_ATN | ICR_ASSERT_SEL));
-
-    /* 
-     * Something weird happens when we cease to drive BSY - looks
-     * like the board/chip is letting us do another read before the 
-     * appropriate propagation delay has expired, and we're confusing
-     * a BSY signal from ourselves as the target's response to SELECTION.
-     *
-     * A small delay (the 'C++' frontend breaks the pipeline with an
-     * unnecessary jump, making it work on my 386-33/Trantor T128, the
-     * tighter 'C' code breaks and requires this) solves the problem - 
-     * the 1 us delay is arbitrary, and only used because this delay will 
-     * be the same on other platforms and since it works here, it should 
-     * work there.
-     *
-     * wingel suggests that this could be due to failing to wait
-     * one deskew delay.
-     */
-
-    udelay(1);
+       /* 
+        * Raise ATN while SEL is true before BSY goes false from arbitration,
+        * since this is the only way to guarantee that we'll get a MESSAGE OUT
+        * phase immediately after selection.
+        */
+
+       NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY |
+                    ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL));
+       NCR5380_write(MODE_REG, MR_BASE);
+
+       /* 
+        * Reselect interrupts must be turned off prior to the dropping of BSY,
+        * otherwise we will trigger an interrupt.
+        */
+       NCR5380_write(SELECT_ENABLE_REG, 0);
+
+       /*
+        * The initiator shall then wait at least two deskew delays and release 
+        * the BSY signal.
+        */
+       udelay(1);              /* wingel -- wait two bus deskew delay >2*45ns */
+
+       /* Reset BSY */
+       NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA |
+                                      ICR_ASSERT_ATN | ICR_ASSERT_SEL));
+
+       /* 
+        * Something weird happens when we cease to drive BSY - looks
+        * like the board/chip is letting us do another read before the 
+        * appropriate propagation delay has expired, and we're confusing
+        * a BSY signal from ourselves as the target's response to SELECTION.
+        *
+        * A small delay (the 'C++' frontend breaks the pipeline with an
+        * unnecessary jump, making it work on my 386-33/Trantor T128, the
+        * tighter 'C' code breaks and requires this) solves the problem - 
+        * the 1 us delay is arbitrary, and only used because this delay will 
+        * be the same on other platforms and since it works here, it should 
+        * work there.
+        *
+        * wingel suggests that this could be due to failing to wait
+        * one deskew delay.
+        */
+
+       udelay(1);
 
 #if (NDEBUG & NDEBUG_SELECTION)
-    printk("scsi%d : selecting target %d\n", instance->host_no, cmd->target);
+       printk("scsi%d : selecting target %d\n", instance->host_no, cmd->target);
 #endif
 
-    /* 
-     * The SCSI specification calls for a 250 ms timeout for the actual 
-     * selection.
-     */
+       /* 
+        * The SCSI specification calls for a 250 ms timeout for the actual 
+        * selection.
+        */
 
-    timeout = jiffies + (250*HZ/1000); 
+       timeout = jiffies + (250 * HZ / 1000);
 
-    /* 
-     * XXX very interesting - we're seeing a bounce where the BSY we 
-     * asserted is being reflected / still asserted (propagation delay?)
-     * and it's detecting as true.  Sigh.
-     */
+       /* 
+        * XXX very interesting - we're seeing a bounce where the BSY we 
+        * asserted is being reflected / still asserted (propagation delay?)
+        * and it's detecting as true.  Sigh.
+        */
 
-    while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) & 
-       (SR_BSY | SR_IO)));
+       while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) &
+                                       (SR_BSY | SR_IO)));
 
-    if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == 
+       if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) ==
            (SR_SEL | SR_IO)) {
-           NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-           NCR5380_reselect(instance);
-           printk ("scsi%d : reselection after won arbitration?\n",
-               instance->host_no);
-           NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-           return -1;
-    }
-
-    /* 
-     * No less than two deskew delays after the initiator detects the 
-     * BSY signal is true, it shall release the SEL signal and may 
-     * change the DATA BUS.                                     -wingel
-     */
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+               NCR5380_reselect(instance);
+               printk("scsi%d : reselection after won arbitration?\n",
+                      instance->host_no);
+               NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+               return -1;
+       }
+       /* 
+        * No less than two deskew delays after the initiator detects the 
+        * BSY signal is true, it shall release the SEL signal and may 
+        * change the DATA BUS.                                     -wingel
+        */
 
-    udelay(1);
+       udelay(1);
 
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
 
-    if (!(NCR5380_read(STATUS_REG) & SR_BSY)) {
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-       if (hostdata->targets_present & (1 << cmd->target)) {
-           printk("scsi%d : weirdness\n", instance->host_no);
-           if (hostdata->restart_select)
-               printk("\trestart select\n");
+       if (!(NCR5380_read(STATUS_REG) & SR_BSY)) {
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+               if (hostdata->targets_present & (1 << cmd->target)) {
+                       printk("scsi%d : weirdness\n", instance->host_no);
+                       if (hostdata->restart_select)
+                               printk("\trestart select\n");
 #ifdef NDEBUG
-           NCR5380_print (instance);
+                       NCR5380_print(instance);
 #endif
-           NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-           return -1;
-       }
-       cmd->result = DID_BAD_TARGET << 16;
+                       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                       return -1;
+               }
+               cmd->result = DID_BAD_TARGET << 16;
 #ifdef NCR5380_STATS
-       collect_stats(hostdata, cmd);
+               collect_stats(hostdata, cmd);
 #endif
-       cmd->scsi_done(cmd);
-       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+               cmd->scsi_done(cmd);
+               NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 #if (NDEBUG & NDEBUG_SELECTION)
-       printk("scsi%d : target did not respond within 250ms\n", 
-           instance->host_no);
+               printk("scsi%d : target did not respond within 250ms\n",
+                      instance->host_no);
 #endif
-       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-       return 0;
-    } 
-
-    hostdata->targets_present |= (1 << cmd->target);
-
-    /*
-     * Since we followed the SCSI spec, and raised ATN while SEL 
-     * was true but before BSY was false during selection, the information
-     * transfer phase should be a MESSAGE OUT phase so that we can send the
-     * IDENTIFY message.
-     * 
-     * If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG
-     * message (2 bytes) with a tag ID that we increment with every command
-     * until it wraps back to 0.
-     *
-     * XXX - it turns out that there are some broken SCSI-II devices,
-     *      which claim to support tagged queuing but fail when more than
-     *      some number of commands are issued at once.
-     */
-
-    /* Wait for start of REQ/ACK handshake */
+               NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+               return 0;
+       }
+       hostdata->targets_present |= (1 << cmd->target);
+
+       /*
+        * Since we followed the SCSI spec, and raised ATN while SEL 
+        * was true but before BSY was false during selection, the information
+        * transfer phase should be a MESSAGE OUT phase so that we can send the
+        * IDENTIFY message.
+        * 
+        * If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG
+        * message (2 bytes) with a tag ID that we increment with every command
+        * until it wraps back to 0.
+        *
+        * XXX - it turns out that there are some broken SCSI-II devices,
+        *       which claim to support tagged queuing but fail when more than
+        *       some number of commands are issued at once.
+        */
+
+       /* Wait for start of REQ/ACK handshake */
 #ifdef NCR_TIMEOUT
-    {
-      unsigned long timeout = jiffies + NCR_TIMEOUT;
-      while (!(NCR5380_read(STATUS_REG) & SR_REQ) && jiffies < timeout);
-
-      if (jiffies >= timeout) {
-        printk("scsi%d: timeout at NCR5380.c:%d\n", __LINE__);
-        NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-        return -1;
-      }
-    }
-#else /* NCR_TIMEOUT */
-    while (!(NCR5380_read(STATUS_REG) & SR_REQ));
-#endif /* def NCR_TIMEOUT */
+       {
+               unsigned long timeout = jiffies + NCR_TIMEOUT;
+
+               while (!(NCR5380_read(STATUS_REG) & SR_REQ) && jiffies < timeout);
+
+               if (jiffies >= timeout) {
+                       printk("scsi%d: timeout at NCR5380.c:%d\n", __LINE__);
+                       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                       return -1;
+               }
+       }
+#else                          /* NCR_TIMEOUT */
+       while (!(NCR5380_read(STATUS_REG) & SR_REQ));
+#endif                         /* def NCR_TIMEOUT */
 
 #if (NDEBUG & NDEBUG_SELECTION)
-    printk("scsi%d : target %d selected, going into MESSAGE OUT phase.\n",
-       instance->host_no, cmd->target);
+       printk("scsi%d : target %d selected, going into MESSAGE OUT phase.\n",
+              instance->host_no, cmd->target);
 #endif
-    tmp[0] = IDENTIFY(((instance->irq == IRQ_NONE) ? 0 : 1), cmd->lun);
+       tmp[0] = IDENTIFY(((instance->irq == IRQ_NONE) ? 0 : 1), cmd->lun);
 #ifdef SCSI2
-    if (cmd->device->tagged_queue && (tag != TAG_NONE)) {
-       tmp[1] = SIMPLE_QUEUE_TAG;
-       if (tag == TAG_NEXT) {
-           /* 0 is TAG_NONE, used to imply no tag for this command */
-           if (cmd->device->current_tag == 0)
-               cmd->device->current_tag = 1;
-
-           cmd->tag = cmd->device->current_tag;
-           cmd->device->current_tag++;
-       } else  
-           cmd->tag = (unsigned char) tag;
-
-       tmp[2] = cmd->tag;
-       hostdata->last_message = SIMPLE_QUEUE_TAG;
-       len = 3;
-    } else 
-#endif /* def SCSI2 */
-    {
-       len = 1;
-       cmd->tag=0;
-    }
+       if (cmd->device->tagged_queue && (tag != TAG_NONE)) {
+               tmp[1] = SIMPLE_QUEUE_TAG;
+               if (tag == TAG_NEXT) {
+                       /* 0 is TAG_NONE, used to imply no tag for this command */
+                       if (cmd->device->current_tag == 0)
+                               cmd->device->current_tag = 1;
+
+                       cmd->tag = cmd->device->current_tag;
+                       cmd->device->current_tag++;
+               } else
+                       cmd->tag = (unsigned char) tag;
+
+               tmp[2] = cmd->tag;
+               hostdata->last_message = SIMPLE_QUEUE_TAG;
+               len = 3;
+       } else
+#endif                         /* def SCSI2 */
+       {
+               len = 1;
+               cmd->tag = 0;
+       }
 
-    /* Send message(s) */
-    data = tmp;
-    phase = PHASE_MSGOUT;
-    NCR5380_transfer_pio(instance, &phase, &len, &data);
+       /* Send message(s) */
+       data = tmp;
+       phase = PHASE_MSGOUT;
+       NCR5380_transfer_pio(instance, &phase, &len, &data);
 #if (NDEBUG & NDEBUG_SELECTION)
-    printk("scsi%d : nexus established.\n", instance->host_no);
+       printk("scsi%d : nexus established.\n", instance->host_no);
 #endif
-    /* XXX need to handle errors here */
-    hostdata->connected = cmd;
+       /* XXX need to handle errors here */
+       hostdata->connected = cmd;
 #ifdef SCSI2
-    if (!cmd->device->tagged_queue)
-#endif    
-       hostdata->busy[cmd->target] |= (1 << cmd->lun);
+       if (!cmd->device->tagged_queue)
+#endif
+               hostdata->busy[cmd->target] |= (1 << cmd->lun);
 
-    initialize_SCp(cmd);
+       initialize_SCp(cmd);
 
 
-    return 0;
+       return 0;
 }
 
 /* 
@@ -1778,14 +1872,14 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
  * Purpose : transfers data in given phase using polled I/O
  *
  * Inputs : instance - instance of driver, *phase - pointer to 
- *     what phase is expected, *count - pointer to number of 
- *     bytes to transfer, **data - pointer to data pointer.
+ *      what phase is expected, *count - pointer to number of 
+ *      bytes to transfer, **data - pointer to data pointer.
  * 
  * Returns : -1 when different phase is entered without transferring
- *     maximum number of bytes, 0 if all bytes or transfered or exit
- *     is in same phase.
+ *      maximum number of bytes, 0 if all bytes or transfered or exit
+ *      is in same phase.
  *
- *     Also, *phase, *count, *data are modified in place.
+ *      Also, *phase, *count, *data are modified in place.
  *
  * XXX Note : handling for bus free may be useful.
  */
@@ -1796,197 +1890,193 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
  * counts, we will always do a pseudo DMA or DMA transfer.
  */
 
-static int NCR5380_transfer_pio (struct Scsi_Host *instance, 
-       unsigned char *phase, int *count, unsigned char **data) {
-    NCR5380_local_declare();
-    register unsigned char p = *phase, tmp;
-    register int c = *count;
-    register unsigned char *d = *data;
-    NCR5380_setup(instance);
+static int NCR5380_transfer_pio(struct Scsi_Host *instance,
+               unsigned char *phase, int *count, unsigned char **data) {
+       NCR5380_local_declare();
+       register unsigned char p = *phase, tmp;
+       register int c = *count;
+       register unsigned char *d = *data;
+        NCR5380_setup(instance);
 
 #if (NDEBUG & NDEBUG_PIO)
-    if (!(p & SR_IO))
-      printk("scsi%d : pio write %d bytes\n", instance->host_no, c);
-    else
-      printk("scsi%d : pio read %d bytes\n", instance->host_no, c);
+       if (!(p & SR_IO))
+                printk("scsi%d : pio write %d bytes\n", instance->host_no, c);
+       else
+                printk("scsi%d : pio read %d bytes\n", instance->host_no, c);
 #endif
 
-    /* 
-     * The NCR5380 chip will only drive the SCSI bus when the 
-     * phase specified in the appropriate bits of the TARGET COMMAND
-     * REGISTER match the STATUS REGISTER
-     */
-
-    NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
-
-    do {
        /* 
-        * Wait for assertion of REQ, after which the phase bits will be 
-        * valid 
+        * The NCR5380 chip will only drive the SCSI bus when the 
+        * phase specified in the appropriate bits of the TARGET COMMAND
+        * REGISTER match the STATUS REGISTER
         */
-       while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ));
+
+        NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
+
+       do {
+               /* 
+                * Wait for assertion of REQ, after which the phase bits will be 
+                * valid 
+                */
+               while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ));
 
 #if (NDEBUG & NDEBUG_HANDSHAKE)
-       printk("scsi%d : REQ detected\n", instance->host_no);
+               printk("scsi%d : REQ detected\n", instance->host_no);
 #endif
 
-       /* Check for phase mismatch */  
-       if ((tmp & PHASE_MASK) != p) {
+               /* Check for phase mismatch */
+               if ((tmp & PHASE_MASK) != p) {
 #if (NDEBUG & NDEBUG_PIO)
-           printk("scsi%d : phase mismatch\n", instance->host_no);
-           NCR5380_print_phase(instance);
+                       printk("scsi%d : phase mismatch\n", instance->host_no);
+                       NCR5380_print_phase(instance);
 #endif
-           break;
-       }
-
-       /* Do actual transfer from SCSI bus to / from memory */
-       if (!(p & SR_IO)) 
-           NCR5380_write(OUTPUT_DATA_REG, *d);
-       else 
-           *d = NCR5380_read(CURRENT_SCSI_DATA_REG);
+                       break;
+               }
+               /* Do actual transfer from SCSI bus to / from memory */ if (!(p & SR_IO))
+                        NCR5380_write(OUTPUT_DATA_REG, *d);
+               else
+                       *d = NCR5380_read(CURRENT_SCSI_DATA_REG);
 
-       ++d;
+               ++d;
 
-       /* 
-        * The SCSI standard suggests that in MSGOUT phase, the initiator
-        * should drop ATN on the last byte of the message phase
-        * after REQ has been asserted for the handshake but before
-        * the initiator raises ACK.
-        */
+               /* 
+                * The SCSI standard suggests that in MSGOUT phase, the initiator
+                * should drop ATN on the last byte of the message phase
+                * after REQ has been asserted for the handshake but before
+                * the initiator raises ACK.
+                */
 
-       if (!(p & SR_IO)) {
-           if (!((p & SR_MSG) && c > 1)) {
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                   ICR_ASSERT_DATA);
+               if (!(p & SR_IO)) {
+                       if (!((p & SR_MSG) && c > 1)) {
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                             ICR_ASSERT_DATA);
 #if (NDEBUG & NDEBUG_PIO)
-       NCR5380_print(instance);
+                               NCR5380_print(instance);
 #endif
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                       ICR_ASSERT_DATA | ICR_ASSERT_ACK);
-           } else {
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
-                   ICR_ASSERT_DATA | ICR_ASSERT_ATN);
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                      ICR_ASSERT_DATA | ICR_ASSERT_ACK);
+                       } else {
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                      ICR_ASSERT_DATA | ICR_ASSERT_ATN);
 #if (NDEBUG & NDEBUG_PIO)
-       NCR5380_print(instance);
+                               NCR5380_print(instance);
 #endif
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                   ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
-           }
-       } else {
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                             ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
+                       }
+               } else {
 #if (NDEBUG & NDEBUG_PIO)
-       NCR5380_print(instance);
+                       NCR5380_print(instance);
 #endif
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
-       }
+                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
+               }
 
-       while (NCR5380_read(STATUS_REG) & SR_REQ);
+               while (NCR5380_read(STATUS_REG) & SR_REQ);
 
 #if (NDEBUG & NDEBUG_HANDSHAKE)
-           printk("scsi%d : req false, handshake complete\n", instance->host_no);
+               printk("scsi%d : req false, handshake complete\n", instance->host_no);
 #endif
 
 /*
  * We have several special cases to consider during REQ/ACK handshaking : 
  * 1.  We were in MSGOUT phase, and we are on the last byte of the 
- *     message.  ATN must be dropped as ACK is dropped.
+ *      message.  ATN must be dropped as ACK is dropped.
  *
  * 2.  We are in a MSGIN phase, and we are on the last byte of the  
- *     message.  We must exit with ACK asserted, so that the calling
- *     code may raise ATN before dropping ACK to reject the message.
+ *      message.  We must exit with ACK asserted, so that the calling
+ *      code may raise ATN before dropping ACK to reject the message.
  *
  * 3.  ACK and ATN are clear and the target may proceed as normal.
  */
-       if (!(p == PHASE_MSGIN && c == 1)) {  
-           if (p == PHASE_MSGOUT && c > 1)
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
-           else
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-       } 
-    } while (--c);
+               if (!(p == PHASE_MSGIN && c == 1)) {
+                       if (p == PHASE_MSGOUT && c > 1)
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
+                       else
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+               }
+       } while (--c);
 
-#if (NDEBUG & NDEBUG_PIO) 
-    printk("scsi%d : residual %d\n", instance->host_no, c);
+#if (NDEBUG & NDEBUG_PIO)
+       printk("scsi%d : residual %d\n", instance->host_no, c);
 #endif
 
-    *count = c;
-    *data = d;
-    tmp = NCR5380_read(STATUS_REG);
-    if (tmp & SR_REQ)
-       *phase = tmp & PHASE_MASK;
-    else 
-       *phase = PHASE_UNKNOWN;
-
-    if (!c || (*phase == p))
-       return 0;
-    else 
-       return -1;
+       *count = c;
+       *data = d;
+       tmp = NCR5380_read(STATUS_REG);
+       if (tmp & SR_REQ)
+               *phase = tmp & PHASE_MASK;
+       else
+               *phase = PHASE_UNKNOWN;
+
+       if (!c || (*phase == p))
+               return 0;
+       else
+               return -1;
 }
 
-static void do_reset (struct Scsi_Host *host) {
-    NCR5380_local_declare();
-    NCR5380_setup(host);
-
-    cli();
-    NCR5380_write(TARGET_COMMAND_REG, 
-       PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK));
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
-    udelay(25);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-    sti();
-}
+static void do_reset(struct Scsi_Host *host) {
+       unsigned long flags;
+        NCR5380_local_declare();
+        NCR5380_setup(host);
+
+        save_flags(flags);
+        cli();
+        NCR5380_write(TARGET_COMMAND_REG,
+                PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK));
+        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
+        udelay(25);
+        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+        restore_flags(flags);
+}                              /*
+
+                                * Function : do_abort (Scsi_Host *host)
+                                * 
+                                * Purpose : abort the currently established nexus.  Should only be 
+                                *      called from a routine which can drop into a 
+                                * 
+                                * Returns : 0 on success, -1 on failure.
+                                */ static int do_abort(struct Scsi_Host *host) {
+       NCR5380_local_declare();
+       unsigned char tmp, *msgptr, phase;
+       int len;
+        NCR5380_setup(host);
+
+
+       /* Request message out phase */
+        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
 
-/*
- * Function : do_abort (Scsi_Host *host)
- * 
- * Purpose : abort the currently established nexus.  Should only be 
- *     called from a routine which can drop into a 
- * 
- * Returns : 0 on success, -1 on failure.
- */
+       /* 
+        * Wait for the target to indicate a valid phase by asserting 
+        * REQ.  Once this happens, we'll have either a MSGOUT phase 
+        * and can immediately send the ABORT message, or we'll have some 
+        * other phase and will have to source/sink data.
+        * 
+        * We really don't care what value was on the bus or what value
+        * the target sees, so we just handshake.
+        */
 
-static int do_abort (struct Scsi_Host *host) {
-    NCR5380_local_declare();
-    unsigned char tmp, *msgptr, phase;
-    int len;
-    NCR5380_setup(host);
-
-
-    /* Request message out phase */
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
-
-    /* 
-     * Wait for the target to indicate a valid phase by asserting 
-     * REQ.  Once this happens, we'll have either a MSGOUT phase 
-     * and can immediately send the ABORT message, or we'll have some 
-     * other phase and will have to source/sink data.
-     * 
-     * We really don't care what value was on the bus or what value
-     * the target sees, so we just handshake.
-     */
-    
-    while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ);
-
-    NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
-
-    if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | 
-           ICR_ASSERT_ACK);
-       while (NCR5380_read(STATUS_REG) & SR_REQ);
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
-    }
-   
-    tmp = ABORT;
-    msgptr = &tmp;
-    len = 1;
-    phase = PHASE_MSGOUT;
-    NCR5380_transfer_pio (host, &phase, &len, &msgptr);
-
-    /*
-     * If we got here, and the command completed successfully,
-     * we're about to go into bus free state.
-     */
-
-    return len ? -1 : 0;
+       while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ);
+
+        NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
+
+       if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
+                             ICR_ASSERT_ACK);
+               while (NCR5380_read(STATUS_REG) & SR_REQ);
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
+       }
+       tmp = ABORT;
+       msgptr = &tmp;
+       len = 1;
+       phase = PHASE_MSGOUT;
+       NCR5380_transfer_pio(host, &phase, &len, &msgptr);
+
+       /*
+        * If we got here, and the command completed successfully,
+        * we're about to go into bus free state.
+        */
+
+       return len ? -1 : 0;
 }
 
 #if defined(REAL_DMA) || defined(PSEUDO_DMA) || defined (REAL_DMA_POLL)
@@ -1995,86 +2085,86 @@ static int do_abort (struct Scsi_Host *host) {
  *      unsigned char *phase, int *count, unsigned char **data)
  *
  * Purpose : transfers data in given phase using either real
- *     or pseudo DMA.
+ *      or pseudo DMA.
  *
  * Inputs : instance - instance of driver, *phase - pointer to 
- *     what phase is expected, *count - pointer to number of 
- *     bytes to transfer, **data - pointer to data pointer.
+ *      what phase is expected, *count - pointer to number of 
+ *      bytes to transfer, **data - pointer to data pointer.
  * 
  * Returns : -1 when different phase is entered without transferring
- *     maximum number of bytes, 0 if all bytes or transfered or exit
- *     is in same phase.
+ *      maximum number of bytes, 0 if all bytes or transfered or exit
+ *      is in same phase.
  *
- *     Also, *phase, *count, *data are modified in place.
+ *      Also, *phase, *count, *data are modified in place.
  *
  */
 
 
-static int NCR5380_transfer_dma (struct Scsi_Host *instance, 
-    unsigned char *phase, int *count, unsigned char **data) {
-    NCR5380_local_declare();
-    register int c = *count;
-    register unsigned char p = *phase;
-    register unsigned char *d = *data;
-    unsigned char tmp;
-    int foo;
+static int NCR5380_transfer_dma(struct Scsi_Host *instance,
+               unsigned char *phase, int *count, unsigned char **data) {
+       NCR5380_local_declare();
+       register int c = *count;
+       register unsigned char p = *phase;
+       register unsigned char *d = *data;
+       unsigned char tmp;
+       int foo;
+       unsigned long flags;
 #if defined(REAL_DMA_POLL)
-    int cnt, toPIO;
-    unsigned char saved_data = 0, overrun = 0, residue;
+       int cnt, toPIO;
+       unsigned char saved_data = 0, overrun = 0, residue;
 #endif
 
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) 
-       instance->hostdata;
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+        instance->hostdata;
 
-    NCR5380_setup(instance);
+        NCR5380_setup(instance);
 
-    if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
-       *phase = tmp;
-       return -1;
-    }
-#if defined(REAL_DMA) || defined(REAL_DMA_POLL) 
-#ifdef READ_OVERRUNS
-     if (p & SR_IO) {
-       c -= 2;
-     }
+       if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
+               *phase = tmp;
+               return -1;
+       }
+#if defined(REAL_DMA) || defined(REAL_DMA_POLL)
+#ifdef READ_OVERRUNS if (p & SR_IO) { c -= 2;
+}
 #endif
 #if (NDEBUG & NDEBUG_DMA)
-    printk("scsi%d : initializing DMA channel %d for %s, %d bytes %s %0x\n",
-       instance->host_no, instance->dma_channel, (p & SR_IO) ? "reading" :
-       "writing", c, (p & SR_IO) ? "to" : "from", (unsigned) d);
+printk("scsi%d : initializing DMA channel %d for %s, %d bytes %s %0x\n",
+       instance->host_no, instance->dma_channel, (p & SR_IO) ? "reading" :
+       "writing", c, (p & SR_IO) ? "to" : "from", (unsigned) d);
 #endif
-    hostdata->dma_len = (p & SR_IO) ?
-       NCR5380_dma_read_setup(instance, d, c) : 
-       NCR5380_dma_write_setup(instance, d, c);
+hostdata->dma_len = (p & SR_IO) ?
+NCR5380_dma_read_setup(instance, d, c) :
+NCR5380_dma_write_setup(instance, d, c);
 #endif
 
-    NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
+NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
 
 #ifdef REAL_DMA
-    NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
+NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
 #elif defined(REAL_DMA_POLL)
-    NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE);
+NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE);
 #else
-    /*
-     * Note : on my sample board, watch-dog timeouts occurred when interrupts
-     * were not disabled for the duration of a single DMA transfer, from 
-     * before the setting of DMA mode to after transfer of the last byte.
-     */
+       /*
+        * Note : on my sample board, watch-dog timeouts occurred when interrupts
+        * were not disabled for the duration of a single DMA transfer, from 
+        * before the setting of DMA mode to after transfer of the last byte.
+        */
 
 #if defined(PSEUDO_DMA) && !defined(UNSAFE)
-    cli();
+save_flags(flags);
+cli();
 #endif
-    /* KLL May need eop and parity in 53c400 */
-    if (hostdata->flags & FLAG_NCR53C400)
+       /* KLL May need eop and parity in 53c400 */
+if (hostdata->flags & FLAG_NCR53C400)
        NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_PAR_CHECK
-       | MR_ENABLE_PAR_INTR | MR_ENABLE_EOP_INTR | MR_DMA_MODE
-       | MR_MONITOR_BSY);
-    else
+                 | MR_ENABLE_PAR_INTR | MR_ENABLE_EOP_INTR | MR_DMA_MODE
+                     | MR_MONITOR_BSY);
+else
        NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE);
-#endif /* def REAL_DMA */
+#endif                         /* def REAL_DMA */
 
 #if (NDEBUG & NDEBUG_DMA) & 0
-    printk("scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG));
+printk("scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG));
 #endif
 
 /* 
@@ -2086,12 +2176,13 @@ static int NCR5380_transfer_dma (struct Scsi_Host *instance,
  * is the problem?
  */
 
-    if (p & SR_IO) {
+if (p & SR_IO)
+{
 #ifndef FOO
-       udelay(1);
+udelay(1);
 #endif
-       NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0);
-    } else {
+NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0);
+} else {
 #ifndef FOO
        udelay(1);
 #endif
@@ -2103,86 +2194,90 @@ static int NCR5380_transfer_dma (struct Scsi_Host *instance,
 #ifndef FOO
        udelay(1);
 #endif
-    }
+}
 
 #if defined(REAL_DMA_POLL)
-    do {
+do {
        tmp = NCR5380_read(BUS_AND_STATUS_REG);
-    } while ((tmp & BASR_PHASE_MATCH) && !(tmp & (BASR_BUSY_ERROR | 
-       BASR_END_DMA_TRANSFER)));
+} while ((tmp & BASR_PHASE_MATCH) && !(tmp & (BASR_BUSY_ERROR |
+
+                                             BASR_END_DMA_TRANSFER)));
 
 /*
-  At this point, either we've completed DMA, or we have a phase mismatch,
-  or we've unexpectedly lost BUSY (which is a real error).
-
-  For write DMAs, we want to wait until the last byte has been
-  transferred out over the bus before we turn off DMA mode.  Alas, there
-  seems to be no terribly good way of doing this on a 5380 under all
-  conditions.  For non-scatter-gather operations, we can wait until REQ
-  and ACK both go false, or until a phase mismatch occurs.  Gather-writes
-  are nastier, since the device will be expecting more data than we
-  are prepared to send it, and REQ will remain asserted.  On a 53C8[01] we
-  could test LAST BIT SENT to assure transfer (I imagine this is precisely
-  why this signal was added to the newer chips) but on the older 538[01]
-  this signal does not exist.  The workaround for this lack is a watchdog;
-  we bail out of the wait-loop after a modest amount of wait-time if
-  the usual exit conditions are not met.  Not a terribly clean or
-  correct solution :-%
-
-  Reads are equally tricky due to a nasty characteristic of the NCR5380.
-  If the chip is in DMA mode for an READ, it will respond to a target's
-  REQ by latching the SCSI data into the INPUT DATA register and asserting
-  ACK, even if it has _already_ been notified by the DMA controller that
-  the current DMA transfer has completed!  If the NCR5380 is then taken
-  out of DMA mode, this already-acknowledged byte is lost.
-
-  This is not a problem for "one DMA transfer per command" reads, because
-  the situation will never arise... either all of the data is DMA'ed
-  properly, or the target switches to MESSAGE IN phase to signal a
-  disconnection (either operation bringing the DMA to a clean halt).
-  However, in order to handle scatter-reads, we must work around the
-  problem.  The chosen fix is to DMA N-2 bytes, then check for the
-  condition before taking the NCR5380 out of DMA mode.  One or two extra
-  bytes are transferred via PIO as necessary to fill out the original
-  request.
-*/
-
-    if (p & SR_IO) {
+   At this point, either we've completed DMA, or we have a phase mismatch,
+   or we've unexpectedly lost BUSY (which is a real error).
+
+   For write DMAs, we want to wait until the last byte has been
+   transferred out over the bus before we turn off DMA mode.  Alas, there
+   seems to be no terribly good way of doing this on a 5380 under all
+   conditions.  For non-scatter-gather operations, we can wait until REQ
+   and ACK both go false, or until a phase mismatch occurs.  Gather-writes
+   are nastier, since the device will be expecting more data than we
+   are prepared to send it, and REQ will remain asserted.  On a 53C8[01] we
+   could test LAST BIT SENT to assure transfer (I imagine this is precisely
+   why this signal was added to the newer chips) but on the older 538[01]
+   this signal does not exist.  The workaround for this lack is a watchdog;
+   we bail out of the wait-loop after a modest amount of wait-time if
+   the usual exit conditions are not met.  Not a terribly clean or
+   correct solution :-%
+
+   Reads are equally tricky due to a nasty characteristic of the NCR5380.
+   If the chip is in DMA mode for an READ, it will respond to a target's
+   REQ by latching the SCSI data into the INPUT DATA register and asserting
+   ACK, even if it has _already_ been notified by the DMA controller that
+   the current DMA transfer has completed!  If the NCR5380 is then taken
+   out of DMA mode, this already-acknowledged byte is lost.
+
+   This is not a problem for "one DMA transfer per command" reads, because
+   the situation will never arise... either all of the data is DMA'ed
+   properly, or the target switches to MESSAGE IN phase to signal a
+   disconnection (either operation bringing the DMA to a clean halt).
+   However, in order to handle scatter-reads, we must work around the
+   problem.  The chosen fix is to DMA N-2 bytes, then check for the
+   condition before taking the NCR5380 out of DMA mode.  One or two extra
+   bytes are transferred via PIO as necessary to fill out the original
+   request.
+ */
+
+if (p & SR_IO) {
 #ifdef READ_OVERRUNS
-      udelay(10);
-      if (((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH|BASR_ACK)) ==
-          (BASR_PHASE_MATCH | BASR_ACK))) {
-       saved_data = NCR5380_read(INPUT_DATA_REGISTER);
-       overrun = 1;
-      }
-#endif
-    } else {
-      int limit = 100;
-      while (((tmp = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_ACK) ||
-           (NCR5380_read(STATUS_REG) & SR_REQ)) {
-       if (!(tmp & BASR_PHASE_MATCH)) break;
-       if (--limit < 0) break;
-      }
-    }
+       udelay(10);
+       if (((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) ==
+            (BASR_PHASE_MATCH | BASR_ACK))) {
+               saved_data = NCR5380_read(INPUT_DATA_REGISTER);
+               overrun = 1;
+       }
+#endif
+} else {
+       int limit = 100;
+       while (((tmp = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_ACK) ||
+              (NCR5380_read(STATUS_REG) & SR_REQ)) {
+               if (!(tmp & BASR_PHASE_MATCH))
+                       break;
+               if (--limit < 0)
+                       break;
+       }
+}
 
 
 #if (NDEBUG & NDEBUG_DMA)
-    printk("scsi%d : polled DMA transfer complete, basr 0x%X, sr 0x%X\n",
-          instance->host_no, tmp, NCR5380_read(STATUS_REG));
+printk("scsi%d : polled DMA transfer complete, basr 0x%X, sr 0x%X\n",
+       instance->host_no, tmp, NCR5380_read(STATUS_REG));
 #endif
 
-    NCR5380_write(MODE_REG, MR_BASE);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+NCR5380_write(MODE_REG, MR_BASE);
+NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
-    residue = NCR5380_dma_residual(instance);
-    c -= residue;
-    *count -= c;
-    *data += c;
-    *phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
+residue = NCR5380_dma_residual(instance);
+c -= residue;
+*count -= c;
+*data += c;
+*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
 
 #ifdef READ_OVERRUNS
-    if (*phase == p && (p & SR_IO) && residue == 0) {
-      if (overrun) {
+if (*phase == p && (p & SR_IO) && residue == 0)
+{
+if (overrun) {
 #if (NDEBUG & NDEBUG_DMA)
        printk("Got an input overrun, using saved byte\n");
 #endif
@@ -2190,849 +2285,846 @@ static int NCR5380_transfer_dma (struct Scsi_Host *instance,
        *data += 1;
        *count -= 1;
        cnt = toPIO = 1;
-      } else {
+} else {
        printk("No overrun??\n");
        cnt = toPIO = 2;
-      }
+}
 #if (NDEBUG & NDEBUG_DMA)
-      printk("Doing %d-byte PIO to 0x%X\n", cnt, *data);
+printk("Doing %d-byte PIO to 0x%X\n", cnt, *data);
+#endif
+NCR5380_transfer_pio(instance, phase, &cnt, data);
+*count -= toPIO - cnt;
+}
 #endif
-      NCR5380_transfer_pio(instance, phase, &cnt, data);
-      *count -= toPIO - cnt;
-    }
-#endif        
 
 #if (NDEBUG & NDEBUG_DMA)
-     printk("Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n",
-           *data, *count, *(*data+*count-1), *(*data+*count));
+printk("Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n",
+       *data, *count, *(*data + *count - 1), *(*data + *count));
 #endif
-     return 0;
-     
+return 0;
+
 #elif defined(REAL_DMA)
-    return 0;
-#else /* defined(REAL_DMA_POLL) */
-    if (p & SR_IO) {
+return 0;
+#else                          /* defined(REAL_DMA_POLL) */
+if (p & SR_IO) {
 #ifdef DMA_WORKS_RIGHT
-        foo = NCR5380_pread(instance, d, c);
+       foo = NCR5380_pread(instance, d, c);
 #else
        int diff = 1;
        if (hostdata->flags & FLAG_NCR53C400) {
-           diff=0;
+               diff = 0;
        }
-
        if (!(foo = NCR5380_pread(instance, d, c - diff))) {
-           /*
-            * We can't disable DMA mode after successfully transferring 
-            * what we plan to be the last byte, since that would open up
-            * a race condition where if the target asserted REQ before 
-            * we got the DMA mode reset, the NCR5380 would have latched
-            * an additional byte into the INPUT DATA register and we'd
-            * have dropped it.
-            * 
-            * The workaround was to transfer one fewer bytes than we 
-            * intended to with the pseudo-DMA read function, wait for 
-            * the chip to latch the last byte, read it, and then disable
-            * pseudo-DMA mode.
-            * 
-            * After REQ is asserted, the NCR5380 asserts DRQ and ACK.
-            * REQ is deasserted when ACK is asserted, and not reasserted
-            * until ACK goes false.  Since the NCR5380 won't lower ACK
-            * until DACK is asserted, which won't happen unless we twiddle
-            * the DMA port or we take the NCR5380 out of DMA mode, we 
-            * can guarantee that we won't handshake another extra 
-            * byte.
-            */
-
-           if (!(hostdata->flags & FLAG_NCR53C400)) {
-               while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ));
-               /* Wait for clean handshake */
-               while (NCR5380_read(STATUS_REG) & SR_REQ);
-               d[c - 1] = NCR5380_read(INPUT_DATA_REG);
-           }
+               /*
+                * We can't disable DMA mode after successfully transferring 
+                * what we plan to be the last byte, since that would open up
+                * a race condition where if the target asserted REQ before 
+                * we got the DMA mode reset, the NCR5380 would have latched
+                * an additional byte into the INPUT DATA register and we'd
+                * have dropped it.
+                
+                * The workaround was to transfer one fewer bytes than we 
+                * intended to with the pseudo-DMA read function, wait for 
+                * the chip to latch the last byte, read it, and then disable
+                * pseudo-DMA mode.
+                
+                * After REQ is asserted, the NCR5380 asserts DRQ and ACK.
+                * REQ is deasserted when ACK is asserted, and not reasserted
+                * until ACK goes false.  Since the NCR5380 won't lower ACK
+                * until DACK is asserted, which won't happen unless we twiddle
+                * the DMA port or we take the NCR5380 out of DMA mode, we 
+                * can guarantee that we won't handshake another extra 
+                * byte.
+                */
+
+               if (!(hostdata->flags & FLAG_NCR53C400)) {
+                       while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ));
+                       /* Wait for clean handshake */
+                       while (NCR5380_read(STATUS_REG) & SR_REQ);
+                       d[c - 1] = NCR5380_read(INPUT_DATA_REG);
+               }
        }
 #endif
-    } else {
+} else {
 #ifdef DMA_WORKS_RIGHT
-        foo = NCR5380_pwrite(instance, d, c);
+       foo = NCR5380_pwrite(instance, d, c);
 #else
-        int timeout;
+       int timeout;
 #if (NDEBUG & NDEBUG_C400_PWRITE)
        printk("About to pwrite %d bytes\n", c);
 #endif
        if (!(foo = NCR5380_pwrite(instance, d, c))) {
-           /*
-            * Wait for the last byte to be sent.  If REQ is being asserted for 
-            * the byte we're interested, we'll ACK it and it will go false.  
-            */
-           if (!(hostdata->flags & FLAG_HAS_LAST_BYTE_SENT)) {
-               timeout = 20000;
+               /*
+                * Wait for the last byte to be sent.  If REQ is being asserted for 
+                * the byte we're interested, we'll ACK it and it will go false.  
+                */
+               if (!(hostdata->flags & FLAG_HAS_LAST_BYTE_SENT)) {
+                       timeout = 20000;
 #if 1
 #if 1
-               while (!(NCR5380_read(BUS_AND_STATUS_REG) & 
-                       BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) &
-                       BASR_PHASE_MATCH));
+                       while (!(NCR5380_read(BUS_AND_STATUS_REG) &
+                        BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) &
+                                      BASR_PHASE_MATCH));
 #else
-               if (NCR5380_read(STATUS_REG) & SR_REQ) {
-                   for (; timeout && 
-                       !(NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK); 
-                       --timeout);
-                   for (; timeout && (NCR5380_read(STATUS_REG) & SR_REQ);
-                       --timeout);
-               } 
+                       if (NCR5380_read(STATUS_REG) & SR_REQ) {
+                               for (; timeout &&
+                                    !(NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK);
+                                    --timeout);
+                               for (; timeout && (NCR5380_read(STATUS_REG) & SR_REQ);
+                                    --timeout);
+                       }
 #endif
-       
+
 
 #if (NDEBUG & NDEBUG_LAST_BYTE_SENT)
-               if (!timeout) 
-                   printk("scsi%d : timed out on last byte\n",
-                           instance->host_no);
+                       if (!timeout)
+                               printk("scsi%d : timed out on last byte\n",
+                                      instance->host_no);
 #endif
 
 
-               if (hostdata->flags & FLAG_CHECK_LAST_BYTE_SENT) {
-                   hostdata->flags &= ~FLAG_CHECK_LAST_BYTE_SENT;
-                   if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) {
-                       hostdata->flags |= FLAG_HAS_LAST_BYTE_SENT;
+                       if (hostdata->flags & FLAG_CHECK_LAST_BYTE_SENT) {
+                               hostdata->flags &= ~FLAG_CHECK_LAST_BYTE_SENT;
+                               if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) {
+                                       hostdata->flags |= FLAG_HAS_LAST_BYTE_SENT;
 #if (NDEBUG & NDEBUG_LAST_BYTE_SENT)
-                       printk("scsi%d : last bit sent works\n", 
-                           instance->host_no);
+                                       printk("scsi%d : last bit sent works\n",
+                                              instance->host_no);
 #endif
-                   }
-               }
-           } else  {
+                               }
+                       }
+               } else {
 #if (NDEBUG & NDEBUG_C400_PWRITE)
-               printk("Waiting for LASTBYTE\n");
+                       printk("Waiting for LASTBYTE\n");
 #endif
-               while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT));
+                       while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT));
 #if (NDEBUG & NDEBUG_C400_PWRITE)
-               printk("Got LASTBYTE\n");
+                       printk("Got LASTBYTE\n");
 #endif
-           }
+               }
 #else
-           udelay (5);
+                       udelay(5);
 #endif
-       }
+               }
 #endif
-    }
-
-    NCR5380_write(MODE_REG, MR_BASE);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+       }
+       NCR5380_write(MODE_REG, MR_BASE);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
-    if ((!(p & SR_IO)) && (hostdata->flags & FLAG_NCR53C400)) {
+       if ((!(p & SR_IO)) && (hostdata->flags & FLAG_NCR53C400)) {
 #if (NDEBUG & NDEBUG_C400_PWRITE)
-       printk("53C400w: Checking for IRQ\n");
+               printk("53C400w: Checking for IRQ\n");
 #endif
-       if (NCR5380_read(BUS_AND_STATUS_REG) & BASR_IRQ) {
+               if (NCR5380_read(BUS_AND_STATUS_REG) & BASR_IRQ) {
 #if (NDEBUG & NDEBUG_C400_PWRITE)
-           printk("53C400w:    got it, reading reset interrupt reg\n");
+                       printk("53C400w:    got it, reading reset interrupt reg\n");
 #endif
-           NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-       } else {
-           printk("53C400w:    IRQ NOT THERE!\n");
+                       NCR5380_read(RESET_PARITY_INTERRUPT_REG);
+               } else {
+                       printk("53C400w:    IRQ NOT THERE!\n");
+               }
        }
-    }
-
-    *data = d + c;
-    *count = 0;
-    *phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
+       *data = d + c;
+       *count = 0;
+       *phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
 #if 0
-    NCR5380_print_phase(instance);
+       NCR5380_print_phase(instance);
 #endif
 #if defined(PSEUDO_DMA) && !defined(UNSAFE)
-    sti();
-#endif /* defined(REAL_DMA_POLL) */
-    return foo;
-#endif /* def REAL_DMA */
+       restore_flags(flags);
+#endif                         /* defined(REAL_DMA_POLL) */
+       return foo;
+#endif                         /* def REAL_DMA */
 }
-#endif /* defined(REAL_DMA) | defined(PSEUDO_DMA) */
+#endif                         /* defined(REAL_DMA) | defined(PSEUDO_DMA) */
 
 /*
  * Function : NCR5380_information_transfer (struct Scsi_Host *instance)
  *
  * Purpose : run through the various SCSI phases and do as the target 
- *     directs us to.  Operates on the currently connected command, 
- *     instance->connected.
+ *      directs us to.  Operates on the currently connected command, 
+ *      instance->connected.
  *
  * Inputs : instance, instance for which we are doing commands
  *
  * Side effects : SCSI things happen, the disconnected queue will be 
- *     modified if a command disconnects, *instance->connected will
- *     change.
+ *      modified if a command disconnects, *instance->connected will
+ *      change.
  *
  * XXX Note : we need to watch for bus free or a reset condition here 
- *     to recover from an unexpected bus free condition.
+ *      to recover from an unexpected bus free condition.
  */
-static void NCR5380_information_transfer (struct Scsi_Host *instance) {
-    NCR5380_local_declare();
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) 
-       instance->hostdata;
-    unsigned char msgout = NOP;
-    int sink = 0;
-    int len;
-#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
-    int transfersize;
-#endif
-    unsigned char *data;
-    unsigned char phase, tmp, extended_msg[10], old_phase=0xff;
-    Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
-    NCR5380_setup(instance);
 
-    while (1) {
-       tmp = NCR5380_read(STATUS_REG);
-       /* We only have a valid SCSI phase when REQ is asserted */
-       if (tmp & SR_REQ) {
-           phase = (tmp & PHASE_MASK); 
-           if (phase != old_phase) {
-               old_phase = phase;
+static void NCR5380_information_transfer(struct Scsi_Host *instance) {
+       NCR5380_local_declare();
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+        instance->hostdata;
+       unsigned char msgout = NOP;
+       int sink = 0;
+       int len;
+#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
+       int transfersize;
+#endif
+       unsigned char *data;
+       unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
+       Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
+        NCR5380_setup(instance);
+
+       while (1) {
+               tmp = NCR5380_read(STATUS_REG);
+               /* We only have a valid SCSI phase when REQ is asserted */
+               if (tmp & SR_REQ) {
+                       phase = (tmp & PHASE_MASK);
+                       if (phase != old_phase) {
+                               old_phase = phase;
 #if (NDEBUG & NDEBUG_INFORMATION)
-               NCR5380_print_phase(instance);
+                               NCR5380_print_phase(instance);
 #endif
-           }
-           
-           if (sink && (phase != PHASE_MSGOUT)) {
-               NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
-
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | 
-                   ICR_ASSERT_ACK);
-               while (NCR5380_read(STATUS_REG) & SR_REQ);
-               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                   ICR_ASSERT_ATN);
-               sink = 0;
-               continue;
-           }
-
-           switch (phase) {
-           case PHASE_DATAIN:
-           case PHASE_DATAOUT:
+                       }
+                       if (sink && (phase != PHASE_MSGOUT)) {
+                               NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
+
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
+                                             ICR_ASSERT_ACK);
+                               while (NCR5380_read(STATUS_REG) & SR_REQ);
+                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                             ICR_ASSERT_ATN);
+                               sink = 0;
+                               continue;
+                       }
+                       switch (phase) {
+                               case PHASE_DATAIN:
+                                   case PHASE_DATAOUT:
 #if (NDEBUG & NDEBUG_NO_DATAOUT)
-               printk("scsi%d : NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n",
-                   instance->host_no);
-               sink = 1;
-               do_abort(instance);
-               cmd->result = DID_ERROR  << 16;
-               cmd->done(cmd);
-               return;
-#endif
-               /* 
-                * If there is no room left in the current buffer in the
-                * scatter-gather list, move onto the next one.
-                */
-
-               if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
-                   ++cmd->SCp.buffer;
-                   --cmd->SCp.buffers_residual;
-                   cmd->SCp.this_residual = cmd->SCp.buffer->length;
-                   cmd->SCp.ptr = cmd->SCp.buffer->address;
+                                   printk("scsi%d : NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n",
+                                          instance->host_no);
+                               sink = 1;
+                               do_abort(instance);
+                               cmd->result = DID_ERROR << 16;
+                               cmd->done(cmd);
+                               return;
+#endif
+                               /* 
+                                * If there is no room left in the current buffer in the
+                                * scatter-gather list, move onto the next one.
+                                */
+
+                               if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
+                                       ++cmd->SCp.buffer;
+                                       --cmd->SCp.buffers_residual;
+                                       cmd->SCp.this_residual = cmd->SCp.buffer->length;
+                                       cmd->SCp.ptr = cmd->SCp.buffer->address;
 #if (NDEBUG & NDEBUG_INFORMATION)
-                   printk("scsi%d : %d bytes and %d buffers left\n",
-                       instance->host_no, cmd->SCp.this_residual,
-                       cmd->SCp.buffers_residual);
-#endif
-               }
-
-               /*
-                * The preferred transfer method is going to be 
-                * PSEUDO-DMA for systems that are strictly PIO,
-                * since we can let the hardware do the handshaking.
-                *
-                * For this to work, we need to know the transfersize
-                * ahead of time, since the pseudo-DMA code will sit
-                * in an unconditional loop.
-                */
+                                       printk("scsi%d : %d bytes and %d buffers left\n",
+                                              instance->host_no, cmd->SCp.this_residual,
+                                              cmd->SCp.buffers_residual);
+#endif
+                               }
+                               /*
+                                * The preferred transfer method is going to be 
+                                * PSEUDO-DMA for systems that are strictly PIO,
+                                * since we can let the hardware do the handshaking.
+                                *
+                                * For this to work, we need to know the transfersize
+                                * ahead of time, since the pseudo-DMA code will sit
+                                * in an unconditional loop.
+                                */
 
 #if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
-               /* KLL
-                * PSEUDO_DMA is defined here. If this is the g_NCR5380
-                * driver then it will always be defined, so the
-                * FLAG_NO_PSEUDO_DMA is used to inhibit PDMA in the base
-                * NCR5380 case.  I think this is a fairly clean solution.
-                * We supplement these 2 if's with the flag.
-                */
+                               /* KLL
+                                * PSEUDO_DMA is defined here. If this is the g_NCR5380
+                                * driver then it will always be defined, so the
+                                * FLAG_NO_PSEUDO_DMA is used to inhibit PDMA in the base
+                                * NCR5380 case.  I think this is a fairly clean solution.
+                                * We supplement these 2 if's with the flag.
+                                */
 #ifdef NCR5380_dma_xfer_len
-               if (!cmd->device->borken &&
-                   !(hostdata->flags & FLAG_NO_PSEUDO_DMA) &&
-                   (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 0) {
+                               if (!cmd->device->borken &&
+                               !(hostdata->flags & FLAG_NO_PSEUDO_DMA) &&
+                                   (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 0) {
 #else
-               transfersize = cmd->transfersize;
-
-#ifdef LIMIT_TRANSFERSIZE  /* If we have problems with interrupt service */
-               if( transfersize > 512 )
-                   transfersize = 512;
-#endif  /* LIMIT_TRANSFERSIZE */
-
-               if (!cmd->device->borken && transfersize && 
-                   !(hostdata->flags & FLAG_NO_PSEUDO_DMA) &&
-                   cmd->SCp.this_residual && !(cmd->SCp.this_residual % 
-                   transfersize)) {
-                    /* Limit transfers to 32K, for xx400 & xx406
-                     * pseudoDMA that transfers in 128 bytes blocks. */
-                    if (transfersize > 32*1024)
-                         transfersize = 32*1024;
-#endif
-                   len = transfersize;
-                   if (NCR5380_transfer_dma(instance, &phase,
-                       &len, (unsigned char **) &cmd->SCp.ptr)) {
-                       /*
-                        * If the watchdog timer fires, all future accesses to this
-                        * device will use the polled-IO.
-                        */ 
-                       printk("scsi%d : switching target %d lun %d to slow handshake\n",
-                           instance->host_no, cmd->target, cmd->lun);
-                       cmd->device->borken = 1;
-                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                           ICR_ASSERT_ATN);
-                       sink = 1;
-                       do_abort(instance);
-                       cmd->result = DID_ERROR  << 16;
-                       cmd->done(cmd);
-                       /* XXX - need to source or sink data here, as appropriate */
-                   } else
-                       cmd->SCp.this_residual -= transfersize - len;
-               } else
-#endif /* defined(PSEUDO_DMA) || defined(REAL_DMA_POLL) */
-                 NCR5380_transfer_pio(instance, &phase, 
-                   (int *) &cmd->SCp.this_residual, (unsigned char **)
-                   &cmd->SCp.ptr);
-               break;
-           case PHASE_MSGIN:
-               len = 1;
-               data = &tmp;
-               NCR5380_transfer_pio(instance, &phase, &len, &data);
-               cmd->SCp.Message = tmp;
-
-               switch (tmp) {
-               /*
-                * Linking lets us reduce the time required to get the 
-                * next command out to the device, hopefully this will
-                * mean we don't waste another revolution due to the delays
-                * required by ARBITRATION and another SELECTION.
-                *
-                * In the current implementation proposal, low level drivers
-                * merely have to start the next command, pointed to by 
-                * next_link, done() is called as with unlinked commands.
-                */
+                               transfersize = cmd->transfersize;
+
+#ifdef LIMIT_TRANSFERSIZE      /* If we have problems with interrupt service */
+                               if (transfersize > 512)
+                                       transfersize = 512;
+#endif                         /* LIMIT_TRANSFERSIZE */
+
+                               if (!cmd->device->borken && transfersize &&
+                               !(hostdata->flags & FLAG_NO_PSEUDO_DMA) &&
+                                   cmd->SCp.this_residual && !(cmd->SCp.this_residual %
+                                                        transfersize)) {
+                                       /* Limit transfers to 32K, for xx400 & xx406
+                                        * pseudoDMA that transfers in 128 bytes blocks. */
+                                       if (transfersize > 32 * 1024)
+                                               transfersize = 32 * 1024;
+#endif
+                                       len = transfersize;
+                                       if (NCR5380_transfer_dma(instance, &phase,
+                                                                &len, (unsigned char **) &cmd->SCp.ptr)) {
+                                               /*
+                                                * If the watchdog timer fires, all future accesses to this
+                                                * device will use the polled-IO.
+                                                */
+                                               printk("scsi%d : switching target %d lun %d to slow handshake\n",
+                                                      instance->host_no, cmd->target, cmd->lun);
+                                               cmd->device->borken = 1;
+                                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                                        ICR_ASSERT_ATN);
+                                               sink = 1;
+                                               do_abort(instance);
+                                               cmd->result = DID_ERROR << 16;
+                                               cmd->done(cmd);
+                                               /* XXX - need to source or sink data here, as appropriate */
+                                       } else
+                                               cmd->SCp.this_residual -= transfersize - len;
+                               } else
+#endif                         /* defined(PSEUDO_DMA) || defined(REAL_DMA_POLL) */
+                                       NCR5380_transfer_pio(instance, &phase,
+                                                            (int *) &cmd->SCp.this_residual, (unsigned char **)
+                                                         &cmd->SCp.ptr);
+                               break;
+                               case PHASE_MSGIN:
+                                   len = 1;
+                               data = &tmp;
+                               NCR5380_transfer_pio(instance, &phase, &len, &data);
+                               cmd->SCp.Message = tmp;
+
+                               switch (tmp) {
+                                       /*
+                                        * Linking lets us reduce the time required to get the 
+                                        * next command out to the device, hopefully this will
+                                        * mean we don't waste another revolution due to the delays
+                                        * required by ARBITRATION and another SELECTION.
+                                        *
+                                        * In the current implementation proposal, low level drivers
+                                        * merely have to start the next command, pointed to by 
+                                        * next_link, done() is called as with unlinked commands.
+                                        */
 #ifdef LINKED
-               case LINKED_CMD_COMPLETE:
-               case LINKED_FLG_CMD_COMPLETE:
-                   /* Accept message by clearing ACK */
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                   
-#if (NDEBUG & NDEBUG_LINKED) 
-                   printk("scsi%d : target %d lun %d linked command complete.\n",
-                       instance->host_no, cmd->target, cmd->lun);
-#endif
-                   /* 
-                    * Sanity check : A linked command should only terminate with
-                    * one of these messages if there are more linked commands
-                    * available.
-                    */
-
-                   if (!cmd->next_link) {
-                        printk("scsi%d : target %d lun %d linked command complete, no next_link\n"
-                           instance->host_no, cmd->target, cmd->lun);
-                           sink = 1;
-                           do_abort (instance);
-                           return;
-                   }
-
-                   initialize_SCp(cmd->next_link);
-                   /* The next command is still part of this process */
-                   cmd->next_link->tag = cmd->tag;
-                   cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 
-#if (NDEBUG & NDEBUG_LINKED) 
-                   printk("scsi%d : target %d lun %d linked request done, calling scsi_done().\n",
-                       instance->host_no, cmd->target, cmd->lun);
+                                       case LINKED_CMD_COMPLETE:
+                                           case LINKED_FLG_CMD_COMPLETE:
+                                       /* Accept message by clearing ACK */
+                                           NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+
+#if (NDEBUG & NDEBUG_LINKED)
+                                       printk("scsi%d : target %d lun %d linked command complete.\n",
+                                              instance->host_no, cmd->target, cmd->lun);
+#endif
+                                       /* 
+                                        * Sanity check : A linked command should only terminate with
+                                        * one of these messages if there are more linked commands
+                                        * available.
+                                        */
+
+                                       if (!cmd->next_link) {
+                                               printk("scsi%d : target %d lun %d linked command complete, no next_link\n"
+                                                      instance->host_no, cmd->target, cmd->lun);
+                                               sink = 1;
+                                               do_abort(instance);
+                                               return;
+                                       }
+                                       initialize_SCp(cmd->next_link);
+                                       /* The next command is still part of this process */
+                                       cmd->next_link->tag = cmd->tag;
+                                       cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
+#if (NDEBUG & NDEBUG_LINKED)
+                                       printk("scsi%d : target %d lun %d linked request done, calling scsi_done().\n",
+                                              instance->host_no, cmd->target, cmd->lun);
 #endif
 #ifdef NCR5380_STATS
-                   collect_stats(hostdata, cmd);
-#endif
-                   cmd->scsi_done(cmd);
-                   cmd = hostdata->connected;
-                   break;
-#endif /* def LINKED */
-               case ABORT:
-               case COMMAND_COMPLETE: 
-                   /* Accept message by clearing ACK */
-                   sink = 1;
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                   hostdata->connected = NULL;
+                                       collect_stats(hostdata, cmd);
+#endif
+                                       cmd->scsi_done(cmd);
+                                       cmd = hostdata->connected;
+                                       break;
+#endif                         /* def LINKED */
+                                       case ABORT:
+                                           case COMMAND_COMPLETE:
+                                       /* Accept message by clearing ACK */
+                                           sink = 1;
+                                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                       hostdata->connected = NULL;
 #if (NDEBUG & NDEBUG_QUEUES)
-                   printk("scsi%d : command for target %d, lun %d completed\n",
-                       instance->host_no, cmd->target, cmd->lun);
-#endif
-                   hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
-
-                   /* 
-                    * I'm not sure what the correct thing to do here is : 
-                    * 
-                    * If the command that just executed is NOT a request 
-                    * sense, the obvious thing to do is to set the result
-                    * code to the values of the stored parameters.
-                    * 
-                    * If it was a REQUEST SENSE command, we need some way 
-                    * to differentiate between the failure code of the original
-                    * and the failure code of the REQUEST sense - the obvious
-                    * case is success, where we fall through and leave the result
-                    * code unchanged.
-                    * 
-                    * The non-obvious place is where the REQUEST SENSE failed 
-                    */
-
-                   if (cmd->cmnd[0] != REQUEST_SENSE) 
-                       cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 
-                   else if (cmd->SCp.Status != GOOD)
-                       cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
-                   
-#ifdef AUTOSENSE
-                   if ((cmd->cmnd[0] != REQUEST_SENSE) && 
-                       (cmd->SCp.Status == CHECK_CONDITION)) {
-#if (NDEBUG & NDEBUG_AUTOSENSE) 
-                       printk("scsi%d : performing request sense\n", 
-                           instance->host_no);
-#endif
-                       cmd->cmnd[0] = REQUEST_SENSE;
-                       cmd->cmnd[1] &= 0xe0;
-                       cmd->cmnd[2] = 0;
-                       cmd->cmnd[3] = 0;
-                       cmd->cmnd[4] = sizeof(cmd->sense_buffer);
-                       cmd->cmnd[5] = 0;
-
-                       cmd->SCp.buffer = NULL;
-                       cmd->SCp.buffers_residual = 0;
-                       cmd->SCp.ptr = (char *) cmd->sense_buffer;
-                       cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
+                                       printk("scsi%d : command for target %d, lun %d completed\n",
+                                              instance->host_no, cmd->target, cmd->lun);
+#endif
+                                       hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
+
+                                       /* 
+                                        * I'm not sure what the correct thing to do here is : 
+                                        * 
+                                        * If the command that just executed is NOT a request 
+                                        * sense, the obvious thing to do is to set the result
+                                        * code to the values of the stored parameters.
+                                        * 
+                                        * If it was a REQUEST SENSE command, we need some way 
+                                        * to differentiate between the failure code of the original
+                                        * and the failure code of the REQUEST sense - the obvious
+                                        * case is success, where we fall through and leave the result
+                                        * code unchanged.
+                                        * 
+                                        * The non-obvious place is where the REQUEST SENSE failed 
+                                        */
+
+                                       if (cmd->cmnd[0] != REQUEST_SENSE)
+                                               cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
+                                       else if (cmd->SCp.Status != GOOD)
+                                               cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
-                       cli();
-                       LIST(cmd,hostdata->issue_queue);
-                       cmd->host_scribble = (unsigned char *) 
-                           hostdata->issue_queue;
-                       hostdata->issue_queue = (Scsi_Cmnd *) cmd;
-                       sti();
+#ifdef AUTOSENSE
+                                       if ((cmd->cmnd[0] != REQUEST_SENSE) &&
+                                           (cmd->SCp.Status == CHECK_CONDITION)) {
+                                               unsigned long flags;
+#if (NDEBUG & NDEBUG_AUTOSENSE)
+                                               printk("scsi%d : performing request sense\n",
+                                                      instance->host_no);
+#endif
+                                               cmd->cmnd[0] = REQUEST_SENSE;
+                                               cmd->cmnd[1] &= 0xe0;
+                                               cmd->cmnd[2] = 0;
+                                               cmd->cmnd[3] = 0;
+                                               cmd->cmnd[4] = sizeof(cmd->sense_buffer);
+                                               cmd->cmnd[5] = 0;
+
+                                               cmd->SCp.buffer = NULL;
+                                               cmd->SCp.buffers_residual = 0;
+                                               cmd->SCp.ptr = (char *) cmd->sense_buffer;
+                                               cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
+
+                                               save_flags(flags);
+                                               cli();
+                                               LIST(cmd, hostdata->issue_queue);
+                                               cmd->host_scribble = (unsigned char *)
+                                                   hostdata->issue_queue;
+                                               hostdata->issue_queue = (Scsi_Cmnd *) cmd;
+                                               restore_flags(flags);
 #if (NDEBUG & NDEBUG_QUEUES)
-                       printk("scsi%d : REQUEST SENSE added to head of issue queue\n",instance->host_no);
+                                               printk("scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no);
 #endif
-                  } else {
-#endif /* def AUTOSENSE */
+                                       } else {
+#endif                         /* def AUTOSENSE */
 #ifdef NCR5380_STATS
-                       collect_stats(hostdata, cmd);
-#endif
-                       cmd->scsi_done(cmd);
-                  }
-
-                   NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-                   /* 
-                    * Restore phase bits to 0 so an interrupted selection, 
-                    * arbitration can resume.
-                    */
-                   NCR5380_write(TARGET_COMMAND_REG, 0);
-                   
-                   while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
-                       barrier();
-                   return;
-               case MESSAGE_REJECT:
-                   /* Accept message by clearing ACK */
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                   switch (hostdata->last_message) {
-                   case HEAD_OF_QUEUE_TAG:
-                   case ORDERED_QUEUE_TAG:
-                   case SIMPLE_QUEUE_TAG:
-                       cmd->device->tagged_queue = 0;
-                       hostdata->busy[cmd->target] |= (1 << cmd->lun);
-                       break;
-                   default:
-                       break;
-                   }
-               case DISCONNECT:
-                   /* Accept message by clearing ACK */
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                   cmd->device->disconnect = 1;
-                   cli();
-                   LIST(cmd,hostdata->disconnected_queue);
-                   cmd->host_scribble = (unsigned char *) 
-                       hostdata->disconnected_queue;
-                   hostdata->connected = NULL;
-                   hostdata->disconnected_queue = cmd;
-                   sti();
+                                               collect_stats(hostdata, cmd);
+#endif
+                                               cmd->scsi_done(cmd);
+                                       }
+
+                                       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                                       /* 
+                                        * Restore phase bits to 0 so an interrupted selection, 
+                                        * arbitration can resume.
+                                        */
+                                       NCR5380_write(TARGET_COMMAND_REG, 0);
+
+                                       while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
+                                               barrier();
+                                       return;
+                                       case MESSAGE_REJECT:
+                                       /* Accept message by clearing ACK */
+                                           NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                       switch (hostdata->last_message) {
+                                               case HEAD_OF_QUEUE_TAG:
+                                                   case ORDERED_QUEUE_TAG:
+                                                   case SIMPLE_QUEUE_TAG:
+                                                   cmd->device->tagged_queue = 0;
+                                               hostdata->busy[cmd->target] |= (1 << cmd->lun);
+                                               break;
+                                               default:
+                                                   break;
+                                       }
+                                       case DISCONNECT: {
+                                               unsigned long flags;
+                                               /* Accept message by clearing ACK */
+                                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                               cmd->device->disconnect = 1;
+                                               save_flags(flags);
+                                               cli();
+                                               LIST(cmd, hostdata->disconnected_queue);
+                                               cmd->host_scribble = (unsigned char *)
+                                                   hostdata->disconnected_queue;
+                                               hostdata->connected = NULL;
+                                               hostdata->disconnected_queue = cmd;
+                                               restore_flags(flags);
 #if (NDEBUG & NDEBUG_QUEUES)
-                   printk("scsi%d : command for target %d lun %d was moved from connected to"
-                          "  the disconnected_queue\n", instance->host_no, 
-                           cmd->target, cmd->lun);
-#endif
-                   /* 
-                    * Restore phase bits to 0 so an interrupted selection, 
-                    * arbitration can resume.
-                    */
-                   NCR5380_write(TARGET_COMMAND_REG, 0);
-                   /* Enable reselect interrupts */
-                   NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-                   /* Wait for bus free to avoid nasty timeouts */
-                   while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
-                       barrier();
+                                               printk("scsi%d : command for target %d lun %d was moved from connected to"
+                                                      "  the disconnected_queue\n", instance->host_no,
+                                                 cmd->target, cmd->lun);
+#endif
+                                               /* 
+                                                * Restore phase bits to 0 so an interrupted selection, 
+                                                * arbitration can resume.
+                                                */
+                                               NCR5380_write(TARGET_COMMAND_REG, 0);
+
+                                               /* Enable reselect interrupts */
+                                               NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                                               /* Wait for bus free to avoid nasty timeouts */
+                                               while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
+                                                       barrier();
 #if 0
-                   NCR5380_print_status(instance);
-#endif
-                   return;
-               /* 
-                * The SCSI data pointer is *IMPLICITLY* saved on a disconnect
-                * operation, in violation of the SCSI spec so we can safely 
-                * ignore SAVE/RESTORE pointers calls.
-                *
-                * Unfortunately, some disks violate the SCSI spec and 
-                * don't issue the required SAVE_POINTERS message before
-                * disconnecting, and we have to break spec to remain 
-                * compatible.
-                */
-               case SAVE_POINTERS:
-               case RESTORE_POINTERS:
-                   /* Accept message by clearing ACK */
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                   break;
-               case EXTENDED_MESSAGE:
+                                               NCR5380_print_status(instance);
+#endif
+                                               return;
+                                       }
+                                       /* 
+                                        * The SCSI data pointer is *IMPLICITLY* saved on a disconnect
+                                        * operation, in violation of the SCSI spec so we can safely 
+                                        * ignore SAVE/RESTORE pointers calls.
+                                        *
+                                        * Unfortunately, some disks violate the SCSI spec and 
+                                        * don't issue the required SAVE_POINTERS message before
+                                        * disconnecting, and we have to break spec to remain 
+                                        * compatible.
+                                        */
+                                       case SAVE_POINTERS:
+                                           case RESTORE_POINTERS:
+                                       /* Accept message by clearing ACK */
+                                           NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                       break;
+                                       case EXTENDED_MESSAGE:
 /* 
  * Extended messages are sent in the following format :
- * Byte        
- * 0           EXTENDED_MESSAGE == 1
- * 1           length (includes one byte for code, doesn't 
- *             include first two bytes)
- * 2           code
- * 3..length+1 arguments
+ * Byte         
+ * 0            EXTENDED_MESSAGE == 1
+ * 1            length (includes one byte for code, doesn't 
+ *              include first two bytes)
+ * 2            code
+ * 3..length+1  arguments
  *
  * Start the extended message buffer with the EXTENDED_MESSAGE
  * byte, since print_msg() wants the whole thing.  
  */
-                   extended_msg[0] = EXTENDED_MESSAGE;
-                   /* Accept first byte by clearing ACK */
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                           extended_msg[0] = EXTENDED_MESSAGE;
+                                       /* Accept first byte by clearing ACK */
+                                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
 #if (NDEBUG & NDEBUG_EXTENDED)
-                   printk("scsi%d : receiving extended message\n",
-                       instance->host_no);
+                                       printk("scsi%d : receiving extended message\n",
+                                              instance->host_no);
 #endif
 
-                   len = 2;
-                   data = extended_msg + 1;
-                   phase = PHASE_MSGIN;
-                   NCR5380_transfer_pio(instance, &phase, &len, &data);
+                                       len = 2;
+                                       data = extended_msg + 1;
+                                       phase = PHASE_MSGIN;
+                                       NCR5380_transfer_pio(instance, &phase, &len, &data);
 
 #if (NDEBUG & NDEBUG_EXTENDED)
-                   printk("scsi%d : length=%d, code=0x%02x\n", 
-                       instance->host_no, (int) extended_msg[1],
-                       (int) extended_msg[2]);
+                                       printk("scsi%d : length=%d, code=0x%02x\n",
+                                              instance->host_no, (int) extended_msg[1],
+                                              (int) extended_msg[2]);
 #endif
 
-                   if (!len && extended_msg[1] <= 
-                       (sizeof (extended_msg) - 1)) {
-                       /* Accept third byte by clearing ACK */
-                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-                       len = extended_msg[1] - 1;
-                       data = extended_msg + 3;
-                       phase = PHASE_MSGIN;
+                                       if (!len && extended_msg[1] <=
+                                           (sizeof(extended_msg) - 1)) {
+                                               /* Accept third byte by clearing ACK */
+                                               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+                                               len = extended_msg[1] - 1;
+                                               data = extended_msg + 3;
+                                               phase = PHASE_MSGIN;
 
-                       NCR5380_transfer_pio(instance, &phase, &len, &data);
+                                               NCR5380_transfer_pio(instance, &phase, &len, &data);
 
 #if (NDEBUG & NDEBUG_EXTENDED)
-                   printk("scsi%d : message received, residual %d\n",
-                       instance->host_no, len);
-#endif
-
-                       switch (extended_msg[2]) {
-                       case EXTENDED_SDTR:
-                       case EXTENDED_WDTR:
-                       case EXTENDED_MODIFY_DATA_POINTER:
-                       case EXTENDED_EXTENDED_IDENTIFY:
-                           tmp = 0;
-                       }
-                   } else if (len) {
-                       printk("scsi%d: error receiving extended message\n",
-                           instance->host_no);
-                       tmp = 0;
-                   } else {
-                       printk("scsi%d: extended message code %02x length %d is too long\n",
-                           instance->host_no, extended_msg[2], extended_msg[1]);
-                       tmp = 0;
-                   }
-               /* Fall through to reject message */
-                   
-               /* 
-                * If we get something weird that we aren't expecting, 
-                * reject it.
-                */
-               default:
-                   if (!tmp) {
-                       printk("scsi%d: rejecting message ", instance->host_no);
-                       print_msg (extended_msg);
-                       printk("\n");
-                   } else if (tmp != EXTENDED_MESSAGE)
-                       printk("scsi%d: rejecting unknown message %02x from target %d, lun %d\n",
-                           instance->host_no, tmp, cmd->target, cmd->lun);
-                   else
-                       printk("scsi%d: rejecting unknown extended message code %02x, length %d from target %d, lun %d\n",
-                           instance->host_no, extended_msg[1], extended_msg[0], cmd->target, cmd->lun);
-
-                   msgout = MESSAGE_REJECT;
-                   NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
-                       ICR_ASSERT_ATN);
-                   break;
-               } /* switch (tmp) */
-               break;
-           case PHASE_MSGOUT:
-               len = 1;
-               data = &msgout;
-               hostdata->last_message = msgout;
-               NCR5380_transfer_pio(instance, &phase, &len, &data);
-               if (msgout == ABORT) {
-                   hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
-                   hostdata->connected = NULL;
-                   cmd->result = DID_ERROR << 16;
+                                               printk("scsi%d : message received, residual %d\n",
+                                                instance->host_no, len);
+#endif
+
+                                               switch (extended_msg[2]) {
+                                                       case EXTENDED_SDTR:
+                                                           case EXTENDED_WDTR:
+                                                           case EXTENDED_MODIFY_DATA_POINTER:
+                                                           case EXTENDED_EXTENDED_IDENTIFY:
+                                                           tmp = 0;
+                                               }
+                                       } else if (len) {
+                                               printk("scsi%d: error receiving extended message\n",
+                                                      instance->host_no);
+                                               tmp = 0;
+                                       } else {
+                                               printk("scsi%d: extended message code %02x length %d is too long\n",
+                                                      instance->host_no, extended_msg[2], extended_msg[1]);
+                                               tmp = 0;
+                                       }
+                                       /* Fall through to reject message */
+
+                                       /* 
+                                        * If we get something weird that we aren't expecting, 
+                                        * reject it.
+                                        */
+                                       default:
+                                           if (!tmp) {
+                                               printk("scsi%d: rejecting message ", instance->host_no);
+                                               print_msg(extended_msg);
+                                               printk("\n");
+                                       } else if (tmp != EXTENDED_MESSAGE)
+                                               printk("scsi%d: rejecting unknown message %02x from target %d, lun %d\n",
+                                                      instance->host_no, tmp, cmd->target, cmd->lun);
+                                       else
+                                               printk("scsi%d: rejecting unknown extended message code %02x, length %d from target %d, lun %d\n",
+                                                      instance->host_no, extended_msg[1], extended_msg[0], cmd->target, cmd->lun);
+
+                                       msgout = MESSAGE_REJECT;
+                                       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
+                                                     ICR_ASSERT_ATN);
+                                       break;
+                               }       /* switch (tmp) */
+                               break;
+                               case PHASE_MSGOUT:
+                                   len = 1;
+                               data = &msgout;
+                               hostdata->last_message = msgout;
+                               NCR5380_transfer_pio(instance, &phase, &len, &data);
+                               if (msgout == ABORT) {
+                                       hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
+                                       hostdata->connected = NULL;
+                                       cmd->result = DID_ERROR << 16;
 #ifdef NCR5380_STATS
-                   collect_stats(hostdata, cmd);
-#endif
-                   cmd->scsi_done(cmd);
-                   NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-                   return;
-               }
-               msgout = NOP;
-               break;
-           case PHASE_CMDOUT:
-               len = cmd->cmd_len;
-               data = cmd->cmnd;
-               /* 
-                * XXX for performance reasons, on machines with a 
-                * PSEUDO-DMA architecture we should probably 
-                * use the dma transfer function.  
-                */
-               NCR5380_transfer_pio(instance, &phase, &len, 
-                   &data);
+                                       collect_stats(hostdata, cmd);
+#endif
+                                       cmd->scsi_done(cmd);
+                                       NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+                                       return;
+                               }
+                               msgout = NOP;
+                               break;
+                               case PHASE_CMDOUT:
+                                   len = cmd->cmd_len;
+                               data = cmd->cmnd;
+                               /* 
+                                * XXX for performance reasons, on machines with a 
+                                * PSEUDO-DMA architecture we should probably 
+                                * use the dma transfer function.  
+                                */
+                               NCR5380_transfer_pio(instance, &phase, &len,
+                                                    &data);
 #ifdef USLEEP
-               if (!disconnect && should_disconnect(cmd->cmnd[0])) {
-                   hostdata->time_expires = jiffies + USLEEP_SLEEP;
+                               if (!disconnect && should_disconnect(cmd->cmnd[0])) {
+                                       hostdata->time_expires = jiffies + USLEEP_SLEEP;
 #if (NDEBUG & NDEBUG_USLEEP)
-               printk("scsi%d : issued command, sleeping until %ul\n", instance->host_no,
-                   hostdata->time_expires);
-#endif
-                   NCR5380_set_timer (instance);
-                   return;
-               }
-#endif /* def USLEEP */
-               break;
-           case PHASE_STATIN:
-               len = 1;
-               data = &tmp;
-               NCR5380_transfer_pio(instance, &phase, &len, &data);
-               cmd->SCp.Status = tmp;
-               break;
-           default:
-               printk("scsi%d : unknown phase\n", instance->host_no);
+                                       printk("scsi%d : issued command, sleeping until %ul\n", instance->host_no,
+                                              hostdata->time_expires);
+#endif
+                                       NCR5380_set_timer(instance);
+                                       return;
+                               }
+#endif                         /* def USLEEP */
+                               break;
+                               case PHASE_STATIN:
+                                   len = 1;
+                               data = &tmp;
+                               NCR5380_transfer_pio(instance, &phase, &len, &data);
+                               cmd->SCp.Status = tmp;
+                               break;
+                               default:
+                                   printk("scsi%d : unknown phase\n", instance->host_no);
 #ifdef NDEBUG
-               NCR5380_print(instance);
+                               NCR5380_print(instance);
 #endif
-           } /* switch(phase) */
-       } /* if (tmp * SR_REQ) */ 
+                       }       /* switch(phase) */
+               }               /* if (tmp * SR_REQ) */
 #ifdef USLEEP
-       else {
-           if (!disconnect && hostdata->time_expires && jiffies > 
-               hostdata->time_expires) {
-               hostdata->time_expires = jiffies + USLEEP_SLEEP;
+               else {
+                       if (!disconnect && hostdata->time_expires && jiffies >
+                           hostdata->time_expires) {
+                               hostdata->time_expires = jiffies + USLEEP_SLEEP;
 #if (NDEBUG & NDEBUG_USLEEP)
-               printk("scsi%d : poll timed out, sleeping until %ul\n", instance->host_no,
-                   hostdata->time_expires);
+                               printk("scsi%d : poll timed out, sleeping until %ul\n", instance->host_no,
+                                      hostdata->time_expires);
 #endif
-               NCR5380_set_timer (instance);
-               return;
-           }
-       }
+                               NCR5380_set_timer(instance);
+                               return;
+                       }
+               }
 #endif
-    } /* while (1) */
+       }                       /* while (1) */
 }
 
 /*
  * Function : void NCR5380_reselect (struct Scsi_Host *instance)
  *
  * Purpose : does reselection, initializing the instance->connected 
- *     field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 
- *     nexus has been reestablished,
- *     
+ *      field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 
+ *      nexus has been reestablished,
+ *      
  * Inputs : instance - this instance of the NCR5380.
  *
  */
 
 
-static void NCR5380_reselect (struct Scsi_Host *instance) {
-    NCR5380_local_declare();
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
-       instance->hostdata;
-    unsigned char target_mask;
-    unsigned char lun, phase;
-    int len;
+static void NCR5380_reselect(struct Scsi_Host *instance) {
+       NCR5380_local_declare();
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+        instance->hostdata;
+       unsigned char target_mask;
+       unsigned char lun, phase;
+       int len;
 #ifdef SCSI2
-    unsigned char tag;
+       unsigned char tag;
 #endif
-    unsigned char msg[3];
-    unsigned char *data;
-    Scsi_Cmnd *tmp = NULL, *prev;
-    int abort = 0;
-    NCR5380_setup(instance);
+       unsigned char msg[3];
+       unsigned char *data;
+       Scsi_Cmnd *tmp = NULL, *prev;
+       int abort = 0;
+        NCR5380_setup(instance);
 
-    /*
-     * Disable arbitration, etc. since the host adapter obviously
-     * lost, and tell an interrupted NCR5380_select() to restart.
-     */
+       /*
+        * Disable arbitration, etc. since the host adapter obviously
+        * lost, and tell an interrupted NCR5380_select() to restart.
+        */
 
-    NCR5380_write(MODE_REG, MR_BASE);
-    hostdata->restart_select = 1;
+        NCR5380_write(MODE_REG, MR_BASE);
+        hostdata->restart_select = 1;
 
-    target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask);
+        target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask);
 
 #if (NDEBUG & NDEBUG_RESELECTION)
-    printk("scsi%d : reselect\n", instance->host_no);
-#endif
-
-    /* 
-     * At this point, we have detected that our SCSI ID is on the bus,
-     * SEL is true and BSY was false for at least one bus settle delay
-     * (400 ns).
-     *
-     * We must assert BSY ourselves, until the target drops the SEL
-     * signal.
-     */
-
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY);
-    
-    while (NCR5380_read(STATUS_REG) & SR_SEL);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-
-    /*
-     * Wait for target to go into MSGIN.
-     */
-
-    while (!(NCR5380_read(STATUS_REG) & SR_REQ));
-
-    len = 1;
-    data = msg;
-    phase = PHASE_MSGIN;
-    NCR5380_transfer_pio(instance, &phase, &len, &data);
-
-
-    if (!msg[0] & 0x80) {
-       printk("scsi%d : expecting IDENTIFY message, got ",
-           instance->host_no);
-       print_msg(msg);
-       abort = 1;
-    } else {
-       /* Accept message by clearing ACK */
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-       lun = (msg[0] & 0x07);
+        printk("scsi%d : reselect\n", instance->host_no);
+#endif
 
        /* 
-        * We need to add code for SCSI-II to track which devices have
-        * I_T_L_Q nexuses established, and which have simple I_T_L
-        * nexuses so we can chose to do additional data transfer.
-        */
+        * At this point, we have detected that our SCSI ID is on the bus,
+        * SEL is true and BSY was false for at least one bus settle delay
+        * (400 ns).
+        *
+        * We must assert BSY ourselves, until the target drops the SEL
+        * signal.
+        */
+
+        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY);
+
+       while (NCR5380_read(STATUS_REG) & SR_SEL);
+        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+
+       /*
+        * Wait for target to go into MSGIN.
+        */
+
+       while (!(NCR5380_read(STATUS_REG) & SR_REQ));
+
+        len = 1;
+        data = msg;
+        phase = PHASE_MSGIN;
+        NCR5380_transfer_pio(instance, &phase, &len, &data);
+
+
+       if (!msg[0] & 0x80) {
+               printk("scsi%d : expecting IDENTIFY message, got ",
+                      instance->host_no);
+               print_msg(msg);
+               abort = 1;
+       } else {
+               /* Accept message by clearing ACK */
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+               lun = (msg[0] & 0x07);
+
+               /* 
+                * We need to add code for SCSI-II to track which devices have
+                * I_T_L_Q nexuses established, and which have simple I_T_L
+                * nexuses so we can chose to do additional data transfer.
+                */
 
 #ifdef SCSI2
 #error "SCSI-II tagged queueing is not supported yet"
 #endif
 
-       /* 
-        * Find the command corresponding to the I_T_L or I_T_L_Q  nexus we 
-        * just reestablished, and remove it from the disconnected queue.
-        */
+               /* 
+                * Find the command corresponding to the I_T_L or I_T_L_Q  nexus we 
+                * just reestablished, and remove it from the disconnected queue.
+                */
 
 
-       for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; 
-           tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) 
-           if ((target_mask == (1 << tmp->target)) && (lun == tmp->lun)
+               for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL;
+                tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
+                       if ((target_mask == (1 << tmp->target)) && (lun == tmp->lun)
 #ifdef SCSI2
-           && (tag == tmp->tag) 
-#endif
-) {
-           if (prev) {
-               REMOVE(prev,prev->host_scribble,tmp,tmp->host_scribble);
-               prev->host_scribble = tmp->host_scribble;
-           } else {
-               REMOVE(-1,hostdata->disconnected_queue,tmp,tmp->host_scribble);
-               hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble;
-           }
-           tmp->host_scribble = NULL;
-           break;
-       }
-
-       if (!tmp) {
+                           && (tag == tmp->tag)
+#endif
+                           ) {
+                               if (prev) {
+                                       REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
+                                       prev->host_scribble = tmp->host_scribble;
+                               } else {
+                                       REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble);
+                                       hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble;
+                               }
+                               tmp->host_scribble = NULL;
+                               break;
+                       }
+               if (!tmp) {
 #ifdef SCSI2
-           printk("scsi%d : warning : target bitmask %02x lun %d tag %d not in disconnect_queue.\n",
-                   instance->host_no, target_mask, lun, tag);
+                       printk("scsi%d : warning : target bitmask %02x lun %d tag %d not in disconnect_queue.\n",
+                              instance->host_no, target_mask, lun, tag);
 #else
-           printk("scsi%d : warning : target bitmask %02x lun %d not in disconnect_queue.\n",
-                   instance->host_no, target_mask, lun);
+                       printk("scsi%d : warning : target bitmask %02x lun %d not in disconnect_queue.\n",
+                              instance->host_no, target_mask, lun);
 #endif
-       /* 
-        * Since we have an established nexus that we can't do anything with,
-        * we must abort it.  
-        */
-       abort = 1;
+                       /* 
+                        * Since we have an established nexus that we can't do anything with,
+                        * we must abort it.  
+                        */
+                       abort = 1;
+               }
        }
-    }
 
-    if (abort) {
-       do_abort (instance);
-    } else {
-       hostdata->connected = tmp;
+       if (abort) {
+               do_abort(instance);
+       } else {
+               hostdata->connected = tmp;
 #if (NDEBUG & NDEBUG_RESELECTION)
-       printk("scsi%d : nexus established, target = %d, lun = %d, tag = %d\n",
-           instance->host_no, tmp->target, tmp->lun, tmp->tag);
+               printk("scsi%d : nexus established, target = %d, lun = %d, tag = %d\n",
+                    instance->host_no, tmp->target, tmp->lun, tmp->tag);
 #endif
-    }
+       }
 }
 
 /*
  * Function : void NCR5380_dma_complete (struct Scsi_Host *instance)
  *
  * Purpose : called by interrupt handler when DMA finishes or a phase
- *     mismatch occurs (which would finish the DMA transfer).  
+ *      mismatch occurs (which would finish the DMA transfer).  
  *
  * Inputs : instance - this instance of the NCR5380.
  *
  * Returns : pointer to the Scsi_Cmnd structure for which the I_T_L
- *     nexus has been reestablished, on failure NULL is returned.
+ *      nexus has been reestablished, on failure NULL is returned.
  */
 
 #ifdef REAL_DMA
-static void NCR5380_dma_complete (NCR5380_instance *instance) {
-    NCR5380_local_declare();
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *
-       instance->hostdata);
-    int transferred;
-    NCR5380_setup(instance);
-    
-    /*
-     * XXX this might not be right.
-     *
-     * Wait for final byte to transfer, ie wait for ACK to go false.
-     *
-     * We should use the Last Byte Sent bit, unfortunately this is 
-     * not available on the 5380/5381 (only the various CMOS chips)
-     */
-
-    while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK);
-
-    NCR5380_write(MODE_REG, MR_BASE);
-    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-
-    /*
-     * The only places we should see a phase mismatch and have to send
-     * data from the same set of pointers will be the data transfer
-     * phases.  So, residual, requested length are only important here.
-     */
-
-    if (!(hostdata->connected->SCp.phase & SR_CD)) {
-       transferred = instance->dmalen - NCR5380_dma_residual();
-       hostdata->connected->SCp.this_residual -= transferred;
-       hostdata->connected->SCp.ptr += transferred;
-    }
+static void NCR5380_dma_complete(NCR5380_instance * instance) {
+       NCR5380_local_declare();
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *
+                                            instance->hostdata);
+       int transferred;
+       NCR5380_setup(instance);
+
+       /*
+        * XXX this might not be right.
+        *
+        * Wait for final byte to transfer, ie wait for ACK to go false.
+        *
+        * We should use the Last Byte Sent bit, unfortunately this is 
+        * not available on the 5380/5381 (only the various CMOS chips)
+        */
+
+       while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK);
+
+       NCR5380_write(MODE_REG, MR_BASE);
+       NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+
+       /*
+        * The only places we should see a phase mismatch and have to send
+        * data from the same set of pointers will be the data transfer
+        * phases.  So, residual, requested length are only important here.
+        */
+
+       if (!(hostdata->connected->SCp.phase & SR_CD)) {
+               transferred = instance->dmalen - NCR5380_dma_residual();
+               hostdata->connected->SCp.this_residual -= transferred;
+               hostdata->connected->SCp.ptr += transferred;
+       }
 }
-#endif /* def REAL_DMA */
+#endif                         /* def REAL_DMA */
 
 /*
  * Function : int NCR5380_abort (Scsi_Cmnd *cmd)
@@ -3040,44 +3132,46 @@ static void NCR5380_dma_complete (NCR5380_instance *instance) {
  * Purpose : abort a command
  *
  * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 
- *     host byte of the result field to, if zero DID_ABORTED is 
- *     used.
+ *      host byte of the result field to, if zero DID_ABORTED is 
+ *      used.
  *
  * Returns : 0 - success, -1 on failure.
  *
  * XXX - there is no way to abort the command that is currently 
- *      connected, you have to wait for it to complete.  If this is 
- *      a problem, we could implement longjmp() / setjmp(), setjmp()
- *      called where the loop started in NCR5380_main().
+ *       connected, you have to wait for it to complete.  If this is 
+ *       a problem, we could implement longjmp() / setjmp(), setjmp()
+ *       called where the loop started in NCR5380_main().
  */
 
 #ifndef NCR5380_abort
 static
 #endif
-int NCR5380_abort (Scsi_Cmnd *cmd) {
-    NCR5380_local_declare();
-    struct Scsi_Host *instance = cmd->host;
-    struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
-       instance->hostdata;
-    Scsi_Cmnd *tmp, **prev;
+int NCR5380_abort(Scsi_Cmnd * cmd) {
+       NCR5380_local_declare();
+       unsigned long flags;
+       struct Scsi_Host *instance = cmd->host;
+       struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
+        instance->hostdata;
+       Scsi_Cmnd *tmp, **prev;
 
-    printk("scsi%d : aborting command\n", instance->host_no);
-    print_Scsi_Cmnd (cmd);
+       printk("scsi%d : aborting command\n", instance->host_no);
+       print_Scsi_Cmnd(cmd);
 
-    NCR5380_print_status (instance);
+       NCR5380_print_status(instance);
 
-    printk("scsi%d : aborting command\n", instance->host_no);
-    print_Scsi_Cmnd (cmd);
+       printk("scsi%d : aborting command\n", instance->host_no);
+       print_Scsi_Cmnd(cmd);
 
-    NCR5380_print_status (instance);
+       NCR5380_print_status(instance);
 
-    cli();
-    NCR5380_setup(instance);
+       save_flags(flags);
+       cli();
+       NCR5380_setup(instance);
 
 #if (NDEBUG & NDEBUG_ABORT)
-    printk("scsi%d : abort called\n", instance->host_no);
-    printk("        basr 0x%X, sr 0x%X\n", 
-          NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG));
+       printk("scsi%d : abort called\n", instance->host_no);
+       printk("        basr 0x%X, sr 0x%X\n",
+            NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG));
 #endif
 
 #if 0
@@ -3087,17 +3181,17 @@ int NCR5380_abort (Scsi_Cmnd *cmd) {
  * information transfer routine can exit cleanly.
  */
 
-    if (hostdata->connected == cmd) {
+       if (hostdata->connected == cmd) {
 #if (NDEBUG & NDEBUG_ABORT)
-       printk("scsi%d : aborting connected command\n", instance->host_no);
+               printk("scsi%d : aborting connected command\n", instance->host_no);
 #endif
-       hostdata->aborted = 1;
+               hostdata->aborted = 1;
 /*
  * We should perform BSY checking, and make sure we haven't slipped
  * into BUS FREE.
  */
 
-       NCR5380_write(INITIATOR_COMMAND_REG, ICR_ASSERT_ATN);
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_ASSERT_ATN);
 /* 
  * Since we can't change phases until we've completed the current 
  * handshake, we have to source or sink a byte of data if the current
@@ -3107,65 +3201,65 @@ int NCR5380_abort (Scsi_Cmnd *cmd) {
 /* 
  * Return control to the executing NCR drive so we can clear the
  * aborted flag and get back into our main loop.
- */ 
-       return 0;
-    }
+ */
+
+               return 0;
+       }
 #endif
 
 /* 
  * Case 2 : If the command hasn't been issued yet, we simply remove it 
- *         from the issue queue.
+ *          from the issue queue.
  */
 #if (NDEBUG & NDEBUG_ABORT)
-    /* KLL */
-    printk("scsi%d : abort going into loop.\n", instance->host_no);
-#endif
-    for (prev = (Scsi_Cmnd **) &(hostdata->issue_queue), 
-       tmp = (Scsi_Cmnd *) hostdata->issue_queue;
-       tmp; prev = (Scsi_Cmnd **) &(tmp->host_scribble), tmp = 
-       (Scsi_Cmnd *) tmp->host_scribble) 
-       if (cmd == tmp) {
-           REMOVE(5,*prev,tmp,tmp->host_scribble);
-           (*prev) = (Scsi_Cmnd *) tmp->host_scribble;
-           tmp->host_scribble = NULL;
-           tmp->result = DID_ABORT << 16;
-           sti();
+       /* KLL */
+       printk("scsi%d : abort going into loop.\n", instance->host_no);
+#endif
+       for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue),
+            tmp = (Scsi_Cmnd *) hostdata->issue_queue;
+            tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp =
+            (Scsi_Cmnd *) tmp->host_scribble)
+               if (cmd == tmp) {
+                       REMOVE(5, *prev, tmp, tmp->host_scribble);
+                       (*prev) = (Scsi_Cmnd *) tmp->host_scribble;
+                       tmp->host_scribble = NULL;
+                       tmp->result = DID_ABORT << 16;
+                       restore_flags(flags);
 #if (NDEBUG & NDEBUG_ABORT)
-    printk("scsi%d : abort removed command from issue queue.\n", 
-       instance->host_no);
+                       printk("scsi%d : abort removed command from issue queue.\n",
+                              instance->host_no);
 #endif
-           tmp->done(tmp);
-           return SCSI_ABORT_SUCCESS;
-       }
+                       tmp->done(tmp);
+                       return SCSI_ABORT_SUCCESS;
+               }
 #if (NDEBUG  & NDEBUG_ABORT)
-    /* KLL */
-       else if (prev == tmp) printk("scsi%d : LOOP\n", instance->host_no);
+       /* KLL */
+               else if (prev == tmp)
+                       printk("scsi%d : LOOP\n", instance->host_no);
 #endif
 
 /* 
  * Case 3 : If any commands are connected, we're going to fail the abort
- *         and let the high level SCSI driver retry at a later time or 
- *         issue a reset.
+ *          and let the high level SCSI driver retry at a later time or 
+ *          issue a reset.
  *
- *         Timeouts, and therefore aborted commands, will be highly unlikely
+ *          Timeouts, and therefore aborted commands, will be highly unlikely
  *          and handling them cleanly in this situation would make the common
- *         case of noresets less efficient, and would pollute our code.  So,
- *         we fail.
+ *          case of noresets less efficient, and would pollute our code.  So,
+ *          we fail.
  */
 
-    if (hostdata->connected) {
-       sti();
+       if (hostdata->connected) {
+               restore_flags(flags);
 #if (NDEBUG & NDEBUG_ABORT)
-    printk("scsi%d : abort failed, command connected.\n", instance->host_no);
+               printk("scsi%d : abort failed, command connected.\n", instance->host_no);
 #endif
-       return SCSI_ABORT_NOT_RUNNING;
-    }
-
+               return SCSI_ABORT_NOT_RUNNING;
+       }
 /*
  * Case 4: If the command is currently disconnected from the bus, and 
- *     there are no connected commands, we reconnect the I_T_L or 
- *     I_T_L_Q nexus associated with it, go into message out, and send 
+ *      there are no connected commands, we reconnect the I_T_L or 
+ *      I_T_L_Q nexus associated with it, go into message out, and send 
  *      an abort message.
  *
  * This case is especially ugly. In order to reestablish the nexus, we
@@ -3187,42 +3281,41 @@ int NCR5380_abort (Scsi_Cmnd *cmd) {
  * it from the disconnected queue.
  */
 
-    for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; 
-       tmp = (Scsi_Cmnd *) tmp->host_scribble) 
-       if (cmd == tmp) {
-           sti(); 
+       for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp;
+            tmp = (Scsi_Cmnd *) tmp->host_scribble)
+               if (cmd == tmp) {
+                       restore_flags(flags);
 #if (NDEBUG & NDEBUG_ABORT)
-    printk("scsi%d : aborting disconnected command.\n", instance->host_no);
+                       printk("scsi%d : aborting disconnected command.\n", instance->host_no);
 #endif
-  
-           if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
-               return SCSI_ABORT_BUSY;
+
+                       if (NCR5380_select(instance, cmd, (int) cmd->tag))
+                               return SCSI_ABORT_BUSY;
 
 #if (NDEBUG & NDEBUG_ABORT)
-    printk("scsi%d : nexus reestablished.\n", instance->host_no);
-#endif
-
-           do_abort (instance);
-
-           cli();
-           for (prev = (Scsi_Cmnd **) &(hostdata->disconnected_queue), 
-               tmp = (Scsi_Cmnd *) hostdata->disconnected_queue;
-               tmp; prev = (Scsi_Cmnd **) &(tmp->host_scribble), tmp = 
-               (Scsi_Cmnd *) tmp->host_scribble) 
-                   if (cmd == tmp) {
-                   REMOVE(5,*prev,tmp,tmp->host_scribble);
-                   *prev = (Scsi_Cmnd *) tmp->host_scribble;
-                   tmp->host_scribble = NULL;
-                   tmp->result = DID_ABORT << 16;
-                   sti();
-                   tmp->done(tmp);
-                   return SCSI_ABORT_SUCCESS;
-               }
-       }
+                       printk("scsi%d : nexus reestablished.\n", instance->host_no);
+#endif
 
+                       do_abort(instance);
+
+                       cli();
+                       for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue),
+                       tmp = (Scsi_Cmnd *) hostdata->disconnected_queue;
+                            tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp =
+                            (Scsi_Cmnd *) tmp->host_scribble)
+                               if (cmd == tmp) {
+                                       REMOVE(5, *prev, tmp, tmp->host_scribble);
+                                       *prev = (Scsi_Cmnd *) tmp->host_scribble;
+                                       tmp->host_scribble = NULL;
+                                       tmp->result = DID_ABORT << 16;
+                                       restore_flags(flags);
+                                       tmp->done(tmp);
+                                       return SCSI_ABORT_SUCCESS;
+                               }
+               }
 /*
  * Case 5 : If we reached this point, the command was not found in any of 
- *         the queues.
+ *          the queues.
  *
  * We probably reached this point because of an unlikely race condition
  * between the command completing successfully and the abortion code,
@@ -3230,10 +3323,10 @@ int NCR5380_abort (Scsi_Cmnd *cmd) {
  * broke.
  */
 
-    sti();
-    printk("scsi%d : warning : SCSI command probably completed successfully\n"
-          "         before abortion\n", instance->host_no); 
-    return SCSI_ABORT_NOT_RUNNING;
+       restore_flags(flags);
+       printk("scsi%d : warning : SCSI command probably completed successfully\n"
+              "         before abortion\n", instance->host_no);
+       return SCSI_ABORT_NOT_RUNNING;
 }
 
 
@@ -3244,18 +3337,17 @@ int NCR5380_abort (Scsi_Cmnd *cmd) {
  *
  * Returns : SCSI_RESET_WAKEUP
  *
- */ 
+ */
 
 #ifndef NCR5380_reset
 static
 #endif
-int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int dummy) {
-    NCR5380_local_declare();
-    NCR5380_setup(cmd->host);
+int NCR5380_reset(Scsi_Cmnd * cmd, unsigned int dummy) {
+       NCR5380_local_declare();
+       NCR5380_setup(cmd->host);
 
-    NCR5380_print_status (cmd->host);
-    do_reset (cmd->host);
+       NCR5380_print_status(cmd->host);
+       do_reset(cmd->host);
 
-    return SCSI_RESET_WAKEUP;
+       return SCSI_RESET_WAKEUP;
 }
-
index a133a7d72b79cc785ab378ea146d430099d08338..3080edc96d88af40df69873003583246e9a4735a 100644 (file)
@@ -976,7 +976,6 @@ static int irq_probe()
     int i;
     
     inb(INT_REG);               /* clear the interrupt register */
-    sti();
     irqs = probe_irq_on();
     
     /* Invalid command will cause an interrupt */
index 76fd05cb714e3c93e50a980f90cb3dd09ac17e65..26621d11dad69d7374f09279d32897c5c21cc1df 100644 (file)
@@ -5579,7 +5579,7 @@ advansys_abort(Scsi_Cmnd *scp)
                 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
                 scp->result = HOST_BYTE(DID_ABORT);
 
-                sti(); /* Enable interrupts for AscAbortSRB(). */
+                /* sti(); - FIXME!!! Enable interrupts for AscAbortSRB() must be careful about io_lock. */
                 ASC_DBG1(1, "advansys_abort: before AscAbortSRB(), scp %x\n",
                     (unsigned) scp);
                 switch (AscAbortSRB(asc_dvc_varp, (ulong) scp)) {
@@ -5849,9 +5849,9 @@ advansys_reset(Scsi_Cmnd *scp, unsigned int reset_flags)
                  * Reset the target's SCSI bus.
                  */
                 ASC_DBG(1, "advansys_reset: before AscResetSB()\n");
-                sti();    /* Enable interrupts for AscResetSB(). */
+                /* sti();    FIXME!!! Enable interrupts for AscResetSB(). */
                 status = AscResetSB(asc_dvc_varp);
-                cli();
+                /* cli();    FIXME!!! */
                 switch (status) {
                 case ASC_TRUE:
                     ASC_DBG(1, "advansys_reset: AscResetSB() success\n");
@@ -5874,9 +5874,9 @@ advansys_reset(Scsi_Cmnd *scp, unsigned int reset_flags)
                 ASC_DBG1(1,
                     "advansys_reset: before AscResetDevice(), target %d\n",
                     scp->target);
-                sti();    /* Enable interrupts for AscResetDevice(). */
+                /* sti();    FIXME!!! Enable interrupts for AscResetDevice(). */
                 status = AscResetDevice(asc_dvc_varp, scp->target);
-                cli();
+                /* cli();    FIXME!!! */
 
                 switch (status) {
                 case ASC_TRUE:
@@ -5888,9 +5888,9 @@ advansys_reset(Scsi_Cmnd *scp, unsigned int reset_flags)
                 default:
                     ASC_DBG(1,
 "advansys_reset: AscResetDevice() failed; Calling AscResetSB()\n");
-                    sti();    /* Enable interrupts for AscResetSB(). */
+                    /* sti();   FIXME!!! Enable interrupts for AscResetSB(). */
                     status = AscResetSB(asc_dvc_varp);
-                    cli();
+                    /* cli(); */
                     switch (status) {
                     case ASC_TRUE:
                         ASC_DBG(1, "advansys_reset: AscResetSB() TRUE\n");
index cb35fefafeef0ff9a394191ab0dd63202610b368..3767e1e3e3aad87c4018e72088462e15d76fe4a2 100644 (file)
@@ -1271,7 +1271,7 @@ int aha152x_abort(Scsi_Cmnd *SCpnt)
     HOSTDATA(shpnt)->aborting++;
     HOSTDATA(shpnt)->abortion_complete=0;
 
-    sti();  /* Hi Eric, guess what ;-) */
+    restore_flags(flags);
 
     /* sleep until the abortion is complete */
     while(!HOSTDATA(shpnt)->abortion_complete)
@@ -1556,7 +1556,7 @@ void aha152x_intr(int irqno, void *dev_id, struct pt_regs * regs)
      intr(). To avoid race conditions, we have to return
      immediately afterwards. */
   CLRBITS(DMACNTRL0, INTEN);
-  sti();  /* Yes, sti() really needs to be here */
+  /* sti();  FIXME!!! Yes, sti() really needs to be here if we want to lock up */
 
   /* disconnected target is trying to reconnect.
      Only possible, if we have disconnected nexuses and
index ffd1e00e10910d72993c0fce09464ec581594a18..33da50f7f0e946e3c94c0d6b83e6e4d0bcb4f903 100644 (file)
@@ -1535,10 +1535,10 @@ int eata2x_reset(Scsi_Cmnd *SCarg, unsigned int reset_flags) {
 #endif
 
    HD(j)->in_reset = TRUE;
-   sti();
-   time = jiffies;
-   while ((jiffies - time) < (10 * HZ) && limit++ < 200000) udelay(100L);
-   cli();
+
+   /* Wait 2 seconds ???!!! */
+   { unsigned long msec = 2 * 1000; while (--msec) udelay(1000); }
+
    printk("%s: reset, interrupts disabled, loops %d.\n", BN(j), limit);
 
    for (i = 0; i < sh[j]->can_queue; i++) {
index f07c5c05dcb7c37582b2ce2874969c3d8ed14491..0724a4e460dc681de9305eb95fa41ac7329ca295 100644 (file)
@@ -1191,7 +1191,7 @@ void fdomain_16x0_intr( int irq, void *dev_id, struct pt_regs * regs )
                                   interruptions while this routine is
                                   running. */
 
-   sti();                      /* Yes, we really want sti() here */
+   /* sti();                    Yes, we really want sti() here if we want to lock up our machine */
    
    outb( 0x00, Interrupt_Cntl_port );
 
index 9a667410a72ae8b773fe974d480c1bb25f424c9e..8d2612fb4695938dcef74bf296771d1cf1cbcbd4 100644 (file)
@@ -614,6 +614,7 @@ int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int leng
 {
     int len = 0;
     NCR5380_local_declare();
+    unsigned long flags;
     unsigned char status;
     int i;
     struct Scsi_Host *scsi_ptr;
@@ -622,7 +623,8 @@ int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int leng
 #ifdef NCR5380_STATS
     Scsi_Device *dev;
     extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
-#endif    
+#endif
+    save_flags(flags);
     cli();
 
     for (scsi_ptr = first_instance; scsi_ptr; scsi_ptr=scsi_ptr->next)
@@ -721,7 +723,7 @@ int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int leng
     len -= offset;
     if (len > length)
            len = length;
-    sti();
+    restore_flags(flags);
     return len;
 }
 
index 550ed7df8be59d5bea1206f1dfbd79d2fc700109..c45a8617d74de8dfe081eb8e2a35a2f3fe0aead4 100644 (file)
@@ -2703,7 +2703,7 @@ void gdth_timeout(void)
 
     timer_table[GDTH_TIMER].expires = jiffies + 30*HZ;
     timer_active |= 1<<GDTH_TIMER;
-    sti();
+    restore_flags(flags);
 }
 #endif
 
index 034b219cc2354fc31cf8bece186d28b5385f6a9c..d1c7507a7798737f93d80e33d1070e6b0972653f 100644 (file)
@@ -877,6 +877,7 @@ interrupt_handler (int irq, void *dev_id, struct pt_regs *regs)
   unsigned int intr_reg;
   unsigned int cmd_result;
   unsigned int ldn;
+  unsigned long flags;
 
   /* search for one adapter-response on shared interrupt */
   do
@@ -892,14 +893,15 @@ interrupt_handler (int irq, void *dev_id, struct pt_regs *regs)
   ldn = intr_reg & 0x0f;
 
   /*must wait for attention reg not busy, then send EOI to subsystem */
+  save_flags(flags);
   while (1) {
       cli ();
       if (!(inb (IM_STAT_REG) & IM_BUSY)) 
         break;
-      sti ();
+      restore_flags(flags);
     }
   outb (IM_EOI | ldn, IM_ATTN_REG);
-  sti ();
+  restore_flags (flags);
 
   /*these should never happen (hw fails, or a local programming bug) */
   if (cmd_result == IM_ADAPTER_HW_FAILURE)
@@ -1007,19 +1009,21 @@ static void
 issue_cmd (struct Scsi_Host *shpnt, unsigned long cmd_reg, 
            unsigned char attn_reg)
 {
+  unsigned long flags;
   /*must wait for attention reg not busy */
+  save_flags(flags);
   while (1)
     {
       cli ();
       if (!(inb (IM_STAT_REG) & IM_BUSY))
        break;
-      sti ();
+      restore_flags (flags);
     }
 
   /*write registers and enable system interrupts */
   outl (cmd_reg, IM_CMD_REG);
   outb (attn_reg, IM_ATTN_REG);
-  sti ();
+  restore_flags (flags);
 }
 
 /*--------------------------------------------------------------------*/
@@ -2021,7 +2025,7 @@ ibmmca_abort (Scsi_Cmnd * cmd)
   /*if cmd for this ldn has already finished, no need to abort */
   if (!ld[ldn].cmd)
     {
-      sti ();
+      /* sti (); */
       return SCSI_ABORT_NOT_RUNNING;
     }
 
@@ -2174,6 +2178,7 @@ int ibmmca_proc_info (char *buffer, char **start, off_t offset, int length,
    int len=0;
    int i,id,lun;
    struct Scsi_Host *shpnt;
+   unsigned long flags;
 
    for (i = 0; hosts[i] && hosts[i]->host_no != hostno; i++);
    shpnt = hosts[i];
@@ -2182,6 +2187,7 @@ int ibmmca_proc_info (char *buffer, char **start, off_t offset, int length,
        return len;
    }
 
+   save_flags(flags);
    cli();
 
    len += sprintf(buffer+len, "\n             IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n",
@@ -2263,7 +2269,7 @@ int ibmmca_proc_info (char *buffer, char **start, off_t offset, int length,
    if (len > length) 
      len = length;
    
-   sti();
+   restore_flags(flags);
    
    return len;
 }
index 7e11430d4802fb36d46183d80fa8929bc21bba12..adc7ccf2e78e1a314cf5e104eade70b16c6a04ac 100644 (file)
@@ -858,7 +858,6 @@ static void in2000_intr (int irqnum, void * dev_id, struct pt_regs *ptregs)
 struct Scsi_Host *instance;
 struct IN2000_hostdata *hostdata;
 Scsi_Cmnd *patch, *cmd;
-unsigned long flags;
 uchar asr, sr, phs, id, lun, *ucp, msg;
 int i,j;
 unsigned long length;
@@ -875,11 +874,6 @@ unsigned short f;
       }
    hostdata = (struct IN2000_hostdata *)instance->hostdata;
 
-/* OK - it should now be safe to re-enable system interrupts */
-
-   save_flags(flags);
-   sti();
-
 #ifdef PROC_STATISTICS
    hostdata->int_cnt++;
 #endif
@@ -1014,7 +1008,6 @@ DB(DB_FIFO,printk("{W:%02x} ",read1_io(IO_FIFO_COUNT)))
             }
 
       write1_io(0, IO_LED_OFF);
-      restore_flags(flags);
       return;
       }
 
@@ -1030,7 +1023,6 @@ DB(DB_FIFO,printk("{W:%02x} ",read1_io(IO_FIFO_COUNT)))
    if (!cmd && (sr != CSR_RESEL_AM && sr != CSR_TIMEOUT && sr != CSR_SELECT)) {
       printk("\nNR:wd-intr-1\n");
       write1_io(0, IO_LED_OFF);
-      restore_flags(flags);
       return;
       }
 
@@ -1092,10 +1084,12 @@ DB(DB_TRANSFER,printk("(%p,%d)",cmd->SCp.ptr,cmd->SCp.this_residual))
 /* Respond to the specific WD3393 interrupt - there are quite a few! */
 
    switch (sr) {
+      unsigned long flags;
 
       case CSR_TIMEOUT:
 DB(DB_INTR,printk("TIMEOUT"))
 
+        save_flags(flags);
          cli();
          if (hostdata->state == S_RUNNING_LEVEL2)
             hostdata->connected = NULL;
@@ -1114,7 +1108,7 @@ CHECK_NULL(cmd,"csr_timeout")
  * are commands waiting to be executed.
  */
 
-         sti();
+         restore_flags(flags);
          in2000_execute(instance);
          break;
 
@@ -1361,6 +1355,7 @@ printk("sync_xfer=%02x",hostdata->sync_xfer[cmd->target]);
 /* Note: this interrupt will occur only after a LEVEL2 command */
 
       case CSR_SEL_XFER_DONE:
+         save_flags(flags);
          cli();
 
 /* Make sure that reselection is enabled at this point - it may
@@ -1388,7 +1383,7 @@ DB(DB_INTR,printk(":%d.%d",cmd->SCp.Status,lun))
  * there are commands waiting to be executed.
  */
 
-            sti();
+            restore_flags(flags);
             in2000_execute(instance);
             }
          else {
@@ -1447,6 +1442,7 @@ DB(DB_INTR,printk("%02x",hostdata->outgoing_msg[0]))
  * so we treat it as a normal command-complete-disconnect.
  */
 
+        save_flags(flags);
          cli();
 
 /* Make sure that reselection is enabled at this point - it may
@@ -1473,12 +1469,13 @@ DB(DB_INTR,printk("UNEXP_DISC-%ld",cmd->pid))
  * there are commands waiting to be executed.
  */
 
-         sti();
+         restore_flags(flags);
          in2000_execute(instance);
          break;
 
 
       case CSR_DISC:
+         save_flags(flags);
          cli();
 
 /* Make sure that reselection is enabled at this point - it may
@@ -1524,7 +1521,7 @@ DB(DB_INTR,printk(":%d",cmd->SCp.Status))
  * there are commands waiting to be executed.
  */
 
-         sti();
+         restore_flags(flags);
          in2000_execute(instance);
          break;
 
@@ -1633,7 +1630,6 @@ DB(DB_INTR,printk("-%ld",cmd->pid))
       }
 
    write1_io(0, IO_LED_OFF);
-   restore_flags(flags);
 
 DB(DB_INTR,printk("} "))
 
index 9e740dd325602820fe6b413de6062a6274ae0395..7f192abfc57e593cdc62ebe4a808085f5dc2223f 100644 (file)
@@ -1457,6 +1457,7 @@ SCSI_LOG_MLQUEUE(4,
     memcpy ((void *) SCpnt->data_cmnd , (const void *) cmnd, 12);
     SCpnt->reset_chain = NULL;
     SCpnt->serial_number = 0;
+    SCpnt->serial_number_at_timeout = 0;
     SCpnt->bufflen = bufflen;
     SCpnt->buffer = buffer;
     SCpnt->flags = 0;
@@ -1526,6 +1527,10 @@ scsi_done (Scsi_Cmnd * SCpnt)
       return;
     }
 
+  /* Set the serial numbers back to zero */
+  SCpnt->serial_number = 0;
+  SCpnt->serial_number_at_timeout = 0;
+
   SCpnt->state = SCSI_STATE_BHQUEUE;
   SCpnt->owner = SCSI_OWNER_BH_HANDLER;
   SCpnt->bh_next = NULL;
@@ -2300,6 +2305,8 @@ int scsi_proc_info(char *buffer, char **start, off_t offset, int length,
            return(-ENOSYS);  /* We do not yet support unplugging */
 
        scan_scsis (HBA_ptr, 1, channel, id, lun);
+       if (HBA_ptr->select_queue_depths != NULL)
+               (HBA_ptr->select_queue_depths)(HBA_ptr, HBA_ptr->host_queue);
        return(length);
 
     }
index d10651019f3edd8a3be2c55e7915133f91bbbc20..727c039bb22bb10df89c57f2b398e607a51bbdea 100644 (file)
@@ -201,6 +201,9 @@ static void do_scsi_times_out (Scsi_Cmnd * SCpnt)
      }
 #endif
 
+    /* Set the serial_number_at_timeout to the current serial_number */
+    SCpnt->serial_number_at_timeout = SCpnt->serial_number;
+
     SCpnt->state = SCSI_STATE_TIMEOUT;
     SCpnt->owner = SCSI_OWNER_ERROR_HANDLER;
     
index fcb3348d471a0f88aa3f995b781d53a493eb8d60..bbf645acdf59f778ba90d3f44ef170727d6da4c1 100644 (file)
@@ -146,6 +146,10 @@ void scsi_old_times_out (Scsi_Cmnd * SCpnt)
     unsigned long flags;
 
     spin_lock_irqsave(&io_request_lock, flags);
+
+    /* Set the serial_number_at_timeout to the current serial_number */
+    SCpnt->serial_number_at_timeout = SCpnt->serial_number;
+
     switch (SCpnt->internal_timeout & (IN_ABORT | IN_RESET | IN_RESET2 | IN_RESET3))
     {
     case NORMAL_TIMEOUT:
@@ -321,6 +325,7 @@ void scsi_old_done (Scsi_Cmnd * SCpnt)
     struct Scsi_Host * host = SCpnt->host;
     int result = SCpnt->result;
     SCpnt->serial_number = 0;
+    SCpnt->serial_number_at_timeout = 0;
     oldto = update_timeout(SCpnt, 0);
 
 #ifdef DEBUG_TIMEOUT
index 09c3407d6bf71874c6590c2edef7b0b514137c33..48791758496aafe8d6d637343241c4fec60ca6dc 100644 (file)
@@ -1426,12 +1426,13 @@ DC390_ScsiRstDetect( PACB pACB )
 #ifdef DC390_DEBUG0
     printk("RST_DETEC");
 #endif
-    save_flags(flags);
-    sti();
-    wlval = jiffies + HZ;
-    while( jiffies < wlval );   /* delay 1 sec */
 
+    /* delay a second */
+    { unsigned int msec = 1*1000; while (--msec) udelay(1000); }
+
+    save_flags(flags);
     cli();
+
     ioport = pACB->IOPortBase;
     bval = DMA_IDLE_CMD;
     outb(bval,ioport+DMA_Cmd);
index 2cd06a2d901f51fcb3696406853383f6bdfd0543..130e6a233c9d0a75c2e2f8190c0cb2dadbd9d74f 100644 (file)
@@ -649,8 +649,6 @@ static void seagate_reconnect_intr (int irq, void *dev_id,
   int temp;
   Scsi_Cmnd *SCtmp;
 
-/* enable all other interrupts. */
-  sti ();
 #if (DEBUG & PHASE_RESELECT)
   printk ("scsi%d : seagate_reconnect_intr() called\n", hostno);
 #endif
@@ -1015,11 +1013,14 @@ static int internal_command (unsigned char target, unsigned char lun,
  */
 
 #if defined(ARBITRATE)
+      { unsigned long flags;
+      save_flags (flags);
       cli ();
       WRITE_CONTROL (0);
       WRITE_DATA ((controller_type == SEAGATE) ? 0x80 : 0x40);
       WRITE_CONTROL (CMD_START_ARB);
-      sti ();
+      restore_flags (flags);
+      }
       while (!((status_read = STATUS) & (STAT_ARB_CMPL | STAT_SEL)) &&
              (jiffies < clock) && !st0x_aborted) ;
 
@@ -1054,19 +1055,25 @@ static int internal_command (unsigned char target, unsigned char lun,
  */
 #ifdef OLDCNTDATASCEME
 #ifdef SWAPCNTDATA
+      { unsigned long flags;
+        save_flags(flags);
        cli();
       WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL |
                      (reselect ? CMD_ATTN : 0));
       WRITE_DATA ((unsigned char) ((1 << target) |
                                (controller_type == SEAGATE ? 0x80 : 0x40)));
-       sti();
+       restore_flags(flags);
+      }
 #else
+      { unsigned long flags;
+      save_flags(flags);
       cli ();
       WRITE_DATA ((unsigned char) ((1 << target) |
                                (controller_type == SEAGATE ? 0x80 : 0x40)));
       WRITE_CONTROL (BASE_CMD | CMD_DRVR_ENABLE | CMD_SEL |
                      (reselect ? CMD_ATTN : 0));
-      sti ();
+      restore_flags (flags);
+      }
 #endif
 #else
        tmp_data = (unsigned char) ((1 << target) | (controller_type == SEAGATE 
index 6263e22586e2d8b4b0753c08175725390357dbae..19380be6f573a3dc1094b3e93462358bb7d603c6 100644 (file)
@@ -629,10 +629,8 @@ static int board_inquiry(unsigned int j) {
    /* Issue OGM interrupt */
    outb(CMD_OGM_INTR, sh[j]->io_port + REG_LCL_INTR);
 
-   sti();
-   time = jiffies;
-   while ((jiffies - time) < HZ && limit++ < 20000) udelay(100L);
-   cli();
+   /* Wait a second.. */
+   { unsigned int msec = 1000; while (--msec) udelay(1000); }
 
    if (cpp->adapter_status || HD(j)->cp_stat[0] != FREE) {
       HD(j)->cp_stat[0] = FREE;
@@ -1233,10 +1231,10 @@ int u14_34f_reset(Scsi_Cmnd *SCarg, unsigned int reset_flags) {
 #endif
 
    HD(j)->in_reset = TRUE;
-   sti();
-   time = jiffies;
-   while ((jiffies - time) < (10 * HZ) && limit++ < 200000) udelay(100L);
-   cli();
+
+   /* Wait 2 seconds ???!!! */
+   { unsigned int msec = 2*1000; while (--msec) udelay(1000); }
+
    printk("%s: reset, interrupts disabled, loops %d.\n", BN(j), limit);
 
    for (i = 0; i < sh[j]->can_queue; i++) {
index 9596aa7f8026b675702161897e963cdf58a52cce..bd909ef8992e9e200ed6337a45ea13a603f504f8 100644 (file)
@@ -1766,9 +1766,12 @@ char buf[32];
 #endif
 
 
-   cli();
-   reset_wd33c93(instance);
-   sti();
+   { unsigned long flags;
+     save_flags(flags);
+     cli();
+     reset_wd33c93(instance);
+     restore_flags(flags);
+   }
 
    printk("wd33c93-%d: chip=%s/%d no_sync=0x%x no_dma=%d",instance->host_no,
          (hostdata->chip==C_WD33C93)?"WD33c93":
index 89947e8a11d8da3151ce437902b3cce48b53efe5..f0633356c9ec508bbfc9348adee0f884b95de020 100644 (file)
@@ -851,18 +851,18 @@ static inline Scb *alloc_scbs (int needed)
     save_flags (flags);
     cli ();
     while (busy) {             /* someone else is allocating */
-       sti ();                 /* Yes this is really needed here */
+       spin_unlock_irq(&io_request_lock);
        for (now = jiffies; now == jiffies; );  /* wait a jiffy */
-       cli ();
+       spin_lock_irq(&io_request_lock);
     }
     busy = 1;                  /* not busy now; it's our turn */
 
     while (freescbs < needed) {
        timeout = jiffies + WAITnexttimeout;
        do {
-           sti ();             /* Yes this is really needed here */
+           spin_unlock_irq(&io_request_lock);
            for (now = jiffies; now == jiffies; );      /* wait a jiffy */
-           cli ();
+           spin_lock_irq(&io_request_lock);
        } while (freescbs < needed && jiffies <= timeout);
        /*
         *  If we get here with enough free Scbs, we can take them.
index f014932fbf14603a83c536634229b94c73557cd7..f63b43cb0796bdd453b7df25713be48c023ec23b 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/blkdev.h>
 #include <linux/sysrq.h>
 #include <linux/file.h>
+#include <linux/init.h>
 #include <linux/quotaops.h>
 
 #include <asm/system.h>
@@ -1729,7 +1730,7 @@ void show_buffers(void)
  * Use gfp() for the hash table to decrease TLB misses, use
  * SLAB cache for buffer heads.
  */
-void buffer_init(void)
+__initfunc(void buffer_init(void))
 {
        int order = 5;          /* Currently maximum order.. */
        unsigned int nr_hash;
index b5273aef1b33617b440122bfdd9f409dc7959455..40845df97092265b3fbde8ff6a97b0b44b027c79 100644 (file)
@@ -524,7 +524,11 @@ got_block:
        /*
         * Check quota for allocation of this block.
         */
-       DQUOT_ALLOC_BLOCK(sb, inode, 1);
+       if(DQUOT_ALLOC_BLOCK(sb, inode, 1)) {
+               unlock_super(sb);
+               *err = -EDQUOT;
+               return 0;
+       }
 
        tmp = j + i * EXT2_BLOCKS_PER_GROUP(sb) + le32_to_cpu(es->s_first_data_block);
 
@@ -560,7 +564,8 @@ got_block:
                for (k = 1;
                     k < prealloc_goal && (j + k) < EXT2_BLOCKS_PER_GROUP(sb);
                     k++) {
-                       DQUOT_PREALLOC_BLOCK(sb, inode, 1);
+                       if (DQUOT_PREALLOC_BLOCK(sb, inode, 1))
+                               break;
                        if (ext2_set_bit (j + k, bh->b_data)) {
                                DQUOT_FREE_BLOCK(sb, inode, 1);
                                break;
index 4859c8e4032989622ace1eb20547ccd9f7d2304f..2e3cbbc0c48ab462b86755bb03a34a2bac856db9 100644 (file)
@@ -405,7 +405,7 @@ repeat:
                return NULL;
        }
        bitmap_nr = load_inode_bitmap (sb, i);
-               if (bitmap_nr < 0) {
+       if (bitmap_nr < 0) {
                unlock_super (sb);
                iput(inode);
                *err = -EIO;
@@ -493,7 +493,13 @@ repeat:
        inc_inode_version (inode, gdp, mode);
 
        unlock_super (sb);
-       DQUOT_ALLOC_INODE(sb, inode);
+       if(DQUOT_ALLOC_INODE(sb, inode)) {
+               sb->dq_op->drop(inode);
+               inode->i_nlink = 0;
+               iput(inode);
+               *err = -EDQUOT;
+               return NULL;
+       }
        ext2_debug ("allocating inode %lu\n", inode->i_ino);
 
        *err = 0;
index 7aec9d62db35b10de5a126cf64753c5a92802217..1674c7389ec7fc4b467e25766f744990dd6e620a 100644 (file)
 extern int init_coda_fs(void);
 #endif
 
+#ifdef CONFIG_DEVPTS_FS
+extern int init_devpts_fs(void);
+#endif
+
 extern void device_setup(void);
 extern void binfmt_setup(void);
 extern void free_initmem(void);
index 4b7d3a31aac34aa608d54af82c83f88b335b0f42..dfb2a76d90da92df7381c80b346ff4496928aec4 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -552,7 +552,7 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
                newattrs.ia_mode &= ~S_ISGID;
                newattrs.ia_valid |= ATTR_MODE;
        }
-       DQUOT_TRANSFER(dentry, newattrs);
+       error = DQUOT_TRANSFER(dentry, &newattrs);
 out:
        return error;
 }
index 673cd9d654712c5544a637b1717201d2a68c4afe..edb850a402bef08bafae50f3eb38b13b5963e038 100644 (file)
  */
 static struct semaphore mount_sem = MUTEX;
 
+#ifdef CONFIG_BSD_PROCESS_ACCT
+extern void acct_auto_close(kdev_t);
+#endif
+
 extern void wait_for_keypress(void);
 extern struct file_operations * get_blkfops(unsigned int major);
 
index 976320d75ff5096936abaad6aa9e1ff3c6d11598..3d0b299fced873cde7ba07520c9a4cf02d67fc91 100644 (file)
@@ -1,14 +1,13 @@
 #ifndef _I386_CURRENT_H
 #define _I386_CURRENT_H
 
-static inline unsigned long get_esp(void)
+static inline struct task_struct * get_current(void)
 {
-       unsigned long esp;
-       __asm__("movl %%esp,%0":"=r" (esp));
-       return esp;
-}
-
-#define current ((struct task_struct *)(get_esp() & ~8191UL))
-
+       struct task_struct *current;
+       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
+       return current;
+ }
+#define current get_current()
 
 #endif /* !(_I386_CURRENT_H) */
index b840952a544127d9a5af3c000425265dfcf6e814..88728512af1becb34e300b1d73a0029348d995c3 100644 (file)
@@ -2,6 +2,8 @@
  * include/asm-ppc/serial.h
  */
 
+#include <linux/config.h>
+
 /*
  * This assumes you have a 1.8432 MHz clock for your UART.
  *
index a0342601f2f84e42cf53d32c036cf330dbc5e531..3f5260c02af89033e05e3ae4e81910e979d9c275 100644 (file)
@@ -305,7 +305,7 @@ static inline kernel_cap_t cap_invert(kernel_cap_t c)
 #define cap_set_full(c)      do { (c).cap = ~0; } while(0)
 #define cap_mask(c,mask)     do { (c).cap &= (mask).cap; } while(0)
 
-#define cap_is_fs_cap(c)     ((c) & CAP_FS_MASK)
+#define cap_is_fs_cap(c)     (CAP_TO_MASK(c) & CAP_FS_MASK)
 
 #endif /* __KERNEL__ */
 
index 3e9791a80c3de13d7964e72811dfd1957ca2ea7d..df6af1ef05270a7c05008b273144bd9dcf574493 100644 (file)
@@ -40,8 +40,8 @@ struct poll_table_struct;
 #define NR_OPEN 1024
 
 #define NR_SUPER 64
-#define BLOCK_SIZE 1024
 #define BLOCK_SIZE_BITS 10
+#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
 
 /* And dynamically-tunable limits and defaults: */
 extern int max_inodes;
index 2a3f1f8ba13dab8eff3801befa044abc08d2a54d..513801cbe647185d3ac0db2f4efee41dd2f3b812 100644 (file)
@@ -2,9 +2,9 @@
 #define _LINUX_JOYSTICK_H
 
 /*
- *  $Id: joystick.h,v 1.3 1998/03/30 11:10:40 mj Exp $
+ * /usr/include/linux/joystick.h  Version 1.0.9
  *
- *  Copyright (C) 1997, 1998 Vojtech Pavlik
+ * Copyright (C) 1996-1998 Vojtech Pavlik
  */
 
 #include <asm/types.h>
  * Version
  */
 
-#define JS_VERSION             0x00010007L             /* 1.0.7 BCD */
+#define JS_VERSION             0x00010008L
 
 /*
  * IOCTL commands for joystick driver
  */
 
-#define JSIOCGVERSION          _IOR('j', 0x01, __u32)                          /* get driver version */
+#define JSIOCGVERSION          _IOR('j', 0x01, __u32)                  /* get driver version */
 
-#define JSIOCGAXES             _IOR('j', 0x11, __u8)                           /* get number of axes */
-#define JSIOCGBUTTONS          _IOR('j', 0x12, __u8)                           /* get number of buttons */
+#define JSIOCGAXES             _IOR('j', 0x11, __u8)                   /* get number of axes */
+#define JSIOCGBUTTONS          _IOR('j', 0x12, __u8)                   /* get number of buttons */
 
-#define JSIOCSCORR             _IOW('j', 0x21, struct js_corr[4])              /* set correction values */
-#define JSIOCGCORR             _IOR('j', 0x22, struct js_corr[4])              /* get correction values */
+#define JSIOCSCORR             _IOW('j', 0x21, struct js_corr[4])      /* set correction values */
+#define JSIOCGCORR             _IOR('j', 0x22, struct js_corr[4])      /* get correction values */
 
 /*
  * Types and constants for get/set correction
  */
 
-#define JS_CORR_NONE           0x00            /* returns raw values */
-#define JS_CORR_BROKEN         0x01            /* broken line */
+#define JS_CORR_NONE           0x00    /* returns raw values */
+#define JS_CORR_BROKEN         0x01    /* broken line */
 
 struct js_corr {
        __s32 coef[8];
@@ -46,13 +46,13 @@ struct js_corr {
 
 #define JS_EVENT_BUTTON                0x01    /* button pressed/released */
 #define JS_EVENT_AXIS          0x02    /* joystick moved */
-#define JS_EVENT_INIT          0x80    /* initial state of device */
+#define JS_EVENT_INIT          0x80    /* initial state of device at open time */
 
 struct js_event {
-        __u32 time;            /* time when event happened in miliseconds since open */
-        __u16 value;           /* new value */
-        __u8  type;            /* type of event, see above */
-        __u8  number;          /* axis/button number */
+       __u32 time;     /* event timestamp in miliseconds since open */
+       __s16 value;    /* value */
+       __u8  type;     /* type of event, see above */
+       __u8  number;   /* axis/button number */
 };
 
 /*
@@ -62,16 +62,16 @@ struct js_event {
 #define JS_RETURN      sizeof(struct JS_DATA_TYPE)
 #define JS_TRUE        1
 #define JS_FALSE       0
-#define JS_X_0         0x01            /* bit mask for x-axis js0 */
-#define JS_Y_0         0x02            /* bit mask for y-axis js0 */
-#define JS_X_1         0x04            /* bit mask for x-axis js1 */
-#define JS_Y_1         0x08            /* bit mask for y-axis js1 */
-#define JS_MAX                 2               /* max number of joysticks */
+#define JS_X_0         0x01    /* bit mask for x-axis js0 */
+#define JS_Y_0         0x02    /* bit mask for y-axis js0 */
+#define JS_X_1         0x04    /* bit mask for x-axis js1 */
+#define JS_Y_1         0x08    /* bit mask for y-axis js1 */
+#define JS_MAX                 2       /* max number of joysticks */
 
 struct JS_DATA_TYPE {
-       int buttons;            /* immediate button state */
-       int x;                  /* immediate x axis value */
-       int y;                  /* immediate y axis value */
+       int buttons;    /* immediate button state */
+       int x;          /* immediate x axis value */
+       int y;          /* immediate y axis value */
 };
 
 
index 99a16486e1e1353a1172192577f9238e926e09d5..1ebe3e3dd216a68b297216c3490d596de546a200 100644 (file)
@@ -37,108 +37,104 @@ extern int  dquot_transfer(struct inode *inode, struct iattr *iattr,
 /*
  * Operations supported for diskquotas.
  */
-#define DQUOT_INIT(inode) \
-if (inode->i_sb && inode->i_sb->dq_op) { \
-       inode->i_sb->dq_op->initialize(inode, -1); \
+extern __inline__ void DQUOT_INIT(struct inode *inode)
+{
+       if (inode->i_sb && inode->i_sb->dq_op)
+               inode->i_sb->dq_op->initialize(inode, -1);
 }
 
-#define DQUOT_DROP(inode) \
-if (IS_QUOTAINIT(inode)) { \
-       if (inode->i_sb && inode->i_sb->dq_op) \
-               inode->i_sb->dq_op->drop(inode); \
+extern __inline__ void DQUOT_DROP(struct inode *inode)
+{
+       if (IS_QUOTAINIT(inode)) {
+               if (inode->i_sb && inode->i_sb->dq_op)
+                       inode->i_sb->dq_op->drop(inode);
+       }
 }
 
-#define DQUOT_SAVE_DROP(inode) \
-if (IS_QUOTAINIT(inode)) { \
-       inode->i_lock = 1; \
-       if (inode->i_sb && inode->i_sb->dq_op) \
-               inode->i_sb->dq_op->drop(inode); \
-       unlock_inode(inode); \
-       goto we_slept; \
+extern __inline__ int DQUOT_PREALLOC_BLOCK(struct super_block *sb, struct inode *inode, int nr)
+{
+       if (sb->dq_op) {
+               if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize),
+                                          current->euid, 0) == NO_QUOTA)
+                       return 1;
+       }
+       return 0;
 }
 
-#define DQUOT_PREALLOC_BLOCK(sb, inode, nr) \
-if (sb->dq_op) { \
-       if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize), \
-                                  current->euid, 0) == NO_QUOTA) \
-               break; \
+extern __inline__ int DQUOT_ALLOC_BLOCK(struct super_block *sb, struct inode *inode, int nr)
+{
+       if (sb->dq_op) {
+               if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize),
+                                          current->euid, 1) == NO_QUOTA)
+                       return 1;
+       }
+       return 0;
 }
 
-#define DQUOT_ALLOC_BLOCK(sb, inode, nr) \
-if (sb->dq_op) { \
-       if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize), \
-                                  current->euid, 1) == NO_QUOTA) { \
-               unlock_super (sb); \
-               *err = -EDQUOT; \
-               return 0; \
-       } \
+extern __inline__ int DQUOT_ALLOC_INODE(struct super_block *sb, struct inode *inode)
+{
+       if (sb->dq_op) {
+               sb->dq_op->initialize (inode, -1);
+               if (sb->dq_op->alloc_inode (inode, 1, current->euid))
+                       return 1;
+       }
+       inode->i_flags |= S_QUOTA;
+       return 0;
 }
 
-#define DQUOT_ALLOC_INODE(sb, inode) \
-if (sb->dq_op) { \
-       sb->dq_op->initialize (inode, -1); \
-       if (sb->dq_op->alloc_inode (inode, 1, current->euid)) { \
-               sb->dq_op->drop (inode); \
-               inode->i_nlink = 0; \
-               iput (inode); \
-               *err = -EDQUOT; \
-               return NULL; \
-       } \
-       inode->i_flags |= S_QUOTA; \
+extern __inline__ void DQUOT_FREE_BLOCK(struct super_block *sb, struct inode *inode, int nr)
+{
+       if (sb->dq_op)
+               sb->dq_op->free_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize));
 }
 
-#define DQUOT_FREE_BLOCK(sb, inode, nr) \
-if (sb->dq_op) { \
-       sb->dq_op->free_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize)); \
+extern __inline__ void DQUOT_FREE_INODE(struct super_block *sb, struct inode *inode)
+{
+       if (sb->dq_op)
+               sb->dq_op->free_inode(inode, 1);
 }
 
-#define DQUOT_FREE_INODE(sb, inode) \
-if (sb->dq_op) { \
-       sb->dq_op->free_inode(inode, 1); \
+extern __inline__ int DQUOT_TRANSFER(struct dentry *dentry, struct iattr *iattr)
+{
+       int error = -EDQUOT;
+
+       if (dentry->d_inode->i_sb->dq_op) {
+               if (IS_QUOTAINIT(dentry->d_inode) == 0)
+                       dentry->d_inode->i_sb->dq_op->initialize(dentry->d_inode, -1);
+               if (dentry->d_inode->i_sb->dq_op->transfer(dentry->d_inode, iattr, 0, current->euid))
+                       goto out;
+               error = notify_change(dentry, iattr);
+               if (error)
+                       dentry->d_inode->i_sb->dq_op->transfer(dentry->d_inode, iattr, 1, current->euid);
+       } else {
+               error = notify_change(dentry, iattr);
+       }
+out:
+       return error;
 }
 
-#define DQUOT_TRANSFER(dentry, iattr) \
-if (dentry->d_inode->i_sb->dq_op) { \
-       if (IS_QUOTAINIT(dentry->d_inode) == 0) \
-               dentry->d_inode->i_sb->dq_op->initialize(dentry->d_inode, -1); \
-       if (dentry->d_inode->i_sb->dq_op->transfer(dentry->d_inode, &iattr, 0, current->euid)) { \
-               error = -EDQUOT; \
-               goto out; \
-       } \
-       error = notify_change(dentry, &iattr); \
-       if (error) \
-               inode->i_sb->dq_op->transfer(dentry->d_inode, &iattr, 1, current->euid); \
-} else { \
-       error = notify_change(dentry, &iattr); \
-}
-
-#define DQUOT_SYNC(dev) \
-sync_dquots(dev, -1)
-
-#define DQUOT_OFF(dev) \
-quota_off(dev, -1)
+#define DQUOT_SYNC(dev)        sync_dquots(dev, -1)
+#define DQUOT_OFF(dev) quota_off(dev, -1)
 
 #else
 
 /*
  * NO-OP when quota not configured.
  */
-#define DQUOT_INIT(inode)
-#define DQUOT_DROP(inode)
-#define DQUOT_SAVE_DROP(inode)
-#define DQUOT_PREALLOC_BLOCK(sb, inode, nr)
-#define DQUOT_ALLOC_BLOCK(sb, inode, nr)
-#define DQUOT_ALLOC_INODE(sb, inode)
-#define DQUOT_FREE_BLOCK(sb, inode, nr)
-#define DQUOT_FREE_INODE(sb, inode)
-#define DQUOT_SYNC(dev)
-#define DQUOT_OFF(dev)
+#define DQUOT_INIT(inode)                      do { } while(0)
+#define DQUOT_DROP(inode)                      do { } while(0)
+#define DQUOT_PREALLOC_BLOCK(sb, inode, nr)    (0)
+#define DQUOT_ALLOC_BLOCK(sb, inode, nr)       (0)
+#define DQUOT_ALLOC_INODE(sb, inode)           (0)
+#define DQUOT_FREE_BLOCK(sb, inode, nr)                do { } while(0)
+#define DQUOT_FREE_INODE(sb, inode)            do { } while(0)
+#define DQUOT_SYNC(dev)                                do { } while(0)
+#define DQUOT_OFF(dev)                         do { } while(0)
 
 /*
  * Special case expands to a simple notify_change.
  */
-#define DQUOT_TRANSFER(dentry, iattr) \
-error = notify_change(dentry, &iattr)
+#define DQUOT_TRANSFER(dentry, iattr) notify_change(dentry, iattr)
 
 #endif /* CONFIG_QUOTA */
 #endif /* _LINUX_QUOTAOPS_ */
index f9ca4c1eddd2bfc19ca0d04aa59c2b179b545e89..eb0d8ac2dfaad08abe19a3800d44ca4aad38b973 100644 (file)
@@ -4,7 +4,6 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
index 16889cdbb686f636330a6b3a3e2c04150d429ddf..b8890647e7bc9019d31b583770f6b5bd1a9c2fb1 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/hippidevice.h>
 #include <linux/skbuff.h>
 #include <linux/errno.h>
-#include <linux/config.h>
 #include <net/arp.h>
 #include <net/sock.h>
 #include <asm/checksum.h>