diff -Nru a/CREDITS b/CREDITS
--- a/CREDITS	Fri May 24 18:55:34 2002
+++ b/CREDITS	Fri May 24 18:55:34 2002
@@ -1705,6 +1705,11 @@
 S: D-91080 Uttenreuth
 S: Germany
 
+N: Gabor Kuti
+M: seasons@falcon.sch.bme.hu
+M: seasons@makosteszta.sote.hu
+D: Software suspend
+
 N: Jaroslav Kysela
 E: perex@suse.cz
 W: http://www.perex.cz
diff -Nru a/Documentation/DMA-mapping.txt b/Documentation/DMA-mapping.txt
--- a/Documentation/DMA-mapping.txt	Fri May 24 18:55:36 2002
+++ b/Documentation/DMA-mapping.txt	Fri May 24 18:55:36 2002
@@ -484,7 +484,7 @@
 of sg entries it mapped them to.
 
 Then you should loop count times (note: this can be less than nents times)
-and use sg_dma_address() and sg_dma_length() macros where you previously
+and use sg_dma_address() and sg_dma_len() macros where you previously
 accessed sg->address and sg->length as shown above.
 
 To unmap a scatterlist, just call:
diff -Nru a/Documentation/DocBook/procfs_example.c b/Documentation/DocBook/procfs_example.c
--- a/Documentation/DocBook/procfs_example.c	Fri May 24 18:55:36 2002
+++ b/Documentation/DocBook/procfs_example.c	Fri May 24 18:55:36 2002
@@ -47,7 +47,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <asm/uaccess.h>
 
 
@@ -245,5 +245,3 @@
 
 MODULE_AUTHOR("Erik Mouw");
 MODULE_DESCRIPTION("procfs examples");
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/Documentation/driver-model.txt b/Documentation/driver-model.txt
--- a/Documentation/driver-model.txt	Fri May 24 18:55:34 2002
+++ b/Documentation/driver-model.txt	Fri May 24 18:55:34 2002
@@ -52,7 +52,8 @@
 Each bus layer should implement the callbacks for these drivers. It then
 forwards the calls on to the device-specific callbacks. This means that
 device-specific drivers must still implement callbacks for each operation.
-But, they are not called from the top level driver layer.
+But, they are not called from the top level driver layer. [So for example
+PCI devices will not call device_register but pci_device_register.]
 
 This does add another layer of indirection for calling one of these functions,
 but there are benefits that are believed to outweigh this slowdown.
@@ -60,7 +61,7 @@
 First, it prevents device-specific drivers from having to know about the
 global device layer. This speeds up integration time incredibly. It also
 allows drivers to be more portable across kernel versions. Note that the
-former was intentional, the latter is an added bonus.
+former was intentional, the latter is an added bonus. 
 
 Second, this added indirection allows the bus to perform any additional logic
 necessary for its child devices. A bus layer may add additional information to
@@ -225,7 +226,6 @@
 	It also allows the platform driver (e.g. ACPI) to a driver without the driver
 	having to have explicit knowledge of (atrocities like) ACPI.
 
-
 current_state:
 	Current power state of the device. For PCI and other modern devices, this is
 	0-3, though it's not necessarily limited to those values.
@@ -251,18 +251,24 @@
 }
 
 probe:
-	Check for device existence and associate driver with it.
+	Check for device existence and associate driver with it. In case of device 
+	insertion, *all* drivers are called. Struct device has parent and bus_id 
+	valid at this point. probe() may only be called from process context. Returns
+	0 if it handles that device, -ESRCH if this driver does not know how to handle
+	this device, valid error otherwise.
 
 remove:
 	Dissociate driver with device. Releases device so that it could be used by
 	another driver. Also, if it is a hotplug device (hotplug PCI, Cardbus), an
-	ejection event could take place here.
+	ejection event could take place here. remove() can be called from interrupt 
+	context. [Fixme: Is that good?] Returns 0 on success. [Can we recover from
+	failed remove or should I define that remove() never fails?]
 
 suspend:
-	Perform one step of the device suspend process.
+	Perform one step of the device suspend process. Returns 0 on success.
 
 resume:
-	Perform one step of the device resume process.
+	Perform one step of the device resume process. Returns 0 on success.
 
 The probe() and remove() callbacks are intended to be much simpler than the
 current PCI correspondents.
@@ -275,7 +281,7 @@
 
 Some device initialisation was done in probe(). This should not be the case
 anymore. All initialisation should take place in the open() call for the
-device.
+device. [FIXME: How do you "open" uhci?]
 
 Breaking initialisation code out must also be done for the resume() callback,
 as most devices will have to be completely reinitialised when coming back from
@@ -324,6 +330,7 @@
 
 enum{
 	SUSPEND_NOTIFY,
+	SUSPEND_DISABLE,
 	SUSPEND_SAVE_STATE,
 	SUSPEND_POWER_DOWN,
 };
@@ -331,6 +338,7 @@
 enum {
 	RESUME_POWER_ON,
 	RESUME_RESTORE_STATE,
+	RESUME_ENABLE,
 };
 
 
@@ -352,9 +360,9 @@
 Instead, the walking of the device tree has been moved to userspace. When a
 user requests the system to suspend, it will walk the device tree, as exported
 via driverfs, and tell each device to go to sleep. It will do this multiple
-times based on what the system policy is.
-
-[ FIXME: URL pointer to the corresponding utility is missing here! ]
+times based on what the system policy is. [Not possible. Take ACPI enabled 
+system, with battery critically low. In such state, you want to suspend-to-disk,
+*fast*. User maybe is not even running powerd (think system startup)!]
 
 Device resume should happen in the same manner when the system awakens.
 
@@ -366,22 +374,25 @@
 cannot resume the hardware from the requested level, or it feels that it is
 too important to be put to sleep, it should return an error from this function.
 
-It does not have to stop I/O requests or actually save state at this point.
+It does not have to stop I/O requests or actually save state at this point. Called
+from process context.
 
 SUSPEND_DISABLE:
 
 The driver should stop taking I/O requests at this stage. Because the save
 state stage happens afterwards, the driver may not want to physically disable
-the device; only mark itself unavailable if possible.
+the device; only mark itself unavailable if possible. Called from process 
+context.
 
 SUSPEND_SAVE_STATE:
 
 The driver should allocate memory and save any device state that is relevant
-for the state it is going to enter.
+for the state it is going to enter. Called from process context.
 
 SUSPEND_POWER_DOWN:
 
-The driver should place the device in the power state requested.
+The driver should place the device in the power state requested. May be called
+from interrupt context.
 
 
 For resume, the stages are defined as follows:
@@ -389,25 +400,27 @@
 RESUME_POWER_ON:
 
 Devices should be powered on and reinitialised to some known working state.
+Called from process context.
 
 RESUME_RESTORE_STATE:
 
 The driver should restore device state to its pre-suspend state and free any
-memory allocated for its saved state.
+memory allocated for its saved state. Called from process context.
 
 RESUME_ENABLE:
 
-The device should start taking I/O requests again.
+The device should start taking I/O requests again. Called from process context.
 
 
 Each driver does not have to implement each stage. But, it if it does
-implemente a stage, it should do what is described above. It should not assume
+implement a stage, it should do what is described above. It should not assume
 that it performed any stage previously, or that it will perform any stage
-later.
+later. [Really? It makes sense to support SAVE_STATE only after DISABLE].
 
 It is quite possible that a driver can fail during the suspend process, for
 whatever reason. In this event, the calling process must gracefully recover
-and restore everything to their states before the suspend transition began.
+and restore everything to their states before the suspend transition began. 
+[Suspend may not fail, think battery low.]
 
 If a driver knows that it cannot suspend or resume properly, it should fail
 during the notify stage. Properly implemented power management schemes should
diff -Nru a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
--- a/Documentation/filesystems/Locking	Fri May 24 18:55:35 2002
+++ b/Documentation/filesystems/Locking	Fri May 24 18:55:35 2002
@@ -42,9 +42,8 @@
 	int (*follow_link) (struct dentry *, struct nameidata *);
 	void (*truncate) (struct inode *);
 	int (*permission) (struct inode *, int);
-	int (*revalidate) (struct dentry *);
 	int (*setattr) (struct dentry *, struct iattr *);
-	int (*getattr) (struct dentry *, struct iattr *);
+	int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *);
 	int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
@@ -67,8 +66,7 @@
 truncate:	no	yes		(see below)
 setattr:	no	yes
 permission:	yes	no
-getattr:				(see below)
-revalidate:	no			(see below)
+getattr:	no	no
 setxattr:	no	yes
 getxattr:	no	yes
 listxattr:	no	yes
@@ -76,14 +74,11 @@
 	Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_sem on
 victim.
 	cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
-	->revalidate(), it may be called both with and without the i_sem
-on dentry->d_inode.
 	->truncate() is never called directly - it's a callback, not a
 method. It's called by vmtruncate() - library function normally used by
 ->setattr(). Locking information above applies to that call (i.e. is
 inherited from ->setattr() - vmtruncate() is used when ATTR_SIZE had been
 passed).
-	->getattr() is currently unused.
 
 See Documentation/filesystems/directory-locking for more detailed discussion
 of the locking scheme for directory operations.
diff -Nru a/Documentation/filesystems/porting b/Documentation/filesystems/porting
--- a/Documentation/filesystems/porting	Fri May 24 18:55:34 2002
+++ b/Documentation/filesystems/porting	Fri May 24 18:55:34 2002
@@ -187,3 +187,31 @@
                unlock_new_inode(inode);
        }
 
+---
+[recommended]
+
+->getattr() finally getting used.  See instances in nfs, minix, etc.
+
+---
+[mandatory]
+
+->revalidate() is gone.  If your filesystem had it - provide ->getattr()
+and let it call whatever you had as ->revlidate() + (for symlinks that
+had ->revalidate()) add calls in ->follow_link()/->readlink().
+
+---
+[mandatory]
+
+->d_parent changes are not protected by BKL anymore.  Read access is safe
+if at least one of the following is true:
+	* filesystem has no cross-directory rename()
+	* dcache_lock is held
+	* dparent_lock is held (shared)
+	* we know that parent had been locked (e.g. we are looking at
+->d_parent of ->lookup() argument).
+	* we are called from ->rename().
+Audit your code and add locking if needed.  Notice that any place that is
+not protected by the conditions above is risky even in the old tree - you
+had been relying on BKL and that's prone to screwups.  Old tree had quite
+a few holes of that kind - unprotected access to ->d_parent leading to
+anything from oops to silent memory corruption.
diff -Nru a/Documentation/ide.txt b/Documentation/ide.txt
--- a/Documentation/ide.txt	Fri May 24 18:55:33 2002
+++ b/Documentation/ide.txt	Fri May 24 18:55:33 2002
@@ -37,9 +37,27 @@
 ***
 ***  Use of the "serialize" option is no longer necessary.
 
-This is the multiple IDE interface driver, as evolved from hd.c.  It supports
-up to 9 IDE interfaces per default, on one or more IRQs (usually 14 & 15).
-There can be up to two drives per interface, as per the ATA-6 spec.
+================================================================================
+Common pitfalls:
+
+- 40-conductor IDE cables are capable of transfering data in DMA modes up to
+  udma2, but no faster.
+
+- If possible devices should be attached to separate channels if they are
+  available. Typically the disk on the first and CD-ROM on the second.
+
+- If you mix devices on the same cable, please consider using similar devices
+  in respect of the data transfer mode they support.
+
+- Even better tru to stick to the same vendor and device type on the same
+  cable.
+
+================================================================================
+
+This is the multiple IDE interface driver, as evolved from hd.c.  
+
+It supports up to 9 IDE interfaces per default, on one or more IRQs (usually
+14 & 15).  There can be up to two drives per interface, as per the ATA-6 spec.
 
 Primary:    ide0, port 0x1f0; major=3;  hda is minor=0; hdb is minor=64
 Secondary:  ide1, port 0x170; major=22; hdc is minor=0; hdd is minor=64
diff -Nru a/Documentation/preempt-locking.txt b/Documentation/preempt-locking.txt
--- a/Documentation/preempt-locking.txt	Fri May 24 18:55:33 2002
+++ b/Documentation/preempt-locking.txt	Fri May 24 18:55:33 2002
@@ -31,6 +31,8 @@
 the previous value of smp_processor_id may not equal the current.  You must
 protect these situations by disabling preemption around them.
 
+You can also use put_cpu() and get_cpu(), which will disable preemption.
+
 
 RULE #2: CPU state must be protected.
 
diff -Nru a/Documentation/swsusp.txt b/Documentation/swsusp.txt
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/swsusp.txt	Fri May 24 18:55:36 2002
@@ -0,0 +1,158 @@
+From kernel/suspend.c:
+
+ * BIG FAT WARNING *********************************************************
+ *
+ * If you have unsupported (*) devices using DMA...
+ *				...say goodbye to your data.
+ *
+ * If you touch anything on disk between suspend and resume...
+ *				...kiss your data goodbye.
+ *
+ * If your disk driver does not support suspend... (IDE does)
+ *				...you'd better find out how to get along
+ *				   without your data.
+ *
+ * (*) pm interface support is needed to make it safe.
+
+You need to append resume=/dev/your_swap_partition to kernel command
+line. Then you suspend by echo 4 > /proc/acpi/sleep.
+
+[Notice. Rest docs is pretty outdated (see date!) It should be safe to
+use swsusp on ext3/reiserfs these days.]
+
+
+Article about goals and implementation of Software Suspend for Linux
+Author: G‚ábor Kuti
+Last revised: 2002-04-08
+
+Idea and goals to achieve
+
+Nowadays it is common in several laptops that they have a suspend button. It
+saves the state of the machine to a filesystem or to a partition and switches
+to standby mode. Later resuming the machine the saved state is loaded back to
+ram and the machine can continue its work. It has two real benefits. First we
+save ourselves the time machine goes down and later boots up, energy costs
+real high when running from batteries. The other gain is that we don't have to
+interrupt our programs so processes that are calculating something for a long
+time shouldn't need to be written interruptible.
+
+On desk machines the power saving function isn't as important as it is in
+laptops but we really may benefit from the second one. Nowadays the number of
+desk machines supporting suspend function in their APM is going up but there
+are (and there will still be for a long time) machines that don't even support
+APM of any kind. On the other hand it is reported that using APM's suspend
+some irqs (e.g. ATA disk irq) is lost and it is annoying for the user until
+the Linux kernel resets the device.
+
+So I started thinking about implementing Software Suspend which doesn't need
+any APM support and - since it uses pretty near only high-level routines - is
+supposed to be architecture independent code.
+
+Using the code
+
+The code is experimental right now - testers, extra eyes are welcome. To
+compile this support into the kernel, you need CONFIG_EXPERIMENTAL, 
+and then CONFIG_SOFTWARE_SUSPEND in menu General Setup to be  enabled. It
+cannot be used as a module and I don't think it will ever be needed.
+
+You have two ways to use this code. The first one is if you've compiled in
+sysrq support then you may press Sysrq-D to request suspend. The other way
+is with a patched SysVinit (my patch is against 2.76 and available at my
+home page). You might call 'swsusp' or 'shutdown -z <time>'. Next way is to
+echo 4 > /proc/acpi/sleep.
+
+Either way it saves the state of the machine into active swaps and then
+reboots. You must explicitly specify the swap partition to resume from with ``resume=''
+kernel option. If signature is found it loads and restores saved state. If the
+option ``noresume'' is specified as a boot parameter, it skips the resuming.
+Warning! Look at section ``Things to implement'' to see what isn't yet
+implemented.  Also I strongly suggest you to list all active swaps in
+/etc/fstab. Firstly because you don't have to specify anything to resume and
+secondly if you have more than one swap area you can't decide which one has the
+'root' signature. 
+
+In the meantime while the system is suspended you should not touch any of the
+hardware!
+
+About the code
+Goals reached
+
+The code can be downloaded from
+http://falcon.sch.bme.hu/~seasons/linux/. It mainly works but there are still
+some of XXXs, TODOs, FIXMEs in the code which seem not to be too important. It
+should work all right except for the problems listed in ``Things to
+implement''. Notes about the code are really welcome.
+
+How the code works
+
+When suspending is triggered it immediately wakes up process bdflush. Bdflush
+checks whether we have anything in our run queue tq_bdflush. Since we queued up
+function do_software_suspend, it is called. Here we shrink everything including
+dcache, inodes, buffers and memory (here mainly processes are swapped out). We
+count how many pages we need to duplicate (we have to be atomical!) then we
+create an appropiate sized page directory. It will point to the original and
+the new (copied) address of the page. We get the free pages by
+__get_free_pages() but since it changes state we have to be able to track it
+later so it also flips in a bit in page's flags (a new Nosave flag). We
+duplicate pages and then mark them as used (so atomicity is ensured). After
+this we write out the image to swaps, do another sync and the machine may
+reboot. We also save registers to stack.
+
+By resuming an ``inverse'' method is executed. The image if exists is loaded,
+loadling is either triggered by ``resume='' kernel option.  We
+change our task to bdflush (it is needed because if we don't do this init does
+an oops when it is waken up later) and then pages are copied back to their
+original location. We restore registers, free previously allocated memory,
+activate memory context and task information. Here we should restore hardware
+state but even without this the machine is restored and processes are continued
+to work. I think hardware state should be restored by some list (using
+notify_chain) and probably by some userland program (run-parts?) for users'
+pleasure. Check out my patch at the same location for the sysvinit patch.
+
+WARNINGS!
+- It does not like pcmcia cards. And this is logical: pcmcia cards need cardmgr to be
+  initialized. they are not initialized during singleuser boot, but "resumed" kernel does
+  expect them to be initialized. That leads to armagedon. You should eject any pcmcia cards
+  before suspending.
+
+Things to implement
+- SMP support. I've done an SMP support but since I don't have access to a kind
+  of this one I cannot test it. Please SMP people test it.  .. Tested it,
+  doesn't work. Had no time to figure out why. There is some mess with
+  interrupts AFAIK..
+- We should only make a copy of data related to kernel segment, since any
+  process data won't be changed.
+- By copying pages back to their original position, copy_page caused General
+  Protection Fault. Why?
+- Hardware state restoring.  Now there's support for notifying via the notify
+  chain, event handlers are welcome. Some devices may have microcodes loaded
+  into them. We should have event handlers for them aswell.
+- We should support other architectures (There are really only some arch
+  related functions..)
+- We should also restore original state of swaps if the ``noresume'' kernel
+  option is specified.. Or do we need such a feature to save state for some
+  other time? Do we need some kind of ``several saved states''?  (Linux-HA
+  people?). There's been some discussion about checkpointing on linux-future.
+- Should make more sanity checks. Or are these enough?
+
+Not so important ideas for implementing
+
+- If a real time process is running then don't suspend the machine.
+- Support for power.conf file as in Solaris, autoshutdown, special
+  devicetypes support, maybe in sysctl.
+- Introduce timeout for SMP locking. But first locking ought to work :O
+- Pre-detect if we don't have enough swap space or free it instead of
+  calling panic.
+- Support for adding/removing hardware while suspended?
+- We should not free pages at the beginning so aggressively, most of them
+  go there anyway..
+- If X is active while suspending then by resuming calling svgatextmode
+  corrupts the virtual console of X.. (Maybe this has been fixed AFAIK).
+
+Any other idea you might have tell me!
+
+Contacting the author
+If you have any question or any patch that solves the above or detected
+problems please contact me at seasons@falcon.sch.bme.hu. I might delay
+answering, sorry about that.
+
diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS	Fri May 24 18:55:33 2002
+++ b/MAINTAINERS	Fri May 24 18:55:33 2002
@@ -1446,6 +1446,14 @@
 L:	linux-raid@vger.kernel.org
 S:	Maintained
 
+SOFTWARE SUSPEND:
+P:	Pavel Machek
+M:	pavel@suse.cz
+M:	pavel@ucw.cz
+L:	http://lister.fornax.hu/mailman/listinfo/swsusp
+W:	http://swsusp.sf.net/
+S:	Maintained
+
 SONIC NETWORK DRIVER
 P:	Thomas Bogendoerfer
 M:	tsbogend@alpha.franken.de
@@ -1724,6 +1732,14 @@
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
 W:	http://pegasus2.sourceforge.net/
+S:	Maintained
+
+USB SCANNER DRIVER
+P:	Brian Beattie
+M:	beattie@beattie-home.net
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+W:	http://www.beattie-home.net/linux
 S:	Maintained
 
 USB SE401 DRIVER
diff -Nru a/Makefile b/Makefile
--- a/Makefile	Fri May 24 18:55:33 2002
+++ b/Makefile	Fri May 24 18:55:33 2002
@@ -1,6 +1,6 @@
 VERSION = 2
 PATCHLEVEL = 5
-SUBLEVEL = 17
+SUBLEVEL = 18
 EXTRAVERSION =
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -37,14 +37,21 @@
 MAKEFILES	= $(TOPDIR)/.config
 GENKSYMS	= /sbin/genksyms
 DEPMOD		= /sbin/depmod
+PERL		= perl
 MODFLAGS	= -DMODULE
+CFLAGS_MODULE   = $(MODFLAGS)
+AFLAGS_MODULE   =
 CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
-PERL		= perl
+EXPORT_FLAGS    =
 
 export	VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
 	CONFIG_SHELL TOPDIR HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
-	CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS MODFLAGS PERL
+	CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL
+
+export CPPFLAGS EXPORT_FLAGS
+export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 
+export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 
 all:	do-it-all
 
@@ -92,6 +99,10 @@
 	  -fomit-frame-pointer -fno-strict-aliasing -fno-common
 AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
 
+ifdef CONFIG_MODULES
+EXPORT_FLAGS := -DEXPORT_SYMTAB
+endif
+
 INIT		=init/init.o
 CORE_FILES	=kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o
 NETWORKS	=net/network.o
@@ -113,10 +124,10 @@
 	drivers/misc/misc.o \
 	drivers/net/net.o \
 	drivers/media/media.o
-DRIVERS-$(CONFIG_NUBUS) += drivers/nubus/nubus.a
+DRIVERS-$(CONFIG_NUBUS) += drivers/nubus/built-in.o
 DRIVERS-$(CONFIG_ATM) += drivers/atm/atm.o
 DRIVERS-$(CONFIG_IDE) += drivers/ide/idedriver.o
-DRIVERS-$(CONFIG_FC4) += drivers/fc4/fc4.a
+DRIVERS-$(CONFIG_FC4) += drivers/fc4/built-in.o
 DRIVERS-$(CONFIG_SCSI) += drivers/scsi/scsidrv.o
 DRIVERS-$(CONFIG_FUSION) += drivers/message/message.o
 DRIVERS-$(CONFIG_IEEE1394) += drivers/ieee1394/ieee1394drv.o
@@ -128,16 +139,16 @@
 DRIVERS-$(CONFIG_SOUND) += sound/sound.o
 DRIVERS-$(CONFIG_MTD) += drivers/mtd/mtdlink.o
 DRIVERS-$(CONFIG_PCMCIA) += drivers/pcmcia/pcmcia.o
-DRIVERS-$(CONFIG_DIO) += drivers/dio/dio.a
+DRIVERS-$(CONFIG_DIO) += drivers/dio/built-in.o
 DRIVERS-$(CONFIG_SBUS) += drivers/sbus/sbus_all.o
 DRIVERS-$(CONFIG_ZORRO) += drivers/zorro/driver.o
 DRIVERS-$(CONFIG_ALL_PPC) += drivers/macintosh/macintosh.o
 DRIVERS-$(CONFIG_MAC) += drivers/macintosh/macintosh.o
 DRIVERS-$(CONFIG_PNP) += drivers/pnp/pnp.o
-DRIVERS-$(CONFIG_SGI_IP22) += drivers/sgi/sgi.a
+DRIVERS-$(CONFIG_SGI_IP22) += drivers/sgi/built-in.o
 DRIVERS-$(CONFIG_VT) += drivers/video/video.o
-DRIVERS-$(CONFIG_PARIDE) += drivers/block/paride/paride.a
-DRIVERS-$(CONFIG_TC) += drivers/tc/tc.a
+DRIVERS-$(CONFIG_PARIDE) += drivers/block/paride/built-in.o
+DRIVERS-$(CONFIG_TC) += drivers/tc/built-in.o
 DRIVERS-$(CONFIG_USB) += drivers/usb/usbdrv.o
 DRIVERS-$(CONFIG_INPUT) += drivers/input/inputdrv.o
 DRIVERS-$(CONFIG_GAMEPORT) += drivers/input/gameport/gamedrv.o
@@ -155,18 +166,27 @@
 
 include arch/$(ARCH)/Makefile
 
-export	CPPFLAGS CFLAGS CFLAGS_KERNEL AFLAGS AFLAGS_KERNEL
-
 export	NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
 
-# Build vmlinux / boot target
+# boot target
 # ---------------------------------------------------------------------------
 
 boot: vmlinux
 	@$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C arch/$(ARCH)/boot
 
-vmlinux: include/linux/version.h $(CONFIGURATION) linuxsubdirs
-	$(LD) $(LINKFLAGS) $(HEAD) $(INIT) \
+# Build vmlinux
+# ---------------------------------------------------------------------------
+
+#	This is a bit tricky: If we need to relink vmlinux, we want
+#	the version number incremented, which means recompile init/version.o
+#	and relink init/init.o. However, we cannot do this during the
+#       normal descending-into-subdirs phase, since at that time
+#       we cannot yet know if we will need to relink vmlinux.
+#	So we descend into init/ inside the rule for vmlinux again.
+
+vmlinux-objs := $(HEAD) $(INIT) $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS)
+
+cmd_link_vmlinux = $(LD) $(LINKFLAGS) $(HEAD) $(INIT) \
 		--start-group \
 		$(CORE_FILES) \
 		$(LIBS) \
@@ -174,10 +194,33 @@
 		$(NETWORKS) \
 		--end-group \
 		-o vmlinux
+
+#	set -e makes the rule exit immediately on error
+
+define rule_link_vmlinux
+	set -e
+	echo Generating build number
+	. scripts/mkversion > .tmpversion
+	mv -f .tmpversion .version
+	$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C init
+	echo $(cmd_link_vmlinux)
+	$(cmd_link_vmlinux)
+	echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd
 	$(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
+endef
+
+vmlinux: $(CONFIGURATION) $(vmlinux-objs) dummy
+	$(call if_changed_rule,link_vmlinux)
+
+#	The actual objects are generated when descending, make sure
+#	no implicit rule kicks in
+
+$(sort $(vmlinux-objs)): linuxsubdirs
+	@
 
 # 	Handle descending into subdirectories listed in $(SUBDIRS)
 
+.PHONY: linuxsubdirs
 linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
 
 $(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/linux/version.h include/config/MARKER
@@ -214,8 +257,6 @@
 include/config/MARKER: scripts/split-include include/linux/autoconf.h
 	scripts/split-include include/linux/autoconf.h include/config
 	@ touch include/config/MARKER
-	. scripts/mkversion > .tmpversion
-	@mv -f .tmpversion .version
 
 # Generate some files
 
@@ -255,7 +296,7 @@
 
 .PHONY: $(patsubst %, _mod_%, $(SUBDIRS))
 $(patsubst %, _mod_%, $(SUBDIRS)) : include/linux/version.h include/config/MARKER
-	@$(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(MODFLAGS)" MAKING_MODULES=1 modules
+	@$(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(CFLAGS_MODULE)" AFLAGS="$(AFLAGS) $(AFLAGS_MODULE)" modules
 
 #	Install modules
 
@@ -330,6 +371,8 @@
 	drivers/zorro/devlist.h drivers/zorro/gen-devlist \
 	sound/oss/bin2hex sound/oss/hex2hex \
 	drivers/atm/fore200e_mkfirm drivers/atm/{pca,sba}*{.bin,.bin1,.bin2} \
+	drivers/scsi/aic7xxx/aic7xxx_seq.h \
+	drivers/scsi/aic7xxx/aic7xxx_reg.h \
 	drivers/scsi/aic7xxx/aicasm/aicasm_gram.c \
 	drivers/scsi/aic7xxx/aicasm/aicasm_scan.c \
 	drivers/scsi/aic7xxx/aicasm/y.tab.h \
@@ -468,3 +511,12 @@
 
 sums:
 	find . -type f -print | sort | xargs sum > .SUMS
+
+# FIXME Should go into a make.lib or something 
+# ---------------------------------------------------------------------------
+
+if_changed_rule = $(if $(strip $? \
+		               $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
+			       $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
+	               @$(rule_$(1)))
+
diff -Nru a/Rules.make b/Rules.make
--- a/Rules.make	Fri May 24 18:55:35 2002
+++ b/Rules.make	Fri May 24 18:55:35 2002
@@ -29,30 +29,88 @@
 unexport subdir-m
 unexport subdir-n
 unexport subdir-
+unexport mod-subdirs
 
 comma	:= ,
 
-#
+# Figure out what we need to build from the various variables
+# ===========================================================================
+
 # When an object is listed to be built compiled-in and modular,
 # only build the compiled-in version
-#
+
 obj-m := $(filter-out $(obj-y),$(obj-m))
 
-#
-# Get things started.
-#
-first_rule: all_targets
+# Handle objects in subdirs
+# ---------------------------------------------------------------------------
+# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
+#   and add the directory to the list of dirs to descend into: $(subdir-y)
+# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 
+#   and add the directory to the list of dirs to descend into: $(subdir-m)
+
+__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
+subdir-y	+= $(__subdir-y)
+__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
+subdir-m	+= $(__subdir-m)
+__subdir-n	:= $(patsubst %/,%,$(filter %/, $(obj-n)))
+subdir-n	+= $(__subdir-n)
+__subdir-	:= $(patsubst %/,%,$(filter %/, $(obj-)))
+subdir-		+= $(__subdir-)
+obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
+obj-m		:= $(filter-out %/, $(obj-m))
+
+# If a dir is selected in $(subdir-y) and also mentioned in $(mod-subdirs),
+# add it to $(subdir-m)
 
 both-m          := $(filter $(mod-subdirs), $(subdir-y))
 SUB_DIRS	:= $(subdir-y)
 MOD_SUB_DIRS	:= $(sort $(subdir-m) $(both-m))
 ALL_SUB_DIRS	:= $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-))
 
+# export.o is never a composite object, since $(export-objs) has a
+# fixed meaning (== objects which EXPORT_SYMBOL())
+__obj-y = $(filter-out export.o,$(obj-y))
+__obj-m = $(filter-out export.o,$(obj-m))
+
+# if $(foo-objs) exists, foo.o is a composite object 
+__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(m:.o=-objs)), $(m))))
+__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(m:.o=-objs)), $(m))))
+
+# FIXME: Rip this out later
+# Backwards compatibility: if a composite object is listed in
+# $(list-multi), skip it here, since the Makefile will have an explicit
+# link rule for it
+
+multi-used-y := $(filter-out $(list-multi),$(__multi-used-y))
+multi-used-m := $(filter-out $(list-multi),$(__multi-used-m))
+
+# Build list of the parts of our composite objects, our composite
+# objects depend on those (obviously)
+multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)))
+multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)))
+
+# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
+# in the local directory
+subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
+
+# Replace multi-part objects by their individual parts, look at local dir only
+real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
+real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
+
+# ==========================================================================
+#
+# Get things started.
+#
+first_rule: all_targets
+
 #
 # Common rules
 #
 
-# export_flags will be set to -DEXPORT_SYMBOL for objects in $(export-objs)
+# Compile C sources (.c)
+# ---------------------------------------------------------------------------
+
+$(export-objs): export_flags := $(EXPORT_FLAGS)
 
 c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags)
 
@@ -71,11 +129,8 @@
 %.o: %.c dummy
 	$(call if_changed,cmd_cc_o_c)
 
-# Old makefiles define their own rules for compiling .S files,
-# but these standard rules are available for any Makefile that
-# wants to use them.  Our plan is to incrementally convert all
-# the Makefiles to these standard rules.  -- rmk, mec
-ifdef USE_STANDARD_AS_RULE
+# Compile assembler sources (.S)
+# ---------------------------------------------------------------------------
 
 a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
 
@@ -89,24 +144,28 @@
 %.o: %.S dummy
 	$(call if_changed,cmd_as_o_S)
 
-endif
-
-# FIXME is anybody using this rule? Why does it have EXTRA_CFLAGS?
-%.o: %.s
-	$(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
+# FIXME
 
 %.lst: %.c
 	$(CC) $(c_flags) -g -c -o $*.o $<
 	$(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
-#
-#
-#
+
+
+# If a Makefile does define neither O_TARGET nor L_TARGET,
+# use a standard O_TARGET named "built-in.o"
+
+ifndef O_TARGET
+ifndef L_TARGET
+O_TARGET := built-in.o
+endif
+endif
+
+# Build the compiled-in targets
+# ---------------------------------------------------------------------------
+
 all_targets: $(O_TARGET) $(L_TARGET) sub_dirs
 
-# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
-# in the local directory
-subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
-# Do build these objects, we need to descend into the directories
+# To build objects in subdirs, we need to descend into the directories
 $(subdir-obj-y): sub_dirs
 
 #
@@ -136,26 +195,6 @@
 # Rule to link composite objects
 #
 
-# export.o is never a composite object, since $(export-objs) has a
-# fixed meaning (== objects which EXPORT_SYMBOL())
-__obj-y = $(filter-out export.o,$(obj-y))
-__obj-m = $(filter-out export.o,$(obj-m))
-
-# if $(foo-objs) exists, foo.o is a composite object 
-__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(basename $(m))-objs), $(m))))
-__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(basename $(m))-objs), $(m))))
-
-# Backwards compatibility: if a composite object is listed in
-# $(list-multi), skip it here, since the Makefile will have an explicit
-# link rule for it
-
-multi-used-y := $(filter-out $(list-multi),$(__multi-used-y))
-multi-used-m := $(filter-out $(list-multi),$(__multi-used-m))
-
-# Build list of the parts of our composite objects, our composite
-# objects depend on those (obviously)
-multi-objs-y := $(foreach m, $(multi-used-y), $($(basename $(m))-objs))
-multi-objs-m := $(foreach m, $(multi-used-m), $($(basename $(m))-objs))
 
 cmd_link_multi = $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs),$^)
 
@@ -319,7 +358,6 @@
 ifneq "$(strip $(export-objs))" ""
 
 $(export-objs): $(TOPDIR)/include/linux/modversions.h
-$(export-objs): export_flags := -DEXPORT_SYMTAB
 
 endif
 
@@ -378,7 +416,7 @@
 # function to only execute the passed command if necessary
 
 if_changed = $(if $(strip $? \
-		          $(filter-out $($(1)),$(cmd_$@))\
-			  $(filter-out $(cmd_$@),$($(1)))),\
-	       @echo $($(1)); $($(1)); echo 'cmd_$@ := $($(1))' > .$@.cmd)
+		          $(filter-out $($(1)),$(cmd_$(@F)))\
+			  $(filter-out $(cmd_$(@F)),$($(1)))),\
+	       @echo '$($(1))' && $($(1)) && echo 'cmd_$@ := $($(1))' > $(@D)/.$(@F).cmd)
 
diff -Nru a/arch/alpha/Makefile b/arch/alpha/Makefile
--- a/arch/alpha/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/alpha/Makefile	Fri May 24 18:55:33 2002
@@ -96,7 +96,7 @@
 CORE_FILES := arch/alpha/kernel/kernel.o arch/alpha/mm/mm.o $(CORE_FILES)
 
 ifeq ($(CONFIG_MATHEMU),y)
-  CORE_FILES := $(CORE_FILES) arch/alpha/math-emu/math-emu.o
+  CORE_FILES := $(CORE_FILES) arch/alpha/math-emu/built-in.o
 endif
 
 LIBS := $(TOPDIR)/arch/alpha/lib/lib.a $(LIBS) $(TOPDIR)/arch/alpha/lib/lib.a
diff -Nru a/arch/alpha/defconfig b/arch/alpha/defconfig
--- a/arch/alpha/defconfig	Fri May 24 18:55:35 2002
+++ b/arch/alpha/defconfig	Fri May 24 18:55:35 2002
@@ -223,15 +223,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -276,7 +267,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
--- a/arch/alpha/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/alpha/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET := kernel.o
 
 EXTRA_AFLAGS := $(CFLAGS)
diff -Nru a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
--- a/arch/alpha/kernel/smp.c	Fri May 24 18:55:34 2002
+++ b/arch/alpha/kernel/smp.c	Fri May 24 18:55:34 2002
@@ -868,6 +868,8 @@
  *
  * Does not return until remote CPUs are nearly ready to execute <func>
  * or are or have executed.
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
  */
 
 int
diff -Nru a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c
--- a/arch/alpha/kernel/srm_env.c	Fri May 24 18:55:34 2002
+++ b/arch/alpha/kernel/srm_env.c	Fri May 24 18:55:34 2002
@@ -1,27 +1,20 @@
 /*
- * srm_env.c - Access to SRC environment variables through
- *             the linux procfs
+ * srm_env.c - Access to SRM environment
+ *             variables through linux' procfs
  *
- * (C)2001, Jan-Benedict Glaw <jbglaw@lug-owl.de>
+ * Copyright (C) 2001-2002 Jan-Benedict Glaw <jbglaw@lug-owl.de>
  *
  * This driver is at all a modified version of Erik Mouw's
- * ./linux/Documentation/DocBook/procfs_example.c, so: thanky
+ * ./linux/Documentation/DocBook/procfs_example.c, so: thank
  * you, Erik! He can be reached via email at
  * <J.A.K.Mouw@its.tudelft.nl>. It is based on an idea
- * provided by DEC^WCompaq's "Jumpstart" CD. They included
- * a patch like this as well. Thanks for idea!
- *
- *
- * This software has been developed while working on the LART
- * computing board (http://www.lart.tudelft.nl/). The
- * development has been sponsored by the Mobile Multi-media
- * Communications (http://www.mmc.tudelft.nl/) and Ubiquitous
- * Communications (http://www.ubicom.tudelft.nl/) projects.
+ * provided by DEC^WCompaq^WIntel's "Jumpstart" CD. They
+ * included a patch like this as well. Thanks for idea!
  *
  * This program is free software; you can redistribute
  * it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software
- * Foundation version 2.
+ * Public License version 2 as published by the Free Software
+ * Foundation.
  *
  * This program is distributed in the hope that it will be
  * useful, but WITHOUT ANY WARRANTY; without even the implied
@@ -36,6 +29,24 @@
  *
  */
 
+/*
+ * Changelog
+ * ~~~~~~~~~
+ *
+ * Wed, 22 May 2002 00:11:21 +0200
+ * 	- Fix typo on comment (SRC -> SRM)
+ * 	- Call this "Version 0.0.4"
+ *
+ * Tue,  9 Apr 2002 18:44:40 +0200
+ * 	- Implement access by variable name and additionally
+ * 	  by number. This is done by creating two subdirectories
+ * 	  where one holds all names (like the old directory
+ * 	  did) and the other holding 256 files named like "0",
+ * 	  "1" and so on.
+ * 	- Call this "Version 0.0.3"
+ *
+ */
+
 #include <linux/kernel.h>
 #include <linux/config.h>
 #include <linux/module.h>
@@ -45,15 +56,15 @@
 #include <asm/uaccess.h>
 #include <asm/machvec.h>
 
-#define DIRNAME		"srm_environment"	/* Subdir in /proc/	*/
-#define VERSION		"0.0.2"			/* Module version	*/
-#define NAME		"srm_env"		/* Module name		*/
-#define DEBUG
+#define BASE_DIR	"srm_environment"	/* Subdir in /proc/		*/
+#define NAMED_DIR	"named_variables"	/* Subdir for known variables	*/
+#define NUMBERED_DIR	"numbered_variables"	/* Subdir for all variables	*/
+#define VERSION		"0.0.4"			/* Module version		*/
+#define NAME		"srm_env"		/* Module name			*/
 
 MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
 MODULE_DESCRIPTION("Accessing Alpha SRM environment through procfs interface");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 typedef struct _srm_env {
 	char			*name;
@@ -61,8 +72,12 @@
 	struct proc_dir_entry	*proc_entry;
 } srm_env_t;
 
-static struct proc_dir_entry	*directory;
-static srm_env_t	srm_entries[] = {
+static struct proc_dir_entry	*base_dir;
+static struct proc_dir_entry	*named_dir;
+static struct proc_dir_entry	*numbered_dir;
+static char			number[256][4];
+
+static srm_env_t	srm_named_entries[] = {
 	{ "auto_action",	ENV_AUTO_ACTION		},
 	{ "boot_dev",		ENV_BOOT_DEV		},
 	{ "bootdef_dev",	ENV_BOOTDEF_DEV		},
@@ -80,10 +95,11 @@
 	{ "tty_dev",		ENV_TTY_DEV		},
 	{ NULL,			0			},
 };
+static srm_env_t	srm_numbered_entries[256];
 
-static int srm_env_read(char *page, char **start, off_t off, int count,
-		int *eof, void *data)
-{
+static int
+srm_env_read(char *page, char **start, off_t off, int count, int *eof,
+		void *data) {
 	int		nbytes;
 	unsigned long	ret;
 	srm_env_t	*entry;
@@ -108,10 +124,9 @@
 	return nbytes;
 }
 
-
-static int srm_env_write(struct file *file, const char *buffer,
-		unsigned long count, void *data)
-{
+static int
+srm_env_write(struct file *file, const char *buffer, unsigned long count,
+		void *data) {
 #define BUFLEN	512
 	int		nbytes;
 	srm_env_t	*entry;
@@ -127,8 +142,8 @@
 		MOD_DEC_USE_COUNT;
 		return -ENOMEM;
 	}
-		
-	//memcpy(aligned_buffer, buffer, nbytes)
+
+	/* memcpy(aligned_buffer, buffer, nbytes) */
 
 	if(copy_from_user(buf, buffer, count)) {
 		MOD_DEC_USE_COUNT;
@@ -150,55 +165,142 @@
 	return nbytes;
 }
 
-static void srm_env_cleanup(void)
-{
+static void
+srm_env_cleanup(void) {
 	srm_env_t	*entry;
+	unsigned long	var_num;
 
-	if(directory) {
-		entry = srm_entries;
-		while(entry->name != NULL && entry->id != 0) {
-			if(entry->proc_entry) {
-				remove_proc_entry(entry->name, directory);
-				entry->proc_entry = NULL;
+	if(base_dir) {
+		/*
+		 * Remove named entries
+		 */
+		if(named_dir) {
+			entry = srm_named_entries;
+			while(entry->name != NULL && entry->id != 0) {
+				if(entry->proc_entry) {
+					remove_proc_entry(entry->name,
+							named_dir);
+					entry->proc_entry = NULL;
+				}
+				entry++;
 			}
-			entry++;
+			remove_proc_entry(NAMED_DIR, base_dir);
 		}
-		remove_proc_entry(DIRNAME, NULL);
+
+		/*
+		 * Remove numbered entries
+		 */
+		if(numbered_dir) {
+			for(var_num = 0; var_num <= 255; var_num++) {
+				entry =	&srm_numbered_entries[var_num];
+
+				if(entry->proc_entry) {
+					remove_proc_entry(entry->name,
+							numbered_dir);
+					entry->proc_entry	= NULL;
+					entry->name		= NULL;
+				}
+			}
+			remove_proc_entry(NUMBERED_DIR, base_dir);
+		}
+
+		remove_proc_entry(BASE_DIR, NULL);
 	}
 
 	return;
 }
 
-static int __init srm_env_init(void)
-{
+static int __init
+srm_env_init(void) {
 	srm_env_t	*entry;
-	
+	unsigned long	var_num;
+
+	/*
+	 * Check system
+	 */
 	if(!alpha_using_srm) {
 		printk(KERN_INFO "%s: This Alpha system doesn't "
 				"know about SRM...\n", __FUNCTION__);
 		return -ENODEV;
 	}
 
-	directory = proc_mkdir(DIRNAME, NULL);
-	if(directory == NULL)
-		return -ENOMEM;
-	
-	directory->owner = THIS_MODULE;
-	
-	/* Now create all the nodes... */
-	entry = srm_entries;
+	/*
+	 * Init numbers
+	 */
+	for(var_num = 0; var_num <= 255; var_num++)
+		sprintf(number[var_num], "%ld", var_num);
+
+	/*
+	 * Create base directory
+	 */
+	base_dir = proc_mkdir(BASE_DIR, NULL);
+	if(base_dir == NULL) {
+		printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
+				BASE_DIR);
+		goto cleanup;
+	}
+	base_dir->owner = THIS_MODULE;
+
+	/*
+	 * Create per-name subdirectory
+	 */
+	named_dir = proc_mkdir(NAMED_DIR, base_dir);
+	if(named_dir == NULL) {
+		printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
+				BASE_DIR, NAMED_DIR);
+		goto cleanup;
+	}
+	named_dir->owner = THIS_MODULE;
+
+	/*
+	 * Create per-number subdirectory
+	 */
+	numbered_dir = proc_mkdir(NUMBERED_DIR, base_dir);
+	if(numbered_dir == NULL) {
+		printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
+				BASE_DIR, NUMBERED_DIR);
+		goto cleanup;
+
+	}
+	numbered_dir->owner = THIS_MODULE;
+
+	/*
+	 * Create all named nodes
+	 */
+	entry = srm_named_entries;
 	while(entry->name != NULL && entry->id != 0) {
-		entry->proc_entry = create_proc_entry(entry->name, 0644,
-				directory);
+		entry->proc_entry = create_proc_entry(entry->name,
+				0644, named_dir);
 		if(entry->proc_entry == NULL)
 			goto cleanup;
-		entry->proc_entry->data		= entry;
+
+		entry->proc_entry->data		= (void *)entry;
+		entry->proc_entry->owner	= THIS_MODULE;
 		entry->proc_entry->read_proc	= srm_env_read;
 		entry->proc_entry->write_proc	= srm_env_write;
-		entry->proc_entry->owner	= THIS_MODULE;
+
 		entry++;
 	}
-	
+
+	/*
+	 * Create all numbered nodes
+	 */
+	for(var_num = 0; var_num <= 255; var_num++) {
+		entry = &srm_numbered_entries[var_num];
+		entry->name = number[var_num];
+
+		entry->proc_entry = create_proc_entry(entry->name,
+				0644, numbered_dir);
+		if(entry->proc_entry == NULL)
+			goto cleanup;
+
+		entry->id			= var_num;
+		entry->proc_entry->data		= (void *)entry;
+		entry->proc_entry->owner	= THIS_MODULE;
+		entry->proc_entry->read_proc	= srm_env_read;
+		entry->proc_entry->write_proc	= srm_env_write;
+	}
+
 	printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
 			VERSION);
 	return 0;
@@ -208,9 +310,8 @@
 	return -ENOMEM;
 }
 
-
-static void __exit srm_env_exit(void)
-{
+static void __exit
+srm_env_exit(void) {
 	srm_env_cleanup();
 	printk(KERN_INFO "%s: unloaded successfully\n", NAME);
 	return;
diff -Nru a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
--- a/arch/alpha/lib/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/alpha/lib/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for alpha-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 # Many of these routines have implementations tuned for ev6.
diff -Nru a/arch/alpha/math-emu/Makefile b/arch/alpha/math-emu/Makefile
--- a/arch/alpha/math-emu/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/alpha/math-emu/Makefile	Fri May 24 18:55:33 2002
@@ -2,18 +2,10 @@
 # Makefile for the FPU instruction emulation.
 #
 
-CFLAGS += -I. -I$(TOPDIR)/include/math-emu -w
-
-ifeq ($(CONFIG_MATHEMU),y)
-
-O_TARGET	:= math-emu.o
-obj-y		:= math.o qrnnd.o
-
-else
+obj-$(CONFIG_MATHEMU) += math-emu.o
 
 math-emu-objs	:= math.o qrnnd.o
-obj-m		:= math-emu.o
 
-endif
+CFLAGS += -I. -I$(TOPDIR)/include/math-emu -w
 
 include $(TOPDIR)/Rules.make
diff -Nru a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
--- a/arch/alpha/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/alpha/mm/init.c	Fri May 24 18:55:35 2002
@@ -137,7 +137,6 @@
 	printk("%ld reserved pages\n",reserved);
 	printk("%ld pages shared\n",shared);
 	printk("%ld pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 #endif
 
diff -Nru a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
--- a/arch/alpha/mm/numa.c	Fri May 24 18:55:33 2002
+++ b/arch/alpha/mm/numa.c	Fri May 24 18:55:33 2002
@@ -425,5 +425,4 @@
 	printk("%ld pages shared\n",shared);
 	printk("%ld pages swap cached\n",cached);
 	printk("%ld pages in page table cache\n",pgtable_cache_size);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
--- a/arch/arm/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/Makefile	Fri May 24 18:55:35 2002
@@ -26,11 +26,14 @@
 apcs-$(CONFIG_CPU_26)		:=-mapcs-26 -mcpu=arm3 -Os
 
 # This selects which instruction set is used.
+# Note that GCC is lame - it doesn't numerically define an
+# architecture version macro, but instead defines a whole
+# series of macros.
 arch-y				:=
-arch-$(CONFIG_CPU_32v3)		:=-march=armv3
-arch-$(CONFIG_CPU_32v4)		:=-march=armv4
-arch-$(CONFIG_CPU_32v5)		:=-march=armv5
-arch-$(CONFIG_CPU_XSCALE)	:=-march=armv4 -Wa,-mxscale #-march=armv5te
+arch-$(CONFIG_CPU_32v3)		:=-D__LINUX_ARM_ARCH__=3 -march=armv3
+arch-$(CONFIG_CPU_32v4)		:=-D__LINUX_ARM_ARCH__=4 -march=armv4
+arch-$(CONFIG_CPU_32v5)		:=-D__LINUX_ARM_ARCH__=5 -march=armv5
+arch-$(CONFIG_CPU_XSCALE)	:=-D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxscale #-march=armv5te
 
 # This selects how we optimise for the processor.
 tune-y				:=
diff -Nru a/arch/arm/boot/compressed/head-l7200.S b/arch/arm/boot/compressed/head-l7200.S
--- a/arch/arm/boot/compressed/head-l7200.S	Fri May 24 18:55:33 2002
+++ b/arch/arm/boot/compressed/head-l7200.S	Fri May 24 18:55:33 2002
@@ -8,6 +8,7 @@
  */
 
 #include <linux/config.h>
+#include <asm/mach-types.h>
 
 #ifndef CONFIG_ARCH_L7200
 #error What am I doing here...
@@ -26,4 +27,4 @@
 		ble	1b
 
 		mov	r8, #0			@ Zero it out
-		mov	r7, #19			@ Set architecture ID
+		mov	r7, #MACH_TYPE_L7200	@ Set architecture ID
diff -Nru a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
--- a/arch/arm/boot/compressed/head.S	Fri May 24 18:55:36 2002
+++ b/arch/arm/boot/compressed/head.S	Fri May 24 18:55:36 2002
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/arm/boot/compressed/head.S
  *
- *  Copyright (C) 1996-1999 Russell King
+ *  Copyright (C) 1996-2002 Russell King
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -161,7 +161,6 @@
 		cmp	r2, r3
 		blo	1b
 
-		mrc	p15, 0, r6, c0, c0	@ get processor ID
 		bl	cache_on
 
 		mov	r1, sp			@ malloc space above stack
@@ -200,7 +199,8 @@
  */
 		add	r1, r5, r0		@ end of decompressed kernel
 		adr	r2, reloc_start
-		adr	r3, reloc_end
+		ldr	r3, LC1
+		add	r3, r2, r3
 1:		ldmia	r2!, {r8 - r13}		@ copy relocation code
 		stmia	r1!, {r8 - r13}
 		ldmia	r2!, {r8 - r13}
@@ -229,8 +229,9 @@
 		.word	_load_addr		@ r4
 		.word	_start			@ r5
 		.word	_got_start		@ r6
-		.word	_got_end		@ r7
-		.word	user_stack+4096		@ r8
+		.word	_got_end		@ ip
+		.word	user_stack+4096		@ sp
+LC1:		.word	reloc_end - reloc_start
 		.size	LC0, . - LC0
 
 /*
@@ -255,7 +256,7 @@
 cache_on:	mov	r3, #8			@ cache_on function
 		b	call_cache_fn
 
-__cache_on:	sub	r3, r4, #16384		@ Page directory size
+__setup_mmu:	sub	r3, r4, #16384		@ Page directory size
 		bic	r3, r3, #0xff		@ Align the pointer
 		bic	r3, r3, #0x3f00
 /*
@@ -291,20 +292,35 @@
 		str	r1, [r0], #4
 		add	r1, r1, #1048576
 		str	r1, [r0]
+		mov	pc, lr
 
+__armv4_cache_on:
+		mov	r12, lr
+		bl	__setup_mmu
 		mov	r0, #0
 		mcr	p15, 0, r0, c7, c10, 4	@ drain write buffer
-		mcr	p15, 0, r0, c8, c7	@ flush I,D TLBs
-		mcr	p15, 0, r3, c2, c0	@ load page table pointer
-		mov	r0, #-1
-		mcr	p15, 0, r0, c3, c0	@ load domain access register
-		mrc	p15, 0, r0, c1, c0
+		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
 		orr	r0, r0, #0x1000		@ I-cache enable
+		orr	r0, r0, #0x0030
+		b	__common_cache_on
+
+__arm6_cache_on:
+		mov	r12, lr
+		bl	__setup_mmu
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c0, 0	@ invalidate whole cache v3
+		mcr	p15, 0, r0, c5, c0, 0	@ invalidate whole TLB v3
+		mov	r0, #0x30
+__common_cache_on:
 #ifndef DEBUG
-		orr	r0, r0, #0x003d		@ Write buffer, mmu
+		orr	r0, r0, #0x000d		@ Write buffer, mmu
 #endif
-		mcr	p15, 0, r0, c1, c0
-		mov	pc, lr
+		mov	r1, #-1
+		mcr	p15, 0, r3, c2, c0, 0	@ load page table pointer
+		mcr	p15, 0, r1, c3, c0, 0	@ load domain access control
+		mcr	p15, 0, r0, c1, c0, 0	@ load control register
+		mov	pc, r12
 
 /*
  * All code following this line is relocatable.  It is relocated by
@@ -349,11 +365,12 @@
  *  r1  = corrupted
  *  r2  = corrupted
  *  r3  = block offset
- *  r6  = CPU ID
+ *  r6  = corrupted
  *  r12 = corrupted
  */
 
 call_cache_fn:	adr	r12, proc_types
+		mrc	p15, 0, r6, c0, c0	@ get processor ID
 1:		ldr	r1, [r12, #0]		@ get value
 		ldr	r2, [r12, #4]		@ get mask
 		eor	r1, r1, r6		@ (real ^ match)
@@ -380,9 +397,12 @@
 proc_types:
 		.word	0x41560600		@ ARM6/610
 		.word	0xffffffe0
-		b	__arm6_cache_off
+		b	__arm6_cache_off	@ works, but slow
 		b	__arm6_cache_off
 		mov	pc, lr
+@		b	__arm6_cache_on		@ untested
+@		b	__arm6_cache_off
+@		b	__armv3_cache_flush
 
 		.word	0x41007000		@ ARM7/710
 		.word	0xfff8fe00
@@ -392,31 +412,31 @@
 
 		.word	0x41807200		@ ARM720T (writethrough)
 		.word	0xffffff00
-		b	__cache_on
+		b	__armv4_cache_on
 		b	__armv4_cache_off
 		mov	pc, lr
 
 		.word	0x41129200		@ ARM920T
 		.word	0xff00fff0
-		b	__cache_on
+		b	__armv4_cache_on
 		b	__armv4_cache_off
 		b	__armv4_cache_flush
 
 		.word	0x4401a100		@ sa110 / sa1100
 		.word	0xffffffe0
-		b	__cache_on
+		b	__armv4_cache_on
 		b	__armv4_cache_off
 		b	__armv4_cache_flush
 
 		.word	0x6901b110		@ sa1110
 		.word	0xfffffff0
-		b	__cache_on
+		b	__armv4_cache_on
 		b	__armv4_cache_off
 		b	__armv4_cache_flush
 
 		.word	0x69050000		@ xscale
 		.word	0xffff0000
-		b	__cache_on
+		b	__armv4_cache_on
 		b	__armv4_cache_off
 		b	__armv4_cache_flush
 
@@ -450,7 +470,7 @@
 		mov	pc, lr
 
 __arm6_cache_off:
-		mov	r0, #0x00000060		@ ARM6 control reg.
+		mov	r0, #0x00000030		@ ARM6 control reg.
 		b	__armv3_cache_off
 
 __arm7_cache_off:
@@ -458,10 +478,10 @@
 		b	__armv3_cache_off
 
 __armv3_cache_off:
-		mcr	p15, 0, r0, c1, c0	@ turn MMU and cache off
+		mcr	p15, 0, r0, c1, c0, 0	@ turn MMU and cache off
 		mov	r0, #0
-		mcr	p15, 0, r0, c7, c0	@ invalidate whole cache v3
-		mcr	p15, 0, r0, c5, c0	@ invalidate whole TLB v3
+		mcr	p15, 0, r0, c7, c0, 0	@ invalidate whole cache v3
+		mcr	p15, 0, r0, c5, c0, 0	@ invalidate whole TLB v3
 		mov	pc, lr
 
 /*
@@ -488,6 +508,11 @@
 
 		mcr	p15, 0, r1, c7, c7, 0	@ flush I cache
 		mcr	p15, 0, r1, c7, c10, 4	@ drain WB
+		mov	pc, lr
+
+__armv3_cache_flush:
+		mov	r1, #0
+		mcr	p15, 0, r0, c7, c0, 0	@ invalidate whole cache v3
 		mov	pc, lr
 
 /*
diff -Nru a/arch/arm/def-configs/a5k b/arch/arm/def-configs/a5k
--- a/arch/arm/def-configs/a5k	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/a5k	Fri May 24 18:55:34 2002
@@ -258,15 +258,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -286,7 +277,6 @@
 # CONFIG_BLK_DEV_IDE_RAPIDE is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/adsbitsy b/arch/arm/def-configs/adsbitsy
--- a/arch/arm/def-configs/adsbitsy	Fri May 24 18:55:36 2002
+++ b/arch/arm/def-configs/adsbitsy	Fri May 24 18:55:36 2002
@@ -329,15 +329,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -348,7 +339,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/assabet b/arch/arm/def-configs/assabet
--- a/arch/arm/def-configs/assabet	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/assabet	Fri May 24 18:55:35 2002
@@ -469,15 +469,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -492,7 +483,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/badge4 b/arch/arm/def-configs/badge4
--- a/arch/arm/def-configs/badge4	Fri May 24 18:55:36 2002
+++ b/arch/arm/def-configs/badge4	Fri May 24 18:55:36 2002
@@ -522,15 +522,6 @@
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -546,7 +537,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/cerfcube b/arch/arm/def-configs/cerfcube
--- a/arch/arm/def-configs/cerfcube	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/cerfcube	Fri May 24 18:55:33 2002
@@ -450,15 +450,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -473,7 +464,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/cerfpda b/arch/arm/def-configs/cerfpda
--- a/arch/arm/def-configs/cerfpda	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/cerfpda	Fri May 24 18:55:34 2002
@@ -480,15 +480,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -503,7 +494,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/cerfpod b/arch/arm/def-configs/cerfpod
--- a/arch/arm/def-configs/cerfpod	Fri May 24 18:55:36 2002
+++ b/arch/arm/def-configs/cerfpod	Fri May 24 18:55:36 2002
@@ -451,15 +451,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -474,7 +465,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/flexanet b/arch/arm/def-configs/flexanet
--- a/arch/arm/def-configs/flexanet	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/flexanet	Fri May 24 18:55:35 2002
@@ -455,15 +455,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -478,7 +469,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/footbridge b/arch/arm/def-configs/footbridge
--- a/arch/arm/def-configs/footbridge	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/footbridge	Fri May 24 18:55:35 2002
@@ -381,15 +381,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -433,7 +424,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 
 #
diff -Nru a/arch/arm/def-configs/freebird b/arch/arm/def-configs/freebird
--- a/arch/arm/def-configs/freebird	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/freebird	Fri May 24 18:55:34 2002
@@ -364,15 +364,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -383,7 +374,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/freebird_new b/arch/arm/def-configs/freebird_new
--- a/arch/arm/def-configs/freebird_new	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/freebird_new	Fri May 24 18:55:33 2002
@@ -378,15 +378,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -397,7 +388,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/graphicsclient b/arch/arm/def-configs/graphicsclient
--- a/arch/arm/def-configs/graphicsclient	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/graphicsclient	Fri May 24 18:55:35 2002
@@ -431,15 +431,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -454,7 +445,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/graphicsmaster b/arch/arm/def-configs/graphicsmaster
--- a/arch/arm/def-configs/graphicsmaster	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/graphicsmaster	Fri May 24 18:55:33 2002
@@ -408,15 +408,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -427,7 +418,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/h3600 b/arch/arm/def-configs/h3600
--- a/arch/arm/def-configs/h3600	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/h3600	Fri May 24 18:55:34 2002
@@ -458,15 +458,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -481,7 +472,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/iq80310 b/arch/arm/def-configs/iq80310
--- a/arch/arm/def-configs/iq80310	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/iq80310	Fri May 24 18:55:34 2002
@@ -436,15 +436,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -485,7 +476,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/jornada720 b/arch/arm/def-configs/jornada720
--- a/arch/arm/def-configs/jornada720	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/jornada720	Fri May 24 18:55:34 2002
@@ -462,15 +462,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -481,7 +472,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/lart b/arch/arm/def-configs/lart
--- a/arch/arm/def-configs/lart	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/lart	Fri May 24 18:55:35 2002
@@ -460,15 +460,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -483,7 +474,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/neponset b/arch/arm/def-configs/neponset
--- a/arch/arm/def-configs/neponset	Fri May 24 18:55:34 2002
+++ b/arch/arm/def-configs/neponset	Fri May 24 18:55:34 2002
@@ -431,15 +431,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -454,7 +445,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/omnimeter b/arch/arm/def-configs/omnimeter
--- a/arch/arm/def-configs/omnimeter	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/omnimeter	Fri May 24 18:55:35 2002
@@ -294,15 +294,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=y
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -313,7 +304,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/pangolin b/arch/arm/def-configs/pangolin
--- a/arch/arm/def-configs/pangolin	Fri May 24 18:55:36 2002
+++ b/arch/arm/def-configs/pangolin	Fri May 24 18:55:36 2002
@@ -413,15 +413,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_PANGOLIN is not set
 # CONFIG_BLK_DEV_IDECD is not set
@@ -433,7 +424,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/pfs168_mqtft b/arch/arm/def-configs/pfs168_mqtft
--- a/arch/arm/def-configs/pfs168_mqtft	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/pfs168_mqtft	Fri May 24 18:55:35 2002
@@ -434,15 +434,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -457,7 +448,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/pfs168_mqvga b/arch/arm/def-configs/pfs168_mqvga
--- a/arch/arm/def-configs/pfs168_mqvga	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/pfs168_mqvga	Fri May 24 18:55:33 2002
@@ -434,15 +434,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -457,7 +448,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/pfs168_sastn b/arch/arm/def-configs/pfs168_sastn
--- a/arch/arm/def-configs/pfs168_sastn	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/pfs168_sastn	Fri May 24 18:55:33 2002
@@ -435,15 +435,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -458,7 +449,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/pfs168_satft b/arch/arm/def-configs/pfs168_satft
--- a/arch/arm/def-configs/pfs168_satft	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/pfs168_satft	Fri May 24 18:55:33 2002
@@ -434,15 +434,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -457,7 +448,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/rpc b/arch/arm/def-configs/rpc
--- a/arch/arm/def-configs/rpc	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/rpc	Fri May 24 18:55:33 2002
@@ -382,15 +382,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -411,7 +402,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/arm/def-configs/shannon b/arch/arm/def-configs/shannon
--- a/arch/arm/def-configs/shannon	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/shannon	Fri May 24 18:55:33 2002
@@ -373,7 +373,6 @@
 # CONFIG_BLK_DEV_HD_IDE is not set
 # CONFIG_BLK_DEV_HD is not set
 # CONFIG_BLK_DEV_IDEDISK is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -385,7 +384,6 @@
 # CONFIG_BLK_DEV_CMD640 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 
diff -Nru a/arch/arm/def-configs/shark b/arch/arm/def-configs/shark
--- a/arch/arm/def-configs/shark	Fri May 24 18:55:33 2002
+++ b/arch/arm/def-configs/shark	Fri May 24 18:55:33 2002
@@ -410,15 +410,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -435,7 +426,6 @@
 # CONFIG_BLK_DEV_SL82C105 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
 # CONFIG_BLK_DEV_ATARAID_HPT is not set
diff -Nru a/arch/arm/def-configs/stork b/arch/arm/def-configs/stork
--- a/arch/arm/def-configs/stork	Fri May 24 18:55:36 2002
+++ b/arch/arm/def-configs/stork	Fri May 24 18:55:36 2002
@@ -455,15 +455,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=m
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -478,7 +469,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/def-configs/system3 b/arch/arm/def-configs/system3
--- a/arch/arm/def-configs/system3	Fri May 24 18:55:35 2002
+++ b/arch/arm/def-configs/system3	Fri May 24 18:55:35 2002
@@ -472,15 +472,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -495,7 +486,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
--- a/arch/arm/kernel/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/kernel/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 ENTRY_OBJ = entry-$(PROCESSOR).o
 
 AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR)
diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
--- a/arch/arm/kernel/bios32.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/kernel/bios32.c	Fri May 24 18:55:35 2002
@@ -545,73 +545,8 @@
 	}
 }
 
-extern struct hw_pci ebsa285_pci;
-extern struct hw_pci cats_pci;
-extern struct hw_pci netwinder_pci;
-extern struct hw_pci personal_server_pci;
-extern struct hw_pci ftv_pci;
-extern struct hw_pci shark_pci;
-extern struct hw_pci integrator_pci;
-extern struct hw_pci iq80310_pci;
-
-void __init pcibios_init(void)
+void __init pci_common_init(struct hw_pci *hw)
 {
-	struct hw_pci *hw = NULL;
-
-	do {
-#ifdef CONFIG_ARCH_EBSA285
-		if (machine_is_ebsa285()) {
-			hw = &ebsa285_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_SHARK
-		if (machine_is_shark()) {
-			hw = &shark_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_CATS
-		if (machine_is_cats()) {
-			hw = &cats_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_NETWINDER
-		if (machine_is_netwinder()) {
-			hw = &netwinder_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_PERSONAL_SERVER
-		if (machine_is_personal_server()) {
-			hw = &personal_server_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_FTVPCI
-		if (machine_is_ftvpci()) {
-			hw = &ftv_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_INTEGRATOR
-		if (machine_is_integrator()) {
-			hw = &integrator_pci;
-			break;
-		}
-#endif
-#ifdef CONFIG_ARCH_IQ80310
-		if (machine_is_iq80310()) {
-			hw = &iq80310_pci;
-			break;
-		}
-#endif
-	} while (0);
-
-	if (hw == NULL)
-		return;
-
 	if (hw->preinit)
 		hw->preinit();
 	pcibios_init_hw(hw);
diff -Nru a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c
--- a/arch/arm/kernel/dma.c	Fri May 24 18:55:36 2002
+++ b/arch/arm/kernel/dma.c	Fri May 24 18:55:36 2002
@@ -120,6 +120,10 @@
 {
 	dma_t *dma = dma_chan + channel;
 
+	if (dma->active)
+		printk(KERN_ERR "dma%d: altering DMA SG while "
+		       "DMA active\n", channel);
+
 	dma->sg = sg;
 	dma->sgcount = nr_sg;
 	dma->using_sg = 1;
@@ -216,6 +220,14 @@
 free_dma:
 	printk(KERN_ERR "dma%d: trying to disable free DMA\n", channel);
 	BUG();
+}
+
+/*
+ * Is the specified DMA channel active?
+ */
+int dma_channel_active(dmach_t channel)
+{
+	return dma_chan[channel].active;
 }
 
 void set_dma_page(dmach_t channel, char pagenr)
diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
--- a/arch/arm/kernel/ecard.c	Fri May 24 18:55:36 2002
+++ b/arch/arm/kernel/ecard.c	Fri May 24 18:55:36 2002
@@ -541,7 +541,7 @@
  *
  * They are not meant to be called directly, but via enable/disable_irq.
  */
-static void ecard_irq_mask(unsigned int irqnr)
+static void ecard_irq_unmask(unsigned int irqnr)
 {
 	ecard_t *ec = slot_to_ecard(irqnr - 32);
 
@@ -557,7 +557,7 @@
 	}
 }
 
-static void ecard_irq_unmask(unsigned int irqnr)
+static void ecard_irq_mask(unsigned int irqnr)
 {
 	ecard_t *ec = slot_to_ecard(irqnr - 32);
 
@@ -945,20 +945,20 @@
 			break;
 		}
 
-	ec->irq = 32 + slot;
-#ifdef IO_EC_MEMC8_BASE
-	if (slot == 8)
-		ec->irq = 11;
-#endif
 	/*
 	 * hook the interrupt handlers
 	 */
-	if (ec->irq != 0 && ec->irq >= 32) {
+	if (slot < 8) {
+		ec->irq = 32 + slot;
 		set_irq_chip(ec->irq, &ecard_chip);
 		set_irq_handler(ec->irq, do_level_IRQ);
 		set_irq_flags(ec->irq, IRQF_VALID);
 	}
 
+#ifdef IO_EC_MEMC8_BASE
+	if (slot == 8)
+		ec->irq = 11;
+#endif
 #ifdef CONFIG_ARCH_RPC
 	/* On RiscPC, only first two slots have DMA capability */
 	if (slot < 2)
diff -Nru a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
--- a/arch/arm/kernel/head.S	Fri May 24 18:55:33 2002
+++ b/arch/arm/kernel/head.S	Fri May 24 18:55:33 2002
@@ -1,13 +1,13 @@
 /*
  *  linux/arch/arm/kernel/head-armv.S
  *
- *  Copyright (C) 1994-1999 Russell King
+ *  Copyright (C) 1994-2002 Russell King
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- *  32-bit kernel startup code for all architectures
+ *  Kernel startup code for all 32-bit CPUs
  */
 #include <linux/config.h>
 #include <linux/linkage.h>
@@ -17,12 +17,10 @@
 #include <asm/procinfo.h>
 #include <asm/mach/arch.h>
 
-#define K(a,b,c)	((a) << 24 | (b) << 12 | (c))
-
 /*
  * We place the page tables 16K below TEXTADDR.  Therefore, we must make sure
  * that TEXTADDR is correctly set.  Currently, we expect the least significant
- * "short" to be 0x8000, but we could probably relax this restriction to
+ * 16 bits to be 0x8000, but we could probably relax this restriction to
  * TEXTADDR > PAGE_OFFSET + 0x4000
  *
  * Note that swapper_pg_dir is the virtual address of the page tables, and
@@ -35,159 +33,119 @@
 #error TEXTADDR must start at 0xXXXX8000
 #endif
 
-		.globl	swapper_pg_dir
-		.equ	swapper_pg_dir, TEXTADDR - 0x4000
+	.globl	swapper_pg_dir
+	.equ	swapper_pg_dir, TEXTADDR - 0x4000
 
-		.macro	pgtbl, reg, rambase
-		adr	\reg, stext
-		sub	\reg, \reg, #0x4000
-		.endm
+	.macro	pgtbl, reg, rambase
+	adr	\reg, stext
+	sub	\reg, \reg, #0x4000
+	.endm
 
 /*
  * Since the page table is closely related to the kernel start address, we
  * can convert the page table base address to the base address of the section
  * containing both.
  */
-		.macro	krnladr, rd, pgtable, rambase
-		bic	\rd, \pgtable, #0x000ff000
-		.endm
+	.macro	krnladr, rd, pgtable, rambase
+	bic	\rd, \pgtable, #0x000ff000
+	.endm
 
 /*
- *  Kernel startup entry point.
+ * Kernel startup entry point.
+ * ---------------------------
+ *
+ * This is normally called from the decompressor code.  The requirements
+ * are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
+ * r1 = machine nr.
  *
- * The rules are:
- *  r0      - should be 0
- *  r1      - unique architecture number
- *  MMU     - off
- *  I-cache - on or off
- *  D-cache - off
+ * This code is mostly position independent, so if you link the kernel at
+ * 0xc0008000, you call this at __pa(0xc0008000).
  *
- * See linux/arch/arm/tools/mach-types for the complete list of numbers
- * for r1.
+ * See linux/arch/arm/tools/mach-types for the complete list of machine
+ * numbers for r1.
+ *
+ * We're trying to keep crap to a minimum; DO NOT add any machine specific
+ * crap here - that's what the boot loader (or in extreme, well justified
+ * circumstances, zImage) is for.
  */
-		.section ".text.init",#alloc,#execinstr
-		.type	stext, #function
+	.section ".text.init",#alloc,#execinstr
+	.type	stext, #function
 ENTRY(stext)
-		mov	r12, r0
-/*
- * NOTE!  Any code which is placed here should be done for one of
- * the following reasons:
- *
- *  1. Compatability with old production boot firmware (ie, users
- *     actually have and are booting the kernel with the old firmware)
- *     and therefore will be eventually removed.
- *  2. Cover the case when there is no boot firmware.  This is not
- *     ideal, but in this case, it should ONLY set r0 and r1 to the
- *     appropriate value.
- */
-#if defined(CONFIG_ARCH_NETWINDER)
-/*
- * Compatability cruft for old NetWinder NeTTroms.  This
- * code is currently scheduled for destruction in 2.5.xx
- */
-		.rept	8
-		mov	r0, r0
-		.endr
-
-		adr	r2, 1f
-		ldmdb	r2, {r7, r8}
-		and	r3, r2, #0xc000
-		teq	r3, #0x8000
-		beq	__entry
-		bic	r3, r2, #0xc000
-		orr	r3, r3, #0x8000
-		mov	r0, r3
-		mov	r4, #64
-		sub	r5, r8, r7
-		b	1f
-
-		.word	_stext
-		.word	__bss_start
-
-1:
-		.rept	4
-		ldmia	r2!, {r6, r7, r8, r9}
-		stmia	r3!, {r6, r7, r8, r9}
-		.endr
-		subs	r4, r4, #64
-		bcs	1b
-		movs	r4, r5
-		mov	r5, #0
-		movne	pc, r0
-
-		mov	r1, #MACH_TYPE_NETWINDER	@ (will go in 2.5)
-		mov	r12, #2 << 24			@ scheduled for removal in 2.5.xx
-		orr	r12, r12, #5 << 12
-__entry:
+	mov	r12, r0
+	mov	r0, #PSR_F_BIT | PSR_I_BIT | MODE_SVC	@ make sure svc mode
+	msr	cpsr_c, r0			@ and all irqs disabled
+	bl	__lookup_processor_type
+	teq	r10, #0				@ invalid processor?
+	moveq	r0, #'p'			@ yes, error 'p'
+	beq	__error
+	bl	__lookup_architecture_type
+	teq	r7, #0				@ invalid architecture?
+	moveq	r0, #'a'			@ yes, error 'a'
+	beq	__error
+	bl	__create_page_tables
+
+	/*
+	 * The following calls CPU specific code in a position independent
+	 * manner.  See arch/arm/mm/proc-*.S for details.  r10 = base of
+	 * xxx_proc_info structure selected by __lookup_architecture_type
+	 * above.  On return, the CPU will be ready for the MMU to be
+	 * turned on, and r0 will hold the CPU control register value.
+	 */
+	adr	lr, __turn_mmu_on		@ return (PIC) address
+	add	pc, r10, #12
+
+	.type	__switch_data, %object
+__switch_data:
+	.long	__mmap_switched
+	.long	__bss_start			@ r4
+	.long	_end				@ r5
+	.long	processor_id			@ r6
+	.long	__machine_arch_type		@ r7
+	.long	cr_alignment			@ r8
+	.long	init_thread_union+8192		@ sp
+
+/*
+ * Enable the MMU.  This completely changes the structure of the visible
+ * memory space.  You will not be able to trace execution through this.
+ * If you have an enquiry about this, *please* check the linux-arm-kernel
+ * mailing list archives BEFORE sending another post to the list.
+ */
+	.align	5
+	.type	__turn_mmu_on, %function
+__turn_mmu_on:
+	ldr	lr, __switch_data
+#ifdef CONFIG_ALIGNMENT_TRAP
+	orr	r0, r0, #2			@ ...........A.
 #endif
-#if defined(CONFIG_ARCH_L7200)
-/*
- * FIXME - No bootloader, so manually set 'r1' with our architecture number.
+	mcr	p15, 0, r0, c1, c0
+	mov	r0, r0
+	mov	r0, r0
+	mov	r0, r0
+	mov	pc, lr
+
+/*
+ * The following fragment of code is executed with the MMU on, and uses
+ * absolute addresses; this is not position independent.
+ *
+ *  r0  = processor control register
+ *  r1  = machine ID
+ *  r9  = processor ID
+ *  r12 = value of r0 when kernel was called (currently always zero)
  */
-		mov	r1, #MACH_TYPE_L7200
-#endif
-
-		mov	r0, #PSR_F_BIT | PSR_I_BIT | MODE_SVC	@ make sure svc mode
-		msr	cpsr_c, r0			@ and all irqs disabled
-		bl	__lookup_processor_type
-		teq	r10, #0				@ invalid processor?
-		moveq	r0, #'p'			@ yes, error 'p'
-		beq	__error
-		bl	__lookup_architecture_type
-		teq	r7, #0				@ invalid architecture?
-		moveq	r0, #'a'			@ yes, error 'a'
-		beq	__error
-		bl	__create_page_tables
-		adr	lr, __ret			@ return address
-		add	pc, r10, #12			@ initialise processor
-							@ (return control reg)
-
-		.type	__switch_data, %object
-__switch_data:	.long	__mmap_switched
-		.long	compat
-		.long	__bss_start
-		.long	_end
-		.long	processor_id
-		.long	__machine_arch_type
-		.long	cr_alignment
-		.long	init_thread_union+8192
-
-		.type	__ret, %function
-__ret:		ldr	lr, __switch_data
-		mcr	p15, 0, r0, c1, c0
-		mov	r0, r0
-		mov	r0, r0
-		mov	r0, r0
-		mov	pc, lr
-
-		/*
-		 * This code follows on after the page
-		 * table switch and jump above.
-		 *
-		 * r0  = processor control register
-		 * r1  = machine ID
-		 * r9  = processor ID
-		 */
-		.align	5
+	.align	5
 __mmap_switched:
-		adr	r3, __switch_data + 4
-		ldmia	r3, {r2, r4, r5, r6, r7, r8, sp}@ r2 = compat
-							@ sp = stack pointer
-		str	r12, [r2]
-
-		mov	fp, #0				@ Clear BSS (and zero fp)
-1:		cmp	r4, r5
-		strcc	fp, [r4],#4
-		bcc	1b
+	adr	r3, __switch_data + 4
+	ldmia	r3, {r4, r5, r6, r7, r8, sp}
+	mov	fp, #0				@ Clear BSS (and zero fp)
+1:	cmp	r4, r5
+	strcc	fp, [r4],#4
+	bcc	1b
+	str	r9, [r6]			@ Save processor ID
+	str	r1, [r7]			@ Save machine type
+	bic	r2, r0, #2			@ Clear 'A' bit
+	stmia	r8, {r0, r2}			@ Save control register values
+	b	start_kernel
 
-		str	r9, [r6]			@ Save processor ID
-		str	r1, [r7]			@ Save machine type
-#ifdef CONFIG_ALIGNMENT_TRAP
-		orr	r0, r0, #2			@ ...........A.
-#endif
-		bic	r2, r0, #2			@ Clear 'A' bit
-		stmia	r8, {r0, r2}			@ Save control register values
-		b	start_kernel
 
 
 
@@ -205,116 +163,116 @@
  * r8 = page table flags
  */
 __create_page_tables:
-		pgtbl	r4, r5				@ page table address
+	pgtbl	r4, r5				@ page table address
 
-		/*
-		 * Clear the 16K level 1 swapper page table
-		 */
-		mov	r0, r4
-		mov	r3, #0
-		add	r2, r0, #0x4000
-1:		str	r3, [r0], #4
-		str	r3, [r0], #4
-		str	r3, [r0], #4
-		str	r3, [r0], #4
-		teq	r0, r2
-		bne	1b
-
-		/*
-		 * Create identity mapping for first MB of kernel to
-		 * cater for the MMU enable.  This identity mapping
-		 * will be removed by paging_init()
-		 */
-		krnladr	r2, r4, r5			@ start of kernel
-		add	r3, r8, r2			@ flags + kernel base
-		str	r3, [r4, r2, lsr #18]		@ identity mapping
-
-		/*
-		 * Now setup the pagetables for our kernel direct
-		 * mapped region.  We round TEXTADDR down to the
-		 * nearest megabyte boundary.
-		 */
-		add	r0, r4, #(TEXTADDR & 0xff000000) >> 18 @ start of kernel
-		bic	r2, r3, #0x00f00000
-		str	r2, [r0]			@ PAGE_OFFSET + 0MB
-		add	r0, r0, #(TEXTADDR & 0x00f00000) >> 18
-		str	r3, [r0], #4			@ KERNEL + 0MB
-		add	r3, r3, #1 << 20
-		str	r3, [r0], #4			@ KERNEL + 1MB
-		add	r3, r3, #1 << 20
-		str	r3, [r0], #4			@ KERNEL + 2MB
-		add	r3, r3, #1 << 20
-		str	r3, [r0], #4			@ KERNEL + 3MB
-
-		/*
-		 * Ensure that the first section of RAM is present.
-		 * we assume that:
-		 *  1. the RAM is aligned to a 32MB boundary
-		 *  2. the kernel is executing in the same 32MB chunk
-		 *     as the start of RAM.
-		 */
-		bic	r0, r0, #0x01f00000 >> 18	@ round down
-		and	r2, r5, #0xfe000000		@ round down
-		add	r3, r8, r2			@ flags + rambase
-		str	r3, [r0]
+	/*
+	 * Clear the 16K level 1 swapper page table
+	 */
+	mov	r0, r4
+	mov	r3, #0
+	add	r2, r0, #0x4000
+1:	str	r3, [r0], #4
+	str	r3, [r0], #4
+	str	r3, [r0], #4
+	str	r3, [r0], #4
+	teq	r0, r2
+	bne	1b
+
+	/*
+	 * Create identity mapping for first MB of kernel to
+	 * cater for the MMU enable.  This identity mapping
+	 * will be removed by paging_init()
+	 */
+	krnladr	r2, r4, r5			@ start of kernel
+	add	r3, r8, r2			@ flags + kernel base
+	str	r3, [r4, r2, lsr #18]		@ identity mapping
+
+	/*
+	 * Now setup the pagetables for our kernel direct
+	 * mapped region.  We round TEXTADDR down to the
+	 * nearest megabyte boundary.
+	 */
+	add	r0, r4, #(TEXTADDR & 0xff000000) >> 18 @ start of kernel
+	bic	r2, r3, #0x00f00000
+	str	r2, [r0]			@ PAGE_OFFSET + 0MB
+	add	r0, r0, #(TEXTADDR & 0x00f00000) >> 18
+	str	r3, [r0], #4			@ KERNEL + 0MB
+	add	r3, r3, #1 << 20
+	str	r3, [r0], #4			@ KERNEL + 1MB
+	add	r3, r3, #1 << 20
+	str	r3, [r0], #4			@ KERNEL + 2MB
+	add	r3, r3, #1 << 20
+	str	r3, [r0], #4			@ KERNEL + 3MB
+
+	/*
+	 * Ensure that the first section of RAM is present.
+	 * we assume that:
+	 *  1. the RAM is aligned to a 32MB boundary
+	 *  2. the kernel is executing in the same 32MB chunk
+	 *     as the start of RAM.
+	 */
+	bic	r0, r0, #0x01f00000 >> 18	@ round down
+	and	r2, r5, #0xfe000000		@ round down
+	add	r3, r8, r2			@ flags + rambase
+	str	r3, [r0]
 
-		bic	r8, r8, #0x0c			@ turn off cacheable
-							@ and bufferable bits
+	bic	r8, r8, #0x0c			@ turn off cacheable
+						@ and bufferable bits
 #ifdef CONFIG_DEBUG_LL
-		/*
-		 * Map in IO space for serial debugging.
-		 * This allows debug messages to be output
-		 * via a serial console before paging_init.
-		 */
-		add	r0, r4, r7
-		rsb	r3, r7, #0x4000	@ PTRS_PER_PGD*sizeof(long)
-		cmp	r3, #0x0800
-		addge	r2, r0, #0x0800
-		addlt	r2, r0, r3
-		orr	r3, r6, r8
-1:		str	r3, [r0], #4
-		add	r3, r3, #1 << 20
-		teq	r0, r2
-		bne	1b
+	/*
+	 * Map in IO space for serial debugging.
+	 * This allows debug messages to be output
+	 * via a serial console before paging_init.
+	 */
+	add	r0, r4, r7
+	rsb	r3, r7, #0x4000			@ PTRS_PER_PGD*sizeof(long)
+	cmp	r3, #0x0800
+	addge	r2, r0, #0x0800
+	addlt	r2, r0, r3
+	orr	r3, r6, r8
+1:	str	r3, [r0], #4
+	add	r3, r3, #1 << 20
+	teq	r0, r2
+	bne	1b
 #if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
-		/*
-		 * If we're using the NetWinder, we need to map in
-		 * the 16550-type serial port for the debug messages
-		 */
-		teq	r1, #MACH_TYPE_NETWINDER
-		teqne	r1, #MACH_TYPE_CATS
-		bne	1f
-		add	r0, r4, #0x3fc0
-		mov	r3, #0x7c000000
-		orr	r3, r3, r8
-		str	r3, [r0], #4
-		add	r3, r3, #1 << 20
-		str	r3, [r0], #4
+	/*
+	 * If we're using the NetWinder, we need to map in
+	 * the 16550-type serial port for the debug messages
+	 */
+	teq	r1, #MACH_TYPE_NETWINDER
+	teqne	r1, #MACH_TYPE_CATS
+	bne	1f
+	add	r0, r4, #0x3fc0			@ ff000000
+	mov	r3, #0x7c000000
+	orr	r3, r3, r8
+	str	r3, [r0], #4
+	add	r3, r3, #1 << 20
+	str	r3, [r0], #4
 1:
 #endif
 #endif
 #ifdef CONFIG_ARCH_RPC
-		/*
-		 * Map in screen at 0x02000000 & SCREEN2_BASE
-		 * Similar reasons here - for debug.  This is
-		 * only for Acorn RiscPC architectures.
-		 */
-		add	r0, r4, #0x80			@ 02000000
-		mov	r3, #0x02000000
-		orr	r3, r3, r8
-		str	r3, [r0]
-		add	r0, r4, #0x3600			@ d8000000
-		str	r3, [r0]
+	/*
+	 * Map in screen at 0x02000000 & SCREEN2_BASE
+	 * Similar reasons here - for debug.  This is
+	 * only for Acorn RiscPC architectures.
+	 */
+	add	r0, r4, #0x80			@ 02000000
+	mov	r3, #0x02000000
+	orr	r3, r3, r8
+	str	r3, [r0]
+	add	r0, r4, #0x3600			@ d8000000
+	str	r3, [r0]
 #endif
-		mov	pc, lr
+	mov	pc, lr
 
 
 
 /*
- * Exception handling.  Something went wrong and we can't
- * proceed.  We ought to tell the user, but since we
- * don't have any guarantee that we're even running on
- * the right architecture, we do virtually nothing.
+ * Exception handling.  Something went wrong and we can't proceed.  We
+ * ought to tell the user, but since we don't have any guarantee that
+ * we're even running on the right architecture, we do virtually nothing.
+ *
  * r0 = ascii error character:
  *	a = invalid architecture
  *	p = invalid processor
@@ -324,31 +282,32 @@
  */
 __error:
 #ifdef CONFIG_DEBUG_LL
-		mov	r8, r0				@ preserve r0
-		adr	r0, err_str
-		bl	printascii
-		mov	r0, r8
-		bl	printch
+	mov	r8, r0				@ preserve r0
+	adr	r0, err_str
+	bl	printascii
+	mov	r0, r8
+	bl	printch
 #endif
 #ifdef CONFIG_ARCH_RPC
 /*
  * Turn the screen red on a error - RiscPC only.
  */
-		mov	r0, #0x02000000
-		mov	r3, #0x11
-		orr	r3, r3, r3, lsl #8
-		orr	r3, r3, r3, lsl #16
-		str	r3, [r0], #4
-		str	r3, [r0], #4
-		str	r3, [r0], #4
-		str	r3, [r0], #4
+	mov	r0, #0x02000000
+	mov	r3, #0x11
+	orr	r3, r3, r3, lsl #8
+	orr	r3, r3, r3, lsl #16
+	str	r3, [r0], #4
+	str	r3, [r0], #4
+	str	r3, [r0], #4
+	str	r3, [r0], #4
 #endif
-1:		mov	r0, r0
-		b	1b
+1:	mov	r0, r0
+	b	1b
 
 #ifdef CONFIG_DEBUG_LL
-err_str:	.asciz	"\nError: "
-		.align
+err_str:
+	.asciz	"\nError: "
+	.align
 #endif
 
 /*
@@ -365,31 +324,31 @@
  *	r10 = pointer to processor structure
  */
 __lookup_processor_type:
-		adr	r5, 2f
-		ldmia	r5, {r7, r9, r10}
-		sub	r5, r5, r10			@ convert addresses
-		add	r7, r7, r5			@ to our address space
-		add	r10, r9, r5
-		mrc	p15, 0, r9, c0, c0		@ get processor id
-1:		ldmia	r10, {r5, r6, r8}		@ value, mask, mmuflags
-		and	r6, r6, r9			@ mask wanted bits
-		teq	r5, r6
-		moveq	pc, lr
-		add	r10, r10, #PROC_INFO_SZ		@ sizeof(proc_info_list)
-		cmp	r10, r7
-		blt	1b
-		mov	r10, #0				@ unknown processor
-		mov	pc, lr
+	adr	r5, 2f
+	ldmia	r5, {r7, r9, r10}
+	sub	r5, r5, r10			@ convert addresses
+	add	r7, r7, r5			@ to our address space
+	add	r10, r9, r5
+	mrc	p15, 0, r9, c0, c0		@ get processor id
+1:	ldmia	r10, {r5, r6, r8}		@ value, mask, mmuflags
+	and	r6, r6, r9			@ mask wanted bits
+	teq	r5, r6
+	moveq	pc, lr
+	add	r10, r10, #PROC_INFO_SZ		@ sizeof(proc_info_list)
+	cmp	r10, r7
+	blt	1b
+	mov	r10, #0				@ unknown processor
+	mov	pc, lr
 
 /*
  * Look in include/asm-arm/procinfo.h and arch/arm/kernel/arch.[ch] for
  * more information about the __proc_info and __arch_info structures.
  */
-2:		.long	__proc_info_end
-		.long	__proc_info_begin
-		.long	2b
-		.long	__arch_info_begin
-		.long	__arch_info_end
+2:	.long	__proc_info_end
+	.long	__proc_info_begin
+	.long	2b
+	.long	__arch_info_begin
+	.long	__arch_info_end
 
 /*
  * Lookup machine architecture in the linker-build list of architectures.
@@ -405,18 +364,18 @@
  *  r7 = byte offset into page tables for IO
  */
 __lookup_architecture_type:
-		adr	r4, 2b
-		ldmia	r4, {r2, r3, r5, r6, r7}	@ throw away r2, r3
-		sub	r5, r4, r5			@ convert addresses
-		add	r4, r6, r5			@ to our address space
-		add	r7, r7, r5
-1:		ldr	r5, [r4]			@ get machine type
-		teq	r5, r1
-		beq	2f
-		add	r4, r4, #SIZEOF_MACHINE_DESC
-		cmp	r4, r7
-		blt	1b
-		mov	r7, #0				@ unknown architecture
-		mov	pc, lr
-2:		ldmib	r4, {r5, r6, r7}		@ found, get results
-		mov	pc, lr
+	adr	r4, 2b
+	ldmia	r4, {r2, r3, r5, r6, r7}	@ throw away r2, r3
+	sub	r5, r4, r5			@ convert addresses
+	add	r4, r6, r5			@ to our address space
+	add	r7, r7, r5
+1:	ldr	r5, [r4]			@ get machine type
+	teq	r5, r1				@ matches loader number?
+	beq	2f				@ found
+	add	r4, r4, #SIZEOF_MACHINE_DESC	@ next machine_desc
+	cmp	r4, r7
+	blt	1b
+	mov	r7, #0				@ unknown architecture
+	mov	pc, lr
+2:	ldmib	r4, {r5, r6, r7}		@ found, get results
+	mov	pc, lr
diff -Nru a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
--- a/arch/arm/kernel/process.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/kernel/process.c	Fri May 24 18:55:35 2002
@@ -386,16 +386,16 @@
 	pid_t __ret;
 
 	__asm__ __volatile__(
-	"orr	r0, %1, %2	@ kernel_thread sys_clone
-	mov	r1, #0
-	"__syscall(clone)"
-	movs	%0, r0		@ if we are the child
-	bne	1f
-	mov	fp, #0		@ ensure that fp is zero
-	mov	r0, %4
-	mov	lr, pc
-	mov	pc, %3
-	b	sys_exit
+	"orr	r0, %1, %2	@ kernel_thread sys_clone	\n\
+	mov	r1, #0						\n\
+	"__syscall(clone)"					\n\
+	movs	%0, r0		@ if we are the child		\n\
+	bne	1f						\n\
+	mov	fp, #0		@ ensure that fp is zero	\n\
+	mov	r0, %4						\n\
+	mov	lr, pc						\n\
+	mov	pc, %3						\n\
+	b	sys_exit					\n\
 1:	"
         : "=r" (__ret)
         : "Ir" (flags), "I" (CLONE_VM), "r" (fn), "r" (arg)
diff -Nru a/arch/arm/kernel/semaphore.c b/arch/arm/kernel/semaphore.c
--- a/arch/arm/kernel/semaphore.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/kernel/semaphore.c	Fri May 24 18:55:35 2002
@@ -178,76 +178,76 @@
  * value in some cases..
  */
 #ifdef CONFIG_CPU_26
-asm("	.align	5
-	.globl	__down_failed
-__down_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down
-	ldmfd	sp!, {r0 - r3, pc}^
-
-	.align	5
-	.globl	__down_interruptible_failed
-__down_interruptible_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down_interruptible
-	mov	ip, r0
-	ldmfd	sp!, {r0 - r3, pc}^
-
-	.align	5
-	.globl	__down_trylock_failed
-__down_trylock_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down_trylock
-	mov	ip, r0
-	ldmfd	sp!, {r0 - r3, pc}^
-
-	.align	5
-	.globl	__up_wakeup
-__up_wakeup:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__up
-	ldmfd	sp!, {r0 - r3, pc}^
+asm("	.align	5				\n\
+	.globl	__down_failed			\n\
+__down_failed:					\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down				\n\
+	ldmfd	sp!, {r0 - r3, pc}^		\n\
+						\n\
+	.align	5				\n\
+	.globl	__down_interruptible_failed	\n\
+__down_interruptible_failed:			\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down_interruptible		\n\
+	mov	ip, r0				\n\
+	ldmfd	sp!, {r0 - r3, pc}^		\n\
+						\n\
+	.align	5				\n\
+	.globl	__down_trylock_failed		\n\
+__down_trylock_failed:				\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down_trylock			\n\
+	mov	ip, r0				\n\
+	ldmfd	sp!, {r0 - r3, pc}^		\n\
+						\n\
+	.align	5				\n\
+	.globl	__up_wakeup			\n\
+__up_wakeup:					\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__up				\n\
+	ldmfd	sp!, {r0 - r3, pc}^		\n\
 	");
 
 #else
 /* 32 bit version */
-asm("	.align	5
-	.globl	__down_failed
-__down_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down
-	ldmfd	sp!, {r0 - r3, pc}
-
-	.align	5
-	.globl	__down_interruptible_failed
-__down_interruptible_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down_interruptible
-	mov	ip, r0
-	ldmfd	sp!, {r0 - r3, pc}
-
-	.align	5
-	.globl	__down_trylock_failed
-__down_trylock_failed:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__down_trylock
-	mov	ip, r0
-	ldmfd	sp!, {r0 - r3, pc}
-
-	.align	5
-	.globl	__up_wakeup
-__up_wakeup:
-	stmfd	sp!, {r0 - r3, lr}
-	mov	r0, ip
-	bl	__up
-	ldmfd	sp!, {r0 - r3, pc}
+asm("	.align	5				\n\
+	.globl	__down_failed			\n\
+__down_failed:					\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down				\n\
+	ldmfd	sp!, {r0 - r3, pc}		\n\
+						\n\
+	.align	5				\n\
+	.globl	__down_interruptible_failed	\n\
+__down_interruptible_failed:			\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down_interruptible		\n\
+	mov	ip, r0				\n\
+	ldmfd	sp!, {r0 - r3, pc}		\n\
+						\n\
+	.align	5				\n\
+	.globl	__down_trylock_failed		\n\
+__down_trylock_failed:				\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__down_trylock			\n\
+	mov	ip, r0				\n\
+	ldmfd	sp!, {r0 - r3, pc}		\n\
+						\n\
+	.align	5				\n\
+	.globl	__up_wakeup			\n\
+__up_wakeup:					\n\
+	stmfd	sp!, {r0 - r3, lr}		\n\
+	mov	r0, ip				\n\
+	bl	__up				\n\
+	ldmfd	sp!, {r0 - r3, pc}		\n\
 	");
 
 #endif
diff -Nru a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
--- a/arch/arm/kernel/setup.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/kernel/setup.c	Fri May 24 18:55:33 2002
@@ -61,7 +61,6 @@
 extern int _stext, _text, _etext, _edata, _end;
 
 unsigned int processor_id;
-unsigned int compat;
 unsigned int __machine_arch_type;
 unsigned int system_rev;
 unsigned int system_serial_low;
@@ -289,11 +288,6 @@
 	}
 
 	printk("Machine: %s\n", list->name);
-	if (compat)
-		printk(KERN_WARNING "Using compatibility code "
-			"scheduled for removal in v%d.%d.%d\n",
-			compat >> 24, (compat >> 12) & 0x3ff,
-			compat & 0x3ff);
 
 	return list;
 }
diff -Nru a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
--- a/arch/arm/kernel/signal.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/kernel/signal.c	Fri May 24 18:55:33 2002
@@ -618,7 +618,7 @@
 				continue;
 
 			switch (signr) {
-			case SIGCONT: case SIGCHLD: case SIGWINCH:
+			case SIGCONT: case SIGCHLD: case SIGWINCH: case SIGURG:
 				continue;
 
 			case SIGTSTP: case SIGTTIN: case SIGTTOU:
diff -Nru a/arch/arm/kernel/via82c505.c b/arch/arm/kernel/via82c505.c
--- a/arch/arm/kernel/via82c505.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/kernel/via82c505.c	Fri May 24 18:55:33 2002
@@ -79,8 +79,15 @@
 	struct pci_bus *bus;
 
 	printk(KERN_DEBUG "PCI: VIA 82c505\n");
-	request_region(0xA8,2,"via config");
-	request_region(0xCF8,8,"pci config");
+	if (!request_region(0xA8,2,"via config")) {
+		printk(KERN_WARNING"VIA 82c505: Unable to request region 0xA8\n");
+		return;
+	}
+	if (!request_region(0xCF8,8,"pci config")) {
+		printk(KERN_WARNING"VIA 82c505: Unable to request region 0xCF8\n");
+		release_region(0xA8, 2);
+		return;
+	}
 
 	/* Enable compatible Mode */
 	outb(0x96,0xA8);
diff -Nru a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
--- a/arch/arm/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/arm/lib/Makefile	Fri May 24 18:55:33 2002
@@ -4,8 +4,6 @@
 # Copyright (C) 1995-2000 Russell King
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET	:= lib.a
 
 obj-y		:= backtrace.o changebit.o csumipv6.o csumpartial.o   \
diff -Nru a/arch/arm/lib/csumpartial.S b/arch/arm/lib/csumpartial.S
--- a/arch/arm/lib/csumpartial.S	Fri May 24 18:55:36 2002
+++ b/arch/arm/lib/csumpartial.S	Fri May 24 18:55:36 2002
@@ -49,7 +49,7 @@
 		/* we are now half-word aligned */
 
 .less8_wordlp:
-#ifdef __ARM_ARCH_4__
+#if __LINUX_ARM_ARCH__ >= 4
 		ldrh	td0, [buf], #2
 		sub	len, len, #2
 #else
@@ -83,7 +83,7 @@
 		adcnes	sum, sum, td0, lsl #byte(1)	@ update checksum
 
 		tst	buf, #2			@ 32-bit aligned?
-#ifdef __ARM_ARCH_4__
+#if __LINUX_ARM_ARCH__ >= 4
 		ldrneh	td0, [buf], #2		@ make 32-bit aligned
 		subne	len, len, #2
 #else
diff -Nru a/arch/arm/lib/longlong.h b/arch/arm/lib/longlong.h
--- a/arch/arm/lib/longlong.h	Fri May 24 18:55:34 2002
+++ b/arch/arm/lib/longlong.h	Fri May 24 18:55:34 2002
@@ -75,7 +75,7 @@
 
 #if defined (__arm__)
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
-  __asm__ ("adds	%1, %4, %5
+  __asm__ ("adds	%1, %4, %5					\n\
 	adc	%0, %2, %3"						\
 	   : "=r" ((USItype) (sh)),					\
 	     "=&r" ((USItype) (sl))					\
@@ -84,7 +84,7 @@
 	     "%r" ((USItype) (al)),					\
 	     "rI" ((USItype) (bl)))
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
-  __asm__ ("subs	%1, %4, %5
+  __asm__ ("subs	%1, %4, %5					\n\
 	sbc	%0, %2, %3"						\
 	   : "=r" ((USItype) (sh)),					\
 	     "=&r" ((USItype) (sl))					\
@@ -94,18 +94,18 @@
 	     "rI" ((USItype) (bl)))
 #define umul_ppmm(xh, xl, a, b) \
 {register USItype __t0, __t1, __t2;					\
-  __asm__ ("%@ Inlined umul_ppmm
-	mov	%2, %5, lsr #16
-	mov	%0, %6, lsr #16
-	bic	%3, %5, %2, lsl #16
-	bic	%4, %6, %0, lsl #16
-	mul	%1, %3, %4
-	mul	%4, %2, %4
-	mul	%3, %0, %3
-	mul	%0, %2, %0
-	adds	%3, %4, %3
-	addcs	%0, %0, #65536
-	adds	%1, %1, %3, lsl #16
+  __asm__ ("%@ Inlined umul_ppmm					\n\
+	mov	%2, %5, lsr #16						\n\
+	mov	%0, %6, lsr #16						\n\
+	bic	%3, %5, %2, lsl #16					\n\
+	bic	%4, %6, %0, lsl #16					\n\
+	mul	%1, %3, %4						\n\
+	mul	%4, %2, %4						\n\
+	mul	%3, %0, %3						\n\
+	mul	%0, %2, %0						\n\
+	adds	%3, %4, %3						\n\
+	addcs	%0, %0, #65536						\n\
+	adds	%1, %1, %3, lsl #16					\n\
 	adc	%0, %0, %3, lsr #16"					\
 	   : "=&r" ((USItype) (xh)),					\
 	     "=r" ((USItype) (xl)),					\
diff -Nru a/arch/arm/lib/muldi3.c b/arch/arm/lib/muldi3.c
--- a/arch/arm/lib/muldi3.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/lib/muldi3.c	Fri May 24 18:55:33 2002
@@ -33,18 +33,18 @@
 
 #define umul_ppmm(xh, xl, a, b) \
 {register USItype __t0, __t1, __t2;                                     \
-  __asm__ ("%@ Inlined umul_ppmm
-        mov     %2, %5, lsr #16
-        mov     %0, %6, lsr #16
-        bic     %3, %5, %2, lsl #16
-        bic     %4, %6, %0, lsl #16
-        mul     %1, %3, %4
-        mul     %4, %2, %4
-        mul     %3, %0, %3
-        mul     %0, %2, %0
-        adds    %3, %4, %3
-        addcs   %0, %0, #65536
-        adds    %1, %1, %3, lsl #16
+  __asm__ ("%@ Inlined umul_ppmm					\n\
+        mov     %2, %5, lsr #16						\n\
+        mov     %0, %6, lsr #16						\n\
+        bic     %3, %5, %2, lsl #16					\n\
+        bic     %4, %6, %0, lsl #16					\n\
+        mul     %1, %3, %4						\n\
+        mul     %4, %2, %4						\n\
+        mul     %3, %0, %3						\n\
+        mul     %0, %2, %0						\n\
+        adds    %3, %4, %3						\n\
+        addcs   %0, %0, #65536						\n\
+        adds    %1, %1, %3, lsl #16					\n\
         adc     %0, %0, %3, lsr #16"                                    \
            : "=&r" ((USItype) (xh)),                                    \
              "=r" ((USItype) (xl)),                                     \
diff -Nru a/arch/arm/mach-adifcc/Makefile b/arch/arm/mach-adifcc/Makefile
--- a/arch/arm/mach-adifcc/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/arm/mach-adifcc/Makefile	Fri May 24 18:55:33 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= adifcc.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-anakin/Makefile b/arch/arm/mach-anakin/Makefile
--- a/arch/arm/mach-anakin/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-anakin/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= anakin.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-arc/Makefile b/arch/arm/mach-arc/Makefile
--- a/arch/arm/mach-arc/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/arm/mach-arc/Makefile	Fri May 24 18:55:34 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= arc.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
--- a/arch/arm/mach-clps711x/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-clps711x/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= clps711x.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-clps7500/Makefile b/arch/arm/mach-clps7500/Makefile
--- a/arch/arm/mach-clps7500/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-clps7500/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= clps7500.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-ebsa110/Makefile b/arch/arm/mach-ebsa110/Makefile
--- a/arch/arm/mach-ebsa110/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-ebsa110/Makefile	Fri May 24 18:55:35 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= ebsa110.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-epxa10db/Makefile b/arch/arm/mach-epxa10db/Makefile
--- a/arch/arm/mach-epxa10db/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-epxa10db/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= epxa10db.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-footbridge/Makefile b/arch/arm/mach-footbridge/Makefile
--- a/arch/arm/mach-footbridge/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-footbridge/Makefile	Fri May 24 18:55:35 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= footbridge.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c
--- a/arch/arm/mach-footbridge/cats-pci.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/mach-footbridge/cats-pci.c	Fri May 24 18:55:33 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 /* cats host-specific stuff */
 static int irqmap_cats[] __initdata = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 };
@@ -34,7 +35,7 @@
  * why not the standard PCI swizzle?  does this prevent 4-port tulip
  * cards being used (ie, pci-pci bridge based cards)?
  */
-struct hw_pci cats_pci __initdata = {
+static struct hw_pci cats_pci __initdata = {
 	swizzle:		NULL,
 	map_irq:		cats_map_irq,
 	nr_controllers:		1,
@@ -43,3 +44,12 @@
 	preinit:		dc21285_preinit,
 	postinit:		dc21285_postinit,
 };
+
+static int cats_pci_init(void)
+{
+	if (machine_is_cats())
+		pci_common_init(&cats_pci);
+	return 0;
+}
+
+subsys_initcall(cats_pci_init);
diff -Nru a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
--- a/arch/arm/mach-footbridge/dc21285.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-footbridge/dc21285.c	Fri May 24 18:55:35 2002
@@ -1,7 +1,8 @@
 /*
  *  linux/arch/arm/kernel/dec21285.c: PCI functions for DC21285
  *
- *  Copyright (C) 1998-2000 Russell King, Phil Blundell
+ *  Copyright (C) 1998-2001 Russell King
+ *  Copyright (C) 1998-2000 Phil Blundell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -261,31 +262,45 @@
 	add_timer(timer);
 }
 
-void __init dc21285_setup_resources(struct resource **resource)
+int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 {
-	struct resource *busmem, *busmempf;
+	struct resource *res;
 
-	busmem = kmalloc(sizeof(*busmem), GFP_KERNEL);
-	busmempf = kmalloc(sizeof(*busmempf), GFP_KERNEL);
-	memset(busmem, 0, sizeof(*busmem));
-	memset(busmempf, 0, sizeof(*busmempf));
-
-	busmem->flags = IORESOURCE_MEM;
-	busmem->name  = "Footbridge non-prefetch";
-	busmempf->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
-	busmempf->name  = "Footbridge prefetch";
-
-	allocate_resource(&iomem_resource, busmempf, 0x20000000,
-			  0x80000000, 0xffffffff, 0x20000000, NULL, NULL);
-	allocate_resource(&iomem_resource, busmem, 0x40000000,
+	if (nr || !footbridge_cfn_mode())
+		return 0;
+
+	res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+	if (!res) {
+		printk("out of memory for root bus resources");
+		return 0;
+	}
+
+	memset(res, 0, sizeof(struct resource) * 2);
+
+	res[0].flags = IORESOURCE_MEM;
+	res[0].name  = "Footbridge non-prefetch";
+	res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
+	res[1].name  = "Footbridge prefetch";
+
+	allocate_resource(&iomem_resource, &res[1], 0x20000000,
+			  0xa0000000, 0xffffffff, 0x20000000, NULL, NULL);
+	allocate_resource(&iomem_resource, &res[0], 0x40000000,
 			  0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
 
-	resource[0] = &ioport_resource;
-	resource[1] = busmem;
-	resource[2] = busmempf;
+	sys->resource[0] = &ioport_resource;
+	sys->resource[1] = &res[0];
+	sys->resource[2] = &res[1];
+	sys->mem_offset  = DC21285_PCI_MEM;
+
+	return 1;
+}
+
+struct pci_bus * __init dc21285_scan_bus(int nr, struct pci_sys_data *sys)
+{
+	return pci_scan_bus(0, &dc21285_ops, sys);
 }
 
-void __init dc21285_init(void *sysdata)
+void __init dc21285_preinit(void)
 {
 	unsigned int mem_size, mem_mask;
 	int cfn_mode;
@@ -313,17 +328,13 @@
 		"central function" : "addin");
 
 	if (cfn_mode) {
-		static struct resource csrmem, csrio;
+		static struct resource csrio;
 
 		csrio.flags  = IORESOURCE_IO;
 		csrio.name   = "Footbridge";
-		csrmem.flags = IORESOURCE_MEM;
-		csrmem.name  = "Footbridge";
 
 		allocate_resource(&ioport_resource, &csrio, 128,
 				  0xff00, 0xffff, 128, NULL, NULL);
-		allocate_resource(&iomem_resource, &csrmem, 128,
-				  0xf4000000, 0xf8000000, 128, NULL, NULL);
 
 		/*
 		 * Map our SDRAM at a known address in PCI space, just in case
@@ -331,22 +342,12 @@
 		 * necessary, since some VGA cards forcefully use PCI addresses
 		 * in the range 0x000a0000 to 0x000c0000. (eg, S3 cards).
 		 */
-		*CSR_PCICSRBASE       = csrmem.start;
+		*CSR_PCICSRBASE       = 0xf4000000;
 		*CSR_PCICSRIOBASE     = csrio.start;
 		*CSR_PCISDRAMBASE     = __virt_to_bus(PAGE_OFFSET);
 		*CSR_PCIROMBASE       = 0;
 		*CSR_PCICMD = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
 			      PCI_COMMAND_INVALIDATE | PCICMD_ERROR_BITS;
-
-		pci_scan_bus(0, &dc21285_ops, sysdata);
-
-		/*
-		 * Clear any existing errors - we aren't
-		 * interested in historical data...
-		 */
-		*CSR_SA110_CNTL	= (*CSR_SA110_CNTL & 0xffffde07) |
-				  SA110_CNTL_RXSERR;
-		*CSR_PCICMD = (*CSR_PCICMD & 0xffff) | PCICMD_ERROR_BITS;
 	} else if (footbridge_cfn_mode() != 0) {
 		/*
 		 * If we are not compiled to accept "add-in" mode, then
@@ -356,6 +357,19 @@
 		 */
 		panic("PCI: this kernel is compiled for central "
 			"function mode only");
+	}
+}
+
+void __init dc21285_postinit(void)
+{
+	if (footbridge_cfn_mode()) {
+		/*
+		 * Clear any existing errors - we aren't
+		 * interested in historical data...
+		 */
+		*CSR_SA110_CNTL	= (*CSR_SA110_CNTL & 0xffffde07) |
+				  SA110_CNTL_RXSERR;
+		*CSR_PCICMD = (*CSR_PCICMD & 0xffff) | PCICMD_ERROR_BITS;
 	}
 
 	/*
diff -Nru a/arch/arm/mach-footbridge/ebsa285-pci.c b/arch/arm/mach-footbridge/ebsa285-pci.c
--- a/arch/arm/mach-footbridge/ebsa285-pci.c	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-footbridge/ebsa285-pci.c	Fri May 24 18:55:36 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 static int irqmap_ebsa285[] __initdata = { IRQ_IN3, IRQ_IN1, IRQ_IN0, IRQ_PCI };
 
@@ -27,7 +28,7 @@
 	return irqmap_ebsa285[(slot + pin) & 3];
 }
 
-struct hw_pci ebsa285_pci __initdata = {
+static struct hw_pci ebsa285_pci __initdata = {
 	swizzle:		pci_std_swizzle,
 	map_irq:		ebsa285_map_irq,
 	nr_controllers:		1,
@@ -36,3 +37,12 @@
 	preinit:		dc21285_preinit,
 	postinit:		dc21285_postinit,
 };
+
+static int __init ebsa285_init_pci(void)
+{
+	if (machine_is_ebsa285())
+		pci_common_init(&ebsa285_pci);
+	return 0;
+}
+
+subsys_initcall(ebsa285_init_pci);
diff -Nru a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
--- a/arch/arm/mach-footbridge/netwinder-pci.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/mach-footbridge/netwinder-pci.c	Fri May 24 18:55:33 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 /*
  * We now use the slot ID instead of the device identifiers to select
@@ -41,7 +42,7 @@
 	}
 }
 
-struct hw_pci netwinder_pci __initdata = {
+static struct hw_pci netwinder_pci __initdata = {
 	swizzle:		pci_std_swizzle,
 	map_irq:		netwinder_map_irq,
 	nr_controllers:		1,
@@ -50,3 +51,12 @@
 	preinit:		dc21285_preinit,
 	postinit:		dc21285_postinit,
 };
+
+static int __init netwinder_pci_init(void)
+{
+	if (machine_is_netwinder())
+		pci_common_init(&netwinder_pci);
+	return 0;
+}
+
+subsys_initcall(netwinder_pci_init);
diff -Nru a/arch/arm/mach-footbridge/personal-pci.c b/arch/arm/mach-footbridge/personal-pci.c
--- a/arch/arm/mach-footbridge/personal-pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-footbridge/personal-pci.c	Fri May 24 18:55:35 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 static int irqmap_personal_server[] __initdata = {
 	IRQ_IN0, IRQ_IN1, IRQ_IN2, IRQ_IN3, 0, 0, 0,
@@ -36,7 +37,7 @@
 		return irqmap_personal_server[(line - 1) & 3];
 }
 
-struct hw_pci personal_server_pci __initdata = {
+static struct hw_pci personal_server_pci __initdata = {
 	map_irq:		personal_server_map_irq,
 	nr_controllers:		1,
 	setup:			dc21285_setup,
@@ -44,3 +45,12 @@
 	preinit:		dc21285_preinit,
 	postinit:		dc21285_postinit,
 };
+
+static int __init personal_pci_init(void)
+{
+	if (machine_is_personal_server())
+		pci_common_init(&personal_server_pci);
+	return 0;
+}
+
+subsys_initcall(&personal_pci_init);
diff -Nru a/arch/arm/mach-ftvpci/Makefile b/arch/arm/mach-ftvpci/Makefile
--- a/arch/arm/mach-ftvpci/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-ftvpci/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= ftvpci.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-ftvpci/pci.c b/arch/arm/mach-ftvpci/pci.c
--- a/arch/arm/mach-ftvpci/pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-ftvpci/pci.c	Fri May 24 18:55:35 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 /*
  * Owing to a PCB cockup, issue A backplanes are wired thus:
@@ -43,9 +44,17 @@
 }
 
 /* ftv host-specific stuff */
-struct hw_pci ftv_pci __initdata = {
+static struct hw_pci ftv_pci __initdata = {
 	init:		plx90x0_init,
 	swizzle:	ftv_swizzle,
 	map_irq:	ftv_map_irq,
 };
 
+static int __init ftv_pci_init(void)
+{
+	if (machine_is_ftvpci())
+		pci_common_init(&ftv_pci);
+	return 0;
+}
+
+subsys_initcall(ftv_pci_init);
diff -Nru a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile
--- a/arch/arm/mach-integrator/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-integrator/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= integrator.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-integrator/pci.c b/arch/arm/mach-integrator/pci.c
--- a/arch/arm/mach-integrator/pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-integrator/pci.c	Fri May 24 18:55:35 2002
@@ -31,6 +31,7 @@
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 /* 
  * A small note about bridges and interrupts.  The DECchip 21050 (and
@@ -112,7 +113,7 @@
 
 extern void pci_v3_init(void *);
 
-struct hw_pci integrator_pci __initdata = {
+static struct hw_pci integrator_pci __initdata = {
 	swizzle:		integrator_swizzle,
 	map_irq:		integrator_map_irq,
 	setup:			pci_v3_setup,
@@ -121,3 +122,12 @@
 	preinit:		pci_v3_preinit,
 	postinit:		pci_v3_postinit,
 };
+
+static int __init integrator_pci_init(void)
+{
+	if (machine_is_integrator())
+		pci_common_init(&integrator_pci);
+	return 0;
+}
+
+subsys_initcall(integrator_pci_init);
diff -Nru a/arch/arm/mach-iop310/Makefile b/arch/arm/mach-iop310/Makefile
--- a/arch/arm/mach-iop310/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-iop310/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= iop310.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-iop310/iop310-pci.c b/arch/arm/mach-iop310/iop310-pci.c
--- a/arch/arm/mach-iop310/iop310-pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-iop310/iop310-pci.c	Fri May 24 18:55:35 2002
@@ -452,20 +452,24 @@
 		res[0].start = IOP310_PCIPRI_LOWER_IO + 0x6e000000;
 		res[0].end   = IOP310_PCIPRI_LOWER_IO + 0x6e00ffff;
 		res[0].name  = "PCI IO Primary";
+		res[0].flags = IORESOURCE_IO;
 
 		res[1].start = IOP310_PCIPRI_LOWER_MEM;
 		res[1].end   = IOP310_PCIPRI_LOWER_MEM + IOP310_PCI_WINDOW_SIZE;
 		res[1].name  = "PCI Memory Primary";
+		res[1].flags = IORESOURCE_MEM;
 		break;
 
 	case 1:
 		res[0].start = IOP310_PCISEC_LOWER_IO + 0x6e000000;
 		res[0].end   = IOP310_PCISEC_LOWER_IO + 0x6e00ffff;
 		res[0].name  = "PCI IO Secondary";
+		res[0].flags = IORESOURCE_IO;
 
 		res[1].start = IOP310_PCISEC_LOWER_MEM;
 		res[1].end   = IOP310_PCISEC_LOWER_MEM + IOP310_PCI_WINDOW_SIZE;
 		res[1].name  = "PCI Memory Secondary";
+		res[1].flags = IORESOURCE_MEM;
 		break;
 	}
 
diff -Nru a/arch/arm/mach-iop310/iq80310-pci.c b/arch/arm/mach-iop310/iq80310-pci.c
--- a/arch/arm/mach-iop310/iq80310-pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-iop310/iq80310-pci.c	Fri May 24 18:55:35 2002
@@ -18,6 +18,7 @@
 #include <asm/hardware.h>
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 /*
  * The following macro is used to lookup irqs in a standard table
@@ -140,10 +141,19 @@
 	iop310_init();
 }
 
-struct hw_pci iq80310_pci __initdata = {
+static struct hw_pci iq80310_pci __initdata = {
 	swizzle:	pci_std_swizzle,
 	nr_controllers:	2,
 	setup:		iq80310_setup,
 	scan:		iop310_scan_bus,
 	preinit:	iq80310_preinit,
 };
+
+static int __init iq80310_pci_init(void)
+{
+	if (machine_is_iq80310())
+		pci_common_init(&iq80310_pci);
+	return 0;
+}
+
+subsys_initcall(iq80310_pci_init);
diff -Nru a/arch/arm/mach-l7200/Makefile b/arch/arm/mach-l7200/Makefile
--- a/arch/arm/mach-l7200/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-l7200/Makefile	Fri May 24 18:55:35 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= l7200.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
--- a/arch/arm/mach-pxa/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-pxa/Makefile	Fri May 24 18:55:36 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= pxa.o
 
 obj-y :=
diff -Nru a/arch/arm/mach-rpc/Makefile b/arch/arm/mach-rpc/Makefile
--- a/arch/arm/mach-rpc/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-rpc/Makefile	Fri May 24 18:55:35 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= rpc.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c
--- a/arch/arm/mach-rpc/dma.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-rpc/dma.c	Fri May 24 18:55:35 2002
@@ -33,10 +33,6 @@
 	dma_size_32	= 4,
 	dma_size_128	= 16
 } dma_size_t;
-
-typedef struct {
-	dma_size_t	transfersize;
-} dma_t;
 #endif
 
 #define TRANSFER_SIZE	2
@@ -48,10 +44,6 @@
 #define CR	(IOMD_IO0CR - IOMD_IO0CURA)
 #define ST	(IOMD_IO0ST - IOMD_IO0CURA)
 
-#define state_prog_a	0
-#define state_wait_a	1
-#define state_wait_b	2
-
 static void iomd_get_next_sg(struct scatterlist *sg, dma_t *dma)
 {
 	unsigned long end, offset, flags = 0;
@@ -91,76 +83,40 @@
 	sg->length |= flags;
 }
 
-static inline void iomd_setup_dma_a(struct scatterlist *sg, dma_t *dma)
-{
-	iomd_writel(sg->dma_address, dma->dma_base + CURA);
-	iomd_writel(sg->length, dma->dma_base + ENDA);
-}
-
-static inline void iomd_setup_dma_b(struct scatterlist *sg, dma_t *dma)
-{
-	iomd_writel(sg->dma_address, dma->dma_base + CURB);
-	iomd_writel(sg->length, dma->dma_base + ENDB);
-}
-
 static void iomd_dma_handle(int irq, void *dev_id, struct pt_regs *regs)
 {
 	dma_t *dma = (dma_t *)dev_id;
-	unsigned int status = 0, no_buffer = dma->sg == NULL;
+	unsigned long base = dma->dma_base;
 
 	do {
-		switch (dma->state) {
-		case state_prog_a:
-			iomd_get_next_sg(&dma->cur_sg, dma);
-			iomd_setup_dma_a(&dma->cur_sg, dma);
-			dma->state = state_wait_a;
-
-		case state_wait_a:
-			status = iomd_readb(dma->dma_base + ST);
-			switch (status & (DMA_ST_OFL|DMA_ST_INT|DMA_ST_AB)) {
-			case DMA_ST_OFL|DMA_ST_INT:
-				iomd_get_next_sg(&dma->cur_sg, dma);
-				iomd_setup_dma_a(&dma->cur_sg, dma);
-				break;
-
-			case DMA_ST_INT:
-				iomd_get_next_sg(&dma->cur_sg, dma);
-				iomd_setup_dma_b(&dma->cur_sg, dma);
-				dma->state = state_wait_b;
-				break;
-
-			case DMA_ST_OFL|DMA_ST_INT|DMA_ST_AB:
-				iomd_setup_dma_b(&dma->cur_sg, dma);
-				dma->state = state_wait_b;
-				break;
-			}
+		unsigned int status;
+
+		status = iomd_readb(base + ST);
+		if (!(status & DMA_ST_INT))
+			return;
+
+		if (status & DMA_ST_OFL && !dma->sg)
 			break;
 
-		case state_wait_b:
-			status = iomd_readb(dma->dma_base + ST);
-			switch (status & (DMA_ST_OFL|DMA_ST_INT|DMA_ST_AB)) {
-			case DMA_ST_OFL|DMA_ST_INT|DMA_ST_AB:
-				iomd_get_next_sg(&dma->cur_sg, dma);
-				iomd_setup_dma_b(&dma->cur_sg, dma);
-				break;
-
-			case DMA_ST_INT|DMA_ST_AB:
-				iomd_get_next_sg(&dma->cur_sg, dma);
-				iomd_setup_dma_a(&dma->cur_sg, dma);
-				dma->state = state_wait_a;
-				break;
-
-			case DMA_ST_OFL|DMA_ST_INT:
-				iomd_setup_dma_a(&dma->cur_sg, dma);
-				dma->state = state_wait_a;
-				break;
-			}
+		iomd_get_next_sg(&dma->cur_sg, dma);
+
+		switch (status & (DMA_ST_OFL | DMA_ST_AB)) {
+		case DMA_ST_OFL:			/* OIA */
+		case DMA_ST_AB:				/* .IB */
+			iomd_writel(dma->cur_sg.dma_address, base + CURA);
+			iomd_writel(dma->cur_sg.length, base + ENDA);
+			break;
+
+		case DMA_ST_OFL | DMA_ST_AB:		/* OIB */
+		case 0:					/* .IA */
+			iomd_writel(dma->cur_sg.dma_address, base + CURB);
+			iomd_writel(dma->cur_sg.length, base + ENDB);
 			break;
 		}
-	} while (dma->sg && (status & DMA_ST_INT));
+	} while (1);
 
-	if (no_buffer)
-		disable_irq(irq);
+	iomd_writeb(0, dma->dma_base + CR);
+	disable_irq(irq);
 }
 
 static int iomd_request_dma(dmach_t channel, dma_t *dma)
@@ -194,7 +150,6 @@
 		}
 
 		iomd_writeb(DMA_CR_C, dma_base + CR);
-		dma->state = state_prog_a;
 	}
 		
 	if (dma->dma_mode == DMA_MODE_READ)
@@ -207,11 +162,15 @@
 static void iomd_disable_dma(dmach_t channel, dma_t *dma)
 {
 	unsigned long dma_base = dma->dma_base;
+	unsigned long flags;
 	unsigned int ctrl;
 
-	disable_irq(dma->dma_irq);
+	local_irq_save(flags);
 	ctrl = iomd_readb(dma_base + CR);
+	if (ctrl & DMA_CR_E)
+		disable_irq(dma->dma_irq);
 	iomd_writeb(ctrl & ~DMA_CR_E, dma_base + CR);
+	local_irq_restore(flags);
 }
 
 static int iomd_set_dma_speed(dmach_t channel, dma_t *dma, int cycle)
diff -Nru a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
--- a/arch/arm/mach-sa1100/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/arm/mach-sa1100/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for the linux kernel.
 #
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= sa1100.o
 
 # Common support (must be linked before board specific support)
diff -Nru a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
--- a/arch/arm/mach-sa1100/badge4.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/mach-sa1100/badge4.c	Fri May 24 18:55:33 2002
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/tty.h>
 #include <linux/errno.h>
diff -Nru a/arch/arm/mach-shark/Makefile b/arch/arm/mach-shark/Makefile
--- a/arch/arm/mach-shark/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/arm/mach-shark/Makefile	Fri May 24 18:55:33 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= shark.o
 
 # Object file lists.
diff -Nru a/arch/arm/mach-shark/pci.c b/arch/arm/mach-shark/pci.c
--- a/arch/arm/mach-shark/pci.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/mach-shark/pci.c	Fri May 24 18:55:35 2002
@@ -11,6 +11,7 @@
 
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
+#include <asm/mach-types.h>
 
 static int __init shark_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
@@ -22,7 +23,7 @@
 
 extern void __init via82c505_preinit(void *sysdata);
 
-struct hw_pci shark_pci __initdata = {
+static struct hw_pci shark_pci __initdata = {
 	setup:		via82c505_setup,
 	swizzle:       	pci_std_swizzle,
 	map_irq:	shark_map_irq,
@@ -30,3 +31,12 @@
 	scan:		via82c505_scan_bus,
 	preinit:	via82c505_preinit
 };
+
+static int __init shark_pci_init(void)
+{
+	if (machine_is_shark())
+		pci_common_init(&shark_pci);
+	return 0;
+}
+
+subsys_initcall(shark_pci_init);
diff -Nru a/arch/arm/mach-tbox/Makefile b/arch/arm/mach-tbox/Makefile
--- a/arch/arm/mach-tbox/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/arm/mach-tbox/Makefile	Fri May 24 18:55:34 2002
@@ -5,8 +5,6 @@
 # removes any old dependencies. DON'T put your own dependencies here
 # unless it's something special (ie not a .c file).
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= tbox.o
 
 # Object file lists.
diff -Nru a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
--- a/arch/arm/mm/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/arm/mm/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET	:= mm.o
 
 # Object file lists.
diff -Nru a/arch/arm/mm/abort-lv4t.S b/arch/arm/mm/abort-lv4t.S
--- a/arch/arm/mm/abort-lv4t.S	Fri May 24 18:55:36 2002
+++ b/arch/arm/mm/abort-lv4t.S	Fri May 24 18:55:36 2002
@@ -66,8 +66,8 @@
 	add	r6, r6, r2, lsr #3
 	add	r6, r6, r6, lsr #8
 	add	r6, r6, r6, lsr #4
-	and	r6, r6, #15			@ r7 = no. of registers to transfer.
-	and	r5, r8, #15 << 16		@ Extract 'n' form instruction
+	and	r6, r6, #15			@ r6 = no. of registers to transfer.
+	and	r5, r8, #15 << 16		@ Extract 'n' from instruction
 	ldr	r7, [sp, r5, lsr #14]		@ Get register 'Rn'
 	tst	r8, #1 << 23			@ Check U bit
 	subne	r7, r7, r6, lsl #2		@ Undo increment
diff -Nru a/arch/arm/mm/fault-common.c b/arch/arm/mm/fault-common.c
--- a/arch/arm/mm/fault-common.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/mm/fault-common.c	Fri May 24 18:55:33 2002
@@ -339,8 +339,7 @@
 int do_translation_fault(unsigned long addr, int error_code, struct pt_regs *regs)
 {
 	struct task_struct *tsk;
-	struct mm_struct *mm;
-	int offset;
+	unsigned int offset;
 	pgd_t *pgd, *pgd_k;
 	pmd_t *pmd, *pmd_k;
 
@@ -349,16 +348,17 @@
 
 	offset = __pgd_offset(addr);
 
+	/*
+	 * FIXME: CP15 C1 is write only on ARMv3 architectures.
+	 */
 	pgd = cpu_get_pgd() + offset;
 	pgd_k = init_mm.pgd + offset;
 
 	if (pgd_none(*pgd_k))
 		goto bad_area;
 
-#if 0	/* note that we are two-level */
 	if (!pgd_present(*pgd))
 		set_pgd(pgd, *pgd_k);
-#endif
 
 	pmd_k = pmd_offset(pgd_k, addr);
 	pmd   = pmd_offset(pgd, addr);
@@ -371,8 +371,7 @@
 
 bad_area:
 	tsk = current;
-	mm  = tsk->active_mm;
 
-	do_bad_area(tsk, mm, addr, error_code, regs);
+	do_bad_area(tsk, tsk->active_mm, addr, error_code, regs);
 	return 0;
 }
diff -Nru a/arch/arm/mm/init.c b/arch/arm/mm/init.c
--- a/arch/arm/mm/init.c	Fri May 24 18:55:33 2002
+++ b/arch/arm/mm/init.c	Fri May 24 18:55:33 2002
@@ -100,7 +100,6 @@
 	printk("%d slab pages\n", slab);
 	printk("%d pages shared\n", shared);
 	printk("%d pages swap cached\n", cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 struct node_info {
@@ -244,6 +243,7 @@
 	 * also get rid of some of the stuff above as well.
 	 */
 	max_low_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
+	max_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
 	mi->end = memend_pfn << PAGE_SHIFT;
 
 	return bootmem_pages;
diff -Nru a/arch/arm/nwfpe/Makefile b/arch/arm/nwfpe/Makefile
--- a/arch/arm/nwfpe/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/arm/nwfpe/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Copyright (C) 1998, 1999, 2001 Philip Blundell
 #
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET		:= math-emu.o
 
 obj-y			:=
diff -Nru a/arch/arm/nwfpe/softfloat.c b/arch/arm/nwfpe/softfloat.c
--- a/arch/arm/nwfpe/softfloat.c	Fri May 24 18:55:35 2002
+++ b/arch/arm/nwfpe/softfloat.c	Fri May 24 18:55:35 2002
@@ -184,9 +184,9 @@
 {
 #if 0
    float32 f;
-   __asm__("@ packFloat32;
-   	    mov %0, %1, asl #31;
-   	    orr %0, %2, asl #23;
+   __asm__("@ packFloat32;		\n\
+   	    mov %0, %1, asl #31;	\n\
+   	    orr %0, %2, asl #23;	\n\
    	    orr %0, %3"
    	    : /* no outputs */
    	    : "g" (f), "g" (zSign), "g" (zExp), "g" (zSig)
diff -Nru a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
--- a/arch/arm/tools/mach-types	Fri May 24 18:55:35 2002
+++ b/arch/arm/tools/mach-types	Fri May 24 18:55:35 2002
@@ -6,7 +6,7 @@
 # To add an entry into this database, please see Documentation/arm/README,
 # or contact rmk@arm.linux.org.uk
 #
-# Last update: Fri Mar 29 15:51:20 2002
+# Last update: Tue May 21 14:19:05 2002
 #
 # machine_is_xxx	CONFIG_xxxx		MACH_TYPE_xxx		number
 #
@@ -149,7 +149,7 @@
 blue_v1			ARCH_BLUE_V1		BLUE_V1			138
 pxa_cerf		ARCH_PXA_CERF		PXA_CERF		139
 arm7tevb		ARCH_ARM7TEVB		ARM7TEVB		140
-d7400			ARCH_D7400		D7400			141
+d7400			SA1100_D7400		D7400			141
 piranha			ARCH_PIRANHA		PIRANHA			142
 sbcamelot		SA1100_SBCAMELOT	SBCAMELOT		143
 kings			SA1100_KINGS		KINGS			144
@@ -180,3 +180,15 @@
 iq80321			ARCH_IQ80321		IQ80321			169
 wid			SA1100_WID		WID			170
 sabinal			ARCH_SABINAL		SABINAL			171
+ixp425_matacumbe	ARCH_IXP425_MATACUMBE	IXP425_MATACUMBE	172
+miniprint		SA1100_MINIPRINT	MINIPRINT		173
+adm510x			ARCH_ADM510X		ADM510X			174
+svs200			SA1100_SVS200		SVS200			175
+atg_tcu			ARCH_ATG_TCU		ATG_TCU			176
+jornada820		SA1100_JORNADA820	JORNADA820		177
+s3c44b0			ARCH_S3C44B0		S3C44B0			178
+margis2			ARCH_MARGIS2		MARGIS2			179
+ks8695			ARCH_KS8695		KS8695			180
+brh			ARCH_BRH		BRH			181
+s3c2410			ARCH_S3C2410		S3C2410			182
+possio_px30		ARCH_POSSIO_PX30	POSSIO_PX30		183
diff -Nru a/arch/cris/defconfig b/arch/cris/defconfig
--- a/arch/cris/defconfig	Fri May 24 18:55:34 2002
+++ b/arch/cris/defconfig	Fri May 24 18:55:34 2002
@@ -257,15 +257,6 @@
 # CONFIG_BLK_DEV_HD is not set
 # CONFIG_BLK_DEV_IDEDISK is not set
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -276,7 +267,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/cris/drivers/Config.in b/arch/cris/drivers/Config.in
--- a/arch/cris/drivers/Config.in	Fri May 24 18:55:34 2002
+++ b/arch/cris/drivers/Config.in	Fri May 24 18:55:34 2002
@@ -118,7 +118,6 @@
 	define_bool CONFIG_BLK_DEV_IDECD y
 
 	define_bool CONFIG_BLK_DEV_IDEDMA y
-	define_bool CONFIG_DMA_NONPCI y
 	
 	int 'Delay for drives to regain consciousness' CONFIG_ETRAX_IDE_DELAY 15
 	
diff -Nru a/arch/cris/drivers/ide.c b/arch/cris/drivers/ide.c
--- a/arch/cris/drivers/ide.c	Fri May 24 18:55:34 2002
+++ b/arch/cris/drivers/ide.c	Fri May 24 18:55:34 2002
@@ -192,7 +192,7 @@
 #define ATA_PIO0_HOLD    4
 
 static int e100_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq);
-static void e100_ideproc (ide_ide_action_t func, ide_drive_t *drive,
+static void e100_ideproc (ide_ide_action_t func, struct ata_device *drive,
 			  void *buffer, unsigned int length);
 
 /*
@@ -206,7 +206,7 @@
 				 "CONNER CTT8000-A",
 				 NULL};
 
-static void tune_e100_ide(ide_drive_t *drive, byte pio)
+static void tune_e100_ide(struct ata_device *drive, byte pio)
 {
 	unsigned long flags;
 	
@@ -380,7 +380,7 @@
  * extra byte allocated for the buffer.
  */
 static void
-e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
+e100_atapi_read(struct ata_device *drive, void *buffer, unsigned int bytecount)
 {
 	ide_ioreg_t data_reg = IDE_DATA_REG;
 
@@ -459,7 +459,7 @@
 }
 
 static void
-e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
+e100_atapi_write(struct ata_device *drive, void *buffer, unsigned int bytecount)
 {
 	ide_ioreg_t data_reg = IDE_DATA_REG;
 	
@@ -546,7 +546,7 @@
  * This is used for most PIO data transfers *from* the IDE interface
  */
 static void 
-e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+e100_ide_input_data (struct ata_device *drive, void *buffer, unsigned int wcount)
 {
 	e100_atapi_read(drive, buffer, wcount << 2);
 }
@@ -555,7 +555,7 @@
  * This is used for most PIO data transfers *to* the IDE interface
  */
 static void
-e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+e100_ide_output_data (struct ata_device *drive, void *buffer, unsigned int wcount)
 {
 	e100_atapi_write(drive, buffer, wcount << 2);
 }
@@ -661,7 +661,7 @@
 	return 1;	/* let the PIO routines handle this weirdness */
 }
 
-static int config_drive_for_dma (ide_drive_t *drive)
+static int config_drive_for_dma (struct ata_device *drive)
 {
         const char **list;
         struct hd_driveid *id = drive->id;
diff -Nru a/arch/cris/kernel/Makefile b/arch/cris/kernel/Makefile
--- a/arch/cris/kernel/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/cris/kernel/Makefile	Fri May 24 18:55:33 2002
@@ -8,8 +8,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 all: kernel.o head.o
 
 O_TARGET := kernel.o
diff -Nru a/arch/cris/lib/Makefile b/arch/cris/lib/Makefile
--- a/arch/cris/lib/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/cris/lib/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for Etrax-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := -traditional
diff -Nru a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
--- a/arch/cris/mm/fault.c	Fri May 24 18:55:34 2002
+++ b/arch/cris/mm/fault.c	Fri May 24 18:55:35 2002
@@ -440,7 +440,7 @@
 	 * Send a sigbus, regardless of whether we were in kernel
 	 * or user mode.
 	 */
-	info.si_code = SIGBUS;
+	info.si_signo = SIGBUS;
 	info.si_errno = 0;
 	info.si_code = BUS_ADRERR;
 	info.si_addr = (void *)address;
diff -Nru a/arch/cris/mm/init.c b/arch/cris/mm/init.c
--- a/arch/cris/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/cris/mm/init.c	Fri May 24 18:55:35 2002
@@ -181,7 +181,6 @@
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
 	printk("%ld pages in page table cache\n",pgtable_cache_size);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /*
diff -Nru a/arch/i386/Config.help b/arch/i386/Config.help
--- a/arch/i386/Config.help	Fri May 24 18:55:33 2002
+++ b/arch/i386/Config.help	Fri May 24 18:55:33 2002
@@ -940,3 +940,28 @@
 CONFIG_DEBUG_OBSOLETE
   Say Y here if you want to reduce the chances of the tree compiling,
   and are prepared to dig into driver internals to fix compile errors.
+
+Software Suspend
+CONFIG_SOFTWARE_SUSPEND
+  Enable the possibilty of suspendig machine. It doesn't need APM.
+  You may suspend your machine by either pressing Sysrq-d or with
+  'swsusp' or 'shutdown -z <time>' (patch for sysvinit needed). It
+  creates an image which is saved in your active swaps. By the next
+  booting the kernel detects the saved image, restores the memory from
+  it and then it continues to run as before you've suspended.
+  If you don't want the previous state to continue use the 'noresume'
+  kernel option. However note that your partitions will be fsck'd and
+  you must re-mkswap your swap partitions/files.
+
+  Right now you may boot without resuming and then later resume but
+  in meantime you cannot use those swap partitions/files which were
+  involved in suspending. Also in this case there is a risk that buffers
+  on disk won't match with saved ones.
+
+  SMP is supported ``as-is''. There's a code for it but doesn't work.
+  There have been problems reported relating SCSI.
+  
+  This option is about getting stable. However there is still some
+  absence of features.
+
+  For more information take a look at Documentation/swsusp.txt.
diff -Nru a/arch/i386/boot/video.S b/arch/i386/boot/video.S
--- a/arch/i386/boot/video.S	Fri May 24 18:55:34 2002
+++ b/arch/i386/boot/video.S	Fri May 24 18:55:34 2002
@@ -438,6 +438,7 @@
 
 # Setting of user mode (AX=mode ID) => CF=success
 mode_set:
+	movw	%ax, %fs:(0x01fa)		# Store mode for use in acpi_wakeup.S
 	movw	%ax, %bx
 	cmpb	$0xff, %ah
 	jz	setalias
diff -Nru a/arch/i386/config.in b/arch/i386/config.in
--- a/arch/i386/config.in	Fri May 24 18:55:34 2002
+++ b/arch/i386/config.in	Fri May 24 18:55:34 2002
@@ -396,6 +396,9 @@
 
 mainmenu_option next_comment
 comment 'Kernel hacking'
+if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+   dep_bool 'Software Suspend' CONFIG_SOFTWARE_SUSPEND $CONFIG_PM
+fi
 
 bool 'Kernel debugging' CONFIG_DEBUG_KERNEL
 if [ "$CONFIG_DEBUG_KERNEL" != "n" ]; then
diff -Nru a/arch/i386/defconfig b/arch/i386/defconfig
--- a/arch/i386/defconfig	Fri May 24 18:55:33 2002
+++ b/arch/i386/defconfig	Fri May 24 18:55:33 2002
@@ -119,6 +119,7 @@
 CONFIG_BINFMT_MISC=y
 CONFIG_PM=y
 # CONFIG_APM is not set
+# CONFIG_SOFTWARE_SUSPEND is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -232,15 +233,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -285,7 +277,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_IVB is not set
 CONFIG_IDEDMA_AUTO=y
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
 # CONFIG_BLK_DEV_ATARAID_HPT is not set
diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
--- a/arch/i386/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/i386/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -8,7 +8,6 @@
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
 EXTRA_AFLAGS	:= -traditional
-USE_STANDARD_AS_RULE	:= true
 
 all: kernel.o head.o init_task.o
 
diff -Nru a/arch/i386/kernel/acpi.c b/arch/i386/kernel/acpi.c
--- a/arch/i386/kernel/acpi.c	Fri May 24 18:55:36 2002
+++ b/arch/i386/kernel/acpi.c	Fri May 24 18:55:36 2002
@@ -44,6 +44,8 @@
 #include <asm/pgalloc.h>
 #include <asm/io_apic.h>
 #include <asm/tlbflush.h>
+#define ACPI_C
+#include <asm/suspend.h>
 
 
 #define PREFIX			"ACPI: "
@@ -621,6 +623,34 @@
 {
 	acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
 	printk(KERN_DEBUG "ACPI: have wakeup address 0x%8.8lx\n", acpi_wakeup_address);
+}
+
+/*
+ * (KG): Since we affect stack here, we make this function as flat and easy
+ * as possible in order to not provoke gcc to use local variables on the stack.
+ * Note that on resume, all (expect nosave) variables will have the state from
+ * the time of writing (suspend_save_image) and the registers (including the
+ * stack pointer, but excluding the instruction pointer) will be loaded with 
+ * the values saved at save_processor_context() time.
+ */
+void do_suspend_magic(int resume)
+{
+	/* DANGER WILL ROBINSON!
+	 *
+	 * If this function is too difficult for gcc to optimize, it will crash and burn!
+	 * see above.
+	 *
+	 * DO NOT TOUCH.
+	 */
+	if (!resume) {
+		save_processor_context();
+		acpi_save_register_state((unsigned long)&&acpi_sleep_done);
+		acpi_enter_sleep_state(3);
+		return;
+	}
+acpi_sleep_done:
+	restore_processor_context();
+	printk("CPU context restored...\n");
 }
 
 #endif /*CONFIG_ACPI_SLEEP*/
diff -Nru a/arch/i386/kernel/acpi_wakeup.S b/arch/i386/kernel/acpi_wakeup.S
--- a/arch/i386/kernel/acpi_wakeup.S	Fri May 24 18:55:34 2002
+++ b/arch/i386/kernel/acpi_wakeup.S	Fri May 24 18:55:34 2002
@@ -3,6 +3,7 @@
 #include <linux/linkage.h>
 #include <asm/segment.h>
 
+# Do we need to deal with A20?
 
 ALIGN
 wakeup_start:
@@ -10,9 +11,12 @@
 	wakeup_code_start = .
 	.code16
 
+ 	movw	$0xb800, %ax
+	movw	%ax,%fs
+	movw	$0x0e00 + 'L', %fs:(0x10)
 	cli
 	cld
-
+	  
 	# setup data segment
 	movw	%cs, %ax
 
@@ -20,6 +24,14 @@
 	movw	%ax, %ds
 	movw	%ax, %ss
 	mov	$(wakeup_stack - wakeup_data), %sp		# Private stack is needed for ASUS board
+	movw	$0x0e00 + 'S', %fs:(0x12)	
+
+	movl	real_magic - wakeup_data, %eax
+	cmpl	$0x12345678, %eax
+	jne	bogus_real_magic
+
+	mov	video_mode - wakeup_data, %ax
+	call	mode_set
 
 	# set up page table
 	movl	(real_save_cr3 - wakeup_data), %eax
@@ -28,40 +40,114 @@
 	# make sure %cr4 is set correctly (features, etc)
 	movl	(real_save_cr4 - wakeup_data), %eax
 	movl	%eax, %cr4
+	movw	$0xb800, %ax
+	movw	%ax,%fs
+	movw	$0x0e00 + 'i', %fs:(0x12)
 
 	# need a gdt
 	lgdt	real_save_gdt - wakeup_data
 
-	movl	%cr0, %eax
-	orl     $0x80000001, %eax
+	movl	(real_save_cr0 - wakeup_data), %eax
 	movl	%eax, %cr0
+	movw	$0x0e00 + 'n', %fs:(0x14)
+
+	movl	real_magic - wakeup_data, %eax
+	cmpl	$0x12345678, %eax
+	jne	bogus_real_magic
 
 	ljmpl	$__KERNEL_CS,$wakeup_pmode_return
 
+bogus_real_magic:
+	movw	$0x0e00 + 'B', %fs:(0x12)
+	jmp bogus_real_magic
+
+/* This code uses an extended set of video mode numbers. These include:
+ * Aliases for standard modes
+ *	NORMAL_VGA (-1)
+ *	EXTENDED_VGA (-2)
+ *	ASK_VGA (-3)
+ * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
+ * of compatibility when extending the table. These are between 0x00 and 0xff.
+ */
+#define VIDEO_FIRST_MENU 0x0000
+
+/* Standard BIOS video modes (BIOS number + 0x0100) */
+#define VIDEO_FIRST_BIOS 0x0100
+
+/* VESA BIOS video modes (VESA number + 0x0200) */
+#define VIDEO_FIRST_VESA 0x0200
+
+/* Video7 special modes (BIOS number + 0x0900) */
+#define VIDEO_FIRST_V7 0x0900
+
+# Setting of user mode (AX=mode ID) => CF=success
+mode_set:
+	movw	%ax, %bx
+#if 0
+	cmpb	$0xff, %ah
+	jz	setalias
+
+	testb	$VIDEO_RECALC>>8, %ah
+	jnz	_setrec
+
+	cmpb	$VIDEO_FIRST_RESOLUTION>>8, %ah
+	jnc	setres
+	
+	cmpb	$VIDEO_FIRST_SPECIAL>>8, %ah
+	jz	setspc
+
+	cmpb	$VIDEO_FIRST_V7>>8, %ah
+	jz	setv7
+#endif
+	
+	cmpb	$VIDEO_FIRST_VESA>>8, %ah
+	jnc	check_vesa
+#if 0	
+	orb	%ah, %ah
+	jz	setmenu
+#endif
+	
+	decb	%ah
+#	jz	setbios				  Add bios modes later
+
+setbad:	clc
+	ret
+
+check_vesa:
+	subb	$VIDEO_FIRST_VESA>>8, %bh
+	orw	$0x4000, %bx			# Use linear frame buffer
+	movw	$0x4f02, %ax			# VESA BIOS mode set call
+	int	$0x10
+	cmpw	$0x004f, %ax			# AL=4f if implemented
+	jnz	_setbad				# AH=0 if OK
+
+	stc
+	ret
+
+_setbad: jmp setbad
+
 	.code32
 	ALIGN
 
-.org	0x100
+.org	0x300
 wakeup_data:
 		.word 0
 real_save_gdt:	.word 0
 		.long 0
+real_save_cr0:	.long 0
 real_save_cr3:	.long 0
 real_save_cr4:	.long 0
+real_magic:	.long 0
+video_mode:	.long 0
 
-.org	0x300
+.org	0x500
 wakeup_stack:
 wakeup_end:
 
 wakeup_pmode_return:
-	# restore data segment
 	movl	$__KERNEL_DS, %eax
-	movw	%ax, %ds
-	movw	%ax, %es
-
-	# and restore the stack
-	movw	%ax, %ss
-	movl	saved_esp, %esp
+	movl	%eax, %ds
+	movw	$0x0e00 + 'u', %ds:(0xb8016)
 
 	# restore other segment registers
 	xorl	%eax, %eax
@@ -72,6 +158,30 @@
 	lgdt	saved_gdt
 	lidt	saved_idt
 	lldt	saved_ldt
+	ljmp	$(__KERNEL_CS),$1f
+1:
+	movl	%cr3, %eax
+	movl	%eax, %cr3
+	wbinvd
+
+	# and restore the stack ... but you need gdt for this to work
+	movl	$__KERNEL_DS, %eax
+	movw	%ax, %ss
+	movw	%ax, %ds
+	movw	%ax, %es
+	movw	%ax, %fs
+	movw	%ax, %gs
+	movl	saved_esp, %esp
+
+	movw	$0x0e00 + 'W', %ds:(0xb8018)
+	movl	$(1024*1024*3), %ecx
+	movl	$0, %esi
+	rep	lodsb
+	movw	$0x0e00 + 'O', %ds:(0xb8018)
+
+	movl	%cs:saved_magic2, %eax
+	cmpl	$0x12345678, %eax
+	jne	bogus_magic
 
 	# restore the other general registers
 	movl	saved_ebx, %ebx
@@ -81,8 +191,21 @@
 
 	# jump to place where we left off
 	movl	saved_eip,%eax
+	movw	$0x0e00 + 'x', %ds:(0xb8018)
+	pushl	%eax
+	popl	%eax
+	movw	$0x0e00 + '!', %ds:(0xb801a)
 	jmp	*%eax
 
+bogus_magic:
+	movw	$0x0e00 + 'B', %ds:(0xb8018)
+	jmp bogus_magic
+
+bogus_magic2:
+	movw	$0x0e00 + '2', %ds:(0xb8018)
+	jmp bogus_magic2
+		
+
 ##
 # acpi_copy_wakeup_routine
 #
@@ -113,23 +236,22 @@
 	movl    %edx, real_save_cr3 - wakeup_start (%eax)
 	movl    %cr4, %edx
 	movl    %edx, real_save_cr4 - wakeup_start (%eax)
+	movl	%cr0, %edx
+	movl	%edx, real_save_cr0 - wakeup_start (%eax)
 	sgdt    real_save_gdt - wakeup_start (%eax)
 
+	movl	saved_videomode, %edx
+	movl	%edx, video_mode - wakeup_start (%eax)
+	movl	$0x12345678, real_magic - wakeup_start (%eax)
+	movl	$0x12345678, saved_magic2
+
 	# restore the regs we used
 	popl	%edi
 	popl	%esi
 	ret
 
-
 .data
 ALIGN
-# saved registers
-saved_gdt:	.long	0,0
-saved_idt:	.long	0,0
-saved_ldt:	.long	0
-saved_tss:	.long	0
-saved_cr0:	.long	0
-
 ENTRY(saved_ebp)	.long	0
 ENTRY(saved_esi)	.long	0
 ENTRY(saved_edi)	.long	0
@@ -137,3 +259,16 @@
 
 ENTRY(saved_eip)	.long	0
 ENTRY(saved_esp)	.long	0
+
+ENTRY(saved_magic)	.long	0
+ENTRY(saved_magic2)	.long	0	
+ENTRY(saved_videomode)	.long	0
+
+ALIGN
+# saved registers
+saved_gdt:	.long	0,0
+saved_idt:	.long	0,0
+saved_ldt:	.long	0
+saved_tss:	.long	0
+saved_cr0:	.long	0
+
diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
--- a/arch/i386/kernel/apm.c	Fri May 24 18:55:33 2002
+++ b/arch/i386/kernel/apm.c	Fri May 24 18:55:33 2002
@@ -1667,6 +1667,7 @@
 	daemonize();
 
 	strcpy(current->comm, "kapmd");
+	current->flags |= PF_IOTHREAD;
 	sigfillset(&current->blocked);
 
 	if (apm_info.connection_version == 0) {
@@ -2024,5 +2025,3 @@
 MODULE_PARM(idle_period, "i");
 MODULE_PARM_DESC(idle_period,
 	"Period (in sec/100) over which to caculate the idle percentage");
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/arch/i386/kernel/bluesmoke.c b/arch/i386/kernel/bluesmoke.c
--- a/arch/i386/kernel/bluesmoke.c	Fri May 24 18:55:34 2002
+++ b/arch/i386/kernel/bluesmoke.c	Fri May 24 18:55:34 2002
@@ -5,7 +5,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/smp.h>
 #include <linux/config.h>
 #include <linux/irq.h>
@@ -68,11 +68,11 @@
 	unsigned int cpu = smp_processor_id();
 
 	/* Thermal monitoring */
-	if (!test_bit(X86_FEATURE_ACPI, c->x86_capability))
+	if (!cpu_has(c, X86_FEATURE_ACPI))
 		return;	/* -ENODEV */
 
 	/* Clock modulation */
-	if (!test_bit(X86_FEATURE_ACC, c->x86_capability))
+	if (!cpu_has(c, X86_FEATURE_ACC))
 		return;	/* -ENODEV */
 
 	rdmsr(MSR_IA32_MISC_ENABLE, l, h);
@@ -274,7 +274,7 @@
 	 *	Check for MCE support
 	 */
 
-	if( !test_bit(X86_FEATURE_MCE, c->x86_capability) )
+	if( !cpu_has(c, X86_FEATURE_MCE) )
 		return;	
 
 	/*
@@ -304,7 +304,7 @@
 	 *	Check for PPro style MCA
 	 */
  		
-	if( !test_bit(X86_FEATURE_MCA, c->x86_capability) )
+	if( !cpu_has(c, X86_FEATURE_MCA) )
 		return;
 
 	/* Ok machine check is available */
diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
--- a/arch/i386/kernel/cpuid.c	Fri May 24 18:55:33 2002
+++ b/arch/i386/kernel/cpuid.c	Fri May 24 18:55:33 2002
@@ -171,8 +171,6 @@
 module_init(cpuid_init);
 module_exit(cpuid_exit)
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>");
 MODULE_DESCRIPTION("x86 generic CPUID driver");
 MODULE_LICENSE("GPL");
diff -Nru a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
--- a/arch/i386/kernel/i8259.c	Fri May 24 18:55:36 2002
+++ b/arch/i386/kernel/i8259.c	Fri May 24 18:55:36 2002
@@ -11,6 +11,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
+#include <linux/device.h>
 
 #include <asm/atomic.h>
 #include <asm/system.h>
@@ -237,7 +238,19 @@
 	}
 }
 
-void __init init_8259A(int auto_eoi)
+static struct device device_i8259A = {
+	name:	       	"i8259A",
+	bus_id:		"0020",
+};
+
+static int __init init_8259A_devicefs(void)
+{
+	return register_sys_device(&device_i8259A);
+}
+
+__initcall(init_8259A_devicefs);
+
+void init_8259A(int auto_eoi)
 {
 	unsigned long flags;
 
diff -Nru a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
--- a/arch/i386/kernel/microcode.c	Fri May 24 18:55:34 2002
+++ b/arch/i386/kernel/microcode.c	Fri May 24 18:55:34 2002
@@ -80,7 +80,6 @@
 MODULE_DESCRIPTION("Intel CPU (IA-32) microcode update driver");
 MODULE_AUTHOR("Tigran Aivazian <tigran@veritas.com>");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 #define MICRO_DEBUG 0
 
@@ -211,7 +210,7 @@
 	req->err = 1; /* assume update will fail on this cpu */
 
 	if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
-		test_bit(X86_FEATURE_IA64, c->x86_capability)){
+	    	cpu_has(c, X86_FEATURE_IA64)) {
 		printk(KERN_ERR "microcode: CPU%d not a capable Intel processor\n", cpu_num);
 		return;
 	}
diff -Nru a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
--- a/arch/i386/kernel/msr.c	Fri May 24 18:55:35 2002
+++ b/arch/i386/kernel/msr.c	Fri May 24 18:55:35 2002
@@ -236,7 +236,7 @@
   
   if ( !(cpu_online_map & (1UL << cpu)) )
     return -ENXIO;		/* No such CPU */
-  if ( !test_bit(X86_FEATURE_MSR, c->x86_capability) )
+  if ( !cpu_has(c, X86_FEATURE_MSR) )
     return -EIO;		/* MSR not supported */
   
   return 0;
@@ -271,8 +271,6 @@
 
 module_init(msr_init);
 module_exit(msr_exit)
-
-EXPORT_NO_SYMBOLS;
 
 MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>");
 MODULE_DESCRIPTION("x86 generic MSR driver");
diff -Nru a/arch/i386/kernel/mtrr.c b/arch/i386/kernel/mtrr.c
--- a/arch/i386/kernel/mtrr.c	Fri May 24 18:55:33 2002
+++ b/arch/i386/kernel/mtrr.c	Fri May 24 18:55:33 2002
@@ -387,7 +387,7 @@
 	 return;
 
     /*  Save value of CR4 and clear Page Global Enable (bit 7)  */
-    if ( test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability) ) {
+    if ( cpu_has_pge ) {
 	ctxt->cr4val = read_cr4();
 	write_cr4(ctxt->cr4val & (unsigned char) ~(1<<7));
     }
@@ -448,7 +448,7 @@
     write_cr0( read_cr0() & 0xbfffffff );
 
     /*  Restore value of CR4  */
-    if ( test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability) )
+    if ( cpu_has_pge )
 	write_cr4(ctxt->cr4val);
 
     /*  Re-enable interrupts locally (if enabled previously)  */
@@ -2122,7 +2122,7 @@
 
 static int __init mtrr_setup(void)
 {
-    if ( test_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability) ) {
+    if ( cpu_has_mtrr ) {
 	/* Intel (P6) standard MTRRs */
 	mtrr_if = MTRR_IF_INTEL;
 	get_mtrr = intel_get_mtrr;
@@ -2166,14 +2166,14 @@
 		break;
 	}
 
-    } else if ( test_bit(X86_FEATURE_K6_MTRR, boot_cpu_data.x86_capability) ) {
+    } else if ( cpu_has_k6_mtrr ) {
 	/* Pre-Athlon (K6) AMD CPU MTRRs */
 	mtrr_if = MTRR_IF_AMD_K6;
 	get_mtrr = amd_get_mtrr;
 	set_mtrr_up = amd_set_mtrr_up;
 	size_or_mask  = 0xfff00000; /* 32 bits */
 	size_and_mask = 0;
-    } else if ( test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) ) {
+    } else if ( cpu_has_cyrix_arr ) {
 	/* Cyrix ARRs */
 	mtrr_if = MTRR_IF_CYRIX_ARR;
 	get_mtrr = cyrix_get_arr;
@@ -2182,7 +2182,7 @@
 	cyrix_arr_init();
 	size_or_mask  = 0xfff00000; /* 32 bits */
 	size_and_mask = 0;
-    } else if ( test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) ) {
+    } else if ( cpu_has_centaur_mcr ) {
 	/* Centaur MCRs */
 	mtrr_if = MTRR_IF_CENTAUR_MCR;
 	get_mtrr = centaur_get_mcr;
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c	Fri May 24 18:55:35 2002
+++ b/arch/i386/kernel/setup.c	Fri May 24 18:55:35 2002
@@ -168,6 +168,8 @@
 static int disable_x86_serial_nr __initdata = 1;
 static int disable_x86_fxsr __initdata = 0;
 
+extern unsigned long saved_videomode;
+
 /*
  * This is set up by the setup-routine at boot-time
  */
@@ -182,6 +184,7 @@
 #define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
 #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
 #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
+#define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA))
 #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
 #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
 #define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
@@ -681,6 +684,10 @@
  	drive_info = DRIVE_INFO;
  	screen_info = SCREEN_INFO;
 	apm_info.bios = APM_BIOS_INFO;
+#ifdef CONFIG_ACPI_SLEEP
+	saved_videomode = VIDEO_MODE;
+	printk("Video mode to be used for restore is %lx\n", saved_videomode);
+#endif
 	if( SYS_DESC_TABLE.length != 0 ) {
 		MCA_bus = SYS_DESC_TABLE.table[3] &0x2;
 		machine_id = SYS_DESC_TABLE.table[0];
@@ -1226,7 +1233,7 @@
 			 * here.
 			 */
 			if (c->x86_model == 6 || c->x86_model == 7) {
-				if (!test_bit(X86_FEATURE_XMM, c->x86_capability)) {
+				if (!cpu_has(c, X86_FEATURE_XMM)) {
 					printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
 					rdmsr(MSR_K7_HWCR, l, h);
 					l &= ~0x00008000;
@@ -2153,7 +2160,7 @@
 		strcpy(c->x86_model_id, p);
 	
 #ifdef CONFIG_SMP
-	if (test_bit(X86_FEATURE_HT, c->x86_capability)) {
+	if (cpu_has(c, X86_FEATURE_HT)) {
 		extern	int phys_proc_id[NR_CPUS];
 		
 		u32 	eax, ebx, ecx, edx;
@@ -2322,8 +2329,7 @@
 
 static void __init squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
 {
-	if( test_bit(X86_FEATURE_PN, c->x86_capability) &&
-	    disable_x86_serial_nr ) {
+	if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) {
 		/* Disable processor serial number */
 		unsigned long lo,hi;
 		rdmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
@@ -2760,7 +2766,7 @@
 	else
 		seq_printf(m, "stepping\t: unknown\n");
 
-	if ( test_bit(X86_FEATURE_TSC, c->x86_capability) ) {
+	if ( cpu_has(c, X86_FEATURE_TSC) ) {
 		seq_printf(m, "cpu MHz\t\t: %lu.%03lu\n",
 			cpu_khz / 1000, (cpu_khz % 1000));
 	}
diff -Nru a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
--- a/arch/i386/kernel/signal.c	Fri May 24 18:55:35 2002
+++ b/arch/i386/kernel/signal.c	Fri May 24 18:55:35 2002
@@ -21,6 +21,7 @@
 #include <linux/tty.h>
 #include <linux/personality.h>
 #include <linux/binfmts.h>
+#include <linux/suspend.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
@@ -594,6 +595,11 @@
 	if ((regs->xcs & 3) != 3)
 		return 1;
 
+	if (current->flags & PF_FREEZE) {
+		refrigerator(0);
+		goto no_signal;
+	}
+
 	if (!oldset)
 		oldset = &current->blocked;
 
@@ -701,6 +707,7 @@
 		return 1;
 	}
 
+ no_signal:
 	/* Did we come from a system call? */
 	if (regs->orig_eax >= 0) {
 		/* Restart the system call - no handlers present */
diff -Nru a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c	Fri May 24 18:55:33 2002
+++ b/arch/i386/kernel/smp.c	Fri May 24 18:55:33 2002
@@ -544,7 +544,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 {
 	struct call_data_struct data;
@@ -560,7 +560,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	wmb();
 	/* Send a message to all other CPUs and wait for them to respond */
@@ -573,7 +573,7 @@
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
 			barrier();
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 
 	return 0;
 }
diff -Nru a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
--- a/arch/i386/kernel/smpboot.c	Fri May 24 18:55:35 2002
+++ b/arch/i386/kernel/smpboot.c	Fri May 24 18:55:35 2002
@@ -1087,8 +1087,7 @@
 	/*
 	 * If we couldn't find a local APIC, then get out of here now!
 	 */
-	if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) &&
-	    !test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability)) {
+	if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) {
 		printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
 			boot_cpu_physical_apicid);
 		printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
@@ -1203,8 +1202,7 @@
 	 * If Hyper-Threading is avaialble, construct cpu_sibling_map[], so
 	 * that we can tell the sibling CPU efficiently.
 	 */
-	if (test_bit(X86_FEATURE_HT, boot_cpu_data.x86_capability)
-	    && smp_num_siblings > 1) {
+	if (cpu_has_ht && smp_num_siblings > 1) {
 		for (cpu = 0; cpu < NR_CPUS; cpu++)
 			cpu_sibling_map[cpu] = NO_PROC_ID;
 		
diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Fri May 24 18:55:35 2002
+++ b/arch/i386/kernel/time.c	Fri May 24 18:55:35 2002
@@ -42,6 +42,7 @@
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/module.h>
+#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/smp.h>
@@ -635,6 +636,18 @@
 bad_ctc:
 	return 0;
 }
+
+static struct device device_i8253 = {
+	name:	       	"i8253",
+	bus_id:		"0040",
+};
+
+static int time_init_driverfs(void)
+{
+	return register_sys_device(&device_i8253);
+}
+
+__initcall(time_init_driverfs);
 
 void __init time_init(void)
 {
diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c	Fri May 24 18:55:34 2002
+++ b/arch/i386/kernel/traps.c	Fri May 24 18:55:34 2002
@@ -321,7 +321,7 @@
 		printk(KERN_CRIT "PNPBIOS fault.. attempting recovery.\n");
 		__asm__ volatile(
 			"movl %0, %%esp\n\t"
-			"jmp %1\n\t"
+			"jmp *%1\n\t"
 			: "=a" (pnp_bios_fault_esp), "=b" (pnp_bios_fault_eip));
 		panic("do_trap: can't hit this");
 	}
diff -Nru a/arch/i386/lib/Makefile b/arch/i386/lib/Makefile
--- a/arch/i386/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/i386/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for i386-specific library files..
 #
 
-USE_STANDARD_AS_RULE	:= true
-
 L_TARGET = lib.a
 
 obj-y = checksum.o old-checksum.o delay.o \
diff -Nru a/arch/i386/math-emu/Makefile b/arch/i386/math-emu/Makefile
--- a/arch/i386/math-emu/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/i386/math-emu/Makefile	Fri May 24 18:55:33 2002
@@ -9,7 +9,6 @@
 PARANOID = -DPARANOID
 CFLAGS	:= $(CFLAGS) $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION)
 
-USE_STANDARD_AS_RULE	:= true
 EXTRA_AFLAGS	:= $(PARANOID)
 
 # From 'C' language sources:
diff -Nru a/arch/i386/mm/init.c b/arch/i386/mm/init.c
--- a/arch/i386/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/i386/mm/init.c	Fri May 24 18:55:34 2002
@@ -93,7 +93,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/arch/i386/vmlinux.lds b/arch/i386/vmlinux.lds
--- a/arch/i386/vmlinux.lds	Fri May 24 18:55:34 2002
+++ b/arch/i386/vmlinux.lds	Fri May 24 18:55:34 2002
@@ -66,6 +66,12 @@
   __init_end = .;
 
   . = ALIGN(4096);
+  __nosave_begin = .;
+  .data_nosave : { *(.data.nosave) }
+  . = ALIGN(4096);
+  __nosave_end = .;
+
+  . = ALIGN(4096);
   .data.page_aligned : { *(.data.idt) }
 
   . = ALIGN(32);
diff -Nru a/arch/ia64/defconfig b/arch/ia64/defconfig
--- a/arch/ia64/defconfig	Fri May 24 18:55:33 2002
+++ b/arch/ia64/defconfig	Fri May 24 18:55:33 2002
@@ -204,15 +204,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -257,7 +248,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_IVB is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
 # CONFIG_BLK_DEV_ATARAID_HPT is not set
diff -Nru a/arch/ia64/ia32/Makefile b/arch/ia64/ia32/Makefile
--- a/arch/ia64/ia32/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ia64/ia32/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for the ia32 kernel emulation subsystem.
 #
 
-USE_STANDARD_AS_RULE := true
-
 all: ia32.o
 
 O_TARGET := ia32.o
diff -Nru a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
--- a/arch/ia64/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/ia64/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for the linux kernel.
 #
 
-USE_STANDARD_AS_RULE := true
-
 all: kernel.o head.o init_task.o
 
 O_TARGET := kernel.o
diff -Nru a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
--- a/arch/ia64/kernel/irq_ia64.c	Fri May 24 18:55:35 2002
+++ b/arch/ia64/kernel/irq_ia64.c	Fri May 24 18:55:35 2002
@@ -14,7 +14,7 @@
 
 #include <linux/config.h>
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
diff -Nru a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
--- a/arch/ia64/kernel/smp.c	Fri May 24 18:55:35 2002
+++ b/arch/ia64/kernel/smp.c	Fri May 24 18:55:35 2002
@@ -283,8 +283,8 @@
  * Does not return until remote CPUs are nearly ready to execute <func> or are or have
  * executed.
  *
- * You must not call this function with disabled interrupts or from a hardware interrupt
- * handler, you may call it from a bottom half handler.
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
  */
 int
 smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait)
@@ -302,7 +302,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 
 	call_data = &data;
 	mb();	/* ensure store to call_data precedes setting of IPI_CALL_FUNC */
@@ -317,7 +317,7 @@
 			barrier();
 	call_data = NULL;
 
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 	return 0;
 }
 
diff -Nru a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
--- a/arch/ia64/lib/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/ia64/lib/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for ia64-specific library routines..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 export-objs := io.o swiotlb.o
diff -Nru a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
--- a/arch/ia64/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/ia64/mm/init.c	Fri May 24 18:55:35 2002
@@ -187,7 +187,6 @@
 			pgdat = pgdat->node_next;
 		} while (pgdat);
 		printk("Total of %ld pages in page table cache\n", pgtable_cache_size);
-		printk("%ld buffermem pages\n", nr_buffermem_pages());
 		printk("%d free buffer pages\n", nr_free_buffer_pages());
 	}
 #else /* !CONFIG_DISCONTIGMEM */
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-bigsur-mp b/arch/ia64/sn/configs/sn1/defconfig-bigsur-mp
--- a/arch/ia64/sn/configs/sn1/defconfig-bigsur-mp	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-bigsur-mp	Fri May 24 18:55:35 2002
@@ -183,15 +183,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -238,7 +229,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-bigsur-sp b/arch/ia64/sn/configs/sn1/defconfig-bigsur-sp
--- a/arch/ia64/sn/configs/sn1/defconfig-bigsur-sp	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-bigsur-sp	Fri May 24 18:55:34 2002
@@ -183,15 +183,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -238,7 +229,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-dig-mp b/arch/ia64/sn/configs/sn1/defconfig-dig-mp
--- a/arch/ia64/sn/configs/sn1/defconfig-dig-mp	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-dig-mp	Fri May 24 18:55:36 2002
@@ -139,15 +139,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -163,7 +154,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-dig-sp b/arch/ia64/sn/configs/sn1/defconfig-dig-sp
--- a/arch/ia64/sn/configs/sn1/defconfig-dig-sp	Fri May 24 18:55:33 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-dig-sp	Fri May 24 18:55:33 2002
@@ -139,15 +139,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -163,7 +154,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-generic-mp b/arch/ia64/sn/configs/sn1/defconfig-generic-mp
--- a/arch/ia64/sn/configs/sn1/defconfig-generic-mp	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-generic-mp	Fri May 24 18:55:34 2002
@@ -134,15 +134,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -158,7 +149,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-generic-sp b/arch/ia64/sn/configs/sn1/defconfig-generic-sp
--- a/arch/ia64/sn/configs/sn1/defconfig-generic-sp	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-generic-sp	Fri May 24 18:55:35 2002
@@ -134,15 +134,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -158,7 +149,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-prom-medusa b/arch/ia64/sn/configs/sn1/defconfig-prom-medusa
--- a/arch/ia64/sn/configs/sn1/defconfig-prom-medusa	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-prom-medusa	Fri May 24 18:55:35 2002
@@ -147,15 +147,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -171,7 +162,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp
--- a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp	Fri May 24 18:55:34 2002
@@ -204,15 +204,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -228,7 +219,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-modules b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-modules
--- a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-modules	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-modules	Fri May 24 18:55:36 2002
@@ -206,15 +206,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -230,7 +221,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-syn1-0 b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-syn1-0
--- a/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-syn1-0	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-sn1-mp-syn1-0	Fri May 24 18:55:35 2002
@@ -204,15 +204,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -228,7 +219,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn1/defconfig-sn1-sp b/arch/ia64/sn/configs/sn1/defconfig-sn1-sp
--- a/arch/ia64/sn/configs/sn1/defconfig-sn1-sp	Fri May 24 18:55:33 2002
+++ b/arch/ia64/sn/configs/sn1/defconfig-sn1-sp	Fri May 24 18:55:33 2002
@@ -204,15 +204,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -228,7 +219,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-dig-numa b/arch/ia64/sn/configs/sn2/defconfig-dig-numa
--- a/arch/ia64/sn/configs/sn2/defconfig-dig-numa	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-dig-numa	Fri May 24 18:55:34 2002
@@ -140,15 +140,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -164,7 +155,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-mp b/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-mp
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-mp	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-mp	Fri May 24 18:55:36 2002
@@ -139,15 +139,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -163,7 +154,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-sp b/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-sp
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-sp	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-dig-sp	Fri May 24 18:55:35 2002
@@ -139,15 +139,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -163,7 +154,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-mp b/arch/ia64/sn/configs/sn2/defconfig-sn2-mp
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-mp	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-mp	Fri May 24 18:55:34 2002
@@ -204,15 +204,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -228,7 +219,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-mp-modules b/arch/ia64/sn/configs/sn2/defconfig-sn2-mp-modules
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-mp-modules	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-mp-modules	Fri May 24 18:55:36 2002
@@ -206,15 +206,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -230,7 +221,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-prom-medusa b/arch/ia64/sn/configs/sn2/defconfig-sn2-prom-medusa
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-prom-medusa	Fri May 24 18:55:35 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-prom-medusa	Fri May 24 18:55:35 2002
@@ -147,15 +147,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -171,7 +162,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/configs/sn2/defconfig-sn2-sp b/arch/ia64/sn/configs/sn2/defconfig-sn2-sp
--- a/arch/ia64/sn/configs/sn2/defconfig-sn2-sp	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/configs/sn2/defconfig-sn2-sp	Fri May 24 18:55:34 2002
@@ -204,15 +204,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -228,7 +219,6 @@
 # CONFIG_BLK_DEV_RZ1000 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ia64/sn/fakeprom/Makefile b/arch/ia64/sn/fakeprom/Makefile
--- a/arch/ia64/sn/fakeprom/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/fakeprom/Makefile	Fri May 24 18:55:36 2002
@@ -6,8 +6,6 @@
 #  Copyright (c) 2000-2001 Silicon Graphics, Inc.  All rights reserved.
 #
 
-USE_STANDARD_AS_RULE := true
-
 TOPDIR=../../../..
 HPATH           = $(TOPDIR)/include
 
diff -Nru a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
--- a/arch/ia64/sn/kernel/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/ia64/sn/kernel/Makefile	Fri May 24 18:55:33 2002
@@ -31,8 +31,6 @@
 # http://oss.sgi.com/projects/GenInfo/NoticeExplan
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_CFLAGS    := -DLITTLE_ENDIAN
 
 O_TARGET        = sn.o
diff -Nru a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c
--- a/arch/ia64/sn/kernel/mca.c	Fri May 24 18:55:34 2002
+++ b/arch/ia64/sn/kernel/mca.c	Fri May 24 18:55:34 2002
@@ -35,7 +35,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/threads.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
diff -Nru a/arch/ia64/sn/kernel/sn1/Makefile b/arch/ia64/sn/kernel/sn1/Makefile
--- a/arch/ia64/sn/kernel/sn1/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/kernel/sn1/Makefile	Fri May 24 18:55:36 2002
@@ -32,8 +32,6 @@
 # http://oss.sgi.com/projects/GenInfo/NoticeExplan
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_CFLAGS    := -DLITTLE_ENDIAN
 
 all: sn1.a
diff -Nru a/arch/ia64/sn/kernel/sn2/Makefile b/arch/ia64/sn/kernel/sn2/Makefile
--- a/arch/ia64/sn/kernel/sn2/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ia64/sn/kernel/sn2/Makefile	Fri May 24 18:55:36 2002
@@ -32,8 +32,6 @@
 # http://oss.sgi.com/projects/GenInfo/NoticeExplan
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_CFLAGS    := -DLITTLE_ENDIAN
 
 all: sn2.a
diff -Nru a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c
--- a/arch/m68k/amiga/amisound.c	Fri May 24 18:55:36 2002
+++ b/arch/m68k/amiga/amisound.c	Fri May 24 18:55:36 2002
@@ -9,7 +9,7 @@
  */
 
 #include <linux/config.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/init.h>
 
diff -Nru a/arch/m68k/amiga/pcmcia.c b/arch/m68k/amiga/pcmcia.c
--- a/arch/m68k/amiga/pcmcia.c	Fri May 24 18:55:34 2002
+++ b/arch/m68k/amiga/pcmcia.c	Fri May 24 18:55:34 2002
@@ -13,7 +13,7 @@
 */
 
 #include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <asm/amigayle.h>
 #include <asm/amipcmcia.h>
diff -Nru a/arch/m68k/apollo/dn_ints.c b/arch/m68k/apollo/dn_ints.c
--- a/arch/m68k/apollo/dn_ints.c	Fri May 24 18:55:36 2002
+++ b/arch/m68k/apollo/dn_ints.c	Fri May 24 18:55:36 2002
@@ -1,6 +1,6 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/kernel_stat.h>
 
 #include <asm/system.h>
diff -Nru a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c
--- a/arch/m68k/atari/stram.c	Fri May 24 18:55:34 2002
+++ b/arch/m68k/atari/stram.c	Fri May 24 18:55:34 2002
@@ -984,8 +984,11 @@
 	unsigned long len;
 
 	while (1) {
-		INIT_REQUEST;
-		
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
+
 		start = swap_start + (CURRENT->sector << 9);
 		len   = CURRENT->current_nr_sectors << 9;
 		if ((start + len) > swap_end) {
diff -Nru a/arch/m68k/fpsp040/Makefile b/arch/m68k/fpsp040/Makefile
--- a/arch/m68k/fpsp040/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/m68k/fpsp040/Makefile	Fri May 24 18:55:36 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := -traditional
 
 OS_TARGET := fpsp.o
diff -Nru a/arch/m68k/ifpsp060/Makefile b/arch/m68k/ifpsp060/Makefile
--- a/arch/m68k/ifpsp060/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/m68k/ifpsp060/Makefile	Fri May 24 18:55:34 2002
@@ -4,8 +4,6 @@
 # License.  See the file "README.legal" in the main directory of this archive
 # for more details.
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := -traditional
 
 OS_TARGET := ifpsp.o
diff -Nru a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
--- a/arch/m68k/kernel/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/m68k/kernel/Makefile	Fri May 24 18:55:36 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := -traditional
 
 ifndef CONFIG_SUN3
diff -Nru a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
--- a/arch/m68k/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/m68k/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for m68k-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := -traditional
diff -Nru a/arch/m68k/math-emu/Makefile b/arch/m68k/math-emu/Makefile
--- a/arch/m68k/math-emu/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/m68k/math-emu/Makefile	Fri May 24 18:55:33 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := -traditional
 
 #EXTRA_AFLAGS += -DFPU_EMU_DEBUG
diff -Nru a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
--- a/arch/m68k/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/m68k/mm/init.c	Fri May 24 18:55:34 2002
@@ -35,20 +35,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-int do_check_pgt_cache(int low, int high)
-{
-	int freed = 0;
-	if(pgtable_cache_size > high) {
-		do {
-			if(pmd_quicklist)
-				freed += free_pmd_slow(get_pmd_fast());
-			if(pte_quicklist)
-				free_pte_slow(get_pte_fast()), freed++;
-		} while(pgtable_cache_size > low);
-	}
-	return freed;
-}
-
 /*
  * BAD_PAGE is the page that is used for page faults when linux
  * is out-of-memory. Older versions of linux just did a
@@ -56,27 +42,9 @@
  * for a process dying in kernel mode, possibly leaving an inode
  * unused etc..
  *
- * BAD_PAGETABLE is the accompanying page-table: it is initialized
- * to point to BAD_PAGE entries.
- *
  * ZERO_PAGE is a special page that is used for zero-initialized
  * data and COW.
  */
-unsigned long empty_bad_page_table;
-
-pte_t *__bad_pagetable(void)
-{
-    memset((void *)empty_bad_page_table, 0, PAGE_SIZE);
-    return (pte_t *)empty_bad_page_table;
-}
-
-unsigned long empty_bad_page;
-
-pte_t __bad_page(void)
-{
-    memset ((void *)empty_bad_page, 0, PAGE_SIZE);
-    return pte_mkdirty(__mk_pte(empty_bad_page, PAGE_SHARED));
-}
 
 unsigned long empty_zero_page;
 
@@ -106,8 +74,6 @@
     printk("%d reserved pages\n",reserved);
     printk("%d pages shared\n",shared);
     printk("%d pages swap cached\n",cached);
-    printk("%ld pages in page table cache\n",pgtable_cache_size);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 extern void init_pointer_table(unsigned long ptable);
@@ -127,7 +93,7 @@
 	unsigned long tmp;
 	int i;
 
-	max_mapnr = num_physpages = MAP_NR(high_memory);
+	max_mapnr = num_physpages = (((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT);
 
 #ifdef CONFIG_ATARI
 	if (MACH_IS_ATARI)
@@ -138,12 +104,6 @@
 	totalram_pages = free_all_bootmem();
 
 	for (tmp = PAGE_OFFSET ; tmp < (unsigned long)high_memory; tmp += PAGE_SIZE) {
-#if 0
-#ifndef CONFIG_SUN3
-		if (virt_to_phys ((void *)tmp) >= mach_max_dma_address)
-			clear_bit(PG_DMA, &virt_to_page(tmp)->flags);
-#endif
-#endif
 		if (PageReserved(virt_to_page(tmp))) {
 			if (tmp >= (unsigned long)&_text
 			    && tmp < (unsigned long)&_etext)
@@ -155,14 +115,6 @@
 				datapages++;
 			continue;
 		}
-#if 0
-		set_page_count(virt_to_page(tmp), 1);
-#ifdef CONFIG_BLK_DEV_INITRD
-		if (!initrd_start ||
-		    (tmp < (initrd_start & PAGE_MASK) || tmp >= initrd_end))
-#endif
-			free_page(tmp);
-#endif
 	}
 	
 #ifndef CONFIG_SUN3
diff -Nru a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
--- a/arch/m68k/mm/kmap.c	Fri May 24 18:55:35 2002
+++ b/arch/m68k/mm/kmap.c	Fri May 24 18:55:35 2002
@@ -189,7 +189,7 @@
 			printk ("\npa=%#lx va=%#lx ", physaddr, virtaddr);
 #endif
 		pgd_dir = pgd_offset_k(virtaddr);
-		pmd_dir = pmd_alloc_kernel(pgd_dir, virtaddr);
+		pmd_dir = pmd_alloc(&init_mm, pgd_dir, virtaddr);
 		if (!pmd_dir) {
 			printk("ioremap: no mem for pmd_dir\n");
 			return NULL;
@@ -201,7 +201,7 @@
 			virtaddr += PTRTREESIZE;
 			size -= PTRTREESIZE;
 		} else {
-			pte_dir = pte_alloc_kernel(pmd_dir, virtaddr);
+			pte_dir = pte_alloc_kernel(&init_mm, pmd_dir, virtaddr);
 			if (!pte_dir) {
 				printk("ioremap: no mem for pte_dir\n");
 				return NULL;
@@ -273,7 +273,7 @@
 			pmd_clear(pmd_dir);
 			return;
 		}
-		pte_dir = pte_offset(pmd_dir, virtaddr);
+		pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
 
 		pte_val(*pte_dir) = 0;
 		virtaddr += PAGE_SIZE;
@@ -350,7 +350,7 @@
 			pmd_clear(pmd_dir);
 			return;
 		}
-		pte_dir = pte_offset(pmd_dir, virtaddr);
+		pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
 
 		pte_val(*pte_dir) = (pte_val(*pte_dir) & _CACHEMASK040) | cmode;
 		virtaddr += PAGE_SIZE;
diff -Nru a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
--- a/arch/m68k/mm/memory.c	Fri May 24 18:55:36 2002
+++ b/arch/m68k/mm/memory.c	Fri May 24 18:55:36 2002
@@ -25,69 +25,6 @@
 #include <asm/amigahw.h>
 #endif
 
-struct pgtable_cache_struct quicklists;
-
-void __bad_pte(pmd_t *pmd)
-{
-	printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
-	pmd_set(pmd, BAD_PAGETABLE);
-}
-
-void __bad_pmd(pgd_t *pgd)
-{
-	printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd));
-	pgd_set(pgd, (pmd_t *)BAD_PAGETABLE);
-}
-
-#if 0
-pte_t *get_pte_slow(pmd_t *pmd, unsigned long offset)
-{
-	pte_t *pte;
-
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
-	if (pmd_none(*pmd)) {
-		if (pte) {
-			clear_page(pte);
-			__flush_page_to_ram((unsigned long)pte);
-			flush_tlb_kernel_page((unsigned long)pte);
-			nocache_page((unsigned long)pte);
-			pmd_set(pmd, pte);
-			return pte + offset;
-		}
-		pmd_set(pmd, BAD_PAGETABLE);
-		return NULL;
-	}
-	free_page((unsigned long)pte);
-	if (pmd_bad(*pmd)) {
-		__bad_pte(pmd);
-		return NULL;
-	}
-	return (pte_t *)__pmd_page(*pmd) + offset;
-}
-#endif
-
-#if 0
-pmd_t *get_pmd_slow(pgd_t *pgd, unsigned long offset)
-{
-	pmd_t *pmd;
-
-	pmd = get_pointer_table();
-	if (pgd_none(*pgd)) {
-		if (pmd) {
-			pgd_set(pgd, pmd);
-			return pmd + offset;
-		}
-		pgd_set(pgd, (pmd_t *)BAD_PAGETABLE);
-		return NULL;
-	}
-	free_pointer_table(pmd);
-	if (pgd_bad(*pgd)) {
-		__bad_pmd(pgd);
-		return NULL;
-	}
-	return (pmd_t *)__pgd_page(*pgd) + offset;
-}
-#endif
 
 /* ++andreas: {get,free}_pointer_table rewritten to use unused fields from
    struct page instead of separately kmalloced struct.  Stolen from
diff -Nru a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
--- a/arch/m68k/mm/motorola.c	Fri May 24 18:55:36 2002
+++ b/arch/m68k/mm/motorola.c	Fri May 24 18:55:36 2002
@@ -176,7 +176,7 @@
 				pte_dir = kernel_page_table();
 				pmd_set(pmd_dir, pte_dir);
 			}
-			pte_dir = pte_offset(pmd_dir, virtaddr);
+			pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
 
 			if (virtaddr) {
 				if (!pte_present(*pte_dir))
@@ -262,15 +262,13 @@
 	 * initialize the bad page table and bad page to point
 	 * to a couple of allocated pages
 	 */
-	empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
-	empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
 	empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
 	memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
 	/*
-	 * Set up SFC/DFC registers (user data space)
+	 * Set up SFC/DFC registers
 	 */
-	set_fs (USER_DS);
+	set_fs(KERNEL_DS);
 
 #ifdef DEBUG
 	printk ("before free_area_init\n");
diff -Nru a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
--- a/arch/m68k/mm/sun3mmu.c	Fri May 24 18:55:34 2002
+++ b/arch/m68k/mm/sun3mmu.c	Fri May 24 18:55:34 2002
@@ -59,8 +59,6 @@
 #ifdef TEST_VERIFY_AREA
 	wp_works_ok = 0;
 #endif
-	empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
-	empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
 	empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
 	memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
diff -Nru a/arch/mips/au1000/common/Makefile b/arch/mips/au1000/common/Makefile
--- a/arch/mips/au1000/common/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/mips/au1000/common/Makefile	Fri May 24 18:55:36 2002
@@ -10,8 +10,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all: au1000.o
diff -Nru a/arch/mips/baget/setup.c b/arch/mips/baget/setup.c
--- a/arch/mips/baget/setup.c	Fri May 24 18:55:33 2002
+++ b/arch/mips/baget/setup.c	Fri May 24 18:55:33 2002
@@ -17,7 +17,6 @@
 long int vac_memory_upper;
 
 #define CACHEABLE_STR(val) ((val) ? "not cached" : "cached")
-#define MIN(a,b)           (((a)<(b)) ? (a):(b)) 
 		
 static void __init vac_show(void)
 { 
@@ -102,7 +101,7 @@
 		if (a24_addr >= from && a24_addr < to)
 			printk("\ta24 at %08lx (%dMB)\t[vme, A24/%s, %s]\n",
 			       a24_addr,
-			       MIN((unsigned int)(a24_addr - from)>>20, 32),
+			       min((unsigned int)(a24_addr - from)>>20, 32U),
 			       (a24_base & VAC_A24_DATAPATH) ?  "user" :
 			       ((a24_base & VAC_A24_D32_ENABLE)  ?  
 				"D32" : "D16"),
diff -Nru a/arch/mips/ddb5074/Makefile b/arch/mips/ddb5074/Makefile
--- a/arch/mips/ddb5074/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/mips/ddb5074/Makefile	Fri May 24 18:55:33 2002
@@ -9,8 +9,6 @@
 # Note 2! The CFLAGS definitions are now in the main makefile...
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET = ddb5074.a
diff -Nru a/arch/mips/ddb5476/Makefile b/arch/mips/ddb5476/Makefile
--- a/arch/mips/ddb5476/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/mips/ddb5476/Makefile	Fri May 24 18:55:36 2002
@@ -9,8 +9,6 @@
 # Note 2! The CFLAGS definitions are now in the main makefile...
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET = ddb5476.a
diff -Nru a/arch/mips/ddb5xxx/ddb5477/Makefile b/arch/mips/ddb5xxx/ddb5477/Makefile
--- a/arch/mips/ddb5xxx/ddb5477/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips/ddb5xxx/ddb5477/Makefile	Fri May 24 18:55:34 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET:= ddb5477.o
diff -Nru a/arch/mips/dec/Makefile b/arch/mips/dec/Makefile
--- a/arch/mips/dec/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips/dec/Makefile	Fri May 24 18:55:34 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET := dec.o
 
 all: dec.o
diff -Nru a/arch/mips/dec/prom/Makefile b/arch/mips/dec/prom/Makefile
--- a/arch/mips/dec/prom/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips/dec/prom/Makefile	Fri May 24 18:55:35 2002
@@ -8,8 +8,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 OBJS  = init.o memory.o cmdline.o identify.o locore.o
diff -Nru a/arch/mips/defconfig-ddb5476 b/arch/mips/defconfig-ddb5476
--- a/arch/mips/defconfig-ddb5476	Fri May 24 18:55:35 2002
+++ b/arch/mips/defconfig-ddb5476	Fri May 24 18:55:35 2002
@@ -199,15 +199,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -250,7 +241,6 @@
 # CONFIG_BLK_DEV_VIA82CXXX is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/mips/defconfig-it8172 b/arch/mips/defconfig-it8172
--- a/arch/mips/defconfig-it8172	Fri May 24 18:55:35 2002
+++ b/arch/mips/defconfig-it8172	Fri May 24 18:55:35 2002
@@ -264,15 +264,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -331,7 +322,6 @@
 # CONFIG_BLK_DEV_UMC8672 is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/mips/gt64120/common/pci.c b/arch/mips/gt64120/common/pci.c
--- a/arch/mips/gt64120/common/pci.c	Fri May 24 18:55:35 2002
+++ b/arch/mips/gt64120/common/pci.c	Fri May 24 18:55:35 2002
@@ -41,6 +41,7 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/version.h>
+#include <linux/cache.h>
 #include <asm/pci.h>
 #include <asm/io.h>
 #include <asm/gt64120/gt64120.h>
@@ -1014,9 +1015,6 @@
 	return arrayCounter;
 }
 
-#define ALIGN(val,align)        (((val) + ((align) - 1)) & ~((align) - 1))
-#define MAX(val1, val2) ((val1) > (val2) ? (val1) : (val2))
-
 /*
  * This function goes through the list of devices and allocates the BARs in
  * either IO or MEM space.  It does it in order of size, which will limit the
@@ -1071,14 +1069,14 @@
 			device.devfn =
 			    PCI_DEVFN(pci_devices[maxDevice].slot, 0);
 			if (pci_devices[maxDevice].BARtype[maxBAR] == 1) {
-				alignto = MAX(0x1000, maxSize);
+				alignto = max(0x1000U, maxSize);
 				base = ALIGN(pci0_io_base, alignto);
 				pci0WriteConfigReg(PCI_BASE_ADDRESS_0 +
 						   (maxBAR * 4), &device,
 						   base | 0x1);
 				pci0_io_base = base + alignto;
 			} else {
-				alignto = MAX(0x1000, maxSize);
+				alignto = max(0x1000U, maxSize);
 				base = ALIGN(pci0_mem_base, alignto);
 				pci0WriteConfigReg(PCI_BASE_ADDRESS_0 +
 						   (maxBAR * 4), &device,
diff -Nru a/arch/mips/gt64120/momenco_ocelot/Makefile b/arch/mips/gt64120/momenco_ocelot/Makefile
--- a/arch/mips/gt64120/momenco_ocelot/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/mips/gt64120/momenco_ocelot/Makefile	Fri May 24 18:55:33 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET:= momenco_ocelot.o
diff -Nru a/arch/mips/ite-boards/generic/Makefile b/arch/mips/ite-boards/generic/Makefile
--- a/arch/mips/ite-boards/generic/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips/ite-boards/generic/Makefile	Fri May 24 18:55:34 2002
@@ -10,8 +10,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all: it8172.o
diff -Nru a/arch/mips/jazz/Makefile b/arch/mips/jazz/Makefile
--- a/arch/mips/jazz/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips/jazz/Makefile	Fri May 24 18:55:35 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all: jazz.o
diff -Nru a/arch/mips/jazz/reset.c b/arch/mips/jazz/reset.c
--- a/arch/mips/jazz/reset.c	Fri May 24 18:55:35 2002
+++ b/arch/mips/jazz/reset.c	Fri May 24 18:55:35 2002
@@ -6,7 +6,7 @@
  *  $Id:$
  */
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <asm/jazz.h>
 #include <asm/io.h>
 #include <asm/system.h>
diff -Nru a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
--- a/arch/mips/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 # EXTRA_AFLAGS = -mips3 -mcpu=r4000 # not used?
 
 all:	kernel.o head.o init_task.o
diff -Nru a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
--- a/arch/mips/kernel/smp.c	Fri May 24 18:55:34 2002
+++ b/arch/mips/kernel/smp.c	Fri May 24 18:55:34 2002
@@ -191,6 +191,8 @@
  * The caller of this wants the passed function to run on every cpu.  If wait
  * is set, wait until all cpus have finished the function before returning.
  * The lock is here to protect the call structure.
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
  */
 int smp_call_function (void (*func) (void *info), void *info, int retry, 
 								int wait)
@@ -202,7 +204,7 @@
 		return 0;
 	}
 
-	spin_lock_bh(&smp_fn_call.lock);
+	spin_lock(&smp_fn_call.lock);
 
 	atomic_set(&smp_fn_call.finished, 0);
 	smp_fn_call.fn = func;
@@ -219,7 +221,7 @@
 		while(atomic_read(&smp_fn_call.finished) != cpus) {}
 	}
 
-	spin_unlock_bh(&smp_fn_call.lock);
+	spin_unlock(&smp_fn_call.lock);
 	return 0;
 }
 
diff -Nru a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
--- a/arch/mips/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/mips/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for MIPS-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true;
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := $(CFLAGS)
diff -Nru a/arch/mips/mips-boards/generic/Makefile b/arch/mips/mips-boards/generic/Makefile
--- a/arch/mips/mips-boards/generic/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/mips/mips-boards/generic/Makefile	Fri May 24 18:55:36 2002
@@ -27,8 +27,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET := mipsboards.o
diff -Nru a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
--- a/arch/mips/mm/fault.c	Fri May 24 18:55:34 2002
+++ b/arch/mips/mm/fault.c	Fri May 24 18:55:34 2002
@@ -191,7 +191,7 @@
 	 * or user mode.
 	 */
 	tsk->thread.cp0_badvaddr = address;
-	info.si_code = SIGBUS;
+	info.si_signo = SIGBUS;
 	info.si_errno = 0;
 	info.si_code = BUS_ADRERR;
 	info.si_addr = (void *) address;
diff -Nru a/arch/mips/mm/init.c b/arch/mips/mm/init.c
--- a/arch/mips/mm/init.c	Fri May 24 18:55:36 2002
+++ b/arch/mips/mm/init.c	Fri May 24 18:55:36 2002
@@ -135,7 +135,6 @@
 	printk("%d pages swap cached\n",cached);
 	printk("%ld pages in page table cache\n",pgtable_cache_size);
 	printk("%d free pages\n", free);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/arch/mips/philips/nino/Makefile b/arch/mips/philips/nino/Makefile
--- a/arch/mips/philips/nino/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips/philips/nino/Makefile	Fri May 24 18:55:35 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET := nino.o
 
 all: nino.o
diff -Nru a/arch/mips/sgi/kernel/Makefile b/arch/mips/sgi/kernel/Makefile
--- a/arch/mips/sgi/kernel/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/mips/sgi/kernel/Makefile	Fri May 24 18:55:33 2002
@@ -8,8 +8,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET := ip22-kern.o
diff -Nru a/arch/mips/sni/Makefile b/arch/mips/sni/Makefile
--- a/arch/mips/sni/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips/sni/Makefile	Fri May 24 18:55:34 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all:	sni.o int-handler.o
diff -Nru a/arch/mips64/kernel/Makefile b/arch/mips64/kernel/Makefile
--- a/arch/mips64/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips64/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -6,8 +6,6 @@
 # unless it's something special (ie not a .c file).
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all:	kernel.o head.o init_task.o
diff -Nru a/arch/mips64/lib/Makefile b/arch/mips64/lib/Makefile
--- a/arch/mips64/lib/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips64/lib/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for MIPS-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 L_TARGET = lib.a
diff -Nru a/arch/mips64/mips-boards/generic/Makefile b/arch/mips64/mips-boards/generic/Makefile
--- a/arch/mips64/mips-boards/generic/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/mips64/mips-boards/generic/Makefile	Fri May 24 18:55:34 2002
@@ -27,8 +27,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 all: mipsboards.o
diff -Nru a/arch/mips64/mm/fault.c b/arch/mips64/mm/fault.c
--- a/arch/mips64/mm/fault.c	Fri May 24 18:55:36 2002
+++ b/arch/mips64/mm/fault.c	Fri May 24 18:55:36 2002
@@ -247,7 +247,7 @@
 	 * or user mode.
 	 */
 	tsk->thread.cp0_badvaddr = address;
-	info.si_code = SIGBUS;
+	info.si_signo = SIGBUS;
 	info.si_errno = 0;
 	info.si_code = BUS_ADRERR;
 	info.si_addr = (void *) address;
diff -Nru a/arch/mips64/mm/init.c b/arch/mips64/mm/init.c
--- a/arch/mips64/mm/init.c	Fri May 24 18:55:33 2002
+++ b/arch/mips64/mm/init.c	Fri May 24 18:55:33 2002
@@ -339,7 +339,6 @@
 	printk("%d pages swap cached\n",cached);
 	printk("%ld pages in page table cache\n", pgtable_cache_size);
 	printk("%d free pages\n", free);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 #ifndef CONFIG_DISCONTIGMEM
diff -Nru a/arch/mips64/sgi-ip22/Makefile b/arch/mips64/sgi-ip22/Makefile
--- a/arch/mips64/sgi-ip22/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/mips64/sgi-ip22/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # under Linux.
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 L_TARGET = ip22.a
diff -Nru a/arch/mips64/sgi-ip27/Makefile b/arch/mips64/sgi-ip27/Makefile
--- a/arch/mips64/sgi-ip27/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/mips64/sgi-ip27/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for the IP27 specific kernel interface routines under Linux.
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET = ip27.o
diff -Nru a/arch/mips64/sgi-ip27/ip27-rtc.c b/arch/mips64/sgi-ip27/ip27-rtc.c
--- a/arch/mips64/sgi-ip27/ip27-rtc.c	Fri May 24 18:55:35 2002
+++ b/arch/mips64/sgi-ip27/ip27-rtc.c	Fri May 24 18:55:35 2002
@@ -222,7 +222,6 @@
 
 module_init(rtc_init);
 module_exit(rtc_exit);
-EXPORT_NO_SYMBOLS;
 
 /*
  *	Info exported via "/proc/rtc".
diff -Nru a/arch/mips64/sgi-ip32/Makefile b/arch/mips64/sgi-ip32/Makefile
--- a/arch/mips64/sgi-ip32/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/mips64/sgi-ip32/Makefile	Fri May 24 18:55:36 2002
@@ -8,8 +8,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := $(CFLAGS)
 
 O_TARGET := ip32-kern.a
diff -Nru a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
--- a/arch/parisc/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/parisc/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -9,15 +9,9 @@
 
 all: kernel.o init_task.o pdc_cons.o process.o head.o
 O_TARGET = kernel.o
-O_OBJS = 
 
 # Object file lists.
 
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
-
 obj-y		+= cache.o setup.o traps.o time.o irq.o \
 		syscall.o entry.o sys_parisc.o pdc.o ptrace.o hardware.o \
 		inventory.o drivers.o semaphore.o pa7300lc.o pci-dma.o \
@@ -38,15 +32,6 @@
 # obj-$(CONFIG_IOMMU_CCIO) += ccio-rm-dma.o
 obj-$(CONFIG_IOMMU_CCIO) += ccio-dma.o
 
-.o.S:	$(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -c $*.S -o $*.o
-
-# Translate to Rules.make lists.
-
-O_OBJS          := $(filter-out $(export-objs), $(obj-y))
-OX_OBJS         := $(filter     $(export-objs), $(obj-y))
-M_OBJS          := $(sort $(filter-out $(export-objs), $(obj-m)))
-MX_OBJS         := $(sort $(filter     $(export-objs), $(obj-m)))
-MI_OBJS		:= $(sort $(filter-out $(export-objs), $(int-m)))
-MIX_OBJS	:= $(sort $(filter     $(export-objs), $(int-m)))
+EXTRA_AFLAGS := -traditional
 
 include $(TOPDIR)/Rules.make
diff -Nru a/arch/parisc/lib/Makefile b/arch/parisc/lib/Makefile
--- a/arch/parisc/lib/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/parisc/lib/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for parisc-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 obj-y := lusercopy.o bitops.o checksum.o
diff -Nru a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
--- a/arch/parisc/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/parisc/mm/init.c	Fri May 24 18:55:35 2002
@@ -154,7 +154,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 void set_pte_phys (unsigned long vaddr, unsigned long phys)
diff -Nru a/arch/ppc/boot/chrp/Makefile b/arch/ppc/boot/chrp/Makefile
--- a/arch/ppc/boot/chrp/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ppc/boot/chrp/Makefile	Fri May 24 18:55:36 2002
@@ -7,8 +7,6 @@
 #
 # Based on coffboot by Paul Mackerras
 
-USE_STANDARD_AS_RULE := true
-
 LD_ARGS = -T ../ld.script -Ttext 0x00400000
 
 OBJS = ../common/crt0.o start.o main.o misc.o ../common/string.o image.o \
diff -Nru a/arch/ppc/boot/common/Makefile b/arch/ppc/boot/common/Makefile
--- a/arch/ppc/boot/common/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ppc/boot/common/Makefile	Fri May 24 18:55:36 2002
@@ -8,8 +8,6 @@
 # Tom Rini	January 2001
 #
 
-USE_STANDARD_AS_RULE	:= true
-
 coffcrt0.o:
 	$(CC) $(AFLAGS) -DXCOFF -traditional -c -o coffcrt0.o crt0.S
 
diff -Nru a/arch/ppc/boot/prep/Makefile b/arch/ppc/boot/prep/Makefile
--- a/arch/ppc/boot/prep/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/ppc/boot/prep/Makefile	Fri May 24 18:55:36 2002
@@ -15,8 +15,6 @@
 # modified by Cort (cort@cs.nmt.edu)
 #
 
-USE_STANDARD_AS_RULE		:= true
-
 TFTPIMAGE			= /tftpboot/zImage.prep
 ifeq ($(CONFIG_SMP),y)
 TFTPIMAGE			= $(TFTPBOOT).smp
diff -Nru a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
--- a/arch/ppc/boot/simple/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/ppc/boot/simple/Makefile	Fri May 24 18:55:33 2002
@@ -14,8 +14,6 @@
 # Free Software Foundation;  either version 2 of the  License, or (at your
 # option) any later version.
 
-USE_STANDARD_AS_RULE		:= true
-
 # Normally, we use the 'misc-simple.c' file for decompress_kernel and
 # whatnot.  Sometimes we need to override this however.
 MISC				:= ../common/misc-simple.o
diff -Nru a/arch/ppc/configs/IVMS8_defconfig b/arch/ppc/configs/IVMS8_defconfig
--- a/arch/ppc/configs/IVMS8_defconfig	Fri May 24 18:55:33 2002
+++ b/arch/ppc/configs/IVMS8_defconfig	Fri May 24 18:55:33 2002
@@ -178,15 +178,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -205,7 +196,6 @@
 # CONFIG_IDE_EXT_DIRECT is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/TQM860L_defconfig b/arch/ppc/configs/TQM860L_defconfig
--- a/arch/ppc/configs/TQM860L_defconfig	Fri May 24 18:55:34 2002
+++ b/arch/ppc/configs/TQM860L_defconfig	Fri May 24 18:55:34 2002
@@ -188,15 +188,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -215,7 +206,6 @@
 # CONFIG_IDE_EXT_DIRECT is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/apus_defconfig b/arch/ppc/configs/apus_defconfig
--- a/arch/ppc/configs/apus_defconfig	Fri May 24 18:55:34 2002
+++ b/arch/ppc/configs/apus_defconfig	Fri May 24 18:55:34 2002
@@ -234,15 +234,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 CONFIG_BLK_DEV_IDETAPE=m
@@ -262,7 +253,6 @@
 CONFIG_BLK_DEV_BUDDHA=y
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/common_defconfig b/arch/ppc/configs/common_defconfig
--- a/arch/ppc/configs/common_defconfig	Fri May 24 18:55:34 2002
+++ b/arch/ppc/configs/common_defconfig	Fri May 24 18:55:34 2002
@@ -227,15 +227,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -284,7 +275,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/cpci405_defconfig b/arch/ppc/configs/cpci405_defconfig
--- a/arch/ppc/configs/cpci405_defconfig	Fri May 24 18:55:35 2002
+++ b/arch/ppc/configs/cpci405_defconfig	Fri May 24 18:55:35 2002
@@ -192,15 +192,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -218,7 +209,6 @@
 CONFIG_BLK_DEV_CPCI405_IDE=y
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/k2_defconfig b/arch/ppc/configs/k2_defconfig
--- a/arch/ppc/configs/k2_defconfig	Fri May 24 18:55:33 2002
+++ b/arch/ppc/configs/k2_defconfig	Fri May 24 18:55:33 2002
@@ -214,15 +214,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -263,7 +254,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/menf1_defconfig b/arch/ppc/configs/menf1_defconfig
--- a/arch/ppc/configs/menf1_defconfig	Fri May 24 18:55:33 2002
+++ b/arch/ppc/configs/menf1_defconfig	Fri May 24 18:55:33 2002
@@ -214,15 +214,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -266,7 +257,6 @@
 # CONFIG_BLK_DEV_SL82C105 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/mvme5100_defconfig b/arch/ppc/configs/mvme5100_defconfig
--- a/arch/ppc/configs/mvme5100_defconfig	Fri May 24 18:55:33 2002
+++ b/arch/ppc/configs/mvme5100_defconfig	Fri May 24 18:55:33 2002
@@ -208,15 +208,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -259,7 +250,6 @@
 # CONFIG_BLK_DEV_SL82C105 is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/ppc/configs/pmac_defconfig b/arch/ppc/configs/pmac_defconfig
--- a/arch/ppc/configs/pmac_defconfig	Fri May 24 18:55:36 2002
+++ b/arch/ppc/configs/pmac_defconfig	Fri May 24 18:55:36 2002
@@ -217,15 +217,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 CONFIG_BLK_DEV_IDECS=m
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -274,7 +265,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/pplus_defconfig b/arch/ppc/configs/pplus_defconfig
--- a/arch/ppc/configs/pplus_defconfig	Fri May 24 18:55:36 2002
+++ b/arch/ppc/configs/pplus_defconfig	Fri May 24 18:55:36 2002
@@ -221,15 +221,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -274,7 +265,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/redwood5_defconfig b/arch/ppc/configs/redwood5_defconfig
--- a/arch/ppc/configs/redwood5_defconfig	Fri May 24 18:55:34 2002
+++ b/arch/ppc/configs/redwood5_defconfig	Fri May 24 18:55:34 2002
@@ -184,15 +184,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -204,7 +195,6 @@
 CONFIG_IBM_OCP_IDE=y
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/configs/sandpoint_defconfig b/arch/ppc/configs/sandpoint_defconfig
--- a/arch/ppc/configs/sandpoint_defconfig	Fri May 24 18:55:35 2002
+++ b/arch/ppc/configs/sandpoint_defconfig	Fri May 24 18:55:35 2002
@@ -184,15 +184,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -237,7 +228,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/defconfig b/arch/ppc/defconfig
--- a/arch/ppc/defconfig	Fri May 24 18:55:34 2002
+++ b/arch/ppc/defconfig	Fri May 24 18:55:34 2002
@@ -227,15 +227,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -284,7 +275,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
-# CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
diff -Nru a/arch/ppc/iSeries/rtc.c b/arch/ppc/iSeries/rtc.c
--- a/arch/ppc/iSeries/rtc.c	Fri May 24 18:55:35 2002
+++ b/arch/ppc/iSeries/rtc.c	Fri May 24 18:55:35 2002
@@ -209,7 +209,6 @@
 
 module_init(rtc_init);
 module_exit(rtc_exit);
-EXPORT_NO_SYMBOLS;
 
 /*
  *	Info exported via "/proc/driver/rtc".
diff -Nru a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
--- a/arch/ppc/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/ppc/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -9,8 +9,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE	:= true
-
 ifdef CONFIG_PPC64BRIDGE
 EXTRA_AFLAGS		:= -Wa,-mppc64bridge
 endif
diff -Nru a/arch/ppc/kernel/ppc4xx_setup.c b/arch/ppc/kernel/ppc4xx_setup.c
--- a/arch/ppc/kernel/ppc4xx_setup.c	Fri May 24 18:55:33 2002
+++ b/arch/ppc/kernel/ppc4xx_setup.c	Fri May 24 18:55:33 2002
@@ -68,10 +68,6 @@
 extern void pckbd_leds(unsigned char leds);
 extern void pckbd_init_hw(void);
 
-extern int nonpci_ide_default_irq(ide_ioreg_t base);
-extern void nonpci_ide_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port,
-				       ide_ioreg_t ctrl_port, int *irq);
-
 extern void ppc4xx_wdt_heartbeat(void);
 extern int wdt_enable;
 extern unsigned long wdt_period;
@@ -376,11 +372,8 @@
 **     defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
 */
 #ifdef CONFIG_IDE
-# if defined(CONFIG_PCI)
+# ifdef CONFIG_PCI
 	ppc_ide_md.ide_init_hwif = ppc4xx_ide_init_hwif_ports;
-# elif defined (CONFIG_DMA_NONPCI)	/* ON board IDE */
-	ppc_ide_md.default_irq = nonpci_ide_default_irq;
-	ppc_ide_md.ide_init_hwif = nonpci_ide_init_hwif_ports;
 # endif
 #endif
 	board_init();
diff -Nru a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
--- a/arch/ppc/kernel/smp.c	Fri May 24 18:55:36 2002
+++ b/arch/ppc/kernel/smp.c	Fri May 24 18:55:36 2002
@@ -209,7 +209,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 {
 	if (smp_num_cpus <= 1)
@@ -237,7 +237,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	/* Send a message to all other CPUs and wait for them to respond */
 	smp_message_pass(target, PPC_MSG_CALL_FUNCTION, 0, 0);
@@ -269,7 +269,7 @@
 	ret = 0;
 
  out:
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 	return ret;
 }
 
diff -Nru a/arch/ppc/kernel/temp.c b/arch/ppc/kernel/temp.c
--- a/arch/ppc/kernel/temp.c	Fri May 24 18:55:33 2002
+++ b/arch/ppc/kernel/temp.c	Fri May 24 18:55:33 2002
@@ -13,7 +13,7 @@
 
 #include <linux/config.h>
 #include <linux/errno.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/string.h>
diff -Nru a/arch/ppc/lib/Makefile b/arch/ppc/lib/Makefile
--- a/arch/ppc/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/ppc/lib/Makefile	Fri May 24 18:55:33 2002
@@ -4,8 +4,6 @@
 # Makefile for ppc-specific library files..
 #
 
-USE_STANDARD_AS_RULE	:= true
-
 O_TARGET		:= lib.o
 
 export-objs		:= dec_and_lock.o
diff -Nru a/arch/ppc/mm/Makefile b/arch/ppc/mm/Makefile
--- a/arch/ppc/mm/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/ppc/mm/Makefile	Fri May 24 18:55:34 2002
@@ -9,8 +9,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE	:= true
-
 ifdef CONFIG_PPC64BRIDGE
 EXTRA_AFLAGS		:= -Wa,-mppc64bridge
 endif
diff -Nru a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
--- a/arch/ppc/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/ppc/mm/init.c	Fri May 24 18:55:34 2002
@@ -140,7 +140,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* Free up now-unused memory */
diff -Nru a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile
--- a/arch/ppc/platforms/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/ppc/platforms/Makefile	Fri May 24 18:55:35 2002
@@ -9,8 +9,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE	:= true
-
 ifdef CONFIG_PPC64BRIDGE
 EXTRA_AFLAGS		:= -Wa,-mppc64bridge
 endif
diff -Nru a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
--- a/arch/ppc64/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/ppc64/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE    := true
-
 EXTRA_CFLAGS = -mno-minimal-toc
 
 KHEAD := head.o
diff -Nru a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c
--- a/arch/ppc64/kernel/rtc.c	Fri May 24 18:55:36 2002
+++ b/arch/ppc64/kernel/rtc.c	Fri May 24 18:55:36 2002
@@ -211,7 +211,6 @@
 
 module_init(rtc_init);
 module_exit(rtc_exit);
-EXPORT_NO_SYMBOLS;
 
 /*
  *	Info exported via "/proc/driver/rtc".
diff -Nru a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c
--- a/arch/ppc64/kernel/smp.c	Fri May 24 18:55:36 2002
+++ b/arch/ppc64/kernel/smp.c	Fri May 24 18:55:36 2002
@@ -466,7 +466,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
 			int wait)
@@ -486,7 +486,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	/* Send a message to all other CPUs and wait for them to respond */
 	smp_message_pass(MSG_ALL_BUT_SELF, PPC_MSG_CALL_FUNCTION, 0, 0);
@@ -530,7 +530,7 @@
 
  out:
 	HMT_medium();
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 	return ret;
 }
 
diff -Nru a/arch/ppc64/lib/Makefile b/arch/ppc64/lib/Makefile
--- a/arch/ppc64/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/ppc64/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for ppc64-specific library files..
 #
 
-USE_STANDARD_AS_RULE    := true
-
 O_TARGET = lib.o
 
 obj-y           := checksum.o dec_and_lock.o string.o strcase.o
diff -Nru a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
--- a/arch/ppc64/mm/init.c	Fri May 24 18:55:36 2002
+++ b/arch/ppc64/mm/init.c	Fri May 24 18:55:36 2002
@@ -134,7 +134,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 void *
diff -Nru a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
--- a/arch/s390/boot/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/s390/boot/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
 O_TARGET := 
diff -Nru a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
--- a/arch/s390/kernel/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/s390/kernel/Makefile	Fri May 24 18:55:36 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 all: kernel.o head.o init_task.o
 
 O_TARGET := kernel.o
diff -Nru a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
--- a/arch/s390/kernel/debug.c	Fri May 24 18:55:33 2002
+++ b/arch/s390/kernel/debug.c	Fri May 24 18:55:33 2002
@@ -71,7 +71,6 @@
 static struct proc_dir_entry 
 *debug_create_proc_dir_entry(struct proc_dir_entry *root,
 			     const char *name, mode_t mode,
-			     struct inode_operations *iops,
 			     struct file_operations *fops);
 static void debug_delete_proc_dir_entry(struct proc_dir_entry *root,
 					struct proc_dir_entry *entry);
@@ -151,28 +150,18 @@
 
 static debug_info_t *debug_area_first = NULL;
 static debug_info_t *debug_area_last = NULL;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-static struct semaphore debug_lock = MUTEX;
-#else
 DECLARE_MUTEX(debug_lock);
-#endif
 
 static int initialized = 0;
 
 static struct file_operations debug_file_ops = {
+	owner:	THIS_MODULE,
 	read:    debug_output,
 	write:   debug_input,	
 	open:    debug_open,
 	release: debug_close,
 };
 
-static struct inode_operations debug_inode_ops = {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	default_file_ops: &debug_file_ops,	/* file ops */
-#endif
-};
-
-
 static struct proc_dir_entry *debug_proc_root_entry;
 
 /* functions */
@@ -277,19 +266,15 @@
 
 	/* create proc rood directory */
 
-        rc->proc_root_entry =
-            debug_create_proc_dir_entry(debug_proc_root_entry, rc->name,
-                                        S_IFDIR | S_IRUGO | S_IXUGO |
-                                        S_IWUSR | S_IWGRP, NULL, NULL);
+        rc->proc_root_entry = proc_mkdir(rc->name, debug_proc_root_entry);
 
 	/* append new element to linked list */
 
-        if(debug_area_first == NULL){
+        if (debug_area_first == NULL) {
                 /* first element in list */
                 debug_area_first = rc;
                 rc->prev = NULL;
-        }
-        else{
+        } else {
                 /* append element to end of list */
                 debug_area_last->next = rc;
                 rc->prev = debug_area_last;
@@ -513,7 +498,6 @@
 #ifdef DEBUG
 	printk("debug_open\n");
 #endif
-	MOD_INC_USE_COUNT;
 	down(&debug_lock);
 
 	/* find debug log and view */
@@ -523,8 +507,8 @@
 		for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
 			if (debug_info->views[i] == NULL)
 				continue;
-			else if (debug_info->proc_entries[i]->low_ino ==
-				 file->f_dentry->d_inode->i_ino) {
+			else if (debug_info->proc_entries[i] ==
+				 PDE(file->f_dentry->d_inode)) {
 				goto found;	/* found view ! */
 			}
 		}
@@ -566,8 +550,6 @@
 
       out:
 	up(&debug_lock);
-	if (rc != 0)
-		MOD_DEC_USE_COUNT;
 	return rc;
 }
 
@@ -587,7 +569,6 @@
 	debug_info_free(p_info->debug_info_snap);
 	debug_info_put(p_info->debug_info_org);
 	kfree(file->private_data);
-	MOD_DEC_USE_COUNT;
 	return 0;		/* success */
 }
 
@@ -598,42 +579,11 @@
 
 static struct proc_dir_entry *debug_create_proc_dir_entry
     (struct proc_dir_entry *root, const char *name, mode_t mode,
-     struct inode_operations *iops, struct file_operations *fops) 
+     struct file_operations *fops) 
 {
-	struct proc_dir_entry *rc = NULL;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	const char *fn = name;
-	int len;
-	len = strlen(fn);
-
-	rc = (struct proc_dir_entry *) kmalloc(sizeof(struct proc_dir_entry)
-					       + len + 1, GFP_ATOMIC);
-	if (!rc)
-		goto out;
-
-	memset(rc, 0, sizeof(struct proc_dir_entry));
-	memcpy(((char *) rc) + sizeof(*rc), fn, len + 1);
-	rc->name = ((char *) rc) + sizeof(*rc);
-	rc->namelen = len;
-	rc->low_ino = 0, rc->mode = mode;
-	rc->nlink = 1;
-	rc->uid = 0;
-	rc->gid = 0;
-	rc->size = 0;
-	rc->get_info = NULL;
-	rc->ops = iops;
-
-	proc_register(root, rc);
-#else
-	rc = create_proc_entry(name, mode, root);
-	if (!rc)
-		goto out;
-	if (fops)
+	struct proc_dir_entry *rc = create_proc_entry(name, mode, root);
+	if (rc && fops)
 		rc->proc_fops = fops;
-#endif
-
-      out:
 	return rc;
 }
 
@@ -645,13 +595,7 @@
 static void debug_delete_proc_dir_entry
     (struct proc_dir_entry *root, struct proc_dir_entry *proc_entry) 
 {
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	proc_unregister(root, proc_entry->low_ino);
-	kfree(proc_entry);
-#else
 	remove_proc_entry(proc_entry->name, root);
-#endif
 }
 
 /*
@@ -906,11 +850,7 @@
 
 	down(&debug_lock);
 	if (!initialized) {
-		debug_proc_root_entry =
-		    debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT,
-						S_IFDIR | S_IRUGO | S_IXUGO
-						| S_IWUSR | S_IWGRP, NULL,
-						NULL);
+		debug_proc_root_entry = proc_mkdir(DEBUG_DIR_ROOT, NULL);
 		printk(KERN_INFO "debug: Initialization complete\n");
 		initialized = 1;
 	}
@@ -953,7 +893,6 @@
 		id->proc_entries[i] =
 		    debug_create_proc_dir_entry(id->proc_root_entry,
 						view->name, mode,
-						&debug_inode_ops,
 						&debug_file_ops);
 		rc = 0;
 	}
@@ -1271,7 +1210,7 @@
 #ifdef DEBUG
 	printk("debug_cleanup_module: \n");
 #endif
-	debug_delete_proc_dir_entry(&proc_root, debug_proc_root_entry);
+	debug_delete_proc_dir_entry(NULL, debug_proc_root_entry);
 	return;
 }
 
diff -Nru a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
--- a/arch/s390/kernel/smp.c	Fri May 24 18:55:33 2002
+++ b/arch/s390/kernel/smp.c	Fri May 24 18:55:33 2002
@@ -146,7 +146,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 {
 	struct call_data_struct data;
@@ -162,7 +162,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	/* Send a message to all other CPUs and wait for them to respond */
         smp_ext_bitcall_others(ec_call_function);
@@ -174,7 +174,7 @@
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
 			barrier();
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 
 	return 0;
 }
diff -Nru a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
--- a/arch/s390/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/s390/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for s390-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := -traditional
diff -Nru a/arch/s390/mm/init.c b/arch/s390/mm/init.c
--- a/arch/s390/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/s390/mm/init.c	Fri May 24 18:55:34 2002
@@ -87,7 +87,6 @@
         printk("%d pages shared\n",shared);
         printk("%d pages swap cached\n",cached);
         printk("%ld pages in page table cache\n",pgtable_cache_size);
-        printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/arch/s390x/boot/Makefile b/arch/s390x/boot/Makefile
--- a/arch/s390x/boot/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/s390x/boot/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
 O_TARGET := 
diff -Nru a/arch/s390x/kernel/Makefile b/arch/s390x/kernel/Makefile
--- a/arch/s390x/kernel/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/s390x/kernel/Makefile	Fri May 24 18:55:35 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 all: kernel.o head.o init_task.o
 
 O_TARGET	:= kernel.o
diff -Nru a/arch/s390x/kernel/debug.c b/arch/s390x/kernel/debug.c
--- a/arch/s390x/kernel/debug.c	Fri May 24 18:55:33 2002
+++ b/arch/s390x/kernel/debug.c	Fri May 24 18:55:33 2002
@@ -71,7 +71,6 @@
 static struct proc_dir_entry 
 *debug_create_proc_dir_entry(struct proc_dir_entry *root,
 			     const char *name, mode_t mode,
-			     struct inode_operations *iops,
 			     struct file_operations *fops);
 static void debug_delete_proc_dir_entry(struct proc_dir_entry *root,
 					struct proc_dir_entry *entry);
@@ -166,13 +165,6 @@
 	release: debug_close,
 };
 
-static struct inode_operations debug_inode_ops = {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	default_file_ops: &debug_file_ops,	/* file ops */
-#endif
-};
-
-
 static struct proc_dir_entry *debug_proc_root_entry;
 
 /* functions */
@@ -277,11 +269,7 @@
 
 	/* create proc rood directory */
 
-        rc->proc_root_entry =
-            debug_create_proc_dir_entry(debug_proc_root_entry, rc->name,
-                                        S_IFDIR | S_IRUGO | S_IXUGO |
-                                        S_IWUSR | S_IWGRP, NULL, NULL);
-
+        rc->proc_root_entry = proc_mkdir(rc->name, debug_proc_root_entry);
 	/* append new element to linked list */
 
         if(debug_area_first == NULL){
@@ -523,8 +511,8 @@
 		for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
 			if (debug_info->views[i] == NULL)
 				continue;
-			else if (debug_info->proc_entries[i]->low_ino ==
-				 file->f_dentry->d_inode->i_ino) {
+			else if (debug_info->proc_entries[i] ==
+				 PDE(file->f_dentry->d_inode)) {
 				goto found;	/* found view ! */
 			}
 		}
@@ -598,42 +586,11 @@
 
 static struct proc_dir_entry *debug_create_proc_dir_entry
     (struct proc_dir_entry *root, const char *name, mode_t mode,
-     struct inode_operations *iops, struct file_operations *fops) 
+     struct file_operations *fops) 
 {
-	struct proc_dir_entry *rc = NULL;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	const char *fn = name;
-	int len;
-	len = strlen(fn);
-
-	rc = (struct proc_dir_entry *) kmalloc(sizeof(struct proc_dir_entry)
-					       + len + 1, GFP_ATOMIC);
-	if (!rc)
-		goto out;
-
-	memset(rc, 0, sizeof(struct proc_dir_entry));
-	memcpy(((char *) rc) + sizeof(*rc), fn, len + 1);
-	rc->name = ((char *) rc) + sizeof(*rc);
-	rc->namelen = len;
-	rc->low_ino = 0, rc->mode = mode;
-	rc->nlink = 1;
-	rc->uid = 0;
-	rc->gid = 0;
-	rc->size = 0;
-	rc->get_info = NULL;
-	rc->ops = iops;
-
-	proc_register(root, rc);
-#else
-	rc = create_proc_entry(name, mode, root);
-	if (!rc)
-		goto out;
-	if (fops)
+	struct proc_dir_entry *rc = create_proc_entry(name, mode, root);
+	if (rc && fops)
 		rc->proc_fops = fops;
-#endif
-
-      out:
 	return rc;
 }
 
@@ -645,13 +602,7 @@
 static void debug_delete_proc_dir_entry
     (struct proc_dir_entry *root, struct proc_dir_entry *proc_entry) 
 {
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
-	proc_unregister(root, proc_entry->low_ino);
-	kfree(proc_entry);
-#else
 	remove_proc_entry(proc_entry->name, root);
-#endif
 }
 
 /*
@@ -906,11 +857,7 @@
 
 	down(&debug_lock);
 	if (!initialized) {
-		debug_proc_root_entry =
-		    debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT,
-						S_IFDIR | S_IRUGO | S_IXUGO
-						| S_IWUSR | S_IWGRP, NULL,
-						NULL);
+		debug_proc_root_entry = proc_mkdir(DEBUG_DIR_ROOT, NULL);
 		printk(KERN_INFO "debug: Initialization complete\n");
 		initialized = 1;
 	}
@@ -953,7 +900,6 @@
 		id->proc_entries[i] =
 		    debug_create_proc_dir_entry(id->proc_root_entry,
 						view->name, mode,
-						&debug_inode_ops,
 						&debug_file_ops);
 		rc = 0;
 	}
diff -Nru a/arch/s390x/kernel/smp.c b/arch/s390x/kernel/smp.c
--- a/arch/s390x/kernel/smp.c	Fri May 24 18:55:36 2002
+++ b/arch/s390x/kernel/smp.c	Fri May 24 18:55:36 2002
@@ -146,7 +146,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 {
 	struct call_data_struct data;
@@ -162,7 +162,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	/* Send a message to all other CPUs and wait for them to respond */
         smp_ext_bitcall_others(ec_call_function);
@@ -174,7 +174,7 @@
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
 			barrier();
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 
 	return 0;
 }
diff -Nru a/arch/s390x/lib/Makefile b/arch/s390x/lib/Makefile
--- a/arch/s390x/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/s390x/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for s390-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := -traditional
diff -Nru a/arch/s390x/mm/init.c b/arch/s390x/mm/init.c
--- a/arch/s390x/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/s390x/mm/init.c	Fri May 24 18:55:34 2002
@@ -87,7 +87,6 @@
         printk("%d pages shared\n",shared);
         printk("%d pages swap cached\n",cached);
         printk("%ld pages in page table cache\n",pgtable_cache_size);
-        printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/arch/sh/defconfig b/arch/sh/defconfig
--- a/arch/sh/defconfig	Fri May 24 18:55:33 2002
+++ b/arch/sh/defconfig	Fri May 24 18:55:33 2002
@@ -97,15 +97,6 @@
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -120,7 +111,6 @@
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
 
 #
diff -Nru a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
--- a/arch/sh/kernel/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/sh/kernel/Makefile	Fri May 24 18:55:36 2002
@@ -80,6 +80,4 @@
 obj-y		+= $(machine-specific-objs)
 endif
 
-USE_STANDARD_AS_RULE := true
-
 include $(TOPDIR)/Rules.make
diff -Nru a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
--- a/arch/sh/lib/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/sh/lib/Makefile	Fri May 24 18:55:35 2002
@@ -6,6 +6,4 @@
 obj-y  = delay.o memcpy.o memset.o memmove.o memchr.o old-checksum.o \
 	 checksum.o strcasecmp.o strlen.o
 
-USE_STANDARD_AS_RULE := true
-
 include $(TOPDIR)/Rules.make
diff -Nru a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile
--- a/arch/sh/mm/Makefile	Fri May 24 18:55:35 2002
+++ b/arch/sh/mm/Makefile	Fri May 24 18:55:35 2002
@@ -13,6 +13,4 @@
 obj-$(CONFIG_CPU_SH3) += cache-sh3.o
 obj-$(CONFIG_CPU_SH4) += cache-sh4.o __clear_user_page-sh4.o __copy_user_page-sh4.o ioremap.o
 
-USE_STANDARD_AS_RULE := true
-
 include $(TOPDIR)/Rules.make
diff -Nru a/arch/sh/mm/init.c b/arch/sh/mm/init.c
--- a/arch/sh/mm/init.c	Fri May 24 18:55:36 2002
+++ b/arch/sh/mm/init.c	Fri May 24 18:55:36 2002
@@ -70,7 +70,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
--- a/arch/sparc/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/sparc/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -7,8 +7,6 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
-
 SH = $(CONFIG_SHELL)
 
 all: kernel.o head.o init_task.o
diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
--- a/arch/sparc/kernel/ioport.c	Fri May 24 18:55:36 2002
+++ b/arch/sparc/kernel/ioport.c	Fri May 24 18:55:36 2002
@@ -351,7 +351,7 @@
  * CPU view of this memory may be inconsistent with
  * a device view and explicit flushing is necessary.
  */
-u32 sbus_map_single(struct sbus_dev *sdev, void *va, long len, int direction)
+dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *va, size_t len, int direction)
 {
 #if 0 /* This is the version that abuses consistent space */
 	unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK;
@@ -398,7 +398,7 @@
 #endif
 }
 
-void sbus_unmap_single(struct sbus_dev *sdev, u32 ba, long n, int direction)
+void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t ba, size_t n, int direction)
 {
 #if 0 /* This is the version that abuses consistent space */
 	struct resource *res;
@@ -445,7 +445,7 @@
 
 /*
  */
-void sbus_dma_sync_single(struct sbus_dev *sdev, u32 ba, long size, int direction)
+void sbus_dma_sync_single(struct sbus_dev *sdev, dma_addr_t ba, size_t size, int direction)
 {
 #if 0
 	unsigned long va;
diff -Nru a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
--- a/arch/sparc/lib/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/sparc/lib/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for Sparc library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 
 EXTRA_AFLAGS := -ansi -DST_DIV0=0x02
diff -Nru a/arch/sparc/math-emu/Makefile b/arch/sparc/math-emu/Makefile
--- a/arch/sparc/math-emu/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/sparc/math-emu/Makefile	Fri May 24 18:55:33 2002
@@ -7,7 +7,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
 
 O_TARGET := math-emu.o
 obj-y    := math.o ashldi3.o
diff -Nru a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
--- a/arch/sparc/mm/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/sparc/mm/Makefile	Fri May 24 18:55:36 2002
@@ -7,7 +7,6 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 O_TARGET := mm.o
diff -Nru a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
--- a/arch/sparc/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/sparc/mm/init.c	Fri May 24 18:55:35 2002
@@ -82,7 +82,6 @@
 	if (sparc_cpu_model == sun4m || sparc_cpu_model == sun4d)
 		printk("%ld entries in page dir cache\n",pgd_cache_size);
 #endif	
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 extern pgprot_t protection_map[16];
diff -Nru a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
--- a/arch/sparc/mm/srmmu.c	Fri May 24 18:55:33 2002
+++ b/arch/sparc/mm/srmmu.c	Fri May 24 18:55:33 2002
@@ -394,7 +394,6 @@
 
 static pte_t *srmmu_pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	BUG();
 	return NULL;
 }
 
diff -Nru a/arch/sparc64/defconfig b/arch/sparc64/defconfig
--- a/arch/sparc64/defconfig	Fri May 24 18:55:35 2002
+++ b/arch/sparc64/defconfig	Fri May 24 18:55:35 2002
@@ -265,15 +265,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -281,12 +272,16 @@
 # CONFIG_BLK_DEV_IDESCSI is not set
 
 #
-# ATA host chipset support
+# ATA host chip set support
 #
 # CONFIG_BLK_DEV_CMD640 is not set
 # CONFIG_BLK_DEV_CMD640_ENHANCED is not set
 # CONFIG_BLK_DEV_ISAPNP is not set
 # CONFIG_BLK_DEV_RZ1000 is not set
+
+#
+#   PCI host chip set support
+#
 # CONFIG_BLK_DEV_OFFBOARD is not set
 # CONFIG_IDEPCI_SHARE_IRQ is not set
 CONFIG_BLK_DEV_IDEDMA_PCI=y
@@ -321,7 +316,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_IVB is not set
 CONFIG_IDEDMA_AUTO=y
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
 # CONFIG_BLK_DEV_ATARAID_HPT is not set
@@ -393,7 +387,6 @@
 # Fusion MPT device support
 #
 CONFIG_FUSION=m
-# CONFIG_FUSION_BOOT is not set
 
 #
 # (ability to boot linux kernel from Fusion device is DISABLED!)
@@ -622,6 +615,9 @@
 # File systems
 #
 # CONFIG_QUOTA is not set
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+# CONFIG_QIFACE_COMPAT is not set
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 # CONFIG_REISERFS_FS is not set
@@ -782,10 +778,11 @@
 # USB Host Controller Drivers
 #
 CONFIG_USB_EHCI_HCD=m
-# CONFIG_USB_OHCI_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_UHCI_HCD_ALT is not set
 CONFIG_USB_UHCI=y
 # CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=y
 
 #
 # USB Device Class drivers
@@ -802,6 +799,7 @@
 CONFIG_USB_STORAGE_DPCM=y
 CONFIG_USB_STORAGE_HP8200e=y
 CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
@@ -809,7 +807,7 @@
 #
 CONFIG_USB_HID=y
 CONFIG_USB_HIDINPUT=y
-# CONFIG_USB_HIDDEV is not set
+CONFIG_USB_HIDDEV=y
 CONFIG_USB_WACOM=m
 
 #
diff -Nru a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
--- a/arch/sparc64/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/sparc64/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -4,7 +4,6 @@
 
 SH = $(CONFIG_SHELL)
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 all: kernel.o head.o init_task.o
diff -Nru a/arch/sparc64/kernel/binfmt_aout32.c b/arch/sparc64/kernel/binfmt_aout32.c
--- a/arch/sparc64/kernel/binfmt_aout32.c	Fri May 24 18:55:35 2002
+++ b/arch/sparc64/kernel/binfmt_aout32.c	Fri May 24 18:55:35 2002
@@ -408,7 +408,5 @@
 	unregister_binfmt(&aout32_format);
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_aout32_binfmt);
 module_exit(exit_aout32_binfmt);
diff -Nru a/arch/sparc64/kernel/central.c b/arch/sparc64/kernel/central.c
--- a/arch/sparc64/kernel/central.c	Fri May 24 18:55:36 2002
+++ b/arch/sparc64/kernel/central.c	Fri May 24 18:55:36 2002
@@ -77,7 +77,7 @@
 		      struct linux_prom_registers *regs,
 		      int nregs)
 {
-	if(fhc->num_fhc_ranges)
+	if (fhc->num_fhc_ranges)
 		adjust_regs(regs, nregs, fhc->fhc_ranges,
 			    fhc->num_fhc_ranges);
 }
@@ -86,7 +86,7 @@
 void apply_central_ranges(struct linux_central *central,
 			  struct linux_prom_registers *regs, int nregs)
 {
-	if(central->num_central_ranges)
+	if (central->num_central_ranges)
 		adjust_regs(regs, nregs, central->central_ranges,
 			    central->num_central_ranges);
 }
@@ -114,7 +114,7 @@
 		prom_printf("FHC: Cannot find any toplevel firehose controllers.\n");
 		prom_halt();
 	}
-	while(node) {
+	while (node) {
 		struct linux_fhc *fhc;
 		int board;
 		u32 tmp;
@@ -139,7 +139,7 @@
 		fhc_ranges_init(node, fhc);
 
 		/* Non-central FHC's have 64-bit OBP format registers. */
-		if(prom_getproperty(node, "reg",
+		if (prom_getproperty(node, "reg",
 				    (char *)&fpregs[0], sizeof(fpregs)) == -1) {
 			prom_printf("FHC: Fatal error, cannot get fhc regs.\n");
 			prom_halt();
@@ -157,7 +157,7 @@
 		fhc->board = board;
 
 		tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_JCTRL);
-		if((tmp & FHC_JTAG_CTRL_MENAB) != 0)
+		if ((tmp & FHC_JTAG_CTRL_MENAB) != 0)
 			fhc->jtag_master = 1;
 		else
 			fhc->jtag_master = 0;
@@ -180,10 +180,10 @@
 
 		/* Look for the next FHC. */
 		node = prom_getsibling(node);
-		if(node == 0)
+		if (node == 0)
 			break;
 		node = prom_searchsiblings(node, "fhc");
-		if(node == 0)
+		if (node == 0)
 			break;
 	}
 }
@@ -196,7 +196,7 @@
 	int clknode, nslots, tmp, nregs;
 
 	clknode = prom_searchsiblings(prom_getchild(fnode), "clock-board");
-	if(clknode == 0 || clknode == -1) {
+	if (clknode == 0 || clknode == -1) {
 		prom_printf("Critical error, central lacks clock-board.\n");
 		prom_halt();
 	}
@@ -213,7 +213,7 @@
 	central->clkregs = ((((unsigned long)cregs[1].which_io) << 32UL) |
 			    ((unsigned long)cregs[1].phys_addr));
 
-	if(nregs == 2)
+	if (nregs == 2)
 		central->clkver = 0UL;
 	else
 		central->clkver = ((((unsigned long)cregs[2].which_io) << 32UL) |
@@ -229,9 +229,9 @@
 		nslots = 8;
 		break;
 	case 0x80:
-		if(central->clkver != 0UL &&
+		if (central->clkver != 0UL &&
 		   upa_readb(central->clkver) != 0) {
-			if((upa_readb(central->clkver) & 0x80) != 0)
+			if ((upa_readb(central->clkver) & 0x80) != 0)
 				nslots = 4;
 			else
 				nslots = 5;
@@ -251,7 +251,7 @@
 {
 	struct linux_fhc *fhc;
 
-	for(fhc = fhc_list; fhc != NULL; fhc = fhc->next) {
+	for (fhc = fhc_list; fhc != NULL; fhc = fhc->next) {
 		u32 tmp;
 
 		/* Clear all of the interrupt mapping registers
@@ -282,7 +282,7 @@
 		tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
 
 		/* All non-central boards have this bit set. */
-		if(! IS_CENTRAL_FHC(fhc))
+		if (! IS_CENTRAL_FHC(fhc))
 			tmp |= FHC_CONTROL_IXIST;
 
 		/* For all FHCs, clear the firmware synchronization
@@ -304,7 +304,7 @@
 	int cnode, fnode, err;
 
 	cnode = prom_finddevice("/central");
-	if(cnode == 0 || cnode == -1) {
+	if (cnode == 0 || cnode == -1) {
 		if (this_is_starfire)
 			starfire_cpu_setup();
 		return;
@@ -340,7 +340,7 @@
 
 	fhc->parent = central_bus;
 	fnode = prom_searchsiblings(prom_getchild(cnode), "fhc");
-	if(fnode == 0 || fnode == -1) {
+	if (fnode == 0 || fnode == -1) {
 		prom_printf("Critical error, central board lacks fhc.\n");
 		prom_halt();
 	}
@@ -418,7 +418,7 @@
 	tmp = upa_readb(central->clkregs + CLOCK_CTRL);
 
 	/* NOTE: reverse logic on this bit */
-	if(on)
+	if (on)
 		tmp &= ~(CLOCK_CTRL_RLED);
 	else
 		tmp |= CLOCK_CTRL_RLED;
@@ -435,8 +435,8 @@
 	struct linux_fhc *fhc;
 
 	central_ledblink(central_bus, led_state);
-	for(fhc = fhc_list; fhc != NULL; fhc = fhc->next)
-		if(! IS_CENTRAL_FHC(fhc))
+	for (fhc = fhc_list; fhc != NULL; fhc = fhc->next)
+		if (! IS_CENTRAL_FHC(fhc))
 			fhc_ledblink(fhc, led_state);
 	led_state = ! led_state;
 	sftimer.expires = jiffies + (HZ >> 1);
diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
--- a/arch/sparc64/kernel/entry.S	Fri May 24 18:55:33 2002
+++ b/arch/sparc64/kernel/entry.S	Fri May 24 18:55:33 2002
@@ -1429,7 +1429,7 @@
 sys_clone:	flushw
 		movrz		%o1, %fp, %o1
 		mov		0, %o3
-		ba,pt		%xcc, do_fork_FIXME_NOW_RETURNS_TASK_STRUCT
+		ba,pt		%xcc, sparc_do_fork
 		 add		%sp, STACK_BIAS + REGWIN_SZ, %o2
 ret_from_syscall:
 		/* Clear SPARC_FLAG_NEWCHILD, switch_to leaves thread.flags in
diff -Nru a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
--- a/arch/sparc64/kernel/process.c	Fri May 24 18:55:35 2002
+++ b/arch/sparc64/kernel/process.c	Fri May 24 18:55:35 2002
@@ -582,6 +582,17 @@
 	do_exit(SIGILL);
 }
 
+asmlinkage int sparc_do_fork(unsigned long clone_flags,
+			     unsigned long stack_start,
+			     struct pt_regs *regs,
+			     unsigned long stack_size)
+{
+	struct task_struct *p = do_fork(clone_flags, stack_start,
+					regs, stack_size);
+
+	return IS_ERR(p) ? PTR_ERR(p) : p->pid;
+}
+
 /* Copy a Sparc thread.  The fork() return value conventions
  * under SunOS are nothing short of bletcherous:
  * Parent -->  %o0 == childs  pid, %o1 == 0
diff -Nru a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
--- a/arch/sparc64/kernel/smp.c	Fri May 24 18:55:33 2002
+++ b/arch/sparc64/kernel/smp.c	Fri May 24 18:55:33 2002
@@ -551,6 +551,10 @@
 
 extern unsigned long xcall_call_function;
 
+/*
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
 int smp_call_function(void (*func)(void *info), void *info,
 		      int nonatomic, int wait)
 {
@@ -566,7 +570,7 @@
 	atomic_set(&data.finished, 0);
 	data.wait = wait;
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 
 	call_data = &data;
 
@@ -584,12 +588,12 @@
 		udelay(1);
 	}
 
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 
 	return 0;
 
 out_timeout:
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 	printk("XCALL: Remote cpus not responding, ncpus=%d finished=%d\n",
 	       smp_num_cpus - 1, atomic_read(&data.finished));
 	return 0;
@@ -824,30 +828,26 @@
 	}
 }
 
-void smp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
+void smp_flush_tlb_range(struct mm_struct *mm, unsigned long start,
 			 unsigned long end)
 {
-	struct mm_struct *mm = vma->vm_mm;
-
-	{
-		u32 ctx = CTX_HWBITS(mm->context);
-		int cpu = smp_processor_id();
+	u32 ctx = CTX_HWBITS(mm->context);
+	int cpu = smp_processor_id();
 
-		start &= PAGE_MASK;
-		end    = PAGE_ALIGN(end);
+	start &= PAGE_MASK;
+	end    = PAGE_ALIGN(end);
 
-		if (mm == current->active_mm && atomic_read(&mm->mm_users) == 1) {
-			mm->cpu_vm_mask = (1UL << cpu);
-			goto local_flush_and_out;
-		}
+	if (mm == current->active_mm && atomic_read(&mm->mm_users) == 1) {
+		mm->cpu_vm_mask = (1UL << cpu);
+		goto local_flush_and_out;
+	}
 
-		smp_cross_call_masked(&xcall_flush_tlb_range,
-				      ctx, start, end,
-				      mm->cpu_vm_mask);
+	smp_cross_call_masked(&xcall_flush_tlb_range,
+			      ctx, start, end,
+			      mm->cpu_vm_mask);
 
-	local_flush_and_out:
-		__flush_tlb_range(ctx, start, SECONDARY_CONTEXT, end, PAGE_SIZE, (end-start));
-	}
+ local_flush_and_out:
+	__flush_tlb_range(ctx, start, SECONDARY_CONTEXT, end, PAGE_SIZE, (end-start));
 }
 
 void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end)
diff -Nru a/arch/sparc64/lib/Makefile b/arch/sparc64/lib/Makefile
--- a/arch/sparc64/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/sparc64/lib/Makefile	Fri May 24 18:55:33 2002
@@ -2,7 +2,6 @@
 # Makefile for Sparc64 library files..
 #
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 L_TARGET = lib.a
diff -Nru a/arch/sparc64/mm/Makefile b/arch/sparc64/mm/Makefile
--- a/arch/sparc64/mm/Makefile	Fri May 24 18:55:36 2002
+++ b/arch/sparc64/mm/Makefile	Fri May 24 18:55:36 2002
@@ -2,7 +2,6 @@
 # Makefile for the linux Sparc64-specific parts of the memory manager.
 #
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 O_TARGET := mm.o
diff -Nru a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
--- a/arch/sparc64/mm/init.c	Fri May 24 18:55:35 2002
+++ b/arch/sparc64/mm/init.c	Fri May 24 18:55:35 2002
@@ -341,7 +341,6 @@
 #ifndef CONFIG_SMP
 	printk("%d entries in page dir cache\n",pgd_cache_size);
 #endif	
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 void mmu_info(struct seq_file *m)
diff -Nru a/arch/sparc64/prom/Makefile b/arch/sparc64/prom/Makefile
--- a/arch/sparc64/prom/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/sparc64/prom/Makefile	Fri May 24 18:55:34 2002
@@ -3,7 +3,6 @@
 # Linux.
 #
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 L_TARGET = promlib.a
diff -Nru a/arch/sparc64/solaris/Makefile b/arch/sparc64/solaris/Makefile
--- a/arch/sparc64/solaris/Makefile	Fri May 24 18:55:33 2002
+++ b/arch/sparc64/solaris/Makefile	Fri May 24 18:55:33 2002
@@ -2,11 +2,10 @@
 # Makefile for the Solaris binary emulation.
 #
 
-USE_STANDARD_AS_RULE := true
 EXTRA_AFLAGS := -ansi
 
 ifeq ($(CONFIG_SOLARIS_EMUL),m)
-  EXTRA_AFLAGS += $(MODFLAGS)
+  EXTRA_AFLAGS += $(CFLAGS_MODULE) # FIXME
 endif
 
 solaris-objs := entry64.o fs.o misc.o signal.o systbl.o socket.o \
diff -Nru a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
--- a/arch/sparc64/solaris/fs.c	Fri May 24 18:55:34 2002
+++ b/arch/sparc64/solaris/fs.c	Fri May 24 18:55:34 2002
@@ -11,6 +11,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/namei.h>
 #include <linux/mm.h>
 #include <linux/file.h>
 #include <linux/stat.h>
diff -Nru a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
--- a/arch/sparc64/solaris/misc.c	Fri May 24 18:55:35 2002
+++ b/arch/sparc64/solaris/misc.c	Fri May 24 18:55:35 2002
@@ -725,7 +725,6 @@
 
 MODULE_AUTHOR("Jakub Jelinek (jj@ultra.linux.cz), Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz)");
 MODULE_DESCRIPTION("Solaris binary emulation module");
-EXPORT_NO_SYMBOLS;
 
 #ifdef __sparc_v9__
 extern u32 tl0_solaris[8];
diff -Nru a/arch/x86_64/defconfig b/arch/x86_64/defconfig
--- a/arch/x86_64/defconfig	Fri May 24 18:55:36 2002
+++ b/arch/x86_64/defconfig	Fri May 24 18:55:36 2002
@@ -183,15 +183,6 @@
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
 # CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set
-# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set
-# CONFIG_BLK_DEV_IDEDISK_IBM is not set
-# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set
-# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set
-# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set
-# CONFIG_BLK_DEV_IDEDISK_WD is not set
-# CONFIG_BLK_DEV_COMMERIAL is not set
-# CONFIG_BLK_DEV_TIVO is not set
 # CONFIG_BLK_DEV_IDECS is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -238,7 +229,6 @@
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_IDEDMA_IVB is not set
 CONFIG_IDEDMA_AUTO=y
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_ATARAID is not set
 # CONFIG_BLK_DEV_ATARAID_PDC is not set
 # CONFIG_BLK_DEV_ATARAID_HPT is not set
diff -Nru a/arch/x86_64/ia32/Makefile b/arch/x86_64/ia32/Makefile
--- a/arch/x86_64/ia32/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/ia32/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for the ia32 kernel emulation subsystem.
 #
 
-USE_STANDARD_AS_RULE := true
-
 export-objs := ia32_ioctl.o	
 
 all: ia32.o
diff -Nru a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
--- a/arch/x86_64/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for the linux kernel.
 #
 
-USE_STANDARD_AS_RULE := true
-
 EXTRA_AFLAGS := -traditional
 
 all: kernel.o head.o head64.o init_task.o
diff -Nru a/arch/x86_64/kernel/bluesmoke.c b/arch/x86_64/kernel/bluesmoke.c
--- a/arch/x86_64/kernel/bluesmoke.c	Fri May 24 18:55:36 2002
+++ b/arch/x86_64/kernel/bluesmoke.c	Fri May 24 18:55:36 2002
@@ -5,7 +5,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/smp.h>
 #include <linux/config.h>
 #include <linux/irq.h>
diff -Nru a/arch/x86_64/kernel/cpuid.c b/arch/x86_64/kernel/cpuid.c
--- a/arch/x86_64/kernel/cpuid.c	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/kernel/cpuid.c	Fri May 24 18:55:34 2002
@@ -171,8 +171,6 @@
 module_init(cpuid_init);
 module_exit(cpuid_exit)
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>");
 MODULE_DESCRIPTION("x86 generic CPUID driver");
 MODULE_LICENSE("GPL");
diff -Nru a/arch/x86_64/kernel/msr.c b/arch/x86_64/kernel/msr.c
--- a/arch/x86_64/kernel/msr.c	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/kernel/msr.c	Fri May 24 18:55:34 2002
@@ -272,8 +272,6 @@
 module_init(msr_init);
 module_exit(msr_exit)
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>");
 MODULE_DESCRIPTION("x86 generic MSR driver");
 MODULE_LICENSE("GPL");
diff -Nru a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
--- a/arch/x86_64/kernel/smp.c	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/kernel/smp.c	Fri May 24 18:55:34 2002
@@ -380,7 +380,7 @@
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
  * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler, you may call it from a bottom half handler.
+ * hardware interrupt handler or from a bottom half handler.
  */
 {
 	struct call_data_struct data;
@@ -396,7 +396,7 @@
 	if (wait)
 		atomic_set(&data.finished, 0);
 
-	spin_lock_bh(&call_lock);
+	spin_lock(&call_lock);
 	call_data = &data;
 	wmb();
 	/* Send a message to all other CPUs and wait for them to respond */
@@ -409,7 +409,7 @@
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
 			barrier();
-	spin_unlock_bh(&call_lock);
+	spin_unlock(&call_lock);
 
 	return 0;
 }
diff -Nru a/arch/x86_64/lib/Makefile b/arch/x86_64/lib/Makefile
--- a/arch/x86_64/lib/Makefile	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/lib/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for x86_64-specific library files..
 #
 
-USE_STANDARD_AS_RULE := true
-
 L_TARGET = lib.a
 obj-y  = generic-checksum.o old-checksum.o delay.o \
 	usercopy.o getuser.o putuser.o  \
diff -Nru a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
--- a/arch/x86_64/mm/init.c	Fri May 24 18:55:34 2002
+++ b/arch/x86_64/mm/init.c	Fri May 24 18:55:34 2002
@@ -67,7 +67,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld buffermem pages\n", nr_buffermem_pages());
 }
 
 /* References to section boundaries */
diff -Nru a/drivers/acorn/block/Makefile b/drivers/acorn/block/Makefile
--- a/drivers/acorn/block/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/acorn/block/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for the Acorn block device drivers.
 #
 
-USE_STANDARD_AS_RULE := true
-
 O_TARGET	:= acorn-block.o
 
 obj-y		:=
diff -Nru a/drivers/acorn/block/mfmhd.c b/drivers/acorn/block/mfmhd.c
--- a/drivers/acorn/block/mfmhd.c	Fri May 24 18:55:34 2002
+++ b/drivers/acorn/block/mfmhd.c	Fri May 24 18:55:34 2002
@@ -889,17 +889,6 @@
 {
 	DBG("mfm_request CURRENT=%p Busy=%d\n", CURRENT, Busy);
 
-	if (QUEUE_EMPTY) {
-		DBG("mfm_request: Exited due to NULL Current 1\n");
-		return;
-	}
-
-	if (CURRENT->rq_status == RQ_INACTIVE) {
-		/* Hmm - seems to be happening a lot on 1.3.45 */
-		/*console_printf("mfm_request: Exited due to INACTIVE Current\n"); */
-		return;
-	}
-
 	/* If we are still processing then return; we will get called again */
 	if (Busy) {
 		/* Again seems to be common in 1.3.45 */
@@ -914,16 +903,14 @@
 		DBG("mfm_request: loop start\n");
 		sti();
 
-		DBG("mfm_request: before INIT_REQUEST\n");
+		DBG("mfm_request: before blk_queue_empty\n");
 
-		if (QUEUE_EMPTY) {
-			printk("mfm_request: Exiting due to !CURRENT (pre)\n");
+		if (blk_queue_empty(QUEUE)) {
+			printk("mfm_request: Exiting due to empty queue (pre)\n");
 			CLEAR_INTR;
 			Busy = 0;
 			return;
-		};
-
-		INIT_REQUEST;
+		}
 
 		DBG("mfm_request:                 before arg extraction\n");
 
@@ -1472,7 +1459,6 @@
 
 #ifdef MODULE
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
 
 int init_module(void)
diff -Nru a/drivers/acorn/char/mouse_rpc.c b/drivers/acorn/char/mouse_rpc.c
--- a/drivers/acorn/char/mouse_rpc.c	Fri May 24 18:55:35 2002
+++ b/drivers/acorn/char/mouse_rpc.c	Fri May 24 18:55:35 2002
@@ -17,6 +17,7 @@
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/errno.h>
 
 #include <asm/hardware.h>
 #include <asm/irq.h>
@@ -87,4 +88,4 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("RiscPC mouse driver");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/char/serial-card.c b/drivers/acorn/char/serial-card.c
--- a/drivers/acorn/char/serial-card.c	Fri May 24 18:55:36 2002
+++ b/drivers/acorn/char/serial-card.c	Fri May 24 18:55:36 2002
@@ -113,8 +113,6 @@
 			ecard_release (expcard[i]);
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Russell King");
 MODULE_LICENSE("GPL");
 
diff -Nru a/drivers/acorn/net/Makefile b/drivers/acorn/net/Makefile
--- a/drivers/acorn/net/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/net/Makefile	Fri May 24 18:55:33 2002
@@ -3,13 +3,6 @@
 # Makefile for the Acorn ethercard network device drivers
 #
 
-O_TARGET := acorn-net.o
-
-obj-y	:=
-obj-m	:=
-obj-n	:=
-obj-	:=
-
 obj-$(CONFIG_ARM_ETHERH)	+= etherh.o
 obj-$(CONFIG_ARM_ETHER3)	+= ether3.o
 obj-$(CONFIG_ARM_ETHER1)	+= ether1.o
diff -Nru a/drivers/acorn/net/etherh.c b/drivers/acorn/net/etherh.c
--- a/drivers/acorn/net/etherh.c	Fri May 24 18:55:36 2002
+++ b/drivers/acorn/net/etherh.c	Fri May 24 18:55:36 2002
@@ -66,6 +66,7 @@
 };
 
 struct etherh_priv {
+	struct ei_device eidev;
 	unsigned int	id;
 	unsigned int	ctrl_port;
 	unsigned int	ctrl;
@@ -150,8 +151,8 @@
 static void
 etherh_setif(struct net_device *dev)
 {
-	struct ei_device *ei_local = (struct ei_device *) dev->priv;
-	struct etherh_priv *eh = (struct etherh_priv *)dev->rmem_start;
+	struct etherh_priv *eh = (struct etherh_priv *)dev->priv;
+	struct ei_device *ei_local = &eh->eidev;
 	unsigned long addr, flags;
 
 	local_irq_save(flags);
@@ -194,8 +195,8 @@
 static int
 etherh_getifstat(struct net_device *dev)
 {
-	struct ei_device *ei_local = (struct ei_device *) dev->priv;
-	struct etherh_priv *eh = (struct etherh_priv *)dev->rmem_start;
+	struct etherh_priv *eh = (struct etherh_priv *)dev->priv;
+	struct ei_device *ei_local = &eh->eidev;
 	int stat = 0;
 
 	switch (eh->id) {
@@ -560,6 +561,9 @@
 	if (!eh)
 		goto out_nopriv;
 
+	memset(eh, 0, sizeof(struct etherh_priv));
+	spin_lock_init(&eh->eidev.page_lock);
+
 	SET_MODULE_OWNER(dev);
 
 	dev->open	= etherh_open;
@@ -567,7 +571,7 @@
 	dev->set_config	= etherh_set_config;
 	dev->irq	= ec->irq;
 	dev->base_addr	= ecard_address(ec, ECARD_MEMC, 0);
-	dev->rmem_start	= (unsigned long)eh;
+	dev->priv	= eh;
 
 	/*
 	 * IRQ and control port handling
diff -Nru a/drivers/acorn/scsi/Makefile b/drivers/acorn/scsi/Makefile
--- a/drivers/acorn/scsi/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/scsi/Makefile	Fri May 24 18:55:33 2002
@@ -2,15 +2,6 @@
 # Makefile for drivers/acorn/scsi
 #
 
-USE_STANDARD_AS_RULE := true
-
-O_TARGET	:= acorn-scsi.o
-
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
-
 export-objs		:= fas216.o queue.o msgqueue.o
 acornscsi_mod-objs	:= acornscsi.o acornscsi-io.o
 
diff -Nru a/drivers/acorn/scsi/acornscsi.c b/drivers/acorn/scsi/acornscsi.c
--- a/drivers/acorn/scsi/acornscsi.c	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/scsi/acornscsi.c	Fri May 24 18:55:33 2002
@@ -157,6 +157,7 @@
 #include "../../scsi/constants.h"
 #include "acornscsi.h"
 #include "msgqueue.h"
+#include "scsi.h"
 
 #include <scsi/scsicam.h>
 
@@ -902,17 +903,8 @@
     SCp->ptr += length;
     SCp->this_residual -= length;
 
-    if (!SCp->this_residual) {
-	if (SCp->buffers_residual) {
-	    SCp->buffer++;
-	    SCp->buffers_residual--;
-	    SCp->ptr = (char *)SCp->buffer->address;
-	    SCp->this_residual = SCp->buffer->length;
-	} else {
-	    SCp->ptr = NULL;
-	    host->dma.xfer_done = 1;
-	}
-    }
+    if (SCp->this_residual == 0 && next_SCp(SCp) == 0)
+	host->dma.xfer_done = 1;
 }
 
 /*
@@ -2558,20 +2550,8 @@
     SCpnt->SCp.phase = (int)acornscsi_datadirection(SCpnt->cmnd[0]);
     SCpnt->SCp.sent_command = 0;
     SCpnt->SCp.scsi_xferred = 0;
-    SCpnt->SCp.Status = 0;
-    SCpnt->SCp.Message = 0;
 
-    if (SCpnt->use_sg) {
-	SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->buffer;
-	SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
-	SCpnt->SCp.ptr = (char *) SCpnt->SCp.buffer->address;
-	SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
-    } else {
-	SCpnt->SCp.buffer = NULL;
-	SCpnt->SCp.buffers_residual = 0;
-	SCpnt->SCp.ptr = (char *) SCpnt->request_buffer;
-	SCpnt->SCp.this_residual = SCpnt->request_bufflen;
-    }
+    init_SCp(SCpnt);
 
     host->stats.queues += 1;
 
@@ -3180,4 +3160,4 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("AcornSCSI driver");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/arxescsi.c b/drivers/acorn/scsi/arxescsi.c
--- a/drivers/acorn/scsi/arxescsi.c	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/scsi/arxescsi.c	Fri May 24 18:55:33 2002
@@ -452,4 +452,4 @@
 MODULE_AUTHOR("Stefan Hanske");
 MODULE_DESCRIPTION("ARXESCSI driver for Acorn machines");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/cumana_1.c b/drivers/acorn/scsi/cumana_1.c
--- a/drivers/acorn/scsi/cumana_1.c	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/scsi/cumana_1.c	Fri May 24 18:55:33 2002
@@ -426,4 +426,4 @@
 module_exit(cumanascsi_exit);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/cumana_2.c b/drivers/acorn/scsi/cumana_2.c
--- a/drivers/acorn/scsi/cumana_2.c	Fri May 24 18:55:36 2002
+++ b/drivers/acorn/scsi/cumana_2.c	Fri May 24 18:55:36 2002
@@ -38,6 +38,7 @@
 #include "../../scsi/sd.h"
 #include "../../scsi/hosts.h"
 #include "fas216.h"
+#include "scsi.h"
 
 #include <scsi/scsicam.h>
 
@@ -188,15 +189,9 @@
 
 	if (dmach != NO_DMA &&
 	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {
-		int bufs = SCp->buffers_residual;
-		int pci_dir, dma_dir, alatch_dir;
+		int bufs, pci_dir, dma_dir, alatch_dir;
 
-		if (bufs)
-			memcpy(info->sg + 1, SCp->buffer + 1,
-				sizeof(struct scatterlist) * bufs);
-		info->sg[0].address = SCp->ptr;
-		info->sg[0].page    = NULL;
-		info->sg[0].length  = SCp->this_residual;
+		bufs = copy_SCp_to_sg(&info->sg[0], SCp, NR_SG);
 
 		if (direction == DMA_OUT)
 			pci_dir = PCI_DMA_TODEVICE,
@@ -605,4 +600,4 @@
 MODULE_PARM(term, "1-8i");
 MODULE_PARM_DESC(term, "SCSI bus termination");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/ecoscsi.c b/drivers/acorn/scsi/ecoscsi.c
--- a/drivers/acorn/scsi/ecoscsi.c	Fri May 24 18:55:36 2002
+++ b/drivers/acorn/scsi/ecoscsi.c	Fri May 24 18:55:36 2002
@@ -299,4 +299,4 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/eesox.c b/drivers/acorn/scsi/eesox.c
--- a/drivers/acorn/scsi/eesox.c	Fri May 24 18:55:35 2002
+++ b/drivers/acorn/scsi/eesox.c	Fri May 24 18:55:35 2002
@@ -44,6 +44,7 @@
 #include "../../scsi/sd.h"
 #include "../../scsi/hosts.h"
 #include "fas216.h"
+#include "scsi.h"
 
 #include <scsi/scsicam.h>
 
@@ -192,15 +193,9 @@
 
 	if (dmach != NO_DMA &&
 	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {
-		int bufs = SCp->buffers_residual;
-		int pci_dir, dma_dir;
+		int bufs, pci_dir, dma_dir;
 
-		if (bufs)
-			memcpy(info->sg + 1, SCp->buffer + 1,
-				sizeof(struct scatterlist) * bufs);
-		info->sg[0].address = SCp->ptr;
-		info->sg[0].page    = NULL;
-		info->sg[0].length  = SCp->this_residual;
+		bufs = copy_SCp_to_sg(&info->sg[0], SCp, NR_SG);
 
 		if (direction == DMA_OUT)
 			pci_dir = PCI_DMA_TODEVICE,
@@ -602,4 +597,4 @@
 MODULE_PARM(term, "1-8i");
 MODULE_PARM_DESC(term, "SCSI bus termination");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/fas216.c b/drivers/acorn/scsi/fas216.c
--- a/drivers/acorn/scsi/fas216.c	Fri May 24 18:55:35 2002
+++ b/drivers/acorn/scsi/fas216.c	Fri May 24 18:55:35 2002
@@ -59,6 +59,7 @@
 #include "../../scsi/scsi.h"
 #include "../../scsi/hosts.h"
 #include "fas216.h"
+#include "scsi.h"
 
 #define VER_MAJOR	0
 #define VER_MINOR	0
@@ -588,38 +589,32 @@
 static void
 fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
 {
-	unsigned char *ptr;
-	unsigned int residual;
+	Scsi_Pointer *SCp = &info->scsi.SCp;
 
 	fas216_checkmagic(info);
 
-	ptr = info->scsi.SCp.ptr;
-	residual = info->scsi.SCp.this_residual;
-
 	info->SCpnt->request_bufflen -= bytes_transferred;
 
-	while (residual <= bytes_transferred && bytes_transferred) {
-		/* We have used up this buffer */
-		bytes_transferred -= residual;
-		if (info->scsi.SCp.buffers_residual) {
-			info->scsi.SCp.buffer++;
-			info->scsi.SCp.buffers_residual--;
-			ptr = (unsigned char *)info->scsi.SCp.buffer->address;
-			residual = info->scsi.SCp.buffer->length;
-		} else {
-			ptr = NULL;
-			residual = 0;
+	while (bytes_transferred != 0) {
+		if (SCp->this_residual > bytes_transferred)
+			break;
+		/*
+		 * We have used up this buffer.  Move on to the
+		 * next buffer.
+		 */
+		bytes_transferred -= SCp->this_residual;
+		if (!next_SCp(&info->scsi.SCp)) {
+			printk(KERN_WARNING "scsi%d.%c: out of buffers\n",
+				info->host->host_no, '0' + info->SCpnt->target);
+			return;
 		}
 	}
 
-	residual -= bytes_transferred;
-	ptr += bytes_transferred;
-
-	if (residual == 0)
-		ptr = NULL;
-
-	info->scsi.SCp.ptr = ptr;
-	info->scsi.SCp.this_residual = residual;
+	SCp->this_residual -= bytes_transferred;
+	if (SCp->this_residual)
+		SCp->ptr += bytes_transferred;
+	else
+		SCp->ptr = NULL;
 }
 
 /* Function: void fas216_pio(FAS216_Info *info, fasdmadir_t direction)
@@ -631,35 +626,12 @@
 static void
 fas216_pio(FAS216_Info *info, fasdmadir_t direction)
 {
-	unsigned int residual;
-	char *ptr;
-
 	fas216_checkmagic(info);
 
-	residual = info->scsi.SCp.this_residual;
-	ptr = info->scsi.SCp.ptr;
-
 	if (direction == DMA_OUT)
-		outb(*ptr++, REG_FF(info));
+		outb(get_next_SCp_byte(&info->scsi.SCp), REG_FF(info));
 	else
-		*ptr++ = inb(REG_FF(info));
-
-	residual -= 1;
-
-	if (residual == 0) {
-		if (info->scsi.SCp.buffers_residual) {
-			info->scsi.SCp.buffer++;
-			info->scsi.SCp.buffers_residual--;
-			ptr = (unsigned char *)info->scsi.SCp.buffer->address;
-			residual = info->scsi.SCp.buffer->length;
-		} else {
-			ptr = NULL;
-			residual = 0;
-		}
-	}
-
-	info->scsi.SCp.ptr = ptr;
-	info->scsi.SCp.this_residual = residual;
+		put_next_SCp_byte(&info->scsi.SCp, inb(REG_FF(info)));
 }
 
 /* Function: void fas216_starttransfer(FAS216_Info *info,
@@ -2034,48 +2006,8 @@
 	SCpnt->scsi_done = done;
 	SCpnt->host_scribble = (void *)fas216_std_done;
 	SCpnt->result = 0;
-	SCpnt->SCp.Message = 0;
-	SCpnt->SCp.Status = 0;
-
-	if (SCpnt->use_sg) {
-		unsigned long len = 0;
-		int buf;
-
-		SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->buffer;
-		SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
-		SCpnt->SCp.ptr = (char *) SCpnt->SCp.buffer->address;
-		SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
-		/*
-		 * Calculate correct buffer length.  Some commands
-		 * come in with the wrong request_bufflen.
-		 */
-		for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++)
-			len += SCpnt->SCp.buffer[buf].length;
 
-		if (SCpnt->request_bufflen != len)
-			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
-			       "length %d, should be %ld\n", info->host->host_no,
-			       '0' + SCpnt->target, SCpnt->request_bufflen, len);
-		SCpnt->request_bufflen = len;
-	} else {
-		SCpnt->SCp.buffer = NULL;
-		SCpnt->SCp.buffers_residual = 0;
-		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
-		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
-	}
-
-	/*
-	 * If the upper SCSI layers pass a buffer, but zero length,
-	 * we aren't interested in the buffer pointer.
-	 */
-	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
-#if 0
-		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
-		       "command ", info->host->host_no, '0' + SCpnt->target);
-		print_command(SCpnt->cmnd);
-#endif
-		SCpnt->SCp.ptr = NULL;
-	}
+	init_SCp(SCpnt);
 
 	info->stats.queues += 1;
 	SCpnt->tag = 0;
diff -Nru a/drivers/acorn/scsi/oak.c b/drivers/acorn/scsi/oak.c
--- a/drivers/acorn/scsi/oak.c	Fri May 24 18:55:33 2002
+++ b/drivers/acorn/scsi/oak.c	Fri May 24 18:55:33 2002
@@ -290,4 +290,4 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("Oak SCSI driver");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/powertec.c b/drivers/acorn/scsi/powertec.c
--- a/drivers/acorn/scsi/powertec.c	Fri May 24 18:55:36 2002
+++ b/drivers/acorn/scsi/powertec.c	Fri May 24 18:55:36 2002
@@ -41,6 +41,7 @@
 #include "../../scsi/sd.h"
 #include "../../scsi/hosts.h"
 #include "fas216.h"
+#include "scsi.h"
 
 #include <scsi/scsicam.h>
 
@@ -180,15 +181,9 @@
 
 	if (dmach != NO_DMA &&
 	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {
-		int bufs = SCp->buffers_residual;
-		int pci_dir, dma_dir;
+		int bufs, pci_dir, dma_dir;
 
-		if (bufs)
-			memcpy(info->sg + 1, SCp->buffer + 1,
-				sizeof(struct scatterlist) * bufs);
-		info->sg[0].address = SCp->ptr;
-		info->sg[0].page    = NULL;
-		info->sg[0].length  = SCp->this_residual;
+		bufs = copy_SCp_to_sg(&info->sg[0], SCp, NR_SG);
 
 		if (direction == DMA_OUT)
 			pci_dir = PCI_DMA_TODEVICE,
@@ -502,4 +497,4 @@
 MODULE_PARM(term, "1-8i");
 MODULE_PARM_DESC(term, "SCSI bus termination");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/acorn/scsi/scsi.h b/drivers/acorn/scsi/scsi.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/acorn/scsi/scsi.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,122 @@
+/*
+ *  linux/drivers/acorn/scsi/scsi.h
+ *
+ *  Copyright (C) 2002 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Commonly used scsi driver functions.
+ */
+
+#define BELT_AND_BRACES
+
+/*
+ * The scatter-gather list handling.  This contains all
+ * the yucky stuff that needs to be fixed properly.
+ */
+static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int max)
+{
+	int bufs = SCp->buffers_residual;
+
+	BUG_ON(bufs + 1 > max);
+
+	sg->page   = virt_to_page(SCp->ptr);
+	sg->offset = ((unsigned int)SCp->ptr) & ~PAGE_MASK;
+	sg->length = SCp->this_residual;
+
+	if (bufs)
+		memcpy(sg + 1, SCp->buffer + 1,
+		       sizeof(struct scatterlist) * bufs);
+	return bufs + 1;
+}
+
+static inline int next_SCp(Scsi_Pointer *SCp)
+{
+	int ret = SCp->buffers_residual;
+	if (ret) {
+		SCp->buffer++;
+		SCp->buffers_residual--;
+		SCp->ptr = (char *)
+			 (page_address(SCp->buffer->page) +
+			  SCp->buffer->offset);
+		SCp->this_residual = SCp->buffer->length;
+	} else {
+		SCp->ptr = NULL;
+		SCp->this_residual = 0;
+	}
+	return ret;
+}
+
+static inline unsigned char get_next_SCp_byte(Scsi_Pointer *SCp)
+{
+	char c = SCp->ptr;
+
+	SCp->ptr += 1;
+	SCp->this_residual -= 1;
+	if (SCp->this_residual == 0)
+		next_SCp(SCp);
+
+	return c;
+}
+
+static inline void put_next_SCp_byte(Scsi_Pointer *SCp, unsigned char c)
+{
+	SCp->ptr = c;
+	SCp->ptr += 1;
+	SCp->this_residual -= 1;
+	if (SCp->this_residual == 0)
+		next_SCp(SCp);
+}
+
+static inline void init_SCp(Scsi_Cmnd *SCpnt)
+{
+	SCpnt->SCp.Message = 0;
+	SCpnt->SCp.Status = 0;
+
+	if (SCpnt->use_sg) {
+		unsigned long len = 0;
+		int buf;
+
+		SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->buffer;
+		SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
+		SCpnt->SCp.ptr = (char *)
+			 (page_address(SCpnt->SCp.buffer->page) +
+			  SCpnt->SCp.buffer->offset);
+		SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
+
+#ifdef BELT_AND_BRACES
+		/*
+		 * Calculate correct buffer length.  Some commands
+		 * come in with the wrong request_bufflen.
+		 */
+		for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++)
+			len += SCpnt->SCp.buffer[buf].length;
+
+		if (SCpnt->request_bufflen != len)
+			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
+			       "length %d, should be %ld\n", SCpnt->host->host_no,
+			       '0' + SCpnt->target, SCpnt->request_bufflen, len);
+		SCpnt->request_bufflen = len;
+#endif
+	} else {
+		SCpnt->SCp.buffer = NULL;
+		SCpnt->SCp.buffers_residual = 0;
+		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
+		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
+	}
+
+	/*
+	 * If the upper SCSI layers pass a buffer, but zero length,
+	 * we aren't interested in the buffer pointer.
+	 */
+	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
+#ifdef BELT_AND_BRACES
+		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
+		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
+		print_command(SCpnt->cmnd);
+#endif
+		SCpnt->SCp.ptr = NULL;
+	}
+}
diff -Nru a/drivers/acpi/Makefile b/drivers/acpi/Makefile
--- a/drivers/acpi/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/acpi/Makefile	Fri May 24 18:55:35 2002
@@ -21,35 +21,29 @@
 #
 # ACPI Boot-Time Table Parsing
 #
-ifeq ($(CONFIG_ACPI_BOOT),y)
-  obj-y		+= acpi_tables.o
-endif
+obj-$(CONFIG_ACPI_BOOT)		+= acpi_tables.o
 
 #
 # ACPI Core Subsystem (Interpreter)
 #
-ifeq ($(CONFIG_ACPI_INTERPRETER),y)
-  obj-y		+= acpi_osl.o acpi_utils.o
-  subdir-y	+= dispatcher events executer hardware namespace parser \
-		   resources tables utilities
-  obj-y 	+= $(foreach dir,$(subdir-y),$(dir)/$(dir).o)
-endif
+obj-$(CONFIG_ACPI_INTERPRETER)	+= acpi_osl.o acpi_utils.o \
+				   dispatcher/ events/ executer/ hardware/ \
+				   namespace/ parser/ resources/ tables/ \
+				   utilities/
 
 #
 # ACPI Bus and Device Drivers
 #
-ifeq ($(CONFIG_ACPI_BUS),y)
-  obj-y				+= acpi_bus.o 
-  obj-$(CONFIG_ACPI_AC) 	+= acpi_ac.o
-  obj-$(CONFIG_ACPI_BATTERY)	+= acpi_battery.o
-  obj-$(CONFIG_ACPI_BUTTON)	+= acpi_button.o
-  obj-$(CONFIG_ACPI_EC)		+= acpi_ec.o
-  obj-$(CONFIG_ACPI_FAN)	+= acpi_fan.o
-  obj-$(CONFIG_ACPI_PCI)	+= acpi_pci_root.o acpi_pci_link.o
-  obj-$(CONFIG_ACPI_POWER)	+= acpi_power.o
-  obj-$(CONFIG_ACPI_PROCESSOR)	+= acpi_processor.o
-  obj-$(CONFIG_ACPI_THERMAL)	+= acpi_thermal.o
-  obj-$(CONFIG_ACPI_SYSTEM)	+= acpi_system.o
-endif
+obj-$(CONFIG_ACPI_BUS)		+= acpi_bus.o 
+obj-$(CONFIG_ACPI_AC) 		+= acpi_ac.o
+obj-$(CONFIG_ACPI_BATTERY)	+= acpi_battery.o
+obj-$(CONFIG_ACPI_BUTTON)	+= acpi_button.o
+obj-$(CONFIG_ACPI_EC)		+= acpi_ec.o
+obj-$(CONFIG_ACPI_FAN)		+= acpi_fan.o
+obj-$(CONFIG_ACPI_PCI)		+= acpi_pci_root.o acpi_pci_link.o
+obj-$(CONFIG_ACPI_POWER)	+= acpi_power.o
+obj-$(CONFIG_ACPI_PROCESSOR)	+= acpi_processor.o
+obj-$(CONFIG_ACPI_THERMAL)	+= acpi_thermal.o
+obj-$(CONFIG_ACPI_SYSTEM)	+= acpi_system.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/acpi/acpi_system.c b/drivers/acpi/acpi_system.c
--- a/drivers/acpi/acpi_system.c	Fri May 24 18:55:36 2002
+++ b/drivers/acpi/acpi_system.c	Fri May 24 18:55:36 2002
@@ -33,6 +33,8 @@
 #include <linux/delay.h>
 #include <linux/sysrq.h>
 #include <linux/pm.h>
+#include <linux/device.h>
+#include <linux/suspend.h>
 #include <asm/uaccess.h>
 #include <asm/acpi.h>
 #include "acpi_bus.h"
@@ -128,6 +130,12 @@
 	/* restore device context */
 	device_resume(RESUME_RESTORE_STATE);
 #endif
+
+	if (dmi_broken & BROKEN_INIT_AFTER_S1) {
+		printk("Broken toshiba laptop -> kicking interrupts\n");
+		init_8259A(0);
+	}
+
 	return AE_OK;
 }
 
@@ -254,20 +262,16 @@
 	switch (state)
 	{
 	case ACPI_STATE_S1:
-		/* do nothing */
+		barrier();
+		status = acpi_enter_sleep_state(state);
 		break;
 
 	case ACPI_STATE_S2:
 	case ACPI_STATE_S3:
-		acpi_save_register_state((unsigned long)&&acpi_sleep_done);
+		do_suspend_magic(0);
 		break;
 	}
 
-	barrier();
-	status = acpi_enter_sleep_state(state);
-
-acpi_sleep_done:
-
 	acpi_restore_register_state();
 	restore_flags(flags);
 
@@ -290,6 +294,8 @@
 	if (state < ACPI_STATE_S1 || state > ACPI_STATE_S5)
 		return AE_ERROR;
 
+	freeze_processes();
+
 	/* do we have a wakeup address for S2 and S3? */
 	if (state == ACPI_STATE_S2 || state == ACPI_STATE_S3) {
 		if (!acpi_wakeup_address)
@@ -323,6 +329,8 @@
 	/* reset firmware waking vector */
 	acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS) 0);
 
+	thaw_processes();
+
 	return status;
 }
 
@@ -700,8 +708,17 @@
 	
 	if (!system->states[state])
 		return_VALUE(-ENODEV);
+
 	
+#ifdef CONFIG_SOFTWARE_SUSPEND
+	if (state == 4) {
+		/* We are working from process context, that's why we may call it directly. */ 
+		do_software_suspend();
+		return_VALUE(count);
+	}
+#endif
 	status = acpi_suspend(state);
+
 	if (ACPI_FAILURE(status))
 		return_VALUE(-ENODEV);
 	
@@ -1180,6 +1197,10 @@
 		}
 	}
 	printk(")\n");
+#ifdef CONFIG_SOFTWARE_SUSPEND
+	printk(KERN_INFO "Software suspend => we can do S4.");
+	system->states[4] = 1;
+#endif
 
 #ifdef CONFIG_PM
 	/* Install the soft-off (S5) handler. */
diff -Nru a/drivers/acpi/debugger/Makefile b/drivers/acpi/debugger/Makefile
--- a/drivers/acpi/debugger/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/acpi/debugger/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/dispatcher/Makefile b/drivers/acpi/dispatcher/Makefile
--- a/drivers/acpi/dispatcher/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/acpi/dispatcher/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/events/Makefile b/drivers/acpi/events/Makefile
--- a/drivers/acpi/events/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/acpi/events/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/executer/Makefile b/drivers/acpi/executer/Makefile
--- a/drivers/acpi/executer/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/acpi/executer/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile
--- a/drivers/acpi/hardware/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/acpi/hardware/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
--- a/drivers/acpi/namespace/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/acpi/namespace/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
--- a/drivers/acpi/parser/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/acpi/parser/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
--- a/drivers/acpi/resources/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/acpi/resources/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile
--- a/drivers/acpi/tables/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/acpi/tables/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
--- a/drivers/acpi/utilities/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/acpi/utilities/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-O_TARGET := $(notdir $(CURDIR)).o
-
 obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
--- a/drivers/atm/ambassador.c	Fri May 24 18:55:33 2002
+++ b/drivers/atm/ambassador.c	Fri May 24 18:55:33 2002
@@ -2581,8 +2581,6 @@
 /********** module stuff **********/
 
 #ifdef MODULE
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR(maintainer_string);
 MODULE_DESCRIPTION(description_string);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
--- a/drivers/atm/eni.c	Fri May 24 18:55:34 2002
+++ b/drivers/atm/eni.c	Fri May 24 18:55:34 2002
@@ -2340,5 +2340,4 @@
 module_init(eni_init);
 module_exit(eni_cleanup);
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
--- a/drivers/atm/firestream.c	Fri May 24 18:55:33 2002
+++ b/drivers/atm/firestream.c	Fri May 24 18:55:33 2002
@@ -2124,4 +2124,4 @@
 module_exit(firestream_cleanup_module);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
+
diff -Nru a/drivers/atm/horizon.c b/drivers/atm/horizon.c
--- a/drivers/atm/horizon.c	Fri May 24 18:55:33 2002
+++ b/drivers/atm/horizon.c	Fri May 24 18:55:33 2002
@@ -2765,15 +2765,13 @@
     u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1));
     u8 irq = pci_dev->irq;
     
-    // check IO region
-    if (check_region (iobase, HRZ_IO_EXTENT)) {
-      PRINTD (DBG_WARN, "IO range already in use");
-      continue;
-    }
+    /* XXX DEV_LABEL is a guess */
+    if (!request_region (iobase, HRZ_IO_EXTENT, DEV_LABEL))
+  	  continue;
 
     if (pci_enable_device (pci_dev))
       continue;
-
+    
     dev = kmalloc (sizeof(hrz_dev), GFP_KERNEL);
     if (!dev) {
       // perhaps we should be nice: deregister all adapters and abort?
@@ -2807,9 +2805,6 @@
 	dev->atm_dev->dev_data = (void *) dev;
 	dev->pci_dev = pci_dev; 
 	
-	/* XXX DEV_LABEL is a guess */
-	request_region (iobase, HRZ_IO_EXTENT, DEV_LABEL);
-	
 	// enable bus master accesses
 	pci_set_master (pci_dev);
 	
@@ -2901,8 +2896,10 @@
 	atm_dev_deregister (dev->atm_dev);
       } /* atm_dev_register */
       free_irq (irq, dev);
+	
     } /* request_irq */
     kfree (dev);
+    release_region(iobase, HRZ_IO_EXTENT);
   } /* kmalloc and while */
   return devs;
 }
@@ -2931,8 +2928,6 @@
 }
 
 #ifdef MODULE
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR(maintainer_string);
 MODULE_DESCRIPTION(description_string);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
--- a/drivers/atm/idt77252.c	Fri May 24 18:55:35 2002
+++ b/drivers/atm/idt77252.c	Fri May 24 18:55:35 2002
@@ -3894,7 +3894,6 @@
 module_init(idt77252_init);
 module_exit(idt77252_exit);
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
 
 MODULE_PARM(vpibits, "i");
diff -Nru a/drivers/atm/suni.c b/drivers/atm/suni.c
--- a/drivers/atm/suni.c	Fri May 24 18:55:34 2002
+++ b/drivers/atm/suni.c	Fri May 24 18:55:34 2002
@@ -4,7 +4,7 @@
 
 
 #include <linux/module.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
diff -Nru a/drivers/block/blkpg.c b/drivers/block/blkpg.c
--- a/drivers/block/blkpg.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/blkpg.c	Fri May 24 18:55:33 2002
@@ -36,6 +36,7 @@
 #include <linux/genhd.h>
 #include <linux/module.h>               /* for EXPORT_SYMBOL */
 #include <linux/backing-dev.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
@@ -259,7 +260,7 @@
 						(long *)arg);
 
 		case BLKSECTGET:
-			if ((q = blk_get_queue(dev)) == NULL)
+			if ((q = bdev_get_queue(bdev)) == NULL)
 				return -EINVAL;
 
 			usval = q->max_sectors;
diff -Nru a/drivers/block/block_ioctl.c b/drivers/block/block_ioctl.c
--- a/drivers/block/block_ioctl.c	Fri May 24 18:55:35 2002
+++ b/drivers/block/block_ioctl.c	Fri May 24 18:55:35 2002
@@ -56,7 +56,7 @@
 	struct request *rq;
 	int close = 0, err;
 
-	q = blk_get_queue(to_kdev_t(bdev->bd_dev));
+	q = bdev_get_queue(bdev);
 	if (!q)
 		return -ENXIO;
 
diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
--- a/drivers/block/cciss.c	Fri May 24 18:55:36 2002
+++ b/drivers/block/cciss.c	Fri May 24 18:55:36 2002
@@ -2608,7 +2608,6 @@
 
 }
 
-EXPORT_NO_SYMBOLS;
 static int __init init_cciss_module(void)
 {
 	return ( cciss_init());
diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
--- a/drivers/block/cpqarray.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/cpqarray.c	Fri May 24 18:55:33 2002
@@ -296,7 +296,6 @@
 #ifdef MODULE
 
 MODULE_PARM(eisa, "1-8i");
-EXPORT_NO_SYMBOLS;
 
 /* This is a bit of a hack... */
 int __init init_module(void)
diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
--- a/drivers/block/floppy.c	Fri May 24 18:55:34 2002
+++ b/drivers/block/floppy.c	Fri May 24 18:55:34 2002
@@ -173,6 +173,8 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
+#include <linux/buffer_head.h>		/* for invalidate_buffers() */
 
 /*
  * PS/2 floppies have much slower step rates than regular floppies.
@@ -242,6 +244,7 @@
 #include <linux/blk.h>
 #include <linux/blkpg.h>
 #include <linux/cdrom.h> /* for the compatibility eject ioctl */
+#include <linux/completion.h>
 
 #ifndef fd_get_dma_residue
 #define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
@@ -3791,6 +3794,7 @@
 	if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
 		if (buffer_drive == drive)
 			buffer_track = -1;
+		/* umm, invalidate_buffers() in ->open??  --hch */
 		invalidate_buffers(mk_kdev(FLOPPY_MAJOR,old_dev));
 	}
 
@@ -3852,6 +3856,74 @@
 	return 0;
 }
 
+/*
+ * This implements "read block 0" for floppy_revalidate().
+ * Needed for format autodetection, checking whether there is
+ * a disk in the drive, and whether that disk is writable.
+ */
+
+static void floppy_rb0_complete(struct bio *bio)
+{
+	complete((struct completion*)bio->bi_private);
+}
+
+static int __floppy_read_block_0(struct block_device *bdev)
+{
+	struct bio bio;
+	struct bio_vec bio_vec;
+	struct completion complete;
+	struct page *page;
+	size_t size;
+
+	page = alloc_page(GFP_NOIO);
+	if (!page) {
+		process_fd_request();
+		return -ENOMEM;
+	}
+
+	size = bdev->bd_block_size;
+	if (!size)
+		size = 1024;
+
+	bio_init(&bio);
+	bio.bi_io_vec = &bio_vec;
+	bio_vec.bv_page = page;
+	bio_vec.bv_len = size;
+	bio_vec.bv_offset = 0;
+	bio.bi_vcnt = 1;
+	bio.bi_idx = 0;
+	bio.bi_size = size;
+	bio.bi_bdev = bdev;
+	bio.bi_sector = 0;
+	init_completion(&complete);
+	bio.bi_private = &complete;
+	bio.bi_end_io = floppy_rb0_complete;
+
+	submit_bio(READ, &bio);
+	run_task_queue(&tq_disk);
+	process_fd_request();
+	wait_for_completion(&complete);
+
+	__free_page(page);
+
+	return 0;
+}
+
+static int floppy_read_block_0(kdev_t dev)
+{
+	struct block_device *bdev;
+	int ret;
+
+	bdev = bdget(kdev_t_to_nr(dev));
+	if (!bdev) {
+		printk("No block device for %s\n", __bdevname(dev));
+		BUG();
+	}
+	ret = __floppy_read_block_0(bdev);
+	atomic_dec(&bdev->bd_count);
+	return ret;
+}
+
 /* revalidate the floppy disk, i.e. trigger format autodetection by reading
  * the bootblock (block 0). "Autodetection" is also needed to check whether
  * there is a disk in the drive at all... Thus we also do it for fixed
@@ -3859,9 +3931,6 @@
 static int floppy_revalidate(kdev_t dev)
 {
 #define NO_GEOM (!current_type[drive] && !TYPE(dev))
-#if 0
-	struct buffer_head * bh;
-#endif
 	int drive=DRIVE(dev);
 	int cf;
 
@@ -3888,29 +3957,8 @@
 		if (cf)
 			UDRS->generation++;
 		if (NO_GEOM){
-#if 0
-	/*
-	 * What the devil is going on here?  We are not guaranteed to do
-	 * any IO and ENXIO case is nothing but ENOMEM in disguise - it
-	 * happens if and only if buffer cache is out of memory.  WTF?
-	 */
 			/* auto-sensing */
-			int size = floppy_blocksizes[minor(dev)];
-			if (!size)
-				size = 1024;
-			if (!(bh = getblk(dev,0,size))){
-				process_fd_request();
-				return -ENXIO;
-			}
-			if (bh && !buffer_uptodate(bh))
-				ll_rw_block(READ, 1, &bh);
-			process_fd_request();
-			wait_on_buffer(bh);
-			brelse(bh);
-			return 0;
-#endif
-			process_fd_request();
-			return 0;
+			return floppy_read_block_0(dev);
 		}
 		if (cf)
 			poll_drive(0, FD_RAW_NEED_DISK);
@@ -4178,11 +4226,15 @@
 
 static int have_no_fdc= -ENODEV;
 
+static struct device device_floppy;
 
 int __init floppy_init(void)
 {
 	int i,unit,drive;
 
+	strcpy(device_floppy.name, "floppy");
+	strcpy(device_floppy.bus_id, "03?0");
+	register_sys_device(&device_floppy);
 
 	raw_cmd = NULL;
 
diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
--- a/drivers/block/ll_rw_blk.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/ll_rw_blk.c	Fri May 24 18:55:33 2002
@@ -25,6 +25,7 @@
 #include <linux/bootmem.h>
 #include <linux/completion.h>
 #include <linux/compiler.h>
+#include <linux/buffer_head.h>
 #include <scsi/scsi.h>
 #include <linux/backing-dev.h>
 
@@ -79,8 +80,8 @@
 int blk_nohighio = 0;
 
 /**
- * blk_get_queue: - return the queue that matches the given device
- * @dev:    device
+ * bdev_get_queue: - return the queue that matches the given device
+ * @bdev:    device
  *
  * Description:
  *     Given a specific device, return the queue that will hold I/O
@@ -89,14 +90,9 @@
  *     stored in the same location.
  *
  **/
-inline request_queue_t *blk_get_queue(kdev_t dev)
+inline request_queue_t *bdev_get_queue(struct block_device *bdev)
 {
-	struct blk_dev_struct *bdev = blk_dev + major(dev);
-
-	if (bdev->queue)
-		return bdev->queue(dev);
-	else
-		return &blk_dev[major(dev)].request_queue;
+	return bdev->bd_queue;
 }
 
 /**
@@ -111,7 +107,7 @@
 struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev)
 {
 	struct backing_dev_info *ret = NULL;
-	request_queue_t *q = blk_get_queue(to_kdev_t(bdev->bd_dev));
+	request_queue_t *q = bdev_get_queue(bdev);
 
 	if (q)
 		ret = &q->backing_dev_info;
@@ -523,42 +519,6 @@
 	printk("\n");
 }
 
-/*
- * standard prep_rq_fn that builds 10 byte cmds
- */
-int ll_10byte_cmd_build(request_queue_t *q, struct request *rq)
-{
-	int hard_sect = queue_hardsect_size(q);
-	sector_t block = rq->hard_sector / (hard_sect >> 9);
-	unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9);
-
-	if (!(rq->flags & REQ_CMD))
-		return 0;
-
-	memset(rq->cmd, 0, sizeof(rq->cmd));
-
-	if (rq_data_dir(rq) == READ)
-		rq->cmd[0] = READ_10;
-	else 
-		rq->cmd[0] = WRITE_10;
-
-	/*
-	 * fill in lba
-	 */
-	rq->cmd[2] = (block >> 24) & 0xff;
-	rq->cmd[3] = (block >> 16) & 0xff;
-	rq->cmd[4] = (block >>  8) & 0xff;
-	rq->cmd[5] = block & 0xff;
-
-	/*
-	 * and transfer length
-	 */
-	rq->cmd[7] = (blocks >> 8) & 0xff;
-	rq->cmd[8] = blocks & 0xff;
-
-	return 0;
-}
-
 void blk_recount_segments(request_queue_t *q, struct bio *bio)
 {
 	struct bio_vec *bv, *bvprv = NULL;
@@ -1418,7 +1378,9 @@
 	req->buffer = bio_data(bio);	/* see ->buffer comment above */
 	req->waiting = NULL;
 	req->bio = req->biotail = bio;
-	req->rq_dev = to_kdev_t(bio->bi_bdev->bd_dev);
+	if (bio->bi_bdev)
+		req->rq_dev = to_kdev_t(bio->bi_bdev->bd_dev);
+	else	req->rq_dev = NODEV;
 	add_request(q, req, insert_here);
 out:
 	if (freereq)
@@ -1515,7 +1477,7 @@
 	 * Stacking drivers are expected to know what they are doing.
 	 */
 	do {
-		q = blk_get_queue(to_kdev_t(bio->bi_bdev->bd_dev));
+		q = bdev_get_queue(bio->bi_bdev);
 		if (!q) {
 			printk(KERN_ERR
 			       "generic_make_request: Trying to access nonexistent block-device %s (%Lu)\n",
@@ -1763,9 +1725,8 @@
 {
 	if (rq->flags & REQ_CMD) {
 		rq->hard_sector += nsect;
-		rq->hard_nr_sectors -= nsect;
+		rq->nr_sectors = rq->hard_nr_sectors -= nsect;
 		rq->sector = rq->hard_sector;
-		rq->nr_sectors = rq->hard_nr_sectors;
 
 		rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
 		rq->hard_cur_sectors = rq->current_nr_sectors;
@@ -1919,7 +1880,7 @@
 EXPORT_SYMBOL(end_that_request_first);
 EXPORT_SYMBOL(end_that_request_last);
 EXPORT_SYMBOL(blk_init_queue);
-EXPORT_SYMBOL(blk_get_queue);
+EXPORT_SYMBOL(bdev_get_queue);
 EXPORT_SYMBOL(blk_cleanup_queue);
 EXPORT_SYMBOL(blk_queue_make_request);
 EXPORT_SYMBOL(blk_queue_bounce_limit);
@@ -1942,7 +1903,6 @@
 EXPORT_SYMBOL(blk_phys_contig_segment);
 EXPORT_SYMBOL(blk_hw_contig_segment);
 
-EXPORT_SYMBOL(ll_10byte_cmd_build);
 EXPORT_SYMBOL(blk_queue_prep_rq);
 
 EXPORT_SYMBOL(blk_queue_init_tags);
diff -Nru a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/loop.c	Fri May 24 18:55:33 2002
@@ -71,11 +71,12 @@
 #include <linux/smp_lock.h>
 #include <linux/swap.h>
 #include <linux/slab.h>
+#include <linux/loop.h>
+#include <linux/suspend.h>
+#include <linux/buffer_head.h>		/* for invalidate_bdev() */
 
 #include <asm/uaccess.h>
 
-#include <linux/loop.h>		
-
 #define MAJOR_NR LOOP_MAJOR
 
 static int max_loop = 8;
@@ -534,6 +535,7 @@
 	daemonize();
 
 	sprintf(current->comm, "loop%d", lo->lo_number);
+	current->flags |= PF_IOTHREAD;
 
 	spin_lock_irq(&current->sigmask_lock);
 	sigfillset(&current->blocked);
diff -Nru a/drivers/block/paride/Makefile b/drivers/block/paride/Makefile
--- a/drivers/block/paride/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/block/paride/Makefile	Fri May 24 18:55:35 2002
@@ -5,8 +5,6 @@
 # Rewritten to use lists instead of if-statements.
 #
 
-L_TARGET := paride.a
-
 export-objs := paride.o bpck6.o
 
 obj-$(CONFIG_PARIDE)		+= paride.o
diff -Nru a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
--- a/drivers/block/paride/paride.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/paride/paride.c	Fri May 24 18:55:33 2002
@@ -296,9 +296,6 @@
 		range = 3;
 		if (pi->mode >= pi->proto->epp_first) range = 8;
 		if ((range == 8) && (pi->port % 8)) return 0;
-#ifndef CONFIG_PARPORT
-		if (check_region(pi->port,range)) return 0;
-#endif /* !CONFIG_PARPORT */
 		pi->reserved = range;
 		return (!pi_test_proto(pi,scratch,verbose));
 	}
@@ -307,9 +304,6 @@
 		range = 3;
 		if (pi->mode >= pi->proto->epp_first) range = 8;
 		if ((range == 8) && (pi->port % 8)) break;
-#ifndef CONFIG_PARPORT
-		if (check_region(pi->port,range)) break;
-#endif /* !CONFIG_PARPORT */
 		pi->reserved = range;
 		if (!pi_test_proto(pi,scratch,verbose)) best = pi->mode;
 	}
@@ -331,10 +325,6 @@
 	if (!pi_register_parport(pi,verbose))
 	  return 0;
 
-#ifndef CONFIG_PARPORT
-	if (check_region(pi->port,3)) return 0;
-#endif /* !CONFIG_PARPORT */
-
 	if (pi->proto->test_port) {
 		pi_claim(pi);
 		max = pi->proto->test_port(pi);
@@ -424,7 +414,11 @@
 	}
 
 #ifndef CONFIG_PARPORT
-	request_region(pi->port,pi->reserved,pi->device);
+	if (!request_region(pi->port,pi->reserved,pi->device))
+		{
+		printk(KERN_WARNING"paride: Unable to request region 0x%x\n", pi->port);
+		return 0;
+		}
 #endif /* !CONFIG_PARPORT */
 
 	if (pi->parname)
diff -Nru a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
--- a/drivers/block/paride/pcd.c	Fri May 24 18:55:35 2002
+++ b/drivers/block/paride/pcd.c	Fri May 24 18:55:35 2002
@@ -760,8 +760,11 @@
 
 	if (pcd_busy) return;
         while (1) {
-	    if (QUEUE_EMPTY || (CURRENT->rq_status == RQ_INACTIVE)) return;
-	    INIT_REQUEST;
+	    if (blk_queue_empty(QUEUE)) {
+		    CLEAR_INTR;
+		    return;
+	    }
+
 	    if (rq_data_dir(CURRENT) == READ) {
 		unit = minor(CURRENT->rq_dev);
 		if (unit != pcd_unit) {
diff -Nru a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
--- a/drivers/block/paride/pd.c	Fri May 24 18:55:34 2002
+++ b/drivers/block/paride/pd.c	Fri May 24 18:55:34 2002
@@ -835,8 +835,10 @@
 
         if (pd_busy) return;
 repeat:
-        if (QUEUE_EMPTY || (CURRENT->rq_status == RQ_INACTIVE)) return;
-        INIT_REQUEST;
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
 
         pd_dev = minor(CURRENT->rq_dev);
 	pd_unit = unit = DEVICE_NR(CURRENT->rq_dev);
diff -Nru a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
--- a/drivers/block/paride/pf.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/paride/pf.c	Fri May 24 18:55:33 2002
@@ -841,8 +841,10 @@
 
         if (pf_busy) return;
 repeat:
-        if (QUEUE_EMPTY || (CURRENT->rq_status == RQ_INACTIVE)) return;
-        INIT_REQUEST;
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
 
         pf_unit = unit = DEVICE_NR(CURRENT->rq_dev);
         pf_block = CURRENT->sector;
diff -Nru a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
--- a/drivers/block/paride/pg.c	Fri May 24 18:55:34 2002
+++ b/drivers/block/paride/pg.c	Fri May 24 18:55:34 2002
@@ -244,7 +244,7 @@
 	int timeout;		  /* timeout requested */
 	int status;		  /* last sense key */
 	int drive;		  /* drive */
-	int access;               /* count of active opens ... */
+	unsigned long access;     /* count of active opens ... */
 	int present;		  /* device present ? */
 	char *bufptr;
 	char name[PG_NAMELEN];	  /* pg0, pg1, ... */
diff -Nru a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c
--- a/drivers/block/ps2esdi.c	Fri May 24 18:55:33 2002
+++ b/drivers/block/ps2esdi.c	Fri May 24 18:55:33 2002
@@ -471,9 +471,12 @@
 	       CURRENT->current_nr_sectors, CURRENT->buffer);
 #endif
 
-	/* standard macro that ensures that requests are really on the
+	/* standard procedure to ensure that requests are really on the
 	   list + sanity checks.                     */
-	INIT_REQUEST;
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
 
 	if (isa_virt_to_bus(CURRENT->buffer + CURRENT->current_nr_sectors * 512) > 16 * MB) {
 		printk("%s: DMA above 16MB not supported\n", DEVICE_NAME);
diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
--- a/drivers/block/rd.c	Fri May 24 18:55:36 2002
+++ b/drivers/block/rd.c	Fri May 24 18:55:36 2002
@@ -48,6 +48,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/buffer_head.h>		/* for invalidate_bdev() */
 #include <asm/uaccess.h>
 
 /*
@@ -376,6 +377,7 @@
 	if (rd_bdev[unit] == NULL) {
 		rd_bdev[unit] = bdget(kdev_t_to_nr(inode->i_rdev));
 		rd_bdev[unit]->bd_openers++;
+		rd_bdev[unit]->bd_block_size = rd_blocksize;
 		rd_bdev[unit]->bd_inode->i_mapping->a_ops = &ramdisk_aops;
 	}
 
diff -Nru a/drivers/block/xd.c b/drivers/block/xd.c
--- a/drivers/block/xd.c	Fri May 24 18:55:34 2002
+++ b/drivers/block/xd.c	Fri May 24 18:55:34 2002
@@ -210,12 +210,11 @@
 
 		printk("Detected a%s controller (type %d) at address %06x\n",
 			xd_sigs[controller].name,controller,address);
-		if (check_region(xd_iobase,4)) {
+		if (!request_region(xd_iobase,4,"xd")) {
 			printk("xd: Ports at 0x%x are not available\n",
 				xd_iobase);
 			return;
 		}
-		request_region(xd_iobase,4,"xd");
 		if (controller)
 			xd_sigs[controller].init_controller(address);
 		xd_drives = xd_initdrives(xd_sigs[controller].init_drive);
@@ -279,8 +278,13 @@
 	sti();
 	if (xdc_busy)
 		return;
-	while (code = 0, !QUEUE_EMPTY) {
-		INIT_REQUEST;	/* do some checking on the request structure */
+	while (1) {
+		code = 0;
+		/* do some checking on the request structure */
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
 
 		if (CURRENT_DEV < xd_drives
 		    && (CURRENT->flags & REQ_CMD)
diff -Nru a/drivers/block/z2ram.c b/drivers/block/z2ram.c
--- a/drivers/block/z2ram.c	Fri May 24 18:55:36 2002
+++ b/drivers/block/z2ram.c	Fri May 24 18:55:36 2002
@@ -76,7 +76,10 @@
 
     while ( TRUE )
     {
-	INIT_REQUEST;
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
 
 	start = CURRENT->sector << 9;
 	len  = CURRENT->current_nr_sectors << 9;
diff -Nru a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
--- a/drivers/bluetooth/bluecard_cs.c	Fri May 24 18:55:35 2002
+++ b/drivers/bluetooth/bluecard_cs.c	Fri May 24 18:55:35 2002
@@ -1120,5 +1120,3 @@
 
 module_init(init_bluecard_cs);
 module_exit(exit_bluecard_cs);
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
--- a/drivers/bluetooth/dtl1_cs.c	Fri May 24 18:55:35 2002
+++ b/drivers/bluetooth/dtl1_cs.c	Fri May 24 18:55:35 2002
@@ -935,5 +935,3 @@
 
 module_init(init_dtl1_cs);
 module_exit(exit_dtl1_cs);
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c
--- a/drivers/cdrom/aztcd.c	Fri May 24 18:55:36 2002
+++ b/drivers/cdrom/aztcd.c	Fri May 24 18:55:36 2002
@@ -2493,4 +2493,3 @@
 }
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
--- a/drivers/cdrom/cdu31a.c	Fri May 24 18:55:33 2002
+++ b/drivers/cdrom/cdu31a.c	Fri May 24 18:55:33 2002
@@ -1598,7 +1598,8 @@
 		 * The beginning here is stolen from the hard disk driver.  I hope
 		 * it's right.
 		 */
-		if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE) {
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
 			goto end_do_cdu31a_request;
 		}
 
@@ -1606,8 +1607,6 @@
 			scd_spinup();
 		}
 
-		INIT_REQUEST;
-
 		block = CURRENT->sector;
 		nblock = CURRENT->nr_sectors;
 
@@ -3503,4 +3502,3 @@
 module_exit(cdu31a_exit);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
--- a/drivers/cdrom/cm206.c	Fri May 24 18:55:35 2002
+++ b/drivers/cdrom/cm206.c	Fri May 24 18:55:35 2002
@@ -856,9 +856,11 @@
 	uch *source, *dest;
 
 	while (1) {		/* repeat until all requests have been satisfied */
-		INIT_REQUEST;
-		if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
 			return;
+		}
+
 		if (CURRENT->cmd != READ) {
 			debug(("Non-read command %d on cdrom\n",
 			       CURRENT->cmd));
diff -Nru a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c
--- a/drivers/cdrom/gscd.c	Fri May 24 18:55:33 2002
+++ b/drivers/cdrom/gscd.c	Fri May 24 18:55:33 2002
@@ -279,9 +279,11 @@
 	unsigned int nsect;
 
       repeat:
-	if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
-		goto out;
-	INIT_REQUEST;
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
+
 	dev = minor(CURRENT->rq_dev);
 	block = CURRENT->sector;
 	nsect = CURRENT->nr_sectors;
@@ -1070,4 +1072,3 @@
 
 MODULE_AUTHOR("Oliver Raupach <raupach@nwfs1.rz.fh-hannover.de>");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/cdrom/isp16.c b/drivers/cdrom/isp16.c
--- a/drivers/cdrom/isp16.c	Fri May 24 18:55:35 2002
+++ b/drivers/cdrom/isp16.c	Fri May 24 18:55:35 2002
@@ -368,5 +368,4 @@
 #endif
 module_exit(isp16_exit);
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
--- a/drivers/cdrom/mcdx.c	Fri May 24 18:55:35 2002
+++ b/drivers/cdrom/mcdx.c	Fri May 24 18:55:35 2002
@@ -562,19 +562,11 @@
 
       again:
 
-	if (QUEUE_EMPTY) {
-		xtrace(REQUEST, "end_request(0): CURRENT == NULL\n");
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
 		return;
 	}
 
-	if (CURRENT->rq_status == RQ_INACTIVE) {
-		xtrace(REQUEST,
-		       "end_request(0): rq_status == RQ_INACTIVE\n");
-		return;
-	}
-
-	INIT_REQUEST;
-
 	dev = minor(CURRENT->rq_dev);
 	stuffp = mcdx_stuffp[dev];
 
@@ -1008,8 +1000,6 @@
 }
 
 /* MODULE STUFF ***********************************************************/
-
-EXPORT_NO_SYMBOLS;
 
 int __mcdx_init(void)
 {
diff -Nru a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
--- a/drivers/cdrom/sbpcd.c	Fri May 24 18:55:34 2002
+++ b/drivers/cdrom/sbpcd.c	Fri May 24 18:55:34 2002
@@ -4915,12 +4915,15 @@
 	printk(" do_sbpcd_request[%di](%p:%ld+%ld), Pid:%d, Time:%li\n",
 		xnr, CURRENT, CURRENT->sector, CURRENT->nr_sectors, current->pid, jiffies);
 #endif
-	INIT_REQUEST;
+
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
+
 	req=CURRENT;		/* take out our request so no other */
 	blkdev_dequeue_request(req);	/* task can fuck it up         GTL  */
-	
-	if (req->rq_status == RQ_INACTIVE)
-		sbpcd_end_request(req, 0);
+
 	if (req -> sector == -1)
 		sbpcd_end_request(req, 0);
 	spin_unlock_irq(q->queue_lock);
diff -Nru a/drivers/cdrom/sonycd535.c b/drivers/cdrom/sonycd535.c
--- a/drivers/cdrom/sonycd535.c	Fri May 24 18:55:35 2002
+++ b/drivers/cdrom/sonycd535.c	Fri May 24 18:55:35 2002
@@ -806,10 +806,11 @@
 		 * The beginning here is stolen from the hard disk driver.  I hope
 		 * it's right.
 		 */
-		if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE) {
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
 			return;
 		}
-		INIT_REQUEST;
+
 		dev = minor(CURRENT->rq_dev);
 		block = CURRENT->sector;
 		nsect = CURRENT->nr_sectors;
diff -Nru a/drivers/char/Makefile b/drivers/char/Makefile
--- a/drivers/char/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/char/Makefile	Fri May 24 18:55:35 2002
@@ -150,13 +150,7 @@
 obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
 obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o
 obj-$(CONFIG_SX) += sx.o generic_serial.o
-
-obj-$(CONFIG_RIO) += generic_serial.o
-subdir-$(CONFIG_RIO) += rio
-ifeq ($(CONFIG_RIO),y)
-  obj-y += rio/rio.o
-endif
-
+obj-$(CONFIG_RIO) += rio/ generic_serial.o
 obj-$(CONFIG_SH_SCI) += sh-sci.o generic_serial.o
 obj-$(CONFIG_SERIAL167) += serial167.o
 obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o
@@ -188,14 +182,8 @@
 obj-$(CONFIG_I8K) += i8k.o
 obj-$(CONFIG_DS1620) += ds1620.o
 obj-$(CONFIG_INTEL_RNG) += i810_rng.o
-
 obj-$(CONFIG_QIC02_TAPE) += tpqic02.o
-
-subdir-$(CONFIG_FTAPE) += ftape
-ifeq ($(CONFIG_FTAPE),y)
-  obj-y       += ftape/ftape.o
-endif
-
+obj-$(CONFIG_FTAPE) += ftape/
 obj-$(CONFIG_H8) += h8.o
 obj-$(CONFIG_PPDEV) += ppdev.o
 obj-$(CONFIG_DZ) += dz.o
@@ -222,26 +210,10 @@
 obj-$(CONFIG_SH_WDT) += shwdt.o
 obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
-
-subdir-$(CONFIG_MWAVE) += mwave
-ifeq ($(CONFIG_MWAVE),y)
-  obj-y += mwave/mwave.o
-endif
-
-subdir-$(CONFIG_AGP) += agp
-ifeq ($(CONFIG_AGP),y)
-  obj-y += agp/agp.o
-endif
-
-subdir-$(CONFIG_DRM) += drm
-ifeq ($(CONFIG_DRM),y)
-  obj-y += drm/drm.o
-endif
-
-subdir-$(CONFIG_PCMCIA) += pcmcia
-ifeq ($(CONFIG_PCMCIA),y)
-  obj-y += pcmcia/pcmcia_char.o
-endif
+obj-$(CONFIG_MWAVE) += mwave/
+obj-$(CONFIG_AGP) += agp/
+obj-$(CONFIG_DRM) += drm/
+obj-$(CONFIG_PCMCIA) += pcmcia/
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/char/acquirewdt.c b/drivers/char/acquirewdt.c
--- a/drivers/char/acquirewdt.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/acquirewdt.c	Fri May 24 18:55:33 2002
@@ -249,4 +249,3 @@
 module_exit(acq_exit);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/agp/Makefile b/drivers/char/agp/Makefile
--- a/drivers/char/agp/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/char/agp/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # space ioctl interface to use agp memory.  It also adds a kernel interface
 # that other drivers could use to manipulate agp memory.
 
-O_TARGET	:= agp.o
-
 export-objs := agpgart_be.o
 
 agpgart-objs := agpgart_fe.o agpgart_be.o
diff -Nru a/drivers/char/agp/agpgart_be.c b/drivers/char/agp/agpgart_be.c
--- a/drivers/char/agp/agpgart_be.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/agp/agpgart_be.c	Fri May 24 18:55:34 2002
@@ -28,7 +28,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/errno.h>
diff -Nru a/drivers/char/drm/Config.in b/drivers/char/drm/Config.in
--- a/drivers/char/drm/Config.in	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/Config.in	Fri May 24 18:55:36 2002
@@ -1,5 +1,5 @@
 #
-# drm device configuration
+# Drm device configuration
 #
 # This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
@@ -12,5 +12,6 @@
     tristate '  ATI Rage 128' CONFIG_DRM_R128
     dep_tristate '  ATI Radeon' CONFIG_DRM_RADEON $CONFIG_AGP
     dep_tristate '  Intel I810' CONFIG_DRM_I810 $CONFIG_AGP
+    dep_tristate '  Intel 830M' CONFIG_DRM_I830 $CONFIG_AGP
     dep_tristate '  Matrox g200/g400' CONFIG_DRM_MGA $CONFIG_AGP
 fi
diff -Nru a/drivers/char/drm/Makefile b/drivers/char/drm/Makefile
--- a/drivers/char/drm/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/Makefile	Fri May 24 18:55:36 2002
@@ -2,13 +2,12 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-O_TARGET	:= drm.o
-
 gamma-objs  := gamma_drv.o gamma_dma.o
 tdfx-objs   := tdfx_drv.o
 r128-objs   := r128_drv.o r128_cce.o r128_state.o
 mga-objs    := mga_drv.o mga_dma.o mga_state.o mga_warp.o
 i810-objs   := i810_drv.o i810_dma.o
+i830-objs   := i830_drv.o i830_dma.o
 radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o
 ffb-objs    := ffb_drv.o ffb_context.o
 
@@ -18,6 +17,7 @@
 obj-$(CONFIG_DRM_RADEON)+= radeon.o
 obj-$(CONFIG_DRM_MGA)	+= mga.o
 obj-$(CONFIG_DRM_I810)	+= i810.o
+obj-$(CONFIG_DRM_I830)	+= i830.o
 obj-$(CONFIG_DRM_FFB)   += ffb.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/char/drm/drm.h b/drivers/char/drm/drm.h
--- a/drivers/char/drm/drm.h	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/drm.h	Fri May 24 18:55:34 2002
@@ -104,9 +104,9 @@
 #include "i810_drm.h"
 #include "r128_drm.h"
 #include "radeon_drm.h"
-#ifdef CONFIG_DRM_SIS
 #include "sis_drm.h"
-#endif
+#include "i830_drm.h"
+#include "gamma_drm.h"
 
 typedef struct drm_version {
 	int    version_major;	  /* Major version			    */
@@ -449,6 +449,12 @@
 #define DRM_IOCTL_I810_SWAP		DRM_IO(  0x46)
 #define DRM_IOCTL_I810_COPY		DRM_IOW( 0x47, drm_i810_copy_t)
 #define DRM_IOCTL_I810_DOCOPY		DRM_IO(  0x48)
+#define DRM_IOCTL_I810_OV0INFO		DRM_IOR( 0x49, drm_i810_overlay_t)
+#define DRM_IOCTL_I810_FSTATUS		DRM_IO ( 0x4a)
+#define DRM_IOCTL_I810_OV0FLIP		DRM_IO ( 0x4b)
+#define DRM_IOCTL_I810_MC		DRM_IOW( 0x4c, drm_i810_mc_t)
+#define DRM_IOCTL_I810_RSTATUS		DRM_IO ( 0x4d )
+
 
 /* Rage 128 specific ioctls */
 #define DRM_IOCTL_R128_INIT		DRM_IOW( 0x40, drm_r128_init_t)
@@ -466,6 +472,7 @@
 #define DRM_IOCTL_R128_STIPPLE		DRM_IOW( 0x4d, drm_r128_stipple_t)
 #define DRM_IOCTL_R128_INDIRECT		DRM_IOWR(0x4f, drm_r128_indirect_t)
 #define DRM_IOCTL_R128_FULLSCREEN	DRM_IOW( 0x50, drm_r128_fullscreen_t)
+#define DRM_IOCTL_R128_CLEAR2		DRM_IOW( 0x51, drm_r128_clear2_t)
 
 /* Radeon specific ioctls */
 #define DRM_IOCTL_RADEON_CP_INIT	DRM_IOW( 0x40, drm_radeon_init_t)
@@ -482,8 +489,15 @@
 #define DRM_IOCTL_RADEON_STIPPLE	DRM_IOW( 0x4c, drm_radeon_stipple_t)
 #define DRM_IOCTL_RADEON_INDIRECT	DRM_IOWR(0x4d, drm_radeon_indirect_t)
 #define DRM_IOCTL_RADEON_TEXTURE	DRM_IOWR(0x4e, drm_radeon_texture_t)
+#define DRM_IOCTL_RADEON_VERTEX2	DRM_IOW( 0x4f, drm_radeon_vertex_t)
+#define DRM_IOCTL_RADEON_CMDBUF  	DRM_IOW( 0x50, drm_radeon_cmd_buffer_t)
+#define DRM_IOCTL_RADEON_GETPARAM	DRM_IOWR(0x51, drm_radeon_getparam_t)
+#define DRM_IOCTL_RADEON_FLIP		DRM_IO(  0x52)
+
+/* Gamma specific ioctls */
+#define DRM_IOCTL_GAMMA_INIT		DRM_IOW( 0x40, drm_gamma_init_t)
+#define DRM_IOCTL_GAMMA_COPY		DRM_IOW( 0x41, drm_gamma_copy_t)
 
-#ifdef CONFIG_DRM_SIS
 /* SiS specific ioctls */
 #define SIS_IOCTL_FB_ALLOC		DRM_IOWR(0x44, drm_sis_mem_t)
 #define SIS_IOCTL_FB_FREE		DRM_IOW( 0x45, drm_sis_mem_t)
@@ -493,6 +507,16 @@
 #define SIS_IOCTL_FLIP			DRM_IOW( 0x48, drm_sis_flip_t)
 #define SIS_IOCTL_FLIP_INIT		DRM_IO(  0x49)
 #define SIS_IOCTL_FLIP_FINAL		DRM_IO(  0x50)
-#endif
+
+/* I830 specific ioctls */
+#define DRM_IOCTL_I830_INIT		DRM_IOW( 0x40, drm_i830_init_t)
+#define DRM_IOCTL_I830_VERTEX		DRM_IOW( 0x41, drm_i830_vertex_t)
+#define DRM_IOCTL_I830_CLEAR		DRM_IOW( 0x42, drm_i830_clear_t)
+#define DRM_IOCTL_I830_FLUSH		DRM_IO ( 0x43)
+#define DRM_IOCTL_I830_GETAGE		DRM_IO ( 0x44)
+#define DRM_IOCTL_I830_GETBUF		DRM_IOWR(0x45, drm_i830_dma_t)
+#define DRM_IOCTL_I830_SWAP		DRM_IO ( 0x46)
+#define DRM_IOCTL_I830_COPY		DRM_IOW( 0x47, drm_i830_copy_t)
+#define DRM_IOCTL_I830_DOCOPY		DRM_IO ( 0x48)
 
 #endif
diff -Nru a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
--- a/drivers/char/drm/drmP.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/drmP.h	Fri May 24 18:55:36 2002
@@ -50,7 +50,7 @@
 #include <linux/pci.h>
 #include <linux/wrapper.h>
 #include <linux/version.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/smp_lock.h>	/* For (un)lock_kernel */
 #include <linux/mm.h>
 #if defined(__alpha__) || defined(__powerpc__)
@@ -66,27 +66,11 @@
 #include <linux/types.h>
 #include <linux/agp_backend.h>
 #endif
-#if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */
 #include <linux/tqueue.h>
 #include <linux/poll.h>
-#endif
-#if LINUX_VERSION_CODE < 0x020400
-#include "compat-pre24.h"
-#endif
 #include <asm/pgalloc.h>
 #include "drm.h"
 
-/* page_to_bus for earlier kernels, not optimal in all cases */
-#ifndef page_to_bus
-#define page_to_bus(page)	((unsigned int)(virt_to_bus(page_address(page))))
-#endif
-
-/* We just use virt_to_bus for pci_map_single on older kernels */
-#if LINUX_VERSION_CODE < 0x020400
-#define pci_map_single(hwdev, ptr, size, direction)	virt_to_bus(ptr)
-#define pci_unmap_single(hwdev, dma_addr, size, direction)
-#endif
-
 /* DRM template customization defaults
  */
 #ifndef __HAVE_AGP
@@ -161,179 +145,57 @@
 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 
 				/* Backward compatibility section */
-				/* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
-#ifndef _PAGE_PWT
-#define _PAGE_PWT _PAGE_WT
-#endif
-				/* Wait queue declarations changed in 2.3.1 */
-#ifndef DECLARE_WAITQUEUE
-#define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
-typedef struct wait_queue *wait_queue_head_t;
-#define init_waitqueue_head(q) *q = NULL;
+#ifndef minor
+#define minor(x) MINOR((x))
 #endif
 
-				/* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
-#ifndef _PAGE_PSE
-#define _PAGE_PSE _PAGE_4M
-#endif
-
-				/* vm_offset changed to vm_pgoff in 2.3.25 */
-#if LINUX_VERSION_CODE < 0x020319
-#define VM_OFFSET(vma) ((vma)->vm_offset)
-#else
-#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
+#ifndef MODULE_LICENSE
+#define MODULE_LICENSE(x) 
 #endif
 
-				/* *_nopage return values defined in 2.3.26 */
-#ifndef NOPAGE_SIGBUS
-#define NOPAGE_SIGBUS 0
-#endif
-#ifndef NOPAGE_OOM
-#define NOPAGE_OOM 0
+#ifndef preempt_disable
+#define preempt_disable()
+#define preempt_enable()
 #endif
 
-				/* module_init/module_exit added in 2.3.13 */
-#ifndef module_init
-#define module_init(x)  int init_module(void) { return x(); }
-#endif
-#ifndef module_exit
-#define module_exit(x)  void cleanup_module(void) { x(); }
+#ifndef pte_offset_map 
+#define pte_offset_map pte_offset
+#define pte_unmap(pte)
 #endif
 
-				/* Generic cmpxchg added in 2.3.x */
-#ifndef __HAVE_ARCH_CMPXCHG
-				/* Include this here so that driver can be
-                                   used with older kernels. */
-#if defined(__alpha__)
-static __inline__ unsigned long
-__cmpxchg_u32(volatile int *m, int old, int new)
-{
-	unsigned long prev, cmp;
-
-	__asm__ __volatile__(
-	"1:	ldl_l %0,%5\n"
-	"	cmpeq %0,%3,%1\n"
-	"	beq %1,2f\n"
-	"	mov %4,%1\n"
-	"	stl_c %1,%2\n"
-	"	beq %1,3f\n"
-	"2:	mb\n"
-	".subsection 2\n"
-	"3:	br 1b\n"
-	".previous"
-	: "=&r"(prev), "=&r"(cmp), "=m"(*m)
-	: "r"((long) old), "r"(new), "m"(*m)
-	: "memory" );
-
-	return prev;
-}
-
-static __inline__ unsigned long
-__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
-{
-	unsigned long prev, cmp;
-
-	__asm__ __volatile__(
-	"1:	ldq_l %0,%5\n"
-	"	cmpeq %0,%3,%1\n"
-	"	beq %1,2f\n"
-	"	mov %4,%1\n"
-	"	stq_c %1,%2\n"
-	"	beq %1,3f\n"
-	"2:	mb\n"
-	".subsection 2\n"
-	"3:	br 1b\n"
-	".previous"
-	: "=&r"(prev), "=&r"(cmp), "=m"(*m)
-	: "r"((long) old), "r"(new), "m"(*m)
-	: "memory" );
-
-	return prev;
-}
-
-static __inline__ unsigned long
-__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
-{
-	switch (size) {
-		case 4:
-			return __cmpxchg_u32(ptr, old, new);
-		case 8:
-			return __cmpxchg_u64(ptr, old, new);
-	}
-	return old;
-}
-#define cmpxchg(ptr,o,n)						 \
-  ({									 \
-     __typeof__(*(ptr)) _o_ = (o);					 \
-     __typeof__(*(ptr)) _n_ = (n);					 \
-     (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,		 \
-				    (unsigned long)_n_, sizeof(*(ptr))); \
-  })
-
-#elif __i386__
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-				      unsigned long new, int size)
-{
-	unsigned long prev;
-	switch (size) {
-	case 1:
-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
-				     : "memory");
-		return prev;
-	case 2:
-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
-				     : "memory");
-		return prev;
-	case 4:
-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
-				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
-				     : "memory");
-		return prev;
-	}
-	return old;
-}
-
-#elif defined(__powerpc__)
-extern void __cmpxchg_called_with_bad_pointer(void);
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-                                      unsigned long new, int size)
+#if LINUX_VERSION_CODE < 0x020500
+static inline struct page * vmalloc_to_page(void * vmalloc_addr)
 {
-	unsigned long prev;
-
-	switch (size) {
-	case 4:
-		__asm__ __volatile__(
-			"sync;"
-			"0:    lwarx %0,0,%1 ;"
-			"      cmpl 0,%0,%3;"
-			"      bne 1f;"
-			"      stwcx. %2,0,%1;"
-			"      bne- 0b;"
-			"1:    "
-			"sync;"
-			: "=&r"(prev)
-			: "r"(ptr), "r"(new), "r"(old)
-			: "cr0", "memory");
-		return prev;
+	unsigned long addr = (unsigned long) vmalloc_addr;
+	struct page *page = NULL;
+	pgd_t *pgd = pgd_offset_k(addr);
+	pmd_t *pmd;
+	pte_t *ptep, pte;
+  
+	if (!pgd_none(*pgd)) {
+		pmd = pmd_offset(pgd, addr);
+		if (!pmd_none(*pmd)) {
+			preempt_disable();
+			ptep = pte_offset_map(pmd, addr);
+			pte = *ptep;
+			if (pte_present(pte))
+				page = pte_page(pte);
+			pte_unmap(ptep);
+			preempt_enable();
+		}
 	}
-	__cmpxchg_called_with_bad_pointer();
-	return old;
+	return page;
 }
+#endif
 
-#endif /* i386, powerpc & alpha */
-
-#ifndef __alpha__
-#define cmpxchg(ptr,o,n)						\
-  ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),		\
-				 (unsigned long)(n),sizeof(*(ptr))))
+#if LINUX_VERSION_CODE < 0x020500
+#define DRM_RPR_ARG(vma)
+#else
+#define DRM_RPR_ARG(vma) vma,
 #endif
 
-#endif /* !__HAVE_ARCH_CMPXCHG */
+
+#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
 
 				/* Macros to make printk easier */
 #define DRM_ERROR(fmt, arg...) \
@@ -369,6 +231,9 @@
 #define DRM_IOREMAP(map)						\
 	(map)->handle = DRM(ioremap)( (map)->offset, (map)->size )
 
+#define DRM_IOREMAP_NOCACHE(map)					\
+	(map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size)
+
 #define DRM_IOREMAPFREE(map)						\
 	do {								\
 		if ( (map)->handle && (map)->size )			\
@@ -778,34 +643,18 @@
 			       struct poll_table_struct *wait);
 
 				/* Mapping support (drm_vm.h) */
-#if LINUX_VERSION_CODE < 0x020317
-extern unsigned long DRM(vm_nopage)(struct vm_area_struct *vma,
-				    unsigned long address,
-				    int unused);
-extern unsigned long DRM(vm_shm_nopage)(struct vm_area_struct *vma,
-					unsigned long address,
-					int unused);
-extern unsigned long DRM(vm_dma_nopage)(struct vm_area_struct *vma,
-					unsigned long address,
-					int unused);
-extern unsigned long DRM(vm_sg_nopage)(struct vm_area_struct *vma,
-				       unsigned long address,
-				       int unused);
-#else
-				/* Return type changed in 2.3.23 */
 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
 				   unsigned long address,
-				   int unused);
+				   int write_access);
 extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
 				       unsigned long address,
-				       int unused);
+				       int write_access);
 extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
 				       unsigned long address,
-				       int unused);
+				       int write_access);
 extern struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
 				      unsigned long address,
-				      int unused);
-#endif
+				      int write_access);
 extern void	     DRM(vm_open)(struct vm_area_struct *vma);
 extern void	     DRM(vm_close)(struct vm_area_struct *vma);
 extern void	     DRM(vm_shm_close)(struct vm_area_struct *vma);
@@ -827,6 +676,7 @@
 extern void	     DRM(free_pages)(unsigned long address, int order,
 				     int area);
 extern void	     *DRM(ioremap)(unsigned long offset, unsigned long size);
+extern void	     *DRM(ioremap_nocache)(unsigned long offset, unsigned long size);
 extern void	     DRM(ioremapfree)(void *pt, unsigned long size);
 
 #if __REALLY_HAVE_AGP
diff -Nru a/drivers/char/drm/drm_agpsupport.h b/drivers/char/drm/drm_agpsupport.h
--- a/drivers/char/drm/drm_agpsupport.h	Fri May 24 18:55:33 2002
+++ b/drivers/char/drm/drm_agpsupport.h	Fri May 24 18:55:33 2002
@@ -35,12 +35,8 @@
 
 #if __REALLY_HAVE_AGP
 
-#if LINUX_VERSION_CODE < 0x020400
-#include "agpsupport-pre24.h"
-#else
 #define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
 #define DRM_AGP_PUT inter_module_put("drm_agp")
-#endif
 
 static const drm_agp_t *drm_agp = NULL;
 
@@ -271,24 +267,24 @@
 		case INTEL_GX:		head->chipset = "Intel 440GX";   break;
 		case INTEL_I810:	head->chipset = "Intel i810";    break;
 
-#if LINUX_VERSION_CODE >= 0x020400
 		case INTEL_I815:	head->chipset = "Intel i815";	 break;
+#if LINUX_VERSION_CODE >= 0x020415
 	 	case INTEL_I820:	head->chipset = "Intel i820";	 break;
+#endif
 		case INTEL_I840:	head->chipset = "Intel i840";    break;
+#if LINUX_VERSION_CODE >= 0x020415
 		case INTEL_I845:	head->chipset = "Intel i845";    break;
-		case INTEL_I850:	head->chipset = "Intel i850";	 break;
 #endif
+		case INTEL_I850:	head->chipset = "Intel i850";	 break;
 
 		case VIA_GENERIC:	head->chipset = "VIA";           break;
 		case VIA_VP3:		head->chipset = "VIA VP3";       break;
 		case VIA_MVP3:		head->chipset = "VIA MVP3";      break;
-#if LINUX_VERSION_CODE >= 0x020400
 		case VIA_MVP4:		head->chipset = "VIA MVP4";      break;
 		case VIA_APOLLO_KX133:	head->chipset = "VIA Apollo KX133";
 			break;
 		case VIA_APOLLO_KT133:	head->chipset = "VIA Apollo KT133";
 			break;
-#endif
 
 		case VIA_APOLLO_PRO: 	head->chipset = "VIA Apollo Pro";
 			break;
diff -Nru a/drivers/char/drm/drm_auth.h b/drivers/char/drm/drm_auth.h
--- a/drivers/char/drm/drm_auth.h	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/drm_auth.h	Fri May 24 18:55:35 2002
@@ -64,6 +64,7 @@
 	hash	     = DRM(hash_magic)(magic);
 	entry	     = DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC);
 	if (!entry) return -ENOMEM;
+	memset(entry, 0, sizeof(*entry));
 	entry->magic = magic;
 	entry->priv  = priv;
 	entry->next  = NULL;
diff -Nru a/drivers/char/drm/drm_bufs.h b/drivers/char/drm/drm_bufs.h
--- a/drivers/char/drm/drm_bufs.h	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/drm_bufs.h	Fri May 24 18:55:34 2002
@@ -229,11 +229,7 @@
 	DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
 
 	for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
-#if LINUX_VERSION_CODE >= 0x020300
 		if (pt->vma->vm_private_data == map) found_maps++;
-#else
-		if (pt->vma->vm_pte == map) found_maps++;
-#endif
 	}
 
 	if(!found_maps) {
diff -Nru a/drivers/char/drm/drm_context.h b/drivers/char/drm/drm_context.h
--- a/drivers/char/drm/drm_context.h	Fri May 24 18:55:33 2002
+++ b/drivers/char/drm/drm_context.h	Fri May 24 18:55:33 2002
@@ -27,6 +27,10 @@
  * Authors:
  *    Rickard E. (Rik) Faith <faith@valinux.com>
  *    Gareth Hughes <gareth@valinux.com>
+ * ChangeLog:
+ *  2001-11-16	Torsten Duwe <duwe@caldera.de>
+ *		added context constructor/destructor hooks,
+ *		needed by SiS driver's memory management.
  */
 
 #define __NO_VERSION__
@@ -316,6 +320,10 @@
 				/* Should this return -EBUSY instead? */
 		return -ENOMEM;
 	}
+#ifdef DRIVER_CTX_CTOR
+	if ( ctx.handle != DRM_KERNEL_CONTEXT )
+		DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
+#endif
 
 	if ( copy_to_user( (drm_ctx_t *)arg, &ctx, sizeof(ctx) ) )
 		return -EFAULT;
@@ -390,6 +398,9 @@
 		priv->remove_auth_on_close = 1;
 	}
 	if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
+#ifdef DRIVER_CTX_DTOR
+		DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
+#endif
 		DRM(ctxbitmap_free)( dev, ctx.handle );
 	}
 
diff -Nru a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h
--- a/drivers/char/drm/drm_dma.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/drm_dma.h	Fri May 24 18:55:36 2002
@@ -598,6 +598,25 @@
 	}
 }
 
+#else
+
+int DRM(control)( struct inode *inode, struct file *filp,
+		  unsigned int cmd, unsigned long arg )
+{
+	drm_control_t ctl;
+
+	if ( copy_from_user( &ctl, (drm_control_t *)arg, sizeof(ctl) ) )
+		return -EFAULT;
+
+	switch ( ctl.func ) {
+	case DRM_INST_HANDLER:
+	case DRM_UNINST_HANDLER:
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 #endif /* __HAVE_DMA_IRQ */
 
 #endif /* __HAVE_DMA */
diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
--- a/drivers/char/drm/drm_drv.h	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/drm_drv.h	Fri May 24 18:55:34 2002
@@ -113,7 +113,6 @@
 #define DRIVER_IOCTLS
 #endif
 #ifndef DRIVER_FOPS
-#if LINUX_VERSION_CODE >= 0x020400
 #define DRIVER_FOPS				\
 static struct file_operations	DRM(fops) = {	\
 	owner:   THIS_MODULE,			\
@@ -126,19 +125,6 @@
 	fasync:	 DRM(fasync),			\
 	poll:	 DRM(poll),			\
 }
-#else
-#define DRIVER_FOPS				\
-static struct file_operations	DRM(fops) = {	\
-	open:	 DRM(open),			\
-	flush:	 DRM(flush),			\
-	release: DRM(release),			\
-	ioctl:	 DRM(ioctl),			\
-	mmap:	 DRM(mmap),			\
-	read:	 DRM(read),			\
-	fasync:	 DRM(fasync),			\
-	poll:	 DRM(poll),			\
-}
-#endif
 #endif
 
 
@@ -201,10 +187,8 @@
 
 	/* The DRM_IOCTL_DMA ioctl should be defined by the driver.
 	 */
-#if __HAVE_DMA_IRQ
 	[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)]       = { DRM(control),     1, 1 },
 #endif
-#endif
 
 #if __REALLY_HAVE_AGP
 	[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)]   = { DRM(agp_acquire), 1, 1 },
@@ -732,9 +716,6 @@
 
 	retcode = DRM(open_helper)( inode, filp, dev );
 	if ( !retcode ) {
-#if LINUX_VERSION_CODE < 0x020333
-		MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
-#endif
 		atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
 		spin_lock( &dev->count_lock );
 		if ( !dev->open_count++ ) {
@@ -853,9 +834,6 @@
 	 * End inline drm_release
 	 */
 
-#if LINUX_VERSION_CODE < 0x020333
-	MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
-#endif
 	atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
 	spin_lock( &dev->count_lock );
 	if ( !--dev->open_count ) {
diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
--- a/drivers/char/drm/drm_fops.h	Fri May 24 18:55:33 2002
+++ b/drivers/char/drm/drm_fops.h	Fri May 24 18:55:33 2002
@@ -191,24 +191,8 @@
 		send -= count;
 	}
 
-#if LINUX_VERSION_CODE < 0x020315 && !defined(KILLFASYNCHASTHREEPARAMETERS)
-	/* The extra parameter to kill_fasync was added in 2.3.21, and is
-           _not_ present in _stock_ 2.2.14 and 2.2.15.  However, some
-           distributions patch 2.2.x kernels to add this parameter.  The
-           Makefile.linux attempts to detect this addition and defines
-           KILLFASYNCHASTHREEPARAMETERS if three parameters are found. */
-	if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO);
-#else
-
-				/* Parameter added in 2.3.21. */
-#if LINUX_VERSION_CODE < 0x020400
-	if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO, POLL_IN);
-#else
-				/* Type of first parameter changed in
-                                   Linux 2.4.0-test2... */
 	if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN);
-#endif
-#endif
+
 	DRM_DEBUG("waking\n");
 	wake_up_interruptible(&dev->buf_readers);
 	return 0;
diff -Nru a/drivers/char/drm/drm_lists.h b/drivers/char/drm/drm_lists.h
--- a/drivers/char/drm/drm_lists.h	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/drm_lists.h	Fri May 24 18:55:34 2002
@@ -42,7 +42,7 @@
 				    DRM_MEM_BUFLISTS);
 
 	if(!bl->bufs) return -ENOMEM;
-
+	memset(bl->bufs, 0, sizeof(*bl->bufs));
 	bl->count      = count;
 	bl->rp	       = bl->bufs;
 	bl->wp	       = bl->bufs;
diff -Nru a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h
--- a/drivers/char/drm/drm_memory.h	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/drm_memory.h	Fri May 24 18:55:34 2002
@@ -85,12 +85,7 @@
 	}
 
 	si_meminfo(&si);
-#if LINUX_VERSION_CODE < 0x020317
-				/* Changed to page count in 2.3.23 */
-	DRM(ram_available) = si.totalram >> PAGE_SHIFT;
-#else
 	DRM(ram_available) = si.totalram;
-#endif
 	DRM(ram_used)	   = 0;
 }
 
@@ -257,12 +252,7 @@
 	for (addr = address, sz = bytes;
 	     sz > 0;
 	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
-#if LINUX_VERSION_CODE >= 0x020400
-				/* Argument type changed in 2.4.0-test6/pre8 */
 		mem_map_reserve(virt_to_page(addr));
-#else
-		mem_map_reserve(MAP_NR(addr));
-#endif
 	}
 
 	return address;
@@ -283,12 +273,7 @@
 		for (addr = address, sz = bytes;
 		     sz > 0;
 		     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
-#if LINUX_VERSION_CODE >= 0x020400
-				/* Argument type changed in 2.4.0-test6/pre8 */
 			mem_map_unreserve(virt_to_page(addr));
-#else
-			mem_map_unreserve(MAP_NR(addr));
-#endif
 		}
 		free_pages(address, order);
 	}
@@ -317,6 +302,29 @@
 	}
 
 	if (!(pt = ioremap(offset, size))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return NULL;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
+	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
+	spin_unlock(&DRM(mem_lock));
+	return pt;
+}
+
+void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size)
+{
+	void *pt;
+
+	if (!size) {
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Mapping 0 bytes at 0x%08lx\n", offset);
+		return NULL;
+	}
+
+	if (!(pt = ioremap_nocache(offset, size))) {
 		spin_lock(&DRM(mem_lock));
 		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
 		spin_unlock(&DRM(mem_lock));
diff -Nru a/drivers/char/drm/drm_scatter.h b/drivers/char/drm/drm_scatter.h
--- a/drivers/char/drm/drm_scatter.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/drm_scatter.h	Fri May 24 18:55:36 2002
@@ -94,6 +94,8 @@
 		return -ENOMEM;
 	}
 
+	memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
+
 	entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
 				     DRM_MEM_PAGES );
 	if ( !entry->busaddr ) {
diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h
--- a/drivers/char/drm/drm_stub.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/drm_stub.h	Fri May 24 18:55:36 2002
@@ -31,10 +31,6 @@
 #define __NO_VERSION__
 #include "drmP.h"
 
-#if LINUX_VERSION_CODE < 0x020400
-#include "stubsupport-pre24.h"
-#endif
-
 #define DRM_STUB_MAXCARDS 16	/* Enough for one machine */
 
 static struct drm_stub_list {
@@ -70,9 +66,7 @@
 }
 
 static struct file_operations DRM(stub_fops) = {
-#if LINUX_VERSION_CODE >= 0x020400
 	owner:   THIS_MODULE,
-#endif
 	open:	 DRM(stub_open)
 };
 
diff -Nru a/drivers/char/drm/drm_vm.h b/drivers/char/drm/drm_vm.h
--- a/drivers/char/drm/drm_vm.h	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/drm_vm.h	Fri May 24 18:55:35 2002
@@ -56,16 +56,9 @@
 	close:   DRM(vm_close),
 };
 
-#if LINUX_VERSION_CODE < 0x020317
-unsigned long DRM(vm_nopage)(struct vm_area_struct *vma,
-			     unsigned long address,
-			     int unused)
-#else
-				/* Return type changed in 2.3.23 */
 struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
 			    unsigned long address,
-			    int unused)
-#endif
+			    int write_access)
 {
 #if __REALLY_HAVE_AGP
 	drm_file_t *priv  = vma->vm_file->private_data;
@@ -122,11 +115,7 @@
 		DRM_DEBUG("baddr = 0x%lx page = 0x%p, offset = 0x%lx\n",
 			  baddr, __va(agpmem->memory->memory[offset]), offset);
 
-#if LINUX_VERSION_CODE < 0x020317
-		return page_address(page);
-#else
 		return page;
-#endif
         }
 vm_nopage_error:
 #endif /* __REALLY_HAVE_AGP */
@@ -134,22 +123,11 @@
 	return NOPAGE_SIGBUS;		/* Disallow mremap */
 }
 
-#if LINUX_VERSION_CODE < 0x020317
-unsigned long DRM(vm_shm_nopage)(struct vm_area_struct *vma,
-				 unsigned long address,
-				 int unused)
-#else
-				/* Return type changed in 2.3.23 */
 struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
 				unsigned long address,
-				int unused)
-#endif
+				int write_access)
 {
-#if LINUX_VERSION_CODE >= 0x020300
 	drm_map_t	 *map	 = (drm_map_t *)vma->vm_private_data;
-#else
-	drm_map_t	 *map	 = (drm_map_t *)vma->vm_pte;
-#endif
 	unsigned long	 offset;
 	unsigned long	 i;
 	struct page	 *page;
@@ -165,11 +143,7 @@
 	get_page(page);
 
 	DRM_DEBUG("shm_nopage 0x%lx\n", address);
-#if LINUX_VERSION_CODE < 0x020317
-	return page_address(page);
-#else
 	return page;
-#endif
 }
 
 /* Special close routine which deletes map information if we are the last
@@ -188,25 +162,14 @@
 
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
-#if LINUX_VERSION_CODE < 0x020333
-	MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
-#endif
 	atomic_dec(&dev->vma_count);
 
-#if LINUX_VERSION_CODE >= 0x020300
 	map = vma->vm_private_data;
-#else
-	map = vma->vm_pte;
-#endif
 
 	down(&dev->struct_sem);
 	for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
 		next = pt->next;
-#if LINUX_VERSION_CODE >= 0x020300
 		if (pt->vma->vm_private_data == map) found_maps++;
-#else
-		if (pt->vma->vm_pte == map) found_maps++;
-#endif
 		if (pt->vma == vma) {
 			if (prev) {
 				prev->next = pt->next;
@@ -259,16 +222,9 @@
 	up(&dev->struct_sem);
 }
 
-#if LINUX_VERSION_CODE < 0x020317
-unsigned long DRM(vm_dma_nopage)(struct vm_area_struct *vma,
-				 unsigned long address,
-				 int unused)
-#else
-				/* Return type changed in 2.3.23 */
 struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
 				unsigned long address,
-				int unused)
-#endif
+				int write_access)
 {
 	drm_file_t	 *priv	 = vma->vm_file->private_data;
 	drm_device_t	 *dev	 = priv->dev;
@@ -288,30 +244,15 @@
 
 	get_page(page);
 
-	DRM_DEBUG("dma_nopage 0x%lx (page %lu)\n", address, page_nr); 
-#if LINUX_VERSION_CODE < 0x020317
-	return page_address(page);
-#else
+	DRM_DEBUG("dma_nopage 0x%lx (page %lu)\n", address, page_nr);
 	return page;
-#endif
 }
 
-#if LINUX_VERSION_CODE < 0x020317
-unsigned long DRM(vm_sg_nopage)(struct vm_area_struct *vma,
-				unsigned long address,
-				int unused)
-#else
-				/* Return type changed in 2.3.23 */
 struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
 			       unsigned long address,
-			       int unused)
-#endif
+			       int write_access)
 {
-#if LINUX_VERSION_CODE >= 0x020300
 	drm_map_t        *map    = (drm_map_t *)vma->vm_private_data;
-#else
-	drm_map_t        *map    = (drm_map_t *)vma->vm_pte;
-#endif
 	drm_file_t *priv = vma->vm_file->private_data;
 	drm_device_t *dev = priv->dev;
 	drm_sg_mem_t *entry = dev->sg;
@@ -331,11 +272,7 @@
 	page = entry->pagelist[page_offset];
 	get_page(page);
 
-#if LINUX_VERSION_CODE < 0x020317
-	return page_address(page);
-#else
 	return page;
-#endif
 }
 
 void DRM(vm_open)(struct vm_area_struct *vma)
@@ -347,10 +284,6 @@
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
 	atomic_inc(&dev->vma_count);
-#if LINUX_VERSION_CODE < 0x020333
-				/* The map can exist after the fd is closed. */
-	MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
-#endif
 
 	vma_entry = DRM(alloc)(sizeof(*vma_entry), DRM_MEM_VMAS);
 	if (vma_entry) {
@@ -371,9 +304,6 @@
 
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
-#if LINUX_VERSION_CODE < 0x020333
-	MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
-#endif
 	atomic_dec(&dev->vma_count);
 
 	down(&dev->struct_sem);
@@ -412,13 +342,13 @@
 	unlock_kernel();
 
 	vma->vm_ops   = &DRM(vm_dma_ops);
-	vma->vm_flags |= VM_RESERVED; /* Don't swap */
 
-#if LINUX_VERSION_CODE < 0x020203 /* KERNEL_VERSION(2,2,3) */
-				/* In Linux 2.2.3 and above, this is
-				   handled in do_mmap() in mm/mmap.c. */
-	++filp->f_count;
+#if LINUX_VERSION_CODE <= 0x020414
+	vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
+#else
+	vma->vm_flags |= VM_RESERVED; /* Don't swap */
 #endif
+
 	vma->vm_file  =	 filp;	/* Needed for drm_vm_open() */
 	DRM(vm_open)(vma);
 	return 0;
@@ -521,12 +451,12 @@
 		}
 		offset = DRIVER_GET_REG_OFS();
 #ifdef __sparc__
-		if (io_remap_page_range(vma, vma->vm_start,
+		if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
 					VM_OFFSET(vma) + offset,
 					vma->vm_end - vma->vm_start,
 					vma->vm_page_prot, 0))
 #else
-		if (remap_page_range(vma, vma->vm_start,
+		if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
 				     VM_OFFSET(vma) + offset,
 				     vma->vm_end - vma->vm_start,
 				     vma->vm_page_prot))
@@ -540,34 +470,33 @@
 		break;
 	case _DRM_SHM:
 		vma->vm_ops = &DRM(vm_shm_ops);
-#if LINUX_VERSION_CODE >= 0x020300
 		vma->vm_private_data = (void *)map;
-#else
-		vma->vm_pte = (unsigned long)map;
-#endif
 				/* Don't let this area swap.  Change when
 				   DRM_KERNEL advisory is supported. */
+#if LINUX_VERSION_CODE <= 0x020414
+		vma->vm_flags |= VM_LOCKED;
+#else
 		vma->vm_flags |= VM_RESERVED;
+#endif
 		break;
 	case _DRM_SCATTER_GATHER:
 		vma->vm_ops = &DRM(vm_sg_ops);
-#if LINUX_VERSION_CODE >= 0x020300
 		vma->vm_private_data = (void *)map;
+#if LINUX_VERSION_CODE <= 0x020414
+		vma->vm_flags |= VM_LOCKED;
 #else
-		vma->vm_pte = (unsigned long)map;
+		vma->vm_flags |= VM_RESERVED;
 #endif
-                vma->vm_flags |= VM_RESERVED;
                 break;
 	default:
 		return -EINVAL;	/* This should never happen. */
 	}
+#if LINUX_VERSION_CODE <= 0x020414
+	vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
+#else
 	vma->vm_flags |= VM_RESERVED; /* Don't swap */
-
-#if LINUX_VERSION_CODE < 0x020203 /* KERNEL_VERSION(2,2,3) */
-				/* In Linux 2.2.3 and above, this is
-				   handled in do_mmap() in mm/mmap.c. */
-	++filp->f_count;
 #endif
+
 	vma->vm_file  =	 filp;	/* Needed for drm_vm_open() */
 	DRM(vm_open)(vma);
 	return 0;
diff -Nru a/drivers/char/drm/gamma.h b/drivers/char/drm/gamma.h
--- a/drivers/char/drm/gamma.h	Fri May 24 18:55:33 2002
+++ b/drivers/char/drm/gamma.h	Fri May 24 18:55:33 2002
@@ -41,6 +41,8 @@
 /* DMA customization:
  */
 #define __HAVE_DMA			1
+#define __HAVE_AGP			1
+#define __MUST_HAVE_AGP			0
 #define __HAVE_OLD_DMA			1
 #define __HAVE_PCI_DMA			1
 
@@ -61,33 +63,61 @@
 #define __HAVE_DMA_QUIESCENT		1
 #define DRIVER_DMA_QUIESCENT() do {					\
 	/* FIXME ! */ 							\
-	gamma_dma_quiescent_dual(dev);					\
+	gamma_dma_quiescent_single(dev);					\
 	return 0;							\
 } while (0)
 
 #define __HAVE_DMA_IRQ			1
 #define __HAVE_DMA_IRQ_BH		1
+
+#if 1
 #define DRIVER_PREINSTALL() do {					\
 	drm_gamma_private_t *dev_priv =					\
 				(drm_gamma_private_t *)dev->dev_private;\
-	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	0x00000000 );		\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	0x00000004 );		\
 	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );		\
 } while (0)
-
 #define DRIVER_POSTINSTALL() do {					\
 	drm_gamma_private_t *dev_priv =					\
 				(drm_gamma_private_t *)dev->dev_private;\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);			\
 	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002001 );		\
 	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000008 );		\
 	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00039090 );		\
 } while (0)
+#else
+#define DRIVER_POSTINSTALL() do {					\
+	drm_gamma_private_t *dev_priv =					\
+				(drm_gamma_private_t *)dev->dev_private;\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002000 );		\
+	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000004 );		\
+} while (0)
+
+#define DRIVER_PREINSTALL() do {					\
+	drm_gamma_private_t *dev_priv =					\
+				(drm_gamma_private_t *)dev->dev_private;\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	GAMMA_QUEUED_DMA_MODE );\
+	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );\
+} while (0)
+#endif
 
 #define DRIVER_UNINSTALL() do {						\
 	drm_gamma_private_t *dev_priv =					\
 				(drm_gamma_private_t *)dev->dev_private;\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);			\
 	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00000000 );		\
 	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000000 );		\
 	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00000000 );		\
 } while (0)
+
+#define DRIVER_AGP_BUFFERS_MAP( dev )					\
+	((drm_gamma_private_t *)((dev)->dev_private))->buffers
 
 #endif /* __GAMMA_H__ */
diff -Nru a/drivers/char/drm/gamma_dma.c b/drivers/char/drm/gamma_dma.c
--- a/drivers/char/drm/gamma_dma.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/gamma_dma.c	Fri May 24 18:55:36 2002
@@ -37,28 +37,25 @@
 #include <linux/interrupt.h>	/* For task queue support */
 #include <linux/delay.h>
 
-
 static inline void gamma_dma_dispatch(drm_device_t *dev, unsigned long address,
 				      unsigned long length)
 {
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
-
-	GAMMA_WRITE(GAMMA_DMAADDRESS, virt_to_phys((void *)address));
-	while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4)
-		;
+				(drm_gamma_private_t *)dev->dev_private;
+	mb();
+	while ( GAMMA_READ(GAMMA_INFIFOSPACE) < 2);
+	GAMMA_WRITE(GAMMA_DMAADDRESS, address);
+	while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4);
 	GAMMA_WRITE(GAMMA_DMACOUNT, length / 4);
 }
 
 void gamma_dma_quiescent_single(drm_device_t *dev)
 {
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
+				(drm_gamma_private_t *)dev->dev_private;
+	while (GAMMA_READ(GAMMA_DMACOUNT));
 
-	while (GAMMA_READ(GAMMA_DMACOUNT))
-		;
-	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
-		;
+	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 2);
 
 	GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
 	GAMMA_WRITE(GAMMA_SYNC, 0);
@@ -72,56 +69,50 @@
 void gamma_dma_quiescent_dual(drm_device_t *dev)
 {
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
+				(drm_gamma_private_t *)dev->dev_private;
+	while (GAMMA_READ(GAMMA_DMACOUNT));
 
-	while (GAMMA_READ(GAMMA_DMACOUNT))
-		;
-	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
-		;
+	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
 
 	GAMMA_WRITE(GAMMA_BROADCASTMASK, 3);
-
 	GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
 	GAMMA_WRITE(GAMMA_SYNC, 0);
 
-				/* Read from first MX */
+	/* Read from first MX */
 	do {
-		while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
-			;
+		while (!GAMMA_READ(GAMMA_OUTFIFOWORDS));
 	} while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
 
-				/* Read from second MX */
+	/* Read from second MX */
 	do {
-		while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000))
-			;
+		while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000));
 	} while (GAMMA_READ(GAMMA_OUTPUTFIFO + 0x10000) != GAMMA_SYNC_TAG);
 }
 
 void gamma_dma_ready(drm_device_t *dev)
 {
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
-
-	while (GAMMA_READ(GAMMA_DMACOUNT))
-		;
+				(drm_gamma_private_t *)dev->dev_private;
+	while (GAMMA_READ(GAMMA_DMACOUNT));
 }
 
 static inline int gamma_dma_is_ready(drm_device_t *dev)
 {
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
-
-	return !GAMMA_READ(GAMMA_DMACOUNT);
+				(drm_gamma_private_t *)dev->dev_private;
+	return(!GAMMA_READ(GAMMA_DMACOUNT));
 }
 
 void gamma_dma_service(int irq, void *device, struct pt_regs *regs)
 {
-	drm_device_t	    *dev      = (drm_device_t *)device;
-	drm_device_dma_t    *dma      = dev->dma;
+	drm_device_t	 *dev = (drm_device_t *)device;
+	drm_device_dma_t *dma = dev->dma;
 	drm_gamma_private_t *dev_priv =
-		(drm_gamma_private_t *)dev->dev_private;
+				(drm_gamma_private_t *)dev->dev_private;
 
 	atomic_inc(&dev->counts[6]); /* _DRM_STAT_IRQ */
+
+	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
 	GAMMA_WRITE(GAMMA_GDELAYTIMER, 0xc350/2); /* 0x05S */
 	GAMMA_WRITE(GAMMA_GCOMMANDINTFLAGS, 8);
 	GAMMA_WRITE(GAMMA_GINTFLAGS, 0x2001);
@@ -165,7 +156,9 @@
 	}
 
 	buf	= dma->next_buffer;
-	address = (unsigned long)buf->address;
+	/* WE NOW ARE ON LOGICAL PAGES!! - using page table setup in dma_init */
+	/* So we pass the buffer index value into the physical page offset */
+	address = buf->idx << 12;
 	length	= buf->used;
 
 	DRM_DEBUG("context %d, buffer %d (%ld bytes)\n",
@@ -232,6 +225,9 @@
 	buf->time_dispatched = get_cycles();
 #endif
 
+	/* WE NOW ARE ON LOGICAL PAGES!!! - overriding address */
+	address = buf->idx << 12;
+
 	gamma_dma_dispatch(dev, address, length);
 	gamma_free_buffer(dev, dma->this_buffer);
 	dma->this_buffer = buf;
@@ -581,4 +577,256 @@
 		return -EFAULT;
 
 	return retcode;
+}
+
+/* =============================================================
+ * DMA initialization, cleanup
+ */
+
+static int gamma_do_init_dma( drm_device_t *dev, drm_gamma_init_t *init )
+{
+	drm_gamma_private_t *dev_priv;
+	drm_device_dma_t    *dma = dev->dma;
+	drm_buf_t	    *buf;
+	int i;
+	struct list_head    *list;
+	unsigned int	    *pgt;
+
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	dev_priv = DRM(alloc)( sizeof(drm_gamma_private_t),
+							DRM_MEM_DRIVER );
+	if ( !dev_priv )
+		return -ENOMEM;
+
+	dev->dev_private = (void *)dev_priv;
+
+	memset( dev_priv, 0, sizeof(drm_gamma_private_t) );
+
+	list_for_each(list, &dev->maplist->head) {
+		drm_map_list_t *r_list = (drm_map_list_t *)list;
+		if( r_list->map &&
+		    r_list->map->type == _DRM_SHM &&
+		    r_list->map->flags & _DRM_CONTAINS_LOCK ) {
+			dev_priv->sarea = r_list->map;
+ 			break;
+ 		}
+ 	}
+
+	DRM_FIND_MAP( dev_priv->mmio0, init->mmio0 );
+	DRM_FIND_MAP( dev_priv->mmio1, init->mmio1 );
+	DRM_FIND_MAP( dev_priv->mmio2, init->mmio2 );
+	DRM_FIND_MAP( dev_priv->mmio3, init->mmio3 );
+
+	dev_priv->sarea_priv = (drm_gamma_sarea_t *)
+		((u8 *)dev_priv->sarea->handle +
+		 init->sarea_priv_offset);
+
+	if (init->pcimode) {
+		buf = dma->buflist[GLINT_DRI_BUF_COUNT];
+		pgt = buf->address;
+
+ 		for (i = 0; i < GLINT_DRI_BUF_COUNT; i++) {
+			buf = dma->buflist[i];
+			*pgt = virt_to_phys((void*)buf->address) | 0x07;
+			pgt++;
+		}
+
+		buf = dma->buflist[GLINT_DRI_BUF_COUNT];
+	} else {
+		DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
+
+		DRM_IOREMAP( dev_priv->buffers );
+
+		buf = dma->buflist[GLINT_DRI_BUF_COUNT];
+		pgt = buf->address;
+
+ 		for (i = 0; i < GLINT_DRI_BUF_COUNT; i++) {
+			buf = dma->buflist[i];
+			*pgt = (unsigned int)buf->address + 0x07;
+			pgt++;
+		}
+
+		buf = dma->buflist[GLINT_DRI_BUF_COUNT];
+
+		while (GAMMA_READ(GAMMA_INFIFOSPACE) < 1);
+		GAMMA_WRITE( GAMMA_GDMACONTROL, 0xe);
+	}
+	while (GAMMA_READ(GAMMA_INFIFOSPACE) < 2);
+	GAMMA_WRITE( GAMMA_PAGETABLEADDR, virt_to_phys((void*)buf->address) );
+	GAMMA_WRITE( GAMMA_PAGETABLELENGTH, 2 );
+
+	return 0;
+}
+
+int gamma_do_cleanup_dma( drm_device_t *dev )
+{
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	if ( dev->dev_private ) {
+		drm_gamma_private_t *dev_priv = dev->dev_private;
+
+		DRM_IOREMAPFREE( dev_priv->buffers );
+
+		DRM(free)( dev->dev_private, sizeof(drm_gamma_private_t),
+			   DRM_MEM_DRIVER );
+		dev->dev_private = NULL;
+	}
+
+	return 0;
+}
+
+int gamma_dma_init( struct inode *inode, struct file *filp,
+		  unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_gamma_init_t init;
+
+	if ( copy_from_user( &init, (drm_gamma_init_t *)arg, sizeof(init) ) )
+		return -EFAULT;
+
+	switch ( init.func ) {
+	case GAMMA_INIT_DMA:
+		return gamma_do_init_dma( dev, &init );
+	case GAMMA_CLEANUP_DMA:
+		return gamma_do_cleanup_dma( dev );
+	}
+
+	return -EINVAL;
+}
+
+static int gamma_do_copy_dma( drm_device_t *dev, drm_gamma_copy_t *copy )
+{
+	drm_device_dma_t    *dma = dev->dma;
+	unsigned int        *screenbuf;
+
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	/* We've DRM_RESTRICTED this DMA buffer */
+
+	screenbuf = dma->buflist[ GLINT_DRI_BUF_COUNT + 1 ]->address;
+
+#if 0
+	*buffer++ = 0x180;	/* Tag (FilterMode) */
+	*buffer++ = 0x200;	/* Allow FBColor through */
+	*buffer++ = 0x53B;	/* Tag */
+	*buffer++ = copy->Pitch;
+	*buffer++ = 0x53A;	/* Tag */
+	*buffer++ = copy->SrcAddress;
+	*buffer++ = 0x539;	/* Tag */
+	*buffer++ = copy->WidthHeight; /* Initiates transfer */
+	*buffer++ = 0x53C;	/* Tag - DMAOutputAddress */
+	*buffer++ = virt_to_phys((void*)screenbuf);
+	*buffer++ = 0x53D;	/* Tag - DMAOutputCount */
+	*buffer++ = copy->Count; /* Reads HostOutFifo BLOCKS until ..*/
+
+	/* Data now sitting in dma->buflist[ GLINT_DRI_BUF_COUNT + 1 ] */
+	/* Now put it back to the screen */
+
+	*buffer++ = 0x180;	/* Tag (FilterMode) */
+	*buffer++ = 0x400;	/* Allow Sync through */
+	*buffer++ = 0x538;	/* Tag - DMARectangleReadTarget */
+	*buffer++ = 0x155;	/* FBSourceData | count */
+	*buffer++ = 0x537;	/* Tag */
+	*buffer++ = copy->Pitch;
+	*buffer++ = 0x536;	/* Tag */
+	*buffer++ = copy->DstAddress;
+	*buffer++ = 0x535;	/* Tag */
+	*buffer++ = copy->WidthHeight; /* Initiates transfer */
+	*buffer++ = 0x530;	/* Tag - DMAAddr */
+	*buffer++ = virt_to_phys((void*)screenbuf);
+	*buffer++ = 0x531;
+	*buffer++ = copy->Count; /* initiates DMA transfer of color data */
+#endif
+
+	/* need to dispatch it now */
+
+	return 0;
+}
+
+int gamma_dma_copy( struct inode *inode, struct file *filp,
+		  unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_gamma_copy_t copy;
+
+	if ( copy_from_user( &copy, (drm_gamma_copy_t *)arg, sizeof(copy) ) )
+		return -EFAULT;
+
+	return gamma_do_copy_dma( dev, &copy );
+}
+
+/* =============================================================
+ * Per Context SAREA Support
+ */
+
+int gamma_getsareactx(struct inode *inode, struct file *filp,
+		     unsigned int cmd, unsigned long arg)
+{
+	drm_file_t	*priv	= filp->private_data;
+	drm_device_t	*dev	= priv->dev;
+	drm_ctx_priv_map_t request;
+	drm_map_t *map;
+
+	if (copy_from_user(&request,
+			   (drm_ctx_priv_map_t *)arg,
+			   sizeof(request)))
+		return -EFAULT;
+
+	down(&dev->struct_sem);
+	if ((int)request.ctx_id >= dev->max_context) {
+		up(&dev->struct_sem);
+		return -EINVAL;
+	}
+
+	map = dev->context_sareas[request.ctx_id];
+	up(&dev->struct_sem);
+
+	request.handle = map->handle;
+	if (copy_to_user((drm_ctx_priv_map_t *)arg, &request, sizeof(request)))
+		return -EFAULT;
+	return 0;
+}
+
+int gamma_setsareactx(struct inode *inode, struct file *filp,
+		     unsigned int cmd, unsigned long arg)
+{
+	drm_file_t	*priv	= filp->private_data;
+	drm_device_t	*dev	= priv->dev;
+	drm_ctx_priv_map_t request;
+	drm_map_t *map = NULL;
+	drm_map_list_t *r_list;
+	struct list_head *list;
+
+	if (copy_from_user(&request,
+			   (drm_ctx_priv_map_t *)arg,
+			   sizeof(request)))
+		return -EFAULT;
+
+	down(&dev->struct_sem);
+	r_list = NULL;
+	list_for_each(list, &dev->maplist->head) {
+		r_list = (drm_map_list_t *)list;
+		if(r_list->map &&
+		   r_list->map->handle == request.handle) break;
+	}
+	if (list == &(dev->maplist->head)) {
+		up(&dev->struct_sem);
+		return -EINVAL;
+	}
+	map = r_list->map;
+	up(&dev->struct_sem);
+
+	if (!map) return -EINVAL;
+
+	down(&dev->struct_sem);
+	if ((int)request.ctx_id >= dev->max_context) {
+		up(&dev->struct_sem);
+		return -EINVAL;
+	}
+	dev->context_sareas[request.ctx_id] = map;
+	up(&dev->struct_sem);
+	return 0;
 }
diff -Nru a/drivers/char/drm/gamma_drm.h b/drivers/char/drm/gamma_drm.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/gamma_drm.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,79 @@
+#ifndef _GAMMA_DRM_H_
+#define _GAMMA_DRM_H_
+
+typedef struct _drm_gamma_tex_region {
+	unsigned char next, prev; /* indices to form a circular LRU  */
+	unsigned char in_use;	/* owned by a client, or free? */
+	int age;		/* tracked by clients to update local LRU's */
+} drm_gamma_tex_region_t;
+
+typedef struct {
+	unsigned int	GDeltaMode;
+	unsigned int	GDepthMode;
+	unsigned int	GGeometryMode;
+	unsigned int	GTransformMode;
+} drm_gamma_context_regs_t;
+
+typedef struct _drm_gamma_sarea {
+   	drm_gamma_context_regs_t context_state;
+
+	unsigned int dirty;
+
+
+	/* Maintain an LRU of contiguous regions of texture space.  If
+	 * you think you own a region of texture memory, and it has an
+	 * age different to the one you set, then you are mistaken and
+	 * it has been stolen by another client.  If global texAge
+	 * hasn't changed, there is no need to walk the list.
+	 *
+	 * These regions can be used as a proxy for the fine-grained
+	 * texture information of other clients - by maintaining them
+	 * in the same lru which is used to age their own textures,
+	 * clients have an approximate lru for the whole of global
+	 * texture space, and can make informed decisions as to which
+	 * areas to kick out.  There is no need to choose whether to
+	 * kick out your own texture or someone else's - simply eject
+	 * them all in LRU order.  
+	 */
+   
+#define GAMMA_NR_TEX_REGIONS 64
+	drm_gamma_tex_region_t texList[GAMMA_NR_TEX_REGIONS+1]; 
+				/* Last elt is sentinal */
+        int texAge;		/* last time texture was uploaded */
+        int last_enqueue;	/* last time a buffer was enqueued */
+	int last_dispatch;	/* age of the most recently dispatched buffer */
+	int last_quiescent;     /*  */
+	int ctxOwner;		/* last context to upload state */
+
+	int vertex_prim;
+} drm_gamma_sarea_t;
+
+typedef struct drm_gamma_copy {
+	unsigned int	DMAOutputAddress;
+	unsigned int	DMAOutputCount;
+	unsigned int	DMAReadGLINTSource;
+	unsigned int	DMARectangleWriteAddress;
+	unsigned int	DMARectangleWriteLinePitch;
+	unsigned int	DMARectangleWrite;
+	unsigned int	DMARectangleReadAddress;
+	unsigned int	DMARectangleReadLinePitch;
+	unsigned int	DMARectangleRead;
+	unsigned int	DMARectangleReadTarget;
+} drm_gamma_copy_t;
+
+typedef struct drm_gamma_init {
+   	enum {
+	   	GAMMA_INIT_DMA    = 0x01,
+	       	GAMMA_CLEANUP_DMA = 0x02
+	} func;
+
+   	int sarea_priv_offset;
+	int pcimode;
+	unsigned int mmio0;
+	unsigned int mmio1;
+	unsigned int mmio2;
+	unsigned int mmio3;
+	unsigned int buffers_offset;
+} drm_gamma_init_t;
+
+#endif /* _GAMMA_DRM_H_ */
diff -Nru a/drivers/char/drm/gamma_drv.c b/drivers/char/drm/gamma_drv.c
--- a/drivers/char/drm/gamma_drv.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/gamma_drv.c	Fri May 24 18:55:36 2002
@@ -38,15 +38,19 @@
 
 #define DRIVER_NAME		"gamma"
 #define DRIVER_DESC		"3DLabs gamma"
-#define DRIVER_DATE		"20010216"
+#define DRIVER_DATE		"20010624"
 
-#define DRIVER_MAJOR		1
+#define DRIVER_MAJOR		2
 #define DRIVER_MINOR		0
 #define DRIVER_PATCHLEVEL	0
 
 #define DRIVER_IOCTLS							  \
-	[DRM_IOCTL_NR(DRM_IOCTL_DMA)]	     = { gamma_dma,	  1, 0 }
+	[DRM_IOCTL_NR(DRM_IOCTL_DMA)]	     = { gamma_dma,	  1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_GAMMA_INIT)] = { gamma_dma_init,  1, 1 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_GAMMA_COPY)] = { gamma_dma_copy,  1, 1 }
 
+#define IOCTL_TABLE_NAME	DRM(ioctls)
+#define IOCTL_FUNC_NAME 	DRM(ioctl)
 
 #define __HAVE_COUNTERS		5
 #define __HAVE_COUNTER6		_DRM_STAT_IRQ
@@ -57,6 +61,7 @@
 
 
 #include "drm_auth.h"
+#include "drm_agpsupport.h"
 #include "drm_bufs.h"
 #include "drm_context.h"
 #include "drm_dma.h"
@@ -81,7 +86,6 @@
 
 __setup( DRIVER_NAME "=", gamma_options );
 #endif
-
 
 #include "drm_fops.h"
 #include "drm_init.h"
diff -Nru a/drivers/char/drm/gamma_drv.h b/drivers/char/drm/gamma_drv.h
--- a/drivers/char/drm/gamma_drv.h	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/gamma_drv.h	Fri May 24 18:55:35 2002
@@ -32,8 +32,9 @@
 #ifndef _GAMMA_DRV_H_
 #define _GAMMA_DRV_H_
 
-
 typedef struct drm_gamma_private {
+	drm_gamma_sarea_t *sarea_priv;
+	drm_map_t *sarea;
 	drm_map_t *buffers;
 	drm_map_t *mmio0;
 	drm_map_t *mmio1;
@@ -51,6 +52,11 @@
 	}								\
 } while (0)
 
+				/* gamma_dma.c */
+extern int gamma_dma_init( struct inode *inode, struct file *filp,
+			 unsigned int cmd, unsigned long arg );
+extern int gamma_dma_copy( struct inode *inode, struct file *filp,
+			 unsigned int cmd, unsigned long arg );
 
 extern void gamma_dma_ready(drm_device_t *dev);
 extern void gamma_dma_quiescent_single(drm_device_t *dev);
@@ -63,6 +69,7 @@
 extern int  gamma_find_devices(void);
 extern int  gamma_found(void);
 
+#define GLINT_DRI_BUF_COUNT 256
 
 #define GAMMA_OFF(reg)						   \
 	((reg < 0x1000)						   \
@@ -78,7 +85,6 @@
 			   ((reg < 0x10000)  ? dev_priv->mmio1->handle :     \
 			    ((reg < 0x11000) ? dev_priv->mmio2->handle :     \
 					       dev_priv->mmio3->handle))))
-	
 #define GAMMA_ADDR(reg)	 (GAMMA_BASE(reg) + GAMMA_OFF(reg))
 #define GAMMA_DEREF(reg) *(__volatile__ int *)GAMMA_ADDR(reg)
 #define GAMMA_READ(reg)	 GAMMA_DEREF(reg)
@@ -91,9 +97,11 @@
 #define GAMMA_FILTERMODE       0x8c00
 #define GAMMA_GCOMMANDINTFLAGS 0x0c50
 #define GAMMA_GCOMMANDMODE     0x0c40
+#define		GAMMA_QUEUED_DMA_MODE		1<<1
 #define GAMMA_GCOMMANDSTATUS   0x0c60
 #define GAMMA_GDELAYTIMER      0x0c38
 #define GAMMA_GDMACONTROL      0x0060
+#define 	GAMMA_USE_AGP			1<<1
 #define GAMMA_GINTENABLE       0x0808
 #define GAMMA_GINTFLAGS	       0x0810
 #define GAMMA_INFIFOSPACE      0x0018
@@ -101,5 +109,12 @@
 #define GAMMA_OUTPUTFIFO       0x2000
 #define GAMMA_SYNC	       0x8c40
 #define GAMMA_SYNC_TAG	       0x0188
+#define GAMMA_PAGETABLEADDR    0x0C00
+#define GAMMA_PAGETABLELENGTH  0x0C08
+
+#define GAMMA_PASSTHROUGH	0x1FE
+#define GAMMA_DMAADDRTAG	0x530
+#define GAMMA_DMACOUNTTAG	0x531
+#define GAMMA_COMMANDINTTAG	0x532
 
 #endif
diff -Nru a/drivers/char/drm/i810.h b/drivers/char/drm/i810.h
--- a/drivers/char/drm/i810.h	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/i810.h	Fri May 24 18:55:35 2002
@@ -60,50 +60,10 @@
 	i810_dma_quiescent( dev );					\
 } while (0)
 
-#define __HAVE_DMA_IRQ		1
-#define __HAVE_DMA_IRQ_BH	1
-#define __HAVE_SHARED_IRQ       1
-#define DRIVER_PREINSTALL() do {					\
-	drm_i810_private_t *dev_priv =					\
-		(drm_i810_private_t *)dev->dev_private;			\
-	u16 tmp;							\
-   	tmp = I810_READ16( I810REG_HWSTAM );				\
-   	tmp = tmp & 0x6000;						\
-   	I810_WRITE16( I810REG_HWSTAM, tmp );				\
-									\
-      	tmp = I810_READ16( I810REG_INT_MASK_R );			\
-   	tmp = tmp & 0x6000;		/* Unmask interrupts */		\
-   	I810_WRITE16( I810REG_INT_MASK_R, tmp );			\
-   	tmp = I810_READ16( I810REG_INT_ENABLE_R );			\
-   	tmp = tmp & 0x6000;		/* Disable all interrupts */	\
-      	I810_WRITE16( I810REG_INT_ENABLE_R, tmp );			\
-} while (0)
-
-#define DRIVER_POSTINSTALL() do {					\
-	drm_i810_private_t *dev_priv =					\
-		(drm_i810_private_t *)dev->dev_private;			\
-	u16 tmp;							\
-   	tmp = I810_READ16( I810REG_INT_ENABLE_R );			\
-   	tmp = tmp & 0x6000;						\
-   	tmp = tmp | 0x0003;	/* Enable bp & user interrupts */	\
-   	I810_WRITE16( I810REG_INT_ENABLE_R, tmp );			\
-} while (0)
-
-#define DRIVER_UNINSTALL() do {						\
-	drm_i810_private_t *dev_priv =					\
-		(drm_i810_private_t *)dev->dev_private;			\
-	u16 tmp;							\
-	if ( dev_priv ) {						\
-		tmp = I810_READ16( I810REG_INT_IDENTITY_R );		\
-		tmp = tmp & ~(0x6000);	/* Clear all interrupts */	\
-		if ( tmp != 0 )						\
-			I810_WRITE16( I810REG_INT_IDENTITY_R, tmp );	\
-									\
-		tmp = I810_READ16( I810REG_INT_ENABLE_R );		\
-		tmp = tmp & 0x6000;	/* Disable all interrupts */	\
-		I810_WRITE16( I810REG_INT_ENABLE_R, tmp );		\
-	}								\
-} while (0)
+/* Don't need an irq any more.  The template code will make sure that
+ * a noop stub is generated for compatibility.
+ */
+#define __HAVE_DMA_IRQ		0
 
 /* Buffer customization:
  */
diff -Nru a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
--- a/drivers/char/drm/i810_dma.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/i810_dma.c	Fri May 24 18:55:35 2002
@@ -26,7 +26,7 @@
  *
  * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
  *	    Jeff Hartmann <jhartmann@valinux.com>
- *          Keith Whitwell <keithw@valinux.com>
+ *          Keith Whitwell <keith_whitwell@yahoo.com>
  *
  */
 
@@ -35,11 +35,8 @@
 #include "drmP.h"
 #include "i810_drv.h"
 #include <linux/interrupt.h>	/* For task queue support */
-
-/* in case we don't have a 2.3.99-pre6 kernel or later: */
-#ifndef VM_DONTCOPY
-#define VM_DONTCOPY 0
-#endif
+#include <linux/delay.h>
+#include <linux/pagemap.h>
 
 #define I810_BUF_FREE		2
 #define I810_BUF_CLIENT		1
@@ -50,29 +47,27 @@
 
 #define RING_LOCALS	unsigned int outring, ringmask; volatile char *virt;
 
-#define BEGIN_LP_RING(n) do {				\
-	if (I810_VERBOSE)				\
-		DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n",	\
-			  n, __FUNCTION__);		\
-	if (dev_priv->ring.space < n*4) 		\
-		i810_wait_ring(dev, n*4);		\
-	dev_priv->ring.space -= n*4;			\
-	outring = dev_priv->ring.tail;			\
-	ringmask = dev_priv->ring.tail_mask;		\
-	virt = dev_priv->ring.virtual_start;		\
+#define BEGIN_LP_RING(n) do {						\
+	if (0) DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", n, __FUNCTION__);	\
+	if (dev_priv->ring.space < n*4)					\
+		i810_wait_ring(dev, n*4);				\
+	dev_priv->ring.space -= n*4;					\
+	outring = dev_priv->ring.tail;					\
+	ringmask = dev_priv->ring.tail_mask;				\
+	virt = dev_priv->ring.virtual_start;				\
 } while (0)
 
-#define ADVANCE_LP_RING() do {					\
-	if (I810_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n");	\
-	dev_priv->ring.tail = outring;				\
-	I810_WRITE(LP_RING + RING_TAIL, outring);		\
+#define ADVANCE_LP_RING() do {				\
+	if (0) DRM_DEBUG("ADVANCE_LP_RING\n");			\
+	dev_priv->ring.tail = outring;			\
+	I810_WRITE(LP_RING + RING_TAIL, outring);	\
 } while(0)
 
-#define OUT_RING(n) do {						\
-	if (I810_VERBOSE) DRM_DEBUG("   OUT_RING %x\n", (int)(n));	\
-	*(volatile unsigned int *)(virt + outring) = n;			\
-	outring += 4;							\
-	outring &= ringmask;						\
+#define OUT_RING(n) do {				\
+	if (0) DRM_DEBUG("   OUT_RING %x\n", (int)(n));	\
+	*(volatile unsigned int *)(virt + outring) = n;	\
+	outring += 4;					\
+	outring &= ringmask;				\
 } while (0)
 
 static inline void i810_print_status_page(drm_device_t *dev)
@@ -86,6 +81,7 @@
    	DRM_DEBUG(  "hw_status: LpRing Head ptr : %x\n", temp[1]);
    	DRM_DEBUG(  "hw_status: IRing Head ptr : %x\n", temp[2]);
       	DRM_DEBUG(  "hw_status: Reserved : %x\n", temp[3]);
+	DRM_DEBUG(  "hw_status: Last Render: %x\n", temp[4]);
    	DRM_DEBUG(  "hw_status: Driver Counter : %d\n", temp[5]);
    	for(i = 6; i < dma->buf_count + 6; i++) {
 	   	DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 6, temp[i]);
@@ -163,7 +159,7 @@
    	buf_priv->currently_mapped = I810_BUF_MAPPED;
 	unlock_kernel();
 
-	if (remap_page_range(vma, vma->vm_start,
+	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
 			     VM_OFFSET(vma),
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot)) return -EAGAIN;
@@ -181,36 +177,31 @@
 
 	if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL;
 
-	if(VM_DONTCOPY != 0) {
 #if LINUX_VERSION_CODE <= 0x020402
-		down( &current->mm->mmap_sem );
+	down( &current->mm->mmap_sem );
 #else
-		down_write( &current->mm->mmap_sem );
+	down_write( &current->mm->mmap_sem );
 #endif
-		old_fops = filp->f_op;
-		filp->f_op = &i810_buffer_fops;
-		dev_priv->mmap_buffer = buf;
-		buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
-						    PROT_READ|PROT_WRITE,
-						    MAP_SHARED,
-						    buf->bus_address);
-		dev_priv->mmap_buffer = NULL;
-   		filp->f_op = old_fops;
-		if ((unsigned long)buf_priv->virtual > -1024UL) {
-			/* Real error */
-			DRM_DEBUG("mmap error\n");
-			retcode = (signed int)buf_priv->virtual;
-			buf_priv->virtual = 0;
-		}
+	old_fops = filp->f_op;
+	filp->f_op = &i810_buffer_fops;
+	dev_priv->mmap_buffer = buf;
+	buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
+					    PROT_READ|PROT_WRITE,
+					    MAP_SHARED,
+					    buf->bus_address);
+	dev_priv->mmap_buffer = NULL;
+	filp->f_op = old_fops;
+	if ((unsigned long)buf_priv->virtual > -1024UL) {
+		/* Real error */
+		DRM_DEBUG("mmap error\n");
+		retcode = (signed int)buf_priv->virtual;
+		buf_priv->virtual = 0;
+	}
 #if LINUX_VERSION_CODE <= 0x020402
-		up( &current->mm->mmap_sem );
+	up( &current->mm->mmap_sem );
 #else
-		up_write( &current->mm->mmap_sem );
+	up_write( &current->mm->mmap_sem );
 #endif
-	} else {
-		buf_priv->virtual = buf_priv->kernel_virtual;
-   		buf_priv->currently_mapped = I810_BUF_MAPPED;
-	}
 	return retcode;
 }
 
@@ -219,28 +210,21 @@
 	drm_i810_buf_priv_t *buf_priv = buf->dev_private;
 	int retcode = 0;
 
-	if(VM_DONTCOPY != 0) {
-		if(buf_priv->currently_mapped != I810_BUF_MAPPED)
-			return -EINVAL;
+	if(buf_priv->currently_mapped != I810_BUF_MAPPED)
+		return -EINVAL;
 #if LINUX_VERSION_CODE <= 0x020402
-		down( &current->mm->mmap_sem );
+	down( &current->mm->mmap_sem );
 #else
-		down_write( &current->mm->mmap_sem );
-#endif
-#if LINUX_VERSION_CODE < 0x020399
-        	retcode = do_munmap((unsigned long)buf_priv->virtual,
-				    (size_t) buf->total);
-#else
-        	retcode = do_munmap(current->mm,
-				    (unsigned long)buf_priv->virtual,
-				    (size_t) buf->total);
+	down_write( &current->mm->mmap_sem );
 #endif
+	retcode = do_munmap(current->mm,
+			    (unsigned long)buf_priv->virtual,
+			    (size_t) buf->total);
 #if LINUX_VERSION_CODE <= 0x020402
-		up( &current->mm->mmap_sem );
+	up( &current->mm->mmap_sem );
 #else
-		up_write( &current->mm->mmap_sem );
+	up_write( &current->mm->mmap_sem );
 #endif
-	}
    	buf_priv->currently_mapped = I810_BUF_UNMAPPED;
    	buf_priv->virtual = 0;
 
@@ -286,18 +270,28 @@
 	if(address == 0UL)
 		return 0;
 
+#if LINUX_VERSION_CODE < 0x020500
+	atomic_inc(&virt_to_page(address)->count);
+	set_bit(PG_locked, &virt_to_page(address)->flags);
+#else
 	get_page(virt_to_page(address));
 	SetPageLocked(virt_to_page(address));
-
+#endif
 	return address;
 }
 
 static void i810_free_page(drm_device_t *dev, unsigned long page)
 {
 	if (page) {
+#if LINUX_VERSION_CODE < 0x020500
+		atomic_dec(&virt_to_page(page)->count);
+		clear_bit(PG_locked, &virt_to_page(page)->flags);
+		wake_up(&virt_to_page(page)->wait);
+#else
 		struct page *p = virt_to_page(page);
 		put_page(p);
 		unlock_page(p);
+#endif
 		free_page(page);
 	}
 }
@@ -358,8 +352,7 @@
 		   	DRM_ERROR("lockup\n");
 		   	goto out_wait_ring;
 		}
-
-	   	for (i = 0 ; i < 2000 ; i++) ;
+		udelay(1);
 	}
 
 out_wait_ring:
@@ -447,9 +440,6 @@
 		((u8 *)dev_priv->sarea_map->handle +
 		 init->sarea_priv_offset);
 
-   	atomic_set(&dev_priv->flush_done, 0);
-	init_waitqueue_head(&dev_priv->flush_queue);
-
    	dev_priv->ring.Start = init->ring_start;
    	dev_priv->ring.End = init->ring_end;
    	dev_priv->ring.Size = init->ring_size;
@@ -474,6 +464,9 @@
 	dev_priv->back_offset = init->back_offset;
 	dev_priv->depth_offset = init->depth_offset;
 
+	dev_priv->overlay_offset = init->overlay_offset;
+	dev_priv->overlay_physical = init->overlay_physical;
+
 	dev_priv->front_di1 = init->front_offset | init->pitch_bits;
 	dev_priv->back_di1 = init->back_offset | init->pitch_bits;
 	dev_priv->zi1 = init->depth_offset | init->pitch_bits;
@@ -539,16 +532,12 @@
 
 /* Most efficient way to verify state for the i810 is as it is
  * emitted.  Non-conformant state is silently dropped.
- *
- * Use 'volatile' & local var tmp to force the emitted values to be
- * identical to the verified ones.
  */
 static void i810EmitContextVerified( drm_device_t *dev,
-				     volatile unsigned int *code )
+				     unsigned int *code )
 {
    	drm_i810_private_t *dev_priv = dev->dev_private;
 	int i, j = 0;
-	unsigned int tmp;
 	RING_LOCALS;
 
 	BEGIN_LP_RING( I810_CTX_SETUP_SIZE );
@@ -560,14 +549,13 @@
 	OUT_RING( code[I810_CTXREG_ST1] );
 
 	for ( i = 4 ; i < I810_CTX_SETUP_SIZE ; i++ ) {
-		tmp = code[i];
-
-		if ((tmp & (7<<29)) == (3<<29) &&
-		    (tmp & (0x1f<<24)) < (0x1d<<24))
+		if ((code[i] & (7<<29)) == (3<<29) &&
+		    (code[i] & (0x1f<<24)) < (0x1d<<24))
 		{
-			OUT_RING( tmp );
+			OUT_RING( code[i] );
 			j++;
 		}
+		else printk("constext state dropped!!!\n");
 	}
 
 	if (j & 1)
@@ -581,7 +569,6 @@
 {
    	drm_i810_private_t *dev_priv = dev->dev_private;
 	int i, j = 0;
-	unsigned int tmp;
 	RING_LOCALS;
 
 	BEGIN_LP_RING( I810_TEX_SETUP_SIZE );
@@ -592,14 +579,14 @@
 	OUT_RING( code[I810_TEXREG_MI3] );
 
 	for ( i = 4 ; i < I810_TEX_SETUP_SIZE ; i++ ) {
-		tmp = code[i];
 
-		if ((tmp & (7<<29)) == (3<<29) &&
-		    (tmp & (0x1f<<24)) < (0x1d<<24))
+		if ((code[i] & (7<<29)) == (3<<29) &&
+		    (code[i] & (0x1f<<24)) < (0x1d<<24))
 		{
-			OUT_RING( tmp );
+			OUT_RING( code[i] );
 			j++;
 		}
+		else printk("texture state dropped!!!\n");
 	}
 
 	if (j & 1)
@@ -624,9 +611,9 @@
 	if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) {
 		OUT_RING( CMD_OP_DESTBUFFER_INFO );
 		OUT_RING( tmp );
-	} else
-	   DRM_DEBUG("bad di1 %x (allow %x or %x)\n",
-		     tmp, dev_priv->front_di1, dev_priv->back_di1);
+	} 
+	else
+	   printk("buffer state dropped\n");
 
 	/* invarient:
 	 */
@@ -711,7 +698,6 @@
 			continue;
 
 	   	if ( flags & I810_FRONT ) {
-		   	DRM_DEBUG("clear front\n");
 			BEGIN_LP_RING( 6 );
 			OUT_RING( BR00_BITBLT_CLIENT |
 				  BR00_OP_COLOR_BLT | 0x3 );
@@ -724,7 +710,6 @@
 		}
 
 		if ( flags & I810_BACK ) {
-			DRM_DEBUG("clear back\n");
 			BEGIN_LP_RING( 6 );
 			OUT_RING( BR00_BITBLT_CLIENT |
 				  BR00_OP_COLOR_BLT | 0x3 );
@@ -737,7 +722,6 @@
 		}
 
 		if ( flags & I810_DEPTH ) {
-			DRM_DEBUG("clear depth\n");
 			BEGIN_LP_RING( 6 );
 			OUT_RING( BR00_BITBLT_CLIENT |
 				  BR00_OP_COLOR_BLT | 0x3 );
@@ -763,8 +747,6 @@
 	int i;
 	RING_LOCALS;
 
-	DRM_DEBUG("swapbuffers\n");
-
   	i810_kernel_lost_context(dev);
 
       	if (nbox > I810_NR_SAREA_CLIPRECTS)
@@ -783,10 +765,6 @@
 		    pbox->y2 > dev_priv->h)
 			continue;
 
-	   	DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
-			  pbox[i].x1, pbox[i].y1,
-			  pbox[i].x2, pbox[i].y2);
-
 		BEGIN_LP_RING( 6 );
 		OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4 );
 		OUT_RING( pitch | (0xCC << 16));
@@ -811,7 +789,7 @@
    	int nbox = sarea_priv->nbox;
 	unsigned long address = (unsigned long)buf->bus_address;
 	unsigned long start = address - dev->agp->base;
-	int i = 0, u;
+	int i = 0;
    	RING_LOCALS;
 
    	i810_kernel_lost_context(dev);
@@ -819,33 +797,16 @@
    	if (nbox > I810_NR_SAREA_CLIPRECTS)
 		nbox = I810_NR_SAREA_CLIPRECTS;
 
-	if (discard) {
-		u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
-			    I810_BUF_HARDWARE);
-		if(u != I810_BUF_CLIENT) {
-			DRM_DEBUG("xxxx 2\n");
-		}
-	}
-
 	if (used > 4*1024)
 		used = 0;
 
 	if (sarea_priv->dirty)
 	   i810EmitState( dev );
 
-  	DRM_DEBUG("dispatch vertex addr 0x%lx, used 0x%x nbox %d\n",
-		  address, used, nbox);
-
-   	dev_priv->counter++;
-   	DRM_DEBUG(  "dispatch counter : %ld\n", dev_priv->counter);
-   	DRM_DEBUG(  "i810_dma_dispatch\n");
-   	DRM_DEBUG(  "start : %lx\n", start);
-	DRM_DEBUG(  "used : %d\n", used);
-   	DRM_DEBUG(  "start + used - 4 : %ld\n", start + used - 4);
-
 	if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
-		*(u32 *)buf_priv->virtual = (GFX_OP_PRIMITIVE |
-					     sarea_priv->vertex_prim |
+		unsigned int prim = (sarea_priv->vertex_prim & PR_MASK);
+
+		*(u32 *)buf_priv->virtual = (GFX_OP_PRIMITIVE | prim | 
 					     ((used/4)-2));
 
 		if (used & 4) {
@@ -878,154 +839,62 @@
 		} while (++i < nbox);
 	}
 
-	BEGIN_LP_RING(10);
-	OUT_RING( CMD_STORE_DWORD_IDX );
-	OUT_RING( 20 );
-	OUT_RING( dev_priv->counter );
-	OUT_RING( 0 );
-
 	if (discard) {
+		dev_priv->counter++;
+
+		(void) cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
+			       I810_BUF_HARDWARE);
+
+		BEGIN_LP_RING(8);
+		OUT_RING( CMD_STORE_DWORD_IDX );
+		OUT_RING( 20 );
+		OUT_RING( dev_priv->counter );
 		OUT_RING( CMD_STORE_DWORD_IDX );
 		OUT_RING( buf_priv->my_use_idx );
 		OUT_RING( I810_BUF_FREE );
+		OUT_RING( CMD_REPORT_HEAD );
 		OUT_RING( 0 );
+		ADVANCE_LP_RING();
 	}
-
-      	OUT_RING( CMD_REPORT_HEAD );
-	OUT_RING( 0 );
-   	ADVANCE_LP_RING();
 }
 
 
-/* Interrupts are only for flushing */
-void i810_dma_service(int irq, void *device, struct pt_regs *regs)
-{
-	drm_device_t	 *dev = (drm_device_t *)device;
-      	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-   	u16 temp;
-
-	atomic_inc(&dev->counts[_DRM_STAT_IRQ]);
-      	temp = I810_READ16(I810REG_INT_IDENTITY_R);
-   	temp = temp & ~(0x6000);
-   	if(temp != 0) I810_WRITE16(I810REG_INT_IDENTITY_R,
-				   temp); /* Clear all interrupts */
-	else
-	   return;
-
-   	queue_task(&dev->tq, &tq_immediate);
-   	mark_bh(IMMEDIATE_BH);
-}
-
-void i810_dma_immediate_bh(void *device)
-{
-	drm_device_t *dev = (drm_device_t *) device;
-      	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-
-   	atomic_set(&dev_priv->flush_done, 1);
-   	wake_up_interruptible(&dev_priv->flush_queue);
-}
-
-static inline void i810_dma_emit_flush(drm_device_t *dev)
-{
-   	drm_i810_private_t *dev_priv = dev->dev_private;
-   	RING_LOCALS;
-
-   	i810_kernel_lost_context(dev);
-
-   	BEGIN_LP_RING(2);
-      	OUT_RING( CMD_REPORT_HEAD );
-      	OUT_RING( GFX_OP_USER_INTERRUPT );
-      	ADVANCE_LP_RING();
-
-/*  	i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */
-/*     	atomic_set(&dev_priv->flush_done, 1); */
-/*     	wake_up_interruptible(&dev_priv->flush_queue); */
-}
-
-static inline void i810_dma_quiescent_emit(drm_device_t *dev)
+void i810_dma_quiescent(drm_device_t *dev)
 {
       	drm_i810_private_t *dev_priv = dev->dev_private;
    	RING_LOCALS;
 
+/*  	printk("%s\n", __FUNCTION__); */
+
   	i810_kernel_lost_context(dev);
 
    	BEGIN_LP_RING(4);
    	OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
    	OUT_RING( CMD_REPORT_HEAD );
       	OUT_RING( 0 );
-      	OUT_RING( GFX_OP_USER_INTERRUPT );
+      	OUT_RING( 0 );
    	ADVANCE_LP_RING();
 
-/*  	i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */
-/*     	atomic_set(&dev_priv->flush_done, 1); */
-/*     	wake_up_interruptible(&dev_priv->flush_queue); */
-}
-
-void i810_dma_quiescent(drm_device_t *dev)
-{
-      	DECLARE_WAITQUEUE(entry, current);
-  	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-	unsigned long end;
-
-   	if(dev_priv == NULL) {
-	   	return;
-	}
-      	atomic_set(&dev_priv->flush_done, 0);
-   	add_wait_queue(&dev_priv->flush_queue, &entry);
-   	end = jiffies + (HZ*3);
-
-   	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
-	      	i810_dma_quiescent_emit(dev);
-	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
-		if((signed)(end - jiffies) <= 0) {
-		   	DRM_ERROR("lockup\n");
-		   	break;
-		}
-	      	schedule_timeout(HZ*3);
-	      	if (signal_pending(current)) {
-		   	break;
-		}
-	}
-
-   	current->state = TASK_RUNNING;
-   	remove_wait_queue(&dev_priv->flush_queue, &entry);
-
-   	return;
+	i810_wait_ring( dev, dev_priv->ring.Size - 8 );
 }
 
 static int i810_flush_queue(drm_device_t *dev)
 {
-   	DECLARE_WAITQUEUE(entry, current);
-  	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+   	drm_i810_private_t *dev_priv = dev->dev_private;
 	drm_device_dma_t *dma = dev->dma;
-	unsigned long end;
    	int i, ret = 0;
+   	RING_LOCALS;
+	
+/*  	printk("%s\n", __FUNCTION__); */
 
-   	if(dev_priv == NULL) {
-	   	return 0;
-	}
-      	atomic_set(&dev_priv->flush_done, 0);
-   	add_wait_queue(&dev_priv->flush_queue, &entry);
-   	end = jiffies + (HZ*3);
-   	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
-	      	i810_dma_emit_flush(dev);
-	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
-		if((signed)(end - jiffies) <= 0) {
-		   	DRM_ERROR("lockup\n");
-		   	break;
-		}
-	      	schedule_timeout(HZ*3);
-	      	if (signal_pending(current)) {
-		   	ret = -EINTR; /* Can't restart */
-		   	break;
-		}
-	}
+   	i810_kernel_lost_context(dev);
 
-   	current->state = TASK_RUNNING;
-   	remove_wait_queue(&dev_priv->flush_queue, &entry);
+   	BEGIN_LP_RING(2);
+      	OUT_RING( CMD_REPORT_HEAD );
+      	OUT_RING( 0 );
+      	ADVANCE_LP_RING();
 
+	i810_wait_ring( dev, dev_priv->ring.Size - 8 );
 
    	for (i = 0; i < dma->buf_count; i++) {
 	   	drm_buf_t *buf = dma->buflist[ i ];
@@ -1037,7 +906,7 @@
 		if (used == I810_BUF_HARDWARE)
 			DRM_DEBUG("reclaimed from HARDWARE\n");
 		if (used == I810_BUF_CLIENT)
-			DRM_DEBUG("still on client HARDWARE\n");
+			DRM_DEBUG("still on client\n");
 	}
 
    	return ret;
@@ -1077,7 +946,6 @@
    	drm_file_t	  *priv	  = filp->private_data;
    	drm_device_t	  *dev	  = priv->dev;
 
-   	DRM_DEBUG("i810_flush_ioctl\n");
    	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
 		DRM_ERROR("i810_flush_ioctl called without lock held\n");
 		return -EINVAL;
@@ -1108,9 +976,6 @@
 		return -EINVAL;
 	}
 
-	DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
-		  vertex.idx, vertex.used, vertex.discard);
-
 	if(vertex.idx < 0 || vertex.idx > dma->buf_count) return -EINVAL;
 
 	i810_dma_dispatch_vertex( dev,
@@ -1159,8 +1024,6 @@
 	drm_file_t *priv = filp->private_data;
 	drm_device_t *dev = priv->dev;
 
-	DRM_DEBUG("i810_swap_bufs\n");
-
    	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
 		DRM_ERROR("i810_swap_buf called without lock held\n");
 		return -EINVAL;
@@ -1196,7 +1059,6 @@
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 
-	DRM_DEBUG("getbuf\n");
    	if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d)))
 		return -EFAULT;
 
@@ -1209,9 +1071,6 @@
 
 	retcode = i810_dma_get_buffer(dev, &d, filp);
 
-	DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
-		  current->pid, retcode, d.granted);
-
 	if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d)))
 		return -EFAULT;
    	sarea_priv->last_dispatch = (int) hw_status[5];
@@ -1219,46 +1078,171 @@
 	return retcode;
 }
 
-int i810_copybuf(struct inode *inode, struct file *filp, unsigned int cmd,
+int i810_copybuf(struct inode *inode,
+		 struct file *filp, 
+		 unsigned int cmd,
+		 unsigned long arg)
+{
+	/* Never copy - 2.4.x doesn't need it */
+	return 0;
+}
+
+int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd,
 		unsigned long arg)
 {
-	drm_file_t	  *priv	    = filp->private_data;
-	drm_device_t	  *dev	    = priv->dev;
-	drm_i810_copy_t	  d;
-   	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
-   	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
-     					dev_priv->sarea_priv;
-	drm_buf_t *buf;
-	drm_i810_buf_priv_t *buf_priv;
+	/* Never copy - 2.4.x doesn't need it */
+	return 0;
+}
+
+static void i810_dma_dispatch_mc(drm_device_t *dev, drm_buf_t *buf, int used,
+		unsigned int last_render)
+{
+	drm_i810_private_t *dev_priv = dev->dev_private;
+	drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+	drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	unsigned long address = (unsigned long)buf->bus_address;
+	unsigned long start = address - dev->agp->base;
+	int u;
+	RING_LOCALS;
+
+	i810_kernel_lost_context(dev);
+
+	u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
+		I810_BUF_HARDWARE);
+	if(u != I810_BUF_CLIENT) {
+		DRM_DEBUG("MC found buffer that isn't mine!\n");
+	}
+
+	if (used > 4*1024)
+		used = 0;
+
+	sarea_priv->dirty = 0x7f;
+
+	DRM_DEBUG("dispatch mc addr 0x%lx, used 0x%x\n",
+		address, used);
+
+	dev_priv->counter++;
+	DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter);
+	DRM_DEBUG("i810_dma_dispatch_mc\n");
+	DRM_DEBUG("start : %lx\n", start);
+	DRM_DEBUG("used : %d\n", used);
+	DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4);
+
+	if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
+		if (used & 4) {
+			*(u32 *)((u32)buf_priv->virtual + used) = 0;
+			used += 4;
+		}
+
+		i810_unmap_buffer(buf);
+	}
+	BEGIN_LP_RING(4);
+	OUT_RING( CMD_OP_BATCH_BUFFER );
+	OUT_RING( start | BB1_PROTECTED );
+	OUT_RING( start + used - 4 );
+	OUT_RING( 0 );
+	ADVANCE_LP_RING();
+
+
+	BEGIN_LP_RING(8);
+	OUT_RING( CMD_STORE_DWORD_IDX );
+	OUT_RING( buf_priv->my_use_idx );
+	OUT_RING( I810_BUF_FREE );
+	OUT_RING( 0 );
+
+	OUT_RING( CMD_STORE_DWORD_IDX );
+	OUT_RING( 16 );
+	OUT_RING( last_render );
+	OUT_RING( 0 );
+	ADVANCE_LP_RING();
+}
+
+int i810_dma_mc(struct inode *inode, struct file *filp,
+	unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
 	drm_device_dma_t *dma = dev->dma;
+	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
+		dev_priv->sarea_priv;
+	drm_i810_mc_t mc;
+
+	if (copy_from_user(&mc, (drm_i810_mc_t *)arg, sizeof(mc)))
+		return -EFAULT;
+
 
 	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
-		DRM_ERROR("i810_dma called without lock held\n");
+		DRM_ERROR("i810_dma_mc called without lock held\n");
 		return -EINVAL;
 	}
 
-   	if (copy_from_user(&d, (drm_i810_copy_t *)arg, sizeof(d)))
-		return -EFAULT;
+	i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used,
+		mc.last_render );
 
-        if(d.idx < 0 || d.idx > dma->buf_count) return -EINVAL;
-	buf = dma->buflist[ d.idx ];
-   	buf_priv = buf->dev_private;
-	if (buf_priv->currently_mapped != I810_BUF_MAPPED) return -EPERM;
+	atomic_add(mc.used, &dev->counts[_DRM_STAT_SECONDARY]);
+	atomic_inc(&dev->counts[_DRM_STAT_DMA]);
+	sarea_priv->last_enqueue = dev_priv->counter-1;
+	sarea_priv->last_dispatch = (int) hw_status[5];
 
-	if(d.used < 0 || d.used > buf->total) return -EINVAL;
+	return 0;
+}
 
-   	if (copy_from_user(buf_priv->virtual, d.address, d.used))
-		return -EFAULT;
+int i810_rstatus(struct inode *inode, struct file *filp,
+		unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
 
-   	sarea_priv->last_dispatch = (int) hw_status[5];
+	return (int)(((u32 *)(dev_priv->hw_status_page))[4]);
+}
+
+int i810_ov0_info(struct inode *inode, struct file *filp,
+		unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+	drm_i810_overlay_t data;
 
+	data.offset = dev_priv->overlay_offset;
+	data.physical = dev_priv->overlay_physical;
+	copy_to_user((drm_i810_overlay_t *)arg,&data,sizeof(data));
 	return 0;
 }
 
-int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd,
-		unsigned long arg)
+int i810_fstatus(struct inode *inode, struct file *filp,
+		unsigned int cmd, unsigned long arg)
 {
-	if(VM_DONTCOPY == 0) return 1;
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+
+	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i810_fstatus called without lock held\n");
+		return -EINVAL;
+	}
+	return I810_READ(0x30008);
+}
+
+int i810_ov0_flip(struct inode *inode, struct file *filp,
+		unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+
+	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i810_ov0_flip called without lock held\n");
+		return -EINVAL;
+	}
+
+	//Tell the overlay to update
+	I810_WRITE(0x30000,dev_priv->overlay_physical | 0x80000000);
+
 	return 0;
 }
+
+
diff -Nru a/drivers/char/drm/i810_drm.h b/drivers/char/drm/i810_drm.h
--- a/drivers/char/drm/i810_drm.h	Fri May 24 18:55:33 2002
+++ b/drivers/char/drm/i810_drm.h	Fri May 24 18:55:33 2002
@@ -88,6 +88,8 @@
 #define I810_TEXREG_MCS  7	/* GFX_OP_MAP_COORD_SETS ??? */
 #define I810_TEX_SETUP_SIZE 8
 
+/* Flags for clear ioctl
+ */
 #define I810_FRONT   0x1
 #define I810_BACK    0x2
 #define I810_DEPTH   0x4
@@ -112,6 +114,8 @@
 	unsigned int front_offset;
 	unsigned int back_offset;
 	unsigned int depth_offset;
+	unsigned int overlay_offset;
+	unsigned int overlay_physical;
 	unsigned int w;
 	unsigned int h;
 	unsigned int pitch;
@@ -189,11 +193,36 @@
 	void *address;		/* Address to copy from */
 } drm_i810_copy_t;
 
+#define PR_TRIANGLES         (0x0<<18)
+#define PR_TRISTRIP_0        (0x1<<18)
+#define PR_TRISTRIP_1        (0x2<<18)
+#define PR_TRIFAN            (0x3<<18)
+#define PR_POLYGON           (0x4<<18)
+#define PR_LINES             (0x5<<18)
+#define PR_LINESTRIP         (0x6<<18)
+#define PR_RECTS             (0x7<<18)
+#define PR_MASK              (0x7<<18)
+
+
 typedef struct drm_i810_dma {
 	void *virtual;
 	int request_idx;
 	int request_size;
 	int granted;
 } drm_i810_dma_t;
+
+typedef struct _drm_i810_overlay_t {
+	unsigned int offset;    /* Address of the Overlay Regs */
+	unsigned int physical;
+} drm_i810_overlay_t;
+
+typedef struct _drm_i810_mc {
+	int idx;                /* buffer index */
+	int used;               /* nr bytes in use */
+	int num_blocks;         /* number of GFXBlocks */
+	int *length;            /* List of lengths for GFXBlocks (FUTURE)*/
+	unsigned int last_render; /* Last Render Request */
+} drm_i810_mc_t;
+
 
 #endif /* _I810_DRM_H_ */
diff -Nru a/drivers/char/drm/i810_drv.c b/drivers/char/drm/i810_drv.c
--- a/drivers/char/drm/i810_drv.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/i810_drv.c	Fri May 24 18:55:36 2002
@@ -39,11 +39,19 @@
 
 #define DRIVER_NAME		"i810"
 #define DRIVER_DESC		"Intel i810"
-#define DRIVER_DATE		"20010616"
+#define DRIVER_DATE		"20020211"
 
+/* Interface history
+ *
+ * 1.1   - XFree86 4.1
+ * 1.2   - XvMC interfaces
+ *       - XFree86 4.2
+ * 1.2.1 - Disable copying code (leave stub ioctls for backwards compatibility)
+ *       - Remove requirement for interrupt (leave stubs again)
+ */
 #define DRIVER_MAJOR		1
-#define DRIVER_MINOR		1
-#define DRIVER_PATCHLEVEL	0
+#define DRIVER_MINOR		2
+#define DRIVER_PATCHLEVEL	1
 
 #define DRIVER_IOCTLS							    \
 	[DRM_IOCTL_NR(DRM_IOCTL_I810_INIT)]   = { i810_dma_init,    1, 1 }, \
@@ -54,7 +62,12 @@
 	[DRM_IOCTL_NR(DRM_IOCTL_I810_GETBUF)] = { i810_getbuf,      1, 0 }, \
    	[DRM_IOCTL_NR(DRM_IOCTL_I810_SWAP)]   = { i810_swap_bufs,   1, 0 }, \
    	[DRM_IOCTL_NR(DRM_IOCTL_I810_COPY)]   = { i810_copybuf,     1, 0 }, \
-   	[DRM_IOCTL_NR(DRM_IOCTL_I810_DOCOPY)] = { i810_docopy,      1, 0 },
+   	[DRM_IOCTL_NR(DRM_IOCTL_I810_DOCOPY)] = { i810_docopy,      1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I810_OV0INFO)] = { i810_ov0_info,   1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I810_FSTATUS)] = { i810_fstatus,    1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I810_OV0FLIP)] = { i810_ov0_flip,   1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I810_MC)]      = { i810_dma_mc,     1, 1 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I810_RSTATUS)] = { i810_rstatus,    1, 0 }
 
 
 #define __HAVE_COUNTERS         4
diff -Nru a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
--- a/drivers/char/drm/i810_drv.h	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/i810_drv.h	Fri May 24 18:55:35 2002
@@ -64,8 +64,6 @@
       	unsigned long hw_status_page;
    	unsigned long counter;
 
-   	atomic_t flush_done;
-   	wait_queue_head_t flush_queue;	/* Processes waiting until flush    */
 	drm_buf_t *mmap_buffer;
 
 
@@ -73,8 +71,11 @@
 
 	int back_offset;
 	int depth_offset;
+	int overlay_offset;
+	int overlay_physical;
 	int w, h;
 	int pitch;
+
 } drm_i810_private_t;
 
 				/* i810_dma.c */
@@ -89,15 +90,29 @@
 extern int  i810_getage(struct inode *inode, struct file *filp,
 			unsigned int cmd, unsigned long arg);
 extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
+
+/* Obsolete:
+ */
 extern int i810_copybuf(struct inode *inode, struct file *filp,
 			unsigned int cmd, unsigned long arg);
+/* Obsolete:
+ */
 extern int i810_docopy(struct inode *inode, struct file *filp,
 		       unsigned int cmd, unsigned long arg);
 
-extern void i810_dma_quiescent(drm_device_t *dev);
+extern int i810_rstatus(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
+extern int i810_ov0_info(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
+extern int i810_fstatus(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
+extern int i810_ov0_flip(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
+extern int i810_dma_mc(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
 
-#define I810_VERBOSE 0
 
+extern void i810_dma_quiescent(drm_device_t *dev);
 
 int i810_dma_vertex(struct inode *inode, struct file *filp,
 		    unsigned int cmd, unsigned long arg);
diff -Nru a/drivers/char/drm/i830.h b/drivers/char/drm/i830.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/i830.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,116 @@
+/* i830.h -- Intel I830 DRM template customization -*- linux-c -*-
+ * Created: Thu Feb 15 00:01:12 2001 by gareth@valinux.com
+ *
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __I830_H__
+#define __I830_H__
+
+/* This remains constant for all DRM template files.
+ */
+#define DRM(x) i830_##x
+
+/* General customization:
+ */
+#define __HAVE_AGP		1
+#define __MUST_HAVE_AGP		1
+#define __HAVE_MTRR		1
+#define __HAVE_CTX_BITMAP	1
+
+/* Driver customization:
+ */
+#define __HAVE_RELEASE		1
+#define DRIVER_RELEASE() do {						\
+	i830_reclaim_buffers( dev, priv->pid );				\
+} while (0)
+
+/* DMA customization:
+ */
+#define __HAVE_DMA		1
+#define __HAVE_DMA_QUEUE	1
+#define __HAVE_DMA_WAITLIST	1
+#define __HAVE_DMA_RECLAIM	1
+
+#define __HAVE_DMA_QUIESCENT	1
+#define DRIVER_DMA_QUIESCENT() do {					\
+	i830_dma_quiescent( dev );					\
+} while (0)
+
+#define __HAVE_DMA_IRQ		1
+#define __HAVE_DMA_IRQ_BH	1
+#define __HAVE_SHARED_IRQ       1
+#define DRIVER_PREINSTALL() do {					\
+	drm_i830_private_t *dev_priv =					\
+		(drm_i830_private_t *)dev->dev_private;			\
+	u16 tmp;							\
+   	tmp = I830_READ16( I830REG_HWSTAM );				\
+   	tmp = tmp & 0x6000;						\
+   	I830_WRITE16( I830REG_HWSTAM, tmp );				\
+									\
+      	tmp = I830_READ16( I830REG_INT_MASK_R );			\
+   	tmp = tmp & 0x6000;		/* Unmask interrupts */		\
+   	I830_WRITE16( I830REG_INT_MASK_R, tmp );			\
+   	tmp = I830_READ16( I830REG_INT_ENABLE_R );			\
+   	tmp = tmp & 0x6000;		/* Disable all interrupts */	\
+      	I830_WRITE16( I830REG_INT_ENABLE_R, tmp );			\
+} while (0)
+
+#define DRIVER_POSTINSTALL() do {					\
+	drm_i830_private_t *dev_priv =					\
+		(drm_i830_private_t *)dev->dev_private;	\
+	u16 tmp;							\
+   	tmp = I830_READ16( I830REG_INT_ENABLE_R );			\
+   	tmp = tmp & 0x6000;						\
+   	tmp = tmp | 0x0003;	/* Enable bp & user interrupts */	\
+   	I830_WRITE16( I830REG_INT_ENABLE_R, tmp );			\
+} while (0)
+
+#define DRIVER_UNINSTALL() do {						\
+	drm_i830_private_t *dev_priv =					\
+		(drm_i830_private_t *)dev->dev_private;			\
+	u16 tmp;							\
+	if ( dev_priv ) {						\
+		tmp = I830_READ16( I830REG_INT_IDENTITY_R );		\
+		tmp = tmp & ~(0x6000);	/* Clear all interrupts */	\
+		if ( tmp != 0 )						\
+			I830_WRITE16( I830REG_INT_IDENTITY_R, tmp );	\
+									\
+		tmp = I830_READ16( I830REG_INT_ENABLE_R );		\
+		tmp = tmp & 0x6000;	/* Disable all interrupts */	\
+		I830_WRITE16( I830REG_INT_ENABLE_R, tmp );		\
+	}								\
+} while (0)
+
+/* Buffer customization:
+ */
+
+#define DRIVER_BUF_PRIV_T	drm_i830_buf_priv_t
+
+#define DRIVER_AGP_BUFFERS_MAP( dev )					\
+	((drm_i830_private_t *)((dev)->dev_private))->buffer_map
+
+#endif
diff -Nru a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/i830_dma.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,1425 @@
+/* i830_dma.c -- DMA support for the I830 -*- linux-c -*-
+ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *	    Jeff Hartmann <jhartmann@valinux.com>
+ *      Keith Whitwell <keithw@valinux.com>
+ *      Abraham vd Merwe <abraham@2d3d.co.za>
+ *
+ */
+
+#define __NO_VERSION__
+#include "i830.h"
+#include "drmP.h"
+#include "i830_drv.h"
+#include <linux/interrupt.h>	/* For task queue support */
+#include <linux/delay.h>
+#include <linux/pagemap.h>
+
+/* in case we don't have a 2.3.99-pre6 kernel or later: */
+#ifndef VM_DONTCOPY
+#define VM_DONTCOPY 0
+#endif
+
+#define I830_BUF_FREE		2
+#define I830_BUF_CLIENT		1
+#define I830_BUF_HARDWARE      	0
+
+#define I830_BUF_UNMAPPED 0
+#define I830_BUF_MAPPED   1
+
+#define RING_LOCALS	unsigned int outring, ringmask; volatile char *virt;
+
+
+#define DO_IDLE_WORKAROUND()					\
+do {								\
+   int _head;							\
+   int _tail;							\
+   int _i;							\
+   do { 							\
+      _head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR;	\
+      _tail = I830_READ(LP_RING + RING_TAIL) & TAIL_ADDR;	\
+      udelay(10);						\
+   } while(_head != _tail);					\
+} while(0)
+
+#define I830_SYNC_WORKAROUND 0
+
+#define BEGIN_LP_RING(n) do {				\
+	if (I830_VERBOSE)				\
+		DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n",	\
+			  n, __FUNCTION__);		\
+	if (I830_SYNC_WORKAROUND)			\
+		DO_IDLE_WORKAROUND();			\
+	if (dev_priv->ring.space < n*4) 		\
+		i830_wait_ring(dev, n*4);		\
+	dev_priv->ring.space -= n*4;			\
+	outring = dev_priv->ring.tail;			\
+	ringmask = dev_priv->ring.tail_mask;		\
+	virt = dev_priv->ring.virtual_start;		\
+} while (0)
+
+#define ADVANCE_LP_RING() do {					\
+	if (I830_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n");	\
+	dev_priv->ring.tail = outring;				\
+	I830_WRITE(LP_RING + RING_TAIL, outring);		\
+} while(0)
+
+#define OUT_RING(n) do {						\
+	if (I830_VERBOSE) DRM_DEBUG("   OUT_RING %x\n", (int)(n));	\
+	*(volatile unsigned int *)(virt + outring) = n;			\
+	outring += 4;							\
+	outring &= ringmask;						\
+} while (0)
+
+static inline void i830_print_status_page(drm_device_t *dev)
+{
+   	drm_device_dma_t *dma = dev->dma;
+      	drm_i830_private_t *dev_priv = dev->dev_private;
+	u32 *temp = (u32 *)dev_priv->hw_status_page;
+   	int i;
+
+   	DRM_DEBUG(  "hw_status: Interrupt Status : %x\n", temp[0]);
+   	DRM_DEBUG(  "hw_status: LpRing Head ptr : %x\n", temp[1]);
+   	DRM_DEBUG(  "hw_status: IRing Head ptr : %x\n", temp[2]);
+      	DRM_DEBUG(  "hw_status: Reserved : %x\n", temp[3]);
+   	DRM_DEBUG(  "hw_status: Driver Counter : %d\n", temp[5]);
+   	for(i = 9; i < dma->buf_count + 9; i++) {
+	   	DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 9, temp[i]);
+	}
+}
+
+static drm_buf_t *i830_freelist_get(drm_device_t *dev)
+{
+   	drm_device_dma_t *dma = dev->dma;
+	int		 i;
+   	int 		 used;
+   
+	/* Linear search might not be the best solution */
+
+   	for (i = 0; i < dma->buf_count; i++) {
+	   	drm_buf_t *buf = dma->buflist[ i ];
+	   	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+		/* In use is already a pointer */
+	   	used = cmpxchg(buf_priv->in_use, I830_BUF_FREE, 
+			       I830_BUF_CLIENT);
+	   	if(used == I830_BUF_FREE) {
+			return buf;
+		}
+	}
+   	return NULL;
+}
+
+/* This should only be called if the buffer is not sent to the hardware
+ * yet, the hardware updates in use for us once its on the ring buffer.
+ */
+
+static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
+{
+   	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+   	int used;
+   
+   	/* In use is already a pointer */
+   	used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, I830_BUF_FREE);
+   	if(used != I830_BUF_CLIENT) {
+	   	DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx);
+	   	return -EINVAL;
+	}
+   
+   	return 0;
+}
+
+static struct file_operations i830_buffer_fops = {
+	open:	 DRM(open),
+	flush:	 DRM(flush),
+	release: DRM(release),
+	ioctl:	 DRM(ioctl),
+	mmap:	 i830_mmap_buffers,
+	read:	 DRM(read),
+	fasync:	 DRM(fasync),
+      	poll:	 DRM(poll),
+};
+
+int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
+{
+	drm_file_t	    *priv	  = filp->private_data;
+	drm_device_t	    *dev;
+	drm_i830_private_t  *dev_priv;
+	drm_buf_t           *buf;
+	drm_i830_buf_priv_t *buf_priv;
+
+	lock_kernel();
+	dev	 = priv->dev;
+	dev_priv = dev->dev_private;
+	buf      = dev_priv->mmap_buffer;
+	buf_priv = buf->dev_private;
+   
+	vma->vm_flags |= (VM_IO | VM_DONTCOPY);
+	vma->vm_file = filp;
+   
+   	buf_priv->currently_mapped = I830_BUF_MAPPED;
+	unlock_kernel();
+
+	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
+			     VM_OFFSET(vma),
+			     vma->vm_end - vma->vm_start,
+			     vma->vm_page_prot)) return -EAGAIN;
+	return 0;
+}
+
+static int i830_map_buffer(drm_buf_t *buf, struct file *filp)
+{
+	drm_file_t	  *priv	  = filp->private_data;
+	drm_device_t	  *dev	  = priv->dev;
+	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+      	drm_i830_private_t *dev_priv = dev->dev_private;
+   	struct file_operations *old_fops;
+	int retcode = 0;
+
+	if(buf_priv->currently_mapped == I830_BUF_MAPPED) return -EINVAL;
+
+	if(VM_DONTCOPY != 0) {
+#if LINUX_VERSION_CODE <= 0x020402
+		down( &current->mm->mmap_sem );
+#else
+		down_write( &current->mm->mmap_sem );
+#endif
+		old_fops = filp->f_op;
+		filp->f_op = &i830_buffer_fops;
+		dev_priv->mmap_buffer = buf;
+		buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, 
+						    PROT_READ|PROT_WRITE,
+						    MAP_SHARED, 
+						    buf->bus_address);
+		dev_priv->mmap_buffer = NULL;
+   		filp->f_op = old_fops;
+		if ((unsigned long)buf_priv->virtual > -1024UL) {
+			/* Real error */
+			DRM_DEBUG("mmap error\n");
+			retcode = (signed int)buf_priv->virtual;
+			buf_priv->virtual = 0;
+		}
+#if LINUX_VERSION_CODE <= 0x020402
+		up( &current->mm->mmap_sem );
+#else
+		up_write( &current->mm->mmap_sem );
+#endif
+	} else {
+		buf_priv->virtual = buf_priv->kernel_virtual;
+   		buf_priv->currently_mapped = I830_BUF_MAPPED;
+	}
+	return retcode;
+}
+
+static int i830_unmap_buffer(drm_buf_t *buf)
+{
+	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+	int retcode = 0;
+
+	if(VM_DONTCOPY != 0) {
+		if(buf_priv->currently_mapped != I830_BUF_MAPPED) 
+			return -EINVAL;
+#if LINUX_VERSION_CODE <= 0x020402
+		down( &current->mm->mmap_sem );
+#else
+		down_write( &current->mm->mmap_sem );
+#endif
+
+        	retcode = do_munmap(current->mm, 
+				    (unsigned long)buf_priv->virtual, 
+				    (size_t) buf->total);
+
+#if LINUX_VERSION_CODE <= 0x020402
+		up( &current->mm->mmap_sem );
+#else
+   		up_write( &current->mm->mmap_sem );
+#endif
+	}
+   	buf_priv->currently_mapped = I830_BUF_UNMAPPED;
+   	buf_priv->virtual = 0;
+
+	return retcode;
+}
+
+static int i830_dma_get_buffer(drm_device_t *dev, drm_i830_dma_t *d, 
+			       struct file *filp)
+{
+	drm_file_t	  *priv	  = filp->private_data;
+	drm_buf_t	  *buf;
+	drm_i830_buf_priv_t *buf_priv;
+	int retcode = 0;
+
+	buf = i830_freelist_get(dev);
+	if (!buf) {
+		retcode = -ENOMEM;
+	   	DRM_DEBUG("retcode=%d\n", retcode);
+		return retcode;
+	}
+   
+	retcode = i830_map_buffer(buf, filp);
+	if(retcode) {
+		i830_freelist_put(dev, buf);
+	   	DRM_DEBUG("mapbuf failed, retcode %d\n", retcode);
+		return retcode;
+	}
+	buf->pid     = priv->pid;
+	buf_priv = buf->dev_private;	
+	d->granted = 1;
+   	d->request_idx = buf->idx;
+   	d->request_size = buf->total;
+   	d->virtual = buf_priv->virtual;
+
+	return retcode;
+}
+
+static unsigned long i830_alloc_page(drm_device_t *dev)
+{
+	unsigned long address;
+   
+	address = __get_free_page(GFP_KERNEL);
+	if(address == 0UL) 
+		return 0;
+	
+#if LINUX_VERSION_CODE < 0x020500
+	atomic_inc(&virt_to_page(address)->count);
+	set_bit(PG_locked, &virt_to_page(address)->flags);
+#else
+	get_page(virt_to_page(address));
+	SetPageLocked(virt_to_page(address));
+#endif
+	return address;
+}
+
+static void i830_free_page(drm_device_t *dev, unsigned long page)
+{
+	if (page) {
+#if LINUX_VERSION_CODE < 0x020500
+		atomic_dec(&virt_to_page(page)->count);
+		clear_bit(PG_locked, &virt_to_page(page)->flags);
+		wake_up(&virt_to_page(page)->wait);
+#else
+		struct page *p = virt_to_page(page);
+		put_page(p);
+		unlock_page(p);
+#endif
+		free_page(page);
+	}
+}
+
+static int i830_dma_cleanup(drm_device_t *dev)
+{
+	drm_device_dma_t *dma = dev->dma;
+
+	if(dev->dev_private) {
+		int i;
+	   	drm_i830_private_t *dev_priv = 
+	     		(drm_i830_private_t *) dev->dev_private;
+	   
+	   	if(dev_priv->ring.virtual_start) {
+		   	DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
+					 dev_priv->ring.Size);
+		}
+	   	if(dev_priv->hw_status_page != 0UL) {
+		   	i830_free_page(dev, dev_priv->hw_status_page);
+		   	/* Need to rewrite hardware status page */
+		   	I830_WRITE(0x02080, 0x1ffff000);
+		}
+	   	DRM(free)(dev->dev_private, sizeof(drm_i830_private_t), 
+			 DRM_MEM_DRIVER);
+	   	dev->dev_private = NULL;
+
+		for (i = 0; i < dma->buf_count; i++) {
+			drm_buf_t *buf = dma->buflist[ i ];
+			drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+			DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
+		}
+	}
+   	return 0;
+}
+
+static int i830_wait_ring(drm_device_t *dev, int n)
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+   	drm_i830_ring_buffer_t *ring = &(dev_priv->ring);
+   	int iters = 0;
+   	unsigned long end;
+	unsigned int last_head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+
+	end = jiffies + (HZ*3);
+   	while (ring->space < n) {
+	   	int i;
+	
+	   	ring->head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+	   	ring->space = ring->head - (ring->tail+8);
+		if (ring->space < 0) ring->space += ring->Size;
+	   
+		if (ring->head != last_head) {
+			end = jiffies + (HZ*3);
+			last_head = ring->head;
+		}
+	  
+	   	iters++;
+		if((signed)(end - jiffies) <= 0) {
+		   	DRM_ERROR("space: %d wanted %d\n", ring->space, n);
+		   	DRM_ERROR("lockup\n");
+		   	goto out_wait_ring;
+		}
+
+		udelay(1);
+	}
+
+out_wait_ring:   
+   	return iters;
+}
+
+static void i830_kernel_lost_context(drm_device_t *dev)
+{
+      	drm_i830_private_t *dev_priv = dev->dev_private;
+   	drm_i830_ring_buffer_t *ring = &(dev_priv->ring);
+      
+   	ring->head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+     	ring->tail = I830_READ(LP_RING + RING_TAIL);
+     	ring->space = ring->head - (ring->tail+8);
+     	if (ring->space < 0) ring->space += ring->Size;
+}
+
+static int i830_freelist_init(drm_device_t *dev, drm_i830_private_t *dev_priv)
+{
+      	drm_device_dma_t *dma = dev->dma;
+   	int my_idx = 36;
+   	u32 *hw_status = (u32 *)(dev_priv->hw_status_page + my_idx);
+   	int i;
+
+   	if(dma->buf_count > 1019) {
+	   	/* Not enough space in the status page for the freelist */
+	   	return -EINVAL;
+	}
+
+   	for (i = 0; i < dma->buf_count; i++) {
+	   	drm_buf_t *buf = dma->buflist[ i ];
+	   	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+
+	   	buf_priv->in_use = hw_status++;
+	   	buf_priv->my_use_idx = my_idx;
+	   	my_idx += 4;
+
+	   	*buf_priv->in_use = I830_BUF_FREE;
+
+		buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, 
+							buf->total);
+	}
+	return 0;
+}
+
+static int i830_dma_initialize(drm_device_t *dev, 
+			       drm_i830_private_t *dev_priv,
+			       drm_i830_init_t *init)
+{
+	struct list_head *list;
+
+   	memset(dev_priv, 0, sizeof(drm_i830_private_t));
+
+	list_for_each(list, &dev->maplist->head) {
+		drm_map_list_t *r_list = (drm_map_list_t *)list;
+		if( r_list->map &&
+		    r_list->map->type == _DRM_SHM &&
+		    r_list->map->flags & _DRM_CONTAINS_LOCK ) {
+			dev_priv->sarea_map = r_list->map;
+ 			break;
+ 		}
+ 	}
+
+	if(!dev_priv->sarea_map) {
+		dev->dev_private = (void *)dev_priv;
+		i830_dma_cleanup(dev);
+		DRM_ERROR("can not find sarea!\n");
+		return -EINVAL;
+	}
+	DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset );
+	if(!dev_priv->mmio_map) {
+		dev->dev_private = (void *)dev_priv;
+		i830_dma_cleanup(dev);
+		DRM_ERROR("can not find mmio map!\n");
+		return -EINVAL;
+	}
+	DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset );
+	if(!dev_priv->buffer_map) {
+		dev->dev_private = (void *)dev_priv;
+		i830_dma_cleanup(dev);
+		DRM_ERROR("can not find dma buffer map!\n");
+		return -EINVAL;
+	}
+
+	dev_priv->sarea_priv = (drm_i830_sarea_t *)
+		((u8 *)dev_priv->sarea_map->handle +
+		 init->sarea_priv_offset);
+
+   	atomic_set(&dev_priv->flush_done, 0);
+	init_waitqueue_head(&dev_priv->flush_queue);
+
+   	dev_priv->ring.Start = init->ring_start;
+   	dev_priv->ring.End = init->ring_end;
+   	dev_priv->ring.Size = init->ring_size;
+
+   	dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + 
+						    init->ring_start, 
+						    init->ring_size);
+
+   	if (dev_priv->ring.virtual_start == NULL) {
+		dev->dev_private = (void *) dev_priv;
+	   	i830_dma_cleanup(dev);
+	   	DRM_ERROR("can not ioremap virtual address for"
+			  " ring buffer\n");
+	   	return -ENOMEM;
+	}
+
+   	dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
+   
+	dev_priv->w = init->w;
+	dev_priv->h = init->h;
+	dev_priv->pitch = init->pitch;
+	dev_priv->back_offset = init->back_offset;
+	dev_priv->depth_offset = init->depth_offset;
+
+	dev_priv->front_di1 = init->front_offset | init->pitch_bits;
+	dev_priv->back_di1 = init->back_offset | init->pitch_bits;
+	dev_priv->zi1 = init->depth_offset | init->pitch_bits;
+
+	dev_priv->cpp = init->cpp;
+	/* We are using seperate values as placeholders for mechanisms for
+	 * private backbuffer/depthbuffer usage.
+	 */
+
+	dev_priv->back_pitch = init->back_pitch;
+	dev_priv->depth_pitch = init->depth_pitch;
+
+   	/* Program Hardware Status Page */
+   	dev_priv->hw_status_page = i830_alloc_page(dev);
+   	if(dev_priv->hw_status_page == 0UL) {
+		dev->dev_private = (void *)dev_priv;
+		i830_dma_cleanup(dev);
+		DRM_ERROR("Can not allocate hardware status page\n");
+		return -ENOMEM;
+	}
+   	memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
+	DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
+   
+   	I830_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page));
+	DRM_DEBUG("Enabled hardware status page\n");
+   
+   	/* Now we need to init our freelist */
+   	if(i830_freelist_init(dev, dev_priv) != 0) {
+		dev->dev_private = (void *)dev_priv;
+	   	i830_dma_cleanup(dev);
+	   	DRM_ERROR("Not enough space in the status page for"
+			  " the freelist\n");
+	   	return -ENOMEM;
+	}
+	dev->dev_private = (void *)dev_priv;
+
+   	return 0;
+}
+
+int i830_dma_init(struct inode *inode, struct file *filp,
+		  unsigned int cmd, unsigned long arg)
+{
+   	drm_file_t *priv = filp->private_data;
+   	drm_device_t *dev = priv->dev;
+   	drm_i830_private_t *dev_priv;
+   	drm_i830_init_t init;
+   	int retcode = 0;
+	
+  	if (copy_from_user(&init, (drm_i830_init_t *)arg, sizeof(init)))
+		return -EFAULT;
+	
+   	switch(init.func) {
+	 	case I830_INIT_DMA:
+			dev_priv = DRM(alloc)(sizeof(drm_i830_private_t), 
+					      DRM_MEM_DRIVER);
+	   		if(dev_priv == NULL) return -ENOMEM;
+	   		retcode = i830_dma_initialize(dev, dev_priv, &init);
+	   	break;
+	 	case I830_CLEANUP_DMA:
+	   		retcode = i830_dma_cleanup(dev);
+	   	break;
+	 	default:
+	   		retcode = -EINVAL;
+	   	break;
+	}
+   
+   	return retcode;
+}
+
+/* Most efficient way to verify state for the i830 is as it is
+ * emitted.  Non-conformant state is silently dropped.
+ *
+ * Use 'volatile' & local var tmp to force the emitted values to be
+ * identical to the verified ones.
+ */
+static void i830EmitContextVerified( drm_device_t *dev, 
+				     volatile unsigned int *code )
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	int i, j = 0;
+	unsigned int tmp;
+	RING_LOCALS;
+
+	BEGIN_LP_RING( I830_CTX_SETUP_SIZE );
+	for ( i = 0 ; i < I830_CTX_SETUP_SIZE ; i++ ) {
+		tmp = code[i];
+
+#if 0
+		if ((tmp & (7<<29)) == (3<<29) &&
+		    (tmp & (0x1f<<24)) < (0x1d<<24)) {
+			OUT_RING( tmp ); 
+			j++;
+		} else {
+			printk("Skipping %d\n", i);
+		}
+#else
+		OUT_RING( tmp ); 
+		j++;
+#endif
+	}
+
+	if (j & 1) 
+		OUT_RING( 0 ); 
+
+	ADVANCE_LP_RING();
+}
+
+static void i830EmitTexVerified( drm_device_t *dev, 
+				 volatile unsigned int *code ) 
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	int i, j = 0;
+	unsigned int tmp;
+	RING_LOCALS;
+
+	BEGIN_LP_RING( I830_TEX_SETUP_SIZE );
+
+	OUT_RING( GFX_OP_MAP_INFO );
+	OUT_RING( code[I830_TEXREG_MI1] );
+	OUT_RING( code[I830_TEXREG_MI2] );
+	OUT_RING( code[I830_TEXREG_MI3] );
+	OUT_RING( code[I830_TEXREG_MI4] );
+	OUT_RING( code[I830_TEXREG_MI5] );
+
+	for ( i = 6 ; i < I830_TEX_SETUP_SIZE ; i++ ) {
+		tmp = code[i];
+		OUT_RING( tmp ); 
+		j++;
+	} 
+
+	if (j & 1) 
+		OUT_RING( 0 ); 
+
+	ADVANCE_LP_RING();
+}
+
+static void i830EmitTexBlendVerified( drm_device_t *dev, 
+				     volatile unsigned int *code,
+				     volatile unsigned int num)
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	int i, j = 0;
+	unsigned int tmp;
+	RING_LOCALS;
+
+	BEGIN_LP_RING( num );
+
+	for ( i = 0 ; i < num ; i++ ) {
+		tmp = code[i];
+		OUT_RING( tmp );
+		j++;
+	}
+
+	if (j & 1) 
+		OUT_RING( 0 ); 
+
+	ADVANCE_LP_RING();
+}
+
+static void i830EmitTexPalette( drm_device_t *dev,
+			        unsigned int *palette,
+			        int number,
+			        int is_shared )
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	int i;
+	RING_LOCALS;
+
+	BEGIN_LP_RING( 258 );
+
+	if(is_shared == 1) {
+		OUT_RING(CMD_OP_MAP_PALETTE_LOAD |
+			 MAP_PALETTE_NUM(0) |
+			 MAP_PALETTE_BOTH);
+	} else {
+		OUT_RING(CMD_OP_MAP_PALETTE_LOAD | MAP_PALETTE_NUM(number));
+	}
+	for(i = 0; i < 256; i++) {
+		OUT_RING(palette[i]);
+	}
+	OUT_RING(0);
+}
+
+/* Need to do some additional checking when setting the dest buffer.
+ */
+static void i830EmitDestVerified( drm_device_t *dev, 
+				  volatile unsigned int *code ) 
+{	
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	unsigned int tmp;
+	RING_LOCALS;
+
+	BEGIN_LP_RING( I830_DEST_SETUP_SIZE + 6 );
+
+	tmp = code[I830_DESTREG_CBUFADDR];
+	if (tmp == dev_priv->front_di1) {
+		/* Don't use fence when front buffer rendering */
+		OUT_RING( CMD_OP_DESTBUFFER_INFO );
+		OUT_RING( BUF_3D_ID_COLOR_BACK | 
+			  BUF_3D_PITCH(dev_priv->back_pitch * dev_priv->cpp) );
+		OUT_RING( tmp );
+
+		OUT_RING( CMD_OP_DESTBUFFER_INFO );
+		OUT_RING( BUF_3D_ID_DEPTH |
+			  BUF_3D_PITCH(dev_priv->depth_pitch * dev_priv->cpp));
+		OUT_RING( dev_priv->zi1 );
+	} else if(tmp == dev_priv->back_di1) {
+		OUT_RING( CMD_OP_DESTBUFFER_INFO );
+		OUT_RING( BUF_3D_ID_COLOR_BACK | 
+			  BUF_3D_PITCH(dev_priv->back_pitch * dev_priv->cpp) |
+			  BUF_3D_USE_FENCE);
+		OUT_RING( tmp );
+
+		OUT_RING( CMD_OP_DESTBUFFER_INFO );
+		OUT_RING( BUF_3D_ID_DEPTH | BUF_3D_USE_FENCE | 
+			  BUF_3D_PITCH(dev_priv->depth_pitch * dev_priv->cpp));
+		OUT_RING( dev_priv->zi1 );
+	} else {
+		DRM_DEBUG("bad di1 %x (allow %x or %x)\n",
+			  tmp, dev_priv->front_di1, dev_priv->back_di1);
+	}
+
+	/* invarient:
+	 */
+
+
+	OUT_RING( GFX_OP_DESTBUFFER_VARS );
+	OUT_RING( code[I830_DESTREG_DV1] );
+
+	OUT_RING( GFX_OP_DRAWRECT_INFO );
+	OUT_RING( code[I830_DESTREG_DR1] );
+	OUT_RING( code[I830_DESTREG_DR2] );
+	OUT_RING( code[I830_DESTREG_DR3] );
+	OUT_RING( code[I830_DESTREG_DR4] );
+
+	/* Need to verify this */
+	tmp = code[I830_DESTREG_SENABLE];
+	if((tmp & ~0x3) == GFX_OP_SCISSOR_ENABLE) {
+		OUT_RING( tmp );
+	} else {
+		DRM_DEBUG("bad scissor enable\n");
+		OUT_RING( 0 );
+	}
+
+	OUT_RING( code[I830_DESTREG_SENABLE] );
+
+	OUT_RING( GFX_OP_SCISSOR_RECT );
+	OUT_RING( code[I830_DESTREG_SR1] );
+	OUT_RING( code[I830_DESTREG_SR2] );
+
+	ADVANCE_LP_RING();
+}
+
+static void i830EmitState( drm_device_t *dev )
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+      	drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	unsigned int dirty = sarea_priv->dirty;
+
+	if (dirty & I830_UPLOAD_BUFFERS) {
+		i830EmitDestVerified( dev, sarea_priv->BufferState );
+		sarea_priv->dirty &= ~I830_UPLOAD_BUFFERS;
+	}
+
+	if (dirty & I830_UPLOAD_CTX) {
+		i830EmitContextVerified( dev, sarea_priv->ContextState );
+		sarea_priv->dirty &= ~I830_UPLOAD_CTX;
+	}
+
+	if (dirty & I830_UPLOAD_TEX0) {
+		i830EmitTexVerified( dev, sarea_priv->TexState[0] );
+		sarea_priv->dirty &= ~I830_UPLOAD_TEX0;
+	}
+
+	if (dirty & I830_UPLOAD_TEX1) {
+		i830EmitTexVerified( dev, sarea_priv->TexState[1] );
+		sarea_priv->dirty &= ~I830_UPLOAD_TEX1;
+	}
+
+	if (dirty & I830_UPLOAD_TEXBLEND0) {
+		i830EmitTexBlendVerified( dev, sarea_priv->TexBlendState[0],
+				sarea_priv->TexBlendStateWordsUsed[0]);
+		sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND0;
+	}
+
+	if (dirty & I830_UPLOAD_TEXBLEND1) {
+		i830EmitTexBlendVerified( dev, sarea_priv->TexBlendState[1],
+				sarea_priv->TexBlendStateWordsUsed[1]);
+		sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND1;
+	}
+
+	if (dirty & I830_UPLOAD_TEX_PALETTE_SHARED) {
+	   i830EmitTexPalette(dev, sarea_priv->Palette[0], 0, 1);
+	} else {
+	   if (dirty & I830_UPLOAD_TEX_PALETTE_N(0)) {
+	      i830EmitTexPalette(dev, sarea_priv->Palette[0], 0, 0);
+	      sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(0);
+	   }
+	   if (dirty & I830_UPLOAD_TEX_PALETTE_N(1)) {
+	      i830EmitTexPalette(dev, sarea_priv->Palette[1], 1, 0);
+	      sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(1);
+	   }
+	}
+}
+
+static void i830_dma_dispatch_clear( drm_device_t *dev, int flags, 
+				    unsigned int clear_color,
+				    unsigned int clear_zval,
+				    unsigned int clear_depthmask)
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+      	drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	int nbox = sarea_priv->nbox;
+	drm_clip_rect_t *pbox = sarea_priv->boxes;
+	int pitch = dev_priv->pitch;
+	int cpp = dev_priv->cpp;
+	int i;
+	unsigned int BR13, CMD, D_CMD;
+	RING_LOCALS;
+
+  	i830_kernel_lost_context(dev);
+
+	switch(cpp) {
+	case 2: 
+		BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24);
+		D_CMD = CMD = XY_COLOR_BLT_CMD;
+		break;
+	case 4:
+		BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24) | (1<<25);
+		CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | 
+		       XY_COLOR_BLT_WRITE_RGB);
+		D_CMD = XY_COLOR_BLT_CMD;
+		if(clear_depthmask & 0x00ffffff)
+			D_CMD |= XY_COLOR_BLT_WRITE_RGB;
+		if(clear_depthmask & 0xff000000)
+			D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
+		break;
+	default:
+		BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24);
+		D_CMD = CMD = XY_COLOR_BLT_CMD;
+		break;
+	}
+
+      	if (nbox > I830_NR_SAREA_CLIPRECTS)
+     		nbox = I830_NR_SAREA_CLIPRECTS;
+
+	for (i = 0 ; i < nbox ; i++, pbox++) {
+		if (pbox->x1 > pbox->x2 ||
+		    pbox->y1 > pbox->y2 ||
+		    pbox->x2 > dev_priv->w ||
+		    pbox->y2 > dev_priv->h)
+			continue;
+
+	   	if ( flags & I830_FRONT ) {	    
+		   	DRM_DEBUG("clear front\n");
+			BEGIN_LP_RING( 6 );	    
+			OUT_RING( CMD );
+			OUT_RING( BR13 );
+			OUT_RING( (pbox->y1 << 16) | pbox->x1 );
+			OUT_RING( (pbox->y2 << 16) | pbox->x2 );
+			OUT_RING( 0 );
+			OUT_RING( clear_color );
+			ADVANCE_LP_RING();
+		}
+
+		if ( flags & I830_BACK ) {
+			DRM_DEBUG("clear back\n");
+			BEGIN_LP_RING( 6 );	    
+			OUT_RING( CMD );
+			OUT_RING( BR13 );
+			OUT_RING( (pbox->y1 << 16) | pbox->x1 );
+			OUT_RING( (pbox->y2 << 16) | pbox->x2 );
+			OUT_RING( dev_priv->back_offset );
+			OUT_RING( clear_color );
+			ADVANCE_LP_RING();
+		}
+
+		if ( flags & I830_DEPTH ) {
+			DRM_DEBUG("clear depth\n");
+			BEGIN_LP_RING( 6 );
+			OUT_RING( D_CMD );
+			OUT_RING( BR13 );
+			OUT_RING( (pbox->y1 << 16) | pbox->x1 );
+			OUT_RING( (pbox->y2 << 16) | pbox->x2 );
+			OUT_RING( dev_priv->depth_offset );
+			OUT_RING( clear_zval );
+			ADVANCE_LP_RING();
+		}
+	}
+}
+
+static void i830_dma_dispatch_swap( drm_device_t *dev )
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+      	drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	int nbox = sarea_priv->nbox;
+	drm_clip_rect_t *pbox = sarea_priv->boxes;
+	int pitch = dev_priv->pitch;
+	int cpp = dev_priv->cpp;
+	int ofs = dev_priv->back_offset;
+	int i;
+	unsigned int CMD, BR13;
+	RING_LOCALS;
+
+	DRM_DEBUG("swapbuffers\n");
+
+	switch(cpp) {
+	case 2: 
+		BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24);
+		CMD = XY_SRC_COPY_BLT_CMD;
+		break;
+	case 4:
+		BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24) | (1<<25);
+		CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
+		       XY_SRC_COPY_BLT_WRITE_RGB);
+		break;
+	default:
+		BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24);
+		CMD = XY_SRC_COPY_BLT_CMD;
+		break;
+	}
+
+  	i830_kernel_lost_context(dev);
+
+      	if (nbox > I830_NR_SAREA_CLIPRECTS)
+     		nbox = I830_NR_SAREA_CLIPRECTS;
+
+	for (i = 0 ; i < nbox; i++, pbox++) 
+	{
+		if (pbox->x1 > pbox->x2 ||
+		    pbox->y1 > pbox->y2 ||
+		    pbox->x2 > dev_priv->w ||
+		    pbox->y2 > dev_priv->h)
+			continue;
+ 
+		DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
+			  pbox->x1, pbox->y1,
+			  pbox->x2, pbox->y2);
+
+		BEGIN_LP_RING( 8 );
+		OUT_RING( CMD );
+		OUT_RING( BR13 );
+
+		OUT_RING( (pbox->y1 << 16) |
+			  pbox->x1 );
+		OUT_RING( (pbox->y2 << 16) |
+			  pbox->x2 );
+
+		OUT_RING( 0 /* front ofs always zero */ );
+		OUT_RING( (pbox->y1 << 16) |
+			  pbox->x1 );
+
+		OUT_RING( BR13 & 0xffff );
+		OUT_RING( ofs );
+
+		ADVANCE_LP_RING();
+	}
+}
+
+
+static void i830_dma_dispatch_vertex(drm_device_t *dev, 
+				     drm_buf_t *buf,
+				     int discard,
+				     int used)
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+   	drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv;
+   	drm_clip_rect_t *box = sarea_priv->boxes;
+   	int nbox = sarea_priv->nbox;
+	unsigned long address = (unsigned long)buf->bus_address;
+	unsigned long start = address - dev->agp->base;     
+	int i = 0, u;
+   	RING_LOCALS;
+
+   	i830_kernel_lost_context(dev);
+
+   	if (nbox > I830_NR_SAREA_CLIPRECTS) 
+		nbox = I830_NR_SAREA_CLIPRECTS;
+
+	if (discard) {
+		u = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, 
+			    I830_BUF_HARDWARE);
+		if(u != I830_BUF_CLIENT) {
+			DRM_DEBUG("xxxx 2\n");
+		}
+	}
+
+	if (used > 4*1024) 
+		used = 0;
+
+	if (sarea_priv->dirty)
+	   i830EmitState( dev );
+
+  	DRM_DEBUG("dispatch vertex addr 0x%lx, used 0x%x nbox %d\n", 
+		  address, used, nbox);
+
+   	dev_priv->counter++;
+   	DRM_DEBUG(  "dispatch counter : %ld\n", dev_priv->counter);
+   	DRM_DEBUG(  "i830_dma_dispatch\n");
+   	DRM_DEBUG(  "start : %lx\n", start);
+	DRM_DEBUG(  "used : %d\n", used);
+   	DRM_DEBUG(  "start + used - 4 : %ld\n", start + used - 4);
+
+	if (buf_priv->currently_mapped == I830_BUF_MAPPED) {
+		*(u32 *)buf_priv->virtual = (GFX_OP_PRIMITIVE |
+					     sarea_priv->vertex_prim |
+					     ((used/4)-2));
+		
+		if (used & 4) {
+			*(u32 *)((u32)buf_priv->virtual + used) = 0;
+			used += 4;
+		}
+
+		i830_unmap_buffer(buf);
+	}
+		   
+	if (used) {
+		do {
+			if (i < nbox) {
+				BEGIN_LP_RING(6);
+				OUT_RING( GFX_OP_DRAWRECT_INFO );
+				OUT_RING( sarea_priv->BufferState[I830_DESTREG_DR1] );
+				OUT_RING( box[i].x1 | (box[i].y1<<16) );
+				OUT_RING( box[i].x2 | (box[i].y2<<16) );
+				OUT_RING( sarea_priv->BufferState[I830_DESTREG_DR4] );
+				OUT_RING( 0 );
+				ADVANCE_LP_RING();
+			}
+
+			BEGIN_LP_RING(4);
+
+			OUT_RING( MI_BATCH_BUFFER );
+			OUT_RING( start | MI_BATCH_NON_SECURE );
+			OUT_RING( start + used - 4 );
+			OUT_RING( 0 );
+			ADVANCE_LP_RING();
+			
+		} while (++i < nbox);
+	}
+
+	BEGIN_LP_RING(10);
+	OUT_RING( CMD_STORE_DWORD_IDX );
+	OUT_RING( 20 );
+	OUT_RING( dev_priv->counter );
+	OUT_RING( 0 );
+
+	if (discard) {
+		OUT_RING( CMD_STORE_DWORD_IDX );
+		OUT_RING( buf_priv->my_use_idx );
+		OUT_RING( I830_BUF_FREE );
+		OUT_RING( 0 );
+	}
+
+      	OUT_RING( CMD_REPORT_HEAD );
+	OUT_RING( 0 );
+   	ADVANCE_LP_RING();
+}
+
+/* Interrupts are only for flushing */
+void i830_dma_service(int irq, void *device, struct pt_regs *regs)
+{
+	drm_device_t	 *dev = (drm_device_t *)device;
+      	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+   	u16 temp;
+   
+      	temp = I830_READ16(I830REG_INT_IDENTITY_R);
+   	temp = temp & ~(0x6000);
+   	if(temp != 0) I830_WRITE16(I830REG_INT_IDENTITY_R, 
+				   temp); /* Clear all interrupts */
+	else
+	   return;
+ 
+   	queue_task(&dev->tq, &tq_immediate);
+   	mark_bh(IMMEDIATE_BH);
+}
+
+void DRM(dma_immediate_bh)(void *device)
+{
+	drm_device_t *dev = (drm_device_t *) device;
+      	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+
+   	atomic_set(&dev_priv->flush_done, 1);
+   	wake_up_interruptible(&dev_priv->flush_queue);
+}
+
+static inline void i830_dma_emit_flush(drm_device_t *dev)
+{
+   	drm_i830_private_t *dev_priv = dev->dev_private;
+   	RING_LOCALS;
+
+   	i830_kernel_lost_context(dev);
+
+   	BEGIN_LP_RING(2);
+      	OUT_RING( CMD_REPORT_HEAD );
+      	OUT_RING( GFX_OP_USER_INTERRUPT );
+      	ADVANCE_LP_RING();
+
+	i830_wait_ring( dev, dev_priv->ring.Size - 8 );
+	atomic_set(&dev_priv->flush_done, 1);
+	wake_up_interruptible(&dev_priv->flush_queue);
+}
+
+static inline void i830_dma_quiescent_emit(drm_device_t *dev)
+{
+      	drm_i830_private_t *dev_priv = dev->dev_private;
+   	RING_LOCALS;
+
+  	i830_kernel_lost_context(dev);
+
+   	BEGIN_LP_RING(4);
+   	OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+   	OUT_RING( CMD_REPORT_HEAD );
+      	OUT_RING( 0 );
+      	OUT_RING( GFX_OP_USER_INTERRUPT );
+   	ADVANCE_LP_RING();
+
+	i830_wait_ring( dev, dev_priv->ring.Size - 8 );
+	atomic_set(&dev_priv->flush_done, 1);
+	wake_up_interruptible(&dev_priv->flush_queue);
+}
+
+void i830_dma_quiescent(drm_device_t *dev)
+{
+      	DECLARE_WAITQUEUE(entry, current);
+  	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+	unsigned long end;      
+
+   	if(dev_priv == NULL) {
+	   	return;
+	}
+      	atomic_set(&dev_priv->flush_done, 0);
+   	add_wait_queue(&dev_priv->flush_queue, &entry);
+   	end = jiffies + (HZ*3);
+   
+   	for (;;) {
+		current->state = TASK_INTERRUPTIBLE;
+	      	i830_dma_quiescent_emit(dev);
+	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
+		if((signed)(end - jiffies) <= 0) {
+		   	DRM_ERROR("lockup\n");
+		   	break;
+		}	   
+	      	schedule_timeout(HZ*3);
+	      	if (signal_pending(current)) {
+		   	break;
+		}
+	}
+   
+   	current->state = TASK_RUNNING;
+   	remove_wait_queue(&dev_priv->flush_queue, &entry);
+   
+   	return;
+}
+
+static int i830_flush_queue(drm_device_t *dev)
+{
+   	DECLARE_WAITQUEUE(entry, current);
+  	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+	drm_device_dma_t *dma = dev->dma;
+	unsigned long end;
+   	int i, ret = 0;      
+
+   	if(dev_priv == NULL) {
+	   	return 0;
+	}
+      	atomic_set(&dev_priv->flush_done, 0);
+   	add_wait_queue(&dev_priv->flush_queue, &entry);
+   	end = jiffies + (HZ*3);
+   	for (;;) {
+		current->state = TASK_INTERRUPTIBLE;
+	      	i830_dma_emit_flush(dev);
+	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
+		if((signed)(end - jiffies) <= 0) {
+		   	DRM_ERROR("lockup\n");
+		   	break;
+		}	   
+	      	schedule_timeout(HZ*3);
+	      	if (signal_pending(current)) {
+		   	ret = -EINTR; /* Can't restart */
+		   	break;
+		}
+	}
+   
+   	current->state = TASK_RUNNING;
+   	remove_wait_queue(&dev_priv->flush_queue, &entry);
+
+
+   	for (i = 0; i < dma->buf_count; i++) {
+	   	drm_buf_t *buf = dma->buflist[ i ];
+	   	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+	   
+		int used = cmpxchg(buf_priv->in_use, I830_BUF_HARDWARE, 
+				   I830_BUF_FREE);
+
+		if (used == I830_BUF_HARDWARE)
+			DRM_DEBUG("reclaimed from HARDWARE\n");
+		if (used == I830_BUF_CLIENT)
+			DRM_DEBUG("still on client HARDWARE\n");
+	}
+
+   	return ret;
+}
+
+/* Must be called with the lock held */
+void i830_reclaim_buffers(drm_device_t *dev, pid_t pid)
+{
+	drm_device_dma_t *dma = dev->dma;
+	int		 i;
+
+	if (!dma) return;
+      	if (!dev->dev_private) return;
+	if (!dma->buflist) return;
+
+        i830_flush_queue(dev);
+
+	for (i = 0; i < dma->buf_count; i++) {
+	   	drm_buf_t *buf = dma->buflist[ i ];
+	   	drm_i830_buf_priv_t *buf_priv = buf->dev_private;
+	   
+		if (buf->pid == pid && buf_priv) {
+			int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, 
+					   I830_BUF_FREE);
+
+			if (used == I830_BUF_CLIENT)
+				DRM_DEBUG("reclaimed from client\n");
+		   	if(buf_priv->currently_mapped == I830_BUF_MAPPED)
+		     		buf_priv->currently_mapped = I830_BUF_UNMAPPED;
+		}
+	}
+}
+
+int i830_flush_ioctl(struct inode *inode, struct file *filp, 
+		     unsigned int cmd, unsigned long arg)
+{
+   	drm_file_t	  *priv	  = filp->private_data;
+   	drm_device_t	  *dev	  = priv->dev;
+   
+   	DRM_DEBUG("i830_flush_ioctl\n");
+   	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_flush_ioctl called without lock held\n");
+		return -EINVAL;
+	}
+
+   	i830_flush_queue(dev);
+   	return 0;
+}
+
+int i830_dma_vertex(struct inode *inode, struct file *filp,
+	       unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_device_dma_t *dma = dev->dma;
+   	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
+     					dev_priv->sarea_priv; 
+	drm_i830_vertex_t vertex;
+
+	if (copy_from_user(&vertex, (drm_i830_vertex_t *)arg, sizeof(vertex)))
+		return -EFAULT;
+
+   	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_dma_vertex called without lock held\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n",
+		  vertex.idx, vertex.used, vertex.discard);
+
+	if(vertex.idx < 0 || vertex.idx > dma->buf_count) return -EINVAL;
+
+	i830_dma_dispatch_vertex( dev, 
+				  dma->buflist[ vertex.idx ], 
+				  vertex.discard, vertex.used );
+
+	sarea_priv->last_enqueue = dev_priv->counter-1;
+   	sarea_priv->last_dispatch = (int) hw_status[5];
+   
+	return 0;
+}
+
+int i830_clear_bufs(struct inode *inode, struct file *filp,
+		   unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_i830_clear_t clear;
+
+   	if (copy_from_user(&clear, (drm_i830_clear_t *)arg, sizeof(clear)))
+		return -EFAULT;
+   
+   	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_clear_bufs called without lock held\n");
+		return -EINVAL;
+	}
+
+	/* GH: Someone's doing nasty things... */
+	if (!dev->dev_private) {
+		return -EINVAL;
+	}
+
+	i830_dma_dispatch_clear( dev, clear.flags, 
+				 clear.clear_color, 
+				 clear.clear_depth,
+			         clear.clear_depthmask);
+   	return 0;
+}
+
+int i830_swap_bufs(struct inode *inode, struct file *filp,
+		  unsigned int cmd, unsigned long arg)
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+   
+	DRM_DEBUG("i830_swap_bufs\n");
+
+   	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_swap_buf called without lock held\n");
+		return -EINVAL;
+	}
+
+	i830_dma_dispatch_swap( dev );
+   	return 0;
+}
+
+int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
+		unsigned long arg)
+{
+   	drm_file_t	  *priv	    = filp->private_data;
+	drm_device_t	  *dev	    = priv->dev;
+   	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
+     					dev_priv->sarea_priv; 
+
+      	sarea_priv->last_dispatch = (int) hw_status[5];
+	return 0;
+}
+
+int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
+		unsigned long arg)
+{
+	drm_file_t	  *priv	    = filp->private_data;
+	drm_device_t	  *dev	    = priv->dev;
+	int		  retcode   = 0;
+	drm_i830_dma_t	  d;
+   	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
+     					dev_priv->sarea_priv; 
+
+	DRM_DEBUG("getbuf\n");
+   	if (copy_from_user(&d, (drm_i830_dma_t *)arg, sizeof(d)))
+		return -EFAULT;
+   
+	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_dma called without lock held\n");
+		return -EINVAL;
+	}
+	
+	d.granted = 0;
+
+	retcode = i830_dma_get_buffer(dev, &d, filp);
+
+	DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
+		  current->pid, retcode, d.granted);
+
+	if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d)))
+		return -EFAULT;
+   	sarea_priv->last_dispatch = (int) hw_status[5];
+
+	return retcode;
+}
+
+int i830_copybuf(struct inode *inode, struct file *filp, unsigned int cmd,
+		unsigned long arg)
+{
+	drm_file_t	  *priv	    = filp->private_data;
+	drm_device_t	  *dev	    = priv->dev;
+	drm_i830_copy_t	  d;
+   	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
+   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
+     					dev_priv->sarea_priv; 
+	drm_buf_t *buf;
+	drm_i830_buf_priv_t *buf_priv;
+	drm_device_dma_t *dma = dev->dma;
+
+	if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+		DRM_ERROR("i830_dma called without lock held\n");
+		return -EINVAL;
+	}
+   
+   	if (copy_from_user(&d, (drm_i830_copy_t *)arg, sizeof(d)))
+		return -EFAULT;
+
+	if(d.idx < 0 || d.idx > dma->buf_count) return -EINVAL;
+	buf = dma->buflist[ d.idx ];
+   	buf_priv = buf->dev_private;
+	if (buf_priv->currently_mapped != I830_BUF_MAPPED) return -EPERM;
+
+	if(d.used < 0 || d.used > buf->total) return -EINVAL;
+
+   	if (copy_from_user(buf_priv->virtual, d.address, d.used))
+		return -EFAULT;
+
+   	sarea_priv->last_dispatch = (int) hw_status[5];
+
+	return 0;
+}
+
+int i830_docopy(struct inode *inode, struct file *filp, unsigned int cmd,
+		unsigned long arg)
+{
+	if(VM_DONTCOPY == 0) return 1;
+	return 0;
+}
diff -Nru a/drivers/char/drm/i830_drm.h b/drivers/char/drm/i830_drm.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/i830_drm.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,238 @@
+#ifndef _I830_DRM_H_
+#define _I830_DRM_H_
+
+/* WARNING: These defines must be the same as what the Xserver uses.
+ * if you change them, you must change the defines in the Xserver.
+ */
+
+#ifndef _I830_DEFINES_
+#define _I830_DEFINES_
+
+#define I830_DMA_BUF_ORDER		12
+#define I830_DMA_BUF_SZ 		(1<<I830_DMA_BUF_ORDER)
+#define I830_DMA_BUF_NR 		256
+#define I830_NR_SAREA_CLIPRECTS 	8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I830_NR_TEX_REGIONS 64
+#define I830_LOG_MIN_TEX_REGION_SIZE 16
+
+/* if defining I830_ENABLE_4_TEXTURES, do it in i830_3d_reg.h, too */
+#if !defined(I830_ENABLE_4_TEXTURES)
+#define I830_TEXTURE_COUNT	2
+#define I830_TEXBLEND_COUNT	2	/* always same as TEXTURE_COUNT? */
+#else /* defined(I830_ENABLE_4_TEXTURES) */
+#define I830_TEXTURE_COUNT	4
+#define I830_TEXBLEND_COUNT	4	/* always same as TEXTURE_COUNT? */
+#endif /* I830_ENABLE_4_TEXTURES */
+
+#define I830_TEXBLEND_SIZE	12	/* (4 args + op) * 2 + COLOR_FACTOR */
+
+#define I830_UPLOAD_CTX			0x1
+#define I830_UPLOAD_BUFFERS		0x2
+#define I830_UPLOAD_CLIPRECTS		0x4
+#define I830_UPLOAD_TEX0_IMAGE		0x100 /* handled clientside */
+#define I830_UPLOAD_TEX0_CUBE		0x200 /* handled clientside */
+#define I830_UPLOAD_TEX1_IMAGE		0x400 /* handled clientside */
+#define I830_UPLOAD_TEX1_CUBE		0x800 /* handled clientside */
+#define I830_UPLOAD_TEX2_IMAGE		0x1000 /* handled clientside */
+#define I830_UPLOAD_TEX2_CUBE		0x2000 /* handled clientside */
+#define I830_UPLOAD_TEX3_IMAGE		0x4000 /* handled clientside */
+#define I830_UPLOAD_TEX3_CUBE		0x8000 /* handled clientside */
+#define I830_UPLOAD_TEX_N_IMAGE(n)	(0x100 << (n * 2))
+#define I830_UPLOAD_TEX_N_CUBE(n)	(0x200 << (n * 2))
+#define I830_UPLOAD_TEXIMAGE_MASK	0xff00
+#define I830_UPLOAD_TEX0			0x10000
+#define I830_UPLOAD_TEX1			0x20000
+#define I830_UPLOAD_TEX2			0x40000
+#define I830_UPLOAD_TEX3			0x80000
+#define I830_UPLOAD_TEX_N(n)		(0x10000 << (n))
+#define I830_UPLOAD_TEX_MASK		0xf0000
+#define I830_UPLOAD_TEXBLEND0		0x100000
+#define I830_UPLOAD_TEXBLEND1		0x200000
+#define I830_UPLOAD_TEXBLEND2		0x400000
+#define I830_UPLOAD_TEXBLEND3		0x800000
+#define I830_UPLOAD_TEXBLEND_N(n)	(0x100000 << (n))
+#define I830_UPLOAD_TEXBLEND_MASK	0xf00000
+#define I830_UPLOAD_TEX_PALETTE_N(n)    (0x1000000 << (n))
+#define I830_UPLOAD_TEX_PALETTE_SHARED	0x4000000
+
+/* Indices into buf.Setup where various bits of state are mirrored per
+ * context and per buffer.  These can be fired at the card as a unit,
+ * or in a piecewise fashion as required.
+ */
+
+/* Destbuffer state 
+ *    - backbuffer linear offset and pitch -- invarient in the current dri
+ *    - zbuffer linear offset and pitch -- also invarient
+ *    - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
+ */
+
+#define I830_DESTREG_CBUFADDR 0
+/* Invarient */
+#define I830_DESTREG_DBUFADDR 1
+#define I830_DESTREG_DV0 2
+#define I830_DESTREG_DV1 3
+#define I830_DESTREG_SENABLE 4
+#define I830_DESTREG_SR0 5
+#define I830_DESTREG_SR1 6
+#define I830_DESTREG_SR2 7
+#define I830_DESTREG_DR0 8
+#define I830_DESTREG_DR1 9
+#define I830_DESTREG_DR2 10
+#define I830_DESTREG_DR3 11
+#define I830_DESTREG_DR4 12
+#define I830_DEST_SETUP_SIZE 13
+
+/* Context state
+ */
+#define I830_CTXREG_STATE1		0
+#define I830_CTXREG_STATE2		1
+#define I830_CTXREG_STATE3		2
+#define I830_CTXREG_STATE4		3
+#define I830_CTXREG_STATE5		4
+#define I830_CTXREG_IALPHAB		5
+#define I830_CTXREG_STENCILTST		6
+#define I830_CTXREG_ENABLES_1		7
+#define I830_CTXREG_ENABLES_2		8
+#define I830_CTXREG_AA			9
+#define I830_CTXREG_FOGCOLOR		10
+#define I830_CTXREG_BLENDCOLR0		11
+#define I830_CTXREG_BLENDCOLR		12 /* Dword 1 of 2 dword command */
+#define I830_CTXREG_VF			13
+#define I830_CTXREG_VF2			14
+#define I830_CTXREG_MCSB0		15
+#define I830_CTXREG_MCSB1		16
+#define I830_CTX_SETUP_SIZE		17
+
+/* Texture state (per tex unit)
+ */
+
+#define I830_TEXREG_MI0	0	/* GFX_OP_MAP_INFO (6 dwords) */
+#define I830_TEXREG_MI1	1
+#define I830_TEXREG_MI2	2
+#define I830_TEXREG_MI3	3
+#define I830_TEXREG_MI4	4
+#define I830_TEXREG_MI5	5
+#define I830_TEXREG_MF	6	/* GFX_OP_MAP_FILTER */
+#define I830_TEXREG_MLC	7	/* GFX_OP_MAP_LOD_CTL */
+#define I830_TEXREG_MLL	8	/* GFX_OP_MAP_LOD_LIMITS */
+#define I830_TEXREG_MCS	9	/* GFX_OP_MAP_COORD_SETS */
+#define I830_TEX_SETUP_SIZE 10
+
+#define I830_FRONT   0x1
+#define I830_BACK    0x2
+#define I830_DEPTH   0x4
+
+#endif /* _I830_DEFINES_ */
+
+typedef struct _drm_i830_init {
+	enum {
+		I830_INIT_DMA = 0x01,
+		I830_CLEANUP_DMA = 0x02
+	} func;
+	unsigned int mmio_offset;
+	unsigned int buffers_offset;
+	int sarea_priv_offset;
+	unsigned int ring_start;
+	unsigned int ring_end;
+	unsigned int ring_size;
+	unsigned int front_offset;
+	unsigned int back_offset;
+	unsigned int depth_offset;
+	unsigned int w;
+	unsigned int h;
+	unsigned int pitch;
+	unsigned int pitch_bits;
+	unsigned int back_pitch;
+	unsigned int depth_pitch;
+	unsigned int cpp;
+} drm_i830_init_t;
+
+/* Warning: If you change the SAREA structure you must change the Xserver
+ * structure as well */
+
+typedef struct _drm_i830_tex_region {
+	unsigned char next, prev; /* indices to form a circular LRU  */
+	unsigned char in_use;	/* owned by a client, or free? */
+	int age;		/* tracked by clients to update local LRU's */
+} drm_i830_tex_region_t;
+
+typedef struct _drm_i830_sarea {
+	unsigned int ContextState[I830_CTX_SETUP_SIZE];
+   	unsigned int BufferState[I830_DEST_SETUP_SIZE];
+	unsigned int TexState[I830_TEXTURE_COUNT][I830_TEX_SETUP_SIZE];
+	unsigned int TexBlendState[I830_TEXBLEND_COUNT][I830_TEXBLEND_SIZE];
+	unsigned int TexBlendStateWordsUsed[I830_TEXBLEND_COUNT];
+	unsigned int Palette[2][256];
+   	unsigned int dirty;
+
+	unsigned int nbox;
+	drm_clip_rect_t boxes[I830_NR_SAREA_CLIPRECTS];
+
+	/* Maintain an LRU of contiguous regions of texture space.  If
+	 * you think you own a region of texture memory, and it has an
+	 * age different to the one you set, then you are mistaken and
+	 * it has been stolen by another client.  If global texAge
+	 * hasn't changed, there is no need to walk the list.
+	 *
+	 * These regions can be used as a proxy for the fine-grained
+	 * texture information of other clients - by maintaining them
+	 * in the same lru which is used to age their own textures,
+	 * clients have an approximate lru for the whole of global
+	 * texture space, and can make informed decisions as to which
+	 * areas to kick out.  There is no need to choose whether to
+	 * kick out your own texture or someone else's - simply eject
+	 * them all in LRU order.  
+	 */
+
+	drm_i830_tex_region_t texList[I830_NR_TEX_REGIONS+1]; 
+				/* Last elt is sentinal */
+        int texAge;		/* last time texture was uploaded */
+        int last_enqueue;	/* last time a buffer was enqueued */
+	int last_dispatch;	/* age of the most recently dispatched buffer */
+	int last_quiescent;     /*  */
+	int ctxOwner;		/* last context to upload state */
+
+	int vertex_prim;
+} drm_i830_sarea_t;
+
+typedef struct _drm_i830_clear {
+	int clear_color;
+	int clear_depth;
+	int flags;
+	unsigned int clear_colormask;
+	unsigned int clear_depthmask;
+} drm_i830_clear_t;
+
+
+
+/* These may be placeholders if we have more cliprects than
+ * I830_NR_SAREA_CLIPRECTS.  In that case, the client sets discard to
+ * false, indicating that the buffer will be dispatched again with a
+ * new set of cliprects.
+ */
+typedef struct _drm_i830_vertex {
+   	int idx;		/* buffer index */
+	int used;		/* nr bytes in use */
+	int discard;		/* client is finished with the buffer? */
+} drm_i830_vertex_t;
+
+typedef struct _drm_i830_copy_t {
+   	int idx;		/* buffer index */
+	int used;		/* nr bytes in use */
+	void *address;		/* Address to copy from */
+} drm_i830_copy_t;
+
+typedef struct drm_i830_dma {
+	void *virtual;
+	int request_idx;
+	int request_size;
+	int granted;
+} drm_i830_dma_t;
+
+#endif /* _I830_DRM_H_ */
diff -Nru a/drivers/char/drm/i830_drv.c b/drivers/char/drm/i830_drv.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/i830_drv.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,102 @@
+/* i830_drv.c -- I810 driver -*- linux-c -*-
+ * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Rickard E. (Rik) Faith <faith@valinux.com>
+ *    Jeff Hartmann <jhartmann@valinux.com>
+ *    Gareth Hughes <gareth@valinux.com>
+ *    Abraham vd Merwe <abraham@2d3d.co.za>
+ */
+
+#include <linux/config.h>
+#include "i830.h"
+#include "drmP.h"
+#include "i830_drv.h"
+
+#define DRIVER_AUTHOR		"VA Linux Systems Inc."
+
+#define DRIVER_NAME		"i830"
+#define DRIVER_DESC		"Intel 830M"
+#define DRIVER_DATE		"20011004"
+
+#define DRIVER_MAJOR		1
+#define DRIVER_MINOR		2
+#define DRIVER_PATCHLEVEL	0
+
+#define DRIVER_IOCTLS							    \
+	[DRM_IOCTL_NR(DRM_IOCTL_I830_INIT)]   = { i830_dma_init,    1, 1 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_VERTEX)] = { i830_dma_vertex,  1, 0 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_CLEAR)]  = { i830_clear_bufs,  1, 0 }, \
+      	[DRM_IOCTL_NR(DRM_IOCTL_I830_FLUSH)]  = { i830_flush_ioctl, 1, 0 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_GETAGE)] = { i830_getage,      1, 0 }, \
+	[DRM_IOCTL_NR(DRM_IOCTL_I830_GETBUF)] = { i830_getbuf,      1, 0 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_SWAP)]   = { i830_swap_bufs,   1, 0 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_COPY)]   = { i830_copybuf,     1, 0 }, \
+   	[DRM_IOCTL_NR(DRM_IOCTL_I830_DOCOPY)] = { i830_docopy,      1, 0 },
+
+#define __HAVE_COUNTERS         4
+#define __HAVE_COUNTER6         _DRM_STAT_IRQ
+#define __HAVE_COUNTER7         _DRM_STAT_PRIMARY
+#define __HAVE_COUNTER8         _DRM_STAT_SECONDARY
+#define __HAVE_COUNTER9         _DRM_STAT_DMA
+
+
+#include "drm_agpsupport.h"
+#include "drm_auth.h"
+#include "drm_bufs.h"
+#include "drm_context.h"
+#include "drm_dma.h"
+#include "drm_drawable.h"
+#include "drm_drv.h"
+
+#ifndef MODULE
+/* DRM(options) is called by the kernel to parse command-line options
+ * passed via the boot-loader (e.g., LILO).  It calls the insmod option
+ * routine, drm_parse_drm.
+ */
+
+/* JH- We have to hand expand the string ourselves because of the cpp.  If
+ * anyone can think of a way that we can fit into the __setup macro without
+ * changing it, then please send the solution my way.
+ */
+static int __init i830_options( char *str )
+{
+   DRM(parse_options)( str );
+   return 1;
+}
+
+__setup( DRIVER_NAME "=", i830_options );
+#endif
+
+#include "drm_fops.h"
+#include "drm_init.h"
+#include "drm_ioctl.h"
+#include "drm_lock.h"
+#include "drm_lists.h"
+#include "drm_memory.h"
+#include "drm_proc.h"
+#include "drm_vm.h"
+#include "drm_stub.h"
diff -Nru a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/i830_drv.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,213 @@
+/* i830_drv.h -- Private header for the I830 driver -*- linux-c -*-
+ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * 	    Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#ifndef _I830_DRV_H_
+#define _I830_DRV_H_
+
+typedef struct drm_i830_buf_priv {
+   	u32 *in_use;
+   	int my_use_idx;
+	int currently_mapped;
+	void *virtual;
+	void *kernel_virtual;
+	int map_count;
+   	struct vm_area_struct *vma;
+} drm_i830_buf_priv_t;
+
+typedef struct _drm_i830_ring_buffer{
+	int tail_mask;
+	unsigned long Start;
+	unsigned long End;
+	unsigned long Size;
+	u8 *virtual_start;
+	int head;
+	int tail;
+	int space;
+} drm_i830_ring_buffer_t;
+
+typedef struct drm_i830_private {
+	drm_map_t *sarea_map;
+	drm_map_t *buffer_map;
+	drm_map_t *mmio_map;
+
+	drm_i830_sarea_t *sarea_priv;
+   	drm_i830_ring_buffer_t ring;
+
+      	unsigned long hw_status_page;
+   	unsigned long counter;
+
+   	atomic_t flush_done;
+   	wait_queue_head_t flush_queue;	/* Processes waiting until flush    */
+	drm_buf_t *mmap_buffer;
+	
+	u32 front_di1, back_di1, zi1;
+	
+	int back_offset;
+	int depth_offset;
+	int w, h;
+	int pitch;
+	int back_pitch;
+	int depth_pitch;
+	unsigned int cpp;
+} drm_i830_private_t;
+
+				/* i830_dma.c */
+extern int  i830_dma_schedule(drm_device_t *dev, int locked);
+extern int  i830_getbuf(struct inode *inode, struct file *filp,
+			unsigned int cmd, unsigned long arg);
+extern int  i830_dma_init(struct inode *inode, struct file *filp,
+			  unsigned int cmd, unsigned long arg);
+extern int  i830_flush_ioctl(struct inode *inode, struct file *filp,
+			     unsigned int cmd, unsigned long arg);
+extern void i830_reclaim_buffers(drm_device_t *dev, pid_t pid);
+extern int  i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
+			unsigned long arg);
+extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
+extern int i830_copybuf(struct inode *inode, struct file *filp, 
+			unsigned int cmd, unsigned long arg);
+extern int i830_docopy(struct inode *inode, struct file *filp, 
+		       unsigned int cmd, unsigned long arg);
+
+extern void i830_dma_quiescent(drm_device_t *dev);
+
+extern int i830_dma_vertex(struct inode *inode, struct file *filp,
+			  unsigned int cmd, unsigned long arg);
+
+extern int i830_swap_bufs(struct inode *inode, struct file *filp,
+			 unsigned int cmd, unsigned long arg);
+
+extern int i830_clear_bufs(struct inode *inode, struct file *filp,
+			  unsigned int cmd, unsigned long arg);
+
+#define I830_VERBOSE 0
+
+#define I830_BASE(reg)		((unsigned long) \
+				dev_priv->mmio_map->handle)
+#define I830_ADDR(reg)		(I830_BASE(reg) + reg)
+#define I830_DEREF(reg)		*(__volatile__ int *)I830_ADDR(reg)
+#define I830_READ(reg)		I830_DEREF(reg)
+#define I830_WRITE(reg,val) 	do { I830_DEREF(reg) = val; } while (0)
+#define I830_DEREF16(reg)	*(__volatile__ u16 *)I830_ADDR(reg)
+#define I830_READ16(reg) 	I830_DEREF16(reg)
+#define I830_WRITE16(reg,val)	do { I830_DEREF16(reg) = val; } while (0)
+
+#define GFX_OP_USER_INTERRUPT 		((0<<29)|(2<<23))
+#define GFX_OP_BREAKPOINT_INTERRUPT	((0<<29)|(1<<23))
+#define CMD_REPORT_HEAD			(7<<23)
+#define CMD_STORE_DWORD_IDX		((0x21<<23) | 0x1)
+#define CMD_OP_BATCH_BUFFER  ((0x0<<29)|(0x30<<23)|0x1)
+
+#define INST_PARSER_CLIENT   0x00000000
+#define INST_OP_FLUSH        0x02000000
+#define INST_FLUSH_MAP_CACHE 0x00000001
+
+
+#define BB1_START_ADDR_MASK   (~0x7)
+#define BB1_PROTECTED         (1<<0)
+#define BB1_UNPROTECTED       (0<<0)
+#define BB2_END_ADDR_MASK     (~0x7)
+
+#define I830REG_HWSTAM		0x02098
+#define I830REG_INT_IDENTITY_R	0x020a4
+#define I830REG_INT_MASK_R 	0x020a8
+#define I830REG_INT_ENABLE_R	0x020a0
+
+#define LP_RING     		0x2030
+#define HP_RING     		0x2040
+#define RING_TAIL      		0x00
+#define TAIL_ADDR		0x000FFFF8
+#define RING_HEAD      		0x04
+#define HEAD_WRAP_COUNT     	0xFFE00000
+#define HEAD_WRAP_ONE       	0x00200000
+#define HEAD_ADDR           	0x001FFFFC
+#define RING_START     		0x08
+#define START_ADDR          	0x00FFFFF8
+#define RING_LEN       		0x0C
+#define RING_NR_PAGES       	0x000FF000 
+#define RING_REPORT_MASK    	0x00000006
+#define RING_REPORT_64K     	0x00000002
+#define RING_REPORT_128K    	0x00000004
+#define RING_NO_REPORT      	0x00000000
+#define RING_VALID_MASK     	0x00000001
+#define RING_VALID          	0x00000001
+#define RING_INVALID        	0x00000000
+
+#define GFX_OP_SCISSOR         ((0x3<<29)|(0x1c<<24)|(0x10<<19))
+#define SC_UPDATE_SCISSOR       (0x1<<1)
+#define SC_ENABLE_MASK          (0x1<<0)
+#define SC_ENABLE               (0x1<<0)
+
+#define GFX_OP_SCISSOR_INFO    ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
+#define SCI_YMIN_MASK      (0xffff<<16)
+#define SCI_XMIN_MASK      (0xffff<<0)
+#define SCI_YMAX_MASK      (0xffff<<16)
+#define SCI_XMAX_MASK      (0xffff<<0)
+
+#define GFX_OP_SCISSOR_ENABLE	 ((0x3<<29)|(0x1c<<24)|(0x10<<19))
+#define GFX_OP_SCISSOR_RECT	 ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
+#define GFX_OP_COLOR_FACTOR      ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
+#define GFX_OP_STIPPLE           ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define GFX_OP_MAP_INFO          ((0x3<<29)|(0x1d<<24)|0x4)
+#define GFX_OP_DESTBUFFER_VARS   ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
+#define GFX_OP_DRAWRECT_INFO     ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
+#define GFX_OP_PRIMITIVE         ((0x3<<29)|(0x1f<<24))
+
+#define CMD_OP_DESTBUFFER_INFO	 ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
+
+
+#define BR00_BITBLT_CLIENT   0x40000000
+#define BR00_OP_COLOR_BLT    0x10000000
+#define BR00_OP_SRC_COPY_BLT 0x10C00000
+#define BR13_SOLID_PATTERN   0x80000000
+
+#define BUF_3D_ID_COLOR_BACK    (0x3<<24)
+#define BUF_3D_ID_DEPTH         (0x7<<24)
+#define BUF_3D_USE_FENCE        (1<<23)
+#define BUF_3D_PITCH(x)         (((x)/4)<<2)
+
+#define CMD_OP_MAP_PALETTE_LOAD	((3<<29)|(0x1d<<24)|(0x82<<16)|255)
+#define MAP_PALETTE_NUM(x)	((x<<8) & (1<<8))
+#define MAP_PALETTE_BOTH	(1<<11)
+
+#define XY_COLOR_BLT_CMD		((2<<29)|(0x50<<22)|0x4)
+#define XY_COLOR_BLT_WRITE_ALPHA	(1<<21)
+#define XY_COLOR_BLT_WRITE_RGB		(1<<20)
+
+#define XY_SRC_COPY_BLT_CMD             ((2<<29)|(0x53<<22)|6)
+#define XY_SRC_COPY_BLT_WRITE_ALPHA     (1<<21)
+#define XY_SRC_COPY_BLT_WRITE_RGB       (1<<20)
+
+#define MI_BATCH_BUFFER 	((0x30<<23)|1)
+#define MI_BATCH_NON_SECURE	(1)
+
+
+#endif
+
diff -Nru a/drivers/char/drm/mga_state.c b/drivers/char/drm/mga_state.c
--- a/drivers/char/drm/mga_state.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/drm/mga_state.c	Fri May 24 18:55:35 2002
@@ -163,6 +163,9 @@
 	drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[0];
 	DMA_LOCALS;
 
+/*  	printk("mga_g400_emit_tex0 %x %x %x\n", tex->texorg, */
+/*  	       tex->texctl, tex->texctl2); */
+
 	BEGIN_DMA( 6 );
 
 	DMA_BLOCK( MGA_TEXCTL2,		tex->texctl2 | MGA_G400_TC2_MAGIC,
@@ -204,6 +207,9 @@
 	drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[1];
 	DMA_LOCALS;
 
+/*  	printk("mga_g400_emit_tex1 %x %x %x\n", tex->texorg,  */
+/*  	       tex->texctl, tex->texctl2); */
+
 	BEGIN_DMA( 5 );
 
 	DMA_BLOCK( MGA_TEXCTL2,		(tex->texctl2 |
@@ -271,6 +277,8 @@
 	drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
 	unsigned int pipe = sarea_priv->warp_pipe;
 	DMA_LOCALS;
+
+/*  	printk("mga_g400_emit_pipe %x\n", pipe); */
 
 	BEGIN_DMA( 10 );
 
diff -Nru a/drivers/char/drm/r128_drv.c b/drivers/char/drm/r128_drv.c
--- a/drivers/char/drm/r128_drv.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/r128_drv.c	Fri May 24 18:55:34 2002
@@ -39,11 +39,11 @@
 
 #define DRIVER_NAME		"r128"
 #define DRIVER_DESC		"ATI Rage 128"
-#define DRIVER_DATE		"20010405"
+#define DRIVER_DATE		"20010917"
 
 #define DRIVER_MAJOR		2
-#define DRIVER_MINOR		1
-#define DRIVER_PATCHLEVEL	6
+#define DRIVER_MINOR		2
+#define DRIVER_PATCHLEVEL	0
 
 #define DRIVER_IOCTLS							    \
    [DRM_IOCTL_NR(DRM_IOCTL_DMA)]             = { r128_cce_buffers,  1, 0 }, \
diff -Nru a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c
--- a/drivers/char/drm/r128_state.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/r128_state.c	Fri May 24 18:55:34 2002
@@ -1519,10 +1519,75 @@
 {
 	drm_file_t *priv = filp->private_data;
 	drm_device_t *dev = priv->dev;
+	drm_r128_private_t *dev_priv = dev->dev_private;
+	drm_device_dma_t *dma = dev->dma;
+	drm_buf_t *buf;
+	drm_r128_buf_priv_t *buf_priv;
+	drm_r128_indirect_t indirect;
+#if 0
+	RING_LOCALS;
+#endif
 
 	LOCK_TEST_WITH_RETURN( dev );
 
-	/* Indirect buffer firing is not supported at this time.
+	if ( !dev_priv ) {
+		DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
+		return -EINVAL;
+	}
+
+	if ( copy_from_user( &indirect, (drm_r128_indirect_t *)arg,
+			     sizeof(indirect) ) )
+		return -EFAULT;
+
+	DRM_DEBUG( "indirect: idx=%d s=%d e=%d d=%d\n",
+		   indirect.idx, indirect.start,
+		   indirect.end, indirect.discard );
+
+	if ( indirect.idx < 0 || indirect.idx >= dma->buf_count ) {
+		DRM_ERROR( "buffer index %d (of %d max)\n",
+			   indirect.idx, dma->buf_count - 1 );
+		return -EINVAL;
+	}
+
+	buf = dma->buflist[indirect.idx];
+	buf_priv = buf->dev_private;
+
+	if ( buf->pid != current->pid ) {
+		DRM_ERROR( "process %d using buffer owned by %d\n",
+			   current->pid, buf->pid );
+		return -EINVAL;
+	}
+	if ( buf->pending ) {
+		DRM_ERROR( "sending pending buffer %d\n", indirect.idx );
+		return -EINVAL;
+	}
+
+	if ( indirect.start < buf->used ) {
+		DRM_ERROR( "reusing indirect: start=0x%x actual=0x%x\n",
+			   indirect.start, buf->used );
+		return -EINVAL;
+	}
+
+	RING_SPACE_TEST_WITH_RETURN( dev_priv );
+	VB_AGE_TEST_WITH_RETURN( dev_priv );
+
+	buf->used = indirect.end;
+	buf_priv->discard = indirect.discard;
+
+#if 0
+	/* Wait for the 3D stream to idle before the indirect buffer
+	 * containing 2D acceleration commands is processed.
 	 */
-	return -EINVAL;
+	BEGIN_RING( 2 );
+	RADEON_WAIT_UNTIL_3D_IDLE();
+	ADVANCE_RING();
+#endif
+
+	/* Dispatch the indirect buffer full of commands from the
+	 * X server.  This is insecure and is thus only available to
+	 * privileged clients.
+	 */
+	r128_cce_dispatch_indirect( dev, buf, indirect.start, indirect.end );
+
+	return 0;
 }
diff -Nru a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
--- a/drivers/char/drm/radeon_cp.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/radeon_cp.c	Fri May 24 18:55:34 2002
@@ -744,17 +744,17 @@
 	 * and screwing with the clear operation.
 	 */
 	dev_priv->depth_clear.rb3d_cntl = (RADEON_PLANE_MASK_ENABLE |
-					   RADEON_Z_ENABLE |
 					   (dev_priv->color_fmt << 10) |
-					   RADEON_ZBLOCK16);
+					   (1<<15));
 
-	dev_priv->depth_clear.rb3d_zstencilcntl = (dev_priv->depth_fmt |
-						   RADEON_Z_TEST_ALWAYS |
-						   RADEON_STENCIL_TEST_ALWAYS |
-						   RADEON_STENCIL_S_FAIL_KEEP |
-						   RADEON_STENCIL_ZPASS_KEEP |
-						   RADEON_STENCIL_ZFAIL_KEEP |
-						   RADEON_Z_WRITE_ENABLE);
+	dev_priv->depth_clear.rb3d_zstencilcntl = 
+		(dev_priv->depth_fmt |
+		 RADEON_Z_TEST_ALWAYS |
+		 RADEON_STENCIL_TEST_ALWAYS |
+		 RADEON_STENCIL_S_FAIL_REPLACE |
+		 RADEON_STENCIL_ZPASS_REPLACE |
+		 RADEON_STENCIL_ZFAIL_REPLACE |
+		 RADEON_Z_WRITE_ENABLE);
 
 	dev_priv->depth_clear.se_cntl = (RADEON_FFACE_CULL_CW |
 					 RADEON_BFACE_SOLID |
@@ -964,9 +964,7 @@
 	radeon_cp_load_microcode( dev_priv );
 	radeon_cp_init_ring_buffer( dev, dev_priv );
 
-#if ROTATE_BUFS
 	dev_priv->last_buf = 0;
-#endif
 
 	dev->dev_private = (void *)dev_priv;
 
@@ -1146,116 +1144,27 @@
  * Fullscreen mode
  */
 
-static int radeon_do_init_pageflip( drm_device_t *dev )
-{
-	drm_radeon_private_t *dev_priv = dev->dev_private;
-	DRM_DEBUG( "%s\n", __FUNCTION__ );
-
-	dev_priv->crtc_offset =      RADEON_READ( RADEON_CRTC_OFFSET );
-	dev_priv->crtc_offset_cntl = RADEON_READ( RADEON_CRTC_OFFSET_CNTL );
-
-	RADEON_WRITE( RADEON_CRTC_OFFSET, dev_priv->front_offset );
-	RADEON_WRITE( RADEON_CRTC_OFFSET_CNTL,
-		      dev_priv->crtc_offset_cntl |
-		      RADEON_CRTC_OFFSET_FLIP_CNTL );
-
-	dev_priv->page_flipping = 1;
-	dev_priv->current_page = 0;
-
-	return 0;
-}
-
-int radeon_do_cleanup_pageflip( drm_device_t *dev )
-{
-	drm_radeon_private_t *dev_priv = dev->dev_private;
-	DRM_DEBUG( "%s\n", __FUNCTION__ );
-
-	RADEON_WRITE( RADEON_CRTC_OFFSET,      dev_priv->crtc_offset );
-	RADEON_WRITE( RADEON_CRTC_OFFSET_CNTL, dev_priv->crtc_offset_cntl );
-
-	dev_priv->page_flipping = 0;
-	dev_priv->current_page = 0;
-
-	return 0;
-}
-
+/* KW: Deprecated to say the least:
+ */
 int radeon_fullscreen( struct inode *inode, struct file *filp,
 		       unsigned int cmd, unsigned long arg )
 {
-        drm_file_t *priv = filp->private_data;
-        drm_device_t *dev = priv->dev;
-	drm_radeon_fullscreen_t fs;
-
-	LOCK_TEST_WITH_RETURN( dev );
-
-	if ( copy_from_user( &fs, (drm_radeon_fullscreen_t *)arg,
-			     sizeof(fs) ) )
-		return -EFAULT;
-
-	switch ( fs.func ) {
-	case RADEON_INIT_FULLSCREEN:
-		return radeon_do_init_pageflip( dev );
-	case RADEON_CLEANUP_FULLSCREEN:
-		return radeon_do_cleanup_pageflip( dev );
-	}
-
-	return -EINVAL;
+	return 0;
 }
 
 
 /* ================================================================
  * Freelist management
  */
-#define RADEON_BUFFER_USED	0xffffffff
-#define RADEON_BUFFER_FREE	0
 
-#if 0
-static int radeon_freelist_init( drm_device_t *dev )
-{
-	drm_device_dma_t *dma = dev->dma;
-	drm_radeon_private_t *dev_priv = dev->dev_private;
-	drm_buf_t *buf;
-	drm_radeon_buf_priv_t *buf_priv;
-	drm_radeon_freelist_t *entry;
-	int i;
-
-	dev_priv->head = DRM(alloc)( sizeof(drm_radeon_freelist_t),
-				     DRM_MEM_DRIVER );
-	if ( dev_priv->head == NULL )
-		return -ENOMEM;
-
-	memset( dev_priv->head, 0, sizeof(drm_radeon_freelist_t) );
-	dev_priv->head->age = RADEON_BUFFER_USED;
-
-	for ( i = 0 ; i < dma->buf_count ; i++ ) {
-		buf = dma->buflist[i];
-		buf_priv = buf->dev_private;
-
-		entry = DRM(alloc)( sizeof(drm_radeon_freelist_t),
-				    DRM_MEM_DRIVER );
-		if ( !entry ) return -ENOMEM;
-
-		entry->age = RADEON_BUFFER_FREE;
-		entry->buf = buf;
-		entry->prev = dev_priv->head;
-		entry->next = dev_priv->head->next;
-		if ( !entry->next )
-			dev_priv->tail = entry;
-
-		buf_priv->discard = 0;
-		buf_priv->dispatched = 0;
-		buf_priv->list_entry = entry;
-
-		dev_priv->head->next = entry;
-
-		if ( dev_priv->head->next )
-			dev_priv->head->next->prev = entry;
-	}
-
-	return 0;
-
-}
-#endif
+/* Original comment: FIXME: ROTATE_BUFS is a hack to cycle through
+ *   bufs until freelist code is used.  Note this hides a problem with
+ *   the scratch register * (used to keep track of last buffer
+ *   completed) being written to before * the last buffer has actually
+ *   completed rendering.  
+ *
+ * KW:  It's also a good way to find free buffers quickly.
+ */
 
 drm_buf_t *radeon_freelist_get( drm_device_t *dev )
 {
@@ -1264,57 +1173,24 @@
 	drm_radeon_buf_priv_t *buf_priv;
 	drm_buf_t *buf;
 	int i, t;
-#if ROTATE_BUFS
 	int start;
-#endif
-
-	/* FIXME: Optimize -- use freelist code */
-
-	for ( i = 0 ; i < dma->buf_count ; i++ ) {
-		buf = dma->buflist[i];
-		buf_priv = buf->dev_private;
-		if ( buf->pid == 0 ) {
-			DRM_DEBUG( "  ret buf=%d last=%d pid=0\n",
-				   buf->idx, dev_priv->last_buf );
-			return buf;
-		}
-		DRM_DEBUG( "    skipping buf=%d pid=%d\n",
-			   buf->idx, buf->pid );
-	}
 
-#if ROTATE_BUFS
 	if ( ++dev_priv->last_buf >= dma->buf_count )
 		dev_priv->last_buf = 0;
+
 	start = dev_priv->last_buf;
-#endif
+
 	for ( t = 0 ; t < dev_priv->usec_timeout ; t++ ) {
-#if 0
-		/* FIXME: Disable this for now */
-		u32 done_age = dev_priv->scratch[RADEON_LAST_DISPATCH];
-#else
 		u32 done_age = RADEON_READ( RADEON_LAST_DISPATCH_REG );
-#endif
-#if ROTATE_BUFS
 		for ( i = start ; i < dma->buf_count ; i++ ) {
-#else
-		for ( i = 0 ; i < dma->buf_count ; i++ ) {
-#endif
 			buf = dma->buflist[i];
 			buf_priv = buf->dev_private;
-			if ( buf->pending && buf_priv->age <= done_age ) {
-				/* The buffer has been processed, so it
-				 * can now be used.
-				 */
+			if ( buf->pid == 0 || (buf->pending && 
+					       buf_priv->age <= done_age) ) {
 				buf->pending = 0;
-				DRM_DEBUG( "  ret buf=%d last=%d age=%d done=%d\n", buf->idx, dev_priv->last_buf, buf_priv->age, done_age );
 				return buf;
 			}
-			DRM_DEBUG( "    skipping buf=%d age=%d done=%d\n",
-				   buf->idx, buf_priv->age,
-				   done_age );
-#if ROTATE_BUFS
 			start = 0;
-#endif
 		}
 		udelay( 1 );
 	}
@@ -1326,14 +1202,10 @@
 void radeon_freelist_reset( drm_device_t *dev )
 {
 	drm_device_dma_t *dma = dev->dma;
-#if ROTATE_BUFS
 	drm_radeon_private_t *dev_priv = dev->dev_private;
-#endif
 	int i;
 
-#if ROTATE_BUFS
 	dev_priv->last_buf = 0;
-#endif
 	for ( i = 0 ; i < dma->buf_count ; i++ ) {
 		drm_buf_t *buf = dma->buflist[i];
 		drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
diff -Nru a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
--- a/drivers/char/drm/radeon_drm.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/radeon_drm.h	Fri May 24 18:55:36 2002
@@ -2,6 +2,7 @@
  *
  * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
  * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
+ * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +27,7 @@
  * Authors:
  *    Kevin E. Martin <martin@valinux.com>
  *    Gareth Hughes <gareth@valinux.com>
+ *    Keith Whitwell <keith_whitwell@yahoo.com>
  */
 
 #ifndef __RADEON_DRM_H__
@@ -37,7 +39,8 @@
 #ifndef __RADEON_SAREA_DEFINES__
 #define __RADEON_SAREA_DEFINES__
 
-/* What needs to be changed for the current vertex buffer?
+/* Old style state flags, required for sarea interface (1.1 and 1.2
+ * clears) and 1.2 drm_vertex2 ioctl.
  */
 #define RADEON_UPLOAD_CONTEXT		0x00000001
 #define RADEON_UPLOAD_VERTFMT		0x00000002
@@ -56,11 +59,74 @@
 #define RADEON_UPLOAD_TEX2IMAGES	0x00004000
 #define RADEON_UPLOAD_CLIPRECTS		0x00008000 /* handled client-side */
 #define RADEON_REQUIRE_QUIESCENCE	0x00010000
-#define RADEON_UPLOAD_ALL		0x0001ffff
+#define RADEON_UPLOAD_ZBIAS		0x00020000 /* version 1.2 and newer */
+#define RADEON_UPLOAD_ALL		0x003effff
+#define RADEON_UPLOAD_CONTEXT_ALL       0x003e01ff
+
+
+/* New style per-packet identifiers for use in cmd_buffer ioctl with
+ * the RADEON_EMIT_PACKET command.  Comments relate new packets to old
+ * state bits and the packet size:
+ */
+#define RADEON_EMIT_PP_MISC                         0 /* context/7 */
+#define RADEON_EMIT_PP_CNTL                         1 /* context/3 */
+#define RADEON_EMIT_RB3D_COLORPITCH                 2 /* context/1 */
+#define RADEON_EMIT_RE_LINE_PATTERN                 3 /* line/2 */
+#define RADEON_EMIT_SE_LINE_WIDTH                   4 /* line/1 */
+#define RADEON_EMIT_PP_LUM_MATRIX                   5 /* bumpmap/1 */
+#define RADEON_EMIT_PP_ROT_MATRIX_0                 6 /* bumpmap/2 */
+#define RADEON_EMIT_RB3D_STENCILREFMASK             7 /* masks/3 */
+#define RADEON_EMIT_SE_VPORT_XSCALE                 8 /* viewport/6 */
+#define RADEON_EMIT_SE_CNTL                         9 /* setup/2 */
+#define RADEON_EMIT_SE_CNTL_STATUS                  10 /* setup/1 */
+#define RADEON_EMIT_RE_MISC                         11 /* misc/1 */
+#define RADEON_EMIT_PP_TXFILTER_0                   12 /* tex0/6 */
+#define RADEON_EMIT_PP_BORDER_COLOR_0               13 /* tex0/1 */
+#define RADEON_EMIT_PP_TXFILTER_1                   14 /* tex1/6 */
+#define RADEON_EMIT_PP_BORDER_COLOR_1               15 /* tex1/1 */
+#define RADEON_EMIT_PP_TXFILTER_2                   16 /* tex2/6 */
+#define RADEON_EMIT_PP_BORDER_COLOR_2               17 /* tex2/1 */
+#define RADEON_EMIT_SE_ZBIAS_FACTOR                 18 /* zbias/2 */
+#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT           19 /* tcl/11 */
+#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED   20 /* material/17 */
+#define RADEON_MAX_STATE_PACKETS                    21
+
+
+/* Commands understood by cmd_buffer ioctl.  More can be added but
+ * obviously these can't be removed or changed:
+ */
+#define RADEON_CMD_PACKET      1 /* emit one of the register packets above */
+#define RADEON_CMD_SCALARS     2 /* emit scalar data */
+#define RADEON_CMD_VECTORS     3 /* emit vector data */
+#define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */
+#define RADEON_CMD_PACKET3     5 /* emit hw packet */
+#define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */
+
+
+typedef union {
+	int i;
+	struct { 
+		char cmd_type, pad0, pad1, pad2;
+	} header;
+	struct { 
+		char cmd_type, packet_id, pad0, pad1;
+	} packet;
+	struct { 
+		char cmd_type, offset, stride, count; 
+	} scalars;
+	struct { 
+		char cmd_type, offset, stride, count; 
+	} vectors;
+	struct { 
+		char cmd_type, buf_idx, pad0, pad1; 
+	} dma;
+} drm_radeon_cmd_header_t;
+
 
 #define RADEON_FRONT			0x1
 #define RADEON_BACK			0x2
 #define RADEON_DEPTH			0x4
+#define RADEON_STENCIL                  0x8
 
 /* Primitive types
  */
@@ -78,12 +144,9 @@
 /* Byte offsets for indirect buffer data
  */
 #define RADEON_INDEX_PRIM_OFFSET	20
-#define RADEON_HOSTDATA_BLIT_OFFSET	32
 
 #define RADEON_SCRATCH_REG_OFFSET	32
 
-/* Keep these small for testing
- */
 #define RADEON_NR_SAREA_CLIPRECTS	12
 
 /* There are 2 heaps (local/AGP).  Each region within a heap is a
@@ -95,7 +158,7 @@
 #define RADEON_NR_TEX_REGIONS		64
 #define RADEON_LOG_TEX_GRANULARITY	16
 
-#define RADEON_MAX_TEXTURE_LEVELS	11
+#define RADEON_MAX_TEXTURE_LEVELS	12
 #define RADEON_MAX_TEXTURE_UNITS	3
 
 #endif /* __RADEON_SAREA_DEFINES__ */
@@ -155,28 +218,18 @@
 	/* Setup state */
 	unsigned int se_cntl_status;			/* 0x2140 */
 
-#ifdef TCL_ENABLE
-	/* TCL state */
-	radeon_color_regs_t se_tcl_material_emmissive;	/* 0x2210 */
-	radeon_color_regs_t se_tcl_material_ambient;
-	radeon_color_regs_t se_tcl_material_diffuse;
-	radeon_color_regs_t se_tcl_material_specular;
-	unsigned int se_tcl_shininess;
-	unsigned int se_tcl_output_vtx_fmt;
-	unsigned int se_tcl_output_vtx_sel;
-	unsigned int se_tcl_matrix_select_0;
-	unsigned int se_tcl_matrix_select_1;
-	unsigned int se_tcl_ucp_vert_blend_ctl;
-	unsigned int se_tcl_texture_proc_ctl;
-	unsigned int se_tcl_light_model_ctl;
-	unsigned int se_tcl_per_light_ctl[4];
-#endif
-
 	/* Misc state */
 	unsigned int re_top_left;			/* 0x26c0 */
 	unsigned int re_misc;
 } drm_radeon_context_regs_t;
 
+typedef struct {
+	/* Zbias state */
+	unsigned int se_zbias_factor;			/* 0x1dac */
+	unsigned int se_zbias_constant;
+} drm_radeon_context2_regs_t;
+
+
 /* Setup registers for each texture unit
  */
 typedef struct {
@@ -186,24 +239,37 @@
 	unsigned int pp_txcblend;
 	unsigned int pp_txablend;
 	unsigned int pp_tfactor;
-
 	unsigned int pp_border_color;
-
-#ifdef CUBIC_ENABLE
-	unsigned int pp_cubic_faces;
-	unsigned int pp_cubic_offset[5];
-#endif
 } drm_radeon_texture_regs_t;
 
 typedef struct {
+	unsigned int start;
+	unsigned int finish;
+	unsigned int prim:8;
+	unsigned int stateidx:8;
+	unsigned int numverts:16; /* overloaded as offset/64 for elt prims */
+        unsigned int vc_format;   /* vertex format */
+} drm_radeon_prim_t;
+
+
+typedef struct {
+	drm_radeon_context_regs_t context;
+	drm_radeon_texture_regs_t tex[RADEON_MAX_TEXTURE_UNITS];
+	drm_radeon_context2_regs_t context2;
+	unsigned int dirty;
+} drm_radeon_state_t;
+
+
+typedef struct {
 	unsigned char next, prev;
 	unsigned char in_use;
 	int age;
 } drm_radeon_tex_region_t;
 
 typedef struct {
-	/* The channel for communication of state information to the kernel
-	 * on firing a vertex buffer.
+	/* The channel for communication of state information to the
+	 * kernel on firing a vertex buffer with either of the
+	 * obsoleted vertex/index ioctls.
 	 */
 	drm_radeon_context_regs_t context_state;
 	drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
@@ -225,11 +291,15 @@
 	drm_radeon_tex_region_t tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS+1];
 	int tex_age[RADEON_NR_TEX_HEAPS];
 	int ctx_owner;
+        int pfState;                /* number of 3d windows (0,1,2ormore) */
+        int pfCurrentPage;	    /* which buffer is being displayed? */
 } drm_radeon_sarea_t;
 
 
 /* WARNING: If you change any of these defines, make sure to change the
  * defines in the Xserver file (xf86drmRadeon.h)
+ *
+ * KW: actually it's illegal to change any of this (backwards compatibility).
  */
 typedef struct drm_radeon_init {
 	enum {
@@ -285,7 +355,7 @@
 	unsigned int clear_color;
 	unsigned int clear_depth;
 	unsigned int color_mask;
-	unsigned int depth_mask;
+	unsigned int depth_mask;   /* misnamed field:  should be stencil */
 	drm_radeon_clear_rect_t *depth_boxes;
 } drm_radeon_clear_t;
 
@@ -304,6 +374,36 @@
 	int discard;			/* Client finished with buffer? */
 } drm_radeon_indices_t;
 
+/* v1.2 - obsoletes drm_radeon_vertex and drm_radeon_indices
+ *      - allows multiple primitives and state changes in a single ioctl
+ *      - supports driver change to emit native primitives
+ */
+typedef struct drm_radeon_vertex2 {
+	int idx;			/* Index of vertex buffer */
+	int discard;			/* Client finished with buffer? */
+	int nr_states;
+	drm_radeon_state_t *state;
+	int nr_prims;
+	drm_radeon_prim_t *prim;
+} drm_radeon_vertex2_t;
+
+/* v1.3 - obsoletes drm_radeon_vertex2
+ *      - allows arbitarily large cliprect list 
+ *      - allows updating of tcl packet, vector and scalar state
+ *      - allows memory-efficient description of state updates
+ *      - allows state to be emitted without a primitive 
+ *           (for clears, ctx switches)
+ *      - allows more than one dma buffer to be referenced per ioctl
+ *      - supports tcl driver
+ *      - may be extended in future versions with new cmd types, packets
+ */
+typedef struct drm_radeon_cmd_buffer {
+	int bufsz;
+	char *buf;
+	int nbox;
+	drm_clip_rect_t *boxes;
+} drm_radeon_cmd_buffer_t;
+
 typedef struct drm_radeon_tex_image {
 	unsigned int x, y;		/* Blit coordinates */
 	unsigned int width, height;
@@ -329,5 +429,16 @@
 	int end;
 	int discard;
 } drm_radeon_indirect_t;
+
+
+/* 1.3: An ioctl to get parameters that aren't available to the 3d
+ * client any other way.  
+ */
+#define RADEON_PARAM_AGP_BUFFER_OFFSET 0x1
+
+typedef struct drm_radeon_getparam {
+	int param;
+	int *value;
+} drm_radeon_getparam_t;
 
 #endif
diff -Nru a/drivers/char/drm/radeon_drv.c b/drivers/char/drm/radeon_drv.c
--- a/drivers/char/drm/radeon_drv.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/radeon_drv.c	Fri May 24 18:55:34 2002
@@ -37,12 +37,23 @@
 
 #define DRIVER_NAME		"radeon"
 #define DRIVER_DESC		"ATI Radeon"
-#define DRIVER_DATE		"20010405"
+#define DRIVER_DATE		"20020521"
 
 #define DRIVER_MAJOR		1
-#define DRIVER_MINOR		1
-#define DRIVER_PATCHLEVEL	1
+#define DRIVER_MINOR		3
+#define DRIVER_PATCHLEVEL	0
 
+/* Interface history:
+ *
+ * 1.1 - ??
+ * 1.2 - Add vertex2 ioctl (keith)
+ *     - Add stencil capability to clear ioctl (gareth, keith)
+ *     - Increase MAX_TEXTURE_LEVELS (brian)
+ * 1.3 - Add cmdbuf ioctl (keith)
+ *     - Add support for new radeon packets (keith)
+ *     - Add getparam ioctl (keith)
+ *     - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
+ */
 #define DRIVER_IOCTLS							     \
  [DRM_IOCTL_NR(DRM_IOCTL_DMA)]               = { radeon_cp_buffers,  1, 0 }, \
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CP_INIT)]    = { radeon_cp_init,     1, 1 }, \
@@ -58,17 +69,11 @@
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_INDICES)]    = { radeon_cp_indices,  1, 0 }, \
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_TEXTURE)]    = { radeon_cp_texture,  1, 0 }, \
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_STIPPLE)]    = { radeon_cp_stipple,  1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_RADEON_INDIRECT)]   = { radeon_cp_indirect, 1, 1 },
-
-
-#if 0
-/* GH: Count data sent to card via ring or vertex/indirect buffers.
- */
-#define __HAVE_COUNTERS         3
-#define __HAVE_COUNTER6         _DRM_STAT_IRQ
-#define __HAVE_COUNTER7         _DRM_STAT_PRIMARY
-#define __HAVE_COUNTER8         _DRM_STAT_SECONDARY
-#endif
+ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_INDIRECT)]   = { radeon_cp_indirect, 1, 1 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_VERTEX2)]    = { radeon_cp_vertex2,  1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CMDBUF)]     = { radeon_cp_cmdbuf,   1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_GETPARAM)]   = { radeon_cp_getparam, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_FLIP)]       = { radeon_cp_flip,     1, 0 }, 
 
 
 #include "drm_agpsupport.h"
diff -Nru a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
--- a/drivers/char/drm/radeon_drv.h	Fri May 24 18:55:36 2002
+++ b/drivers/char/drm/radeon_drv.h	Fri May 24 18:55:36 2002
@@ -71,14 +71,7 @@
 
    	drm_radeon_freelist_t *head;
    	drm_radeon_freelist_t *tail;
-/* FIXME: ROTATE_BUFS is a hask to cycle through bufs until freelist
-   code is used.  Note this hides a problem with the scratch register
-   (used to keep track of last buffer completed) being written to before
-   the last buffer has actually completed rendering. */
-#define ROTATE_BUFS 1
-#if ROTATE_BUFS
 	int last_buf;
-#endif
 	volatile u32 *scratch;
 
 	int usec_timeout;
@@ -120,10 +113,6 @@
 
 typedef struct drm_radeon_buf_priv {
 	u32 age;
-	int prim;
-	int discard;
-	int dispatched;
-   	drm_radeon_freelist_t *list_entry;
 } drm_radeon_buf_priv_t;
 
 				/* radeon_cp.c */
@@ -176,6 +165,15 @@
 			      unsigned int cmd, unsigned long arg );
 extern int radeon_cp_indirect( struct inode *inode, struct file *filp,
 			       unsigned int cmd, unsigned long arg );
+extern int radeon_cp_vertex2( struct inode *inode, struct file *filp,
+			      unsigned int cmd, unsigned long arg );
+extern int radeon_cp_cmdbuf( struct inode *inode, struct file *filp,
+			      unsigned int cmd, unsigned long arg );
+extern int radeon_cp_getparam( struct inode *inode, struct file *filp,
+			      unsigned int cmd, unsigned long arg );
+extern int radeon_cp_flip( struct inode *inode, struct file *filp,
+			   unsigned int cmd, unsigned long arg );
+
 
 
 /* Register definitions, register access macros and drmAddMap constants
@@ -204,8 +202,6 @@
 #	define RADEON_CRTC_OFFSET_FLIP_CNTL	(1 << 16)
 
 #define RADEON_RB3D_COLORPITCH		0x1c48
-#define RADEON_RB3D_DEPTHCLEARVALUE	0x1c30
-#define RADEON_RB3D_DEPTHXY_OFFSET	0x1c60
 
 #define RADEON_DP_GUI_MASTER_CNTL	0x146c
 #	define RADEON_GMC_SRC_PITCH_OFFSET_CNTL	(1 << 0)
@@ -290,9 +286,6 @@
 #	define RADEON_ROP_ENABLE		(1 << 6)
 #	define RADEON_STENCIL_ENABLE		(1 << 7)
 #	define RADEON_Z_ENABLE			(1 << 8)
-#	define RADEON_DEPTH_XZ_OFFEST_ENABLE	(1 << 9)
-#	define RADEON_ZBLOCK8			(0 << 15)
-#	define RADEON_ZBLOCK16			(1 << 15)
 #define RADEON_RB3D_DEPTHOFFSET		0x1c24
 #define RADEON_RB3D_PLANEMASK		0x1d84
 #define RADEON_RB3D_STENCILREFMASK	0x1d7c
@@ -306,9 +299,9 @@
 #	define RADEON_Z_TEST_MASK		(7 << 4)
 #	define RADEON_Z_TEST_ALWAYS		(7 << 4)
 #	define RADEON_STENCIL_TEST_ALWAYS	(7 << 12)
-#	define RADEON_STENCIL_S_FAIL_KEEP	(0 << 16)
-#	define RADEON_STENCIL_ZPASS_KEEP	(0 << 20)
-#	define RADEON_STENCIL_ZFAIL_KEEP	(0 << 20)
+#	define RADEON_STENCIL_S_FAIL_REPLACE	(2 << 16)
+#	define RADEON_STENCIL_ZPASS_REPLACE	(2 << 20)
+#	define RADEON_STENCIL_ZFAIL_REPLACE	(2 << 24)
 #	define RADEON_Z_WRITE_ENABLE		(1 << 30)
 #define RADEON_RBBM_SOFT_RESET		0x00f0
 #	define RADEON_SOFT_RESET_CP		(1 <<  0)
@@ -357,6 +350,16 @@
 #define RADEON_SE_CNTL_STATUS		0x2140
 #define RADEON_SE_LINE_WIDTH		0x1db8
 #define RADEON_SE_VPORT_XSCALE		0x1d98
+#define RADEON_SE_ZBIAS_FACTOR		0x1db0
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
+#define RADEON_SE_TCL_OUTPUT_VTX_FMT         0x2254
+#define RADEON_SE_TCL_VECTOR_INDX_REG        0x2200
+#       define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT  16
+#       define RADEON_VEC_INDX_DWORD_COUNT_SHIFT     28
+#define RADEON_SE_TCL_VECTOR_DATA_REG       0x2204
+#define RADEON_SE_TCL_SCALAR_INDX_REG       0x2208
+#       define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT  16
+#define RADEON_SE_TCL_SCALAR_DATA_REG       0x220C
 #define RADEON_SURFACE_ACCESS_FLAGS	0x0bf8
 #define RADEON_SURFACE_ACCESS_CLR	0x0bfc
 #define RADEON_SURFACE_CNTL		0x0b00
@@ -457,8 +460,10 @@
 #define RADEON_CP_PACKET3		0xC0000000
 #	define RADEON_3D_RNDR_GEN_INDX_PRIM	0x00002300
 #	define RADEON_WAIT_FOR_IDLE		0x00002600
+#	define RADEON_3D_DRAW_VBUF		0x00002800
 #	define RADEON_3D_DRAW_IMMD		0x00002900
-#	define RADEON_3D_CLEAR_ZMASK		0x00003200
+#	define RADEON_3D_DRAW_INDX		0x00002A00
+#	define RADEON_3D_LOAD_VBPNTR		0x00002F00
 #	define RADEON_CNTL_HOSTDATA_BLT		0x00009400
 #	define RADEON_CNTL_PAINT_MULTI		0x00009A00
 #	define RADEON_CNTL_BITBLT_MULTI		0x00009B00
@@ -470,6 +475,7 @@
 #define RADEON_CP_PACKET1_REG1_MASK	0x003ff800
 
 #define RADEON_VTX_Z_PRESENT			(1 << 31)
+#define RADEON_VTX_PKCOLOR_PRESENT		(1 << 3)
 
 #define RADEON_PRIM_TYPE_NONE			(0 << 0)
 #define RADEON_PRIM_TYPE_POINT			(1 << 0)
@@ -482,6 +488,7 @@
 #define RADEON_PRIM_TYPE_RECT_LIST		(8 << 0)
 #define RADEON_PRIM_TYPE_3VRT_POINT_LIST	(9 << 0)
 #define RADEON_PRIM_TYPE_3VRT_LINE_LIST		(10 << 0)
+#define RADEON_PRIM_TYPE_MASK                   0xf
 #define RADEON_PRIM_WALK_IND			(1 << 4)
 #define RADEON_PRIM_WALK_LIST			(2 << 4)
 #define RADEON_PRIM_WALK_RING			(3 << 4)
@@ -699,7 +706,7 @@
 
 #define RADEON_VERBOSE	0
 
-#define RING_LOCALS	int write; unsigned int mask; volatile u32 *ring;
+#define RING_LOCALS	int write, _nr; unsigned int mask; volatile u32 *ring;
 
 #define BEGIN_RING( n ) do {						\
 	if ( RADEON_VERBOSE ) {						\
@@ -709,7 +716,7 @@
 	if ( dev_priv->ring.space <= (n) * sizeof(u32) ) {		\
 		radeon_wait_ring( dev_priv, (n) * sizeof(u32) );	\
 	}								\
-	dev_priv->ring.space -= (n) * sizeof(u32);			\
+	_nr = n; dev_priv->ring.space -= (n) * sizeof(u32);		\
 	ring = dev_priv->ring.start;					\
 	write = dev_priv->ring.tail;					\
 	mask = dev_priv->ring.tail_mask;				\
@@ -721,7 +728,13 @@
 			  write, dev_priv->ring.tail );			\
 	}								\
 	radeon_flush_write_combine();					\
-	dev_priv->ring.tail = write;					\
+	if (((dev_priv->ring.tail + _nr) & mask) != write) {		\
+		DRM_ERROR( 						\
+			"ADVANCE_RING(): mismatch: nr: %x write: %x\n",	\
+			((dev_priv->ring.tail + _nr) & mask),		\
+			write);						\
+	} else								\
+		dev_priv->ring.tail = write;				\
 	RADEON_WRITE( RADEON_CP_RB_WPTR, write );			\
 } while (0)
 
@@ -732,6 +745,11 @@
 	}								\
 	ring[write++] = (x);						\
 	write &= mask;							\
+} while (0)
+
+#define OUT_RING_REG( reg, val ) do {					\
+	OUT_RING( CP_PACKET0( reg, 0 ) );				\
+	OUT_RING( val );						\
 } while (0)
 
 #define RADEON_PERFORMANCE_BOXES	0
diff -Nru a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
--- a/drivers/char/drm/radeon_state.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/drm/radeon_state.c	Fri May 24 18:55:34 2002
@@ -48,358 +48,209 @@
 		   box->x1, box->y1, box->x2, box->y2 );
 
 	BEGIN_RING( 4 );
-
 	OUT_RING( CP_PACKET0( RADEON_RE_TOP_LEFT, 0 ) );
 	OUT_RING( (box->y1 << 16) | box->x1 );
-
 	OUT_RING( CP_PACKET0( RADEON_RE_WIDTH_HEIGHT, 0 ) );
-	OUT_RING( ((box->y2 - 1) << 16) | (box->x2 - 1) );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_context( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 14 );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_MISC, 6 ) );
-	OUT_RING( ctx->pp_misc );
-	OUT_RING( ctx->pp_fog_color );
-	OUT_RING( ctx->re_solid_color );
-	OUT_RING( ctx->rb3d_blendcntl );
-	OUT_RING( ctx->rb3d_depthoffset );
-	OUT_RING( ctx->rb3d_depthpitch );
-	OUT_RING( ctx->rb3d_zstencilcntl );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_CNTL, 2 ) );
-	OUT_RING( ctx->pp_cntl );
-	OUT_RING( ctx->rb3d_cntl );
-	OUT_RING( ctx->rb3d_coloroffset );
-
-	OUT_RING( CP_PACKET0( RADEON_RB3D_COLORPITCH, 0 ) );
-	OUT_RING( ctx->rb3d_colorpitch );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_vertfmt( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 2 );
-
-	OUT_RING( CP_PACKET0( RADEON_SE_COORD_FMT, 0 ) );
-	OUT_RING( ctx->se_coord_fmt );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_line( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 5 );
-
-	OUT_RING( CP_PACKET0( RADEON_RE_LINE_PATTERN, 1 ) );
-	OUT_RING( ctx->re_line_pattern );
-	OUT_RING( ctx->re_line_state );
-
-	OUT_RING( CP_PACKET0( RADEON_SE_LINE_WIDTH, 0 ) );
-	OUT_RING( ctx->se_line_width );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_bumpmap( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 5 );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_LUM_MATRIX, 0 ) );
-	OUT_RING( ctx->pp_lum_matrix );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_ROT_MATRIX_0, 1 ) );
-	OUT_RING( ctx->pp_rot_matrix_0 );
-	OUT_RING( ctx->pp_rot_matrix_1 );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_masks( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 4 );
-
-	OUT_RING( CP_PACKET0( RADEON_RB3D_STENCILREFMASK, 2 ) );
-	OUT_RING( ctx->rb3d_stencilrefmask );
-	OUT_RING( ctx->rb3d_ropcntl );
-	OUT_RING( ctx->rb3d_planemask );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_viewport( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 7 );
-
-	OUT_RING( CP_PACKET0( RADEON_SE_VPORT_XSCALE, 5 ) );
-	OUT_RING( ctx->se_vport_xscale );
-	OUT_RING( ctx->se_vport_xoffset );
-	OUT_RING( ctx->se_vport_yscale );
-	OUT_RING( ctx->se_vport_yoffset );
-	OUT_RING( ctx->se_vport_zscale );
-	OUT_RING( ctx->se_vport_zoffset );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_setup( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 4 );
-
-	OUT_RING( CP_PACKET0( RADEON_SE_CNTL, 0 ) );
-	OUT_RING( ctx->se_cntl );
-	OUT_RING( CP_PACKET0( RADEON_SE_CNTL_STATUS, 0 ) );
-	OUT_RING( ctx->se_cntl_status );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_tcl( drm_radeon_private_t *dev_priv )
-{
-#ifdef TCL_ENABLE
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 29 );
-
-	OUT_RING( CP_PACKET0( RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED, 27 ) );
-	OUT_RING( ctx->se_tcl_material_emmissive.red );
-	OUT_RING( ctx->se_tcl_material_emmissive.green );
-	OUT_RING( ctx->se_tcl_material_emmissive.blue );
-	OUT_RING( ctx->se_tcl_material_emmissive.alpha );
-	OUT_RING( ctx->se_tcl_material_ambient.red );
-	OUT_RING( ctx->se_tcl_material_ambient.green );
-	OUT_RING( ctx->se_tcl_material_ambient.blue );
-	OUT_RING( ctx->se_tcl_material_ambient.alpha );
-	OUT_RING( ctx->se_tcl_material_diffuse.red );
-	OUT_RING( ctx->se_tcl_material_diffuse.green );
-	OUT_RING( ctx->se_tcl_material_diffuse.blue );
-	OUT_RING( ctx->se_tcl_material_diffuse.alpha );
-	OUT_RING( ctx->se_tcl_material_specular.red );
-	OUT_RING( ctx->se_tcl_material_specular.green );
-	OUT_RING( ctx->se_tcl_material_specular.blue );
-	OUT_RING( ctx->se_tcl_material_specular.alpha );
-	OUT_RING( ctx->se_tcl_shininess );
-	OUT_RING( ctx->se_tcl_output_vtx_fmt );
-	OUT_RING( ctx->se_tcl_output_vtx_sel );
-	OUT_RING( ctx->se_tcl_matrix_select_0 );
-	OUT_RING( ctx->se_tcl_matrix_select_1 );
-	OUT_RING( ctx->se_tcl_ucp_vert_blend_ctl );
-	OUT_RING( ctx->se_tcl_texture_proc_ctl );
-	OUT_RING( ctx->se_tcl_light_model_ctl );
-	for ( i = 0 ; i < 4 ; i++ ) {
-		OUT_RING( ctx->se_tcl_per_light_ctl[i] );
-	}
-
-	ADVANCE_RING();
-#else
-	DRM_ERROR( "TCL not enabled!\n" );
-#endif
-}
-
-static inline void radeon_emit_misc( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_context_regs_t *ctx = &sarea_priv->context_state;
-	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 2 );
-
-	OUT_RING( CP_PACKET0( RADEON_RE_MISC, 0 ) );
-	OUT_RING( ctx->re_misc );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_tex0( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_texture_regs_t *tex = &sarea_priv->tex_state[0];
-	RING_LOCALS;
-	DRM_DEBUG( "    %s: offset=0x%x\n", __FUNCTION__, tex->pp_txoffset );
-
-	BEGIN_RING( 9 );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_0, 5 ) );
-	OUT_RING( tex->pp_txfilter );
-	OUT_RING( tex->pp_txformat );
-	OUT_RING( tex->pp_txoffset );
-	OUT_RING( tex->pp_txcblend );
-	OUT_RING( tex->pp_txablend );
-	OUT_RING( tex->pp_tfactor );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_0, 0 ) );
-	OUT_RING( tex->pp_border_color );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_tex1( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_texture_regs_t *tex = &sarea_priv->tex_state[1];
-	RING_LOCALS;
-	DRM_DEBUG( "    %s: offset=0x%x\n", __FUNCTION__, tex->pp_txoffset );
-
-	BEGIN_RING( 9 );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_1, 5 ) );
-	OUT_RING( tex->pp_txfilter );
-	OUT_RING( tex->pp_txformat );
-	OUT_RING( tex->pp_txoffset );
-	OUT_RING( tex->pp_txcblend );
-	OUT_RING( tex->pp_txablend );
-	OUT_RING( tex->pp_tfactor );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_1, 0 ) );
-	OUT_RING( tex->pp_border_color );
-
+/*	OUT_RING( ((box->y2 - 1) << 16) | (box->x2 - 1) );*/
+	OUT_RING( (box->y2 << 16) | box->x2 );
 	ADVANCE_RING();
 }
 
-static inline void radeon_emit_tex2( drm_radeon_private_t *dev_priv )
+/* Emit 1.1 state
+ */
+static void radeon_emit_state( drm_radeon_private_t *dev_priv,
+			       drm_radeon_context_regs_t *ctx,
+			       drm_radeon_texture_regs_t *tex,
+			       unsigned int dirty )
 {
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	drm_radeon_texture_regs_t *tex = &sarea_priv->tex_state[2];
 	RING_LOCALS;
-	DRM_DEBUG( "    %s\n", __FUNCTION__ );
-
-	BEGIN_RING( 9 );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_2, 5 ) );
-	OUT_RING( tex->pp_txfilter );
-	OUT_RING( tex->pp_txformat );
-	OUT_RING( tex->pp_txoffset );
-	OUT_RING( tex->pp_txcblend );
-	OUT_RING( tex->pp_txablend );
-	OUT_RING( tex->pp_tfactor );
-
-	OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_2, 0 ) );
-	OUT_RING( tex->pp_border_color );
-
-	ADVANCE_RING();
-}
-
-static inline void radeon_emit_state( drm_radeon_private_t *dev_priv )
-{
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	unsigned int dirty = sarea_priv->dirty;
-
 	DRM_DEBUG( "%s: dirty=0x%08x\n", __FUNCTION__, dirty );
 
 	if ( dirty & RADEON_UPLOAD_CONTEXT ) {
-		radeon_emit_context( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_CONTEXT;
+		BEGIN_RING( 14 );
+		OUT_RING( CP_PACKET0( RADEON_PP_MISC, 6 ) );
+		OUT_RING( ctx->pp_misc );
+		OUT_RING( ctx->pp_fog_color );
+		OUT_RING( ctx->re_solid_color );
+		OUT_RING( ctx->rb3d_blendcntl );
+		OUT_RING( ctx->rb3d_depthoffset );
+		OUT_RING( ctx->rb3d_depthpitch );
+		OUT_RING( ctx->rb3d_zstencilcntl );
+		OUT_RING( CP_PACKET0( RADEON_PP_CNTL, 2 ) );
+		OUT_RING( ctx->pp_cntl );
+		OUT_RING( ctx->rb3d_cntl );
+		OUT_RING( ctx->rb3d_coloroffset );
+		OUT_RING( CP_PACKET0( RADEON_RB3D_COLORPITCH, 0 ) );
+		OUT_RING( ctx->rb3d_colorpitch );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_VERTFMT ) {
-		radeon_emit_vertfmt( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_VERTFMT;
+		BEGIN_RING( 2 );
+		OUT_RING( CP_PACKET0( RADEON_SE_COORD_FMT, 0 ) );
+		OUT_RING( ctx->se_coord_fmt );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_LINE ) {
-		radeon_emit_line( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_LINE;
+		BEGIN_RING( 5 );
+		OUT_RING( CP_PACKET0( RADEON_RE_LINE_PATTERN, 1 ) );
+		OUT_RING( ctx->re_line_pattern );
+		OUT_RING( ctx->re_line_state );
+		OUT_RING( CP_PACKET0( RADEON_SE_LINE_WIDTH, 0 ) );
+		OUT_RING( ctx->se_line_width );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_BUMPMAP ) {
-		radeon_emit_bumpmap( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_BUMPMAP;
+		BEGIN_RING( 5 );
+		OUT_RING( CP_PACKET0( RADEON_PP_LUM_MATRIX, 0 ) );
+		OUT_RING( ctx->pp_lum_matrix );
+		OUT_RING( CP_PACKET0( RADEON_PP_ROT_MATRIX_0, 1 ) );
+		OUT_RING( ctx->pp_rot_matrix_0 );
+		OUT_RING( ctx->pp_rot_matrix_1 );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_MASKS ) {
-		radeon_emit_masks( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_MASKS;
+		BEGIN_RING( 4 );
+		OUT_RING( CP_PACKET0( RADEON_RB3D_STENCILREFMASK, 2 ) );
+		OUT_RING( ctx->rb3d_stencilrefmask );
+		OUT_RING( ctx->rb3d_ropcntl );
+		OUT_RING( ctx->rb3d_planemask );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_VIEWPORT ) {
-		radeon_emit_viewport( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_VIEWPORT;
+		BEGIN_RING( 7 );
+		OUT_RING( CP_PACKET0( RADEON_SE_VPORT_XSCALE, 5 ) );
+		OUT_RING( ctx->se_vport_xscale );
+		OUT_RING( ctx->se_vport_xoffset );
+		OUT_RING( ctx->se_vport_yscale );
+		OUT_RING( ctx->se_vport_yoffset );
+		OUT_RING( ctx->se_vport_zscale );
+		OUT_RING( ctx->se_vport_zoffset );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_SETUP ) {
-		radeon_emit_setup( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_SETUP;
-	}
-
-	if ( dirty & RADEON_UPLOAD_TCL ) {
-#ifdef TCL_ENABLE
-		radeon_emit_tcl( dev_priv );
-#endif
-		sarea_priv->dirty &= ~RADEON_UPLOAD_TCL;
+		BEGIN_RING( 4 );
+		OUT_RING( CP_PACKET0( RADEON_SE_CNTL, 0 ) );
+		OUT_RING( ctx->se_cntl );
+		OUT_RING( CP_PACKET0( RADEON_SE_CNTL_STATUS, 0 ) );
+		OUT_RING( ctx->se_cntl_status );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_MISC ) {
-		radeon_emit_misc( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_MISC;
+		BEGIN_RING( 2 );
+		OUT_RING( CP_PACKET0( RADEON_RE_MISC, 0 ) );
+		OUT_RING( ctx->re_misc );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_TEX0 ) {
-		radeon_emit_tex0( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_TEX0;
+		BEGIN_RING( 9 );
+		OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_0, 5 ) );
+		OUT_RING( tex[0].pp_txfilter );
+		OUT_RING( tex[0].pp_txformat );
+		OUT_RING( tex[0].pp_txoffset );
+		OUT_RING( tex[0].pp_txcblend );
+		OUT_RING( tex[0].pp_txablend );
+		OUT_RING( tex[0].pp_tfactor );
+		OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_0, 0 ) );
+		OUT_RING( tex[0].pp_border_color );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_TEX1 ) {
-		radeon_emit_tex1( dev_priv );
-		sarea_priv->dirty &= ~RADEON_UPLOAD_TEX1;
+		BEGIN_RING( 9 );
+		OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_1, 5 ) );
+		OUT_RING( tex[1].pp_txfilter );
+		OUT_RING( tex[1].pp_txformat );
+		OUT_RING( tex[1].pp_txoffset );
+		OUT_RING( tex[1].pp_txcblend );
+		OUT_RING( tex[1].pp_txablend );
+		OUT_RING( tex[1].pp_tfactor );
+		OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_1, 0 ) );
+		OUT_RING( tex[1].pp_border_color );
+		ADVANCE_RING();
 	}
 
 	if ( dirty & RADEON_UPLOAD_TEX2 ) {
-#if 0
-		radeon_emit_tex2( dev_priv );
-#endif
-		sarea_priv->dirty &= ~RADEON_UPLOAD_TEX2;
+		BEGIN_RING( 9 );
+		OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_2, 5 ) );
+		OUT_RING( tex[2].pp_txfilter );
+		OUT_RING( tex[2].pp_txformat );
+		OUT_RING( tex[2].pp_txoffset );
+		OUT_RING( tex[2].pp_txcblend );
+		OUT_RING( tex[2].pp_txablend );
+		OUT_RING( tex[2].pp_tfactor );
+		OUT_RING( CP_PACKET0( RADEON_PP_BORDER_COLOR_2, 0 ) );
+		OUT_RING( tex[2].pp_border_color );
+		ADVANCE_RING();
+	}
+}
+
+/* Emit 1.2 state
+ */
+static void radeon_emit_state2( drm_radeon_private_t *dev_priv,
+				drm_radeon_state_t *state )
+{
+	RING_LOCALS;
+
+	if (state->dirty & RADEON_UPLOAD_ZBIAS) {
+		BEGIN_RING( 3 );
+		OUT_RING( CP_PACKET0( RADEON_SE_ZBIAS_FACTOR, 1 ) );
+		OUT_RING( state->context2.se_zbias_factor ); 
+		OUT_RING( state->context2.se_zbias_constant ); 
+		ADVANCE_RING();
 	}
 
-	sarea_priv->dirty &= ~(RADEON_UPLOAD_TEX0IMAGES |
-			       RADEON_UPLOAD_TEX1IMAGES |
-			       RADEON_UPLOAD_TEX2IMAGES |
-			       RADEON_REQUIRE_QUIESCENCE);
+	radeon_emit_state( dev_priv, &state->context, 
+			   state->tex, state->dirty );
 }
 
+/* New (1.3) state mechanism.  3 commands (packet, scalar, vector) in
+ * 1.3 cmdbuffers allow all previous state to be updated as well as
+ * the tcl scalar and vector areas.  
+ */
+static struct { 
+	int start; 
+	int len; 
+	const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+	{ RADEON_PP_MISC,7,"RADEON_PP_MISC" },
+	{ RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
+	{ RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
+	{ RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
+	{ RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
+	{ RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
+	{ RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
+	{ RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
+	{ RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
+	{ RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
+	{ RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
+	{ RADEON_RE_MISC,1,"RADEON_RE_MISC" },
+	{ RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
+	{ RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
+	{ RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
+	{ RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
+	{ RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
+	{ RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
+	{ RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
+	{ RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
+	{ RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
+};
+
+
+
+
+
+
+
+
+
 
 #if RADEON_PERFORMANCE_BOXES
 /* ================================================================
@@ -464,39 +315,20 @@
  * CP command dispatch functions
  */
 
-static void radeon_print_dirty( const char *msg, unsigned int flags )
-{
-	DRM_DEBUG( "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
-		   msg,
-		   flags,
-		   (flags & RADEON_UPLOAD_CONTEXT)     ? "context, " : "",
-		   (flags & RADEON_UPLOAD_VERTFMT)     ? "vertfmt, " : "",
-		   (flags & RADEON_UPLOAD_LINE)        ? "line, " : "",
-		   (flags & RADEON_UPLOAD_BUMPMAP)     ? "bumpmap, " : "",
-		   (flags & RADEON_UPLOAD_MASKS)       ? "masks, " : "",
-		   (flags & RADEON_UPLOAD_VIEWPORT)    ? "viewport, " : "",
-		   (flags & RADEON_UPLOAD_SETUP)       ? "setup, " : "",
-		   (flags & RADEON_UPLOAD_TCL)         ? "tcl, " : "",
-		   (flags & RADEON_UPLOAD_MISC)        ? "misc, " : "",
-		   (flags & RADEON_UPLOAD_TEX0)        ? "tex0, " : "",
-		   (flags & RADEON_UPLOAD_TEX1)        ? "tex1, " : "",
-		   (flags & RADEON_UPLOAD_TEX2)        ? "tex2, " : "",
-		   (flags & RADEON_UPLOAD_CLIPRECTS)   ? "cliprects, " : "",
-		   (flags & RADEON_REQUIRE_QUIESCENCE) ? "quiescence, " : "" );
-}
-
 static void radeon_cp_dispatch_clear( drm_device_t *dev,
 				      drm_radeon_clear_t *clear,
 				      drm_radeon_clear_rect_t *depth_boxes )
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	drm_radeon_depth_clear_t *depth_clear = &dev_priv->depth_clear;
 	int nbox = sarea_priv->nbox;
 	drm_clip_rect_t *pbox = sarea_priv->boxes;
 	unsigned int flags = clear->flags;
+	u32 rb3d_cntl = 0, rb3d_stencilrefmask= 0;
 	int i;
 	RING_LOCALS;
-	DRM_DEBUG( "%s\n", __FUNCTION__ );
+	DRM_DEBUG( __FUNCTION__": flags = 0x%x\n", flags );
 
 	if ( dev_priv->page_flipping && dev_priv->current_page == 1 ) {
 		unsigned int tmp = flags;
@@ -506,6 +338,28 @@
 		if ( tmp & RADEON_BACK )  flags |= RADEON_FRONT;
 	}
 
+	/* We have to clear the depth and/or stencil buffers by
+	 * rendering a quad into just those buffers.  Thus, we have to
+	 * make sure the 3D engine is configured correctly.
+	 */
+	if ( flags & (RADEON_DEPTH | RADEON_STENCIL) ) {
+		rb3d_cntl = depth_clear->rb3d_cntl;
+
+		if ( flags & RADEON_DEPTH ) {
+			rb3d_cntl |=  RADEON_Z_ENABLE;
+		} else {
+			rb3d_cntl &= ~RADEON_Z_ENABLE;
+		}
+
+		if ( flags & RADEON_STENCIL ) {
+			rb3d_cntl |=  RADEON_STENCIL_ENABLE;
+			rb3d_stencilrefmask = clear->depth_mask; /* misnamed field */
+		} else {
+			rb3d_cntl &= ~RADEON_STENCIL_ENABLE;
+			rb3d_stencilrefmask = 0x00000000;
+		}
+	}
+
 	for ( i = 0 ; i < nbox ; i++ ) {
 		int x = pbox[i].x1;
 		int y = pbox[i].y1;
@@ -530,8 +384,7 @@
 
 			/* Make sure we restore the 3D state next time.
 			 */
-			dev_priv->sarea_priv->dirty |= (RADEON_UPLOAD_CONTEXT |
-							RADEON_UPLOAD_MASKS);
+			dev_priv->sarea_priv->ctx_owner = 0;
 		}
 
 		if ( flags & RADEON_FRONT ) {
@@ -572,36 +425,36 @@
 			OUT_RING( (w << 16) | h );
 
 			ADVANCE_RING();
-
 		}
 
-		if ( flags & RADEON_DEPTH ) {
-			drm_radeon_depth_clear_t *depth_clear =
-			   &dev_priv->depth_clear;
+		if ( flags & (RADEON_DEPTH | RADEON_STENCIL) ) {
 
-			if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
-				radeon_emit_state( dev_priv );
-			}
+			radeon_emit_clip_rect( dev_priv,
+					       &sarea_priv->boxes[i] );
 
-			/* FIXME: Render a rectangle to clear the depth
-			 * buffer.  So much for those "fast Z clears"...
-			 */
-			BEGIN_RING( 23 );
+			BEGIN_RING( 28 );
 
 			RADEON_WAIT_UNTIL_2D_IDLE();
 
 			OUT_RING( CP_PACKET0( RADEON_PP_CNTL, 1 ) );
 			OUT_RING( 0x00000000 );
-			OUT_RING( depth_clear->rb3d_cntl );
-			OUT_RING( CP_PACKET0( RADEON_RB3D_ZSTENCILCNTL, 0 ) );
-			OUT_RING( depth_clear->rb3d_zstencilcntl );
-			OUT_RING( CP_PACKET0( RADEON_RB3D_PLANEMASK, 0 ) );
-			OUT_RING( 0x00000000 );
-			OUT_RING( CP_PACKET0( RADEON_SE_CNTL, 0 ) );
-			OUT_RING( depth_clear->se_cntl );
+			OUT_RING( rb3d_cntl );
+
+			OUT_RING_REG( RADEON_RB3D_ZSTENCILCNTL,
+				      depth_clear->rb3d_zstencilcntl );
+			OUT_RING_REG( RADEON_RB3D_STENCILREFMASK,
+				      rb3d_stencilrefmask );
+			OUT_RING_REG( RADEON_RB3D_PLANEMASK,
+				      0x00000000 );
+			OUT_RING_REG( RADEON_SE_CNTL,
+				      depth_clear->se_cntl );
 
-			OUT_RING( CP_PACKET3( RADEON_3D_DRAW_IMMD, 10 ) );
-			OUT_RING( RADEON_VTX_Z_PRESENT );
+			/* Radeon 7500 doesn't like vertices without
+			 * color.
+			 */
+			OUT_RING( CP_PACKET3( RADEON_3D_DRAW_IMMD, 13 ) );
+			OUT_RING( RADEON_VTX_Z_PRESENT |
+				  RADEON_VTX_PKCOLOR_PRESENT);
 			OUT_RING( (RADEON_PRIM_TYPE_RECT_LIST |
 				   RADEON_PRIM_WALK_RING |
 				   RADEON_MAOS_ENABLE |
@@ -611,22 +464,23 @@
 			OUT_RING( depth_boxes[i].ui[CLEAR_X1] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_Y1] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_DEPTH] );
+			OUT_RING( 0x0 );
 
 			OUT_RING( depth_boxes[i].ui[CLEAR_X1] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_Y2] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_DEPTH] );
+			OUT_RING( 0x0 );
 
 			OUT_RING( depth_boxes[i].ui[CLEAR_X2] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_Y2] );
 			OUT_RING( depth_boxes[i].ui[CLEAR_DEPTH] );
+			OUT_RING( 0x0 );
 
 			ADVANCE_RING();
 
 			/* Make sure we restore the 3D state next time.
 			 */
-			dev_priv->sarea_priv->dirty |= (RADEON_UPLOAD_CONTEXT |
-							RADEON_UPLOAD_SETUP |
-							RADEON_UPLOAD_MASKS);
+			dev_priv->sarea_priv->ctx_owner = 0;
 		}
 	}
 
@@ -690,9 +544,17 @@
 			  RADEON_DP_SRC_SOURCE_MEMORY |
 			  RADEON_GMC_CLR_CMP_CNTL_DIS |
 			  RADEON_GMC_WR_MSK_DIS );
-
-		OUT_RING( dev_priv->back_pitch_offset );
-		OUT_RING( dev_priv->front_pitch_offset );
+		
+		/* Make this work even if front & back are flipped:
+		 */
+		if (dev_priv->current_page == 0) {
+			OUT_RING( dev_priv->back_pitch_offset );
+			OUT_RING( dev_priv->front_pitch_offset );
+		} 
+		else {
+			OUT_RING( dev_priv->front_pitch_offset );
+			OUT_RING( dev_priv->back_pitch_offset );
+		}
 
 		OUT_RING( (x << 16) | y );
 		OUT_RING( (x << 16) | y );
@@ -727,11 +589,12 @@
 	radeon_cp_performance_boxes( dev_priv );
 #endif
 
-	BEGIN_RING( 6 );
+	BEGIN_RING( 4 );
 
 	RADEON_WAIT_UNTIL_3D_IDLE();
+/*
 	RADEON_WAIT_UNTIL_PAGE_FLIPPED();
-
+*/
 	OUT_RING( CP_PACKET0( RADEON_CRTC_OFFSET, 0 ) );
 
 	if ( dev_priv->current_page == 0 ) {
@@ -749,6 +612,7 @@
 	 * performing the swapbuffer ioctl.
 	 */
 	dev_priv->sarea_priv->last_frame++;
+	dev_priv->sarea_priv->pfCurrentPage = dev_priv->current_page;
 
 	BEGIN_RING( 2 );
 
@@ -757,82 +621,121 @@
 	ADVANCE_RING();
 }
 
+static int bad_prim_vertex_nr( int primitive, int nr )
+{
+	switch (primitive & RADEON_PRIM_TYPE_MASK) {
+	case RADEON_PRIM_TYPE_NONE:
+	case RADEON_PRIM_TYPE_POINT:
+		return nr < 1;
+	case RADEON_PRIM_TYPE_LINE:
+		return (nr & 1) || nr == 0;
+	case RADEON_PRIM_TYPE_LINE_STRIP:
+		return nr < 2;
+	case RADEON_PRIM_TYPE_TRI_LIST:
+	case RADEON_PRIM_TYPE_3VRT_POINT_LIST:
+	case RADEON_PRIM_TYPE_3VRT_LINE_LIST:
+	case RADEON_PRIM_TYPE_RECT_LIST:
+		return nr % 3 || nr == 0;
+	case RADEON_PRIM_TYPE_TRI_FAN:
+	case RADEON_PRIM_TYPE_TRI_STRIP:
+		return nr < 3;
+	default:
+		return 1;
+	}	
+}
+
+
+
+typedef struct {
+	unsigned int start;
+	unsigned int finish;
+	unsigned int prim;
+	unsigned int numverts;
+	unsigned int offset;   
+        unsigned int vc_format;
+} drm_radeon_tcl_prim_t;
+
 static void radeon_cp_dispatch_vertex( drm_device_t *dev,
-				       drm_buf_t *buf )
+				       drm_buf_t *buf,
+				       drm_radeon_tcl_prim_t *prim,
+				       drm_clip_rect_t *boxes,
+				       int nbox )
+
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
-	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	int format = sarea_priv->vc_format;
-	int offset = dev_priv->agp_buffers_offset + buf->offset;
-	int size = buf->used;
-	int prim = buf_priv->prim;
+	drm_clip_rect_t box;
+	int offset = dev_priv->agp_buffers_offset + buf->offset + prim->start;
+	int numverts = (int)prim->numverts;
 	int i = 0;
 	RING_LOCALS;
-	DRM_DEBUG( "%s: nbox=%d\n", __FUNCTION__, sarea_priv->nbox );
 
-	if ( 0 )
-		radeon_print_dirty( "dispatch_vertex", sarea_priv->dirty );
 
-	if ( buf->used ) {
-		buf_priv->dispatched = 1;
+	DRM_DEBUG("%s: hwprim 0x%x vfmt 0x%x %d..%d %d verts\n",
+		  __FUNCTION__,
+		  prim->prim,
+		  prim->vc_format,
+		  prim->start,
+		  prim->finish,
+		  prim->numverts);
+
+	if (bad_prim_vertex_nr( prim->prim, prim->numverts )) {
+		DRM_ERROR( "bad prim %x numverts %d\n", 
+			   prim->prim, prim->numverts );
+		return;
+	}
+
 
-		if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
-			radeon_emit_state( dev_priv );
+	do {
+		/* Emit the next cliprect */
+		if ( i < nbox ) {
+			if (__copy_from_user( &box, &boxes[i], sizeof(box) ))
+				return;
+
+			radeon_emit_clip_rect( dev_priv, &box );
 		}
 
-		do {
-			/* Emit the next set of up to three cliprects */
-			if ( i < sarea_priv->nbox ) {
-				radeon_emit_clip_rect( dev_priv,
-						       &sarea_priv->boxes[i] );
-			}
+		/* Emit the vertex buffer rendering commands */
+		BEGIN_RING( 5 );
 
-			/* Emit the vertex buffer rendering commands */
-			BEGIN_RING( 5 );
+		OUT_RING( CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, 3 ) );
+		OUT_RING( offset );
+		OUT_RING( numverts );
+		OUT_RING( prim->vc_format );
+		OUT_RING( prim->prim | RADEON_PRIM_WALK_LIST |
+			  RADEON_COLOR_ORDER_RGBA |
+			  RADEON_VTX_FMT_RADEON_MODE |
+			  (numverts << RADEON_NUM_VERTICES_SHIFT) );
 
-			OUT_RING( CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, 3 ) );
-			OUT_RING( offset );
-			OUT_RING( size );
-			OUT_RING( format );
-			OUT_RING( prim | RADEON_PRIM_WALK_LIST |
-				  RADEON_COLOR_ORDER_RGBA |
-				  RADEON_VTX_FMT_RADEON_MODE |
-				  (size << RADEON_NUM_VERTICES_SHIFT) );
+		ADVANCE_RING();
 
-			ADVANCE_RING();
+		i++;
+	} while ( i < nbox );
+}
 
-			i++;
-		} while ( i < sarea_priv->nbox );
-	}
 
-	if ( buf_priv->discard ) {
-		buf_priv->age = dev_priv->sarea_priv->last_dispatch;
 
-		/* Emit the vertex buffer age */
-		BEGIN_RING( 2 );
-		RADEON_DISPATCH_AGE( buf_priv->age );
-		ADVANCE_RING();
+static void radeon_cp_discard_buffer( drm_device_t *dev, drm_buf_t *buf )
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
+	RING_LOCALS;
 
-		buf->pending = 1;
-		buf->used = 0;
-		/* FIXME: Check dispatched field */
-		buf_priv->dispatched = 0;
-	}
+	buf_priv->age = ++dev_priv->sarea_priv->last_dispatch;
 
-	dev_priv->sarea_priv->last_dispatch++;
+	/* Emit the vertex buffer age */
+	BEGIN_RING( 2 );
+	RADEON_DISPATCH_AGE( buf_priv->age );
+	ADVANCE_RING();
 
-	sarea_priv->dirty &= ~RADEON_UPLOAD_CLIPRECTS;
-	sarea_priv->nbox = 0;
+	buf->pending = 1;
+	buf->used = 0;
 }
 
-
 static void radeon_cp_dispatch_indirect( drm_device_t *dev,
 					 drm_buf_t *buf,
 					 int start, int end )
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
-	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
 	RING_LOCALS;
 	DRM_DEBUG( "indirect: buf=%d s=0x%x e=0x%x\n",
 		   buf->idx, start, end );
@@ -853,8 +756,6 @@
 			data[dwords++] = RADEON_CP_PACKET2;
 		}
 
-		buf_priv->dispatched = 1;
-
 		/* Fire off the indirect buffer */
 		BEGIN_RING( 3 );
 
@@ -864,100 +765,76 @@
 
 		ADVANCE_RING();
 	}
-
-	if ( buf_priv->discard ) {
-		buf_priv->age = dev_priv->sarea_priv->last_dispatch;
-
-		/* Emit the indirect buffer age */
-		BEGIN_RING( 2 );
-		RADEON_DISPATCH_AGE( buf_priv->age );
-		ADVANCE_RING();
-
-		buf->pending = 1;
-		buf->used = 0;
-		/* FIXME: Check dispatched field */
-		buf_priv->dispatched = 0;
-	}
-
-	dev_priv->sarea_priv->last_dispatch++;
 }
 
+
 static void radeon_cp_dispatch_indices( drm_device_t *dev,
-					drm_buf_t *buf,
-					int start, int end,
-					int count )
+					drm_buf_t *elt_buf,
+					drm_radeon_tcl_prim_t *prim, 
+					drm_clip_rect_t *boxes,
+					int nbox )
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
-	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
-	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
-	int format = sarea_priv->vc_format;
-	int offset = dev_priv->agp_buffers_offset;
-	int prim = buf_priv->prim;
+	drm_clip_rect_t box;
+	int offset = dev_priv->agp_buffers_offset + prim->offset;
 	u32 *data;
 	int dwords;
 	int i = 0;
-	RING_LOCALS;
-	DRM_DEBUG( "indices: s=%d e=%d c=%d\n", start, end, count );
-
-	if ( 0 )
-		radeon_print_dirty( "dispatch_indices", sarea_priv->dirty );
-
-	if ( start != end ) {
-		buf_priv->dispatched = 1;
-
-		if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
-			radeon_emit_state( dev_priv );
-		}
+	int start = prim->start + RADEON_INDEX_PRIM_OFFSET;
+	int count = (prim->finish - start) / sizeof(u16);
 
-		dwords = (end - start + 3) / sizeof(u32);
-
-		data = (u32 *)((char *)dev_priv->buffers->handle
-			       + buf->offset + start);
-
-		data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
-
-		data[1] = offset;
-		data[2] = RADEON_MAX_VB_VERTS;
-		data[3] = format;
-		data[4] = (prim | RADEON_PRIM_WALK_IND |
-			   RADEON_COLOR_ORDER_RGBA |
-			   RADEON_VTX_FMT_RADEON_MODE |
-			   (count << RADEON_NUM_VERTICES_SHIFT) );
-
-		if ( count & 0x1 ) {
-			data[dwords-1] &= 0x0000ffff;
-		}
-
-		do {
-			/* Emit the next set of up to three cliprects */
-			if ( i < sarea_priv->nbox ) {
-				radeon_emit_clip_rect( dev_priv,
-						       &sarea_priv->boxes[i] );
-			}
-
-			radeon_cp_dispatch_indirect( dev, buf, start, end );
-
-			i++;
-		} while ( i < sarea_priv->nbox );
+	DRM_DEBUG("%s: hwprim 0x%x vfmt 0x%x %d..%d offset: %x nr %d\n",
+		  __FUNCTION__,
+		  prim->prim,
+		  prim->vc_format,
+		  prim->start,
+		  prim->finish,
+		  prim->offset,
+		  prim->numverts);
+
+	if (bad_prim_vertex_nr( prim->prim, count )) {
+		DRM_ERROR( "bad prim %x count %d\n", 
+			   prim->prim, count );
+		return;
 	}
 
-	if ( buf_priv->discard ) {
-		buf_priv->age = dev_priv->sarea_priv->last_dispatch;
 
-		/* Emit the vertex buffer age */
-		BEGIN_RING( 2 );
-		RADEON_DISPATCH_AGE( buf_priv->age );
-		ADVANCE_RING();
+	if ( start >= prim->finish ||
+	     (prim->start & 0x7) ) {
+		DRM_ERROR( "buffer prim %d\n", prim->prim );
+		return;
+	}
+
+	dwords = (prim->finish - prim->start + 3) / sizeof(u32);
+
+	data = (u32 *)((char *)dev_priv->buffers->handle +
+		       elt_buf->offset + prim->start);
+
+	data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
+	data[1] = offset;
+	data[2] = prim->numverts;
+	data[3] = prim->vc_format;
+	data[4] = (prim->prim |
+		   RADEON_PRIM_WALK_IND |
+		   RADEON_COLOR_ORDER_RGBA |
+		   RADEON_VTX_FMT_RADEON_MODE |
+		   (count << RADEON_NUM_VERTICES_SHIFT) );
+
+	do {
+		if ( i < nbox ) {
+			if (__copy_from_user( &box, &boxes[i], sizeof(box) ))
+				return;
+			
+			radeon_emit_clip_rect( dev_priv, &box );
+		}
 
-		buf->pending = 1;
-		/* FIXME: Check dispatched field */
-		buf_priv->dispatched = 0;
-	}
+		radeon_cp_dispatch_indirect( dev, elt_buf,
+					     prim->start,
+					     prim->finish );
 
-	dev_priv->sarea_priv->last_dispatch++;
+		i++;
+	} while ( i < nbox );
 
-	sarea_priv->dirty &= ~RADEON_UPLOAD_CLIPRECTS;
-	sarea_priv->nbox = 0;
 }
 
 #define RADEON_MAX_TEXTURE_SIZE (RADEON_BUFFER_SIZE - 8 * sizeof(u32))
@@ -968,7 +845,6 @@
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_buf_t *buf;
-	drm_radeon_buf_priv_t *buf_priv;
 	u32 format;
 	u32 *buffer;
 	u8 *data;
@@ -986,8 +862,6 @@
 		   tex->offset >> 10, tex->pitch, tex->format,
 		   image->x, image->y, image->width, image->height );
 
-	buf_priv = buf->dev_private;
-
 	/* The compiler won't optimize away a division by a variable,
 	 * even if the only legal values are powers of two.  Thus, we'll
 	 * use a shift instead.
@@ -1058,7 +932,7 @@
 			DRM_ERROR( "EFAULT on tex->image\n" );
 			return -EFAULT;
 		}
-	} else if ( size < 4 ) {
+	} else if ( size < 4 && size > 0 ) {
 		size = 4;
 	}
 
@@ -1113,9 +987,9 @@
 
 	buf->pid = current->pid;
 	buf->used = (dwords + 8) * sizeof(u32);
-	buf_priv->discard = 1;
 
 	radeon_cp_dispatch_indirect( dev, buf, 0, buf->used );
+	radeon_cp_discard_buffer( dev, buf );
 
 	/* Flush the pixel cache after the blit completes.  This ensures
 	 * the texture data is written out to memory before rendering
@@ -1187,6 +1061,66 @@
 	return 0;
 }
 
+
+
+/* Not sure why this isn't set all the time:
+ */ 
+static int radeon_do_init_pageflip( drm_device_t *dev )
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	dev_priv->crtc_offset =      RADEON_READ( RADEON_CRTC_OFFSET );
+	dev_priv->crtc_offset_cntl = RADEON_READ( RADEON_CRTC_OFFSET_CNTL );
+
+	RADEON_WRITE( RADEON_CRTC_OFFSET, dev_priv->front_offset );
+	RADEON_WRITE( RADEON_CRTC_OFFSET_CNTL,
+		      dev_priv->crtc_offset_cntl |
+		      RADEON_CRTC_OFFSET_FLIP_CNTL );
+
+	dev_priv->page_flipping = 1;
+	dev_priv->current_page = 0;
+
+	return 0;
+}
+
+int radeon_do_cleanup_pageflip( drm_device_t *dev )
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	RADEON_WRITE( RADEON_CRTC_OFFSET,      dev_priv->crtc_offset );
+	RADEON_WRITE( RADEON_CRTC_OFFSET_CNTL, dev_priv->crtc_offset_cntl );
+
+	dev_priv->page_flipping = 0;
+	dev_priv->current_page = 0;
+
+	return 0;
+}
+
+/* Swapping and flipping are different operations, need different ioctls.
+ * They can & should be intermixed to support multiple 3d windows.  
+ */
+int radeon_cp_flip( struct inode *inode, struct file *filp,
+		    unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+	LOCK_TEST_WITH_RETURN( dev );
+
+	RING_SPACE_TEST_WITH_RETURN( dev_priv );
+
+	if (!dev_priv->page_flipping) 
+		radeon_do_init_pageflip( dev );
+		
+	radeon_cp_dispatch_flip( dev );
+
+	return 0;
+}
+
 int radeon_cp_swap( struct inode *inode, struct file *filp,
 		    unsigned int cmd, unsigned long arg )
 {
@@ -1203,13 +1137,8 @@
 	if ( sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS )
 		sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
 
-	if ( !dev_priv->page_flipping ) {
-		radeon_cp_dispatch_swap( dev );
-		dev_priv->sarea_priv->dirty |= (RADEON_UPLOAD_CONTEXT |
-						RADEON_UPLOAD_MASKS);
-	} else {
-		radeon_cp_dispatch_flip( dev );
-	}
+	radeon_cp_dispatch_swap( dev );
+	dev_priv->sarea_priv->ctx_owner = 0;
 
 	return 0;
 }
@@ -1220,10 +1149,11 @@
 	drm_file_t *priv = filp->private_data;
 	drm_device_t *dev = priv->dev;
 	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
 	drm_device_dma_t *dma = dev->dma;
 	drm_buf_t *buf;
-	drm_radeon_buf_priv_t *buf_priv;
 	drm_radeon_vertex_t vertex;
+	drm_radeon_tcl_prim_t prim;
 
 	LOCK_TEST_WITH_RETURN( dev );
 
@@ -1255,7 +1185,6 @@
 	VB_AGE_TEST_WITH_RETURN( dev_priv );
 
 	buf = dma->buflist[vertex.idx];
-	buf_priv = buf->dev_private;
 
 	if ( buf->pid != current->pid ) {
 		DRM_ERROR( "process %d using buffer owned by %d\n",
@@ -1267,11 +1196,37 @@
 		return -EINVAL;
 	}
 
-	buf->used = vertex.count;
-	buf_priv->prim = vertex.prim;
-	buf_priv->discard = vertex.discard;
+	/* Build up a prim_t record:
+	 */
+	if (vertex.count) {
+		buf->used = vertex.count; /* not used? */
+
+		if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
+			radeon_emit_state( dev_priv,
+					   &sarea_priv->context_state,
+					   sarea_priv->tex_state,
+					   sarea_priv->dirty );
+			
+			sarea_priv->dirty &= ~(RADEON_UPLOAD_TEX0IMAGES |
+					       RADEON_UPLOAD_TEX1IMAGES |
+					       RADEON_UPLOAD_TEX2IMAGES |
+					       RADEON_REQUIRE_QUIESCENCE);
+		}
+
+		prim.start = 0;
+		prim.finish = vertex.count; /* unused */
+		prim.prim = vertex.prim;
+		prim.numverts = vertex.count;
+		prim.vc_format = dev_priv->sarea_priv->vc_format;
+		
+		radeon_cp_dispatch_vertex( dev, buf, &prim,
+					   dev_priv->sarea_priv->boxes,
+					   dev_priv->sarea_priv->nbox );
+	}
 
-	radeon_cp_dispatch_vertex( dev, buf );
+	if (vertex.discard) {
+		radeon_cp_discard_buffer( dev, buf );
+	}
 
 	return 0;
 }
@@ -1282,10 +1237,11 @@
 	drm_file_t *priv = filp->private_data;
 	drm_device_t *dev = priv->dev;
 	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
 	drm_device_dma_t *dma = dev->dma;
 	drm_buf_t *buf;
-	drm_radeon_buf_priv_t *buf_priv;
 	drm_radeon_indices_t elts;
+	drm_radeon_tcl_prim_t prim;
 	int count;
 
 	LOCK_TEST_WITH_RETURN( dev );
@@ -1318,7 +1274,6 @@
 	VB_AGE_TEST_WITH_RETURN( dev_priv );
 
 	buf = dma->buflist[elts.idx];
-	buf_priv = buf->dev_private;
 
 	if ( buf->pid != current->pid ) {
 		DRM_ERROR( "process %d using buffer owned by %d\n",
@@ -1343,10 +1298,35 @@
 	}
 
 	buf->used = elts.end;
-	buf_priv->prim = elts.prim;
-	buf_priv->discard = elts.discard;
 
-	radeon_cp_dispatch_indices( dev, buf, elts.start, elts.end, count );
+	if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
+		radeon_emit_state( dev_priv,
+				   &sarea_priv->context_state,
+				   sarea_priv->tex_state,
+				   sarea_priv->dirty );
+
+		sarea_priv->dirty &= ~(RADEON_UPLOAD_TEX0IMAGES |
+				       RADEON_UPLOAD_TEX1IMAGES |
+				       RADEON_UPLOAD_TEX2IMAGES |
+				       RADEON_REQUIRE_QUIESCENCE);
+	}
+
+
+	/* Build up a prim_t record:
+	 */
+	prim.start = elts.start;
+	prim.finish = elts.end; 
+	prim.prim = elts.prim;
+	prim.offset = 0;	/* offset from start of dma buffers */
+	prim.numverts = RADEON_MAX_VB_VERTS; /* duh */
+	prim.vc_format = dev_priv->sarea_priv->vc_format;
+	
+	radeon_cp_dispatch_indices( dev, buf, &prim,
+				   dev_priv->sarea_priv->boxes,
+				   dev_priv->sarea_priv->nbox );
+	if (elts.discard) {
+		radeon_cp_discard_buffer( dev, buf );
+	}
 
 	return 0;
 }
@@ -1414,7 +1394,6 @@
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_device_dma_t *dma = dev->dma;
 	drm_buf_t *buf;
-	drm_radeon_buf_priv_t *buf_priv;
 	drm_radeon_indirect_t indirect;
 	RING_LOCALS;
 
@@ -1440,7 +1419,6 @@
 	}
 
 	buf = dma->buflist[indirect.idx];
-	buf_priv = buf->dev_private;
 
 	if ( buf->pid != current->pid ) {
 		DRM_ERROR( "process %d using buffer owned by %d\n",
@@ -1462,7 +1440,6 @@
 	VB_AGE_TEST_WITH_RETURN( dev_priv );
 
 	buf->used = indirect.end;
-	buf_priv->discard = indirect.discard;
 
 	/* Wait for the 3D stream to idle before the indirect buffer
 	 * containing 2D acceleration commands is processed.
@@ -1478,6 +1455,434 @@
 	 * privileged clients.
 	 */
 	radeon_cp_dispatch_indirect( dev, buf, indirect.start, indirect.end );
+	if (indirect.discard) {
+		radeon_cp_discard_buffer( dev, buf );
+	}
+
+
+	return 0;
+}
+
+int radeon_cp_vertex2( struct inode *inode, struct file *filp,
+		      unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
+	drm_device_dma_t *dma = dev->dma;
+	drm_buf_t *buf;
+	drm_radeon_vertex2_t vertex;
+	int i;
+	unsigned char laststate;
+
+	LOCK_TEST_WITH_RETURN( dev );
+
+	if ( !dev_priv ) {
+		DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
+		return -EINVAL;
+	}
+
+	if ( copy_from_user( &vertex, (drm_radeon_vertex_t *)arg,
+			     sizeof(vertex) ) )
+		return -EFAULT;
+
+	DRM_DEBUG( __FUNCTION__": pid=%d index=%d discard=%d\n",
+		   current->pid, vertex.idx, vertex.discard );
+
+	if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
+		DRM_ERROR( "buffer index %d (of %d max)\n",
+			   vertex.idx, dma->buf_count - 1 );
+		return -EINVAL;
+	}
+
+	RING_SPACE_TEST_WITH_RETURN( dev_priv );
+	VB_AGE_TEST_WITH_RETURN( dev_priv );
+
+	buf = dma->buflist[vertex.idx];
+
+	if ( buf->pid != current->pid ) {
+		DRM_ERROR( "process %d using buffer owned by %d\n",
+			   current->pid, buf->pid );
+		return -EINVAL;
+	}
+
+	if ( buf->pending ) {
+		DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
+		return -EINVAL;
+	}
+	
+	if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
+		return -EINVAL;
+
+	for (laststate = 0xff, i = 0 ; i < vertex.nr_prims ; i++) {
+		drm_radeon_prim_t prim;
+		drm_radeon_tcl_prim_t tclprim;
+		
+		if ( copy_from_user( &prim, &vertex.prim[i], sizeof(prim) ) )
+			return -EFAULT;
+		
+		if ( prim.stateidx != laststate ) {
+			drm_radeon_state_t state;			       
+				
+			if ( copy_from_user( &state, 
+					     &vertex.state[prim.stateidx], 
+					     sizeof(state) ) )
+				return -EFAULT;
+
+			radeon_emit_state2( dev_priv, &state );
+
+			laststate = prim.stateidx;
+		}
+
+		tclprim.start = prim.start;
+		tclprim.finish = prim.finish;
+		tclprim.prim = prim.prim;
+		tclprim.vc_format = prim.vc_format;
+
+		if ( prim.prim & RADEON_PRIM_WALK_IND ) {
+			tclprim.offset = prim.numverts * 64;
+			tclprim.numverts = RADEON_MAX_VB_VERTS; /* duh */
+
+			radeon_cp_dispatch_indices( dev, buf, &tclprim,
+						    sarea_priv->boxes,
+						    sarea_priv->nbox);
+		} else {
+			tclprim.numverts = prim.numverts;
+			tclprim.offset = 0; /* not used */
+
+			radeon_cp_dispatch_vertex( dev, buf, &tclprim,
+						   sarea_priv->boxes,
+						   sarea_priv->nbox);
+		}
+		
+		if (sarea_priv->nbox == 1)
+			sarea_priv->nbox = 0;
+	}
+
+	if ( vertex.discard ) {
+		radeon_cp_discard_buffer( dev, buf );
+	}
+
+	return 0;
+}
+
+
+static int radeon_emit_packets( 
+	drm_radeon_private_t *dev_priv,
+	drm_radeon_cmd_header_t header,
+	drm_radeon_cmd_buffer_t *cmdbuf )
+{
+	int sz = packet[(int)header.packet.packet_id].len;
+	int reg = packet[(int)header.packet.packet_id].start;
+	int i, tmp, *data = (int *)cmdbuf->buf;
+	RING_LOCALS;
+   
+	if (sz * sizeof(int) > cmdbuf->bufsz) 
+		return -EINVAL;
+
+	BEGIN_RING( (sz+1) );
+	OUT_RING( CP_PACKET0( reg, (sz-1) ) );
+	for ( i = 0 ; i < sz ; i++ ) {
+		if (__get_user( tmp, &data[i] ))
+			return -EFAULT;
+		OUT_RING( tmp );
+	}
+	ADVANCE_RING();
+
+	cmdbuf->buf += sz * sizeof(int);
+	cmdbuf->bufsz -= sz * sizeof(int);
+	return 0;
+}
+
+static inline int radeon_emit_scalars( 
+	drm_radeon_private_t *dev_priv,
+	drm_radeon_cmd_header_t header,
+	drm_radeon_cmd_buffer_t *cmdbuf )
+{
+	int sz = header.scalars.count;
+	int i, tmp, *data = (int *)cmdbuf->buf;
+	int start = header.scalars.offset;
+	int stride = header.scalars.stride;
+	RING_LOCALS;
+
+	BEGIN_RING( 3+sz );
+	OUT_RING( CP_PACKET0( RADEON_SE_TCL_SCALAR_INDX_REG, 0 ) );
+	OUT_RING( start | (stride << RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT));
+	OUT_RING( CP_PACKET0_TABLE( RADEON_SE_TCL_SCALAR_DATA_REG, sz-1 ) );
+	for ( i = 0 ; i < sz ; i++ ) {
+		if (__get_user( tmp, &data[i] ))
+			return -EFAULT;
+		OUT_RING( tmp );
+	}	
+	ADVANCE_RING();
+	cmdbuf->buf += sz * sizeof(int);
+	cmdbuf->bufsz -= sz * sizeof(int);
+	return 0;
+}
+
+static inline int radeon_emit_vectors( 
+	drm_radeon_private_t *dev_priv,
+	drm_radeon_cmd_header_t header,
+	drm_radeon_cmd_buffer_t *cmdbuf )
+{
+	int sz = header.vectors.count;
+	int i, tmp, *data = (int *)cmdbuf->buf;
+	int start = header.vectors.offset;
+	int stride = header.vectors.stride;
+	RING_LOCALS;
+
+	BEGIN_RING( 3+sz );
+	OUT_RING( CP_PACKET0( RADEON_SE_TCL_VECTOR_INDX_REG, 0 ) );
+	OUT_RING( start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT));
+	OUT_RING( CP_PACKET0_TABLE( RADEON_SE_TCL_VECTOR_DATA_REG, (sz-1) ) );
+	for ( i = 0 ; i < sz ; i++ ) {
+		if (__get_user( tmp, &data[i] ))
+			return -EFAULT;
+		OUT_RING( tmp );
+	}	
+	ADVANCE_RING();
+
+	cmdbuf->buf += sz * sizeof(int);
+	cmdbuf->bufsz -= sz * sizeof(int);
+	return 0;
+}
+
+
+static int radeon_emit_packet3( drm_device_t *dev,
+				drm_radeon_cmd_buffer_t *cmdbuf )
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	int cmdsz, tmp;
+	int *cmd = (int *)cmdbuf->buf;
+	int j;
+	RING_LOCALS;
+
+	DRM_DEBUG("%s\n", __FUNCTION__);
+
+	if (__get_user( tmp, &cmd[0]))
+		return -EFAULT;
+
+	cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
+
+	if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
+	    cmdsz * 4 > cmdbuf->bufsz)
+		return -EINVAL;
+
+
+	BEGIN_RING( cmdsz );
+	for (j = 0 ; j < cmdsz ; j++) {
+		if (__get_user( tmp, &cmd[j] ))
+			return -EFAULT;
+/*  		printk( "pk3 %d: %x\n", j, tmp); */
+		OUT_RING( tmp );
+	}
+	ADVANCE_RING();
+
+	cmdbuf->buf += cmdsz * 4;
+	cmdbuf->bufsz -= cmdsz * 4;
+	return 0;
+}
+
+
+static int radeon_emit_packet3_cliprect( drm_device_t *dev,
+					 drm_radeon_cmd_buffer_t *cmdbuf )
+{
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_clip_rect_t box;
+	int cmdsz, tmp;
+	int *cmd = (int *)cmdbuf->buf;
+	drm_clip_rect_t *boxes = cmdbuf->boxes;
+	int i = 0, j;
+	RING_LOCALS;
+
+	DRM_DEBUG("%s\n", __FUNCTION__);
+
+	if (__get_user( tmp, &cmd[0]))
+		return -EFAULT;
+
+	cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
+
+	if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
+	    cmdsz * 4 > cmdbuf->bufsz)
+		return -EINVAL;
+
+	do {
+		if ( i < cmdbuf->nbox ) {
+			if (__copy_from_user( &box, &boxes[i], sizeof(box) ))
+				return -EFAULT;
+			radeon_emit_clip_rect( dev_priv, &box );
+		}
+		
+		BEGIN_RING( cmdsz );
+		for (j = 0 ; j < cmdsz ; j++) {
+			if (__get_user( tmp, &cmd[j] ))
+				return -EFAULT;
+/*  			printk( "pk3_clip %d: %x\n", j, tmp); */
+			OUT_RING( tmp );
+		}
+		ADVANCE_RING();
+
+	} while ( ++i < cmdbuf->nbox );
+
+ 	if (cmdbuf->nbox == 1)
+		cmdbuf->nbox = 0;
+
+	cmdbuf->buf += cmdsz * 4;
+	cmdbuf->bufsz -= cmdsz * 4;
+	return 0;
+}
+
+
+
+int radeon_cp_cmdbuf( struct inode *inode, struct file *filp,
+		      unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_device_dma_t *dma = dev->dma;
+	drm_buf_t *buf = 0;
+	int idx;
+	drm_radeon_cmd_buffer_t cmdbuf;
+	drm_radeon_cmd_header_t header;
+
+	LOCK_TEST_WITH_RETURN( dev );
+
+	if ( !dev_priv ) {
+		DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
+		return -EINVAL;
+	}
+
+	if ( copy_from_user( &cmdbuf, (drm_radeon_cmd_buffer_t *)arg,
+			     sizeof(cmdbuf) ) ) {
+		DRM_ERROR("copy_from_user\n");
+		return -EFAULT;
+	}
+
+	DRM_DEBUG( __FUNCTION__": pid=%d\n", current->pid );
+	RING_SPACE_TEST_WITH_RETURN( dev_priv );
+	VB_AGE_TEST_WITH_RETURN( dev_priv );
+
+
+	if (verify_area( VERIFY_READ, cmdbuf.buf, cmdbuf.bufsz ))
+		return -EFAULT;
+
+	if (verify_area( VERIFY_READ, cmdbuf.boxes, 
+			 cmdbuf.nbox * sizeof(drm_clip_rect_t)))
+		return -EFAULT;
+
+	while ( cmdbuf.bufsz >= sizeof(header) ) {
+		
+		if (__get_user( header.i, (int *)cmdbuf.buf )) {
+			DRM_ERROR("__get_user %p\n", cmdbuf.buf);
+			return -EFAULT;
+		}
+
+		cmdbuf.buf += sizeof(header);
+		cmdbuf.bufsz -= sizeof(header);
+
+		switch (header.header.cmd_type) {
+		case RADEON_CMD_PACKET: 
+			if (radeon_emit_packets( dev_priv, header, &cmdbuf )) {
+				DRM_ERROR("radeon_emit_packets failed\n");
+				return -EINVAL;
+			}
+			break;
+
+		case RADEON_CMD_SCALARS:
+			if (radeon_emit_scalars( dev_priv, header, &cmdbuf )) {
+				DRM_ERROR("radeon_emit_scalars failed\n");
+				return -EINVAL;
+			}
+			break;
+
+		case RADEON_CMD_VECTORS:
+			if (radeon_emit_vectors( dev_priv, header, &cmdbuf )) {
+				DRM_ERROR("radeon_emit_vectors failed\n");
+				return -EINVAL;
+			}
+			break;
+
+		case RADEON_CMD_DMA_DISCARD:
+			idx = header.dma.buf_idx;
+			if ( idx < 0 || idx >= dma->buf_count ) {
+				DRM_ERROR( "buffer index %d (of %d max)\n",
+					   idx, dma->buf_count - 1 );
+				return -EINVAL;
+			}
+
+			buf = dma->buflist[idx];
+			if ( buf->pid != current->pid || buf->pending ) {
+				DRM_ERROR( "bad buffer\n" );
+				return -EINVAL;
+			}
+
+			radeon_cp_discard_buffer( dev, buf );
+			break;
+
+		case RADEON_CMD_PACKET3:
+			if (radeon_emit_packet3( dev, &cmdbuf )) {
+				DRM_ERROR("radeon_emit_packet3 failed\n");
+				return -EINVAL;
+			}
+			break;
+
+		case RADEON_CMD_PACKET3_CLIP:
+			if (radeon_emit_packet3_cliprect( dev, &cmdbuf )) {
+				DRM_ERROR("radeon_emit_packet3_clip failed\n");
+				return -EINVAL;
+			}
+			break;
+
+		default:
+			DRM_ERROR("bad cmd_type %d at %p\n", 
+				  header.header.cmd_type,
+				  cmdbuf.buf - sizeof(header));
+			return -EINVAL;
+		}
+	}
+
+
+	return 0;
+}
+
+
+
+int radeon_cp_getparam( struct inode *inode, struct file *filp,
+		      unsigned int cmd, unsigned long arg )
+{
+	drm_file_t *priv = filp->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_radeon_private_t *dev_priv = dev->dev_private;
+	drm_radeon_getparam_t param;
+	int value;
 
+	if ( !dev_priv ) {
+		DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
+		return -EINVAL;
+	}
+
+	if ( copy_from_user( &param, (drm_radeon_getparam_t *)arg,
+			     sizeof(param) ) ) {
+		DRM_ERROR("copy_from_user\n");
+		return -EFAULT;
+	}
+
+	DRM_DEBUG( __FUNCTION__": pid=%d\n", current->pid );
+
+	switch( param.param ) {
+	case RADEON_PARAM_AGP_BUFFER_OFFSET:
+		value = dev_priv->agp_buffers_offset;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if ( copy_to_user( param.value, &value, sizeof(int) ) ) {
+		DRM_ERROR( "copy_to_user\n" );
+		return -EFAULT;
+	}
+	
 	return 0;
 }
diff -Nru a/drivers/char/drm/sis.h b/drivers/char/drm/sis.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,56 @@
+/* sis_drv.h -- Private header for sis driver -*- linux-c -*-
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis.h,v 1.2 2001/12/19 21:25:59 dawes Exp $ */
+
+#ifndef __SIS_H__
+#define __SIS_H__
+
+/* This remains constant for all DRM template files.
+ * Name it sisdrv_##x as there's a conflict with sis_free/malloc in the kernel
+ * that's used for fb devices 
+ */
+#define DRM(x) sisdrv_##x
+
+/* General customization:
+ */
+#define __HAVE_AGP		1
+#define __MUST_HAVE_AGP		0
+#define __HAVE_MTRR		1
+#define __HAVE_CTX_BITMAP	1
+
+/* Buffer customization:
+ */
+#define DRIVER_AGP_BUFFERS_MAP( dev )					\
+	((drm_sis_private_t *)((dev)->dev_private))->buffers
+
+extern int sis_init_context(int context);
+extern int sis_final_context(int context);
+
+#define DRIVER_CTX_CTOR sis_init_context
+#define DRIVER_CTX_DTOR sis_final_context
+
+#endif
diff -Nru a/drivers/char/drm/sis_drm.h b/drivers/char/drm/sis_drm.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_drm.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,36 @@
+
+#ifndef _sis_drm_public_h_
+#define _sis_drm_public_h_
+
+typedef struct {
+  int context;
+  unsigned int offset;
+  unsigned int size;
+  unsigned int free;
+} drm_sis_mem_t;
+
+typedef struct {
+  unsigned int offset, size;
+} drm_sis_agp_t;
+
+typedef struct {
+  unsigned int left, right;
+} drm_sis_flip_t;
+
+#ifdef __KERNEL__
+
+int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+
+int sisp_agp_init(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+int sisp_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+int sisp_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+
+#endif
+
+#endif
diff -Nru a/drivers/char/drm/sis_drv.c b/drivers/char/drm/sis_drv.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_drv.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,74 @@
+/* sis.c -- sis driver -*- linux-c -*-
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <linux/config.h>
+#include "sis.h"
+#include "drmP.h"
+#include "sis_drm.h"
+#include "sis_drv.h"
+
+#define DRIVER_AUTHOR	 "SIS"
+#define DRIVER_NAME	 "sis"
+#define DRIVER_DESC	 "SIS 300/630/540"
+#define DRIVER_DATE	 "20010503"
+#define DRIVER_MAJOR	 1
+#define DRIVER_MINOR	 0
+#define DRIVER_PATCHLEVEL  0
+
+#define DRIVER_IOCTLS \
+        [DRM_IOCTL_NR(SIS_IOCTL_FB_ALLOC)]   = { sis_fb_alloc,	  1, 0 }, \
+        [DRM_IOCTL_NR(SIS_IOCTL_FB_FREE)]    = { sis_fb_free,	  1, 0 }, \
+        /* AGP Memory Management */					  \
+        [DRM_IOCTL_NR(SIS_IOCTL_AGP_INIT)]   = { sisp_agp_init,	  1, 0 }, \
+        [DRM_IOCTL_NR(SIS_IOCTL_AGP_ALLOC)]  = { sisp_agp_alloc,  1, 0 }, \
+        [DRM_IOCTL_NR(SIS_IOCTL_AGP_FREE)]   = { sisp_agp_free,	  1, 0 }
+#if 0 /* these don't appear to be defined */
+	/* SIS Stereo */						 
+	[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)]    = { sis_control,	  1, 1 }, 
+        [DRM_IOCTL_NR(SIS_IOCTL_FLIP)]       = { sis_flip,	  1, 1 }, 
+        [DRM_IOCTL_NR(SIS_IOCTL_FLIP_INIT)]  = { sis_flip_init,	  1, 1 }, 
+        [DRM_IOCTL_NR(SIS_IOCTL_FLIP_FINAL)] = { sis_flip_final,  1, 1 }
+#endif
+
+#define __HAVE_COUNTERS		5
+
+#include "drm_auth.h"
+#include "drm_agpsupport.h"
+#include "drm_bufs.h"
+#include "drm_context.h"
+#include "drm_dma.h"
+#include "drm_drawable.h"
+#include "drm_drv.h"
+#include "drm_fops.h"
+#include "drm_init.h"
+#include "drm_ioctl.h"
+#include "drm_lists.h"
+#include "drm_lock.h"
+#include "drm_memory.h"
+#include "drm_proc.h"
+#include "drm_vm.h"
+#include "drm_stub.h"
diff -Nru a/drivers/char/drm/sis_drv.h b/drivers/char/drm/sis_drv.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_drv.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,45 @@
+/* sis_drv.h -- Private header for sis driver -*- linux-c -*-
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ */
+
+#ifndef _SIS_DRV_H_
+#define _SIS_DRV_H_
+
+typedef struct drm_sis_private {
+	drm_map_t *buffers;
+} drm_sis_private_t;
+
+/* Stereo ? - this was never committed */
+
+int sis_flip(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+int sis_flip_init(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+int sis_flip_final(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg);
+void flip_final(void);
+
+#endif
diff -Nru a/drivers/char/drm/sis_ds.c b/drivers/char/drm/sis_ds.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_ds.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,406 @@
+/* sis_ds.c -- Private header for Direct Rendering Manager -*- linux-c -*-
+ * Created: Mon Jan  4 10:05:05 1999 by sclin@sis.com.tw
+ *
+ * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ * 
+ */
+
+#define __NO_VERSION__
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <asm/io.h>
+#include <linux/pci.h>
+
+#include "sis_ds.h"
+
+/* Set Data Structure, not check repeated value
+ * temporarily used
+ */
+
+set_t *setInit(void)
+{
+  int i;
+  set_t *set;
+
+  set = (set_t *)MALLOC(sizeof(set_t));
+  for(i = 0; i < SET_SIZE; i++){
+    set->list[i].free_next = i+1;    
+    set->list[i].alloc_next = -1;
+  }    
+  set->list[SET_SIZE-1].free_next = -1;
+  set->free = 0;
+  set->alloc = -1;
+  set->trace = -1;
+  
+  return set;
+}
+
+int setAdd(set_t *set, ITEM_TYPE item)
+{
+  int free = set->free;
+  
+  if(free != -1){
+    set->list[free].val = item;
+    set->free = set->list[free].free_next;
+  }
+  else{
+    return 0;
+  }
+
+  set->list[free].alloc_next = set->alloc;
+  set->alloc = free;  
+  set->list[free].free_next = -1;    
+
+  return 1;
+}
+
+int setDel(set_t *set, ITEM_TYPE item)
+{
+  int alloc = set->alloc;
+  int prev = -1;  
+  
+  while(alloc != -1){
+    if(set->list[alloc].val == item){
+      if(prev != -1)      
+        set->list[prev].alloc_next = set->list[alloc].alloc_next; 
+      else
+        set->alloc = set->list[alloc].alloc_next;
+      break;
+    }
+    prev = alloc;
+    alloc = set->list[alloc].alloc_next;      
+  }
+
+  if(alloc == -1)
+    return 0;
+  
+  set->list[alloc].free_next = set->free;
+  set->free = alloc;
+  set->list[alloc].alloc_next = -1;   
+
+  return 1;
+}
+
+/* setFirst -> setAdd -> setNext is wrong */
+
+int setFirst(set_t *set, ITEM_TYPE *item)
+{
+  if(set->alloc == -1)
+    return 0;
+
+  *item = set->list[set->alloc].val;
+  set->trace = set->list[set->alloc].alloc_next; 
+
+  return 1;
+}
+
+int setNext(set_t *set, ITEM_TYPE *item)
+{
+  if(set->trace == -1)
+    return 0;
+  
+  *item = set->list[set->trace].val;
+  set->trace = set->list[set->trace].alloc_next;      
+
+  return 1;
+}
+
+int setDestroy(set_t *set)
+{
+  FREE(set);
+
+  return 1;
+}
+
+/*
+ * GLX Hardware Device Driver common code
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#define ISFREE(bptr) ((bptr)->free)
+
+#define PRINTF(fmt, arg...) do{}while(0)
+#define fprintf(fmt, arg...) do{}while(0)
+
+static void *calloc(size_t nmemb, size_t size)
+{
+  void *addr;
+  addr = kmalloc(nmemb*size, GFP_KERNEL);
+  memset(addr, 0, nmemb*size);
+  return addr;
+}
+#define free(n) kfree(n)
+           
+void mmDumpMemInfo( memHeap_t *heap )
+{
+  TMemBlock *p;
+
+  PRINTF ("Memory heap %p:\n", heap);
+  if (heap == 0) {
+    PRINTF ("  heap == 0\n");
+  } else {
+    p = (TMemBlock *)heap;
+    while (p) {
+      PRINTF ("  Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
+	     p->free ? '.':'U',
+	     p->reserved ? 'R':'.');
+      p = p->next;
+    }
+  }
+  PRINTF ("End of memory blocks\n");
+}
+
+memHeap_t *mmInit(int ofs,
+		  int size)
+{
+   PMemBlock blocks;
+  
+   if (size <= 0) {
+      return 0;
+   }
+   blocks = (TMemBlock *) calloc(1,sizeof(TMemBlock));
+   if (blocks) {
+      blocks->ofs = ofs;
+      blocks->size = size;
+      blocks->free = 1;
+      return (memHeap_t *)blocks;
+   } else
+      return 0;
+}
+
+/* Kludgey workaround for existing i810 server.  Remove soon.
+ */
+memHeap_t *mmAddRange( memHeap_t *heap,
+		       int ofs,
+		       int size )
+{
+   PMemBlock blocks;
+   blocks = (TMemBlock *) calloc(2,sizeof(TMemBlock));
+   if (blocks) {
+      blocks[0].size = size;
+      blocks[0].free = 1;
+      blocks[0].ofs = ofs;
+      blocks[0].next = &blocks[1];
+
+      /* Discontinuity - stops JoinBlock from trying to join non-adjacent
+       * ranges.
+       */
+      blocks[1].size = 0;
+      blocks[1].free = 0;
+      blocks[1].ofs = ofs+size;
+      blocks[1].next = (PMemBlock) heap;      
+      return (memHeap_t *)blocks;
+   } 
+   else
+      return heap;
+}
+
+static TMemBlock* SliceBlock(TMemBlock *p, 
+			     int startofs, int size, 
+			     int reserved, int alignment)
+{
+  TMemBlock *newblock;
+
+  /* break left */
+  if (startofs > p->ofs) {
+    newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
+    newblock->ofs = startofs;
+    newblock->size = p->size - (startofs - p->ofs);
+    newblock->free = 1;
+    newblock->next = p->next;
+    p->size -= newblock->size;
+    p->next = newblock;
+    p = newblock;
+  }
+
+  /* break right */
+  if (size < p->size) {
+    newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
+    newblock->ofs = startofs + size;
+    newblock->size = p->size - size;
+    newblock->free = 1;
+    newblock->next = p->next;
+    p->size = size;
+    p->next = newblock;
+  }
+
+  /* p = middle block */
+  p->align = alignment;
+  p->free = 0;
+  p->reserved = reserved;
+  return p;
+}
+
+PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch)
+{
+  int mask,startofs,endofs;
+  TMemBlock *p;
+
+  if (!heap || align2 < 0 || size <= 0)
+    return NULL;
+  mask = (1 << align2)-1;
+  startofs = 0;
+  p = (TMemBlock *)heap;
+  while (p) {
+    if (ISFREE(p)) {
+      startofs = (p->ofs + mask) & ~mask;
+      if ( startofs < startSearch ) {
+      	startofs = startSearch;
+      }
+      endofs = startofs+size;
+      if (endofs <= (p->ofs+p->size))
+	break;
+    }
+    p = p->next;
+  }
+  if (!p)
+    return NULL;
+  p = SliceBlock(p,startofs,size,0,mask+1);
+  p->heap = heap;
+  return p;
+}
+
+static __inline__ int Join2Blocks(TMemBlock *p)
+{
+  if (p->free && p->next && p->next->free) {
+    TMemBlock *q = p->next;
+    p->size += q->size;
+    p->next = q->next;
+    free(q);
+    return 1;
+  }
+  return 0;
+}
+
+int mmFreeMem(PMemBlock b)
+{
+  TMemBlock *p,*prev;
+
+  if (!b)
+    return 0;
+  if (!b->heap) {
+     fprintf(stderr, "no heap\n");
+     return -1;
+  }
+  p = b->heap;
+  prev = NULL;
+  while (p && p != b) {
+    prev = p;
+    p = p->next;
+  }
+  if (!p || p->free || p->reserved) {
+     if (!p)
+	fprintf(stderr, "block not found in heap\n");
+     else if (p->free)
+	fprintf(stderr, "block already free\n");
+     else
+	fprintf(stderr, "block is reserved\n");
+    return -1;
+  }
+  p->free = 1;
+  Join2Blocks(p);
+  if (prev)
+    Join2Blocks(prev);
+  return 0;
+}
+
+int mmReserveMem(memHeap_t *heap, int offset,int size)
+{
+  int endofs;
+  TMemBlock *p;
+
+  if (!heap || size <= 0)
+    return -1;
+  endofs = offset+size;
+  p = (TMemBlock *)heap;
+  while (p && p->ofs <= offset) {
+    if (ISFREE(p) && endofs <= (p->ofs+p->size)) {
+      SliceBlock(p,offset,size,1,1);
+      return 0;
+    }
+    p = p->next;
+  }
+  return -1;
+}
+
+int mmFreeReserved(memHeap_t *heap, int offset)
+{
+  TMemBlock *p,*prev;
+
+  if (!heap)
+    return -1;
+  p = (TMemBlock *)heap;
+  prev = NULL;
+  while (p && p->ofs != offset) {
+    prev = p;
+    p = p->next;
+  }
+  if (!p || !p->reserved)
+    return -1;
+  p->free = 1;
+  p->reserved = 0;
+  Join2Blocks(p);
+  if (prev)
+    Join2Blocks(prev);
+  return 0;
+}
+
+void mmDestroy(memHeap_t *heap)
+{
+  TMemBlock *p,*q;
+
+  if (!heap)
+    return;
+  p = (TMemBlock *)heap;
+  while (p) {
+    q = p->next;
+    free(p);
+    p = q;
+  }
+}
diff -Nru a/drivers/char/drm/sis_ds.h b/drivers/char/drm/sis_ds.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_ds.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,163 @@
+/* sis_ds.h -- Private header for Direct Rendering Manager -*- linux-c -*-
+ * Created: Mon Jan  4 10:05:05 1999 by sclin@sis.com.tw
+ *
+ * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ * 
+ */
+
+#ifndef _sis_ds_h_
+#define _sis_ds_h_
+
+/* Set Data Structure */
+
+#define SET_SIZE 5000
+#define MALLOC(s) kmalloc(s, GFP_KERNEL)
+#define FREE(s) kfree(s)
+
+typedef unsigned int ITEM_TYPE;
+
+typedef struct {
+  ITEM_TYPE val;
+  int alloc_next, free_next;
+} list_item_t;
+
+typedef struct {
+  int alloc;
+  int free;
+  int trace;
+  list_item_t list[SET_SIZE];
+} set_t;
+
+set_t *setInit(void);
+int setAdd(set_t *set, ITEM_TYPE item);
+int setDel(set_t *set, ITEM_TYPE item);
+int setFirst(set_t *set, ITEM_TYPE *item);
+int setNext(set_t *set, ITEM_TYPE *item);
+int setDestroy(set_t *set);
+
+#endif
+
+/*
+ * GLX Hardware Device Driver common code
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef MM_INC
+#define MM_INC
+
+struct mem_block_t {
+  struct mem_block_t *next;
+  struct mem_block_t *heap;
+  int ofs,size;
+  int align;
+  int free:1;
+  int reserved:1;
+};
+typedef struct mem_block_t TMemBlock;
+typedef struct mem_block_t *PMemBlock;
+
+/* a heap is just the first block in a chain */
+typedef struct mem_block_t memHeap_t;
+
+static __inline__ int mmBlockSize(PMemBlock b)
+{ return b->size; }
+
+static __inline__ int mmOffset(PMemBlock b)
+{ return b->ofs; }
+
+static __inline__ void mmMarkReserved(PMemBlock b)
+{ b->reserved = 1; }
+
+/* 
+ * input: total size in bytes
+ * return: a heap pointer if OK, NULL if error
+ */
+memHeap_t *mmInit( int ofs, int size );
+
+
+
+memHeap_t *mmAddRange( memHeap_t *heap,
+		       int ofs,
+		       int size );
+
+
+/*
+ * Allocate 'size' bytes with 2^align2 bytes alignment,
+ * restrict the search to free memory after 'startSearch'
+ * depth and back buffers should be in different 4mb banks
+ * to get better page hits if possible
+ * input:	size = size of block
+ *       	align2 = 2^align2 bytes alignment
+ *		startSearch = linear offset from start of heap to begin search
+ * return: pointer to the allocated block, 0 if error
+ */
+PMemBlock  mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch );
+
+/*
+ * Free block starts at offset
+ * input: pointer to a block
+ * return: 0 if OK, -1 if error
+ */
+int  mmFreeMem( PMemBlock b );
+
+/*
+ * Reserve 'size' bytes block start at offset
+ * This is used to prevent allocation of memory already used
+ * by the X server for the front buffer, pixmaps, and cursor
+ * input: size, offset
+ * output: 0 if OK, -1 if error
+ */
+int mmReserveMem( memHeap_t *heap, int offset,int size );
+int mmFreeReserved( memHeap_t *heap, int offset );
+
+/*
+ * destroy MM
+ */
+void mmDestroy( memHeap_t *mmInit );
+
+/* For debuging purpose. */
+void mmDumpMemInfo( memHeap_t *mmInit );
+
+#endif
diff -Nru a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/char/drm/sis_mm.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,307 @@
+/* sis_mm.c -- Private header for Direct Rendering Manager -*- linux-c -*-
+ * Created: Mon Jan  4 10:05:05 1999 by sclin@sis.com.tw
+ *
+ * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ * 
+ */
+
+#define __NO_VERSION__
+#include "sis.h"
+#include <linux/sisfb.h>
+#include "drmP.h"
+#include "sis_drm.h"
+#include "sis_drv.h"
+#include "sis_ds.h"
+
+#define MAX_CONTEXT 100
+#define VIDEO_TYPE 0 
+#define AGP_TYPE 1
+
+typedef struct {
+  int used;
+  int context;
+  set_t *sets[2]; /* 0 for video, 1 for AGP */
+} sis_context_t;
+
+static sis_context_t global_ppriv[MAX_CONTEXT];
+
+static int add_alloc_set(int context, int type, unsigned int val)
+{
+  int i, retval = 0;
+  
+  for(i = 0; i < MAX_CONTEXT; i++)
+    if(global_ppriv[i].used && global_ppriv[i].context == context){
+      retval = setAdd(global_ppriv[i].sets[type], val);
+      break;
+    }
+  return retval;
+}
+
+static int del_alloc_set(int context, int type, unsigned int val)
+{  
+  int i, retval = 0;
+  for(i = 0; i < MAX_CONTEXT; i++)
+    if(global_ppriv[i].used && global_ppriv[i].context == context){
+      retval = setDel(global_ppriv[i].sets[type], val);
+      break;
+    }
+  return retval;
+}
+
+/* fb management via fb device */ 
+#if 1
+int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  drm_sis_mem_t fb;
+  struct sis_memreq req;
+  int retval = 0;
+   
+  if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb)))
+	  return -EFAULT;
+  
+  req.size = fb.size;
+  sis_malloc(&req);
+  if(req.offset){
+    /* TODO */
+    fb.offset = req.offset;
+    fb.free = req.offset;
+    if(!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)){
+      DRM_DEBUG("adding to allocation set fails\n");
+      sis_free(req.offset);
+      retval = -1;
+    }
+  }
+  else{  
+    fb.offset = 0;
+    fb.size = 0;
+    fb.free = 0;
+  }
+   
+  if (copy_to_user((drm_sis_mem_t *)arg, &fb, sizeof(fb))) return -EFAULT;
+
+  DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset);
+
+  return retval;
+}
+
+int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  drm_sis_mem_t fb;
+  int retval = 0;
+    
+  if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb)))
+	  return -EFAULT;
+  
+  if(!fb.free){
+    return -1;
+  }
+
+  sis_free(fb.free);
+  if(!del_alloc_set(fb.context, VIDEO_TYPE, fb.free))
+    retval = -1;
+
+  DRM_DEBUG("free fb, offset = %d\n", fb.free);
+  
+  return retval;
+}
+
+#else
+
+int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  return -1;
+}
+
+int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  return 0;
+}
+
+#endif
+
+/* agp memory management */ 
+#if 1
+
+static memHeap_t *AgpHeap = NULL;
+
+int sisp_agp_init(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  drm_sis_agp_t agp;
+   
+  if (copy_from_user(&agp, (drm_sis_agp_t *)arg, sizeof(agp)))
+	  return -EFAULT;
+
+  AgpHeap = mmInit(agp.offset, agp.size);
+
+  DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
+  
+  return 0;
+}
+
+int sisp_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  drm_sis_mem_t agp;
+  PMemBlock block;
+  int retval = 0;
+   
+  if(!AgpHeap)
+    return -1;
+  
+  if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
+	  return -EFAULT;
+  
+  block = mmAllocMem(AgpHeap, agp.size, 0, 0);
+  if(block){
+    /* TODO */
+    agp.offset = block->ofs;
+    agp.free = (unsigned int)block;
+    if(!add_alloc_set(agp.context, AGP_TYPE, agp.free)){
+      DRM_DEBUG("adding to allocation set fails\n");
+      mmFreeMem((PMemBlock)agp.free);
+      retval = -1;
+    }
+  }
+  else{  
+    agp.offset = 0;
+    agp.size = 0;
+    agp.free = 0;
+  }
+   
+  if (copy_to_user((drm_sis_mem_t *)arg, &agp, sizeof(agp))) return -EFAULT;
+
+  DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset);
+
+  return retval;
+}
+
+int sisp_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
+		  unsigned long arg)
+{
+  drm_sis_mem_t agp;
+  int retval = 0;
+
+  if(!AgpHeap)
+    return -1;
+    
+  if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
+	  return -EFAULT;
+  
+  if(!agp.free){
+    return -1;
+  }
+
+  mmFreeMem((PMemBlock)agp.free);
+  if(!del_alloc_set(agp.context, AGP_TYPE, agp.free))
+    retval = -1;
+
+  DRM_DEBUG("free agp, free = %d\n", agp.free);
+  
+  return retval;
+}
+
+#endif
+
+int sis_init_context(int context)
+{
+	int i;
+	
+	for(i = 0; i < MAX_CONTEXT ; i++)
+	  if(global_ppriv[i].used && (global_ppriv[i].context == context))
+	    break;
+
+	if(i >= MAX_CONTEXT){
+	  for(i = 0; i < MAX_CONTEXT ; i++){
+	    if(!global_ppriv[i].used){
+	      global_ppriv[i].context = context;
+	      global_ppriv[i].used = 1;
+	      global_ppriv[i].sets[0] = setInit();
+	      global_ppriv[i].sets[1] = setInit();
+	      DRM_DEBUG("init allocation set, socket=%d, context = %d\n", 
+	                 i, context);
+	      break;
+	    }	
+	  }
+	  if((i >= MAX_CONTEXT) || (global_ppriv[i].sets[0] == NULL) ||
+	     (global_ppriv[i].sets[1] == NULL)){
+	    return 0;
+	  }
+	}
+	
+	return 1;
+}
+
+int sis_final_context(int context)
+{
+	int i;
+
+	for(i=0; i<MAX_CONTEXT; i++)
+	  if(global_ppriv[i].used && (global_ppriv[i].context == context))
+	    break;
+          
+	if(i < MAX_CONTEXT){
+	  set_t *set;
+	  unsigned int item;
+	  int retval;
+	  
+  	  DRM_DEBUG("find socket %d, context = %d\n", i, context);
+
+	  /* Video Memory */
+	  set = global_ppriv[i].sets[0];
+	  retval = setFirst(set, &item);
+	  while(retval){
+   	    DRM_DEBUG("free video memory 0x%x\n", item);
+            sis_free(item);
+	    retval = setNext(set, &item);
+	  }
+	  setDestroy(set);
+
+	  /* AGP Memory */
+	  set = global_ppriv[i].sets[1];
+	  retval = setFirst(set, &item);
+	  while(retval){
+   	    DRM_DEBUG("free agp memory 0x%x\n", item);
+	    mmFreeMem((PMemBlock)item);
+	    retval = setNext(set, &item);
+	  }
+	  setDestroy(set);
+	  
+	  global_ppriv[i].used = 0;	  
+        }
+
+	/* turn-off auto-flip */
+	/* TODO */
+#if defined(SIS_STEREO)
+	flip_final();
+#endif
+	
+	return 1;
+}
diff -Nru a/drivers/char/eurotechwdt.c b/drivers/char/eurotechwdt.c
--- a/drivers/char/eurotechwdt.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/eurotechwdt.c	Fri May 24 18:55:33 2002
@@ -504,4 +504,3 @@
 MODULE_AUTHOR("Rodolfo Giometti");
 MODULE_DESCRIPTION("Driver for Eurotech CPU-1220/1410 on board watchdog");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/ftape/Makefile b/drivers/char/ftape/Makefile
--- a/drivers/char/ftape/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/char/ftape/Makefile	Fri May 24 18:55:35 2002
@@ -23,22 +23,8 @@
 #      Linux.
 #
 
-O_TARGET := ftape.o
-
-subdir-$(CONFIG_FTAPE) += lowlevel
-subdir-$(CONFIG_ZFTAPE) += zftape
-subdir-$(CONFIG_ZFT_COMPRESSOR) += compressor
-
-ifeq ($(CONFIG_FTAPE),y)
-  obj-y    += lowlevel/ftape.o
-endif
-
-ifeq ($(CONFIG_ZFTAPE),y)
-  obj-y   += zftape/zftape.o
-endif
-
-ifeq ($(CONFIG_ZFT_COMPRESSOR),y)
-  obj-y += compressor/zft-compressor.o
-endif
+obj-$(CONFIG_FTAPE)		+= lowlevel/
+obj-$(CONFIG_ZFTAPE)		+= zftape/
+obj-$(CONFIG_ZFT_COMPRESSOR)	+= compressor/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/char/ftape/compressor/Makefile b/drivers/char/ftape/compressor/Makefile
--- a/drivers/char/ftape/compressor/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/char/ftape/compressor/Makefile	Fri May 24 18:55:35 2002
@@ -24,11 +24,9 @@
 #      Linux.
 #
 
-O_TARGET := zft-compressor.o
+obj-$(CONFIG_ZFT_COMPRESSOR) += zft-compressor.o
 
-obj-y    = zftape-compress.o lzrw3.o
-
-obj-m    = $(O_TARGET)
+zft-compressor-objs := zftape-compress.o lzrw3.o
 
 CFLAGS_lzrw3.o	:= -O6 -funroll-all-loops
 
diff -Nru a/drivers/char/ftape/compressor/zftape-compress.c b/drivers/char/ftape/compressor/zftape-compress.c
--- a/drivers/char/ftape/compressor/zftape-compress.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/ftape/compressor/zftape-compress.c	Fri May 24 18:55:34 2002
@@ -1285,7 +1285,6 @@
 	if (!mod_member_present(&__this_module, can_unload))
 		return -EBUSY;
 	__this_module.can_unload = can_unload;
-	EXPORT_NO_SYMBOLS;
 #endif
 	result = zft_compressor_init();
 	keep_module_locked = 0;
diff -Nru a/drivers/char/ftape/lowlevel/Makefile b/drivers/char/ftape/lowlevel/Makefile
--- a/drivers/char/ftape/lowlevel/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/char/ftape/lowlevel/Makefile	Fri May 24 18:55:34 2002
@@ -23,28 +23,26 @@
 #      driver for Linux.
 #
 
-O_TARGET := ftape.o
-
 export-objs := ftape_syms.o
 
-obj-y     = ftape-init.o fdc-io.o fdc-isr.o \
-	    ftape-bsm.o ftape-ctl.o ftape-read.o ftape-rw.o \
-	    ftape-write.o ftape-io.o ftape-calibr.o ftape-ecc.o fc-10.o \
-	    ftape-buffer.o ftape-format.o ftape_syms.o
+obj-$(CONFIG_FTAPE) += ftape.o
+
+ftape-objs := ftape-init.o fdc-io.o fdc-isr.o \
+	      ftape-bsm.o ftape-ctl.o ftape-read.o ftape-rw.o \
+	      ftape-write.o ftape-io.o ftape-calibr.o ftape-ecc.o fc-10.o \
+	      ftape-buffer.o ftape-format.o ftape_syms.o
 
-obj-$(CONFIG_FTAPE) += ftape-setup.o
+ifeq ($(CONFIG_FTAPE),y)
+ftape-objs += ftape-setup.o
+endif
 
 ifndef CONFIG_FT_NO_TRACE_AT_ALL
-obj-y   += ftape-tracing.o
+ftape-objs += ftape-tracing.o
 endif
 
-ifeq ($(CONFIG_PROC_FS),y)
 ifeq ($(CONFIG_FT_PROC_FS),y)
-obj-y += ftape-proc.o
+ftape-objs += ftape-proc.o
 endif
-endif
-
-obj-m  = $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/char/ftape/lowlevel/ftape-calibr.c b/drivers/char/ftape/lowlevel/ftape-calibr.c
--- a/drivers/char/ftape/lowlevel/ftape-calibr.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/ftape/lowlevel/ftape-calibr.c	Fri May 24 18:55:34 2002
@@ -26,7 +26,7 @@
 
 #include <linux/config.h>
 #include <linux/errno.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #if defined(__alpha__)
diff -Nru a/drivers/char/ftape/zftape/Makefile b/drivers/char/ftape/zftape/Makefile
--- a/drivers/char/ftape/zftape/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/char/ftape/zftape/Makefile	Fri May 24 18:55:36 2002
@@ -27,17 +27,15 @@
 # ZFT_OBSOLETE - enable the MTIOC_ZFTAPE_GETBLKSZ ioctl. You should
 #                leave this enabled for compatibility with taper.
 
-EXTRA_CFLAGS := -DZFT_OBSOLETE
-
-O_TARGET := zftape.o
-
 export-objs := zftape_syms.o
 
-obj-y    := zftape-rw.o zftape-ctl.o zftape-read.o \
-	    zftape-write.o zftape-vtbl.o zftape-eof.o \
-	    zftape-init.o zftape-buffers.o zftape_syms.o
+obj-$(CONFIG_ZFTAPE) += zftape.o
 
-obj-m    := $(O_TARGET)
+zftape-objs := zftape-rw.o zftape-ctl.o zftape-read.o \
+	       zftape-write.o zftape-vtbl.o zftape-eof.o \
+	       zftape-init.o zftape-buffers.o zftape_syms.o
+
+EXTRA_CFLAGS := -DZFT_OBSOLETE
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/char/h8.c b/drivers/char/h8.c
--- a/drivers/char/h8.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/h8.c	Fri May 24 18:55:35 2002
@@ -1177,4 +1177,3 @@
 }
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/logibusmouse.c b/drivers/char/logibusmouse.c
--- a/drivers/char/logibusmouse.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/logibusmouse.c	Fri May 24 18:55:36 2002
@@ -163,4 +163,3 @@
 module_exit(logi_busmouse_cleanup);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
--- a/drivers/char/lp.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/lp.c	Fri May 24 18:55:33 2002
@@ -978,4 +978,3 @@
 module_exit(lp_cleanup_module);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/machzwd.c b/drivers/char/machzwd.c
--- a/drivers/char/machzwd.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/machzwd.c	Fri May 24 18:55:34 2002
@@ -35,7 +35,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/slab.h>
diff -Nru a/drivers/char/mixcomwd.c b/drivers/char/mixcomwd.c
--- a/drivers/char/mixcomwd.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/mixcomwd.c	Fri May 24 18:55:34 2002
@@ -276,4 +276,3 @@
 module_exit(mixcomwd_exit);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/moxa.c b/drivers/char/moxa.c
--- a/drivers/char/moxa.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/moxa.c	Fri May 24 18:55:36 2002
@@ -210,8 +210,6 @@
 MODULE_PARM(calloutmajor, "i");
 MODULE_PARM(verbose, "i");
 
-EXPORT_NO_SYMBOLS;
-
 #endif				//MODULE
 
 static struct tty_driver moxaDriver;
diff -Nru a/drivers/char/msbusmouse.c b/drivers/char/msbusmouse.c
--- a/drivers/char/msbusmouse.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/msbusmouse.c	Fri May 24 18:55:36 2002
@@ -173,4 +173,3 @@
 module_exit(ms_bus_mouse_exit)
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/mwave/Makefile b/drivers/char/mwave/Makefile
--- a/drivers/char/mwave/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/char/mwave/Makefile	Fri May 24 18:55:34 2002
@@ -3,23 +3,15 @@
 #
 # See the README file in this directory for more info. <paulsch@us.ibm.com>
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now inherited from the
-# parent makes..
-#
 
-# To compile in lots (~20 KiB) of run-time enablable printk()s for debugging:
-EXTRA_CFLAGS += -DMW_TRACE
+obj-$(CONFIG_MWAVE) += mwave.o
+
+mwave-objs := mwavedd.o smapi.o tp3780i.o 3780i.o
 
 # To have the mwave driver disable other uarts if necessary
 # EXTRA_CFLAGS += -DMWAVE_FUTZ_WITH_OTHER_DEVICES
 
-O_TARGET := mwave.o
-
-obj-y	:= mwavedd.o smapi.o tp3780i.o 3780i.o
-obj-m	:= $(O_TARGET)
+# To compile in lots (~20 KiB) of run-time enablable printk()s for debugging:
+EXTRA_CFLAGS += -DMW_TRACE
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/char/mxser.c b/drivers/char/mxser.c
--- a/drivers/char/mxser.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/mxser.c	Fri May 24 18:55:36 2002
@@ -221,8 +221,6 @@
 MODULE_PARM(calloutmajor, "i");
 MODULE_PARM(verbose, "i");
 
-EXPORT_NO_SYMBOLS;
-
 struct mxser_hwconf {
 	int board_type;
 	int ports;
diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
--- a/drivers/char/n_hdlc.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/n_hdlc.c	Fri May 24 18:55:34 2002
@@ -1025,4 +1025,3 @@
 module_exit(n_hdlc_exit);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
--- a/drivers/char/n_r3964.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/n_r3964.c	Fri May 24 18:55:36 2002
@@ -1476,4 +1476,3 @@
 
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/nvram.c b/drivers/char/nvram.c
--- a/drivers/char/nvram.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/nvram.c	Fri May 24 18:55:35 2002
@@ -706,8 +706,6 @@
 
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 /*
  * Local variables:
  *  c-indent-level: 4
diff -Nru a/drivers/char/nwbutton.c b/drivers/char/nwbutton.c
--- a/drivers/char/nwbutton.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/nwbutton.c	Fri May 24 18:55:35 2002
@@ -241,7 +241,6 @@
 
 MODULE_AUTHOR("Alex Holden");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 module_init(nwbutton_init);
 module_exit(nwbutton_exit);
diff -Nru a/drivers/char/nwflash.c b/drivers/char/nwflash.c
--- a/drivers/char/nwflash.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/nwflash.c	Fri May 24 18:55:35 2002
@@ -702,8 +702,6 @@
 	iounmap((void *)FLASH_BASE);
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_LICENSE("GPL");
 
 MODULE_PARM(flashdebug, "i");
diff -Nru a/drivers/char/pc110pad.c b/drivers/char/pc110pad.c
--- a/drivers/char/pc110pad.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/pc110pad.c	Fri May 24 18:55:33 2002
@@ -849,4 +849,3 @@
 MODULE_DESCRIPTION("Driver for the touchpad on the IBM PC110 palmtop");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/pcmcia/Makefile b/drivers/char/pcmcia/Makefile
--- a/drivers/char/pcmcia/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/char/pcmcia/Makefile	Fri May 24 18:55:33 2002
@@ -4,8 +4,6 @@
 # Makefile for the Linux PCMCIA char device drivers.
 #
 
-O_TARGET := pcmcia_char.o
-
 obj-$(CONFIG_PCMCIA_SERIAL_CS)	+= serial_cs.o
 obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o
 
diff -Nru a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
--- a/drivers/char/pcmcia/synclink_cs.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/pcmcia/synclink_cs.c	Fri May 24 18:55:35 2002
@@ -3239,8 +3239,6 @@
 {
     servinfo_t serv;
 
-    EXPORT_NO_SYMBOLS;
-	
     if (break_on_load) {
 	    mgslpc_get_text_ptr();
 	    BREAKPOINT();
diff -Nru a/drivers/char/pcwd.c b/drivers/char/pcwd.c
--- a/drivers/char/pcwd.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/pcwd.c	Fri May 24 18:55:33 2002
@@ -114,12 +114,6 @@
 {
 	int card_dat, prev_card_dat, found = 0, count = 0, done = 0;
 
-	/* As suggested by Alan Cox - this is a safety measure. */
-	if (check_region(current_readport, 4)) {
-		printk("pcwd: Port 0x%x unavailable.\n", current_readport);
-		return 0;
-	}
-
 	card_dat = 0x00;
 	prev_card_dat = 0x00;
 
@@ -628,15 +622,31 @@
 		outb_p(0xA5, current_readport + 3);
 	}
 
-	if (revision == PCWD_REVISION_A)
-		request_region(current_readport, 2, "PCWD Rev.A (Berkshire)");
-	else
-		request_region(current_readport, 4, "PCWD Rev.C (Berkshire)");
+	if (misc_register(&pcwd_miscdev))
+		return -ENODEV;
+	
+	if (supports_temp)
+		if (misc_register(&temp_miscdev)) {
+			misc_deregister(&pcwd_miscdev);
+			return -ENODEV;		
+		}
 
-	misc_register(&pcwd_miscdev);
 
-	if (supports_temp)
-		misc_register(&temp_miscdev);
+	if (revision == PCWD_REVISION_A) {
+		if (!request_region(current_readport, 2, "PCWD Rev.A (Berkshire)")) {
+			misc_deregister(&pcwd_miscdev);
+			if (supports_temp)
+				misc_deregister(&pcwd_miscdev);
+			return -EIO;		
+		}
+	}
+	else 
+		if (!request_region(current_readport, 4, "PCWD Rev.C (Berkshire)")) {
+			misc_deregister(&pcwd_miscdev);
+			if (supports_temp)
+				misc_deregister(&pcwd_miscdev);
+			return -EIO;
+		}
 
 	return 0;
 }
@@ -660,4 +670,3 @@
 
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/ppdev.c b/drivers/char/ppdev.c
--- a/drivers/char/ppdev.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/ppdev.c	Fri May 24 18:55:35 2002
@@ -776,4 +776,3 @@
 
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/qpmouse.c b/drivers/char/qpmouse.c
--- a/drivers/char/qpmouse.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/qpmouse.c	Fri May 24 18:55:35 2002
@@ -379,4 +379,3 @@
 
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/random.c b/drivers/char/random.c
--- a/drivers/char/random.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/random.c	Fri May 24 18:55:33 2002
@@ -735,18 +735,14 @@
 	__s32		delta, delta2, delta3;
 	int		entropy = 0;
 
-#if defined (__i386__)
-	if ( test_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability) ) {
+#if defined (__i386__) || defined (__x86_64__)
+	if (cpu_has_tsc) {
 		__u32 high;
 		rdtsc(time, high);
 		num ^= high;
 	} else {
 		time = jiffies;
 	}
-#elif defined (__x86_64__)
-	__u32 high;
-	rdtsc(time, high);
-	num ^= high;
 #else
 	time = jiffies;
 #endif
diff -Nru a/drivers/char/rio/Makefile b/drivers/char/rio/Makefile
--- a/drivers/char/rio/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/char/rio/Makefile	Fri May 24 18:55:34 2002
@@ -5,17 +5,10 @@
 # 
 # This file is GPL. See other files for the full Blurb. I'm lazy today. 
 #
-#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := rio.o
+obj-$(CONFIG_RIO) += rio.o
 
-obj-y   := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
+rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
             rioparam.o riopcicopy.o rioroute.o riotable.o riotty.o
-obj-m   := $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
--- a/drivers/char/rio/rioboot.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/rio/rioboot.c	Fri May 24 18:55:34 2002
@@ -129,7 +129,7 @@
 		p->RIOError.Error = HOST_FILE_TOO_LARGE;
 		/* restore(oldspl); */
 		func_exit ();
-		return ENOMEM;
+		return -ENOMEM;
 	}
 
 	if ( p->RIOBooting ) {
@@ -137,7 +137,7 @@
 		p->RIOError.Error = BOOT_IN_PROGRESS;
 		/* restore(oldspl); */
 		func_exit ();
-		return EBUSY;
+		return -EBUSY;
 	}
 
 	/*
@@ -165,7 +165,7 @@
 		p->RIOError.Error = COPYIN_FAILED;
 		/* restore(oldspl); */
 		func_exit ();
-		return EFAULT;
+		return -EFAULT;
 	}
 
 	/*
@@ -295,7 +295,7 @@
 			rio_dprintk (RIO_DEBUG_BOOT, "Bin too large\n");
 			p->RIOError.Error = HOST_FILE_TOO_LARGE;
 			func_exit ();
-			return EFBIG;
+			return -EFBIG;
 		}
 		/*
 		** Ensure that the host really is stopped.
@@ -322,7 +322,7 @@
 				rio_dprintk (RIO_DEBUG_BOOT, "No system memory available\n");
 				p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
 				func_exit ();
-				return ENOMEM;
+				return -ENOMEM;
 			}
 			bzero(DownCode, rbp->Count);
 
@@ -330,7 +330,7 @@
 				rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
 				p->RIOError.Error = COPYIN_FAILED;
 				func_exit ();
-				return EFAULT;
+				return -EFAULT;
 			}
 
 			HostP->Copy( DownCode, StartP, rbp->Count );
@@ -341,7 +341,7 @@
 			rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
 			p->RIOError.Error = COPYIN_FAILED;
 			func_exit ();
-			return EFAULT;
+			return -EFAULT;
 		}
 
 		rio_dprintk (RIO_DEBUG_BOOT, "Copy completed\n");
diff -Nru a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
--- a/drivers/char/rio/riocmd.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/rio/riocmd.c	Fri May 24 18:55:34 2002
@@ -98,7 +98,7 @@
 
 	if ( !CmdBlkP ) {
 		rio_dprintk (RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n");
-		return ENXIO;
+		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = MapP->ID;
@@ -113,7 +113,7 @@
 
 	if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
 		rio_dprintk (RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n");
-		return EIO;
+		return -EIO;
 	}
 	return 0;
 }
@@ -131,7 +131,7 @@
 
 	if ( !CmdBlkP ) {
 		rio_dprintk (RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n");
-		return ENXIO;
+		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = MapP->ID;
@@ -146,7 +146,7 @@
 
 	if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
 		rio_dprintk (RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n");
-		return EIO;
+		return -EIO;
 	}
 	return 0;
 }
@@ -192,7 +192,7 @@
 			}
 		}
 	}
-	return ENXIO;
+	return -ENXIO;
 }
 
 
@@ -206,7 +206,7 @@
 	if ( copyin( (int)arg, (caddr_t)&IdRta, sizeof(IdRta) ) == COPYFAIL ) {
 		rio_dprintk (RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
 		p->RIOError.Error = COPYIN_FAILED;
-		return EFAULT;
+		return -EFAULT;
 	}
 
 	for ( Host = 0 ; Host < p->RIONumHosts; Host++ ) {
@@ -238,7 +238,7 @@
 
 						if ( !CmdBlkP ) {
 							rio_dprintk (RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n");
-							return ENXIO;
+							return -ENXIO;
 						}
 		
 						CmdBlkP->Packet.dest_unit = MapP->ID;
@@ -252,7 +252,7 @@
 		
 						if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
 							rio_dprintk (RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n");
-							return EIO;
+							return -EIO;
 						}
 						return 0;
 					}
@@ -260,7 +260,7 @@
 			}
 		}
 	} 
-	return ENOENT;
+	return -ENOENT;
 }
 
 
@@ -279,17 +279,17 @@
 	if ( copyin( (int)arg, (caddr_t)&KillUnit, sizeof(KillUnit) ) == COPYFAIL ) {
 		rio_dprintk (RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
 		p->RIOError.Error = COPYIN_FAILED;
-		return EFAULT;
+		return -EFAULT;
 	}
 
 	if ( KillUnit.Link > 3 )
-		return ENXIO;
+		return -ENXIO;
  
 	CmdBlkP = RIOGetCmdBlk();
 
 	if ( !CmdBlkP ) {
 		rio_dprintk (RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n");
-		return ENXIO;
+		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = 0;
@@ -310,7 +310,7 @@
 			if ( RIOQueueCmdBlk( HostP, RTAS_PER_HOST+KillUnit.Link,
 							CmdBlkP) == RIO_FAIL ) {
 				rio_dprintk (RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
-				return EIO;
+				return -EIO;
 			}
 			return 0;
 		}
@@ -320,14 +320,14 @@
 				CmdBlkP->Packet.dest_unit = ID+1;
 				if ( RIOQueueCmdBlk( HostP, ID, CmdBlkP) == RIO_FAIL ) {
 					rio_dprintk (RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
-					return EIO;
+					return -EIO;
 				}
 				return 0;
 			}
 		}
 	}
 	RIOFreeCmdBlk( CmdBlkP );
-	return ENXIO;
+	return -ENXIO;
 }
 
 int
@@ -344,7 +344,7 @@
 
 	if ( !CmdBlkP ) {
 		rio_dprintk (RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n");
-		return ENXIO;
+		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = ID;
@@ -359,7 +359,7 @@
 
 	if ( RIOQueueCmdBlk( HostP, ID - 1, CmdBlkP) == RIO_FAIL ) {
 		rio_dprintk (RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n");
-		return EIO;
+		return -EIO;
 	}
 	return 0;
 }
diff -Nru a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
--- a/drivers/char/rio/rioctrl.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/rio/rioctrl.c	Fri May 24 18:55:35 2002
@@ -230,7 +230,7 @@
 						}
 					}
 				} else if (host >= p->RIONumHosts) {
-					return EINVAL;
+					return -EINVAL;
 				} else {
 					if ( p->RIOHosts[host].Flags == RC_RUNNING ) {
 						WWORD(p->RIOHosts[host].ParmMapP->timer , value);
@@ -320,12 +320,12 @@
 							sizeof(SpecialRupCmd)) == COPYFAIL ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
 					p->RIOError.Error = COPYIN_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				CmdBlkP = RIOGetCmdBlk();
 				if ( !CmdBlkP ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD GetCmdBlk failed\n");
-					return ENXIO;
+					return -ENXIO;
 				}
 				CmdBlkP->Packet = SpecialRupCmd.Packet;
 				if ( SpecialRupCmd.Host >= p->RIONumHosts )
@@ -345,12 +345,12 @@
 					return rio_RIODebugMemory(RIO_DEBUG_CTRL, arg);
 				else
 #endif
-					return EPERM;
+					return -EPERM;
 
 			case RIO_ALL_MODEM:
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_ALL_MODEM\n");
 				p->RIOError.Error = IOCTL_COMMAND_UNKNOWN;
-				return EINVAL;
+				return -EINVAL;
 
 			case RIO_GET_TABLE:
 				/*
@@ -365,7 +365,7 @@
 						TOTAL_MAP_ENTRIES*sizeof(struct Map)) == COPYFAIL) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
 		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 
 				{
@@ -407,13 +407,13 @@
 				if ( !su ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_TABLE !Root\n");
 		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return EPERM;
+		 			return -EPERM;
 				}
 				if ( copyin((int)arg, (caddr_t)&p->RIOConnectTable[0], 
 					TOTAL_MAP_ENTRIES*sizeof(struct Map) ) == COPYFAIL ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
 		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 /*
 ***********************************
@@ -455,13 +455,13 @@
 				{
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_BINDINGS !Root\n");
 		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return EPERM;
+		 			return -EPERM;
 				}
 				if (copyout((caddr_t) p->RIOBindTab, (int)arg, 
 						(sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
 		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				return 0;
 
@@ -476,13 +476,13 @@
 				{
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS !Root\n");
 		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return EPERM;
+		 			return -EPERM;
 				}
 				if (copyin((int)arg, (caddr_t)&p->RIOBindTab[0], 
 						(sizeof(ulong) * MAX_RTA_BINDINGS))==COPYFAIL ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
 		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				return 0;
 
@@ -498,7 +498,7 @@
 					if ( !su ) {
 		 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_BIND_RTA !Root\n");
 		 				p->RIOError.Error = NOT_SUPER_USER;
-		 				return EPERM;
+		 				return -EPERM;
 					}
 					for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
 		 				if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
@@ -535,17 +535,17 @@
 				if ((port < 0) || (port > 511)) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
 		 			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-		 			return EINVAL;
+		 			return -EINVAL;
 				}
 				PortP = p->RIOPortp[port];
 				if (!PortP->Mapped) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not mapped\n", port);
 		 			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
-		 			return EINVAL;
+		 			return -EINVAL;
 				}
 				if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not open\n", port);
-		 			return EINVAL;
+		 			return -EINVAL;
 				}
 
 				rio_spin_lock_irqsave(&PortP->portSem, flags);
@@ -553,7 +553,7 @@
 										RIO_FAIL) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME failed\n");
 					rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-					return EBUSY;
+					return -EBUSY;
 				}
 				else {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d resumed\n", port);
@@ -567,13 +567,13 @@
 				if ( !su ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_ASSIGN_RTA !Root\n");
 					p->RIOError.Error = NOT_SUPER_USER;
-					return EPERM;
+					return -EPERM;
 				}
 				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
 									== COPYFAIL) {
 					rio_dprintk (RIO_DEBUG_CTRL, "Copy from user space failed\n");
 					p->RIOError.Error = COPYIN_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return RIOAssignRta(p, &MapEnt);
 
@@ -582,13 +582,13 @@
 				if ( !su ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_CHANGE_NAME !Root\n");
 					p->RIOError.Error = NOT_SUPER_USER;
-					return EPERM;
+					return -EPERM;
 				}
 				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
 						== COPYFAIL) {
 					rio_dprintk (RIO_DEBUG_CTRL, "Copy from user space failed\n");
 					p->RIOError.Error = COPYIN_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return RIOChangeName(p, &MapEnt);
 
@@ -597,13 +597,13 @@
 				if ( !su ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_DELETE_RTA !Root\n");
 		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return EPERM;
+		 			return -EPERM;
 				}
 				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
 							== COPYFAIL ) {
 		 			rio_dprintk (RIO_DEBUG_CTRL, "Copy from data space failed\n");
 		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				return RIODeleteRta(p, &MapEnt);
 
@@ -627,14 +627,14 @@
 				if (copyout((caddr_t)&p->RIORtaDisCons,(int)arg,
 							sizeof(uint))==COPYFAIL) {
 					p->RIOError.Error = COPYOUT_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return 0;
 
 			case RIO_LAST_ERROR:
 				if (copyout((caddr_t)&p->RIOError, (int)arg, 
 						sizeof(struct Error)) ==COPYFAIL )
-					return EFAULT;
+					return -EFAULT;
 				return 0;
 
 			case RIO_GET_LOG:
@@ -643,7 +643,7 @@
 				RIOGetLog(arg);
 				return 0;
 #else
-				return EINVAL;
+				return -EINVAL;
 #endif
 
 			case RIO_GET_MODTYPE:
@@ -651,21 +651,21 @@
 									sizeof(uint)) == COPYFAIL )
 				{
 		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Get module type for port %d\n", port);
 				if ( port < 0 || port > 511 )
 				{
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Bad port number %d\n", port);
 		 			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-		 			return EINVAL;
+		 			return -EINVAL;
 				}
 				PortP = (p->RIOPortp[port]);
 				if (!PortP->Mapped)
 				{
 		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Port %d not mapped\n", port);
 		 			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
-		 			return EINVAL;
+		 			return -EINVAL;
 				}
 				/*
 				** Return module type of port
@@ -674,7 +674,7 @@
 				if (copyout((caddr_t)&port, (int)arg, 
 							sizeof(uint)) == COPYFAIL) {
 		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				return(0);
 			/*
@@ -690,7 +690,7 @@
 				if (copyout((caddr_t)&p->RIOBootMode, (int)arg, 
 						sizeof(p->RIOBootMode)) == COPYFAIL) {
 		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return EFAULT;
+		 			return -EFAULT;
 				}
 				return(0);
 			
@@ -717,24 +717,24 @@
 						== COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
 					 rio_dprintk (RIO_DEBUG_CTRL, "EFAULT");
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( PortSetup.From > PortSetup.To || 
 								PortSetup.To >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
 					 rio_dprintk (RIO_DEBUG_CTRL, "ENXIO");
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				if ( PortSetup.XpCps > p->RIOConf.MaxXpCps ||
 					 PortSetup.XpCps < p->RIOConf.MinXpCps ) {
 					 p->RIOError.Error = XPRINT_CPS_OUT_OF_RANGE;
 					 rio_dprintk (RIO_DEBUG_CTRL, "EINVAL");
-					 return EINVAL;
+					 return -EINVAL;
 				}
 				if ( !p->RIOPortp ) {
 					 cprintf("No p->RIOPortp array!\n");
 					 rio_dprintk (RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
-					 return EIO;
+					 return -EIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "entering loop (%d %d)!\n", PortSetup.From, PortSetup.To);
 				for (loop=PortSetup.From; loop<=PortSetup.To; loop++) {
@@ -800,11 +800,11 @@
 				if (copyin((int)arg, (caddr_t)&PortSetup, sizeof(PortSetup)) 
 							== COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( PortSetup.From >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 
 				port = PortSetup.To = PortSetup.From;
@@ -827,7 +827,7 @@
 				if ( copyout((caddr_t)&PortSetup,(int)arg,sizeof(PortSetup))
 														==COPYFAIL ) {
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -836,11 +836,11 @@
 				if (copyin( (int)arg, (caddr_t)&PortParams,
 					sizeof(struct PortParams)) == COPYFAIL) {
 					p->RIOError.Error = COPYIN_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				if (PortParams.Port >= RIO_PORTS) {
 					p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					return ENXIO;
+					return -ENXIO;
 				}
 				PortP = (p->RIOPortp[PortParams.Port]);
 				PortParams.Config = PortP->Config;
@@ -850,7 +850,7 @@
 				if (copyout((caddr_t)&PortParams, (int)arg, 
 						sizeof(struct PortParams)) == COPYFAIL ) {
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -859,11 +859,11 @@
 				if (copyin((int)arg, (caddr_t)&PortTty, sizeof(struct PortTty)) 
 						== COPYFAIL) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( PortTty.port >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 
 				rio_dprintk (RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
@@ -877,7 +877,7 @@
 				if (copyout((caddr_t)&PortTty, (int)arg, 
 							sizeof(struct PortTty)) == COPYFAIL) {
 					p->RIOError.Error = COPYOUT_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return retval;
 
@@ -885,12 +885,12 @@
 				if (copyin((int)arg, (caddr_t)&PortTty, 
 						sizeof(struct PortTty)) == COPYFAIL) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Set port %d tty\n", PortTty.port);
 				if (PortTty.port >= (ushort) RIO_PORTS) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				PortP = (p->RIOPortp[PortTty.port]);
 #if 0
@@ -910,11 +910,11 @@
 				if ( copyin((int)arg, (caddr_t)&PortParams, sizeof(PortParams))
 					== COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if (PortParams.Port >= (ushort) RIO_PORTS) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				PortP = (p->RIOPortp[PortParams.Port]);
 		 		rio_spin_lock_irqsave(&PortP->portSem, flags);
@@ -927,11 +927,11 @@
 				if ( copyin((int)arg, (caddr_t)&portStats, 
 						sizeof(struct portStats)) == COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( portStats.port >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				PortP = (p->RIOPortp[portStats.port]);
 				portStats.gather = PortP->statsGather;
@@ -943,7 +943,7 @@
 				if ( copyout((caddr_t)&portStats, (int)arg, 
 							sizeof(struct portStats)) == COPYFAIL ) {
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -952,7 +952,7 @@
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
 				if ( port >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				PortP = (p->RIOPortp[port]);
 				rio_spin_lock_irqsave(&PortP->portSem, flags);
@@ -969,11 +969,11 @@
 				if ( copyin( (int)arg, (caddr_t)&portStats, 
 						sizeof(struct portStats)) == COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( portStats.port >= RIO_PORTS ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				PortP = (p->RIOPortp[portStats.port]);
 				rio_spin_lock_irqsave(&PortP->portSem, flags);
@@ -992,7 +992,7 @@
 						sizeof(struct DbInf)*(num+1))==COPYFAIL) {
 						rio_dprintk (RIO_DEBUG_CTRL, "ReadLevels Copy failed\n");
 						p->RIOError.Error = COPYOUT_FAILED;
-						return EFAULT;
+						return -EFAULT;
 					 }
 					 rio_dprintk (RIO_DEBUG_CTRL, "%d levels to copied\n",num);
 					 return retval;
@@ -1004,7 +1004,7 @@
 				if (copyout((caddr_t)&p->RIOConf, (int)arg, 
 							sizeof(struct Conf)) ==COPYFAIL ) {
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -1012,12 +1012,12 @@
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_CONFIG\n");
 				if ( !su ) {
 					 p->RIOError.Error = NOT_SUPER_USER;
-					 return EPERM;
+					 return -EPERM;
 				}
 				if ( copyin((int)arg, (caddr_t)&p->RIOConf, sizeof(struct Conf) )
 						==COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				/*
 				** move a few value around
@@ -1030,13 +1030,13 @@
 
 			case RIO_START_POLLER:
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_START_POLLER\n");
-				return EINVAL;
+				return -EINVAL;
 
 			case RIO_STOP_POLLER:
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_STOP_POLLER\n");
 				if ( !su ) {
 					 p->RIOError.Error = NOT_SUPER_USER;
-					 return EPERM;
+					 return -EPERM;
 				}
 				p->RIOPolling = NOT_POLLING;
 				return retval;
@@ -1047,13 +1047,13 @@
 				if ( copyin( (int)arg, (caddr_t)&DebugCtrl, sizeof(DebugCtrl) )
 							==COPYFAIL ) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( DebugCtrl.SysPort == NO_PORT ) {
 					if ( cmd == RIO_SETDEBUG ) {
 						if ( !su ) {
 							p->RIOError.Error = NOT_SUPER_USER;
-							return EPERM;
+							return -EPERM;
 						}
 						p->rio_debug = DebugCtrl.Debug;
 						p->RIODebugWait = DebugCtrl.Wait;
@@ -1070,7 +1070,7 @@
 							rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n",
 									DebugCtrl.SysPort);
 						 	p->RIOError.Error = COPYOUT_FAILED;
-						 	return EFAULT;
+						 	return -EFAULT;
 						}
 					}
 				}
@@ -1079,12 +1079,12 @@
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n",
 									DebugCtrl.SysPort);
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				else if ( cmd == RIO_SETDEBUG ) {
 					if ( !su ) {
 						p->RIOError.Error = NOT_SUPER_USER;
-						return EPERM;
+						return -EPERM;
 					}
 					rio_spin_lock_irqsave(&PortP->portSem, flags);
 					p->RIOPortp[DebugCtrl.SysPort]->Debug = DebugCtrl.Debug;
@@ -1100,7 +1100,7 @@
 								sizeof(DebugCtrl))==COPYFAIL ) {
 						rio_dprintk (RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
 						p->RIOError.Error = COPYOUT_FAILED;
-						return EFAULT;
+						return -EFAULT;
 					}
 				}
 				return retval;
@@ -1118,7 +1118,7 @@
 				{
 					 rio_dprintk (RIO_DEBUG_CTRL,  "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -1138,7 +1138,7 @@
 						(int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
 					 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 			**
@@ -1155,7 +1155,7 @@
 							sizeof(p->RIONumHosts) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -1167,7 +1167,7 @@
 				if ( !su ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
 					 p->RIOError.Error = NOT_SUPER_USER;
-					 return EPERM;
+					 return -EPERM;
 				}
 				p->RIOHalted = 1;
 				p->RIOSystemUp = 0;
@@ -1217,13 +1217,13 @@
 				if ( !su ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Not super user\n");
 					 p->RIOError.Error = NOT_SUPER_USER;
-					 return EPERM;
+					 return -EPERM;
 				}
 				if ( copyin((int)arg, (caddr_t)&DownLoad, 
 							sizeof(DownLoad) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Copied in download code for product code 0x%x\n",
 				    DownLoad.ProductCode);
@@ -1235,7 +1235,7 @@
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Bad product code %d passed\n",
 							DownLoad.ProductCode);
 					 p->RIOError.Error = NO_SUCH_PRODUCT;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				/*
 				** do something!
@@ -1257,7 +1257,7 @@
 						rio_dprintk (RIO_DEBUG_CTRL, 
 							"RIO_HOST_REQ: Copy in from user space failed\n");
 						p->RIOError.Error = COPYIN_FAILED;
-						return EFAULT;
+						return -EFAULT;
 					}
 					/*
 					** Fetch the parmmap
@@ -1267,7 +1267,7 @@
 								(int)arg, sizeof(PARM_MAP) )==COPYFAIL ) {
 						p->RIOError.Error = COPYOUT_FAILED;
 						rio_dprintk (RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
-						return EFAULT;
+						return -EFAULT;
 					}
 				}
 				return retval;
@@ -1278,13 +1278,13 @@
 							sizeof(HostReq) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( HostReq.HostNum >= p->RIONumHosts ) {
 					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Illegal host number %d\n",
 							HostReq.HostNum);
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
 
@@ -1292,7 +1292,7 @@
 					(int)HostReq.HostP,sizeof(struct Host) ) == COPYFAIL) {
 					p->RIOError.Error = COPYOUT_FAILED;
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
-					return EFAULT;
+					return -EFAULT;
 				}
 				return retval;
 
@@ -1302,13 +1302,13 @@
 								sizeof(HostDpRam) )==COPYFAIL ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
 					p->RIOError.Error = COPYIN_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				if ( HostDpRam.HostNum >= p->RIONumHosts ) {
 					p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Illegal host number %d\n",
 										HostDpRam.HostNum);
-					return ENXIO;
+					return -ENXIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostDpRam.HostNum);
 
@@ -1322,7 +1322,7 @@
 							sizeof(struct DpRam) ) == COPYFAIL ) {
 						p->RIOError.Error = COPYOUT_FAILED;
 						rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
-						return EFAULT;
+						return -EFAULT;
 					}
 				}
 				else if (copyout((caddr_t)p->RIOHosts[HostDpRam.HostNum].Caddr,
@@ -1330,7 +1330,7 @@
 						sizeof(struct DpRam) ) == COPYFAIL ) {
 					 p->RIOError.Error = COPYOUT_FAILED;
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -1339,7 +1339,7 @@
 				if ( (int)arg < 0 || (int)arg > 511 ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n",(int)arg);
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 				rio_spin_lock_irqsave(&PortP->portSem, flags);
 				p->RIOPortp[(int)arg]->State |= RIO_BUSY;
@@ -1356,14 +1356,14 @@
 					sizeof(PortReq) )==COPYFAIL ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
 					p->RIOError.Error = COPYIN_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 
 				if (PortReq.SysPort >= RIO_PORTS) { /* SysPort is unsigned */
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Illegal port number %d\n",
 											PortReq.SysPort);
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
 				if (copyout((caddr_t)p->RIOPortp[PortReq.SysPort], 
@@ -1371,7 +1371,7 @@
 								sizeof(struct Port) ) == COPYFAIL) {
 					 p->RIOError.Error = COPYOUT_FAILED;
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return retval;
 
@@ -1385,19 +1385,19 @@
 						sizeof(RupReq) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if (RupReq.HostNum >= p->RIONumHosts) { /* host is unsigned */
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal host number %d\n",
 								RupReq.HostNum);
 					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 				if ( RupReq.RupNum >= MAX_RUP+LINKS_PER_UNIT ) { /* eek! */
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal rup number %d\n",
 							RupReq.RupNum);
 					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 				HostP = &p->RIOHosts[RupReq.HostNum];
 
@@ -1405,7 +1405,7 @@
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Host %d not running\n",
 							RupReq.HostNum);
 					 p->RIOError.Error = HOST_NOT_RUNNING;
-					 return EIO;
+					 return -EIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Request for rup %d from host %d\n",
 						RupReq.RupNum,RupReq.HostNum);
@@ -1414,7 +1414,7 @@
 					(int)RupReq.RupP,sizeof(struct RUP) ) == COPYFAIL) {
 					p->RIOError.Error = COPYOUT_FAILED;
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
-					return EFAULT;
+					return -EFAULT;
 				}
 				return retval;
 
@@ -1428,19 +1428,19 @@
 					sizeof(LpbReq) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if (LpbReq.Host >= p->RIONumHosts) { /* host is unsigned */
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal host number %d\n",
 							LpbReq.Host);
 					p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					return ENXIO;
+					return -ENXIO;
 				}
 				if ( LpbReq.Link >= LINKS_PER_UNIT ) { /* eek! */
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal link number %d\n",
 							LpbReq.Link);
 					 p->RIOError.Error = LINK_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 				HostP = &p->RIOHosts[LpbReq.Host];
 
@@ -1448,7 +1448,7 @@
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Host %d not running\n",
 						LpbReq.Host );
 					 p->RIOError.Error = HOST_NOT_RUNNING;
-					 return EIO;
+					 return -EIO;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n",
 					LpbReq.Link, LpbReq.Host);
@@ -1457,7 +1457,7 @@
 					(int)LpbReq.LpbP,sizeof(struct LPB) ) == COPYFAIL) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
 					p->RIOError.Error = COPYOUT_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return retval;
 
@@ -1483,7 +1483,7 @@
 			case RIO_SIGNALS_ON:
 				if ( p->RIOSignalProcess ) {
 					 p->RIOError.Error = SIGNALS_ALREADY_SET;
-					 return EBUSY;
+					 return -EBUSY;
 				}
 				p->RIOSignalProcess = getpid();
 				p->RIOPrintDisabled = DONT_PRINT;
@@ -1492,7 +1492,7 @@
 			case RIO_SIGNALS_OFF:
 				if ( p->RIOSignalProcess != getpid() ) {
 					 p->RIOError.Error = NOT_RECEIVING_PROCESS;
-					 return EPERM;
+					 return -EPERM;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "Clear signal process to zero\n");
 				p->RIOSignalProcess = 0;
@@ -1531,7 +1531,7 @@
 				if ( port < 0 || port > 511 ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 				rio_spin_lock_irqsave(&PortP->portSem, flags);
 				switch( cmd )
@@ -1554,7 +1554,7 @@
 
 			case RIO_STREAM_INFO:
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_STREAM_INFO\n");
-				return EINVAL;
+				return -EINVAL;
 
 			case RIO_SEND_PACKET:
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
@@ -1562,11 +1562,11 @@
 									sizeof(SendPack) )==COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				if ( SendPack.PortNum >= 128 ) {
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return ENXIO;
+					 return -ENXIO;
 				}
 
 				PortP = p->RIOPortp[SendPack.PortNum];
@@ -1575,7 +1575,7 @@
 				if ( !can_add_transmit(&PacketP,PortP) ) {
 					 p->RIOError.Error = UNIT_IS_IN_USE;
 					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return ENOSPC;
+					 return -ENOSPC;
 				}
 
 				for ( loop=0; loop<(ushort)(SendPack.Len & 127); loop++ )
@@ -1607,7 +1607,7 @@
 					sizeof(p->RIONoMessage) )==COPYFAIL ) {
 					rio_dprintk (RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
 					p->RIOError.Error = COPYOUT_FAILED;
-					return EFAULT;
+					return -EFAULT;
 				}
 				return 0;
 
@@ -1615,19 +1615,19 @@
 				if (copyin((int)arg, (caddr_t)&SubCmd, 
 						sizeof(struct SubCmdStruct)) == COPYFAIL) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP host %d rup %d addr %x\n", 
 						SubCmd.Host, SubCmd.Rup, SubCmd.Addr);
 
 				if (SubCmd.Rup >= MAX_RUP+LINKS_PER_UNIT ) {
 					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 
 				if (SubCmd.Host >= p->RIONumHosts ) {
 					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 
 				port = p->RIOHosts[SubCmd.Host].
@@ -1640,7 +1640,7 @@
 				if ( RIOPreemptiveCmd(p,  PortP, MEMDUMP ) == RIO_FAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP failed\n");
 					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return EBUSY;
+					 return -EBUSY;
 				}
 				else
 					 PortP->State |= RIO_BUSY;
@@ -1650,20 +1650,20 @@
 							MEMDUMP_SIZE) == COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return 0;
 
 			case RIO_TICK:
 				if ((int)arg < 0 || (int)arg >= p->RIONumHosts)
-					 return EINVAL;
+					 return -EINVAL;
 				rio_dprintk (RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int)arg);
 				WBYTE(p->RIOHosts[(int)arg].SetInt , 0xff);
 				return 0;
 
 			case RIO_TOCK:
 				if ((int)arg < 0 || (int)arg >= p->RIONumHosts)
-					 return EINVAL;
+					 return -EINVAL;
 				rio_dprintk (RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int)arg);
 				WBYTE((p->RIOHosts[(int)arg].ResetInt) , 0xff);
 				return 0;
@@ -1674,7 +1674,7 @@
 				if (copyout((caddr_t)&p->RIOReadCheck,(int)arg,
 							sizeof(uint))== COPYFAIL) {
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return 0;
 
@@ -1682,7 +1682,7 @@
 				if (copyin((int)arg, (caddr_t)&SubCmd, 
 							sizeof(struct SubCmdStruct)) == COPYFAIL) {
 					 p->RIOError.Error = COPYIN_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER host %d rup %d port %d reg %x\n", 
 						SubCmd.Host, SubCmd.Rup, SubCmd.Port, SubCmd.Addr);
@@ -1691,17 +1691,17 @@
 					 rio_dprintk (RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", 
 								SubCmd.Port);
 					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 
 				if (SubCmd.Rup >= MAX_RUP+LINKS_PER_UNIT ) {
 					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 
 				if (SubCmd.Host >= p->RIONumHosts ) {
 					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return EINVAL;
+					 return -EINVAL;
 				}
 
 				port = p->RIOHosts[SubCmd.Host].
@@ -1713,7 +1713,7 @@
 				if (RIOPreemptiveCmd(p, PortP, READ_REGISTER) == RIO_FAIL) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER failed\n");
 					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return EBUSY;
+					 return -EBUSY;
 				}
 				else
 					 PortP->State |= RIO_BUSY;
@@ -1723,7 +1723,7 @@
 							sizeof(uint)) == COPYFAIL ) {
 					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
 					 p->RIOError.Error = COPYOUT_FAILED;
-					 return EFAULT;
+					 return -EFAULT;
 				}
 				return 0;
 				/*
@@ -1750,7 +1750,7 @@
 							return (int)arg;
 					}
 					rio_dprintk (RIO_DEBUG_CTRL, "MAKE Device is called\n");
-					return EINVAL;
+					return -EINVAL;
 				}
 				/*
 				** rio_minor: given a dev_t from a stat() call, return
@@ -1780,7 +1780,7 @@
 	p->RIOError.Error = IOCTL_COMMAND_UNKNOWN;
 
 	func_exit ();
-	return EINVAL;
+	return -EINVAL;
 }
 
 /*
diff -Nru a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
--- a/drivers/char/rio/riotable.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/rio/riotable.c	Fri May 24 18:55:36 2002
@@ -125,7 +125,7 @@
 	rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n"); 
 	if ( p->RIOSystemUp ) {		/* (1) */
 		p->RIOError.Error = HOST_HAS_ALREADY_BEEN_BOOTED;
-		return EBUSY;
+		return -EBUSY;
 	}
 
 	p->RIOError.Error = NOTHING_WRONG_AT_ALL;
@@ -147,7 +147,7 @@
 				if ( *cptr<' ' || *cptr>'~' ) {
 					p->RIOError.Error = BAD_CHARACTER_IN_NAME;
 					p->RIOError.Entry = Entry;
-					return ENXIO;
+					return -ENXIO;
 				}
 				cptr++;
 			}
@@ -169,7 +169,7 @@
 				rio_dprintk (RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n",MapP->Name);
 				p->RIOError.Error = TABLE_ENTRY_ISNT_PROPERLY_NULL;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			rio_dprintk (RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n");
 			continue;
@@ -207,14 +207,14 @@
 							MapP->Name);
 				p->RIOError.Error		 = ZERO_RTA_ID;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			if ( MapP->ID > MAX_RUP ) {
 				rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an illegal ID %d\n",
 							MapP->Name, MapP->ID);
 				p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {
 				if ( MapP->HostUniqueNum == 
@@ -225,7 +225,7 @@
 					p->RIOError.Error = DUPLICATED_RTA_ID;
 					p->RIOError.Entry = Entry;
 					p->RIOError.Other = SubEnt;
-					return ENXIO;
+					return -ENXIO;
 				}
 				/*
 				** If the RtaUniqueNum is the same, it may be looking at both
@@ -240,7 +240,7 @@
 					p->RIOError.Error = DUPLICATE_UNIQUE_NUMBER;
 					p->RIOError.Entry = Entry;
 					p->RIOError.Other = SubEnt;
-					return ENXIO;
+					return -ENXIO;
 				}
 			}
 			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n"); 
@@ -250,7 +250,7 @@
 					(int)MapP->SysPort,MapP->Name, PORTS_PER_RTA);
 				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n"); 
 			/* (7b) */
@@ -259,7 +259,7 @@
 							(int)MapP->SysPort, MapP->Name);
 				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {
 				if ( p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT )
@@ -275,7 +275,7 @@
 						p->RIOError.Error = TTY_NUMBER_IN_USE;
 						p->RIOError.Entry = Entry;
 						p->RIOError.Other = SubEnt;
-						return ENXIO;
+						return -ENXIO;
 					}
 					rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n"); 
 					if (RIOStrCmp(MapP->Name,
@@ -284,7 +284,7 @@
 						p->RIOError.Error = NAME_USED_TWICE;
 						p->RIOError.Entry = Entry;
 						p->RIOError.Other = SubEnt;
-						return ENXIO;
+						return -ENXIO;
 					}
 				}
 			}
@@ -296,14 +296,14 @@
 					MapP->Name);
 				p->RIOError.Error = HOST_ID_NOT_ZERO;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 			if ( MapP->SysPort != NO_PORT ) {
 				rio_dprintk (RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n",
 					MapP->Name);
 				p->RIOError.Error = HOST_SYSPORT_BAD;
 				p->RIOError.Entry = Entry;
-				return ENXIO;
+				return -ENXIO;
 			}
 		}
 	}
@@ -530,7 +530,7 @@
 						rio_dprintk (RIO_DEBUG_TABLE, "Entry is in use and cannot be deleted!\n");
 						p->RIOError.Error = UNIT_IS_IN_USE;
 						rio_spin_unlock_irqrestore( &HostP->HostLock, lock_flags);
-						return EBUSY;
+						return -EBUSY;
 					}
 				}
 				/*
@@ -629,7 +629,7 @@
 
 	rio_dprintk (RIO_DEBUG_TABLE, "Couldn't find entry to be deleted\n");
 	p->RIOError.Error = COULDNT_FIND_ENTRY;
-	return ENXIO;
+	return -ENXIO;
 }
 
 int RIOAssignRta( struct rio_info *p, struct Map *MapP )
@@ -649,25 +649,25 @@
     {
 	rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
 	p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
-	return EINVAL;
+	return -EINVAL;
     }
     if (MapP->RtaUniqueNum == 0)
     {
 	rio_dprintk (RIO_DEBUG_TABLE, "Rta Unique number zero!\n");
 	p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO;
-	return EINVAL;
+	return -EINVAL;
     }
     if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA) )
     {
 	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n",(int)MapP->SysPort,PORTS_PER_RTA);
 	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
-	return EINVAL;
+	return -EINVAL;
     }
     if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS) )
     {
 	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not valid!\n",(int)MapP->SysPort);
 	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
-	return EINVAL;
+	return -EINVAL;
     }
 
     /*
@@ -681,7 +681,7 @@
     {
 	rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
 	p->RIOError.Error = BAD_CHARACTER_IN_NAME;
-	return EINVAL;
+	return -EINVAL;
     }
     sptr++;
     }
@@ -693,7 +693,7 @@
 	    if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING )
 	    {
 		p->RIOError.Error = HOST_NOT_RUNNING;
-		return ENXIO;
+		return -ENXIO;
 	    }
 
 	    /*
@@ -720,7 +720,7 @@
 		if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0)
 		{
 		    p->RIOError.Error = COULDNT_FIND_ENTRY;
-		    return EBUSY;
+		    return -EBUSY;
 		}
 		MapP->ID = (ushort)nNewID + 1;
 		rio_dprintk (RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
@@ -744,7 +744,7 @@
 		    if (unit == MAX_RUP)
 		    {
 			p->RIOError.Error = COULDNT_FIND_ENTRY;
-			return EBUSY;
+			return -EBUSY;
 		    }
 		    HostMapP->Flags |= RTA16_SECOND_SLOT;
 		    HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;
@@ -761,7 +761,7 @@
 	    {
 		rio_dprintk (RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID);
 		p->RIOError.Error = ID_ALREADY_IN_USE;
-		return EBUSY;
+		return -EBUSY;
 	    }
 
 	    /*
@@ -802,7 +802,7 @@
     }
     p->RIOError.Error = UNKNOWN_HOST_NUMBER;
     rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
-    return ENXIO;
+    return -ENXIO;
 }
 
 
@@ -1017,7 +1017,7 @@
 	if ( MapP->ID > MAX_RUP ) {
 		rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
 		p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
-		return EINVAL;
+		return -EINVAL;
 	}
 
 	MapP->Name[MAX_NAME_LEN-1] = '\0';
@@ -1027,7 +1027,7 @@
 		if ( *sptr<' ' || *sptr>'~' ) {
 			rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
 			p->RIOError.Error = BAD_CHARACTER_IN_NAME;
-			return EINVAL;
+			return -EINVAL;
 		}
 		sptr++;
 	}
@@ -1036,7 +1036,7 @@
 		if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum ) {
 			if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING ) {
 				p->RIOError.Error = HOST_NOT_RUNNING;
-				return ENXIO;
+				return -ENXIO;
 			}
 			if ( MapP->ID==0 ) {
 				CCOPY( MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN );
@@ -1047,7 +1047,7 @@
 
 			if ( HostMapP->RtaUniqueNum != MapP->RtaUniqueNum ) {
 				p->RIOError.Error = RTA_NUMBER_WRONG;
-				return ENXIO;
+				return -ENXIO;
 			}
 			CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN );
 			return 0;
@@ -1055,5 +1055,5 @@
 	}
 	p->RIOError.Error = UNKNOWN_HOST_NUMBER;
 	rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
-	return ENXIO;
+	return -ENXIO;
 }
diff -Nru a/drivers/char/sbc60xxwdt.c b/drivers/char/sbc60xxwdt.c
--- a/drivers/char/sbc60xxwdt.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/sbc60xxwdt.c	Fri May 24 18:55:33 2002
@@ -61,7 +61,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/slab.h>
@@ -352,4 +352,3 @@
 module_exit(sbc60xxwdt_unload);
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/serial.c b/drivers/char/serial.c
--- a/drivers/char/serial.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/serial.c	Fri May 24 18:55:34 2002
@@ -5681,7 +5681,7 @@
 	if (state->info && state->info->tty)
 		tty_hangup(state->info->tty);
 	state->type = PORT_UNKNOWN;
-	printk(KERN_INFO "tty%02d unloaded\n", state->line);
+	printk(KERN_INFO "ttyS%02d unloaded\n", state->line);
 	/* These will be hidden, because they are devices that will no longer
 	 * be available to the system. (ie, PCMCIA modems, once ejected)
 	 */
diff -Nru a/drivers/char/serial_21285.c b/drivers/char/serial_21285.c
--- a/drivers/char/serial_21285.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/serial_21285.c	Fri May 24 18:55:34 2002
@@ -495,4 +495,3 @@
 #endif	/* CONFIG_SERIAL_21285_CONSOLE */
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/serial_amba.c b/drivers/char/serial_amba.c
--- a/drivers/char/serial_amba.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/serial_amba.c	Fri May 24 18:55:33 2002
@@ -2012,4 +2012,3 @@
 #endif /* CONFIG_SERIAL_AMBA_CONSOLE */
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/shwdt.c b/drivers/char/shwdt.c
--- a/drivers/char/shwdt.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/shwdt.c	Fri May 24 18:55:34 2002
@@ -406,8 +406,6 @@
 	misc_deregister(&sh_wdt_miscdev);
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Paul Mundt <lethal@chaoticdreams.org>");
 MODULE_DESCRIPTION("SH 3/4 watchdog driver");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/char/synclink.c b/drivers/char/synclink.c
--- a/drivers/char/synclink.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/synclink.c	Fri May 24 18:55:35 2002
@@ -4700,8 +4700,6 @@
 {
 	int rc;
 
-	EXPORT_NO_SYMBOLS;
-	
  	printk("%s %s\n", driver_name, driver_version);
 	
 	mgsl_enum_isa_devices();
diff -Nru a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
--- a/drivers/char/synclinkmp.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/synclinkmp.c	Fri May 24 18:55:34 2002
@@ -3860,8 +3860,6 @@
 {
 	SLMP_INFO *info;
 
-	EXPORT_NO_SYMBOLS;
-
 	if (break_on_load) {
 	 	synclinkmp_get_text_ptr();
   		BREAKPOINT();
diff -Nru a/drivers/char/sysrq.c b/drivers/char/sysrq.c
--- a/drivers/char/sysrq.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/sysrq.c	Fri May 24 18:55:34 2002
@@ -27,6 +27,8 @@
 #include <linux/quotaops.h>
 #include <linux/smp_lock.h>
 #include <linux/module.h>
+#include <linux/suspend.h>
+#include <linux/buffer_head.h>		/* for fsync_bdev()/wakeup_bdflush() */
 
 #include <linux/spinlock.h>
 
@@ -317,6 +319,22 @@
 	action_msg:	"Kill All Tasks",
 };
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+static void sysrq_handle_swsusp(int key, struct pt_regs *pt_regs,
+		struct kbd_struct *kbd, struct tty_struct *tty) {
+        if(!software_suspend_enabled) {
+		printk("Software Suspend is not possible now\n");
+		return;
+	}
+	software_suspend();
+}
+static struct sysrq_key_op sysrq_swsusp_op = {
+	handler:	sysrq_handle_swsusp,
+	help_msg:	"suspenD",
+	action_msg:	"Software suspend\n",
+};
+#endif
+
 /* END SIGNAL SYSRQ HANDLERS BLOCK */
 
 
@@ -339,7 +357,11 @@
 		 and will never arive */
 /* b */	&sysrq_reboot_op,
 /* c */	NULL,
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/* d */	&sysrq_swsusp_op,
+#else
 /* d */	NULL,
+#endif
 /* e */	&sysrq_term_op,
 /* f */	NULL,
 /* g */	NULL,
diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
--- a/drivers/char/tpqic02.c	Fri May 24 18:55:35 2002
+++ b/drivers/char/tpqic02.c	Fri May 24 18:55:35 2002
@@ -2977,4 +2977,3 @@
 #endif
 
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/w83877f_wdt.c b/drivers/char/w83877f_wdt.c
--- a/drivers/char/w83877f_wdt.c	Fri May 24 18:55:33 2002
+++ b/drivers/char/w83877f_wdt.c	Fri May 24 18:55:33 2002
@@ -46,7 +46,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/slab.h>
diff -Nru a/drivers/char/wdt.c b/drivers/char/wdt.c
--- a/drivers/char/wdt.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/wdt.c	Fri May 24 18:55:36 2002
@@ -563,4 +563,3 @@
 MODULE_AUTHOR("Alan Cox");
 MODULE_DESCRIPTION("Driver for ISA ICS watchdog cards (WDT500/501)");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/char/wdt285.c b/drivers/char/wdt285.c
--- a/drivers/char/wdt285.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/wdt285.c	Fri May 24 18:55:34 2002
@@ -182,8 +182,6 @@
 	misc_deregister(&watchdog_miscdev);
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Phil Blundell <pb@nexus.co.uk>");
 MODULE_DESCRIPTION("21285 watchdog driver");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/char/wdt977.c b/drivers/char/wdt977.c
--- a/drivers/char/wdt977.c	Fri May 24 18:55:34 2002
+++ b/drivers/char/wdt977.c	Fri May 24 18:55:34 2002
@@ -340,8 +340,6 @@
 	misc_deregister(&wdt977_miscdev);
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(nwwatchdog_init);
 module_exit(nwwatchdog_exit);
 
diff -Nru a/drivers/char/wdt_pci.c b/drivers/char/wdt_pci.c
--- a/drivers/char/wdt_pci.c	Fri May 24 18:55:36 2002
+++ b/drivers/char/wdt_pci.c	Fri May 24 18:55:36 2002
@@ -651,5 +651,3 @@
 MODULE_AUTHOR("JP Nollmann, Alan Cox");
 MODULE_DESCRIPTION("Driver for the ICS PCI watchdog cards");
 MODULE_LICENSE("GPL");
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/dio/Makefile b/drivers/dio/Makefile
--- a/drivers/dio/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/dio/Makefile	Fri May 24 18:55:34 2002
@@ -1,19 +1,7 @@
 #
 # Makefile for the linux kernel.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-#
-# NB: cribbed from the drivers/sbus/Makefile -- PMM
 
-SUB_DIRS     :=
-MOD_SUB_DIRS := $(SUB_DIRS)
-ALL_SUB_DIRS := $(SUB_DIRS)
-
-L_OBJS   := dio.o
-L_TARGET := dio.a
+obj-y := dio.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/fc4/Makefile b/drivers/fc4/Makefile
--- a/drivers/fc4/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/fc4/Makefile	Fri May 24 18:55:35 2002
@@ -2,8 +2,6 @@
 # Makefile for the Linux Fibre Channel device drivers.
 #
 
-L_TARGET := fc4.a
-
 export-objs := fc_syms.o
 
 fc4-objs := fc.o fc_syms.o
diff -Nru a/drivers/fc4/fc.c b/drivers/fc4/fc.c
--- a/drivers/fc4/fc.c	Fri May 24 18:55:36 2002
+++ b/drivers/fc4/fc.c	Fri May 24 18:55:36 2002
@@ -23,7 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
diff -Nru a/drivers/fc4/soc.c b/drivers/fc4/soc.c
--- a/drivers/fc4/soc.c	Fri May 24 18:55:33 2002
+++ b/drivers/fc4/soc.c	Fri May 24 18:55:33 2002
@@ -760,8 +760,6 @@
 	}
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(soc_probe);
 module_exit(soc_cleanup);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/fc4/socal.c b/drivers/fc4/socal.c
--- a/drivers/fc4/socal.c	Fri May 24 18:55:35 2002
+++ b/drivers/fc4/socal.c	Fri May 24 18:55:35 2002
@@ -900,8 +900,6 @@
 	}
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(socal_probe);
 module_exit(socal_cleanup);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/i2c/i2c-adap-ite.c b/drivers/i2c/i2c-adap-ite.c
--- a/drivers/i2c/i2c-adap-ite.c	Fri May 24 18:55:34 2002
+++ b/drivers/i2c/i2c-adap-ite.c	Fri May 24 18:55:34 2002
@@ -292,8 +292,6 @@
         iic_ite_release();
 }
 
-EXPORT_NO_SYMBOLS;
-
 /* If modules is NOT defined when this file is compiled, then the MODULE_*
  * macros will resolve to nothing
  */
diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
--- a/drivers/i2c/i2c-dev.c	Fri May 24 18:55:36 2002
+++ b/drivers/i2c/i2c-dev.c	Fri May 24 18:55:36 2002
@@ -537,8 +537,6 @@
 	return 0;
 }
 
-EXPORT_NO_SYMBOLS;
-
 #ifdef MODULE
 
 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>");
diff -Nru a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c
--- a/drivers/i2c/i2c-elektor.c	Fri May 24 18:55:33 2002
+++ b/drivers/i2c/i2c-elektor.c	Fri May 24 18:55:33 2002
@@ -295,8 +295,6 @@
 }
 
 
-EXPORT_NO_SYMBOLS;
-
 #ifdef MODULE
 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
 MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
diff -Nru a/drivers/i2c/i2c-elv.c b/drivers/i2c/i2c-elv.c
--- a/drivers/i2c/i2c-elv.c	Fri May 24 18:55:36 2002
+++ b/drivers/i2c/i2c-elv.c	Fri May 24 18:55:36 2002
@@ -195,8 +195,6 @@
 }
 
 
-EXPORT_NO_SYMBOLS;
-
 #ifdef MODULE
 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
 MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter");
diff -Nru a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c
--- a/drivers/i2c/i2c-philips-par.c	Fri May 24 18:55:33 2002
+++ b/drivers/i2c/i2c-philips-par.c	Fri May 24 18:55:33 2002
@@ -287,8 +287,6 @@
 #endif
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
 MODULE_DESCRIPTION("I2C-Bus adapter routines for Philips parallel port adapter");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c
--- a/drivers/i2c/i2c-proc.c	Fri May 24 18:55:36 2002
+++ b/drivers/i2c/i2c-proc.c	Fri May 24 18:55:36 2002
@@ -66,11 +66,6 @@
 static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX];
 
 static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX];
-static unsigned short i2c_inodes[SENSORS_ENTRY_MAX];
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
-static void i2c_fill_inode(struct inode *inode, int fill);
-static void i2c_dir_fill_inode(struct inode *inode, int fill);
-#endif			/* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1) */
 
 static ctl_table sysctl_table[] = {
 	{CTL_DEV, "dev", NULL, 0, 0555},
@@ -198,14 +193,7 @@
 		return id;
 	}
 #endif				/* DEBUG */
-	i2c_inodes[id - 256] =
-	    new_header->ctl_table->child->child->de->low_ino;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27))
 	new_header->ctl_table->child->child->de->owner = controlling_mod;
-#else
-	new_header->ctl_table->child->child->de->fill_inode =
-	    &i2c_dir_fill_inode;
-#endif	/* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) */
 
 	return id;
 }
@@ -227,49 +215,6 @@
 	}
 }
 
-/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o 
-   impossible if some process still uses it or some file in it */
-void i2c_fill_inode(struct inode *inode, int fill)
-{
-	if (fill)
-		MOD_INC_USE_COUNT;
-	else
-		MOD_DEC_USE_COUNT;
-}
-
-/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading
-   the corresponding module impossible if some process still uses it or
-   some file in it */
-void i2c_dir_fill_inode(struct inode *inode, int fill)
-{
-	int i;
-	struct i2c_client *client;
-
-#ifdef DEBUG
-	if (!inode) {
-		printk("i2c-proc.o: Warning: inode NULL in fill_inode()\n");
-		return;
-	}
-#endif				/* def DEBUG */
-
-	for (i = 0; i < SENSORS_ENTRY_MAX; i++)
-		if (i2c_clients[i]
-		    && (i2c_inodes[i] == inode->i_ino)) break;
-#ifdef DEBUG
-	if (i == SENSORS_ENTRY_MAX) {
-		printk
-		    ("i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n",
-		     inode->i_ino);
-		return;
-	}
-#endif				/* def DEBUG */
-	client = i2c_clients[i];
-	if (fill)
-		client->driver->inc_use(client);
-	else
-		client->driver->dec_use(client);
-}
-
 int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp,
 		       void *buffer, size_t * lenp)
 {
@@ -867,12 +812,7 @@
 	if (!
 	    (i2c_proc_header =
 	     register_sysctl_table(i2c_proc, 0))) return -ENOMEM;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1))
 	i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE;
-#else
-	i2c_proc_header->ctl_table->child->de->fill_inode =
-	    &i2c_fill_inode;
-#endif			/* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,1)) */
 	i2c_initialized++;
 	return 0;
 }
diff -Nru a/drivers/i2c/i2c-velleman.c b/drivers/i2c/i2c-velleman.c
--- a/drivers/i2c/i2c-velleman.c	Fri May 24 18:55:34 2002
+++ b/drivers/i2c/i2c-velleman.c	Fri May 24 18:55:34 2002
@@ -184,8 +184,6 @@
 	return 0;
 }
 
-EXPORT_NO_SYMBOLS;
-
 #ifdef MODULE
 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
 MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter");
diff -Nru a/drivers/ide/Config.help b/drivers/ide/Config.help
--- a/drivers/ide/Config.help	Fri May 24 18:55:36 2002
+++ b/drivers/ide/Config.help	Fri May 24 18:55:36 2002
@@ -304,6 +304,7 @@
   The ATP850U/UF is an UltraDMA 33 chipset base.
   The ATP860 is an UltraDMA 66 chipset base.
   The ATP860M(acintosh) version is an UltraDMA 66 chipset base.
+  The ATP865 is an ATA100/133 chipset.
 
   Please read the comments at the top of <file:drivers/ide/aec62xx.c>.
   If you say Y here, then say Y to "Use DMA by default when available"
@@ -313,6 +314,12 @@
   Please read the comments at the top of <file:drivers/ide/aec62xx.c>.
   If unsure, say N.
 
+CONFIG_AEC6280_BURST
+  Use burst mode for DMA transfers. Higher speed, but causes more load
+  on the bus.
+
+  If unsure, say N.
+
 CONFIG_BLK_DEV_ALI15X3
   This driver ensures (U)DMA support for ALI 1533, 1543 and 1543C
   onboard chipsets.  It also tests for Simplex mode and enables
@@ -696,35 +703,6 @@
   EXT_DIRECT is used for IDE devices directly connected to the 8xx
              bus using some glue logic, but _not_ the 8xx internal
              PCMCIA interface (example: IDIF860 systems)
-
-CONFIG_BLK_DEV_IDEDISK_FUJITSU
-  Enable vendor-specific code for Fujitsu IDE disks.  Unless you are
-  the IDE maintainer, you probably do not want to mess with this.
-
-CONFIG_BLK_DEV_IDEDISK_IBM
-  Enable vendor-specific code for IBM IDE disks.  Unless you are the
-  IDE maintainer, you probably do not want to mess with this.
-
-CONFIG_BLK_DEV_IDEDISK_MAXTOR
-  Enable vendor-specific code for Maxtor IDE disks.  Unless you are
-  the IDE maintainer, you probably do not want to mess with this.
-
-CONFIG_BLK_DEV_IDEDISK_QUANTUM
-  Enable vendor-specific code for Quantum IDE disks.  Unless you are
-  the IDE maintainer, you probably do not want to mess with this.
-
-CONFIG_BLK_DEV_IDEDISK_SEAGATE
-  Enable vendor-specific code for Seagate IDE disks.  Unless you are
-  the IDE maintainer, you probably do not want to mess with this.
-
-CONFIG_BLK_DEV_IDEDISK_WD
-  Enable vendor-specific code for Western Digital IDE disks.  Unless
-  you are the IDE maintainer, you probably do not want to mess with
-  this.
-
-CONFIG_BLK_DEV_TIVO
-  Enable vendor-specific code for TiVo IDE disks.  Unless you are the
-  IDE maintainer, you probably do not want to mess with this.
 
 CONFIG_IDEDISK_STROKE
   Should you have a system w/ an AWARD Bios and your drives are larger
diff -Nru a/drivers/ide/Config.in b/drivers/ide/Config.in
--- a/drivers/ide/Config.in	Fri May 24 18:55:36 2002
+++ b/drivers/ide/Config.in	Fri May 24 18:55:36 2002
@@ -15,18 +15,6 @@
    dep_tristate '  Include IDE/ATA-2 DISK support' CONFIG_BLK_DEV_IDEDISK $CONFIG_BLK_DEV_IDE
    dep_mbool '    Use multi-mode by default' CONFIG_IDEDISK_MULTI_MODE $CONFIG_BLK_DEV_IDEDISK
    dep_mbool '    Auto-Geometry Resizing support' CONFIG_IDEDISK_STROKE $CONFIG_BLK_DEV_IDEDISK
-
-   define_bool CONFIG_BLK_DEV_IDEDISK_VENDOR n
-   dep_mbool '    Fujitsu Vendor Specific' CONFIG_BLK_DEV_IDEDISK_FUJITSU $CONFIG_BLK_DEV_IDEDISK_VENDOR
-   dep_mbool '    IBM Vendor Specific' CONFIG_BLK_DEV_IDEDISK_IBM $CONFIG_BLK_DEV_IDEDISK_VENDOR
-   dep_mbool '    Maxtor Vendor Specific' CONFIG_BLK_DEV_IDEDISK_MAXTOR $CONFIG_BLK_DEV_IDEDISK_VENDOR
-   dep_mbool '    Quantum Vendor Specific' CONFIG_BLK_DEV_IDEDISK_QUANTUM $CONFIG_BLK_DEV_IDEDISK_VENDOR
-   dep_mbool '    Seagate Vendor Specific' CONFIG_BLK_DEV_IDEDISK_SEAGATE $CONFIG_BLK_DEV_IDEDISK_VENDOR
-   dep_mbool '    Western Digital Vendor Specific' CONFIG_BLK_DEV_IDEDISK_WD $CONFIG_BLK_DEV_IDEDISK_VENDOR
-
-   define_bool CONFIG_BLK_DEV_COMMERIAL n
-   dep_mbool '    TiVo Commerial Application Specific' CONFIG_BLK_DEV_TIVO $CONFIG_BLK_DEV_COMMERIAL
-
    dep_tristate '  PCMCIA IDE support' CONFIG_BLK_DEV_IDECS $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA
    dep_tristate '  Include IDE/ATAPI CDROM support' CONFIG_BLK_DEV_IDECD $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE $CONFIG_BLK_DEV_IDE
@@ -54,6 +42,7 @@
       dep_bool '    Good-Bad DMA Model-Firmware (EXPERIMENTAL)' CONFIG_IDEDMA_NEW_DRIVE_LISTINGS $CONFIG_EXPERIMENTAL
       dep_bool '    AEC62XX chip set support' CONFIG_BLK_DEV_AEC62XX $CONFIG_BLK_DEV_IDEDMA_PCI
       dep_mbool '      AEC62XX Tuning support' CONFIG_AEC62XX_TUNING $CONFIG_BLK_DEV_AEC62XX
+      dep_mbool '      AEC6280 Burst mode' CONFIG_AEC6280_BURST $CONFIG_BLK_DEV_AEC62XX
       dep_bool '    ALI M15x3 chipset support' CONFIG_BLK_DEV_ALI15X3 $CONFIG_BLK_DEV_IDEDMA_PCI
       dep_mbool '      ALI M15x3 WDC support (DANGEROUS)' CONFIG_WDC_ALI15X3 $CONFIG_BLK_DEV_ALI15X3 $CONFIG_EXPERIMENTAL
       dep_bool '    AMD and nVidia chipset support' CONFIG_BLK_DEV_AMD74XX $CONFIG_BLK_DEV_IDEDMA_PCI
@@ -141,6 +130,8 @@
         "$CONFIG_BLK_DEV_IDEDMA_ICS" = "y" ]; then
       bool '  IGNORE word93 Validation BITS' CONFIG_IDEDMA_IVB
    fi
+   
+   define_bool  CONFIG_ATAPI y
 else
    bool 'Old hard disk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY
    define_bool CONFIG_BLK_DEV_HD $CONFIG_BLK_DEV_HD_ONLY
@@ -152,12 +143,6 @@
    define_bool CONFIG_IDEDMA_AUTO y
 else
    define_bool CONFIG_IDEDMA_AUTO n
-fi
-
-if [ "$CONFIG_BLK_DEV_TIVO" = "y" ]; then
-  define_bool CONFIG_DMA_NONPCI y
-else
-  define_bool CONFIG_DMA_NONPCI n
 fi
 
 dep_tristate 'Support for IDE Raid controllers' CONFIG_BLK_DEV_ATARAID $CONFIG_BLK_DEV_IDE $CONFIG_EXPERIMENTAL
diff -Nru a/drivers/ide/Makefile b/drivers/ide/Makefile
--- a/drivers/ide/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/ide/Makefile	Fri May 24 18:55:36 2002
@@ -10,7 +10,8 @@
 
 O_TARGET := idedriver.o
 
-export-objs	:= ide-taskfile.o ide.o ide-features.o ide-probe.o quirks.o pcidma.o ataraid.o
+export-objs	:= ide-taskfile.o ide.o ide-features.o ide-probe.o quirks.o pcidma.o tcq.o \
+		   atapi.o ataraid.o
 
 obj-y		:=
 obj-m		:=
@@ -20,6 +21,7 @@
 obj-$(CONFIG_BLK_DEV_IDE)       += ide-mod.o
 obj-$(CONFIG_BLK_DEV_IDECS)     += ide-cs.o
 obj-$(CONFIG_BLK_DEV_IDEDISK)   += ide-disk.o
+# obj-$(CONFIG_ATAPI)		+= atapi.o
 obj-$(CONFIG_BLK_DEV_IDECD)     += ide-cd.o
 obj-$(CONFIG_BLK_DEV_IDETAPE)   += ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
@@ -72,6 +74,6 @@
 obj-$(CONFIG_BLK_DEV_ATARAID_PDC)	+= pdcraid.o
 obj-$(CONFIG_BLK_DEV_ATARAID_HPT)	+= hptraid.o
 
-ide-mod-objs	:= ide-taskfile.o ide.o ide-probe.o ide-geometry.o ide-features.o ata-timing.o $(ide-obj-y)
+ide-mod-objs	:= ide-taskfile.o ide.o ide-probe.o ide-geometry.o ide-features.o ata-timing.o atapi.o $(ide-obj-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c
--- a/drivers/ide/aec62xx.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/aec62xx.c	Fri May 24 18:55:35 2002
@@ -1,9 +1,8 @@
 /**** vi:set ts=8 sts=8 sw=8:************************************************
  *
- * Version 0.09	June. 9, 2000
+ * Version 0.11	March 27, 2002
  *
  * Copyright (C) 1999-2000	Andre Hedrick (andre@linux-ide.org)
- * May be copied or modified under the terms of the GNU General Public License
  *
  */
 
@@ -52,6 +51,21 @@
 extern int (*aec62xx_display_info)(char *, char **, off_t, int); /* ide-proc.c */
 static struct pci_dev *bmide_dev;
 
+static const char *aec6280_get_speed(u8 speed)
+{
+	switch(speed) {
+		case 7: return "6";
+		case 6: return "5";
+		case 5: return "4";
+		case 4: return "3";
+		case 3: return "2";
+		case 2: return "1";
+		case 1: return "0";
+		case 0: return "?";
+	}
+	return "?";
+}
+
 static int aec62xx_get_info (char *buffer, char **addr, off_t offset, int count)
 {
 	char *p = buffer;
@@ -70,6 +84,12 @@
 		case PCI_DEVICE_ID_ARTOP_ATP860R:
 			p += sprintf(p, "\n                                AEC6260 Chipset.\n");
 			break;
+		case PCI_DEVICE_ID_ARTOP_ATP865:
+			p += sprintf(p, "\n                                AEC6280 Chipset without ROM.\n");
+			break;
+		case PCI_DEVICE_ID_ARTOP_ATP865R:
+			p += sprintf(p, "\n                                AEC6280 Chipset with ROM.\n");
+			break;
 		default:
 			p += sprintf(p, "\n                                AEC62?? Chipset.\n");
 			break;
@@ -154,6 +174,41 @@
 			(void) pci_read_config_byte(bmide_dev, 0x4a, &uart);
 			p += sprintf(p, "reg4ah = 0x%02x\n", uart);
 			break;
+		case PCI_DEVICE_ID_ARTOP_ATP865:
+		case PCI_DEVICE_ID_ARTOP_ATP865R:
+			(void) pci_read_config_byte(bmide_dev, 0x44, &art);
+			p += sprintf(p, "DMA Mode:       %s(%s)          %s(%s)",
+				(c0&0x20)?((art&0x0f)?"UDMA":" DMA"):" PIO",
+				aec6280_get_speed(art&0x0f),
+				(c0&0x40)?((art&0xf0)?"UDMA":" DMA"):" PIO",
+				aec6280_get_speed(art>>4));
+			(void) pci_read_config_byte(bmide_dev, 0x45, &art);
+			p += sprintf(p, "         %s(%s)          %s(%s)\n",
+				(c0&0x20)?((art&0x0f)?"UDMA":" DMA"):" PIO",
+				aec6280_get_speed(art&0x0f),
+				(c0&0x40)?((art&0xf0)?"UDMA":" DMA"):" PIO",
+				aec6280_get_speed(art>>4));
+			(void) pci_read_config_byte(bmide_dev, 0x40, &art);
+			p += sprintf(p, "Active:         0x%02x", HIGH_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x41, &art);
+			p += sprintf(p, "             0x%02x", HIGH_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x42, &art);
+			p += sprintf(p, "            0x%02x", HIGH_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x43, &art);
+			p += sprintf(p, "              0x%02x\n", HIGH_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x40, &art);
+			p += sprintf(p, "Recovery:       0x%02x", LOW_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x41, &art);
+			p += sprintf(p, "             0x%02x", LOW_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x42, &art);
+			p += sprintf(p, "            0x%02x", LOW_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x43, &art);
+			p += sprintf(p, "              0x%02x\n", LOW_4(art));
+			(void) pci_read_config_byte(bmide_dev, 0x49, &uart);
+			p += sprintf(p, "reg49h = 0x%02x ", uart);
+			(void) pci_read_config_byte(bmide_dev, 0x4a, &uart);
+			p += sprintf(p, "reg4ah = 0x%02x\n", uart);
+			break;
 		default:
 			break;
 	}
@@ -164,8 +219,6 @@
 
 byte aec62xx_proc = 0;
 
-#ifdef CONFIG_AEC62XX_TUNING
-
 struct chipset_bus_clock_list_entry {
 	byte		xfer_speed;
 
@@ -178,6 +231,8 @@
 
 struct chipset_bus_clock_list_entry aec62xx_base [] = {
 #ifdef CONFIG_BLK_DEV_IDEDMA
+	{	XFER_UDMA_6,	0x41,	0x06,	0x31,	0x07	},
+	{	XFER_UDMA_5,	0x41,	0x05,	0x31,	0x06	},
 	{	XFER_UDMA_4,	0x41,	0x04,	0x31,	0x05	},
 	{	XFER_UDMA_3,	0x41,	0x03,	0x31,	0x04	},
 	{	XFER_UDMA_2,	0x41,	0x02,	0x31,	0x03	},
@@ -196,8 +251,6 @@
 	{	0,		0x00,	0x00,	0x00,	0x00	}
 };
 
-extern char *ide_xfer_verbose (byte xfer_rate);
-
 /*
  * TO DO: active tuning and correction of cards without a bios.
  */
@@ -206,7 +259,7 @@
 {
 	for ( ; chipset_table->xfer_speed ; chipset_table++)
 		if (chipset_table->xfer_speed == speed) {
-			return ((byte) ((system_bus_speed <= 33) ? chipset_table->chipset_settings_33 : chipset_table->chipset_settings_34));
+			return ((byte) ((system_bus_speed <= 33333) ? chipset_table->chipset_settings_33 : chipset_table->chipset_settings_34));
 		}
 	return 0x00;
 }
@@ -215,16 +268,39 @@
 {
 	for ( ; chipset_table->xfer_speed ; chipset_table++)
 		if (chipset_table->xfer_speed == speed) {
-			return ((byte) ((system_bus_speed <= 33) ? chipset_table->ultra_settings_33 : chipset_table->ultra_settings_34));
+			return ((byte) ((system_bus_speed <= 33333) ? chipset_table->ultra_settings_33 : chipset_table->ultra_settings_34));
 		}
 	return 0x00;
 }
 
+static int aec62xx_ratemask(struct ata_device *drive)
+{
+	struct pci_dev *dev = drive->channel->pci_dev;
+	u32 bmide = pci_resource_start(dev, 4);
+	int map = 0;
+
+	if (!eighty_ninty_three(drive))
+		return XFER_UDMA;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_ARTOP_ATP865R:
+		case PCI_DEVICE_ID_ARTOP_ATP865:
+			if (IN_BYTE(bmide+2) & 0x10)
+				map |= XFER_UDMA_133;
+			else
+				map |= XFER_UDMA_100;
+		case PCI_DEVICE_ID_ARTOP_ATP860R:
+		case PCI_DEVICE_ID_ARTOP_ATP860:
+			map |= XFER_UDMA_66;
+		case PCI_DEVICE_ID_ARTOP_ATP850UF:
+			map |= XFER_UDMA;
+	}
+	return map;
+}
+
 static int aec6210_tune_chipset(struct ata_device *drive, byte speed)
 {
-	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
-	int err			= 0;
+	struct pci_dev *dev = drive->channel->pci_dev;
 	unsigned short d_conf	= 0x0000;
 	byte ultra		= 0x00;
 	byte ultra_conf		= 0x00;
@@ -252,17 +328,14 @@
 
 	__restore_flags(flags);	/* local CPU only */
 
-	err = ide_config_drive_speed(drive, speed);
-	return(err);
+	return ide_config_drive_speed(drive, speed);
 }
 
 static int aec6260_tune_chipset(struct ata_device *drive, byte speed)
 {
-	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
+	struct pci_dev *dev = drive->channel->pci_dev;
 	byte unit		= (drive->select.b.unit & 0x01);
-	byte ultra_pci		= hwif->unit ? 0x45 : 0x44;
-	int err			= 0;
+	u8 ultra_pci = drive->channel->unit ? 0x45 : 0x44;
 	byte drive_conf		= 0x00;
 	byte ultra_conf		= 0x00;
 	byte ultra		= 0x00;
@@ -287,128 +360,47 @@
 	if (!drive->init_speed)
 		drive->init_speed = speed;
 
-	err = ide_config_drive_speed(drive, speed);
 	drive->current_speed = speed;
-	return(err);
+	return ide_config_drive_speed(drive, speed);
 }
 
 
 static int aec62xx_tune_chipset(struct ata_device *drive, byte speed)
 {
-	if (drive->channel->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
-		return ((int) aec6210_tune_chipset(drive, speed));
-	} else {
-		return ((int) aec6260_tune_chipset(drive, speed));
+	switch (drive->channel->pci_dev->device) {
+		case PCI_DEVICE_ID_ARTOP_ATP865:
+		case PCI_DEVICE_ID_ARTOP_ATP865R:
+		case PCI_DEVICE_ID_ARTOP_ATP860:
+		case PCI_DEVICE_ID_ARTOP_ATP860R:
+			return aec6260_tune_chipset(drive, speed);
+		case PCI_DEVICE_ID_ARTOP_ATP850UF:
+			return aec6210_tune_chipset(drive, speed);
+		default:
+			return -1;
 	}
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static int config_aec6210_chipset_for_dma(struct ata_device *drive, byte ultra)
+static int config_chipset_for_dma(struct ata_device *drive, u8 udma)
 {
-	struct hd_driveid *id	= drive->id;
-	struct ata_channel *hwif = drive->channel;
-	byte unit		= (drive->select.b.unit & 0x01);
-	unsigned long dma_base	= hwif->dma_base;
-	byte speed		= -1;
+	int map;
+	u8 mode;
 
 	if (drive->type != ATA_DISK)
 		return 0;
 
-	if (((id->dma_ultra & 0x0010) ||
-	     (id->dma_ultra & 0x0008) ||
-	     (id->dma_ultra & 0x0004)) && (ultra)) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0002) && (ultra)) {
-		speed = XFER_UDMA_1;
-	} else if ((id->dma_ultra & 0x0001) && (ultra)) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else if (id->dma_1word & 0x0004) {
-		speed = XFER_SW_DMA_2;
-	} else if (id->dma_1word & 0x0002) {
-		speed = XFER_SW_DMA_1;
-	} else if (id->dma_1word & 0x0001) {
-		speed = XFER_SW_DMA_0;
-	} else {
-		return 0;
-	}
-
-	outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-	(void) aec6210_tune_chipset(drive, speed);
-
-	return ((int)	((id->dma_ultra >> 11) & 3) ? 0 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
-}
-
-static int config_aec6260_chipset_for_dma(struct ata_device *drive, byte ultra)
-{
-	struct hd_driveid *id	= drive->id;
-	struct ata_channel *hwif = drive->channel;
-	byte unit		= (drive->select.b.unit & 0x01);
-	unsigned long dma_base	= hwif->dma_base;
-	byte speed		= -1;
-	byte ultra66		= eighty_ninty_three(drive);
+	if (udma)
+		map = aec62xx_ratemask(drive);
+	else
+		map = XFER_SWDMA | XFER_MWDMA;
 
-	if (drive->type != ATA_DISK)
-		return 0;
+	mode = ata_timing_mode(drive, map);
 
-	if ((id->dma_ultra & 0x0010) && (ultra) && (ultra66)) {
-		speed = XFER_UDMA_4;
-	} else if ((id->dma_ultra & 0x0008) && (ultra) && (ultra66)) {
-		speed = XFER_UDMA_3;
-	} else if ((id->dma_ultra & 0x0004) && (ultra)) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0002) && (ultra)) {
-		speed = XFER_UDMA_1;
-	} else if ((id->dma_ultra & 0x0001) && (ultra)) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else if (id->dma_1word & 0x0004) {
-		speed = XFER_SW_DMA_2;
-	} else if (id->dma_1word & 0x0002) {
-		speed = XFER_SW_DMA_1;
-	} else if (id->dma_1word & 0x0001) {
-		speed = XFER_SW_DMA_0;
-	} else {
+	if (mode < XFER_SW_DMA_0)
 		return 0;
-	}
-
-	outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-	(void) aec6260_tune_chipset(drive, speed);
-
-	return ((int)	((id->dma_ultra >> 11) & 3) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
-}
 
-static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
-{
-	switch(drive->channel->pci_dev->device) {
-		case PCI_DEVICE_ID_ARTOP_ATP850UF:
-			return config_aec6210_chipset_for_dma(drive, ultra);
-		case PCI_DEVICE_ID_ARTOP_ATP860:
-		case PCI_DEVICE_ID_ARTOP_ATP860R:
-			return config_aec6260_chipset_for_dma(drive, ultra);
-		default:
-			return 0;
-	}
+	return !aec62xx_tune_chipset(drive, mode);
 }
-
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 static void aec62xx_tune_drive(struct ata_device *drive, byte pio)
@@ -420,15 +412,7 @@
 	else
 		speed = XFER_PIO_0 + min_t(byte, pio, 4);
 
-	switch(drive->channel->pci_dev->device) {
-		case PCI_DEVICE_ID_ARTOP_ATP850UF:
-			(void) aec6210_tune_chipset(drive, speed);
-		case PCI_DEVICE_ID_ARTOP_ATP860:
-		case PCI_DEVICE_ID_ARTOP_ATP860R:
-			(void) aec6260_tune_chipset(drive, speed);
-		default:
-			break;
-        }
+	(void) aec62xx_tune_chipset(drive, speed);
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
@@ -447,7 +431,7 @@
 		on = 0;
 		verbose = 0;
 		if (id->field_valid & 4) {
-			if (id->dma_ultra & 0x001F) {
+			if (id->dma_ultra & 0x007F) {
 				/* Force if Capable UltraDMA */
 				on = config_chipset_for_dma(drive, 1);
 				if ((id->field_valid & 2) &&
@@ -490,10 +474,33 @@
 	return config_drive_xfer_rate(drive);
 }
 #endif
-#endif
 
 static unsigned int __init aec62xx_init_chipset(struct pci_dev *dev)
 {
+	u8 reg49h = 0;
+	u8 reg4ah = 0;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_ARTOP_ATP865:
+		case PCI_DEVICE_ID_ARTOP_ATP865R:
+			/* Clear reset and test bits.  */
+			pci_read_config_byte(dev, 0x49, &reg49h);
+			pci_write_config_byte(dev, 0x49, reg49h & ~0x30);
+			/* Enable chip interrupt output.  */
+			pci_read_config_byte(dev, 0x4a, &reg4ah);
+			pci_write_config_byte(dev, 0x4a, reg4ah & ~0x01);
+#ifdef CONFIG_AEC6280_BURST
+			/* Must be greater than 0x80 for burst mode.  */
+			pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x90);
+			/* Enable burst mode.  */
+			pci_read_config_byte(dev, 0x4a, &reg4ah);
+			pci_write_config_byte(dev, 0x4a, reg4ah | 0x80);
+#endif
+			break;
+		default:
+			break;
+	}
+
 	if (dev->resource[PCI_ROM_RESOURCE].start) {
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
 		printk("%s: ROM enabled at 0x%08lx\n", dev->name, dev->resource[PCI_ROM_RESOURCE].start);
@@ -522,28 +529,30 @@
 
 static void __init aec62xx_init_channel(struct ata_channel *hwif)
 {
-#ifdef CONFIG_AEC62XX_TUNING
 	hwif->tuneproc = aec62xx_tune_drive;
 	hwif->speedproc = aec62xx_tune_chipset;
-# ifdef CONFIG_BLK_DEV_IDEDMA
-	if (hwif->dma_base)
-		hwif->XXX_udma = aec62xx_dmaproc;
-	hwif->highmem = 1;
-# else
 	hwif->drives[0].autotune = 1;
 	hwif->drives[1].autotune = 1;
+
+#ifdef CONFIG_BLK_DEV_IDEDMA
+	if (hwif->dma_base) {
+		hwif->XXX_udma = aec62xx_dmaproc;
+		hwif->highmem = 1;
+# ifdef CONFIG_IDEDMA_AUTO
+		if (!noautodma)
+			hwif->autodma = 1;
 # endif
+	}
 #endif
 }
 
 static void __init aec62xx_init_dma(struct ata_channel *hwif, unsigned long dmabase)
 {
-#ifdef CONFIG_AEC62XX_TUNING
 	u8 reg54h = 0;
 
+	/* FIXME: we need some locking here */
 	pci_read_config_byte(hwif->pci_dev, 0x54, &reg54h);
 	pci_write_config_byte(hwif->pci_dev, 0x54, reg54h & ~(hwif->unit ? 0xF0 : 0x0F));
-#endif
 	ata_init_dma(hwif, dmabase);
 }
 
@@ -579,6 +588,26 @@
 		bootable: OFF_BOARD,
 		flags: ATA_F_IRQ | ATA_F_DMA
 	},
+	{
+		vendor: PCI_VENDOR_ID_ARTOP,
+		device: PCI_DEVICE_ID_ARTOP_ATP865,
+		init_chipset: aec62xx_init_chipset,
+		ata66_check: aec62xx_ata66_check,
+		init_channel: aec62xx_init_channel,
+		enablebits: { {0x00,0x00,0x00},	{0x00,0x00,0x00} },
+		bootable: NEVER_BOARD,
+		flags: ATA_F_IRQ | ATA_F_DMA
+	},
+	{
+		vendor: PCI_VENDOR_ID_ARTOP,
+		device: PCI_DEVICE_ID_ARTOP_ATP865R,
+		init_chipset: aec62xx_init_chipset,
+		ata66_check: aec62xx_ata66_check,
+		init_channel: aec62xx_init_channel,
+		enablebits: { {0x00,0x00,0x00},	{0x00,0x00,0x00} },
+		bootable: OFF_BOARD,
+		flags: ATA_F_IRQ | ATA_F_DMA
+	}
 };
 
 int __init init_aec62xx(void)
diff -Nru a/drivers/ide/ali14xx.c b/drivers/ide/ali14xx.c
--- a/drivers/ide/ali14xx.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/ali14xx.c	Fri May 24 18:55:35 2002
@@ -106,11 +106,11 @@
  * This function computes timing parameters
  * and sets controller registers accordingly.
  */
-static void ali14xx_tune_drive (ide_drive_t *drive, byte pio)
+static void ali14xx_tune_drive(struct ata_device *drive, u8 pio)
 {
 	int driveNum;
 	int time1, time2;
-	byte param1, param2, param3, param4;
+	u8 param1, param2, param3, param4;
 	unsigned long flags;
 	struct ata_timing *t;
 
@@ -124,8 +124,8 @@
 	/* calculate timing, according to PIO mode */
 	time1 = t->cycle;
 	time2 = t->active;
-	param3 = param1 = (time2 * system_bus_speed + 999) / 1000;
-	param4 = param2 = (time1 * system_bus_speed + 999) / 1000 - param1;
+	param3 = param1 = (time2 * system_bus_speed + 999999) / 1000000;
+	param4 = param2 = (time1 * system_bus_speed + 999999) / 1000000 - param1;
 	if (pio < XFER_PIO_3) {
 		param3 += 8;
 		param4 += 8;
diff -Nru a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
--- a/drivers/ide/alim15x3.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/alim15x3.c	Fri May 24 18:55:36 2002
@@ -261,18 +261,18 @@
 
 	s_time = t->setup;
 	a_time = t->active;
-	if ((s_clc = (s_time * system_bus_speed + 999) / 1000) >= 8)
+	if ((s_clc = (s_time * system_bus_speed + 999999) / 1000000) >= 8)
 		s_clc = 0;
-	if ((a_clc = (a_time * system_bus_speed + 999) / 1000) >= 8)
+	if ((a_clc = (a_time * system_bus_speed + 999999) / 1000000) >= 8)
 		a_clc = 0;
 	c_time = t->cycle;
 
 #if 0
-	if ((r_clc = ((c_time - s_time - a_time) * system_bus_speed + 999) / 1000) >= 16)
+	if ((r_clc = ((c_time - s_time - a_time) * system_bus_speed + 999999) / 1000000) >= 16)
 		r_clc = 0;
 #endif
 
-	if (!(r_clc = (c_time * system_bus_speed + 999) / 1000 - a_clc - s_clc)) {
+	if (!(r_clc = (c_time * system_bus_speed + 999999) / 1000000 - a_clc - s_clc)) {
 		r_clc = 1;
 	} else {
 		if (r_clc >= 16)
@@ -304,14 +304,49 @@
 	__restore_flags(flags);
 }
 
+static byte ali15x3_can_ultra(struct ata_device *drive)
+{
+	if (m5229_revision <= 0x20) {
+		return 0;
+	} else if ((m5229_revision < 0xC2) &&
+#ifndef CONFIG_WDC_ALI15X3
+		((chip_is_1543c_e && strstr(drive->id->model, "WDC ")) ||
+		 (drive->type != ATA_DISK))) {
+#else
+		(drive->type != ATA_DISK)) {
+#endif
+		return 0;
+	} else {
+		return 1;
+	}
+}
+
+static int ali15x3_ratemask(struct ata_device *drive)
+{
+	int map = 0;
+
+	if (!ali15x3_can_ultra(drive))
+		return 0;
+
+	map |= XFER_UDMA;
+
+	if (!eighty_ninty_three(drive))
+		return map;
+
+	if (m5229_revision >= 0xC4)
+		map |= XFER_UDMA_100;
+	if (m5229_revision >= 0xC2)
+		map |= XFER_UDMA_66;
+
+	return map;
+}
+
 static int ali15x3_tune_chipset(struct ata_device *drive, byte speed)
 {
-	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
+	struct pci_dev *dev = drive->channel->pci_dev;
 	byte unit		= (drive->select.b.unit & 0x01);
 	byte tmpbyte		= 0x00;
-	int m5229_udma		= hwif->unit ? 0x57 : 0x56;
-	int err			= 0;
+	int m5229_udma		= drive->channel->unit ? 0x57 : 0x56;
 
 	if (speed < XFER_UDMA_0) {
 		byte ultra_enable	= (unit) ? 0x7f : 0xf7;
@@ -323,16 +358,10 @@
 		pci_write_config_byte(dev, m5229_udma, tmpbyte);
 	}
 
-	err = ide_config_drive_speed(drive, speed);
-
+	if (speed < XFER_SW_DMA_0)
+		ali15x3_tune_drive(drive, speed);
 #ifdef CONFIG_BLK_DEV_IDEDMA
-	if (speed >= XFER_SW_DMA_0) {
-		unsigned long dma_base = hwif->dma_base;
-
-		outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2);
-	}
-
-	if (speed >= XFER_UDMA_0) {
+	else if (speed >= XFER_UDMA_0) {
 		pci_read_config_byte(dev, m5229_udma, &tmpbyte);
 		tmpbyte &= (0x0f << ((1-unit) << 2));
 		/*
@@ -348,9 +377,11 @@
 	}
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
+	if (!drive->init_speed)
+		drive->init_speed = speed;
 	drive->current_speed = speed;
 
-	return (err);
+	return ide_config_drive_speed(drive, speed);
 }
 
 static void config_chipset_for_pio(struct ata_device *drive)
@@ -359,75 +390,21 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static int config_chipset_for_dma(struct ata_device *drive, byte ultra33)
+static int config_chipset_for_dma(struct ata_device *drive, u8 udma)
 {
-	struct hd_driveid *id	= drive->id;
-	byte speed		= 0x00;
-	byte ultra66		= eighty_ninty_three(drive);
-	byte ultra100		= (m5229_revision>=0xc4) ? 1 : 0;
-	int  rval;
-
-	if ((id->dma_ultra & 0x0020) && (ultra100) && (ultra66) && (ultra33)) {
-		speed = XFER_UDMA_5;
-	} else if ((id->dma_ultra & 0x0010) && (ultra66) && (ultra33)) {
-		speed = XFER_UDMA_4;
-	} else if ((id->dma_ultra & 0x0008) && (ultra66) && (ultra33)) {
-		speed = XFER_UDMA_3;
-	} else if ((id->dma_ultra & 0x0004) && (ultra33)) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0002) && (ultra33)) {
-		speed = XFER_UDMA_1;
-	} else if ((id->dma_ultra & 0x0001) && (ultra33)) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else if (id->dma_1word & 0x0004) {
-		speed = XFER_SW_DMA_2;
-	} else if (id->dma_1word & 0x0002) {
-		speed = XFER_SW_DMA_1;
-	} else if (id->dma_1word & 0x0001) {
-		speed = XFER_SW_DMA_0;
-	} else {
-		return 0;
-	}
-
-	(void) ali15x3_tune_chipset(drive, speed);
-
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
-	rval = (int)(	((id->dma_ultra >> 11) & 3) ? 1:
-			((id->dma_ultra >> 8) & 7) ? 1:
-			((id->dma_mword >> 8) & 7) ? 1:
-			((id->dma_1word >> 8) & 7) ? 1:
-						     0);
-
-	return rval;
-}
+	int map;
+	u8 mode;
 
-static byte ali15x3_can_ultra(struct ata_device *drive)
-{
-#ifndef CONFIG_WDC_ALI15X3
-	struct hd_driveid *id	= drive->id;
-#endif /* CONFIG_WDC_ALI15X3 */
+	if (udma)
+		map = ali15x3_ratemask(drive);
+	else
+		map = XFER_SWDMA | XFER_MWDMA;
 
-	if (m5229_revision <= 0x20) {
-		return 0;
-	} else if ((m5229_revision < 0xC2) &&
-#ifndef CONFIG_WDC_ALI15X3
-		   ((chip_is_1543c_e && strstr(id->model, "WDC ")) ||
-		    (drive->type != ATA_DISK))) {
-#else /* CONFIG_WDC_ALI15X3 */
-		   (drive->type != ATA_DISK)) {
-#endif /* CONFIG_WDC_ALI15X3 */
+	mode = ata_timing_mode(drive, map);
+	if (mode < XFER_SW_DMA_0)
 		return 0;
-	} else {
-		return 1;
-	}
+
+	return !ali15x3_tune_chipset(drive, mode);
 }
 
 static int ali15x3_config_drive_for_dma(struct ata_device *drive)
diff -Nru a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
--- a/drivers/ide/amd74xx.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/amd74xx.c	Fri May 24 18:55:36 2002
@@ -87,7 +87,6 @@
 static struct amd_ide_chip *amd_config;
 static unsigned char amd_enabled;
 static unsigned int amd_80w;
-static unsigned int amd_clock;
 
 static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3 };
 static unsigned char amd_udma2cyc[] = { 4, 6, 8, 10, 3, 2, 1, 1 };
@@ -131,7 +130,7 @@
 	amd_print("Highest DMA rate:                   %s", amd_dma[amd_config->flags & AMD_UDMA]);
 
 	amd_print("BM-DMA base:                        %#x", amd_base);
-	amd_print("PCI clock:                          %d.%dMHz", amd_clock / 1000, amd_clock / 100 % 10);
+	amd_print("PCI clock:                          %d.%dMHz", system_bus_speed / 1000, system_bus_speed / 100 % 10);
 	
 	amd_print("-----------------------Primary IDE-------Secondary IDE------");
 
@@ -147,7 +146,7 @@
 
 	amd_print("Cable Type:            %10s%20s", (amd_80w & 1) ? "80w" : "40w", (amd_80w & 2) ? "80w" : "40w");
 
-	if (!amd_clock)
+	if (!system_bus_speed)
                 return p - buffer;
 
 	amd_print("-------------------drive0----drive1----drive2----drive3-----");
@@ -169,22 +168,22 @@
 		den[i]  = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
 
 		if (den[i] && uen[i] && udma[i] == 1) {
-			speed[i] = amd_clock * 3;
-			cycle[i] = 666666 / amd_clock;
+			speed[i] = system_bus_speed * 3;
+			cycle[i] = 666666 / system_bus_speed;
 			continue;
 		}
 
-		speed[i] = 4 * amd_clock / ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2);
-		cycle[i] = 1000000 * ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2) / amd_clock / 2;
+		speed[i] = 4 * system_bus_speed / ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2);
+		cycle[i] = 1000000 * ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2) / system_bus_speed / 2;
 	}
 
 	amd_print_drive("Transfer Mode: ", "%10s", den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
 
-	amd_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / amd_clock);
-	amd_print_drive("Cmd Active:    ", "%8dns", 1000000 * active8b[i] / amd_clock);
-	amd_print_drive("Cmd Recovery:  ", "%8dns", 1000000 * recover8b[i] / amd_clock);
-	amd_print_drive("Data Active:   ", "%8dns", 1000000 * active[i] / amd_clock);
-	amd_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / amd_clock);
+	amd_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / system_bus_speed);
+	amd_print_drive("Cmd Active:    ", "%8dns", 1000000 * active8b[i] / system_bus_speed);
+	amd_print_drive("Cmd Recovery:  ", "%8dns", 1000000 * recover8b[i] / system_bus_speed);
+	amd_print_drive("Data Active:   ", "%8dns", 1000000 * active[i] / system_bus_speed);
+	amd_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / system_bus_speed);
 	amd_print_drive("Cycle Time:    ", "%8dns", cycle[i]);
 	amd_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10);
 
@@ -227,9 +226,9 @@
  * by upper layers.
  */
 
-static int amd_set_drive(ide_drive_t *drive, unsigned char speed)
+static int amd_set_drive(struct ata_device *drive, unsigned char speed)
 {
-	ide_drive_t *peer = drive->channel->drives + (~drive->dn & 1);
+	struct ata_device *peer = drive->channel->drives + (~drive->dn & 1);
 	struct ata_timing t, p;
 	int T, UT;
 
@@ -238,7 +237,7 @@
 			printk(KERN_WARNING "ide%d: Drive %d didn't accept speed setting. Oh, well.\n",
 				drive->dn >> 1, drive->dn & 1);
 
-	T = 1000000000 / amd_clock;
+	T = 1000000000 / system_bus_speed;
 	UT = T / min_t(int, max_t(int, amd_config->flags & AMD_UDMA, 1), 2);
 
 	ata_timing_compute(drive, speed, &t, T, UT);
@@ -248,7 +247,7 @@
 		ata_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);
 	}
 
-	if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1;
+	if (speed == XFER_UDMA_5 && system_bus_speed <= 33333) t.udma = 1;
 
 	amd_set_speed(drive->channel->pci_dev, drive->dn, &t);
 
@@ -264,7 +263,7 @@
  * PIO-only tuning.
  */
 
-static void amd74xx_tune_drive(ide_drive_t *drive, unsigned char pio)
+static void amd74xx_tune_drive(struct ata_device *drive, u8 pio)
 {
 	if (!((amd_enabled >> drive->channel->unit) & 1))
 		return;
@@ -356,24 +355,6 @@
 	pci_read_config_byte(dev, AMD_IDE_CONFIG, &t);
 	pci_write_config_byte(dev, AMD_IDE_CONFIG,
 		(amd_config->flags & AMD_BAD_FIFO) ? (t & 0x0f) : (t | 0xf0));
-
-/*
- * Determine the system bus clock.
- */
-
-	amd_clock = system_bus_speed * 1000;
-
-	switch (amd_clock) {
-		case 33000: amd_clock = 33333; break;
-		case 37000: amd_clock = 37500; break;
-		case 41000: amd_clock = 41666; break;
-	}
-
-	if (amd_clock < 20000 || amd_clock > 50000) {
-		printk(KERN_WARNING "AMD_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", amd_clock);
-		printk(KERN_WARNING "AMD_IDE: Use ide0=ata66 if you want to assume 80-wire cable\n");
-		amd_clock = 33333;
-	}
 
 /*
  * Print the boot message.
diff -Nru a/drivers/ide/atapi.c b/drivers/ide/atapi.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/ide/atapi.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,75 @@
+/**** vi:set ts=8 sts=8 sw=8:************************************************
+ *
+ * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * Code common among all the ATAPI device drivers.
+ *
+ * Ideally this should evolve in to a unified driver.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/blkdev.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/cdrom.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/atapi.h>
+
+#include <asm/byteorder.h>
+#include <asm/io.h>
+#include <asm/bitops.h>
+#include <asm/uaccess.h>
+
+/*
+ * Too bad. The drive wants to send us data which we are not ready to accept.
+ * Just throw it away.
+ */
+void atapi_discard_data(struct ata_device *drive, unsigned int bcount)
+{
+	while (bcount--)
+		IN_BYTE(IDE_DATA_REG);
+}
+
+void atapi_write_zeros(struct ata_device *drive, unsigned int bcount)
+{
+	while (bcount--)
+		OUT_BYTE(0, IDE_DATA_REG);
+}
+
+/*
+ * Initializes a packet command. Used by tape and floppy driver.
+ */
+void atapi_init_pc(struct atapi_packet_command *pc)
+{
+	memset(pc->c, 0, 12);
+	pc->retries = 0;
+	pc->flags = 0;
+	pc->request_transfer = 0;
+	pc->buffer = pc->pc_buffer;
+	pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
+	pc->b_data = NULL;
+	pc->bio = NULL;
+}
+
+EXPORT_SYMBOL(atapi_discard_data);
+EXPORT_SYMBOL(atapi_write_zeros);
+EXPORT_SYMBOL(atapi_init_pc);
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c
--- a/drivers/ide/cmd640.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/cmd640.c	Fri May 24 18:55:35 2002
@@ -603,7 +603,7 @@
 	u8 cycle_count;
 
 	recovery_time = cycle_time - (setup_time + active_time);
-	clock_time = 1000 / system_bus_speed;
+	clock_time = 1000000 / system_bus_speed;
 	cycle_count = (cycle_time + clock_time - 1) / clock_time;
 
 	setup_count = (setup_time + clock_time - 1) / clock_time;
diff -Nru a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
--- a/drivers/ide/cmd64x.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/cmd64x.c	Fri May 24 18:55:35 2002
@@ -10,9 +10,9 @@
  *           Due to massive hardware bugs, UltraDMA is only supported
  *           on the 646U2 and not on the 646U.
  *
- * Copyright (C) 1998       Eddie C. Dost  (ecd@skynet.be)
- * Copyright (C) 1998       David S. Miller (davem@redhat.com)
- * Copyright (C) 1999-2000  Andre Hedrick <andre@linux-ide.org>
+ * Copyright (C) 1998		Eddie C. Dost <ecd@skynet.be>
+ * Copyright (C) 1998		David S. Miller <davem@redhat.com>
+ * Copyright (C) 1999-2002	Andre Hedrick <andre@linux-ide.org>
  */
 
 #include <linux/config.h>
@@ -305,7 +305,7 @@
 	 */
 
 	recovery_time = t->cycle - (t->setup + t->active);
-	clock_time = 1000 / system_bus_speed;
+	clock_time = 1000000 / system_bus_speed;
 	cycle_count = (t->cycle + clock_time - 1) / clock_time;
 	setup_count = (t->setup + clock_time - 1) / clock_time;
 	active_count = (t->active + clock_time - 1) / clock_time;
@@ -336,6 +336,59 @@
 		setup_count, active_count, recovery_count);
 }
 
+static int cmd64x_ratemask(struct ata_device *drive)
+{
+	struct pci_dev *dev = drive->channel->pci_dev;
+	int map = 0;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_CMD_680:
+			map |= XFER_UDMA_133;
+		case PCI_DEVICE_ID_CMD_649:
+			map |= XFER_UDMA_100;
+		case PCI_DEVICE_ID_CMD_648:
+			map |= XFER_UDMA_66;
+		case PCI_DEVICE_ID_CMD_643:
+			map |= XFER_UDMA;
+			break;
+		case PCI_DEVICE_ID_CMD_646:
+		{
+			unsigned int class_rev	= 0;
+			pci_read_config_dword(dev,
+				PCI_CLASS_REVISION, &class_rev);
+			class_rev &= 0xff;
+		/*
+		 * UltraDMA only supported on PCI646U and PCI646U2, which
+		 * correspond to revisions 0x03, 0x05 and 0x07 respectively.
+		 * Actually, although the CMD tech support people won't
+		 * tell me the details, the 0x03 revision cannot support
+		 * UDMA correctly without hardware modifications, and even
+		 * then it only works with Quantum disks due to some
+		 * hold time assumptions in the 646U part which are fixed
+		 * in the 646U2.
+		 *
+		 * So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
+		 */
+			switch(class_rev) {
+				case 0x07:
+				case 0x05:
+					map |= XFER_UDMA;
+				case 0x03:
+				case 0x01:
+				default:
+					break;
+			}
+		}
+	}
+
+	if (!eighty_ninty_three(drive)) {
+		if (map & XFER_UDMA)
+			return XFER_UDMA;
+		return 0;
+	}
+	return map;
+}
+
 static byte cmd680_taskfile_timing(struct ata_channel *hwif)
 {
 	struct pci_dev *dev	= hwif->pci_dev;
@@ -435,7 +488,6 @@
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev	= hwif->pci_dev;
-	int err			= 0;
 
 	u8 unit			= (drive->select.b.unit & 0x01);
 	u8 pciU			= (hwif->unit) ? UDIDETCR1 : UDIDETCR0;
@@ -469,9 +521,7 @@
 		case XFER_SW_DMA_1:	regD |= (unit ? 0x80 : 0x20); break;
 		case XFER_SW_DMA_0:	regD |= (unit ? 0xC0 : 0x30); break;
 #else
-	int err			= 0;
-
-		switch(speed) {
+	switch(speed) {
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 		case XFER_PIO_4:	cmd64x_tuneproc(drive, 4); break;
 		case XFER_PIO_3:	cmd64x_tuneproc(drive, 3); break;
@@ -487,8 +537,8 @@
 	(void) pci_write_config_byte(dev, pciU, regU);
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
-	err = ide_config_drive_speed(drive, speed);
-
+	if (!drive->init_speed)
+		drive->init_speed = speed;
 	drive->current_speed = speed;
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
@@ -496,7 +546,7 @@
 	(void) pci_write_config_byte(dev, pciD, regD);
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
-	return err;
+	return ide_config_drive_speed(drive, speed);
 }
 
 static int cmd680_tune_chipset(struct ata_device *drive, byte speed)
@@ -511,7 +561,6 @@
 	u8 scsc			= 0;
 	u16 ultra		= 0;
 	u16 multi		= 0;
-	int err			= 0;
 
         pci_read_config_byte(dev, addr_mask, &mode_pci);
 	pci_read_config_byte(dev, 0x8A, &scsc);
@@ -594,7 +643,6 @@
 			return 1;
 	}
 
-	
 	if (speed >= XFER_MW_DMA_0) 
 		config_cmd680_chipset_for_pio(drive, 0);
 
@@ -609,183 +657,47 @@
 	pci_write_config_word(dev, dma_pci, multi);
 	pci_write_config_word(dev, udma_pci, ultra);
 
-	err = ide_config_drive_speed(drive, speed);
+	if (!drive->init_speed)
+		drive->init_speed = speed;
 	drive->current_speed = speed;
-	return err;
+
+	return ide_config_drive_speed(drive, speed);
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static int config_cmd64x_chipset_for_dma(struct ata_device *drive, unsigned int rev, byte ultra_66)
+static int config_chipset_for_dma(struct ata_device *drive, u8 udma)
 {
-	struct hd_driveid *id	= drive->id;
-	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
-
-	byte speed		= 0x00;
-	byte set_pio		= 0x00;
-	byte udma_33		= ((rev >= 0x05) || (ultra_66)) ? 1 : 0;
-	byte udma_66		= eighty_ninty_three(drive);
-	byte udma_100		= 0;
-	int rval;
-
-	switch(dev->device) {
-		case PCI_DEVICE_ID_CMD_649: udma_100 = 1; break;
-		case PCI_DEVICE_ID_CMD_648:
-		case PCI_DEVICE_ID_CMD_646:
-		case PCI_DEVICE_ID_CMD_643:
-		default:
-			break;
-	}
+	int map;
+	u8 mode;
 
 	if (drive->type != ATA_DISK) {
 		cmdprintk("CMD64X: drive is not a disk at double check, inital check failed!!\n");
 		return 0;
 	}
 
-	/* UltraDMA only supported on PCI646U and PCI646U2,
-	 * which correspond to revisions 0x03, 0x05 and 0x07 respectively.
-	 * Actually, although the CMD tech support people won't
-	 * tell me the details, the 0x03 revision cannot support
-	 * UDMA correctly without hardware modifications, and even
-	 * then it only works with Quantum disks due to some
-	 * hold time assumptions in the 646U part which are fixed
-	 * in the 646U2.
-	 * So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
-	 */
-	if ((id->dma_ultra & 0x0020) && (udma_100) && (udma_66) && (udma_33)) {
-		speed = XFER_UDMA_5;
-	} else if ((id->dma_ultra & 0x0010) && (udma_66) && (udma_33)) {
-		speed = XFER_UDMA_4;
-	} else if ((id->dma_ultra & 0x0008) && (udma_66) && (udma_33)) {
-		speed = XFER_UDMA_3;
-	} else if ((id->dma_ultra & 0x0004) && (udma_33)) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0002) && (udma_33)) {
-		speed = XFER_UDMA_1;
-	} else if ((id->dma_ultra & 0x0001) && (udma_33)) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else if (id->dma_1word & 0x0004) {
-		speed = XFER_SW_DMA_2;
-	} else if (id->dma_1word & 0x0002) {
-		speed = XFER_SW_DMA_1;
-	} else if (id->dma_1word & 0x0001) {
-		speed = XFER_SW_DMA_0;
-	} else {
-		set_pio = 1;
-	}
-
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
-	config_chipset_for_pio(drive, set_pio);
+	if (udma)
+		map = cmd64x_ratemask(drive);
+	else
+		map = XFER_SWDMA | XFER_MWDMA;
 
-	if (set_pio)
-		return 0;
+	mode = ata_timing_mode(drive, map);
 
-	if (cmd64x_tune_chipset(drive, speed))
+	if (mode < XFER_SW_DMA_0) {
+		config_chipset_for_pio(drive, 1);
 		return 0;
-
-	rval = (int)(	((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
-
-	return rval;
-}
-
-static int config_cmd680_chipset_for_dma(struct ata_device *drive)
-{
-	struct hd_driveid *id	= drive->id;
-	byte udma_66		= eighty_ninty_three(drive);
-	byte speed		= 0x00;
-	byte set_pio		= 0x00;
-	int rval;
-
-	if ((id->dma_ultra & 0x0040) && (udma_66))	speed = XFER_UDMA_6;
-	else if ((id->dma_ultra & 0x0020) && (udma_66))	speed = XFER_UDMA_5;
-	else if ((id->dma_ultra & 0x0010) && (udma_66))	speed = XFER_UDMA_4;
-	else if ((id->dma_ultra & 0x0008) && (udma_66))	speed = XFER_UDMA_3;
-	else if (id->dma_ultra & 0x0004)		speed = XFER_UDMA_2;
-	else if (id->dma_ultra & 0x0002)		speed = XFER_UDMA_1;
-	else if (id->dma_ultra & 0x0001)		speed = XFER_UDMA_0;
-	else if (id->dma_mword & 0x0004)		speed = XFER_MW_DMA_2;
-	else if (id->dma_mword & 0x0002)		speed = XFER_MW_DMA_1;
-	else if (id->dma_mword & 0x0001)		speed = XFER_MW_DMA_0;
-	else {
-		set_pio = 1;
 	}
 
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
-	config_chipset_for_pio(drive, set_pio);
-
-	if (set_pio)
-		return 0;
-
-	if (cmd680_tune_chipset(drive, speed))
-		return 0;
-
-	rval = (int)(	((id->dma_ultra >> 14) & 3) ? 1 :
-			((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
-	return rval;
-}
-
-static int config_chipset_for_dma(struct ata_device *drive, unsigned int rev, byte ultra_66)
-{
-	if (drive->channel->pci_dev->device == PCI_DEVICE_ID_CMD_680)
-		return (config_cmd680_chipset_for_dma(drive));
-	return (config_cmd64x_chipset_for_dma(drive, rev, ultra_66));
+	config_chipset_for_pio(drive, 0);
+	return !drive->channel->speedproc(drive, mode);
 }
 
 static int cmd64x_config_drive_for_dma(struct ata_device *drive)
 {
 	struct hd_driveid *id	= drive->id;
 	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
-	unsigned int class_rev	= 0;
-	byte can_ultra_33	= 0;
-	byte can_ultra_66	= 0;
-	byte can_ultra_100	= 0;
-	byte can_ultra_133	= 0;
 	int on = 1;
 	int verbose = 1;
 
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-
-	switch(dev->device) {
-		case PCI_DEVICE_ID_CMD_680:
-			can_ultra_133 = 1;
-		case PCI_DEVICE_ID_CMD_649:
-			can_ultra_100 = 1;
-		case PCI_DEVICE_ID_CMD_648:
-			can_ultra_66  = 1;
-		case PCI_DEVICE_ID_CMD_643:
-			can_ultra_33  = 1;
-			break;
-		case PCI_DEVICE_ID_CMD_646:
-			can_ultra_33  = (class_rev >= 0x05) ? 1 : 0;
-			can_ultra_66  = 0;
-			can_ultra_100 = 0;
-			break;
-		default:
-			udma_enable(drive, 0, 1);
-
-			return 0;
-	}
-
 	if ((id != NULL) && ((id->capability & 1) != 0) &&
 	    hwif->autodma && (drive->type == ATA_DISK)) {
 		/* Consult the list of known "bad" drives */
@@ -795,10 +707,10 @@
 		}
 		on = 0;
 		verbose = 0;
-		if ((id->field_valid & 4) && (can_ultra_33)) {
+		if ((id->field_valid & 4)) {
 			if (id->dma_ultra & 0x007F) {
 				/* Force if Capable UltraDMA */
-				on = config_chipset_for_dma(drive, class_rev, can_ultra_66);
+				on = config_chipset_for_dma(drive, 1);
 				if ((id->field_valid & 2) &&
 				    (!on))
 					goto try_dma_modes;
@@ -808,7 +720,7 @@
 			if ((id->dma_mword & 0x0007) ||
 			    (id->dma_1word & 0x0007)) {
 				/* Force if Capable regular DMA modes */
-				on = config_chipset_for_dma(drive, class_rev, 0);
+				on = config_chipset_for_dma(drive, 0);
 				if (!on)
 					goto no_dma_set;
 			}
@@ -817,7 +729,7 @@
 				goto no_dma_set;
 			}
 			/* Consult the list of known "good" drives */
-			on = config_chipset_for_dma(drive, class_rev, 0);
+			on = config_chipset_for_dma(drive, 0);
 			if (!on)
 				goto no_dma_set;
 		} else {
@@ -1122,14 +1034,13 @@
 	hwif->drives[0].autotune = 1;
 	hwif->drives[1].autotune = 1;
 
-	if (!hwif->dma_base)
-		return;
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
 	switch(dev->device) {
 		case PCI_DEVICE_ID_CMD_680:
 			hwif->busproc	= cmd680_busproc;
-			hwif->XXX_udma	= cmd680_dmaproc;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+			if (hwif->dma_base)
+				hwif->XXX_udma	= cmd680_dmaproc;
+#endif
 			hwif->resetproc = cmd680_reset;
 			hwif->speedproc	= cmd680_tune_chipset;
 			hwif->tuneproc	= cmd680_tuneproc;
@@ -1137,22 +1048,30 @@
 		case PCI_DEVICE_ID_CMD_649:
 		case PCI_DEVICE_ID_CMD_648:
 		case PCI_DEVICE_ID_CMD_643:
-			hwif->udma_stop	= cmd64x_udma_stop;
-			hwif->udma_irq_status = cmd64x_udma_irq_status;
-			hwif->XXX_udma	= cmd64x_dmaproc;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+			if (hwif->dma_base) {
+				hwif->XXX_udma	= cmd64x_dmaproc;
+				hwif->udma_stop	= cmd64x_udma_stop;
+				hwif->udma_irq_status = cmd64x_udma_irq_status;
+			}
+#endif
 			hwif->tuneproc	= cmd64x_tuneproc;
 			hwif->speedproc = cmd64x_tune_chipset;
 			break;
 		case PCI_DEVICE_ID_CMD_646:
 			hwif->chipset = ide_cmd646;
-			if (class_rev == 0x01) {
-				hwif->udma_stop = cmd646_1_udma_stop;
-				hwif->XXX_udma = cmd646_1_dmaproc;
-			} else {
-				hwif->udma_stop = cmd64x_udma_stop;
-				hwif->udma_irq_status = cmd64x_udma_irq_status;
-				hwif->XXX_udma = cmd64x_dmaproc;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+			if (hwif->dma_base) {
+				if (class_rev == 0x01) {
+					hwif->XXX_udma = cmd646_1_dmaproc;
+					hwif->udma_stop = cmd646_1_udma_stop;
+				} else {
+					hwif->XXX_udma = cmd64x_dmaproc;
+					hwif->udma_stop = cmd64x_udma_stop;
+					hwif->udma_irq_status = cmd64x_udma_irq_status;
+				}
 			}
+#endif
 			hwif->tuneproc	= cmd64x_tuneproc;
 			hwif->speedproc	= cmd64x_tune_chipset;
 			break;
@@ -1160,7 +1079,14 @@
 			break;
 	}
 
-	hwif->highmem = 1;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+	if (hwif->dma_base) {
+		hwif->highmem = 1;
+# ifdef CONFIG_IDEDMA_AUTO
+		if (!noautodma)
+			hwif->autodma = 1;
+# endif
+	}
 #endif
 }
 
diff -Nru a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
--- a/drivers/ide/cs5530.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/cs5530.c	Fri May 24 18:55:36 2002
@@ -81,7 +81,7 @@
 /*
  * Set a new transfer mode at the drive
  */
-int cs5530_set_xfer_mode (ide_drive_t *drive, byte mode)
+int cs5530_set_xfer_mode(struct ata_device *drive, byte mode)
 {
 	int error = 0;
 
@@ -113,7 +113,7 @@
  * The ide_init_cs5530() routine guarantees that all drives
  * will have valid default PIO timings set up before we get here.
  */
-static void cs5530_tuneproc (ide_drive_t *drive, byte pio)	/* pio=255 means "autotune" */
+static void cs5530_tuneproc(struct ata_device *drive, byte pio)	/* pio=255 means "autotune" */
 {
 	struct ata_channel *hwif = drive->channel;
 	unsigned int	format, basereg = CS5530_BASEREG(hwif);
@@ -134,12 +134,12 @@
  * cs5530_config_dma() handles selection/setting of DMA/UDMA modes
  * for both the chipset and drive.
  */
-static int cs5530_config_dma (ide_drive_t *drive)
+static int cs5530_config_dma(struct ata_device *drive)
 {
 	int			udma_ok = 1, mode = 0;
 	struct ata_channel *hwif = drive->channel;
 	int			unit = drive->select.b.unit;
-	ide_drive_t		*mate = &hwif->drives[unit^1];
+	struct ata_device		*mate = &hwif->drives[unit^1];
 	struct hd_driveid	*id = drive->id;
 	unsigned int		basereg, reg, timings;
 
diff -Nru a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c
--- a/drivers/ide/cy82c693.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/cy82c693.c	Fri May 24 18:55:34 2002
@@ -121,7 +121,7 @@
 {
 	int clocks;
 
-	clocks = (time*bus_speed+999)/1000 -1;
+	clocks = (time*bus_speed+999999)/1000000 -1;
 
 	if (clocks < 0)
 		clocks = 0;
@@ -183,7 +183,7 @@
 /*
  * set DMA mode a specific channel for CY82C693
  */
-static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
+static void cy82c693_dma_enable(struct ata_device *drive, int mode, int single)
 {
         byte index;
 	byte data;
@@ -270,7 +270,7 @@
 /*
  * tune ide drive - set PIO mode
  */
-static void cy82c693_tune_drive (ide_drive_t *drive, byte pio)
+static void cy82c693_tune_drive(struct ata_device *drive, byte pio)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev = hwif->pci_dev;
diff -Nru a/drivers/ide/dtc2278.c b/drivers/ide/dtc2278.c
--- a/drivers/ide/dtc2278.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/dtc2278.c	Fri May 24 18:55:35 2002
@@ -66,7 +66,7 @@
 	}
 }
 
-static void tune_dtc2278 (ide_drive_t *drive, byte pio)
+static void tune_dtc2278(struct ata_device *drive, byte pio)
 {
 	unsigned long flags;
 
diff -Nru a/drivers/ide/hd.c b/drivers/ide/hd.c
--- a/drivers/ide/hd.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/hd.c	Fri May 24 18:55:33 2002
@@ -544,13 +544,17 @@
 {
 	unsigned int dev, block, nsect, sec, track, head, cyl;
 
-	if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE) return;
 	if (DEVICE_INTR)
 		return;
 repeat:
 	del_timer(&device_timer);
 	sti();
-	INIT_REQUEST;
+
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
+
 	if (reset) {
 		cli();
 		reset_hd();
diff -Nru a/drivers/ide/hpt34x.c b/drivers/ide/hpt34x.c
--- a/drivers/ide/hpt34x.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/hpt34x.c	Fri May 24 18:55:33 2002
@@ -94,9 +94,9 @@
 
 byte hpt34x_proc = 0;
 
-extern char *ide_xfer_verbose (byte xfer_rate);
+extern char *ide_xfer_verbose(byte xfer_rate);
 
-static void hpt34x_clear_chipset (ide_drive_t *drive)
+static void hpt34x_clear_chipset(struct ata_device *drive)
 {
 	unsigned int reg1	= 0, tmp1 = 0;
 	unsigned int reg2	= 0, tmp2 = 0;
@@ -109,9 +109,8 @@
 	pci_write_config_dword(drive->channel->pci_dev, 0x48, tmp2);
 }
 
-static int hpt34x_tune_chipset (ide_drive_t *drive, byte speed)
+static int hpt34x_tune_chipset(struct ata_device *drive, byte speed)
 {
-	int			err;
 	byte			hi_speed, lo_speed;
 	unsigned int reg1	= 0, tmp1 = 0;
 	unsigned int reg2	= 0, tmp2 = 0;
@@ -129,13 +128,9 @@
 	pci_read_config_dword(drive->channel->pci_dev, 0x48, &reg2);
 	tmp1 = ((lo_speed << (3*drive->dn)) | (reg1 & ~(7 << (3*drive->dn))));
 	tmp2 = ((hi_speed << drive->dn) | reg2);
-	err = ide_config_drive_speed(drive, speed);
 	pci_write_config_dword(drive->channel->pci_dev, 0x44, tmp1);
 	pci_write_config_dword(drive->channel->pci_dev, 0x48, tmp2);
 
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
 #if HPT343_DEBUG_DRIVE_INFO
 	printk("%s: %s drive%d (0x%04x 0x%04x) (0x%04x 0x%04x)" \
 		" (0x%02x 0x%02x) 0x%04x\n",
@@ -144,11 +139,13 @@
 		hi_speed, lo_speed, err);
 #endif /* HPT343_DEBUG_DRIVE_INFO */
 
+	if (!drive->init_speed)
+		drive->init_speed = speed;
 	drive->current_speed = speed;
-	return(err);
+	return ide_config_drive_speed(drive, speed);
 }
 
-static void config_chipset_for_pio(ide_drive_t *drive)
+static void config_chipset_for_pio(struct ata_device *drive)
 {
 	unsigned short eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
 	unsigned short xfer_pio = drive->id->eide_pio_modes;
@@ -185,7 +182,7 @@
 	(void) hpt34x_tune_chipset(drive, speed);
 }
 
-static void hpt34x_tune_drive (ide_drive_t *drive, byte pio)
+static void hpt34x_tune_drive(struct ata_device *drive, byte pio)
 {
 	byte speed;
 
@@ -201,55 +198,25 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-/*
- * This allows the configuration of ide_pci chipset registers
- * for cards that learn about the drive's UDMA, DMA, PIO capabilities
- * after the drive is reported by the OS.  Initally for designed for
- * HPT343 UDMA chipset by HighPoint|Triones Technologies, Inc.
- */
-static int config_chipset_for_dma (ide_drive_t *drive, byte ultra)
+static int config_chipset_for_dma(struct ata_device *drive, u8 udma)
 {
-	struct hd_driveid *id	= drive->id;
-	byte speed		= 0x00;
+	int map;
+	u8 mode;
 
 	if (drive->type != ATA_DISK)
 		return 0;
 
-	hpt34x_clear_chipset(drive);
+	if (udma)
+		map = XFER_UDMA;
+	else
+		map = XFER_SWDMA | XFER_MWDMA;
 
-	if ((id->dma_ultra & 0x0010) && ultra) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0008) && ultra) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0004) && ultra) {
-		speed = XFER_UDMA_2;
-	} else if ((id->dma_ultra & 0x0002) && ultra) {
-		speed = XFER_UDMA_1;
-	} else if ((id->dma_ultra & 0x0001) && ultra) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else if (id->dma_1word & 0x0004) {
-		speed = XFER_SW_DMA_2;
-	} else if (id->dma_1word & 0x0002) {
-		speed = XFER_SW_DMA_1;
-	} else if (id->dma_1word & 0x0001) {
-		speed = XFER_SW_DMA_0;
-        } else {
+	mode = ata_timing_mode(drive, map);
+	if (mode < XFER_SW_DMA_0)
 		return 0;
-	}
 
-	(void) hpt34x_tune_chipset(drive, speed);
-
-	return ((int)	((id->dma_ultra >> 11) & 3) ? 0 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
+	hpt34x_clear_chipset(drive);
+	return !hpt34x_tune_chipset(drive, mode);
 }
 
 static int config_drive_xfer_rate(struct ata_device *drive)
diff -Nru a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
--- a/drivers/ide/hpt366.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/hpt366.c	Fri May 24 18:55:33 2002
@@ -471,6 +471,8 @@
 #endif
 
 #define HPT366_DEBUG_DRIVE_INFO		0
+#define HPT374_ALLOW_ATA133_6		0
+#define HPT372_ALLOW_ATA133_6		1
 #define HPT370_ALLOW_ATA100_5		1
 #define HPT366_ALLOW_ATA66_4		1
 #define HPT366_ALLOW_ATA66_3		1
@@ -484,14 +486,9 @@
 static struct pci_dev *hpt_devs[HPT366_MAX_DEVS];
 static int n_hpt_devs;
 
-static unsigned int pci_rev_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev2_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev3_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev5_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev7_check_hpt3xx(struct pci_dev *dev);
-
 static u8 hpt366_proc = 0;
-extern char *ide_xfer_verbose(u8 xfer_rate);
+
+static unsigned int hpt_min_rev(struct pci_dev *dev, int rev);
 
 #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
 static int hpt366_get_info(char *, char **, off_t, int);
@@ -531,7 +528,7 @@
 			(c0 & 0x80) ? "no" : "yes",
 			(c1 & 0x80) ? "no" : "yes");
 
-		if (pci_rev3_check_hpt3xx(dev)) {
+		if (hpt_min_rev(dev, 3)) {
 			u8 cbl;
 			cbl = inb_p(iobase + 0x7b);
 			outb_p(cbl | 1, iobase + 0x7b);
@@ -580,50 +577,6 @@
 }
 #endif  /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */
 
-/*
- * fixme: it really needs to be a switch.
- */
-
-static unsigned int pci_rev_check_hpt3xx (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev > 0x02) ? 1 : 0);
-}
-
-static unsigned int pci_rev2_check_hpt3xx (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev > 0x01) ? 1 : 0);
-}
-
-static unsigned int pci_rev3_check_hpt3xx (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev > 0x02) ? 1 : 0);
-}
-
-static unsigned int pci_rev5_check_hpt3xx (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev > 0x04) ? 1 : 0);
-}
-
-static unsigned int pci_rev7_check_hpt3xx (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev > 0x06) ? 1 : 0);
-}
-
 static int check_in_drive_lists(struct ata_device *drive, const char **list)
 {
 	struct hd_driveid *id = drive->id;
@@ -644,6 +597,64 @@
 	return 0;
 }
 
+static unsigned int hpt_revision(struct pci_dev *dev)
+{
+	unsigned int class_rev;
+	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
+	class_rev &= 0xff;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_TTI_HPT374:
+			class_rev = PCI_DEVICE_ID_TTI_HPT374; break;
+		case PCI_DEVICE_ID_TTI_HPT372:
+			class_rev = PCI_DEVICE_ID_TTI_HPT372; break;
+		default:
+			break;
+	}
+	return class_rev;
+}
+
+static unsigned int hpt_min_rev(struct pci_dev *dev, int rev)
+{
+	return (hpt_revision(dev) >= rev) ? 1 : 0;
+}
+
+static int hpt3xx_ratemask(struct ata_device *drive)
+{
+	struct pci_dev *dev = drive->channel->pci_dev;
+	int map = XFER_UDMA;
+
+	if (hpt_min_rev(dev, 8)) {			/* HPT374 */
+		if (HPT374_ALLOW_ATA133_6)
+			map |= XFER_UDMA_133;
+		map |= (XFER_UDMA_100 | XFER_UDMA_66);
+	} else if (hpt_min_rev(dev, 5)) {		/* HPT372 */
+		if (HPT372_ALLOW_ATA133_6)
+			map |= XFER_UDMA_133;
+		map |= (XFER_UDMA_100 | XFER_UDMA_66);
+	} else if (hpt_min_rev(dev, 4)) {		/* HPT370A */
+		if (HPT370_ALLOW_ATA100_5)
+			map |= XFER_UDMA_100;
+		map |= XFER_UDMA_66;
+	} else if (hpt_min_rev(dev, 3)) {		/* HPT370 */
+		if (HPT370_ALLOW_ATA100_5)
+			map |= XFER_UDMA_100;
+		map |= XFER_UDMA_66;
+		if (check_in_drive_lists(drive, bad_ata33))
+			return 0;
+	} else {					/* HPT366 and HPT368 */
+		map |= XFER_UDMA_66;
+		if (check_in_drive_lists(drive, bad_ata33))
+			return 0;
+	}
+
+	if (!eighty_ninty_three(drive))
+		return XFER_UDMA;
+
+	return map;
+}
+
+
 static unsigned int pci_bus_clock_list(byte speed, struct chipset_bus_clock_list_entry * chipset_table)
 {
 	for ( ; chipset_table->xfer_speed ; chipset_table++)
@@ -772,19 +783,21 @@
 
 static int hpt3xx_tune_chipset(struct ata_device *drive, byte speed)
 {
+	struct pci_dev *dev = drive->channel->pci_dev;
+
 	if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
 		return -1;
 
 	if (!drive->init_speed)
 		drive->init_speed = speed;
 
-	if (pci_rev7_check_hpt3xx(drive->channel->pci_dev)) {
+	if (hpt_min_rev(dev, 7)) {
 		hpt374_tune_chipset(drive, speed);
-	} else if (pci_rev5_check_hpt3xx(drive->channel->pci_dev)) {
+	} else if (hpt_min_rev(dev, 5)) {
 		hpt372_tune_chipset(drive, speed);
-	} else if (pci_rev3_check_hpt3xx(drive->channel->pci_dev)) {
+	} else if (hpt_min_rev(dev, 3)) {
 		hpt370_tune_chipset(drive, speed);
-	} else if (pci_rev2_check_hpt3xx(drive->channel->pci_dev)) {
+	} else if (hpt_min_rev(dev, 2)) {
 		hpt368_tune_chipset(drive, speed);
 	} else {
                 hpt366_tune_chipset(drive, speed);
@@ -845,77 +858,57 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-/*
- * This allows the configuration of ide_pci chipset registers
- * for cards that learn about the drive's UDMA, DMA, PIO capabilities
- * after the drive is reported by the OS.  Initally for designed for
- * HPT366 UDMA chipset by HighPoint|Triones Technologies, Inc.
- *
- * check_in_drive_lists(drive, bad_ata66_4)
- * check_in_drive_lists(drive, bad_ata66_3)
- * check_in_drive_lists(drive, bad_ata33)
- *
- */
 static int config_chipset_for_dma(struct ata_device *drive)
 {
-	struct hd_driveid *id	= drive->id;
-	byte speed		= 0x00;
-	byte ultra66		= eighty_ninty_three(drive);
-	int  rval;
+	struct pci_dev *dev = drive->channel->pci_dev;
+	int map;
+	byte mode;
 
+	/* FIXME: remove this --bkz */
 	config_chipset_for_pio(drive);
-	drive->init_speed = 0;
 
-	if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
+	if (drive->type != ATA_DISK)
 		return 0;
 
-	if ((id->dma_ultra & 0x0040) &&
-	    (pci_rev5_check_hpt3xx(drive->channel->pci_dev)) &&
-	    (ultra66)) {
-		speed = XFER_UDMA_6;
-	} else if ((id->dma_ultra & 0x0020) &&
-	    (!check_in_drive_lists(drive, bad_ata100_5)) &&
-	    (HPT370_ALLOW_ATA100_5) &&
-	    (pci_rev_check_hpt3xx(drive->channel->pci_dev)) &&
-	    (pci_rev3_check_hpt3xx(drive->channel->pci_dev)) &&
-	    (ultra66)) {
-		speed = XFER_UDMA_5;
-	} else if ((id->dma_ultra & 0x0010) &&
-		   (!check_in_drive_lists(drive, bad_ata66_4)) &&
-		   (HPT366_ALLOW_ATA66_4) &&
-		   (ultra66)) {
-		speed = XFER_UDMA_4;
-	} else if ((id->dma_ultra & 0x0008) &&
-		   (!check_in_drive_lists(drive, bad_ata66_3)) &&
-		   (HPT366_ALLOW_ATA66_3) &&
-		   (ultra66)) {
-		speed = XFER_UDMA_3;
-	} else if (id->dma_ultra && (!check_in_drive_lists(drive, bad_ata33))) {
-		if (id->dma_ultra & 0x0004) {
-			speed = XFER_UDMA_2;
-		} else if (id->dma_ultra & 0x0002) {
-			speed = XFER_UDMA_1;
-		} else if (id->dma_ultra & 0x0001) {
-			speed = XFER_UDMA_0;
+	/* FIXME: check SWDMA modes --bkz */
+	map = hpt3xx_ratemask(drive) | XFER_MWDMA;
+	mode = ata_timing_mode(drive, map);
+
+	/* FIXME: badlists need futher investigation --bkz
+		  bad_ata100_5 is for HPT370/370A,
+		  bad_ata66_4, bad_ata66_3 and bad_ata33 are for HPT366/368
+	 */
+	if (mode == XFER_UDMA_5 && hpt_min_rev(dev, 5)) {
+		if (check_in_drive_lists(drive, bad_ata100_5)) {
+			/* FIXME: make XFER_UDMA_66/100/133
+				  independent of XFER_UDMA --bkz */
+			map &= ~XFER_UDMA_100;
+			map |= XFER_UDMA;
+			mode = ata_timing_mode(drive, map);
 		}
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else {
-		return 0;
 	}
+	if (mode == XFER_UDMA_4 && hpt_min_rev(dev, 3)) {
+		if (check_in_drive_lists(drive, bad_ata66_4)) {
+			if (drive->id->dma_ultra & 0x0008) {
+				mode = XFER_UDMA_3;
+			} else {
+				map &= ~XFER_UDMA_66;
+				map |= XFER_UDMA;
+				mode = ata_timing_mode(drive, map);
+			}
+		}
+	}
+	if (mode == XFER_UDMA_3 && hpt_min_rev(dev, 3)) {
+		if (check_in_drive_lists(drive, bad_ata66_3)) {
+			map &= ~XFER_UDMA_66;
+			map |= XFER_UDMA;
+			mode = ata_timing_mode(drive, map);
+		}
+	}
+	if (check_in_drive_lists(drive, bad_ata33) && hpt_min_rev(dev, 3))
+		mode = ata_timing_mode(drive, XFER_MWDMA);
 
-	(void) hpt3xx_tune_chipset(drive, speed);
-
-	rval = (int)(	((id->dma_ultra >> 14) & 3) ? 1 :
-			((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-						     0);
-	return rval;
+	return !hpt3xx_tune_chipset(drive, mode);
 }
 
 static int hpt3xx_quirkproc(struct ata_device *drive)
@@ -937,7 +930,7 @@
 	struct pci_dev *dev = drive->channel->pci_dev;
 
 	if (drive->quirk_list) {
-		if (pci_rev3_check_hpt3xx(dev)) {
+		if (hpt_min_rev(dev, 3)) {
 			byte reg5a = 0;
 			pci_read_config_byte(dev, 0x5a, &reg5a);
 			if (((reg5a & 0x10) >> 4) != mask)
@@ -1283,11 +1276,9 @@
 	freq &= 0x1FF;
 	if (freq < 0x9c) {
 		pll = F_LOW_PCI_33;
-		if (pci_rev7_check_hpt3xx(dev)) {
+		if (hpt_min_rev(dev, 7)) {
 			dev->sysdata = (void *) thirty_three_base_hpt374;
-		} else if (pci_rev5_check_hpt3xx(dev)) {
-			dev->sysdata = (void *) thirty_three_base_hpt372;
-		} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+		} else if (hpt_min_rev(dev, 5)) {
 			dev->sysdata = (void *) thirty_three_base_hpt372;
 		} else {
 			dev->sysdata = (void *) thirty_three_base_hpt370;
@@ -1297,12 +1288,10 @@
 		pll = F_LOW_PCI_40;
 	} else if (freq < 0xc8) {
 		pll = F_LOW_PCI_50;
-		if (pci_rev7_check_hpt3xx(dev)) {
+		if (hpt_min_rev(dev, 7)) {
 	//		dev->sysdata = (void *) fifty_base_hpt374;
 			BUG();
-		} else if (pci_rev5_check_hpt3xx(dev)) {
-			dev->sysdata = (void *) fifty_base_hpt372;
-		} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+		} else if (hpt_min_rev(dev, 5)) {
 			dev->sysdata = (void *) fifty_base_hpt372;
 		} else {
 			dev->sysdata = (void *) fifty_base_hpt370;
@@ -1310,12 +1299,10 @@
 		printk("HPT37X: using 50MHz PCI clock\n");
 	} else {
 		pll = F_LOW_PCI_66;
-		if (pci_rev7_check_hpt3xx(dev)) {
+		if (hpt_min_rev(dev, 7)) {
 	//		dev->sysdata = (void *) sixty_six_base_hpt374;
 			BUG();
-		} else if (pci_rev5_check_hpt3xx(dev)) {
-			dev->sysdata = (void *) sixty_six_base_hpt372;
-		} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+		} else if (hpt_min_rev(dev, 5)) {
 			dev->sysdata = (void *) sixty_six_base_hpt372;
 		} else {
 			dev->sysdata = (void *) sixty_six_base_hpt370;
@@ -1358,12 +1345,10 @@
 				pci_write_config_dword(dev, 0x5c,
 						       pll & ~0x100);
 				pci_write_config_byte(dev, 0x5b, 0x21);
-				if (pci_rev7_check_hpt3xx(dev)) {
+				if (hpt_min_rev(dev, 7)) {
 	//	dev->sysdata = (void *) fifty_base_hpt374;
 					BUG();
-				} else if (pci_rev5_check_hpt3xx(dev)) {
-					dev->sysdata = (void *) fifty_base_hpt372;
-				} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+				} else if (hpt_min_rev(dev, 5)) {
 					dev->sysdata = (void *) fifty_base_hpt372;
 				} else {
 					dev->sysdata = (void *) fifty_base_hpt370;
@@ -1437,7 +1422,7 @@
 	if (test != 0x08)
 		pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
 
-	if (pci_rev3_check_hpt3xx(dev))
+	if (hpt_min_rev(dev, 3))
 		hpt37x_init(dev);
 	else
 		hpt366_init(dev);
@@ -1471,6 +1456,8 @@
 
 static void __init hpt366_init_channel(struct ata_channel *ch)
 {
+	struct pci_dev *dev = ch->pci_dev;
+
 	ch->tuneproc = hpt3xx_tune_drive;
 	ch->speedproc = hpt3xx_tune_chipset;
 	ch->quirkproc = hpt3xx_quirkproc;
@@ -1485,11 +1472,11 @@
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (ch->dma_base) {
-		if (pci_rev3_check_hpt3xx(ch->pci_dev)) {
+		if (hpt_min_rev(dev, 3)) {
 			byte reg5ah = 0;
-			pci_read_config_byte(ch->pci_dev, 0x5a, &reg5ah);
+			pci_read_config_byte(dev, 0x5a, &reg5ah);
 			if (reg5ah & 0x10)	/* interrupt force enable */
-				pci_write_config_byte(ch->pci_dev, 0x5a, reg5ah & ~0x10);
+				pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10);
 			/*
 			 * set up ioctl for power status.
 			 * note: power affects both
@@ -1498,23 +1485,20 @@
 			ch->resetproc	= hpt3xx_reset;
 			ch->busproc	= hpt370_busproc;
 
-			if (pci_rev7_check_hpt3xx(ch->pci_dev)) {
-				ch->udma_stop = hpt374_udma_stop;
-				ch->XXX_udma = hpt374_dmaproc;
-			} else if (pci_rev5_check_hpt3xx(ch->pci_dev)) {
+			if (hpt_min_rev(dev, 7)) {
 				ch->udma_stop = hpt374_udma_stop;
 				ch->XXX_udma = hpt374_dmaproc;
-			} else if (ch->pci_dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+			} else if (hpt_min_rev(dev, 5)) {
 				ch->udma_stop = hpt374_udma_stop;
 				ch->XXX_udma = hpt374_dmaproc;
-			} else if (pci_rev3_check_hpt3xx(ch->pci_dev)) {
+			} else if (hpt_min_rev(dev, 3)) {
 			        ch->udma_start = hpt370_udma_start;
 				ch->udma_stop = hpt370_udma_stop;
 				ch->udma_timeout = hpt370_udma_timeout;
 				ch->udma_irq_lost = hpt370_udma_irq_lost;
 				ch->XXX_udma = hpt370_dmaproc;
 			}
-		} else if (pci_rev2_check_hpt3xx(ch->pci_dev)) {
+		} else if (hpt_min_rev(dev, 2)) {
 			ch->udma_irq_lost = hpt366_udma_irq_lost;
 //			ch->resetproc = hpt3xx_reset;
 //			ch->busproc = hpt3xx_tristate;
diff -Nru a/drivers/ide/hptraid.c b/drivers/ide/hptraid.c
--- a/drivers/ide/hptraid.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/hptraid.c	Fri May 24 18:55:35 2002
@@ -230,14 +230,14 @@
 {
 	unsigned long lba = 0;
 	kdev_t dev;
-	ide_drive_t *ideinfo;
-	
+	struct ata_device *ideinfo;
+
 	dev = mk_kdev(major,minor);
 	ideinfo = get_info_ptr (dev);
 	if (ideinfo==NULL)
 		return 0;
-	
-	
+
+
 	/* first sector of the last cluster */
 	if (ideinfo->head==0) 
 		return 0;
diff -Nru a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c
--- a/drivers/ide/ht6560b.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/ht6560b.c	Fri May 24 18:55:34 2002
@@ -120,7 +120,7 @@
 /*
  * This routine is invoked from ide.c to prepare for access to a given drive.
  */
-static void ht6560b_selectproc (ide_drive_t *drive)
+static void ht6560b_selectproc(struct ata_device *drive)
 {
 	unsigned long flags;
 	static byte current_select = 0;
@@ -195,7 +195,7 @@
 	return 1;
 }
 
-static byte ht_pio2timings(ide_drive_t *drive, byte pio)
+static byte ht_pio2timings(struct ata_device *drive, byte pio)
 {
 	int active_time, recovery_time;
 	int active_cycles, recovery_cycles;
@@ -219,8 +219,8 @@
 		/*
 		 *  Cycle times should be Vesa bus cycles
 		 */
-		active_cycles   = (active_time   * system_bus_speed + 999) / 1000;
-		recovery_cycles = (recovery_time * system_bus_speed + 999) / 1000;
+		active_cycles   = (active_time   * system_bus_speed + 999999) / 1000000;
+		recovery_cycles = (recovery_time * system_bus_speed + 999999) / 1000000;
 		/*
 		 *  Upper and lower limits
 		 */
@@ -248,7 +248,7 @@
 /*
  *  Enable/Disable so called prefetch mode
  */
-static void ht_set_prefetch(ide_drive_t *drive, byte state)
+static void ht_set_prefetch(struct ata_device *drive, byte state)
 {
 	unsigned long flags;
 	int t = HT_PREFETCH_MODE << 8;
@@ -275,7 +275,7 @@
 #endif
 }
 
-static void tune_ht6560b (ide_drive_t *drive, byte pio)
+static void tune_ht6560b(struct ata_device *drive, byte pio)
 {
 	unsigned long flags;
 	byte timing;
diff -Nru a/drivers/ide/icside.c b/drivers/ide/icside.c
--- a/drivers/ide/icside.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/icside.c	Fri May 24 18:55:33 2002
@@ -1,7 +1,7 @@
 /*
  * linux/drivers/ide/icside.c
  *
- * Copyright (c) 1996,1997 Russell King.
+ * Copyright (c) 1996-2002 Russell King.
  *
  * Changelog:
  *  08-Jun-1996	RMK	Created
@@ -25,6 +25,7 @@
 #include <asm/dma.h>
 #include <asm/ecard.h>
 #include <asm/io.h>
+#include <asm/page.h>
 
 extern char *ide_xfer_verbose (byte xfer_rate);
 
@@ -75,6 +76,12 @@
 	ICS_ARCIN_V6_IDESTEPPING
 };
 
+struct icside_state {
+	unsigned int channel;
+	unsigned int enabled;
+	unsigned int irq_port;
+};
+
 static const card_ids icside_cids[] = {
 	{ MANU_ICS,  PROD_ICS_IDE  },
 	{ MANU_ICS2, PROD_ICS2_IDE },
@@ -122,10 +129,21 @@
  */
 static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
 {
-	unsigned int ide_base_port = (unsigned int)ec->irq_data;
+	struct icside_state *state = ec->irq_data;
+	unsigned int base = state->irq_port;
+
+	state->enabled = 1;
 
-	outb (0, ide_base_port + ICS_ARCIN_V6_INTROFFSET_1);
-	outb (0, ide_base_port + ICS_ARCIN_V6_INTROFFSET_2);
+	switch (state->channel) {
+	case 0:
+		outb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
+		inb(base + ICS_ARCIN_V6_INTROFFSET_2);
+		break;
+	case 1:
+		outb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
+		inb(base + ICS_ARCIN_V6_INTROFFSET_1);
+		break;
+	}
 }
 
 /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
@@ -133,10 +151,12 @@
  */
 static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
 {
-	unsigned int ide_base_port = (unsigned int)ec->irq_data;
+	struct icside_state *state = ec->irq_data;
+
+	state->enabled = 0;
 
-	inb (ide_base_port + ICS_ARCIN_V6_INTROFFSET_1);
-	inb (ide_base_port + ICS_ARCIN_V6_INTROFFSET_2);
+	inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+	inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
 }
 
 /* Prototype: icside_irqprobe(struct expansion_card *ec)
@@ -144,10 +164,10 @@
  */
 static int icside_irqpending_arcin_v6(struct expansion_card *ec)
 {
-	unsigned int ide_base_port = (unsigned int)ec->irq_data;
+	struct icside_state *state = ec->irq_data;
 
-	return inb(ide_base_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
-	       inb(ide_base_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
+	return inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
+	       inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
 }
 
 static const expansioncard_ops_t icside_ops_arcin_v6 = {
@@ -210,6 +230,39 @@
 	return iftype;
 }
 
+/*
+ * Handle routing of interrupts.  This is called before
+ * we write the command to the drive.
+ */
+static void icside_maskproc(struct ata_device *drive, int mask)
+{
+	struct ata_channel *ch = drive->channel;
+	struct icside_state *state = ch->hw.priv;
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	state->channel = ch->unit;
+
+	if (state->enabled && !mask) {
+		switch (ch->unit) {
+		case 0:
+			outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+			inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+			break;
+		case 1:
+			outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+			inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+			break;
+		}
+	} else {
+		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+	}
+
+	local_irq_restore(flags);
+}
+
 #ifdef CONFIG_BLK_DEV_IDEDMA_ICS
 /*
  * SG-DMA support.
@@ -223,32 +276,42 @@
 #define NR_ENTRIES 256
 #define TABLE_SIZE (NR_ENTRIES * 8)
 
-static int ide_build_sglist(struct ata_channel *hwif, struct request *rq)
+static int ide_build_sglist(struct ata_channel *ch, struct request *rq)
 {
-	request_queue_t *q = &hwif->drives[DEVICE_NR(rq->rq_dev) & 1].queue;
-	struct scatterlist *sg = hwif->sg_table;
-	int nents = blk_rq_map_sg(q, rq, sg);
-
-	if (rq->q && nents > rq->nr_phys_segments)
-		printk("icside: received %d segments, build %d\n",
-			rq->nr_phys_segments, nents);
+	struct scatterlist *sg = ch->sg_table;
+	int nents;
 
-	if (rq_data_dir(rq) == READ)
-		hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
-	else
-		hwif->sg_dma_direction = PCI_DMA_TODEVICE;
+	if (rq->flags & REQ_DRIVE_ACB) {
+		struct ata_taskfile *args = rq->special;
 
-	return pci_map_sg(NULL, sg, nents, hwif->sg_dma_direction);
-}
+		if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
+			ch->sg_dma_direction = PCI_DMA_TODEVICE;
+		else
+			ch->sg_dma_direction = PCI_DMA_FROMDEVICE;
+
+		memset(sg, 0, sizeof(*sg));
+		sg->page   = virt_to_page(rq->buffer);
+		sg->offset = ((unsigned long)rq->buffer) & ~PAGE_MASK;
+		sg->length = rq->nr_sectors * SECTOR_SIZE;
+		nents = 1;
+	} else {
+		nents = blk_rq_map_sg(rq->q, rq, sg);
+
+		if (rq->q && nents > rq->nr_phys_segments)
+			printk("icside: received %d segments, build %d\n",
+				rq->nr_phys_segments, nents);
+
+		if (rq_data_dir(rq) == READ)
+			ch->sg_dma_direction = PCI_DMA_FROMDEVICE;
+		else
+			ch->sg_dma_direction = PCI_DMA_TODEVICE;
+	}
 
-static int
-icside_udma_new_table(struct ata_channel *ch, struct request *rq)
-{
-	return ch->sg_nents = ide_build_sglist(ch, rq);
+	return pci_map_sg(NULL, sg, nents, ch->sg_dma_direction);
 }
 
 /* Teardown mappings after DMA has completed.  */
-static void icside_destroy_dmatable(ide_drive_t *drive)
+static void icside_destroy_dmatable(struct ata_device *drive)
 {
 	struct scatterlist *sg = drive->channel->sg_table;
 	int nents = drive->channel->sg_nents;
@@ -282,10 +345,9 @@
  *	MW2	70	25	25	120	C
  */
 static int
-icside_config_if(ide_drive_t *drive, int xfer_mode)
+icside_config_if(struct ata_device *drive, int xfer_mode)
 {
-	int func = ide_dma_off;
-	int cycle_time = 0, use_dma_info = 0;
+	int on = 0, cycle_time = 0, use_dma_info = 0;
 
 	switch (xfer_mode) {
 	case XFER_MW_DMA_2: cycle_time = 250; use_dma_info = 1;	break;
@@ -306,7 +368,7 @@
 		drive->init_speed = xfer_mode;
 
 	if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0)
-		func = ide_dma_on;
+		on = 1;
 	else
 		drive->drive_data = 480;
 
@@ -315,50 +377,45 @@
 
 	drive->current_speed = xfer_mode;
 
-	return func;
+	return on;
 }
 
-static int
-icside_set_speed(ide_drive_t *drive, byte speed)
+static int icside_set_speed(struct ata_device *drive, byte speed)
 {
 	return icside_config_if(drive, speed);
 }
 
-/*
- * dma_intr() is the handler for disk read/write DMA interrupts
- */
-static ide_startstop_t icside_dmaintr(struct ata_device *drive, struct request *rq)
+static void icside_dma_enable(struct ata_device *drive, int on, int verbose)
 {
-	int i;
-	byte stat, dma_stat;
-
-	dma_stat = drive->channel->udma(ide_dma_end, drive, rq);
-	stat = GET_STAT();			/* get drive status */
-	if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
-		if (!dma_stat) {
-			for (i = rq->nr_sectors; i > 0;) {
-				i -= rq->current_nr_sectors;
-				ide_end_request(drive, 1);
-			}
-			return ide_stopped;
-		}
-		printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
-		       drive->name, dma_stat);
+	if (!on) {
+		if (verbose)
+			printk("%s: DMA disabled\n", drive->name);
+#ifdef CONFIG_BLK_DEV_IDE_TCQ
+		udma_tcq_enable(drive, 0);
+#endif
 	}
-	return ide_error(drive, "dma_intr", stat);
-}
+	
+	/*
+	 * We don't need any bouncing.  Yes, this looks the
+	 * wrong way around, but it is correct.
+	 */
+	blk_queue_bounce_limit(&drive->queue, BLK_BOUNCE_ANY);
+	drive->using_dma = on;
 
+#ifdef CONFIG_CLK_DEV_IDE_TCQ_DEFAULT
+	if (on)
+		udma_tcq_enable(drive, 1);
+#endif
+}
 
-static int
-icside_dma_check(struct ata_device *drive, struct request *rq)
+static int icside_dma_check(struct ata_device *drive)
 {
 	struct hd_driveid *id = drive->id;
-	struct ata_channel *hwif = drive->channel;
-	int autodma = hwif->autodma;
+	struct ata_channel *ch = drive->channel;
 	int xfer_mode = XFER_PIO_2;
-	int func = ide_dma_off_quietly;
+	int on;
 
-	if (!id || !(id->capability & 1) || !autodma)
+	if (!id || !(id->capability & 1) || !ch->autodma)
 		goto out;
 
 	/*
@@ -367,188 +424,284 @@
 	if (id->field_valid & 2) {
 		if (id->dma_mword & 4) {
 			xfer_mode = XFER_MW_DMA_2;
-			func = ide_dma_on;
 		} else if (id->dma_mword & 2) {
 			xfer_mode = XFER_MW_DMA_1;
-			func = ide_dma_on;
 		} else if (id->dma_mword & 1) {
 			xfer_mode = XFER_MW_DMA_0;
-			func = ide_dma_on;
 		}
-		goto out;
 	}
 
 out:
-	func = icside_config_if(drive, xfer_mode);
+	on = icside_config_if(drive, xfer_mode);
+
+	icside_dma_enable(drive, on, 0);
+
+	return 0;
+}
+
+static int icside_dma_stop(struct ata_device *drive)
+{
+	struct ata_channel *ch = drive->channel;
+
+	drive->waiting_for_dma = 0;
+	disable_dma(ch->hw.dma);
+	icside_destroy_dmatable(drive);
+
+	return get_dma_residue(ch->hw.dma) != 0;
+}
+
+static int icside_dma_start(struct ata_device *drive, struct request *rq)
+{
+	struct ata_channel *ch = drive->channel;
+
+	/*
+	 * We can not enable DMA on both channels.
+	 */
+	BUG_ON(dma_channel_active(ch->hw.dma));
+
+	enable_dma(ch->hw.dma);
+
+	return 0;
+}
+
+/*
+ * dma_intr() is the handler for disk read/write DMA interrupts
+ */
+static ide_startstop_t icside_dmaintr(struct ata_device *drive, struct request *rq)
+{
+	int dma_stat;
+	byte stat;
+
+	dma_stat = icside_dma_stop(drive);
 
-	return hwif->udma(func, drive, rq);
+	stat = GET_STAT();			/* get drive status */
+	if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
+		if (!dma_stat) {
+			__ide_end_request(drive, rq, 1, rq->nr_sectors);
+			return ide_stopped;
+		}
+		printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
+		       drive->name, dma_stat);
+	}
+	return ide_error(drive, rq, "dma_intr", stat);
 }
 
 static int
-icside_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
+icside_dma_common(struct ata_device *drive, struct request *rq,
+		  unsigned int dma_mode)
+{
+	struct ata_channel *ch = drive->channel;
+	unsigned int count;
+
+	/*
+	 * We can not enable DMA on both channels.
+	 */
+	BUG_ON(dma_channel_active(ch->hw.dma));
+
+	count = ch->sg_nents = ide_build_sglist(ch, rq);
+	if (!count)
+		return 1;
+
+	/*
+	 * Route the DMA signals to to this channel.
+	 */
+	outb(ch->select_data, ch->config_data);
+
+	/*
+	 * Select the correct timing for this drive.
+	 */
+	set_dma_speed(ch->hw.dma, drive->drive_data);
+
+	/*
+	 * Tell the DMA engine about the SG table and
+	 * data direction.
+	 */
+	set_dma_sg(ch->hw.dma, ch->sg_table, count);
+	set_dma_mode(ch->hw.dma, dma_mode);
+
+	drive->waiting_for_dma = 1;
+
+	return 0;
+}
+
+static int icside_dma_read(struct ata_device *drive, struct request *rq)
 {
-	struct ata_channel *hwif = drive->channel;
-	int count, reading = 0;
+	struct ata_channel *ch = drive->channel;
+	unsigned int cmd;
 
-	switch (func) {
-	case ide_dma_off:
-		printk("%s: DMA disabled\n", drive->name);
-		/*FALLTHROUGH*/
-
-	case ide_dma_off_quietly:
-	case ide_dma_on:
-		/*
-		 * We don't need any bouncing.  Yes, this looks the
-		 * wrong way around, but it is correct.
-		 */
-		blk_queue_bounce_limit(&drive->queue, BLK_BOUNCE_ANY);
-		drive->using_dma = (func == ide_dma_on);
+	if (icside_dma_common(drive, rq, DMA_MODE_READ))
+		return 1;
+
+	if (drive->type != ATA_DISK)
 		return 0;
 
-	case ide_dma_check:
-		return icside_dma_check(drive, rq);
+	ide_set_handler(drive, icside_dmaintr, WAIT_CMD, NULL);
+
+	if ((rq->flags & REQ_DRIVE_ACB) && drive->addressing == 1) {
+		struct ata_taskfile *args = rq->special;
+		cmd = args->taskfile.command;
+	} else if (drive->addressing) {
+		cmd = WIN_READDMA_EXT;
+	} else {
+		cmd = WIN_READDMA;
+	}
 
-	case ide_dma_read:
-		reading = 1;
-	case ide_dma_write:
-		count = icside_udma_new_table(hwif, rq);
-		if (!count)
-			return 1;
-		disable_dma(hwif->hw.dma);
-
-		/* Route the DMA signals to
-		 * to the correct interface.
-		 */
-		outb(hwif->select_data, hwif->config_data);
-
-		/* Select the correct timing
-		 * for this drive
-		 */
-		set_dma_speed(hwif->hw.dma, drive->drive_data);
-
-		set_dma_sg(hwif->hw.dma, drive->channel->sg_table, count);
-		set_dma_mode(hwif->hw.dma, reading ? DMA_MODE_READ
-			     : DMA_MODE_WRITE);
-
-		drive->waiting_for_dma = 1;
-		if (drive->type != ATA_DISK)
-			return 0;
-
-		ide_set_handler(drive, icside_dmaintr, WAIT_CMD, NULL);
-		OUT_BYTE(reading ? WIN_READDMA : WIN_WRITEDMA,
-			 IDE_COMMAND_REG);
+	OUT_BYTE(cmd, IDE_COMMAND_REG);
+	enable_dma(ch->hw.dma);
+	return 0;
+}
 
-	case ide_dma_begin:
-		enable_dma(hwif->hw.dma);
+static int icside_dma_write(struct ata_device *drive, struct request *rq)
+{
+	struct ata_channel *ch = drive->channel;
+	unsigned int cmd;
+
+	if (icside_dma_common(drive, rq, DMA_MODE_WRITE))
+		return 1;
+
+	if (drive->type != ATA_DISK)
 		return 0;
 
-	case ide_dma_end:
-		drive->waiting_for_dma = 0;
-		disable_dma(hwif->hw.dma);
-		icside_destroy_dmatable(drive);
-		return get_dma_residue(hwif->hw.dma) != 0;
-
-	case ide_dma_test_irq:
-		return inb((unsigned long)hwif->hw.priv) & 1;
-
-	case ide_dma_timeout:
-	default:
-		printk("icside_dmaproc: unsupported function: %d\n", func);
+	ide_set_handler(drive, icside_dmaintr, WAIT_CMD, NULL);
+
+	if ((rq->flags & REQ_DRIVE_ACB) && drive->addressing == 1) {
+		struct ata_taskfile *args = rq->special;
+		cmd = args->taskfile.command;
+	} else if (drive->addressing) {
+		cmd = WIN_WRITEDMA_EXT;
+	} else {
+		cmd = WIN_WRITEDMA;
 	}
-	return 1;
+	OUT_BYTE(cmd, IDE_COMMAND_REG);
+
+	enable_dma(ch->hw.dma);
+	return 0;
 }
 
-static int
-icside_setup_dma(struct ata_channel *hwif, int autodma)
+static int icside_irq_status(struct ata_device *drive)
+{
+	struct ata_channel *ch = drive->channel;
+	struct icside_state *state = ch->hw.priv;
+
+	return inb(state->irq_port +
+		   (ch->unit ?
+			ICS_ARCIN_V6_INTRSTAT_2 :
+			ICS_ARCIN_V6_INTRSTAT_1)) & 1;
+}
+
+static void icside_dma_timeout(struct ata_device *drive)
+{
+	printk(KERN_ERR "ATA: %s: UDMA timeout occured:", drive->name);
+	ide_dump_status(drive, NULL, "UDMA timeout", GET_STAT());
+}
+
+static void icside_irq_lost(struct ata_device *drive)
 {
-	printk("    %s: SG-DMA", hwif->name);
+	printk(KERN_ERR "ATA: %s: IRQ lost\n", drive->name);
+}
 
-	hwif->sg_table = kmalloc(sizeof(struct scatterlist) * NR_ENTRIES,
+static int icside_setup_dma(struct ata_channel *ch)
+{
+	int autodma = 0;
+
+#ifdef CONFIG_IDEDMA_ICS_AUTO
+	autodma = 1;
+#endif
+
+	printk("    %s: SG-DMA", ch->name);
+
+	ch->sg_table = kmalloc(sizeof(struct scatterlist) * NR_ENTRIES,
 				 GFP_KERNEL);
-	if (!hwif->sg_table)
+	if (!ch->sg_table)
 		goto failed;
 
-	hwif->dmatable_cpu = NULL;
-	hwif->dmatable_dma = 0;
-	hwif->speedproc = icside_set_speed;
-	hwif->dmaproc = icside_dmaproc;
-	hwif->autodma = autodma;
+	ch->dmatable_cpu    = NULL;
+	ch->dmatable_dma    = 0;
+	ch->speedproc       = icside_set_speed;
+	ch->XXX_udma        = icside_dma_check;
+	ch->udma_enable     = icside_dma_enable;
+	ch->udma_start      = icside_dma_start;
+	ch->udma_stop       = icside_dma_stop;
+	ch->udma_read       = icside_dma_read;
+	ch->udma_write      = icside_dma_write;
+	ch->udma_irq_status = icside_irq_status;
+	ch->udma_timeout    = icside_dma_timeout;
+	ch->udma_irq_lost   = icside_irq_lost;
+	ch->autodma         = autodma;
 
-	printk(" capable%s\n", autodma ?
-		", auto-enable" : "");
+	printk(" capable%s\n", autodma ? ", auto-enable" : "");
 
 	return 1;
 
 failed:
-	printk(" -- ERROR, unable to allocate DMA table\n");
+	printk(" disabled, unable to allocate DMA table\n");
 	return 0;
 }
 
-void ide_release_dma(struct ata_channel *hwif)
+void ide_release_dma(struct ata_channel *ch)
 {
-	if (hwif->sg_table) {
-		kfree(hwif->sg_table);
-		hwif->sg_table = NULL;
+	if (ch->sg_table) {
+		kfree(ch->sg_table);
+		ch->sg_table = NULL;
 	}
 }
 #endif
 
-static struct ata_channel *
-icside_find_hwif(unsigned long dataport)
+static struct ata_channel *icside_find_hwif(unsigned long dataport)
 {
-	struct ata_channel *hwif;
+	struct ata_channel *ch;
 	int index;
 
 	for (index = 0; index < MAX_HWIFS; ++index) {
-		hwif = &ide_hwifs[index];
-		if (hwif->io_ports[IDE_DATA_OFFSET] == (ide_ioreg_t)dataport)
+		ch = &ide_hwifs[index];
+		if (ch->io_ports[IDE_DATA_OFFSET] == (ide_ioreg_t)dataport)
 			goto found;
 	}
 
 	for (index = 0; index < MAX_HWIFS; ++index) {
-		hwif = &ide_hwifs[index];
-		if (!hwif->io_ports[IDE_DATA_OFFSET])
+		ch = &ide_hwifs[index];
+		if (!ch->io_ports[IDE_DATA_OFFSET])
 			goto found;
 	}
 
 	return NULL;
 found:
-	return hwif;
+	return ch;
 }
 
 static struct ata_channel *
 icside_setup(unsigned long base, struct cardinfo *info, int irq)
 {
 	unsigned long port = base + info->dataoffset;
-	struct ata_channel *hwif;
+	struct ata_channel *ch;
 
-	hwif = icside_find_hwif(base);
-	if (hwif) {
+	ch = icside_find_hwif(base);
+	if (ch) {
 		int i;
 
-		memset(&hwif->hw, 0, sizeof(hw_regs_t));
+		memset(&ch->hw, 0, sizeof(hw_regs_t));
 
 		for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-			hwif->hw.io_ports[i] = (ide_ioreg_t)port;
-			hwif->io_ports[i] = (ide_ioreg_t)port;
+			ch->hw.io_ports[i] = (ide_ioreg_t)port;
+			ch->io_ports[i] = (ide_ioreg_t)port;
 			port += 1 << info->stepping;
 		}
-		hwif->hw.io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
-		hwif->io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
-		hwif->hw.irq  = irq;
-		hwif->irq     = irq;
-		hwif->hw.dma  = NO_DMA;
-		hwif->noprobe = 0;
-		hwif->chipset = ide_acorn;
+		ch->hw.io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
+		ch->io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
+		ch->hw.irq  = irq;
+		ch->irq     = irq;
+		ch->hw.dma  = NO_DMA;
+		ch->noprobe = 0;
+		ch->chipset = ide_acorn;
 	}
 
-	return hwif;
+	return ch;
 }
 
-static int __init icside_register_v5(struct expansion_card *ec, int autodma)
+static int __init icside_register_v5(struct expansion_card *ec)
 {
 	unsigned long slot_port;
-	struct ata_channel *hwif;
+	struct ata_channel *ch;
 
 	slot_port = ecard_address(ec, ECARD_MEMC, 0);
 
@@ -562,17 +715,17 @@
 	 */
 	inb(slot_port + ICS_ARCIN_V5_INTROFFSET);
 
-	hwif = icside_setup(slot_port, &icside_cardinfo_v5, ec->irq);
+	ch = icside_setup(slot_port, &icside_cardinfo_v5, ec->irq);
 
-	return hwif ? 0 : -1;
+	return ch ? 0 : -1;
 }
 
-static int __init icside_register_v6(struct expansion_card *ec, int autodma)
+static int __init icside_register_v6(struct expansion_card *ec)
 {
 	unsigned long slot_port, port;
-	struct ata_channel *hwif;
-	struct ata_channel *mate;
-	int sel = 0;
+	struct icside_state *state;
+	struct ata_channel *ch0, *ch1;
+	unsigned int sel = 0;
 
 	slot_port = ecard_address(ec, ECARD_IOC, ECARD_FAST);
 	port      = ecard_address(ec, ECARD_EASI, ECARD_FAST);
@@ -584,55 +737,57 @@
 
 	outb(sel, slot_port);
 
-	ec->irq_data = (void *)port;
-	ec->ops      = (expansioncard_ops_t *)&icside_ops_arcin_v6;
-
 	/*
 	 * Be on the safe side - disable interrupts
 	 */
 	inb(port + ICS_ARCIN_V6_INTROFFSET_1);
 	inb(port + ICS_ARCIN_V6_INTROFFSET_2);
 
-	hwif = icside_setup(port, &icside_cardinfo_v6_1, ec->irq);
-	mate = icside_setup(port, &icside_cardinfo_v6_2, ec->irq);
+	/*
+	 * Find and register the interfaces.
+	 */
+	ch0 = icside_setup(port, &icside_cardinfo_v6_1, ec->irq);
+	ch1 = icside_setup(port, &icside_cardinfo_v6_2, ec->irq);
+
+	if (!ch0 || !ch1)
+		return -ENODEV;
+
+	state = kmalloc(sizeof(struct icside_state), GFP_KERNEL);
+	if (!state)
+		return -ENOMEM;
+
+	state->channel    = 0;
+	state->enabled    = 0;
+	state->irq_port   = port;
+
+	ec->irq_data      = state;
+	ec->ops           = (expansioncard_ops_t *)&icside_ops_arcin_v6;
+
+	ch0->maskproc     = icside_maskproc;
+	ch0->unit         = 0;
+	ch0->hw.priv      = state;
+	ch0->config_data  = slot_port;
+	ch0->select_data  = sel;
+	ch0->hw.dma       = ec->dma;
+
+	ch1->maskproc     = icside_maskproc;
+	ch1->unit         = 1;
+	ch1->hw.priv      = state;
+	ch1->config_data  = slot_port;
+	ch1->select_data  = sel | 1;
+	ch1->hw.dma       = ec->dma;
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_ICS
-	if (ec->dma != NO_DMA) {
-		if (request_dma(ec->dma, hwif->name))
-			goto no_dma;
-
-		if (hwif) {
-			hwif->config_data = slot_port;
-			hwif->select_data = sel;
-			hwif->hw.dma  = ec->dma;
-			hwif->hw.priv = (void *)
-					(port + ICS_ARCIN_V6_INTRSTAT_1);
-			hwif->unit = 0;
-			icside_setup_dma(hwif, autodma);
-		}
-		if (mate) {
-			mate->config_data = slot_port;
-			mate->select_data = sel | 1;
-			mate->hw.dma  = ec->dma;
-			mate->hw.priv = (void *)
-					(port + ICS_ARCIN_V6_INTRSTAT_2);
-			mate->unit = 1;
-			icside_setup_dma(mate, autodma);
-		}
+	if (ec->dma != NO_DMA && !request_dma(ec->dma, ch0->name)) {
+		icside_setup_dma(ch0);
+		icside_setup_dma(ch1);
 	}
-no_dma:
 #endif
-	return hwif || mate ? 0 : -1;
+	return 0;
 }
 
 int __init icside_init(void)
 {
-	int autodma = 0;
-
-#ifdef CONFIG_IDEDMA_ICS_AUTO
-	autodma = 1;
-#endif
-
 	ecard_startfind ();
 
 	do {
@@ -647,11 +802,11 @@
 
 		switch (icside_identifyif(ec)) {
 		case ics_if_arcin_v5:
-			result = icside_register_v5(ec, autodma);
+			result = icside_register_v5(ec);
 			break;
 
 		case ics_if_arcin_v6:
-			result = icside_register_v6(ec, autodma);
+			result = icside_register_v6(ec);
 			break;
 
 		default:
diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/ide-cd.c	Fri May 24 18:55:35 2002
@@ -322,7 +322,7 @@
 
 /* Mark that we've seen a media change, and invalidate our internal
    buffers. */
-static void cdrom_saw_media_change (ide_drive_t *drive)
+static void cdrom_saw_media_change(struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 
@@ -331,8 +331,7 @@
 	info->nsectors_buffered = 0;
 }
 
-static
-void cdrom_analyze_sense_data(ide_drive_t *drive, struct request *rq)
+static void cdrom_analyze_sense_data(struct ata_device *drive, struct request *rq)
 {
 	int log = 0;
 	/* FIXME --mdcki */
@@ -516,7 +515,7 @@
 #endif
 }
 
-static void cdrom_queue_request_sense(ide_drive_t *drive,
+static void cdrom_queue_request_sense(struct ata_device *drive,
 				      struct completion *wait,
 				      struct request_sense *sense,
 				      struct packet_command *failed_command)
@@ -813,7 +812,7 @@
  * sector added, SECTOR is its sector number.  (SECTOR is then ignored until
  * the buffer is cleared.)
  */
-static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
+static void cdrom_buffer_sectors(struct ata_device *drive, unsigned long sector,
                                   int sectors_to_transfer)
 {
 	struct cdrom_info *info = drive->driver_data;
@@ -1381,7 +1380,7 @@
 }
 
 static
-int cdrom_queue_packet_command(ide_drive_t *drive, unsigned char *cmd,
+int cdrom_queue_packet_command(struct ata_device *drive, unsigned char *cmd,
 		struct request_sense *sense, struct packet_command *pc)
 {
 	struct request rq;
@@ -1728,7 +1727,7 @@
 	return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
 }
 
-static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
+static int cdrom_check_status(struct ata_device *drive, struct request_sense *sense)
 {
 	unsigned char cmd[CDROM_PACKET_SIZE];
 	struct packet_command pc;
@@ -1753,7 +1752,7 @@
 
 /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */
 static int
-cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense)
+cdrom_lockdoor(struct ata_device *drive, int lockflag, struct request_sense *sense)
 {
 	struct packet_command pc;
 	int stat;
@@ -1795,7 +1794,7 @@
 
 /* Eject the disk if EJECTFLAG is 0.
    If EJECTFLAG is 1, try to reload the disk. */
-static int cdrom_eject(ide_drive_t *drive, int ejectflag,
+static int cdrom_eject(struct ata_device *drive, int ejectflag,
 		       struct request_sense *sense)
 {
 	struct packet_command pc;
@@ -1816,7 +1815,7 @@
 	return cdrom_queue_packet_command(drive, cmd, sense, &pc);
 }
 
-static int cdrom_read_capacity(ide_drive_t *drive, u32 *capacity,
+static int cdrom_read_capacity(struct ata_device *drive, u32 *capacity,
 			       struct request_sense *sense)
 {
 	struct {
@@ -1841,7 +1840,7 @@
 	return stat;
 }
 
-static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
+static int cdrom_read_tocentry(struct ata_device *drive, int trackno, int msf_flag,
 				int format, char *buf, int buflen,
 				struct request_sense *sense)
 {
@@ -1868,7 +1867,7 @@
 
 
 /* Try to read the entire TOC for the disk into our internal buffer. */
-static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
+static int cdrom_read_toc(struct ata_device *drive, struct request_sense *sense)
 {
 	int minor, stat, ntracks, i;
 	kdev_t dev;
@@ -2023,7 +2022,7 @@
 }
 
 
-static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
+static int cdrom_read_subchannel(struct ata_device *drive, int format, char *buf,
 				 int buflen, struct request_sense *sense)
 {
 	unsigned char cmd[CDROM_PACKET_SIZE];
@@ -2046,7 +2045,7 @@
 
 /* ATAPI cdrom drives are free to select the speed you request or any slower
    rate :-( Requesting too fast a speed will _not_ produce an error. */
-static int cdrom_select_speed(ide_drive_t *drive, int speed,
+static int cdrom_select_speed(struct ata_device *drive, int speed,
 			      struct request_sense *sense)
 {
 	unsigned char cmd[CDROM_PACKET_SIZE];
@@ -2076,7 +2075,7 @@
 	return cdrom_queue_packet_command(drive, cmd, sense, &pc);
 }
 
-static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end)
+static int cdrom_play_audio(struct ata_device *drive, int lba_start, int lba_end)
 {
 	struct request_sense sense;
 	unsigned char cmd[CDROM_PACKET_SIZE];
@@ -2092,7 +2091,7 @@
 	return cdrom_queue_packet_command(drive, cmd, &sense, &pc);
 }
 
-static int cdrom_get_toc_entry(ide_drive_t *drive, int track,
+static int cdrom_get_toc_entry(struct ata_device *drive, int track,
 				struct atapi_toc_entry **ent)
 {
 	struct cdrom_info *info = drive->driver_data;
@@ -2124,7 +2123,7 @@
 			    struct cdrom_generic_command *cgc)
 {
 	struct packet_command pc;
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 
 	if (cgc->timeout <= 0)
 		cgc->timeout = WAIT_CMD;
@@ -2196,7 +2195,7 @@
 int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
 			   unsigned int cmd, void *arg)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct cdrom_info *info = drive->driver_data;
 	int stat;
 
@@ -2272,7 +2271,7 @@
 static
 int ide_cdrom_reset (struct cdrom_device_info *cdi)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct request_sense sense;
 	struct request req;
 	int ret;
@@ -2295,7 +2294,7 @@
 static
 int ide_cdrom_tray_move(struct cdrom_device_info *cdi, int position)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct request_sense sense;
 
 	if (position) {
@@ -2310,7 +2309,7 @@
 static
 int ide_cdrom_lock_door(struct cdrom_device_info *cdi, int lock)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct request_sense sense;
 
 	return cdrom_lockdoor(drive, lock, &sense);
@@ -2319,7 +2318,7 @@
 static
 int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct request_sense sense;
 	int stat;
 
@@ -2333,7 +2332,7 @@
 static
 int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 
 	if (slot_nr == CDSL_CURRENT) {
 		struct request_sense sense;
@@ -2368,7 +2367,7 @@
 				struct cdrom_multisession *ms_info)
 {
 	struct atapi_toc *toc;
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	struct cdrom_info *info = drive->driver_data;
 	struct request_sense sense;
 	int ret;
@@ -2390,7 +2389,7 @@
 {
 	int stat;
 	char mcnbuf[24];
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 
 /* get MCN */
 	if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL)))
@@ -2414,7 +2413,7 @@
 int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi,
 				       int slot_nr)
 {
-	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct ata_device *drive = (struct ata_device *) cdi->handle;
 	int retval;
 
 	if (slot_nr == CDSL_CURRENT) {
@@ -2472,7 +2471,7 @@
 	generic_packet:		ide_cdrom_packet,
 };
 
-static int ide_cdrom_register (ide_drive_t *drive, int nslots)
+static int ide_cdrom_register(struct ata_device *drive, int nslots)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *devinfo = &info->devinfo;
@@ -2518,7 +2517,7 @@
 }
 
 static
-int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap)
+int ide_cdrom_get_capabilities(struct ata_device *drive, struct atapi_capabilities_page *cap)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *cdi = &info->devinfo;
@@ -2541,7 +2540,7 @@
 	 * registered with the Uniform layer yet, it can't do this.
 	 * Same goes for cdi->ops.
 	 */
-	cdi->handle = (ide_drive_t *) drive;
+	cdi->handle = (struct ata_device *) drive;
 	cdi->ops = &ide_cdrom_dops;
 	init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN);
 	do { /* we seem to get stat=0x01,err=0x00 the first time (??) */
@@ -2553,7 +2552,7 @@
 }
 
 static
-int ide_cdrom_probe_capabilities (ide_drive_t *drive)
+int ide_cdrom_probe_capabilities(struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *cdi = &info->devinfo;
@@ -2659,8 +2658,48 @@
 	return nslots;
 }
 
-static
-int ide_cdrom_setup(ide_drive_t *drive)
+
+/*
+ * standard prep_rq_fn that builds 10 byte cmds
+ */
+static int ll_10byte_cmd_build(request_queue_t *q, struct request *rq)
+{
+	int hard_sect = queue_hardsect_size(q);
+	sector_t block = rq->hard_sector / (hard_sect >> 9);
+	unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9);
+
+	if (!(rq->flags & REQ_CMD))
+		return 0;
+
+	if (rq->hard_nr_sectors != rq->nr_sectors) {
+		printk(KERN_ERR "ide-cd: hard_nr_sectors differs from nr_sectors! %lu %lu\n",
+				rq->nr_sectors, rq->hard_nr_sectors);
+	}
+	memset(rq->cmd, 0, sizeof(rq->cmd));
+
+	if (rq_data_dir(rq) == READ)
+		rq->cmd[0] = GPCMD_READ_10;
+	else
+		rq->cmd[0] = GPCMD_WRITE_10;
+
+	/*
+	 * fill in lba
+	 */
+	rq->cmd[2] = (block >> 24) & 0xff;
+	rq->cmd[3] = (block >> 16) & 0xff;
+	rq->cmd[4] = (block >>  8) & 0xff;
+	rq->cmd[5] = block & 0xff;
+
+	/*
+	 * and transfer length
+	 */
+	rq->cmd[7] = (blocks >> 8) & 0xff;
+	rq->cmd[8] = blocks & 0xff;
+
+	return 0;
+}
+
+static int ide_cdrom_setup(struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *cdi = &info->devinfo;
@@ -2797,16 +2836,14 @@
 }
 
 /* Forwarding functions to generic routines. */
-static
-int ide_cdrom_ioctl (ide_drive_t *drive,
+static int ide_cdrom_ioctl (struct ata_device *drive,
 		     struct inode *inode, struct file *file,
 		     unsigned int cmd, unsigned long arg)
 {
 	return cdrom_ioctl (inode, file, cmd, arg);
 }
 
-static
-int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive)
+static int ide_cdrom_open (struct inode *ip, struct file *fp, struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 	int rc = -ENOMEM;
@@ -2823,21 +2860,21 @@
 
 static
 void ide_cdrom_release (struct inode *inode, struct file *file,
-			ide_drive_t *drive)
+			struct ata_device *drive)
 {
 	cdrom_release (inode, file);
 	MOD_DEC_USE_COUNT;
 }
 
 static
-int ide_cdrom_check_media_change (ide_drive_t *drive)
+int ide_cdrom_check_media_change(struct ata_device *drive)
 {
 	return cdrom_media_changed(mk_kdev (drive->channel->major,
 			(drive->select.b.unit) << PARTN_BITS));
 }
 
 static
-void ide_cdrom_revalidate (ide_drive_t *drive)
+void ide_cdrom_revalidate(struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct atapi_toc *toc;
@@ -2868,7 +2905,7 @@
 }
 
 static
-int ide_cdrom_cleanup(ide_drive_t *drive)
+int ide_cdrom_cleanup(struct ata_device *drive)
 {
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *devinfo = &info->devinfo;
@@ -2888,8 +2925,11 @@
 	return 0;
 }
 
+static void ide_cdrom_attach(struct ata_device *drive);
+
 static struct ata_operations ide_cdrom_driver = {
 	owner:			THIS_MODULE,
+	attach:			ide_cdrom_attach,
 	cleanup:		ide_cdrom_cleanup,
 	standby:		NULL,
 	do_request:		ide_cdrom_do_request,
@@ -2905,67 +2945,63 @@
 /* options */
 static char *ignore = NULL;
 
+static void ide_cdrom_attach(struct ata_device *drive)
+{
+	struct cdrom_info *info;
+	char *req;
+	struct ata_channel *channel;
+	int unit;
+
+	if (drive->type != ATA_ROM)
+		return;
+
+	req = drive->driver_req;
+	if (req[0] != '\0' && strcmp(req, "ide-cdrom"))
+		return;
+
+	/* skip drives that we were told to ignore */
+	if (ignore && !strcmp(ignore, drive->name)) {
+		printk(KERN_INFO "%s: ignored\n", drive->name);
+		return;
+	}
+	info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
+	if (!info) {
+		printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
+		return;
+	}
+	if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
+		printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", drive->name);
+		kfree (info);
+		return;
+	}
+
+
+	memset(info, 0, sizeof (struct cdrom_info));
+	drive->driver_data = info;
+
+	if (ide_cdrom_setup (drive)) {
+		if (ide_cdrom_cleanup (drive))
+			printk (KERN_ERR "%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
+		return;
+	}
+
+	channel = drive->channel;
+	unit = drive - channel->drives;
+
+	ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
+}
+
 MODULE_PARM(ignore, "s");
 MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
 
 static void __exit ide_cdrom_exit(void)
 {
-	ide_drive_t *drive;
-	int failed = 0;
-
-	while ((drive = ide_scan_devices(ATA_ROM, "ide-cdrom", &ide_cdrom_driver, failed)) != NULL)
-		if (ide_cdrom_cleanup (drive)) {
-			printk ("%s: cleanup_module() called while still busy\n", drive->name);
-			failed++;
-		}
+	unregister_ata_driver(&ide_cdrom_driver);
 }
 
 int ide_cdrom_init(void)
 {
-	ide_drive_t *drive;
-	struct cdrom_info *info;
-	int failed = 0;
-
-	MOD_INC_USE_COUNT;
-	while ((drive = ide_scan_devices (ATA_ROM, "ide-cdrom", NULL, failed++)) != NULL) {
-		/* skip drives that we were told to ignore */
-		if (ignore != NULL) {
-			if (strstr(ignore, drive->name)) {
-				printk("ide-cd: ignoring drive %s\n", drive->name);
-				continue;
-			}
-		}
-		if (drive->scsi) {
-			printk("ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
-			continue;
-		}
-		info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
-		if (info == NULL) {
-			printk ("%s: Can't allocate a cdrom structure\n", drive->name);
-			continue;
-		}
-		if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
-			printk ("%s: Failed to register the driver with ide.c\n", drive->name);
-			kfree (info);
-			continue;
-		}
-		memset(info, 0, sizeof (struct cdrom_info));
-		drive->driver_data = info;
-
-		MOD_INC_USE_COUNT;
-		if (ide_cdrom_setup (drive)) {
-			MOD_DEC_USE_COUNT;
-			if (ide_cdrom_cleanup (drive))
-				printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
-			continue;
-		}
-		MOD_DEC_USE_COUNT;
-
-		failed--;
-	}
-	revalidate_drives();
-	MOD_DEC_USE_COUNT;
-	return 0;
+	return ata_driver_module(&ide_cdrom_driver);
 }
 
 module_init(ide_cdrom_init);
diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/ide-disk.c	Fri May 24 18:55:33 2002
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
+#include <linux/buffer_head.h>		/* for invalidate_bdev() */
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -391,6 +392,7 @@
 	if (drive->removable && !drive->usage) {
 		struct ata_taskfile args;
 
+		/* XXX I don't think this is up to the lowlevel drivers..  --hch */
 		invalidate_bdev(inode->i_bdev, 0);
 
 		memset(&args, 0, sizeof(args));
@@ -562,6 +564,8 @@
 	 * already been done...
 	 */
 
+	BUG_ON(in_interrupt());
+
 	if (level != SUSPEND_SAVE_STATE)
 		return 0;
 
@@ -908,7 +912,7 @@
 	if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
 	    (!drive->forced_geom) && drive->bios_sect && drive->bios_head)
 		drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
-	printk(KERN_INFO "%s: %ld sectors", drive->name, capacity);
+	printk(KERN_INFO " %s: %ld sectors", drive->name, capacity);
 
 #if 0
 
@@ -1144,12 +1148,14 @@
 	}
 }
 
+static void idedisk_attach(struct ata_device *drive);
 
 /*
  * Subdriver functions.
  */
 static struct ata_operations idedisk_driver = {
 	owner:			THIS_MODULE,
+	attach:			idedisk_attach,
 	cleanup:		idedisk_cleanup,
 	standby:		idedisk_standby,
 	do_request:		idedisk_do_request,
@@ -1162,46 +1168,49 @@
 	capacity:		idedisk_capacity,
 };
 
-MODULE_DESCRIPTION("ATA DISK Driver");
-
-static void __exit idedisk_exit (void)
+static void idedisk_attach(struct ata_device *drive)
 {
-	struct ata_device *drive;
-	int failed = 0;
+	char *req;
+	struct ata_channel *channel;
+	int unit;
 
-	while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", &idedisk_driver, failed)) != NULL) {
-		if (idedisk_cleanup (drive)) {
-			printk(KERN_ERR "%s: cleanup_module() called while still busy\n", drive->name);
-			++failed;
-		}
+	if (drive->type != ATA_DISK)
+		return;
+
+	req = drive->driver_req;
+	if (req[0] != '\0' && strcmp(req, "ide-disk"))
+		return;
+
+	if (ide_register_subdriver(drive, &idedisk_driver)) {
+		printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
+		return;
+	}
+
+	idedisk_setup(drive);
+	if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
+		printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head);
+		idedisk_cleanup(drive);
+		return;
 	}
+
+	channel = drive->channel;
+	unit = drive - channel->drives;
+
+	ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
 }
 
-int idedisk_init(void)
+static void __exit idedisk_exit(void)
 {
-	struct ata_device *drive;
-	int failed = 0;
-
-	MOD_INC_USE_COUNT;
-	while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", NULL, failed++)) != NULL) {
-		if (ide_register_subdriver (drive, &idedisk_driver)) {
-			printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
-			continue;
-		}
-		idedisk_setup(drive);
-		if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
-			printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head);
-			idedisk_cleanup(drive);
-			continue;
-		}
-		--failed;
-	}
-	revalidate_drives();
-	MOD_DEC_USE_COUNT;
+	unregister_ata_driver(&idedisk_driver);
+}
 
-	return 0;
+int __init idedisk_init(void)
+{
+	return ata_driver_module(&idedisk_driver);
 }
 
 module_init(idedisk_init);
 module_exit(idedisk_exit);
+
+MODULE_DESCRIPTION("ATA DISK Driver");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/ide/ide-features.c b/drivers/ide/ide-features.c
--- a/drivers/ide/ide-features.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/ide-features.c	Fri May 24 18:55:36 2002
@@ -257,12 +257,12 @@
 	struct ata_channel *hwif = drive->channel;
 	int i;
 	int error = 1;
-	byte stat;
+	u8 stat;
 
-#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
-	byte unit = (drive->select.b.unit & 0x01);
+#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(__CRIS__)
+	u8 unit = (drive->select.b.unit & 0x01);
 	outb(inb(hwif->dma_base+2) & ~(1<<(5+unit)), hwif->dma_base+2);
-#endif /* (CONFIG_BLK_DEV_IDEDMA) && !(CONFIG_DMA_NONPCI) */
+#endif
 
 	/*
 	 * Don't use ide_wait_cmd here - it will
@@ -329,7 +329,7 @@
 	drive->id->dma_mword &= ~0x0F00;
 	drive->id->dma_1word &= ~0x0F00;
 
-#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
+#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(__CRIS__)
 	if (speed > XFER_PIO_4) {
 		outb(inb(hwif->dma_base+2)|(1<<(5+unit)), hwif->dma_base+2);
 	} else {
diff -Nru a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
--- a/drivers/ide/ide-floppy.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/ide-floppy.c	Fri May 24 18:55:34 2002
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/ide-floppy.c	Version 0.99	Feb 24 2002
- *
  * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
  * Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net>
  */
@@ -97,6 +95,7 @@
 #include <linux/slab.h>
 #include <linux/cdrom.h>
 #include <linux/ide.h>
+#include <linux/atapi.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -128,12 +127,6 @@
 #define IDEFLOPPY_MAX_PC_RETRIES	3
 
 /*
- *	With each packet command, we allocate a buffer of
- *	IDEFLOPPY_PC_BUFFER_SIZE bytes.
- */
-#define IDEFLOPPY_PC_BUFFER_SIZE	256
-
-/*
  *	In various places in the driver, we need to allocate storage
  *	for packet commands and requests, which will remain valid while
  *	we leave the driver to wait for an interrupt or a timeout event.
@@ -141,25 +134,6 @@
 #define IDEFLOPPY_PC_STACK		(10 + IDEFLOPPY_MAX_PC_RETRIES)
 
 /*
- *	Our view of a packet command.
- */
-typedef struct idefloppy_packet_command_s {
-	u8 c[12];				/* Actual packet bytes */
-	int retries;				/* On each retry, we increment retries */
-	int error;				/* Error code */
-	int request_transfer;			/* Bytes to transfer */
-	int actually_transferred;		/* Bytes actually transferred */
-	int buffer_size;			/* Size of our data buffer */
-	char *b_data;				/* Pointer which runs on the buffers */
-	int b_count;				/* Missing/Available data on the current buffer */
-	byte *buffer;				/* Data buffer */
-	byte *current_position;			/* Pointer into the above buffer */
-	void (*callback) (struct ata_device *, struct request *);	/* Called when this packet command is completed */
-	byte pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE];	/* Temporary buffer */
-	unsigned long flags;			/* Status/Action bit flags: long for set_bit */
-} idefloppy_pc_t;
-
-/*
  *	Packet command flag bits.
  */
 #define	PC_ABORT			0	/* Set when an error is considered normal - We won't retry */
@@ -269,11 +243,11 @@
  *	of type idefloppy_floppy_t, defined below.
  */
 typedef struct {
-	ide_drive_t *drive;
+	struct ata_device *drive;
 
-	idefloppy_pc_t *pc;			/* Current packet command */
-	idefloppy_pc_t *failed_pc; 		/* Last failed packet command */
-	idefloppy_pc_t pc_stack[IDEFLOPPY_PC_STACK];/* Packet command stack */
+	struct atapi_packet_command *pc;		/* Current packet command */
+	struct atapi_packet_command *failed_pc;		/* Last failed packet command */
+	struct atapi_packet_command pc_stack[IDEFLOPPY_PC_STACK];	/* Packet command stack */
 	int pc_stack_index;			/* Next free packet command storage space */
 	struct request rq_stack[IDEFLOPPY_PC_STACK];
 	int rq_stack_index;			/* We implement a circular array */
@@ -645,24 +619,6 @@
 #define	IDEFLOPPY_MAX(a,b)	((a)>(b) ? (a):(b))
 
 /*
- *	Too bad. The drive wants to send us data which we are not ready to accept.
- *	Just throw it away.
- */
-static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount)
-{
-	while (bcount--)
-		IN_BYTE (IDE_DATA_REG);
-}
-
-#if IDEFLOPPY_DEBUG_BUGS
-static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount)
-{
-	while (bcount--)
-		OUT_BYTE (0, IDE_DATA_REG);
-}
-#endif /* IDEFLOPPY_DEBUG_BUGS */
-
-/*
  *	idefloppy_end_request is used to finish servicing a request.
  *
  *	For read/write requests, we will call ide_end_request to pass to the
@@ -698,7 +654,7 @@
 }
 
 static void idefloppy_input_buffers(struct ata_device *drive, struct request *rq,
-	idefloppy_pc_t *pc, unsigned int bcount)
+	struct atapi_packet_command *pc, unsigned int bcount)
 {
 	struct bio *bio = rq->bio;
 	int count;
@@ -713,17 +669,17 @@
 		}
 		if (bio == NULL) {
 			printk (KERN_ERR "%s: bio == NULL in %s, bcount == %d\n", drive->name, __FUNCTION__, bcount);
-			idefloppy_discard_data (drive, bcount);
+			atapi_discard_data(drive, bcount);
 			return;
 		}
-		count = IDEFLOPPY_MIN (bio->bi_size - pc->b_count, bcount);
+		count = IDEFLOPPY_MIN(bio->bi_size - pc->b_count, bcount);
 		atapi_read(drive, bio_data(bio) + pc->b_count, count);
 		bcount -= count; pc->b_count += count;
 	}
 }
 
 static void idefloppy_output_buffers(struct ata_device *drive, struct request *rq,
-	idefloppy_pc_t *pc, unsigned int bcount)
+		struct atapi_packet_command *pc, unsigned int bcount)
 {
 	struct bio *bio = rq->bio;
 	int count;
@@ -740,40 +696,41 @@
 		}
 		if (bio == NULL) {
 			printk (KERN_ERR "%s: bio == NULL in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount);
-			idefloppy_write_zeros (drive, bcount);
+			atapi_write_zeros (drive, bcount);
 			return;
 		}
-		count = IDEFLOPPY_MIN (pc->b_count, bcount);
+		count = IDEFLOPPY_MIN(pc->b_count, bcount);
 		atapi_write(drive, pc->b_data, count);
 		bcount -= count; pc->b_data += count; pc->b_count -= count;
 	}
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static void idefloppy_update_buffers (struct ata_device *drive, struct request *rq,
-	idefloppy_pc_t *pc)
+static void idefloppy_update_buffers(struct ata_device *drive, struct request *rq)
 {
 	struct bio *bio = rq->bio;
 
 	while ((bio = rq->bio) != NULL)
 		idefloppy_end_request(drive, rq, 1);
 }
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 
 /*
  *	idefloppy_queue_pc_head generates a new packet command request in front
  *	of the request queue, before the current request, so that it will be
  *	processed immediately, on the next pass through the driver.
  */
-static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq)
+static void idefloppy_queue_pc_head(struct ata_device *drive,
+		struct atapi_packet_command *pc, struct request *rq)
 {
 	ide_init_drive_cmd (rq);
+	/* FIXME: --mdcki */
 	rq->buffer = (char *) pc;
 	rq->flags = IDEFLOPPY_RQ;
 	(void) ide_do_drive_cmd (drive, rq, ide_preempt);
 }
 
-static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive)
+static struct atapi_packet_command *idefloppy_next_pc_storage(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -782,7 +739,7 @@
 	return (&floppy->pc_stack[floppy->pc_stack_index++]);
 }
 
-static struct request *idefloppy_next_rq_storage (ide_drive_t *drive)
+static struct request *idefloppy_next_rq_storage(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -795,7 +752,7 @@
  *	idefloppy_analyze_error is called on each failed packet command retry
  *	to analyze the request sense.
  */
-static void idefloppy_analyze_error (ide_drive_t *drive,idefloppy_request_sense_result_t *result)
+static void idefloppy_analyze_error(struct ata_device *drive, idefloppy_request_sense_result_t *result)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -807,7 +764,7 @@
 		printk (KERN_INFO "ide-floppy: pc = %x, sense key = %x, asc = %x, ascq = %x\n",floppy->failed_pc->c[0],result->sense_key,result->asc,result->ascq);
 	else
 		printk (KERN_INFO "ide-floppy: sense key = %x, asc = %x, ascq = %x\n",result->sense_key,result->asc,result->ascq);
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 }
 
 static void idefloppy_request_sense_callback(struct ata_device *drive, struct request *rq)
@@ -816,9 +773,9 @@
 
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "ide-floppy: Reached idefloppy_request_sense_callback\n");
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 	if (!floppy->pc->error) {
-		idefloppy_analyze_error (drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer);
+		idefloppy_analyze_error(drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer);
 		idefloppy_end_request(drive, rq, 1);
 	} else {
 		printk (KERN_ERR "Error in REQUEST SENSE itself - Aborting request!\n");
@@ -835,29 +792,14 @@
 
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "ide-floppy: Reached idefloppy_pc_callback\n");
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 
 	idefloppy_end_request(drive, rq, floppy->pc->error ? 0:1);
 }
 
-/*
- *	idefloppy_init_pc initializes a packet command.
- */
-static void idefloppy_init_pc (idefloppy_pc_t *pc)
-{
-	memset (pc->c, 0, 12);
-	pc->retries = 0;
-	pc->flags = 0;
-	pc->request_transfer = 0;
-	pc->buffer = pc->pc_buffer;
-	pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
-	pc->b_data = NULL;
-	pc->callback = idefloppy_pc_callback;
-}
-
-static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc)
+static void idefloppy_create_request_sense_cmd(struct atapi_packet_command *pc)
 {
-	idefloppy_init_pc (pc);	
+	atapi_init_pc(pc);
 	pc->c[0] = IDEFLOPPY_REQUEST_SENSE_CMD;
 	pc->c[4] = 255;
 	pc->request_transfer = 18;
@@ -869,16 +811,16 @@
  *	last packet command. We queue a request sense packet command in
  *	the head of the request list.
  */
-static void idefloppy_retry_pc (ide_drive_t *drive)
+static void idefloppy_retry_pc(struct ata_device *drive)
 {
-	idefloppy_pc_t *pc;
+	struct atapi_packet_command *pc;
 	struct request *rq;
 	idefloppy_error_reg_t error;
 
-	error.all = IN_BYTE (IDE_ERROR_REG);
-	pc = idefloppy_next_pc_storage (drive);
-	rq = idefloppy_next_rq_storage (drive);
-	idefloppy_create_request_sense_cmd (pc);
+	error.all = IN_BYTE(IDE_ERROR_REG);
+	pc = idefloppy_next_pc_storage(drive);
+	rq = idefloppy_next_rq_storage(drive);
+	idefloppy_create_request_sense_cmd(pc);
 	idefloppy_queue_pc_head(drive, pc, rq);
 }
 
@@ -892,7 +834,7 @@
 	idefloppy_status_reg_t status;
 	idefloppy_bcount_reg_t bcount;
 	idefloppy_ireason_reg_t ireason;
-	idefloppy_pc_t *pc=floppy->pc;
+	struct atapi_packet_command *pc = floppy->pc;
 	unsigned int temp;
 
 #if IDEFLOPPY_DEBUG_LOG
@@ -905,7 +847,7 @@
 			set_bit (PC_DMA_ERROR, &pc->flags);
 		} else {
 			pc->actually_transferred=pc->request_transfer;
-			idefloppy_update_buffers(drive, rq, pc);
+			idefloppy_update_buffers(drive, rq);
 		}
 # if IDEFLOPPY_DEBUG_LOG
 		printk (KERN_INFO "ide-floppy: DMA finished\n");
@@ -923,10 +865,10 @@
 
 		ide__sti();	/* local CPU only */
 
-		if (status.b.check || test_bit (PC_DMA_ERROR, &pc->flags)) {	/* Error detected */
+		if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) {	/* Error detected */
 #if IDEFLOPPY_DEBUG_LOG
 			printk (KERN_INFO "ide-floppy: %s: I/O error\n",drive->name);
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 			rq->errors++;
 			if (pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
 				printk (KERN_ERR "ide-floppy: I/O error in request sense command\n");
@@ -942,7 +884,7 @@
 		return ide_stopped;
 	}
 #ifdef CONFIG_BLK_DEV_IDEDMA
-	if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
+	if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
 		printk (KERN_ERR "ide-floppy: The floppy wants to issue more interrupts in DMA mode\n");
 		udma_enable(drive, 0, 1);
 
@@ -957,23 +899,23 @@
 		printk (KERN_ERR "ide-floppy: CoD != 0 in idefloppy_pc_intr\n");
 		return ide_stopped;
 	}
-	if (ireason.b.io == test_bit (PC_WRITING, &pc->flags)) {	/* Hopefully, we will never get here */
+	if (ireason.b.io == test_bit(PC_WRITING, &pc->flags)) {	/* Hopefully, we will never get here */
 		printk (KERN_ERR "ide-floppy: We wanted to %s, ", ireason.b.io ? "Write":"Read");
 		printk (KERN_ERR "but the floppy wants us to %s !\n",ireason.b.io ? "Read":"Write");
 		return ide_stopped;
 	}
-	if (!test_bit (PC_WRITING, &pc->flags)) {			/* Reading - Check that we have enough space */
+	if (!test_bit(PC_WRITING, &pc->flags)) {			/* Reading - Check that we have enough space */
 		temp = pc->actually_transferred + bcount.all;
 		if ( temp > pc->request_transfer) {
 			if (temp > pc->buffer_size) {
 				printk (KERN_ERR "ide-floppy: The floppy wants to send us more data than expected - discarding data\n");
-				idefloppy_discard_data (drive,bcount.all);
+				atapi_discard_data (drive,bcount.all);
 				ide_set_handler(drive, idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD, NULL);
 				return ide_started;
 			}
 #if IDEFLOPPY_DEBUG_LOG
 			printk (KERN_NOTICE "ide-floppy: The floppy wants to send us more data than expected - allowing transfer\n");
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 		}
 	}
 	if (test_bit (PC_WRITING, &pc->flags)) {
@@ -1076,7 +1018,8 @@
 /*
  *	Issue a packet command
  */
-static ide_startstop_t idefloppy_issue_pc(struct ata_device *drive, struct request *rq, idefloppy_pc_t *pc)
+static ide_startstop_t idefloppy_issue_pc(struct ata_device *drive, struct request *rq,
+		struct atapi_packet_command *pc)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 	idefloppy_bcount_reg_t bcount;
@@ -1085,28 +1028,28 @@
 
 #if IDEFLOPPY_DEBUG_BUGS
 	if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD && pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
-		printk (KERN_ERR "ide-floppy: possible ide-floppy.c bug - Two request sense in serial were issued\n");
+		printk(KERN_ERR "ide-floppy: possible ide-floppy.c bug - Two request sense in serial were issued\n");
 	}
-#endif /* IDEFLOPPY_DEBUG_BUGS */
+#endif
 
 	if (floppy->failed_pc == NULL && pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD)
 		floppy->failed_pc=pc;
 	floppy->pc=pc;							/* Set the current packet command */
 
-	if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES || test_bit (PC_ABORT, &pc->flags)) {
+	if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES || test_bit(PC_ABORT, &pc->flags)) {
 		/*
 		 *	We will "abort" retrying a packet command in case
 		 *	a legitimate error code was received.
 		 */
-		if (!test_bit (PC_ABORT, &pc->flags)) {
-			if (!test_bit (PC_SUPPRESS_ERROR, &pc->flags)) {
+		if (!test_bit(PC_ABORT, &pc->flags)) {
+			if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) {
 				;
       printk( KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, asc = %2x, ascq = %2x\n",
 				drive->name, pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq);
 			}
 			pc->error = IDEFLOPPY_ERROR_GENERAL;		/* Giving up */
 		}
-		floppy->failed_pc=NULL;
+		floppy->failed_pc = NULL;
 		pc->callback(drive, rq);
 		return ide_stopped;
 	}
@@ -1129,7 +1072,7 @@
 		else
 			dma_ok = !udma_read(drive, rq);
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 
 	if (IDE_CONTROL_REG)
 		OUT_BYTE (drive->ctl,IDE_CONTROL_REG);
@@ -1140,10 +1083,10 @@
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (dma_ok) {							/* Begin DMA, if necessary */
-		set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
+		set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
 		udma_start(drive, rq);
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 
 	/* Can we transfer the packet when we get the interrupt or wait? */
 	if (test_bit (IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) {
@@ -1172,30 +1115,32 @@
 	return;
 }
 
-static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent)
+static void idefloppy_create_prevent_cmd(struct atapi_packet_command *pc, int prevent)
 {
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "ide-floppy: creating prevent removal command, prevent = %d\n", prevent);
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 
-	idefloppy_init_pc (pc);
+	atapi_init_pc (pc);
 	pc->c[0] = IDEFLOPPY_PREVENT_REMOVAL_CMD;
 	pc->c[4] = prevent;
+	pc->callback = idefloppy_pc_callback;
 }
 
-static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc)
+static void idefloppy_create_read_capacity_cmd(struct atapi_packet_command *pc)
 {
-	idefloppy_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDEFLOPPY_READ_CAPACITY_CMD;
 	pc->c[7] = 255;
 	pc->c[8] = 255;
 	pc->request_transfer = 255;
+	pc->callback = idefloppy_pc_callback;
 }
 
-static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l,
-					      int flags)
+static void idefloppy_create_format_unit_cmd(struct atapi_packet_command *pc,
+		int b, int l, int flags)
 {
-	idefloppy_init_pc (pc);
+	atapi_init_pc (pc);
 	pc->c[0] = IDEFLOPPY_FORMAT_UNIT_CMD;
 	pc->c[1] = 0x17;
 
@@ -1209,18 +1154,19 @@
 
 	put_unaligned(htonl(b), (unsigned int *)(&pc->buffer[4]));
 	put_unaligned(htonl(l), (unsigned int *)(&pc->buffer[8]));
-	pc->buffer_size=12;
+	pc->buffer_size = 12;
 	set_bit(PC_WRITING, &pc->flags);
+	pc->callback = idefloppy_pc_callback;
 }
 
 /*
  *	A mode sense command is used to "sense" floppy parameters.
  */
-static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, byte page_code, byte type)
+static void idefloppy_create_mode_sense_cmd(struct atapi_packet_command *pc, u8 page_code, u8 type)
 {
-	unsigned short length = sizeof (idefloppy_mode_parameter_header_t);
-	
-	idefloppy_init_pc (pc);
+	unsigned short length = sizeof(idefloppy_mode_parameter_header_t);
+
+	atapi_init_pc(pc);
 	pc->c[0] = IDEFLOPPY_MODE_SENSE_CMD;
 	pc->c[1] = 0;
 	pc->c[2] = page_code + (type << 6);
@@ -1235,24 +1181,28 @@
 		default:
 			printk (KERN_ERR "ide-floppy: unsupported page code in create_mode_sense_cmd\n");
 	}
-	put_unaligned (htons (length), (unsigned short *) &pc->c[7]);
+	put_unaligned(htons(length), (unsigned short *) &pc->c[7]);
 	pc->request_transfer = length;
+	pc->callback = idefloppy_pc_callback;
 }
 
-static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start)
+static void idefloppy_create_start_stop_cmd(struct atapi_packet_command *pc, int start)
 {
-	idefloppy_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDEFLOPPY_START_STOP_CMD;
 	pc->c[4] = start;
+	pc->callback = idefloppy_pc_callback;
 }
 
-static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc)
+static void idefloppy_create_test_unit_ready_cmd(struct atapi_packet_command *pc)
 {
-	idefloppy_init_pc(pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDEFLOPPY_TEST_UNIT_READY_CMD;
+	pc->callback = idefloppy_pc_callback;
 }
 
-static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq, sector_t sector)
+static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
+		struct atapi_packet_command *pc, struct request *rq, sector_t sector)
 {
 	int block = sector / floppy->bs_factor;
 	int blocks = rq->nr_sectors / floppy->bs_factor;
@@ -1261,25 +1211,25 @@
 #if IDEFLOPPY_DEBUG_LOG
 	printk ("create_rw1%d_cmd: block == %d, blocks == %d\n",
 		2 * test_bit (IDEFLOPPY_USE_READ12, &floppy->flags), block, blocks);
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 
-	idefloppy_init_pc(pc);
+	atapi_init_pc(pc);
 	if (test_bit (IDEFLOPPY_USE_READ12, &floppy->flags)) {
 		pc->c[0] = cmd == READ ? IDEFLOPPY_READ12_CMD : IDEFLOPPY_WRITE12_CMD;
-		put_unaligned (htonl (blocks), (unsigned int *) &pc->c[6]);
+		put_unaligned(htonl (blocks), (unsigned int *) &pc->c[6]);
 	} else {
 		pc->c[0] = cmd == READ ? IDEFLOPPY_READ10_CMD : IDEFLOPPY_WRITE10_CMD;
-		put_unaligned (htons (blocks), (unsigned short *) &pc->c[7]);
+		put_unaligned(htons (blocks), (unsigned short *) &pc->c[7]);
 	}
-	put_unaligned (htonl (block), (unsigned int *) &pc->c[2]);
+	put_unaligned(htonl(block), (unsigned int *) &pc->c[2]);
 	pc->callback = idefloppy_rw_callback;
 	pc->b_data = rq->buffer;
 	pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
 	if (rq->flags & REQ_RW)
-		set_bit (PC_WRITING, &pc->flags);
+		set_bit(PC_WRITING, &pc->flags);
 	pc->buffer = NULL;
 	pc->request_transfer = pc->buffer_size = blocks * floppy->block_size;
-	set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+	set_bit(PC_DMA_RECOMMENDED, &pc->flags);
 }
 
 /*
@@ -1288,7 +1238,7 @@
 static ide_startstop_t idefloppy_do_request(struct ata_device *drive, struct request *rq, sector_t block)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t *pc;
+	struct atapi_packet_command *pc;
 
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "rq_status: %d, rq_dev: %u, flags: %lx, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->flags,rq->errors);
@@ -1313,7 +1263,8 @@
 		pc = idefloppy_next_pc_storage(drive);
 		idefloppy_create_rw_cmd (floppy, pc, rq, block);
 	} else if (rq->flags & IDEFLOPPY_RQ) {
-		pc = (idefloppy_pc_t *) rq->buffer;
+		/* FIXME: --mdcki */
+		pc = (struct atapi_packet_command *) rq->buffer;
 	} else {
 		blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue");
 		idefloppy_end_request(drive, rq, 0);
@@ -1327,11 +1278,12 @@
  *	idefloppy_queue_pc_tail adds a special packet command request to the
  *	tail of the request queue, and waits for it to be serviced.
  */
-static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc)
+static int idefloppy_queue_pc_tail(struct ata_device *drive, struct atapi_packet_command *pc)
 {
 	struct request rq;
 
 	ide_init_drive_cmd (&rq);
+	/* FIXME: --mdcki */
 	rq.buffer = (char *) pc;
 	rq.flags = IDEFLOPPY_RQ;
 	return ide_do_drive_cmd (drive, &rq, ide_wait);
@@ -1341,10 +1293,10 @@
  *	Look at the flexible disk page parameters. We will ignore the CHS
  *	capacity parameters and use the LBA parameters instead.
  */
-static int idefloppy_get_flexible_disk_page (ide_drive_t *drive)
+static int idefloppy_get_flexible_disk_page(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 	idefloppy_mode_parameter_header_t *header;
 	idefloppy_flexible_disk_page_t *page;
 	int capacity, lba_capacity;
@@ -1382,15 +1334,15 @@
 	return 0;
 }
 
-static int idefloppy_get_capability_page(ide_drive_t *drive)
+static int idefloppy_get_capability_page(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 	idefloppy_mode_parameter_header_t *header;
 	idefloppy_capabilities_page_t *page;
 
 	floppy->srfp=0;
-	idefloppy_create_mode_sense_cmd (&pc, IDEFLOPPY_CAPABILITIES_PAGE,
+	idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE,
 						 MODE_SENSE_CURRENT);
 
 	set_bit(PC_SUPPRESS_ERROR, &pc.flags);
@@ -1408,14 +1360,14 @@
  *	Determine if a media is present in the floppy drive, and if so,
  *	its LBA capacity.
  */
-static int idefloppy_get_capacity (ide_drive_t *drive)
+static int idefloppy_get_capacity(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 	idefloppy_capacity_header_t *header;
 	idefloppy_capacity_descriptor_t *descriptor;
 	int i, descriptors, rc = 1, blocks, length;
-	
+
 	drive->bios_cyl = 0;
 	drive->bios_head = drive->bios_sect = 0;
 	floppy->blocks = floppy->bs_factor = 0;
@@ -1434,9 +1386,9 @@
                 blocks = descriptor->blocks = ntohl (descriptor->blocks);
                 length = descriptor->length = ntohs (descriptor->length);
 
-		if (!i) 
+		if (!i)
 		{
-          	switch (descriptor->dc) {
+			switch (descriptor->dc) {
                 case CAPACITY_UNFORMATTED: /* Clik! drive returns this instead of CAPACITY_CURRENT */
                         if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags))
                                 break; /* If it is not a clik drive, break out (maintains previous driver behaviour) */
@@ -1500,12 +1452,12 @@
 **
 */
 
-static int idefloppy_get_format_capacities (ide_drive_t *drive,
-					    struct inode *inode,
-					    struct file *file,
-					    int *arg)	/* Cheater */
+static int idefloppy_get_format_capacities(struct ata_device *drive,
+		struct inode *inode,
+		struct file *file,
+		int *arg)	/* Cheater */
 {
-        idefloppy_pc_t pc;
+        struct atapi_packet_command pc;
 	idefloppy_capacity_header_t *header;
         idefloppy_capacity_descriptor_t *descriptor;
 	int i, descriptors, blocks, length;
@@ -1519,8 +1471,8 @@
 	if (u_array_size <= 0)
 		return (-EINVAL);
 
-	idefloppy_create_read_capacity_cmd (&pc);
-	if (idefloppy_queue_pc_tail (drive, &pc)) {
+	idefloppy_create_read_capacity_cmd(&pc);
+	if (idefloppy_queue_pc_tail(drive, &pc)) {
 		printk (KERN_ERR "ide-floppy: Can't get floppy parameters\n");
                 return (-EIO);
         }
@@ -1580,7 +1532,7 @@
 **        0x01 - verify media after format.
 */
 
-static int idefloppy_begin_format(ide_drive_t *drive,
+static int idefloppy_begin_format(struct ata_device *drive,
 				  struct inode *inode,
 				  struct file *file,
 				  int *arg)
@@ -1588,7 +1540,7 @@
 	int blocks;
 	int length;
 	int flags;
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 
 	if (get_user(blocks, arg)
 	    || get_user(length, arg+1)
@@ -1599,10 +1551,9 @@
 
 	(void) idefloppy_get_capability_page (drive);	/* Get the SFRP bit */
 	idefloppy_create_format_unit_cmd(&pc, blocks, length, flags);
-	if (idefloppy_queue_pc_tail (drive, &pc))
-	{
-                return (-EIO);
-        }
+	if (idefloppy_queue_pc_tail(drive, &pc))
+                return -EIO;
+
 	return (0);
 }
 
@@ -1616,13 +1567,13 @@
 ** the dsc bit, and return either 0 or 65536.
 */
 
-static int idefloppy_get_format_progress(ide_drive_t *drive,
-					 struct inode *inode,
-					 struct file *file,
-					 int *arg)
+static int idefloppy_get_format_progress(struct ata_device *drive,
+		struct inode *inode,
+		struct file *file,
+		int *arg)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 	int progress_indication=0x10000;
 
 	if (floppy->srfp)
@@ -1664,10 +1615,10 @@
  *
  *	Currently there aren't any ioctl's.
  */
-static int idefloppy_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file,
+static int idefloppy_ioctl(struct ata_device *drive, struct inode *inode, struct file *file,
 				 unsigned int cmd, unsigned long arg)
 {
-	idefloppy_pc_t pc;
+	struct atapi_packet_command pc;
 	idefloppy_floppy_t *floppy = drive->driver_data;
 	int prevent = (arg) ? 1 : 0;
 
@@ -1681,8 +1632,8 @@
 
 		/* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */
                 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
-			idefloppy_create_prevent_cmd (&pc, prevent);
-			(void) idefloppy_queue_pc_tail (drive, &pc);
+			idefloppy_create_prevent_cmd(&pc, prevent);
+			(void) idefloppy_queue_pc_tail(drive, &pc);
 		}
 		if (cmd == CDROMEJECT) {
 			idefloppy_create_start_stop_cmd (&pc, 2);
@@ -1744,14 +1695,14 @@
 /*
  *	Our open/release functions
  */
-static int idefloppy_open (struct inode *inode, struct file *filp, ide_drive_t *drive)
+static int idefloppy_open(struct inode *inode, struct file *filp, struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
-	idefloppy_pc_t pc;
-	
+	struct atapi_packet_command pc;
+
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "Reached idefloppy_open\n");
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 
 	MOD_INC_USE_COUNT;
 	if (drive->usage == 1) {
@@ -1781,7 +1732,7 @@
 			drive->usage--;
 			MOD_DEC_USE_COUNT;
 			return -EROFS;
-		}		
+		}
 		set_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
 		/* IOMEGA Clik! drives do not support lock/unlock commands */
                 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
@@ -1799,13 +1750,13 @@
 	return 0;
 }
 
-static void idefloppy_release (struct inode *inode, struct file *filp, ide_drive_t *drive)
+static void idefloppy_release(struct inode *inode, struct file *filp, struct ata_device *drive)
 {
-	idefloppy_pc_t pc;
-	
+	struct atapi_packet_command pc;
+
 #if IDEFLOPPY_DEBUG_LOG
 	printk (KERN_INFO "Reached idefloppy_release\n");
-#endif /* IDEFLOPPY_DEBUG_LOG */
+#endif
 
 	if (!drive->usage) {
 		idefloppy_floppy_t *floppy = drive->driver_data;
@@ -1826,17 +1777,17 @@
 /*
  *	Check media change. Use a simple algorithm for now.
  */
-static int idefloppy_check_media_change (ide_drive_t *drive)
+static int idefloppy_check_media_change(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 
-	return test_and_clear_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
+	return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
 }
 
 /*
  *	Return the current floppy capacity to ide.c.
  */
-static unsigned long idefloppy_capacity (ide_drive_t *drive)
+static unsigned long idefloppy_capacity(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 	unsigned long capacity = floppy->blocks * floppy->bs_factor;
@@ -1848,7 +1799,7 @@
  *	idefloppy_identify_device checks if we can support a drive,
  *	based on the ATAPI IDENTIFY command results.
  */
-static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
+static int idefloppy_identify_device(struct ata_device *drive,struct hd_driveid *id)
 {
 	struct idefloppy_id_gcw gcw;
 #if IDEFLOPPY_DEBUG_INFO
@@ -1963,7 +1914,7 @@
 /*
  *	Driver initialization.
  */
-static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
+static void idefloppy_setup(struct ata_device *drive, idefloppy_floppy_t *floppy)
 {
 	struct idefloppy_id_gcw gcw;
 	int i;
@@ -2013,7 +1964,7 @@
 	}
 }
 
-static int idefloppy_cleanup (ide_drive_t *drive)
+static int idefloppy_cleanup(struct ata_device *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -2024,11 +1975,14 @@
 	return 0;
 }
 
+static void idefloppy_attach(struct ata_device *drive);
+
 /*
  *	IDE subdriver functions, registered with ide.c
  */
 static struct ata_operations idefloppy_driver = {
 	owner:			THIS_MODULE,
+	attach:			idefloppy_attach,
 	cleanup:		idefloppy_cleanup,
 	standby:		NULL,
 	do_request:		idefloppy_do_request,
@@ -2041,59 +1995,60 @@
 	capacity:		idefloppy_capacity,
 };
 
-MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
-
-static void __exit idefloppy_exit (void)
+static void idefloppy_attach(struct ata_device *drive)
 {
-	ide_drive_t *drive;
-	int failed = 0;
+	idefloppy_floppy_t *floppy;
+	char *req;
+	struct ata_channel *channel;
+	int unit;
 
-	while ((drive = ide_scan_devices(ATA_FLOPPY, "ide-floppy", &idefloppy_driver, failed)) != NULL) {
-		if (idefloppy_cleanup (drive)) {
-			printk ("%s: cleanup_module() called while still busy\n", drive->name);
-			failed++;
-		}
+	if (drive->type != ATA_FLOPPY)
+		return;
+
+	req = drive->driver_req;
+	if (req[0] != '\0' && strcmp(req, "ide-floppy"))
+		return;
+
+	if (!idefloppy_identify_device (drive, drive->id)) {
+		printk (KERN_ERR "ide-floppy: %s: not supported by this version of driver\n",
+				drive->name);
+		return;
+	}
+
+	if (drive->scsi) {
+		printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi emulation.\n",
+				drive->name);
+		return;
 	}
+	if (!(floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL))) {
+		printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n",
+				drive->name);
+		return;
+	}
+	if (ide_register_subdriver(drive, &idefloppy_driver)) {
+		printk(KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
+		kfree (floppy);
+		return;
+	}
+
+	idefloppy_setup(drive, floppy);
+
+	channel = drive->channel;
+	unit = drive - channel->drives;
+
+	ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
 }
 
-/*
- *	idefloppy_init will register the driver for each floppy.
- */
-int idefloppy_init (void)
-{
-	ide_drive_t *drive;
-	idefloppy_floppy_t *floppy;
-	int failed = 0;
+MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
 
-	printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
-	MOD_INC_USE_COUNT;
-	while ((drive = ide_scan_devices (ATA_FLOPPY, "ide-floppy", NULL, failed++)) != NULL) {
-		if (!idefloppy_identify_device (drive, drive->id)) {
-			printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name);
-			continue;
-		}
-		if (drive->scsi) {
-			printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
-			continue;
-		}
-		if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
-			printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
-			continue;
-		}
-		if (ide_register_subdriver (drive, &idefloppy_driver)) {
-			printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
-			kfree (floppy);
-			continue;
-		}
-		MOD_INC_USE_COUNT;
-		idefloppy_setup (drive, floppy);
-		MOD_DEC_USE_COUNT;
+static void __exit idefloppy_exit(void)
+{
+	unregister_ata_driver(&idefloppy_driver);
+}
 
-		failed--;
-	}
-	revalidate_drives();
-	MOD_DEC_USE_COUNT;
-	return 0;
+int __init idefloppy_init(void)
+{
+	return ata_driver_module(&idefloppy_driver);
 }
 
 module_init(idefloppy_init);
diff -Nru a/drivers/ide/ide-m8xx.c b/drivers/ide/ide-m8xx.c
--- a/drivers/ide/ide-m8xx.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/ide-m8xx.c	Fri May 24 18:55:35 2002
@@ -51,7 +51,7 @@
 static int check_ide_device (unsigned long base);
 
 static void ide_interrupt_ack (void *dev);
-static void m8xx_ide_tuneproc(ide_drive_t *drive, byte pio);
+static void m8xx_ide_tuneproc(struct ata_device *drive, byte pio);
 
 typedef	struct ide_ioport_desc {
 	unsigned long	base_off;		/* Offset to PCMCIA memory	*/
@@ -437,7 +437,7 @@
 
 /* Calculate PIO timings */
 static void
-m8xx_ide_tuneproc(ide_drive_t *drive, byte pio)
+m8xx_ide_tuneproc(struct ata_device *drive, byte pio)
 {
 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
 	volatile pcmconf8xx_t	*pcmp;
diff -Nru a/drivers/ide/ide-pci.c b/drivers/ide/ide-pci.c
--- a/drivers/ide/ide-pci.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/ide-pci.c	Fri May 24 18:55:36 2002
@@ -207,7 +207,8 @@
 
 	if ((dev->vendor == PCI_VENDOR_ID_AL && dev->device == PCI_DEVICE_ID_AL_M5219) ||
 			(dev->vendor == PCI_VENDOR_ID_AMD && dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) ||
-			(dev->vendor == PCI_VENDOR_ID_CMD && dev->device == PCI_DEVICE_ID_CMD_643)) {
+			(dev->vendor == PCI_VENDOR_ID_CMD && dev->device == PCI_DEVICE_ID_CMD_643) ||
+			(dev->vendor == PCI_VENDOR_ID_SERVERWORKS && dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)) {
 		outb(inb(dma_base + 2) & 0x60, dma_base+2);
 		if (inb(dma_base + 2) & 0x80)
 			printk(KERN_INFO "%s: simplex device: DMA forced\n", name);
@@ -553,14 +554,14 @@
 			}
 		}
 	}
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
-			dev->name, dev->slot_name, dev->devfn);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+			dev->name, dev->slot_name);
 	setup_pci_device(dev, d);
 	if (!dev2)
 		return;
 	d2 = d;
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
-			dev2->name, dev2->slot_name, dev2->devfn);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+			dev2->name, dev2->slot_name);
 	setup_pci_device(dev2, d2);
 }
 
@@ -583,8 +584,8 @@
 		}
 	}
 
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
-		dev->name, dev->slot_name, dev->devfn);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+		dev->name, dev->slot_name);
 	setup_pci_device(dev, d);
 	if (!dev2) {
 		return;
@@ -600,8 +601,8 @@
 		}
 	}
 	d2 = d;
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
-		dev2->name, dev2->slot_name, dev2->devfn);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+		dev2->name, dev2->slot_name);
 	setup_pci_device(dev2, d2);
 
 }
@@ -622,7 +623,8 @@
 	switch(class_rev) {
 		case 5:
 		case 4:
-		case 3:	printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev->name, dev->slot_name);
+		case 3:	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+					dev->name, dev->slot_name);
 			setup_pci_device(dev, d);
 			return;
 		default:	break;
@@ -643,12 +645,14 @@
 			break;
 		}
 	}
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev->name, dev->slot_name);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+			dev->name, dev->slot_name);
 	setup_pci_device(dev, d);
 	if (!dev2)
 		return;
 	d2 = d;
-	printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev2->name, dev2->slot_name);
+	printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+			dev2->name, dev2->slot_name);
 	setup_pci_device(dev2, d2);
 }
 
@@ -683,7 +687,7 @@
 		 * beeing grabbed by generic drivers.
 		 */
 		if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
-			printk(KERN_INFO "ATA: unknown interface: %s, on PCI slot %s\n",
+			printk(KERN_INFO "ATA: unknown interface: %s, PCI slot %s\n",
 					dev->name, dev->slot_name);
 		}
 		return;
@@ -707,8 +711,8 @@
 	} else if (d->vendor == PCI_VENDOR_ID_PROMISE && d->device == PCI_DEVICE_ID_PROMISE_20268R)
 		pdc20270_device_order_fixup(dev, d);
 	else {
-		printk(KERN_INFO "ATA: %s (%04x:%04x) on PCI slot %s\n",
-				dev->name, vendor, device, dev->slot_name);
+		printk(KERN_INFO "ATA: %s, PCI slot %s\n",
+				dev->name, dev->slot_name);
 		setup_pci_device(dev, d);
 	}
 }
@@ -764,7 +768,7 @@
 		vendor: PCI_VENDOR_ID_INTEL,
 		device: PCI_DEVICE_ID_INTEL_82371MX,
 		enablebits: {{0x6D,0x80,0x80}, {0x00,0x00,0x00}},
-		bootable: ON_BOARD, 0,
+		bootable: ON_BOARD,
 		flags: ATA_F_NODMA
 	},
 	{
@@ -790,6 +794,19 @@
 		device: PCI_DEVICE_ID_VIA_82C561,
 		bootable: ON_BOARD,
 		flags: ATA_F_NOADMA
+	},
+	{
+		vendor: PCI_VENDOR_ID_VIA,
+		device: PCI_DEVICE_ID_VIA_82C586_1,
+		bootable: ON_BOARD,
+		flags: ATA_F_NOADMA
+	},
+	{
+		vendor: PCI_VENDOR_ID_TTI,
+		device: PCI_DEVICE_ID_TTI_HPT366,
+		bootable: OFF_BOARD,
+		extra: 240,
+		flags: ATA_F_IRQ | ATA_F_HPTHACK
 	}
 };
 
diff -Nru a/drivers/ide/ide-pmac.c b/drivers/ide/ide-pmac.c
--- a/drivers/ide/ide-pmac.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/ide-pmac.c	Fri May 24 18:55:36 2002
@@ -33,7 +33,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
diff -Nru a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
--- a/drivers/ide/ide-pnp.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/ide-pnp.c	Fri May 24 18:55:34 2002
@@ -75,7 +75,7 @@
 
 	if (index != -1) {
 		hwif->pci_dev = dev;
-		printk("ide%d: %s IDE interface\n", index, DEV_NAME(dev));
+		printk(KERN_INFO "ide%d: %s IDE interface\n", index, DEV_NAME(dev));
 		return 0;
 	}
 
@@ -133,12 +133,12 @@
 				continue;
 
        			if (PREPARE_FUNC(dev) && (PREPARE_FUNC(dev))(dev) < 0) {
-				printk("ide: %s prepare failed\n", DEV_NAME(dev));
+				printk(KERN_ERR "ide: %s prepare failed\n", DEV_NAME(dev));
 				continue;
 			}
 
 			if (ACTIVATE_FUNC(dev) && (ACTIVATE_FUNC(dev))(dev) < 0) {
-				printk("ide: %s activate failed\n", DEV_NAME(dev));
+				printk(KERN_ERR "ide: %s activate failed\n", DEV_NAME(dev));
 				continue;
 			}
 
diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
--- a/drivers/ide/ide-probe.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/ide-probe.c	Fri May 24 18:55:33 2002
@@ -580,10 +580,14 @@
 	int i;
 	spinlock_t *lock;
 	spinlock_t *new_lock;
+	unsigned long *active;
+	unsigned long *new_active;
 	struct ata_channel *match = NULL;
 
 	/* Spare allocation before sleep. */
 	new_lock = kmalloc(sizeof(*lock), GFP_KERNEL);
+	new_active = kmalloc(sizeof(*active), GFP_KERNEL);
+	*new_active = 0L;
 
 	spin_lock_irqsave(&ide_lock, flags);
 	ch->lock = NULL;
@@ -619,6 +623,7 @@
 	 */
 	if (!match) {
 		lock = new_lock;
+		active = new_active;
 		if (!lock) {
 			spin_unlock_irqrestore(&ide_lock, flags);
 
@@ -627,6 +632,7 @@
 		spin_lock_init(lock);
 	} else {
 		lock = match->lock;
+		active = match->active;
 		if(new_lock)
 			kfree(new_lock);
 	}
@@ -645,8 +651,10 @@
 			OUT_BYTE(0x08, ch->io_ports[IDE_CONTROL_OFFSET]); /* clear nIEN */
 
 		if (request_irq(ch->irq, &ata_irq_request, sa, ch->name, ch)) {
-			if (!match)
+			if (!match) {
 				kfree(lock);
+				kfree(active);
+			}
 
 			spin_unlock_irqrestore(&ide_lock, flags);
 
@@ -658,6 +666,7 @@
 	 * Everything is okay. Tag us as member of this lock group.
 	 */
 	ch->lock = lock;
+	ch->active = active;
 
 	init_timer(&ch->timer);
 	ch->timer.function = &ide_timer_expiry;
diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
--- a/drivers/ide/ide-tape.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/ide-tape.c	Fri May 24 18:55:34 2002
@@ -1,10 +1,6 @@
 /*
- * linux/drivers/ide/ide-tape.c		Version 1.17a	Jan, 2001
- *
  * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il>
  *
- * $Header$
- *
  * This driver was constructed as a student project in the software laboratory
  * of the faculty of electrical engineering in the Technion - Israel's
  * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David.
@@ -12,14 +8,14 @@
  * It is hereby placed under the terms of the GNU general public license.
  * (See linux/COPYING).
  */
- 
+
 /*
  * IDE ATAPI streaming tape driver.
  *
  * This driver is a part of the Linux ide driver and works in co-operation
  * with linux/drivers/block/ide.c.
  *
- * The driver, in co-operation with ide.c, basically traverses the 
+ * The driver, in co-operation with ide.c, basically traverses the
  * request-list for the block device interface. The character device
  * interface, on the other hand, creates new requests, adds them
  * to the request-list of the block device, and waits for their completion.
@@ -417,9 +413,10 @@
 #include <linux/genhd.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
-#include <linux/ide.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
+#include <linux/ide.h>
+#include <linux/atapi.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -615,13 +612,6 @@
 #define IDETAPE_MAX_PC_RETRIES		3
 
 /*
- *	With each packet command, we allocate a buffer of
- *	IDETAPE_PC_BUFFER_SIZE bytes. This is used for several packet
- *	commands (Not for READ/WRITE commands).
- */
-#define IDETAPE_PC_BUFFER_SIZE		256
-
-/*
  *	In various places in the driver, we need to allocate storage
  *	for packet commands and requests, which will remain valid while
  *	we leave the driver to wait for an interrupt or a timeout event.
@@ -712,27 +702,6 @@
 } idetape_chrdev_direction_t;
 
 /*
- *	Our view of a packet command.
- */
-typedef struct idetape_packet_command_s {
-	u8 c[12];				/* Actual packet bytes */
-	int retries;				/* On each retry, we increment retries */
-	int error;				/* Error code */
-	int request_transfer;			/* Bytes to transfer */
-	int actually_transferred;		/* Bytes actually transferred */
-	int buffer_size;			/* Size of our data buffer */
-	struct bio *bio;
-	char *b_data;
-	int b_count;
-	byte *buffer;				/* Data buffer */
-	byte *current_position;			/* Pointer into the above buffer */
-	/* Called when this packet command is completed */
-	ide_startstop_t (*callback) (struct ata_device *, struct request *);
-	byte pc_buffer[IDETAPE_PC_BUFFER_SIZE];	/* Temporary buffer */
-	unsigned long flags;			/* Status/Action bit flags: long for set_bit */
-} idetape_pc_t;
-
-/*
  *	Packet command flag bits.
  */
 #define	PC_ABORT			0	/* Set when an error is considered normal - We won't retry */
@@ -747,10 +716,10 @@
  */
 typedef struct {
 	unsigned	page_code	:6;	/* Page code - Should be 0x2a */
-	__u8		reserved0_6	:1;
-	__u8		ps		:1;	/* parameters saveable */
-	__u8		page_length;		/* Page Length - Should be 0x12 */
-	__u8		reserved2, reserved3;
+	u8		reserved0_6	:1;
+	u8		ps		:1;	/* parameters saveable */
+	u8		page_length;		/* Page Length - Should be 0x12 */
+	u8		reserved2, reserved3;
 	unsigned	ro		:1;	/* Read Only Mode */
 	unsigned	reserved4_1234	:4;
 	unsigned	sprev		:1;	/* Supports SPACE in the reverse direction */
@@ -762,10 +731,10 @@
 	unsigned	reserved5_67	:2;
 	unsigned	lock		:1;	/* Supports locking the volume */
 	unsigned	locked		:1;	/* The volume is locked */
-	unsigned	prevent		:1;	/* The device defaults in the prevent state after power up */	
+	unsigned	prevent		:1;	/* The device defaults in the prevent state after power up */
 	unsigned	eject		:1;	/* The device can eject the volume */
-	__u8		disconnect	:1;	/* The device can break request > ctl */	
-	__u8		reserved6_5	:1;
+	u8		disconnect	:1;	/* The device can break request > ctl */
+	u8		reserved6_5	:1;
 	unsigned	ecc		:1;	/* Supports error correction */
 	unsigned	cmprs		:1;	/* Supports data compression */
 	unsigned	reserved7_0	:1;
@@ -775,12 +744,12 @@
 	unsigned	blk32768	:1;	/* slowb - the device restricts the byte count for PIO */
 						/* transfers for slow buffer memory ??? */
 						/* Also 32768 block size in some cases */
-	__u16		max_speed;		/* Maximum speed supported in KBps */
-	__u8		reserved10, reserved11;
-	__u16		ctl;			/* Continuous Transfer Limit in blocks */
-	__u16		speed;			/* Current Speed, in KBps */
-	__u16		buffer_size;		/* Buffer Size, in 512 bytes */
-	__u8		reserved18, reserved19;
+	u16		max_speed;		/* Maximum speed supported in KBps */
+	u8		reserved10, reserved11;
+	u16		ctl;			/* Continuous Transfer Limit in blocks */
+	u16		speed;			/* Current Speed, in KBps */
+	u16		buffer_size;		/* Buffer Size, in 512 bytes */
+	u8		reserved18, reserved19;
 } idetape_capabilities_page_t;
 
 /*
@@ -790,8 +759,8 @@
 	unsigned	page_code	:6;	/* Page code - Should be 0x30 */
 	unsigned	reserved1_6	:1;
 	unsigned	ps		:1;
-	__u8		page_length;		/* Page Length - Should be 2 */
-	__u8		reserved2;
+	u8		page_length;		/* Page Length - Should be 2 */
+	u8		reserved2;
 	unsigned	play32		:1;
 	unsigned	play32_5	:1;
 	unsigned	reserved2_23	:2;
@@ -843,7 +812,7 @@
  *	of type idetape_tape_t, defined below.
  */
 typedef struct {
-	ide_drive_t *drive;
+	struct ata_device *drive;
 	devfs_handle_t de_r, de_n;
 
 	/*
@@ -861,9 +830,9 @@
 	 *	required since an additional packet command is needed before the
 	 *	retry, to get detailed information on what went wrong.
 	 */
-	idetape_pc_t *pc;			/* Current packet command */
-	idetape_pc_t *failed_pc; 		/* Last failed packet command */
-	idetape_pc_t pc_stack[IDETAPE_PC_STACK];/* Packet command stack */
+	struct atapi_packet_command *pc;			/* Current packet command */
+	struct atapi_packet_command *failed_pc;		/* Last failed packet command */
+	struct atapi_packet_command pc_stack[IDETAPE_PC_STACK];/* Packet command stack */
 	int pc_stack_index;			/* Next free packet command storage space */
 	struct request rq_stack[IDETAPE_PC_STACK];
 	int rq_stack_index;			/* We implement a circular array */
@@ -1248,7 +1217,7 @@
 /*
  *	ATAPI Device Control Register
  */
-typedef union {			
+typedef union {
 	unsigned all			:8;
 	struct {
 		unsigned zero0		:1;	/* Should be set to zero */
@@ -1262,10 +1231,10 @@
 /*
  *	idetape_chrdev_t provides the link between out character device
  *	interface and our block device interface and the corresponding
- *	ide_drive_t structure.
+ *	ata_device structure.
  */
 typedef struct {
-	ide_drive_t *drive;
+	struct ata_device *drive;
 } idetape_chrdev_t;
 
 /*
@@ -1422,7 +1391,7 @@
 
 /*
  *	The variables below are used for the character device interface.
- *	Additional state variables are defined in our ide_drive_t structure.
+ *	Additional state variables are defined in our ata_device structure.
  */
 static idetape_chrdev_t idetape_chrdevs[MAX_HWIFS * MAX_DRIVES];
 static int idetape_chrdev_present = 0;
@@ -1478,21 +1447,13 @@
  *      Function declarations
  *
  */
-static void idetape_onstream_mode_sense_tape_parameter_page(ide_drive_t *drive, int debug);
+static void idetape_onstream_mode_sense_tape_parameter_page(struct ata_device *drive, int debug);
 static int idetape_chrdev_release (struct inode *inode, struct file *filp);
 static void idetape_write_release (struct inode *inode);
 
-/*
- *	Too bad. The drive wants to send us data which we are not ready to accept.
- *	Just throw it away.
- */
-static void idetape_discard_data (ide_drive_t *drive, unsigned int bcount)
-{
-	while (bcount--)
-		IN_BYTE (IDE_DATA_REG);
-}
-
-static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount)
+static void idetape_input_buffers(struct ata_device *drive,
+		struct atapi_packet_command *pc,
+		unsigned int bcount)
 {
 	struct bio *bio = pc->bio;
 	int count;
@@ -1501,7 +1462,7 @@
 #if IDETAPE_DEBUG_BUGS
 		if (bio == NULL) {
 			printk (KERN_ERR "ide-tape: bio == NULL in idetape_input_buffers\n");
-			idetape_discard_data (drive, bcount);
+			atapi_discard_data(drive, bcount);
 			return;
 		}
 #endif
@@ -1518,7 +1479,9 @@
 	pc->bio = bio;
 }
 
-static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount)
+static void idetape_output_buffers(struct ata_device *drive,
+		struct atapi_packet_command *pc,
+		unsigned int bcount)
 {
 	struct bio *bio = pc->bio;
 	int count;
@@ -1529,7 +1492,7 @@
 			printk (KERN_ERR "ide-tape: bio == NULL in idetape_output_buffers\n");
 			return;
 		}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 		count = min(pc->b_count, bcount);
 		atapi_write(drive, bio_data(bio), count);
 		bcount -= count;
@@ -1546,20 +1509,21 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static void idetape_update_buffers (idetape_pc_t *pc)
+static void idetape_update_buffers(struct atapi_packet_command *pc)
 {
 	struct bio *bio = pc->bio;
-	int count, bcount = pc->actually_transferred;
+	int count;
+	unsigned int bcount = pc->actually_transferred;
 
-	if (test_bit (PC_WRITING, &pc->flags))
+	if (test_bit(PC_WRITING, &pc->flags))
 		return;
 	while (bcount) {
-#if IDETAPE_DEBUG_BUGS
+# if IDETAPE_DEBUG_BUGS
 		if (bio == NULL) {
 			printk (KERN_ERR "ide-tape: bio == NULL in idetape_update_buffers\n");
 			return;
 		}
-#endif /* IDETAPE_DEBUG_BUGS */
+# endif
 		count = min(bio->bi_size, bcount);
 		pc->b_count = count;
 		if (pc->b_count == bio->bi_size)
@@ -1568,7 +1532,7 @@
 	}
 	pc->bio = bio;
 }
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 
 /*
  *	idetape_next_pc_storage returns a pointer to a place in which we can
@@ -1576,7 +1540,7 @@
  *	driver. A storage space for a maximum of IDETAPE_PC_STACK packet
  *	commands is allocated at initialization time.
  */
-static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive)
+static struct atapi_packet_command *idetape_next_pc_storage(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -1594,51 +1558,36 @@
  *	Since we queue packet commands in the request queue, we need to
  *	allocate a request, along with the allocation of a packet command.
  */
- 
+
 /**************************************************************
  *                                                            *
  *  This should get fixed to use kmalloc(.., GFP_ATOMIC)      *
  *  followed later on by kfree().   -ml                       *
  *                                                            *
  **************************************************************/
- 
-static struct request *idetape_next_rq_storage (ide_drive_t *drive)
+
+static struct request *idetape_next_rq_storage(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 5)
 		printk (KERN_INFO "ide-tape: rq_stack_index=%d\n",tape->rq_stack_index);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 	if (tape->rq_stack_index==IDETAPE_PC_STACK)
 		tape->rq_stack_index=0;
 	return (&tape->rq_stack[tape->rq_stack_index++]);
 }
 
 /*
- *	idetape_init_pc initializes a packet command.
- */
-static void idetape_init_pc (idetape_pc_t *pc)
-{
-	memset (pc->c, 0, 12);
-	pc->retries = 0;
-	pc->flags = 0;
-	pc->request_transfer = 0;
-	pc->buffer = pc->pc_buffer;
-	pc->buffer_size = IDETAPE_PC_BUFFER_SIZE;
-	pc->bio = NULL;
-	pc->b_data = NULL;
-}
-
-/*
  *	idetape_analyze_error is called on each failed packet command retry
  *	to analyze the request sense. We currently do not utilize this
  *	information.
  */
-static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_result_t *result)
+static void idetape_analyze_error(struct ata_device *drive, idetape_request_sense_result_t *result)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t *pc = tape->failed_pc;
+	struct atapi_packet_command *pc = tape->failed_pc;
 
 	tape->sense     = *result;
 	tape->sense_key = result->sense_key;
@@ -1652,15 +1601,15 @@
 	if (tape->debug_level >= 1)
 		printk (KERN_INFO "ide-tape: pc = %x, sense key = %x, asc = %x, ascq = %x\n",
 				pc->c[0], result->sense_key, result->asc, result->ascq);
-#if IDETAPE_DEBUG_LOG_VERBOSE
+# if IDETAPE_DEBUG_LOG_VERBOSE
 	if (tape->debug_level >= 1)
 		printk (KERN_INFO "ide-tape: pc = %s, sense key = %x, asc = %x, ascq = %x\n",
 			idetape_command_key_verbose((byte) pc->c[0]),
 			result->sense_key,
 			result->asc,
 			result->ascq);
-#endif /* IDETAPE_DEBUG_LOG_VERBOSE */
-#endif /* IDETAPE_DEBUG_LOG */
+# endif
+#endif
 
 	if (tape->onstream && result->sense_key == 2 && result->asc == 0x53 && result->ascq == 2) {
 		clear_bit(PC_DMA_ERROR, &pc->flags);
@@ -1674,30 +1623,30 @@
 	 */
 	if (test_bit (PC_DMA_ERROR, &pc->flags)) {
 		pc->actually_transferred = pc->request_transfer - tape->tape_block_size * ntohl (get_unaligned (&result->information));
-		idetape_update_buffers (pc);
+		idetape_update_buffers(pc);
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 	if (pc->c[0] == IDETAPE_READ_CMD && result->filemark) {
 		pc->error = IDETAPE_ERROR_FILEMARK;
-		set_bit (PC_ABORT, &pc->flags);
+		set_bit(PC_ABORT, &pc->flags);
 	}
 	if (pc->c[0] == IDETAPE_WRITE_CMD) {
 		if (result->eom || (result->sense_key == 0xd && result->asc == 0x0 && result->ascq == 0x2)) {
 			pc->error = IDETAPE_ERROR_EOD;
-			set_bit (PC_ABORT, &pc->flags);
+			set_bit(PC_ABORT, &pc->flags);
 		}
 	}
 	if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) {
 		if (result->sense_key == 8) {
 			pc->error = IDETAPE_ERROR_EOD;
-			set_bit (PC_ABORT, &pc->flags);
+			set_bit(PC_ABORT, &pc->flags);
 		}
 		if (!test_bit (PC_ABORT, &pc->flags) && (tape->onstream || pc->actually_transferred))
 			pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
 	}
 }
 
-static void idetape_abort_pipeline (ide_drive_t *drive)
+static void idetape_abort_pipeline(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage = tape->next_stage;
@@ -1718,7 +1667,7 @@
 /*
  *	idetape_active_next_stage will declare the next stage as "active".
  */
-static void idetape_active_next_stage (ide_drive_t *drive)
+static void idetape_active_next_stage(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage = tape->next_stage;
@@ -1727,13 +1676,13 @@
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_active_next_stage\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 #if IDETAPE_DEBUG_BUGS
 	if (stage == NULL) {
 		printk (KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n");
 		return;
 	}
-#endif /* IDETAPE_DEBUG_BUGS */	
+#endif
 
 	rq->buffer = NULL;
 	rq->bio = stage->bio;
@@ -1749,15 +1698,15 @@
  *	stages, and if we sense that the pipeline is empty, we try to
  *	increase it, until we reach the user compile time memory limit.
  */
-static void idetape_increase_max_pipeline_stages (ide_drive_t *drive)
+static void idetape_increase_max_pipeline_stages(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int increase = (tape->max_pipeline - tape->min_pipeline) / 10;
-	
+
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_increase_max_pipeline_stages\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	tape->max_stages += increase;
 	tape->max_stages = max(tape->max_stages, tape->min_pipeline);
@@ -1798,25 +1747,25 @@
  *	idetape_remove_stage_head removes tape->first_stage from the pipeline.
  *	The caller should avoid race conditions.
  */
-static void idetape_remove_stage_head (ide_drive_t *drive)
+static void idetape_remove_stage_head(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
-	
+
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 #if IDETAPE_DEBUG_BUGS
 	if (tape->first_stage == NULL) {
 		printk (KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n");
-		return;		
+		return;
 	}
 	if (tape->active_stage == tape->first_stage) {
 		printk (KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n");
 		return;
 	}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 	stage = tape->first_stage;
 	tape->first_stage = stage->next;
 	idetape_kfree_stage (tape, stage);
@@ -1828,7 +1777,7 @@
 			printk (KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n");
 		if (tape->nr_stages)
 			printk (KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n");
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 	}
 }
 
@@ -1880,7 +1829,7 @@
 			}
 #endif
 			if (tape->onstream && !tape->raw) {
-				if (tape->first_frame_position == OS_DATA_ENDFRAME1) { 
+				if (tape->first_frame_position == OS_DATA_ENDFRAME1) {
 #if ONSTREAM_DEBUG
 					if (tape->debug_level >= 2)
 						printk("ide-tape: %s: skipping over config parition..\n", tape->name);
@@ -1935,14 +1884,14 @@
 	return 0;
 }
 
-static ide_startstop_t idetape_request_sense_callback(struct ata_device *drive, struct request *rq)
+static void idetape_request_sense_callback(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 	if (!tape->pc->error) {
 		idetape_analyze_error (drive, (idetape_request_sense_result_t *) tape->pc->buffer);
 		idetape_end_request(drive, rq, 1);
@@ -1950,12 +1899,11 @@
 		printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n");
 		idetape_end_request(drive, rq, 0);
 	}
-	return ide_stopped;
 }
 
-static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
+static void idetape_create_request_sense_cmd(struct atapi_packet_command *pc)
 {
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_REQUEST_SENSE_CMD;
 	pc->c[4] = 20;
 	pc->request_transfer = 18;
@@ -1981,7 +1929,7 @@
  *	and wait for their completion using idetape_queue_pc_tail or
  *	idetape_queue_rw_tail.
  */
-static void idetape_queue_pc_head (ide_drive_t *drive,idetape_pc_t *pc,struct request *rq)
+static void idetape_queue_pc_head(struct ata_device *drive, struct atapi_packet_command *pc, struct request *rq)
 {
 	ide_init_drive_cmd (rq);
 	rq->buffer = (char *) pc;
@@ -1994,10 +1942,10 @@
  *	last packet command. We queue a request sense packet command in
  *	the head of the request list.
  */
-static ide_startstop_t idetape_retry_pc (ide_drive_t *drive)
+static void idetape_retry_pc(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t *pc;
+	struct atapi_packet_command *pc;
 	struct request *rq;
 	idetape_error_reg_t error;
 
@@ -2007,7 +1955,6 @@
 	idetape_create_request_sense_cmd (pc);
 	set_bit (IDETAPE_IGNORE_DSC, &tape->flags);
 	idetape_queue_pc_head (drive, pc, rq);
-	return ide_stopped;
 }
 
 /*
@@ -2041,7 +1988,7 @@
 	idetape_status_reg_t status;
 	idetape_bcount_reg_t bcount;
 	idetape_ireason_reg_t ireason;
-	idetape_pc_t *pc = tape->pc;
+	struct atapi_packet_command *pc = tape->pc;
 
 	unsigned int temp;
 	unsigned long cmd_time;
@@ -2052,7 +1999,7 @@
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_pc_intr interrupt handler\n");
-#endif /* IDETAPE_DEBUG_LOG */	
+#endif
 
 	status.all = GET_STAT();					/* Clear the interrupt */
 
@@ -2078,9 +2025,9 @@
 #if IDETAPE_DEBUG_LOG
 		if (tape->debug_level >= 4)
 			printk (KERN_INFO "ide-tape: DMA finished\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 
 	if (!status.b.drq) {						/* No more interrupts */
 		cmd_time = (jiffies - tape->cmd_start_time) * 1000 / HZ;
@@ -2088,7 +2035,7 @@
 #if IDETAPE_DEBUG_LOG
 		if (tape->debug_level >= 2)
 			printk (KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 		clear_bit (PC_DMA_IN_PROGRESS, &pc->flags);
 
 		ide__sti();	/* local CPU only */
@@ -2105,7 +2052,7 @@
 #if IDETAPE_DEBUG_LOG
 			if (tape->debug_level >= 1)
 				printk (KERN_INFO "ide-tape: %s: I/O error, ",tape->name);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 			if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
 				printk (KERN_ERR "ide-tape: I/O error in request sense command\n");
 				return ide_stopped;
@@ -2114,7 +2061,8 @@
 			if (tape->debug_level >= 1)
 				printk(KERN_INFO "ide-tape: [cmd %x]: check condition\n", pc->c[0]);
 #endif
-			return idetape_retry_pc (drive);				/* Retry operation */
+			idetape_retry_pc(drive);				/* Retry operation */
+			return ide_stopped;
 		}
 		pc->error = 0;
 		if (!tape->onstream && test_bit (PC_WAIT_FOR_DSC, &pc->flags) && !status.b.dsc) {	/* Media access command */
@@ -2126,7 +2074,8 @@
 		}
 		if (tape->failed_pc == pc)
 			tape->failed_pc = NULL;
-		return pc->callback(drive, rq);			/* Command finished - Call the callback function */
+		pc->callback(drive, rq);	/* Command finished - Call the callback function */
+		return ide_stopped;
 	}
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
@@ -2136,7 +2085,7 @@
 
 		return ide_stopped;
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 	bcount.b.high = IN_BYTE (IDE_BCOUNTH_REG);			/* Get the number of bytes to transfer */
 	bcount.b.low  = IN_BYTE (IDE_BCOUNTL_REG);			/* on this interrupt */
 	ireason.all   = IN_BYTE (IDE_IREASON_REG);
@@ -2155,14 +2104,14 @@
 		if ( temp > pc->request_transfer) {
 			if (temp > pc->buffer_size) {
 				printk (KERN_ERR "ide-tape: The tape wants to send us more data than expected - discarding data\n");
-				idetape_discard_data (drive, bcount.all);
+				atapi_discard_data (drive, bcount.all);
 				ide_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
 				return ide_started;
 			}
 #if IDETAPE_DEBUG_LOG
 			if (tape->debug_level >= 2)
 				printk (KERN_NOTICE "ide-tape: The tape wants to send us more data than expected - allowing transfer\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 		}
 	}
 	if (test_bit (PC_WRITING, &pc->flags)) {
@@ -2206,11 +2155,11 @@
  *	3.	ATAPI Tape media access commands have immediate status with a
  *		delayed process. In case of a successful initiation of a
  *		media access packet command, the DSC bit will be set when the
- *		actual execution of the command is finished. 
+ *		actual execution of the command is finished.
  *		Since the tape drive will not issue an interrupt, we have to
  *		poll for this event. In this case, we define the request as
  *		"low priority request" by setting rq_status to
- *		IDETAPE_RQ_POSTPONED, 	set a timer to poll for DSC and exit
+ *		IDETAPE_RQ_POSTPONED,	set a timer to poll for DSC and exit
  *		the driver.
  *
  *		ide.c will then give higher priority to requests which
@@ -2231,7 +2180,7 @@
 static ide_startstop_t idetape_transfer_pc(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t *pc = tape->pc;
+	struct atapi_packet_command *pc = tape->pc;
 	idetape_ireason_reg_t ireason;
 	int retries = 100;
 	ide_startstop_t startstop;
@@ -2258,10 +2207,12 @@
 	tape->cmd_start_time = jiffies;
 	ide_set_handler(drive, idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);	/* Set the interrupt routine */
 	atapi_write(drive,pc->c,12);	/* Send the actual packet */
+
 	return ide_started;
 }
 
-static ide_startstop_t idetape_issue_packet_command(struct ata_device *drive, struct request *rq, idetape_pc_t *pc)
+static ide_startstop_t idetape_issue_packet_command(struct ata_device *drive,
+		struct request *rq, struct atapi_packet_command *pc)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_bcount_reg_t bcount;
@@ -2277,7 +2228,7 @@
 		tape->failed_pc = pc;
 	tape->pc = pc;							/* Set the current packet command */
 
-	if (pc->retries > IDETAPE_MAX_PC_RETRIES || test_bit (PC_ABORT, &pc->flags)) {
+	if (pc->retries > IDETAPE_MAX_PC_RETRIES || test_bit(PC_ABORT, &pc->flags)) {
 		/*
 		 *	We will "abort" retrying a packet command in case
 		 *	a legitimate error code was received (crossing a
@@ -2295,12 +2246,13 @@
 			pc->error = IDETAPE_ERROR_GENERAL;		/* Giving up */
 		}
 		tape->failed_pc = NULL;
-		return pc->callback(drive, rq);
+		pc->callback(drive, rq);
+		return ide_stopped;
 	}
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 2)
 		printk (KERN_INFO "ide-tape: Retry number - %d\n", pc->retries);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	pc->retries++;
 	pc->actually_transferred = 0;					/* We haven't transferred any data yet */
@@ -2328,10 +2280,10 @@
 	OUT_BYTE (drive->select.all, IDE_SELECT_REG);
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (dma_ok) {						/* Begin DMA, if necessary */
-		set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
+		set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
 		udma_start(drive, rq);
 	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 	if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) {
 		ide_set_handler(drive, idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL);
 		OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG);
@@ -2345,25 +2297,24 @@
 /*
  *	General packet command callback function.
  */
-static ide_startstop_t idetape_pc_callback(struct ata_device *drive, struct request *rq)
+static void idetape_pc_callback(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	
+
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_pc_callback\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	idetape_end_request(drive, rq, tape->pc->error ? 0 : 1);
-	return ide_stopped;
 }
 
 /*
  *	A mode sense command is used to "sense" tape parameters.
  */
-static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, byte page_code)
+static void idetape_create_mode_sense_cmd(struct atapi_packet_command *pc, byte page_code)
 {
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_MODE_SENSE_CMD;
 	if (page_code != IDETAPE_BLOCK_DESCRIPTOR)
 		pc->c[1] = 8;			/* DBD = 1 - Don't return block descriptors */
@@ -2379,7 +2330,7 @@
 	pc->callback = idetape_pc_callback;
 }
 
-static ide_startstop_t idetape_onstream_buffer_fill_callback (struct ata_device *drive, struct request *rq)
+static void idetape_onstream_buffer_fill_callback (struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -2404,12 +2355,11 @@
 		printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n", tape->cur_frames, tape->max_frames);
 #endif
 	idetape_end_request(drive, rq, tape->pc->error ? 0 : 1);
-	return ide_stopped;
 }
 
-static void idetape_queue_onstream_buffer_fill (ide_drive_t *drive)
+static void idetape_queue_onstream_buffer_fill(struct ata_device *drive)
 {
-	idetape_pc_t *pc;
+	struct atapi_packet_command *pc;
 	struct request *rq;
 
 	pc = idetape_next_pc_storage (drive);
@@ -2419,7 +2369,7 @@
 	idetape_queue_pc_head (drive, pc, rq);
 }
 
-static void calculate_speeds(ide_drive_t *drive)
+static void calculate_speeds(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int full = 125, empty = 75;
@@ -2467,10 +2417,10 @@
 	tape->max_insert_speed = max(tape->max_insert_speed, 500);
 }
 
-static ide_startstop_t idetape_media_access_finished(struct ata_device *drive, struct request *rq)
+static void idetape_media_access_finished(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t *pc = tape->pc;
+	struct atapi_packet_command *pc = tape->pc;
 	idetape_status_reg_t status;
 
 	if (tape->onstream)
@@ -2479,7 +2429,8 @@
 	if (status.b.dsc) {
 		if (status.b.check) {					/* Error detected */
 			printk (KERN_ERR "ide-tape: %s: I/O error, ",tape->name);
-			return idetape_retry_pc (drive);			/* Retry operation */
+			idetape_retry_pc(drive);			/* Retry operation */
+			return;
 		}
 		pc->error = 0;
 		if (tape->failed_pc == pc)
@@ -2488,10 +2439,10 @@
 		pc->error = IDETAPE_ERROR_GENERAL;
 		tape->failed_pc = NULL;
 	}
-	return pc->callback(drive, rq);
+	pc->callback(drive, rq);
 }
 
-static ide_startstop_t idetape_rw_callback(struct ata_device *drive, struct request *rq)
+static void idetape_rw_callback(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int blocks = tape->pc->actually_transferred / tape->tape_block_size;
@@ -2516,7 +2467,7 @@
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_rw_callback\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	tape->first_frame_position += blocks;
 	rq->current_nr_sectors -= blocks;
@@ -2525,14 +2476,15 @@
 		idetape_end_request(drive, rq, 1);
 	else
 		idetape_end_request(drive, rq, tape->pc->error);
-	return ide_stopped;
 }
 
-static void idetape_create_read_cmd (idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct bio *bio)
+static void idetape_create_read_cmd(idetape_tape_t *tape,
+		struct atapi_packet_command *pc,
+		unsigned int length, struct bio *bio)
 {
 	struct bio *p = bio;
 	struct bio_vec *bv = bio_iovec(p);
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_READ_CMD;
 	put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
 	pc->c[1] = 1;
@@ -2549,22 +2501,24 @@
 	if (!tape->onstream) {
 		pc->request_transfer = pc->buffer_size = length * tape->tape_block_size;
 		if (pc->request_transfer == tape->stage_size)
-			set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+			set_bit(PC_DMA_RECOMMENDED, &pc->flags);
 	} else  {
 		if (length) {
 			pc->request_transfer = pc->buffer_size = 32768 + 512;
-			set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+			set_bit(PC_DMA_RECOMMENDED, &pc->flags);
 		} else
 			pc->request_transfer = 0;
 	}
 }
 
-static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct bio *bio)
+static void idetape_create_read_buffer_cmd(idetape_tape_t *tape,
+		struct atapi_packet_command *pc,
+		unsigned int length, struct bio *bio)
 {
 	int size = 32768;
 
 	struct bio *p = bio;
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_READ_BUFFER_CMD;
 	pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK;
 	pc->c[7] = size >> 8;
@@ -2580,11 +2534,13 @@
 	pc->request_transfer = pc->buffer_size = size;
 }
 
-static void idetape_create_write_cmd (idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct bio *bio)
+static void idetape_create_write_cmd(idetape_tape_t *tape,
+		struct atapi_packet_command *pc,
+		unsigned int length, struct bio *bio)
 {
 	struct bio *p = bio;
 	struct bio_vec *bv= bio_iovec(p);
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_WRITE_CMD;
 	put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
 	pc->c[1] = 1;
@@ -2619,16 +2575,16 @@
 static ide_startstop_t idetape_do_request(struct ata_device *drive, struct request *rq, sector_t block)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t *pc;
+	struct atapi_packet_command *pc;
 	struct request *postponed_rq = tape->postponed_rq;
 	idetape_status_reg_t status;
 
 #if IDETAPE_DEBUG_LOG
-	if (tape->debug_level >= 5)
-/*		printk (KERN_INFO "ide-tape: rq_status: %d, rq_dev: %u, cmd: %ld, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->flags,rq->errors); */
+/*	if (tape->debug_level >= 5)
+		printk (KERN_INFO "ide-tape: rq_status: %d, rq_dev: %u, cmd: %ld, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->flags,rq->errors); */
 	if (tape->debug_level >= 2)
 		printk (KERN_INFO "ide-tape: sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	if (!IDETAPE_RQ_CMD (rq->flags)) {
 		/*
@@ -2652,7 +2608,7 @@
 			idetape_end_request(drive, rq, 0);
 			return ide_stopped;
 		}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 
 	tape->postponed_rq = NULL;
 
@@ -2788,7 +2744,8 @@
 			idetape_end_request(drive, rq, IDETAPE_ERROR_EOD);
 			return ide_stopped;
 		case IDETAPE_PC_RQ1:
-			pc = (idetape_pc_t *) rq->buffer;
+			/* FIXME: --mdcki */
+			pc = (struct atapi_packet_command *) rq->buffer;
 			rq->flags = IDETAPE_PC_RQ2;
 			break;
 		case IDETAPE_PC_RQ2:
@@ -2912,7 +2869,8 @@
 	return __idetape_kmalloc_stage (tape, 0, 0);
 }
 
-static void idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t *stage, const char *buf, int n)
+static void idetape_copy_stage_from_user(idetape_tape_t *tape, idetape_stage_t *stage,
+		const char *buf, unsigned int n)
 {
 	struct bio *bio = tape->bio;
 	int count;
@@ -2949,7 +2907,7 @@
 			printk (KERN_ERR "ide-tape: bio == NULL in idetape_copy_stage_to_user\n");
 			return;
 		}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 		count = min(tape->b_count, n);
 		copy_to_user (buf, tape->b_data, count);
 		n -= count;
@@ -2969,7 +2927,7 @@
 static void idetape_init_merge_stage (idetape_tape_t *tape)
 {
 	struct bio *bio = tape->merge_stage->bio;
-	
+
 	tape->bio = bio;
 	if (tape->chrdev_direction == idetape_direction_write)
 		atomic_set(&bio->bi_cnt, 0);
@@ -2993,15 +2951,15 @@
 /*
  *	idetape_add_stage_tail adds a new stage at the end of the pipeline.
  */
-static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage)
+static void idetape_add_stage_tail(struct ata_device *drive, idetape_stage_t *stage)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
-	
+
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_add_stage_tail\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 	spin_lock_irqsave(&tape->spinlock, flags);
 	stage->next=NULL;
 	if (tape->last_stage != NULL)
@@ -3019,7 +2977,7 @@
 /*
  * Initialize the OnStream AUX
  */
-static void idetape_init_stage (ide_drive_t *drive, idetape_stage_t *stage, int frame_type, int logical_blk_num)
+static void idetape_init_stage(struct ata_device *drive, idetape_stage_t *stage, int frame_type, int logical_blk_num)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	os_aux_t *aux = stage->aux;
@@ -3069,7 +3027,7 @@
 		else
 			dat->dat_list[0].flags = OS_DAT_FLAGS_DATA;
 		dat->dat_list[0].reserved = 0;
-	} 
+	}
 	aux->filemark_cnt = ntohl(tape->filemark_cnt);		/* shouldn't this be htonl ?? */
 	aux->phys_fm = ntohl(0xffffffff);			/* shouldn't this be htonl ?? */
 	aux->last_mark_addr = ntohl(tape->last_mark_addr);	/* shouldn't this be htonl ?? */
@@ -3082,7 +3040,7 @@
  *	The caller should ensure that the request will not be serviced
  *	before we install the completion (usually by disabling interrupts).
  */
-static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq)
+static void idetape_wait_for_request(struct ata_device *drive, struct request *rq)
 {
 	DECLARE_COMPLETION(wait);
 	idetape_tape_t *tape = drive->driver_data;
@@ -3102,15 +3060,15 @@
 	spin_lock_irq(&tape->spinlock);
 }
 
-static ide_startstop_t idetape_read_position_callback(struct ata_device *drive, struct request *rq)
+static void idetape_read_position_callback(struct ata_device *drive, struct request *rq)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_read_position_result_t *result;
-	
+
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_read_position_callback\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	if (!tape->pc->error) {
 		result = (idetape_read_position_result_t *) tape->pc->buffer;
@@ -3119,7 +3077,7 @@
 			printk (KERN_INFO "ide-tape: BOP - %s\n",result->bop ? "Yes":"No");
 		if (tape->debug_level >= 2)
 			printk (KERN_INFO "ide-tape: EOP - %s\n",result->eop ? "Yes":"No");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 		if (result->bpu) {
 			printk (KERN_INFO "ide-tape: Block location is unknown to the tape\n");
 			clear_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
@@ -3128,7 +3086,7 @@
 #if IDETAPE_DEBUG_LOG
 			if (tape->debug_level >= 2)
 				printk (KERN_INFO "ide-tape: Block Location - %u\n", ntohl (result->first_block));
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 			tape->partition = result->partition;
 			tape->first_frame_position = ntohl (result->first_block);
 			tape->last_frame_position = ntohl (result->last_block);
@@ -3139,7 +3097,6 @@
 	} else {
 		idetape_end_request(drive, rq, 0);
 	}
-	return ide_stopped;
 }
 
 /*
@@ -3150,22 +3107,23 @@
  *			if write_filemark=0.
  *
  */
-static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark)
+static void idetape_create_write_filemark_cmd(struct ata_device *drive,
+		struct atapi_packet_command *pc,int write_filemark)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD;
 	if (tape->onstream)
 		pc->c[1] = 1; /* Immed bit */
 	pc->c[4] = write_filemark;  /* not used for OnStream ?? */
-	set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+	set_bit(PC_WAIT_FOR_DSC, &pc->flags);
 	pc->callback = idetape_pc_callback;
 }
 
-static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc)
+static void idetape_create_test_unit_ready_cmd(struct atapi_packet_command *pc)
 {
-	idetape_init_pc(pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD;
 	pc->callback = idetape_pc_callback;
 }
@@ -3190,21 +3148,23 @@
  *	the request to the request list without waiting for it to be serviced !
  *	In that case, we usually use idetape_queue_pc_head.
  */
-static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc)
+static int __idetape_queue_pc_tail(struct ata_device *drive, struct atapi_packet_command *pc)
 {
 	struct request rq;
 
 	ide_init_drive_cmd (&rq);
+	/* FIXME: --mdcki */
 	rq.buffer = (char *) pc;
 	rq.flags = IDETAPE_PC_RQ1;
 	return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
 
-static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd)
+static void idetape_create_load_unload_cmd(struct ata_device *drive,
+		struct atapi_packet_command *pc, int cmd)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD;
 	pc->c[4] = cmd;
 	if (tape->onstream) {
@@ -3216,10 +3176,10 @@
 	pc->callback = idetape_pc_callback;
 }
 
-static int idetape_wait_ready (ide_drive_t *drive, unsigned long long timeout)
+static int idetape_wait_ready(struct ata_device *drive, unsigned long long timeout)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 
 	/*
 	 * Wait for the tape to become ready
@@ -3239,12 +3199,12 @@
 		if (!(tape->sense_key == 2 && tape->asc == 4 && (tape->ascq == 1 || tape->ascq == 8)))
 			break;
 		current->state = TASK_INTERRUPTIBLE;
-  		schedule_timeout(HZ / 10);
+		schedule_timeout(HZ / 10);
 	}
 	return -EIO;
 }
 
-static int idetape_queue_pc_tail (ide_drive_t *drive,idetape_pc_t *pc)
+static int idetape_queue_pc_tail(struct ata_device *drive, struct atapi_packet_command *pc)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int rc;
@@ -3258,9 +3218,9 @@
 	return rc;
 }
 
-static int idetape_flush_tape_buffers (ide_drive_t *drive)
+static int idetape_flush_tape_buffers(struct ata_device *drive)
 {
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	int rc;
 
 	idetape_create_write_filemark_cmd(drive, &pc, 0);
@@ -3270,24 +3230,24 @@
 	return 0;
 }
 
-static void idetape_create_read_position_cmd (idetape_pc_t *pc)
+static void idetape_create_read_position_cmd(struct atapi_packet_command *pc)
 {
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_READ_POSITION_CMD;
 	pc->request_transfer = 20;
 	pc->callback = idetape_read_position_callback;
 }
 
-static int idetape_read_position (ide_drive_t *drive)
+static int idetape_read_position(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	int position;
 
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 	    printk (KERN_INFO "ide-tape: Reached idetape_read_position\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 #ifdef NO_LONGER_REQUIRED
 	idetape_flush_tape_buffers(drive);
@@ -3311,11 +3271,13 @@
 	return position;
 }
 
-static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, byte partition, int skip)
+static void idetape_create_locate_cmd(struct ata_device *drive,
+		struct atapi_packet_command *pc,
+		unsigned int block, u8 partition, int skip)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_LOCATE_CMD;
 	if (tape->onstream)
 		pc->c[1] = 1; /* Immediate bit */
@@ -3334,21 +3296,23 @@
 	pc->callback = idetape_pc_callback;
 }
 
-static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent)
+static int idetape_create_prevent_cmd(struct ata_device *drive,
+		struct atapi_packet_command *pc, int prevent)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
 	if (!tape->capabilities.lock)
 		return 0;
 
-	idetape_init_pc(pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_PREVENT_CMD;
 	pc->c[4] = prevent;
 	pc->callback = idetape_pc_callback;
+
 	return 1;
 }
 
-static int __idetape_discard_read_pipeline (ide_drive_t *drive)
+static int __idetape_discard_read_pipeline(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
@@ -3387,13 +3351,13 @@
  *
  *	Like all higher level operations, we queue the commands at the tail
  *	of the request queue and wait for their completion.
- *	
+ *
  */
-static int idetape_position_tape (ide_drive_t *drive, unsigned int block, byte partition, int skip)
+static int idetape_position_tape(struct ata_device *drive, unsigned int block, byte partition, int skip)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int retval;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 
 	if (tape->chrdev_direction == idetape_direction_read)
 		__idetape_discard_read_pipeline(drive);
@@ -3407,7 +3371,7 @@
 	return (idetape_queue_pc_tail (drive, &pc));
 }
 
-static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_position)
+static void idetape_discard_read_pipeline(struct ata_device *drive, int restore_position)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int cnt;
@@ -3428,9 +3392,9 @@
 	}
 }
 
-static void idetape_update_stats (ide_drive_t *drive)
+static void idetape_update_stats(struct ata_device *drive)
 {
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 
 	idetape_create_mode_sense_cmd (&pc, IDETAPE_BUFFER_FILLING_PAGE);
 	pc.callback = idetape_onstream_buffer_fill_callback;
@@ -3441,7 +3405,7 @@
  *	idetape_queue_rw_tail generates a read/write request for the block
  *	device interface and wait for it to be serviced.
  */
-static int idetape_queue_rw_tail (ide_drive_t *drive, int cmd, int blocks, struct bio *bio)
+static int idetape_queue_rw_tail(struct ata_device *drive, int cmd, int blocks, struct bio *bio)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	struct request rq;
@@ -3481,7 +3445,7 @@
  * of the write error recovery mechanism for old OnStream
  * firmware revisions.
  */
-static void idetape_onstream_read_back_buffer (ide_drive_t *drive)
+static void idetape_onstream_read_back_buffer(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int frames, i, logical_blk_num;
@@ -3535,7 +3499,7 @@
 /*
  * Error recovery algorithm for the OnStream tape.
  */
-static void idetape_onstream_write_error_recovery (ide_drive_t *drive)
+static void idetape_onstream_write_error_recovery(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned int block;
@@ -3545,7 +3509,7 @@
 			tape->name, ntohl(tape->sense.information), tape->logical_blk_num,
 			tape->first_frame_position, tape->last_frame_position,
 			tape->blocks_in_buffer, tape->nr_stages,
- 			(ntohl(tape->sense.command_specific) >> 16) & 0xff );
+			(ntohl(tape->sense.command_specific) >> 16) & 0xff );
 		block = ntohl(tape->sense.information) + ((ntohl(tape->sense.command_specific) >> 16) & 0xff);
 		idetape_update_stats(drive);
 		printk(KERN_ERR "ide-tape: %s: relocating %d buffered logical blocks to physical block %u\n", tape->name, tape->cur_frames, block);
@@ -3572,7 +3536,7 @@
 #endif
 		idetape_flush_tape_buffers(drive);
 		block = idetape_read_position(drive);
-		if (block != OS_DATA_ENDFRAME1)  
+		if (block != OS_DATA_ENDFRAME1)
 			printk(KERN_ERR "ide-tape: warning, current position %d, expected %d\n", block, OS_DATA_ENDFRAME1);
 		idetape_position_tape(drive, 0xbb8, 0, 0); /* 3000 */
 	}
@@ -3583,7 +3547,7 @@
  *	idetape_insert_pipeline_into_queue is used to start servicing the
  *	pipeline stages, starting from tape->next_stage.
  */
-static void idetape_insert_pipeline_into_queue (ide_drive_t *drive)
+static void idetape_insert_pipeline_into_queue(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -3598,30 +3562,31 @@
 	}
 }
 
-static void idetape_create_inquiry_cmd (idetape_pc_t *pc)
+static void idetape_create_inquiry_cmd(struct atapi_packet_command *pc)
 {
-	idetape_init_pc(pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_INQUIRY_CMD;
 	pc->c[4] = pc->request_transfer = 254;
 	pc->callback = idetape_pc_callback;
 }
 
-static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc)
+static void idetape_create_rewind_cmd(struct ata_device *drive,
+		struct atapi_packet_command *pc)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_REWIND_CMD;
 	if (tape->onstream)
 		pc->c[1] = 1;
-	set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+	set_bit(PC_WAIT_FOR_DSC, &pc->flags);
 	pc->callback = idetape_pc_callback;
 }
 
-static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length)
+static void idetape_create_mode_select_cmd(struct atapi_packet_command *pc, int length)
 {
-	idetape_init_pc (pc);
-	set_bit (PC_WRITING, &pc->flags);
+	atapi_init_pc(pc);
+	set_bit(PC_WRITING, &pc->flags);
 	pc->c[0] = IDETAPE_MODE_SELECT_CMD;
 	pc->c[1] = 0x10;
 	put_unaligned (htons(length), (unsigned short *) &pc->c[3]);
@@ -3629,29 +3594,29 @@
 	pc->callback = idetape_pc_callback;
 }
 
-static void idetape_create_erase_cmd (idetape_pc_t *pc)
+static void idetape_create_erase_cmd(struct atapi_packet_command *pc)
 {
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_ERASE_CMD;
 	pc->c[1] = 1;
-	set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+	set_bit(PC_WAIT_FOR_DSC, &pc->flags);
 	pc->callback = idetape_pc_callback;
 }
 
-static void idetape_create_space_cmd (idetape_pc_t *pc,int count,byte cmd)
+static void idetape_create_space_cmd(struct atapi_packet_command *pc, int count, u8 cmd)
 {
-	idetape_init_pc (pc);
+	atapi_init_pc(pc);
 	pc->c[0] = IDETAPE_SPACE_CMD;
 	put_unaligned (htonl (count), (unsigned int *) &pc->c[1]);
 	pc->c[1] = cmd;
-	set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+	set_bit(PC_WAIT_FOR_DSC, &pc->flags);
 	pc->callback = &idetape_pc_callback;
 }
 
 /*
  * Verify that we have the correct tape frame
  */
-static int idetape_verify_stage (ide_drive_t *drive, idetape_stage_t *stage, int logical_blk_num, int quiet)
+static int idetape_verify_stage(struct ata_device *drive, idetape_stage_t *stage, int logical_blk_num, int quiet)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	os_aux_t *aux = stage->aux;
@@ -3724,7 +3689,7 @@
 	return 1;
 }
 
-static void idetape_wait_first_stage (ide_drive_t *drive)
+static void idetape_wait_first_stage(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
@@ -3748,7 +3713,7 @@
  *	3.	If we still can't allocate a stage, fallback to
  *		non-pipelined operation mode for this request.
  */
-static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
+static int idetape_add_chrdev_write_request(struct ata_device *drive, int blocks)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *new_stage;
@@ -3836,7 +3801,7 @@
  *	idetape_wait_for_pipeline will wait until all pending pipeline
  *	requests are serviced. Typically called on device close.
  */
-static void idetape_wait_for_pipeline (ide_drive_t *drive)
+static void idetape_wait_for_pipeline(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
@@ -3850,12 +3815,12 @@
 	}
 }
 
-static void idetape_empty_write_pipeline (ide_drive_t *drive)
+static void idetape_empty_write_pipeline(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	int blocks, i, min;
+	int blocks, min;
 	struct bio *bio;
-	
+
 #if IDETAPE_DEBUG_BUGS
 	if (tape->chrdev_direction != idetape_direction_write) {
 		printk (KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n");
@@ -3865,10 +3830,12 @@
 		printk (KERN_ERR "ide-tape: bug: merge_buffer too big\n");
 		tape->merge_stage_size = tape->stage_size;
 	}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 	if (tape->merge_stage_size) {
 		blocks = tape->merge_stage_size / tape->tape_block_size;
 		if (tape->merge_stage_size % tape->tape_block_size) {
+			unsigned int i;
+
 			blocks++;
 			i = tape->tape_block_size - tape->merge_stage_size % tape->tape_block_size;
 			bio = tape->bio->bi_next;
@@ -3916,7 +3883,7 @@
 #endif /* IDETAPE_DEBUG_BUGS */
 }
 
-static void idetape_restart_speed_control (ide_drive_t *drive)
+static void idetape_restart_speed_control(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -3931,7 +3898,7 @@
 	tape->controlled_previous_head_time = tape->uncontrolled_previous_head_time = jiffies;
 }
 
-static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
+static int idetape_initiate_read(struct ata_device *drive, int max_stages)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *new_stage;
@@ -4000,7 +3967,7 @@
 	return 0;
 }
 
-static int idetape_get_logical_blk (ide_drive_t *drive, int logical_blk_num, int max_stages, int quiet)
+static int idetape_get_logical_blk(struct ata_device *drive, int logical_blk_num, int max_stages, int quiet)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
@@ -4071,7 +4038,7 @@
  *	to service a character device read request and add read-ahead
  *	requests to our pipeline.
  */
-static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks)
+static int idetape_add_chrdev_read_request(struct ata_device *drive,int blocks)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned long flags;
@@ -4145,13 +4112,15 @@
 	return (bytes_read);
 }
 
-static void idetape_pad_zeros (ide_drive_t *drive, int bcount)
+static void idetape_pad_zeros(struct ata_device *drive, int bcount)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	struct bio *bio;
-	int count, blocks;
-	
+	int blocks;
+
 	while (bcount) {
+		unsigned int count;
+
 		bio = tape->merge_stage->bio;
 		count = min(tape->stage_size, bcount);
 		bcount -= count;
@@ -4166,7 +4135,7 @@
 	}
 }
 
-static int idetape_pipeline_size (ide_drive_t *drive)
+static int idetape_pipeline_size(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
@@ -4190,17 +4159,17 @@
  *	Rewinds the tape to the Beginning Of the current Partition (BOP).
  *
  *	We currently support only one partition.
- */ 
-static int idetape_rewind_tape (ide_drive_t *drive)
+ */
+static int idetape_rewind_tape(struct ata_device *drive)
 {
 	int retval;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_tape_t *tape = drive->driver_data;
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 2)
 		printk (KERN_INFO "ide-tape: Reached idetape_rewind_tape\n");
-#endif /* IDETAPE_DEBUG_LOG */	
-	
+#endif
+
 	idetape_create_rewind_cmd (drive, &pc);
 	retval = idetape_queue_pc_tail (drive, &pc);
 	if (retval)
@@ -4221,16 +4190,16 @@
  *	mtio.h compatible commands should be issued to the character device
  *	interface.
  */
-static int idetape_blkdev_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file,
+static int idetape_blkdev_ioctl(struct ata_device *drive, struct inode *inode, struct file *file,
 				 unsigned int cmd, unsigned long arg)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_config_t config;
 
-#if IDETAPE_DEBUG_LOG	
+#if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 4)
 		printk (KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n");
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 	switch (cmd) {
 		case 0x0340:
 			if (copy_from_user ((char *) &config, (char *) arg, sizeof (idetape_config_t)))
@@ -4240,7 +4209,7 @@
 			break;
 		case 0x0350:
 			config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency;
-			config.nr_stages = tape->max_stages; 
+			config.nr_stages = tape->max_stages;
 			if (copy_to_user ((char *) arg, (char *) &config, sizeof (idetape_config_t)))
 				return -EFAULT;
 			break;
@@ -4255,7 +4224,7 @@
  *	However, we still allow opening it so that we can issue general
  *	ide driver configuration ioctl's, such as the interrupt unmask feature.
  */
-static int idetape_blkdev_open (struct inode *inode, struct file *filp, ide_drive_t *drive)
+static int idetape_blkdev_open(struct inode *inode, struct file *filp, struct ata_device *drive)
 {
 	MOD_INC_USE_COUNT;
 #if ONSTREAM_DEBUG
@@ -4264,7 +4233,7 @@
 	return 0;
 }
 
-static void idetape_blkdev_release (struct inode *inode, struct file *filp, ide_drive_t *drive)
+static void idetape_blkdev_release(struct inode *inode, struct file *filp, struct ata_device *drive)
 {
 	MOD_DEC_USE_COUNT;
 #if ONSTREAM_DEBUG
@@ -4275,7 +4244,7 @@
 /*
  *	Character device interface functions
  */
-static ide_drive_t *get_drive_ptr (kdev_t i_rdev)
+static struct ata_device *get_drive_ptr (kdev_t i_rdev)
 {
 	unsigned int i = minor(i_rdev) & ~0xc0;
 
@@ -4284,7 +4253,7 @@
 	return (idetape_chrdevs[i].drive);
 }
 
-static int idetape_onstream_space_over_filemarks_backward (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_onstream_space_over_filemarks_backward(struct ata_device *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int cnt = 0;
@@ -4328,7 +4297,7 @@
  *
  * Just scans for the filemark sequentially.
  */
-static int idetape_onstream_space_over_filemarks_forward_slow (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_onstream_space_over_filemarks_forward_slow(struct ata_device *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int cnt = 0;
@@ -4371,7 +4340,7 @@
 /*
  * Fast linux specific version of OnStream FSF
  */
-static int idetape_onstream_space_over_filemarks_forward_fast (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_onstream_space_over_filemarks_forward_fast(struct ata_device *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int cnt = 0, next_mark_addr;
@@ -4455,10 +4424,10 @@
  *	the filemark is in our internal pipeline even if the tape doesn't
  *	support spacing over filemarks in the reverse direction.
  */
-static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_space_over_filemarks(struct ata_device *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	unsigned long flags;
 	int retval,count=0;
 	int speed_control;
@@ -4563,7 +4532,7 @@
 				    size_t count, loff_t *ppos)
 {
 	struct inode *inode = file->f_dentry->d_inode;
-	ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+	struct ata_device *drive = get_drive_ptr (inode->i_rdev);
 	idetape_tape_t *tape = drive->driver_data;
 	ssize_t bytes_read,temp, actually_read = 0, rc;
 
@@ -4632,7 +4601,7 @@
 	return actually_read;
 }
 
-static void idetape_update_last_marker (ide_drive_t *drive, int last_mark_addr, int next_mark_addr)
+static void idetape_update_last_marker(struct ata_device *drive, int last_mark_addr, int next_mark_addr)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
@@ -4686,7 +4655,7 @@
 	return;
 }
 
-static void idetape_write_filler (ide_drive_t *drive, int block, int cnt)
+static void idetape_write_filler(struct ata_device *drive, int block, int cnt)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
@@ -4717,7 +4686,7 @@
 	__idetape_kfree_stage (stage);
 }
 
-static void __idetape_write_header (ide_drive_t *drive, int block, int cnt)
+static void __idetape_write_header(struct ata_device *drive, int block, int cnt)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
@@ -4752,7 +4721,7 @@
 	idetape_flush_tape_buffers (drive);
 }
 
-static void idetape_write_header (ide_drive_t *drive, int locate_eod)
+static void idetape_write_header(struct ata_device *drive, int locate_eod)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -4774,11 +4743,11 @@
 	}
 }
 
-static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t idetape_chrdev_write(struct file *file, const char *buf,
+		size_t count, loff_t *ppos)
 {
 	struct inode *inode = file->f_dentry->d_inode;
-	ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+	struct ata_device *drive = get_drive_ptr (inode->i_rdev);
 	idetape_tape_t *tape = drive->driver_data;
 	ssize_t retval, actually_written = 0;
 	int position;
@@ -4791,7 +4760,7 @@
 #if IDETAPE_DEBUG_LOG
 	if (tape->debug_level >= 3)
 		printk (KERN_INFO "ide-tape: Reached idetape_chrdev_write, count %Zd\n", count);
-#endif /* IDETAPE_DEBUG_LOG */
+#endif
 
 	if (tape->onstream) {
 		if (count != tape->tape_block_size) {
@@ -4821,7 +4790,7 @@
 			printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n");
 			tape->merge_stage_size = 0;
 		}
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
 		if ((tape->merge_stage = __idetape_kmalloc_stage (tape, 0, 0)) == NULL)
 			return -ENOMEM;
 		tape->chrdev_direction = idetape_direction_write;
@@ -4914,11 +4883,11 @@
 	return (actually_written);
 }
 
-static int idetape_write_filemark (ide_drive_t *drive)
+static int idetape_write_filemark(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int last_mark_addr;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 
 	if (!tape->onstream) {
 		idetape_create_write_filemark_cmd(drive, &pc, 1);	/* Write a filemark */
@@ -4945,7 +4914,7 @@
 	return 0;
 }
 
-static void idetape_write_eod (ide_drive_t *drive)
+static void idetape_write_eod(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -4962,7 +4931,7 @@
 	return;
 }
 
-int idetape_seek_logical_blk (ide_drive_t *drive, int logical_blk_num)
+int idetape_seek_logical_blk(struct ata_device *drive, int logical_blk_num)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int estimated_address = logical_blk_num + 20;
@@ -5022,7 +4991,7 @@
  *		In this case, MTFSFM is also usually not supported (it is
  *		supported in the rare case in which we crossed the filemark
  *		during our read-ahead pipelined operation mode).
- *		
+ *
  *	MTWEOF	-	Writes mt_count filemarks. Tape is positioned after
  *			the last written filemark.
  *
@@ -5042,7 +5011,7 @@
  *
  *	MTERASE	-	Erases tape.
  *
- *	MTSETBLK - 	Sets the user block size to mt_count bytes. If
+ *	MTSETBLK -	Sets the user block size to mt_count bytes. If
  *			mt_count is 0, we will attempt to autodetect
  *			the block size.
  *
@@ -5050,21 +5019,21 @@
  *			each block is assumed to contain which user_block_size
  *			bytes.
  *
- *	MTSETPART - 	Switches to another tape partition.
+ *	MTSETPART -	Switches to another tape partition.
  *
- *	MTLOCK - 	Locks the tape door.
+ *	MTLOCK -	Locks the tape door.
  *
- *	MTUNLOCK - 	Unlocks the tape door.
+ *	MTUNLOCK -	Unlocks the tape door.
  *
  *	The following commands are currently not supported:
  *
  *	MTFSS, MTBSS, MTWSM, MTSETDENSITY,
  *	MTSETDRVBUFFER, MT_ST_BOOLEANS, MT_ST_WRITE_THRESHOLD.
  */
-static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_mtioctop(struct ata_device *drive,short mt_op,int mt_count)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	int i,retval;
 
 #if IDETAPE_DEBUG_LOG
@@ -5237,7 +5206,7 @@
  */
 static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
 {
-	ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+	struct ata_device *drive = get_drive_ptr (inode->i_rdev);
 	idetape_tape_t *tape = drive->driver_data;
 	struct mtop mtop;
 	struct mtget mtget;
@@ -5303,7 +5272,7 @@
 	}
 }
 
-static int __idetape_analyze_headers (ide_drive_t *drive, int block)
+static int __idetape_analyze_headers(struct ata_device *drive, int block)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	idetape_stage_t *stage;
@@ -5369,7 +5338,7 @@
 	return 1;
 }
 
-static int idetape_analyze_headers (ide_drive_t *drive)
+static int idetape_analyze_headers(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int position, block;
@@ -5401,15 +5370,15 @@
  */
 static int idetape_chrdev_open (struct inode *inode, struct file *filp)
 {
-	ide_drive_t *drive;
+	struct ata_device *drive;
 	idetape_tape_t *tape;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	unsigned int minor=minor(inode->i_rdev);
-			
+
 #if IDETAPE_DEBUG_LOG
 	printk (KERN_INFO "ide-tape: Reached idetape_chrdev_open\n");
-#endif /* IDETAPE_DEBUG_LOG */
-	
+#endif
+
 	if ((drive = get_drive_ptr (inode->i_rdev)) == NULL)
 		return -ENXIO;
 	tape = drive->driver_data;
@@ -5459,7 +5428,7 @@
 
 static void idetape_write_release (struct inode *inode)
 {
-	ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+	struct ata_device *drive = get_drive_ptr (inode->i_rdev);
 	idetape_tape_t *tape = drive->driver_data;
 	unsigned int minor=minor(inode->i_rdev);
 
@@ -5484,9 +5453,9 @@
  */
 static int idetape_chrdev_release (struct inode *inode, struct file *filp)
 {
-	ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+	struct ata_device *drive = get_drive_ptr (inode->i_rdev);
 	idetape_tape_t *tape;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	unsigned int minor=minor(inode->i_rdev);
 
 	tape = drive->driver_data;
@@ -5529,9 +5498,9 @@
  *	1	If the tape can be supported by us, based on the information
  *		we have so far.
  *
- *	0 	If this tape driver is not currently supported by us.
+ *	0	If this tape driver is not currently supported by us.
  */
-static int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id)
+static int idetape_identify_device(struct ata_device *drive,struct hd_driveid *id)
 {
 	struct idetape_id_gcw gcw;
 #if IDETAPE_DEBUG_INFO
@@ -5653,9 +5622,9 @@
 /*
  * Notify vendor ID to the OnStream tape drive
  */
-static void idetape_onstream_set_vendor (ide_drive_t *drive, char *vendor)
+static void idetape_onstream_set_vendor(struct ata_device *drive, char *vendor)
 {
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_mode_parameter_header_t *header;
 
 	idetape_create_mode_select_cmd(&pc, sizeof(*header) + 8);
@@ -5680,9 +5649,9 @@
  * Various unused OnStream commands
  */
 #if ONSTREAM_DEBUG
-static void idetape_onstream_set_retries (ide_drive_t *drive, int retries)
+static void idetape_onstream_set_retries(struct ata_device *drive, int retries)
 {
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 
 	idetape_create_mode_select_cmd(&pc, sizeof(idetape_mode_parameter_header_t) + 4);
 	pc.buffer[0] = 3 + 4;
@@ -5701,9 +5670,9 @@
 /*
  * Configure 32.5KB block size.
  */
-static void idetape_onstream_configure_block_size (ide_drive_t *drive)
+static void idetape_onstream_configure_block_size(struct ata_device *drive)
 {
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_mode_parameter_header_t *header;
 	idetape_block_size_page_t *bs;
 
@@ -5747,13 +5716,13 @@
 /*
  * Use INQUIRY to get the firmware revision
  */
-static void idetape_get_inquiry_results (ide_drive_t *drive)
+static void idetape_get_inquiry_results(struct ata_device *drive)
 {
 	char *r;
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_inquiry_result_t *inquiry;
-	
+
 	idetape_create_inquiry_cmd(&pc);
 	if (idetape_queue_pc_tail (drive, &pc)) {
 		printk (KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", tape->name);
@@ -5777,7 +5746,7 @@
 /*
  * Configure the OnStream ATAPI tape drive for default operation
  */
-static void idetape_configure_onstream (ide_drive_t *drive)
+static void idetape_configure_onstream(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 
@@ -5801,13 +5770,13 @@
  *	idetape_get_mode_sense_parameters asks the tape about its various
  *	parameters. This may work for other drives to???
  */
-static void idetape_onstream_mode_sense_tape_parameter_page(ide_drive_t *drive, int debug)
+static void idetape_onstream_mode_sense_tape_parameter_page(struct ata_device *drive, int debug)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_mode_parameter_header_t *header;
 	onstream_tape_paramtr_page_t *prm;
-	
+
 	idetape_create_mode_sense_cmd (&pc, IDETAPE_PARAMTR_PAGE);
 	if (idetape_queue_pc_tail (drive, &pc)) {
 		printk (KERN_ERR "ide-tape: Can't get tape parameters page - probably no tape inserted in onstream drive\n");
@@ -5830,13 +5799,13 @@
  *	parameters. In particular, we will adjust our data transfer buffer
  *	size to the recommended value as returned by the tape.
  */
-static void idetape_get_mode_sense_results (ide_drive_t *drive)
+static void idetape_get_mode_sense_results(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_mode_parameter_header_t *header;
 	idetape_capabilities_page_t *capabilities;
-	
+
 	idetape_create_mode_sense_cmd (&pc, IDETAPE_CAPABILITIES_PAGE);
 	if (idetape_queue_pc_tail (drive, &pc)) {
 		printk (KERN_ERR "ide-tape: Can't get tape parameters - assuming some default values\n");
@@ -5876,7 +5845,7 @@
 	printk (KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type);
 	printk (KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp);
 	printk (KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl);
-	
+
 	printk (KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n");
 	printk (KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code);
 	printk (KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length);
@@ -5895,7 +5864,7 @@
 	printk (KERN_INFO "ide-tape: Supports 32768 bytes block size / Restricted byte count for PIO transfers - %s\n",capabilities->blk32768 ? "Yes":"No");
 	printk (KERN_INFO "ide-tape: Maximum supported speed in KBps - %d\n",capabilities->max_speed);
 	printk (KERN_INFO "ide-tape: Continuous transfer limits in blocks - %d\n",capabilities->ctl);
-	printk (KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed);	
+	printk (KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed);
 	printk (KERN_INFO "ide-tape: Buffer size - %d\n",capabilities->buffer_size*512);
 #endif /* IDETAPE_DEBUG_INFO */
 }
@@ -5904,14 +5873,14 @@
  *	ide_get_blocksize_from_block_descriptor does a mode sense page 0 with block descriptor
  *	and if it succeeds sets the tape block size with the reported value
  */
-static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive)
+static void idetape_get_blocksize_from_block_descriptor(struct ata_device *drive)
 {
 
 	idetape_tape_t *tape = drive->driver_data;
-	idetape_pc_t pc;
+	struct atapi_packet_command pc;
 	idetape_mode_parameter_header_t *header;
 	idetape_parameter_block_descriptor_t *block_descrp;
-	
+
 	idetape_create_mode_sense_cmd (&pc, IDETAPE_BLOCK_DESCRIPTOR);
 	if (idetape_queue_pc_tail (drive, &pc)) {
 		printk (KERN_ERR "ide-tape: Can't get block descriptor\n");
@@ -5941,9 +5910,10 @@
  *	Note that at this point ide.c already assigned us an irq, so that
  *	we can queue requests here and wait for their completion.
  */
-static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
+static void idetape_setup(struct ata_device *drive, idetape_tape_t *tape, int minor)
 {
-	unsigned long t1, tmid, tn, t;
+	unsigned long t1, tmid, tn;
+	unsigned long t;
 	int speed;
 	struct idetape_id_gcw gcw;
 	int stage_size;
@@ -5981,7 +5951,7 @@
 		set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags);
 
 	tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10;
-	
+
 	idetape_get_inquiry_results(drive);
 	idetape_get_mode_sense_results(drive);
 	idetape_get_blocksize_from_block_descriptor(drive);
@@ -6035,14 +6005,15 @@
 	 *	Ensure that the number we got makes sense; limit
 	 *	it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX.
 	 */
-	tape->best_dsc_rw_frequency = max(min(t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN);
+	tape->best_dsc_rw_frequency = max(min(t, (unsigned long) IDETAPE_DSC_RW_MAX),
+			(unsigned long) IDETAPE_DSC_RW_MIN);
 	printk (KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, %dkB pipeline, %lums tDSC%s\n",
 		drive->name, tape->name, tape->capabilities.speed, (tape->capabilities.buffer_size * 512) / tape->stage_size,
 		tape->stage_size / 1024, tape->max_stages * tape->stage_size / 1024,
 		tape->best_dsc_rw_frequency * 1000 / HZ, drive->using_dma ? ", DMA":"");
 }
 
-static int idetape_cleanup (ide_drive_t *drive)
+static int idetape_cleanup(struct ata_device *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	int minor = tape->minor;
@@ -6072,18 +6043,18 @@
 	return 0;
 }
 
-static void idetape_revalidate(ide_drive_t *_dummy)
+static void idetape_revalidate(struct ata_device *_dummy)
 {
 	/* We don't have to handle any partition information here, which is the
 	 * default behaviour of this method.
 	 */
 }
 
-/*
- *	IDE subdriver functions, registered with ide.c
- */
+static void idetape_attach(struct ata_device *);
+
 static struct ata_operations idetape_driver = {
 	owner:			THIS_MODULE,
+	attach:			idetape_attach,
 	cleanup:		idetape_cleanup,
 	standby:		NULL,
 	do_request:		idetape_do_request,
@@ -6095,6 +6066,8 @@
 	revalidate:		idetape_revalidate,
 };
 
+
+
 /*
  *	Our character device supporting functions, passed to register_chrdev.
  */
@@ -6107,104 +6080,93 @@
 	release:	idetape_chrdev_release,
 };
 
-MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
-MODULE_LICENSE("GPL");
-
-static void __exit idetape_exit (void)
+static void idetape_attach(struct ata_device *drive)
 {
-	ide_drive_t *drive;
-	int minor;
+	idetape_tape_t *tape;
+	int minor, supported = 0;
+	char *req;
+	struct ata_channel *channel;
+	int unit;
 
-	for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++) {
-		drive = idetape_chrdevs[minor].drive;
-		if (drive != NULL && idetape_cleanup (drive))
-		printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name);
-	}
-}
+	if (drive->type != ATA_TAPE)
+		return;
+
+	req = drive->driver_req;
+	if (req[0] != '\0' && strcmp(req, "ide-tape"))
+		return;
 
-/*
- *	idetape_init will register the driver for each tape.
- */
-int idetape_init (void)
-{
-	ide_drive_t *drive;
-	idetape_tape_t *tape;
-	int minor, failed = 0, supported = 0;
-/* DRIVER(drive)->busy++; */
-	MOD_INC_USE_COUNT;
-#if ONSTREAM_DEBUG
-        printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_init\n");
-#endif
 	if (!idetape_chrdev_present)
 		for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
 			idetape_chrdevs[minor].drive = NULL;
 
-	if ((drive = ide_scan_devices(ATA_TAPE, "ide-tape", NULL, failed++)) == NULL) {
-		revalidate_drives();
-		MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
-		printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
-		return 0;
-	}
 	if (!idetape_chrdev_present &&
 	    devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) {
-		printk (KERN_ERR "ide-tape: Failed to register character device interface\n");
-		MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
-		printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
-		return -EBUSY;
+		printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
+		return;
 	}
-	do {
-		if (!idetape_identify_device (drive, drive->id)) {
-			printk (KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
-			continue;
-		}
-		if (drive->scsi) {
-			if (strstr(drive->id->model, "OnStream DI-")) {
-				printk("ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
-			} else {
-				printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
-				continue;
-			}
-		}
-		tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
-		if (tape == NULL) {
-			printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
-			continue;
-		}
-		if (ide_register_subdriver (drive, &idetape_driver)) {
-			printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
-			kfree (tape);
-			continue;
+
+	if (!idetape_identify_device (drive, drive->id)) {
+		printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
+		return;
+	}
+	if (drive->scsi) {
+		if (strstr(drive->id->model, "OnStream DI-")) {
+			printk(KERN_INFO "ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
+		} else {
+			printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
+			return;
 		}
-		for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
-		idetape_setup (drive, tape, minor);
-		idetape_chrdevs[minor].drive = drive;
-		tape->de_r =
-		    devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
-				    drive->channel->major, minor,
-				    S_IFCHR | S_IRUGO | S_IWUGO,
-				    &idetape_fops, NULL);
-		tape->de_n =
-		    devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
-				    drive->channel->major, minor + 128,
-				    S_IFCHR | S_IRUGO | S_IWUGO,
-				    &idetape_fops, NULL);
-		devfs_register_tape (tape->de_r);
-		supported++; failed--;
-	} while ((drive = ide_scan_devices(ATA_TAPE, "ide-tape", NULL, failed++)) != NULL);
+	}
+	tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
+	if (!tape) {
+		printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
+		return;
+	}
+	if (ide_register_subdriver (drive, &idetape_driver)) {
+		printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
+		kfree (tape);
+		return;
+	}
+	for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
+	idetape_setup (drive, tape, minor);
+	idetape_chrdevs[minor].drive = drive;
+	tape->de_r =
+		devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
+				drive->channel->major, minor,
+				S_IFCHR | S_IRUGO | S_IWUGO,
+				&idetape_fops, NULL);
+	tape->de_n =
+		devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
+				drive->channel->major, minor + 128,
+				S_IFCHR | S_IRUGO | S_IWUGO,
+				&idetape_fops, NULL);
+	devfs_register_tape (tape->de_r);
+	supported++;
+
 	if (!idetape_chrdev_present && !supported) {
 		devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
 	} else
 		idetape_chrdev_present = 1;
-	revalidate_drives();
-	MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
-	printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
-	return 0;
+
+	/* Feel free to use partitions even on tapes... */
+
+	channel = drive->channel;
+	unit = drive - channel->drives;
+
+	ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
+}
+
+MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
+MODULE_LICENSE("GPL");
+
+static void __exit idetape_exit(void)
+{
+	unregister_ata_driver(&idetape_driver);
+}
+
+int __init idetape_init(void)
+{
+	return ata_driver_module(&idetape_driver);
 }
 
 module_init(idetape_init);
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/ide.c	Fri May 24 18:55:35 2002
@@ -68,6 +68,11 @@
 #include "ata-timing.h"
 #include "pcihost.h"
 
+
+MODULE_DESCRIPTION("ATA/ATAPI driver infrastructure");
+MODULE_PARM(options,"s");
+MODULE_LICENSE("GPL");
+
 /*
  * Those will be moved into separate header files eventually.
  */
@@ -134,39 +139,15 @@
 
 int noautodma = 0;
 
+/* Single linked list of sub device type drivers */
+static struct ata_operations *ata_drivers; /* = NULL */
+static spinlock_t ata_drivers_lock = SPIN_LOCK_UNLOCKED;
+
 /*
  * This is declared extern in ide.h, for access by other IDE modules:
  */
 struct ata_channel ide_hwifs[MAX_HWIFS];	/* master data repository */
 
-#if (DISK_RECOVERY_TIME > 0)
-/*
- * For really screwed hardware (hey, at least it *can* be used with Linux)
- * we can enforce a minimum delay time between successive operations.
- */
-static unsigned long read_timer (void)
-{
-	unsigned long t, flags;
-	int i;
-
-	__save_flags(flags);	/* local CPU only */
-	__cli();		/* local CPU only */
-	t = jiffies * 11932;
-	outb_p(0, 0x43);
-	i = inb_p(0x40);
-	i |= inb(0x40) << 8;
-	__restore_flags(flags);	/* local CPU only */
-	return (t - i);
-}
-#endif
-
-static inline void set_recovery_timer(struct ata_channel *channel)
-{
-#if (DISK_RECOVERY_TIME > 0)
-	channel->last_time = read_timer();
-#endif
-}
-
 static void init_hwif_data(struct ata_channel *ch, unsigned int index)
 {
 	static const byte ide_major[] = {
@@ -241,8 +222,6 @@
 
 	/* Add default hw interfaces */
 	ide_init_default_hwifs();
-
-	idebus_parameter = 0;
 }
 
 /*
@@ -284,7 +263,7 @@
 	return 0;
 }
 
-int __ide_end_request(struct ata_device *drive, struct request *rq, int uptodate, int nr_secs)
+int __ide_end_request(struct ata_device *drive, struct request *rq, int uptodate, unsigned int nr_secs)
 {
 	unsigned long flags;
 	int ret = 1;
@@ -667,56 +646,72 @@
 	end_that_request_last(rq);
 }
 
+#if FANCY_STATUS_DUMPS
+struct ata_bit_messages {
+	u8 mask;
+	u8 match;
+	const char *msg;
+};
+
+static struct ata_bit_messages ata_status_msgs[] = {
+	{ BUSY_STAT,  BUSY_STAT,  "Busy"           },
+	{ READY_STAT, READY_STAT, "DriveReady"     },
+	{ WRERR_STAT, WRERR_STAT, "DeviceFault"    },
+	{ SEEK_STAT,  SEEK_STAT,  "SeekComplete"   },
+	{ DRQ_STAT,   DRQ_STAT,   "DataRequest"    },
+	{ ECC_STAT,   ECC_STAT,   "CorrectedError" },
+	{ INDEX_STAT, INDEX_STAT, "Index"          },
+	{ ERR_STAT,   ERR_STAT,   "Error"          }
+};
+
+static struct ata_bit_messages ata_error_msgs[] = {
+	{ ICRC_ERR|ABRT_ERR,	ABRT_ERR,		"DriveStatusError"   },
+	{ ICRC_ERR|ABRT_ERR,	ICRC_ERR,		"BadSector"	     },
+	{ ICRC_ERR|ABRT_ERR,	ICRC_ERR|ABRT_ERR,	"BadCRC"	     },
+	{ ECC_ERR,		ECC_ERR,		"UncorrectableError" },
+	{ ID_ERR,		ID_ERR,			"SectorIdNotFound"   },
+	{ TRK0_ERR,		TRK0_ERR,		"TrackZeroNotFound"  },
+	{ MARK_ERR,		MARK_ERR,		"AddrMarkNotFound"   }
+};
+
+static void ata_dump_bits(struct ata_bit_messages *msgs, int nr, byte bits)
+{
+	int i;
+
+	printk(" { ");
+
+	for (i = 0; i < nr; i++, msgs++)
+		if ((bits & msgs->mask) == msgs->match)
+			printk("%s ", msgs->msg);
+
+	printk("} ");
+}
+#else
+#define ata_dump_bits(msgs,nr,bits) do { } while (0)
+#endif
+
 /*
  * Error reporting, in human readable form (luxurious, but a memory hog).
  */
 u8 ide_dump_status(struct ata_device *drive, struct request * rq, const char *msg, u8 stat)
 {
 	unsigned long flags;
-	byte err = 0;
+	u8 err = 0;
 
 	__save_flags (flags);	/* local CPU only */
 	ide__sti();		/* local CPU only */
-#if !(FANCY_STATUS_DUMPS)
-	printk("%s: %s: status=0x%02x\n", drive->name, msg, stat);
-#else
-	printk(" { ");
-	{
-		char *msg = "";
-		if (stat & BUSY_STAT)
-			msg = "Busy";
-		else {
-			if (stat & READY_STAT)
-				msg = "DriveReady";
-			if (stat & WRERR_STAT)
-				msg = "DeviceFault";
-			if (stat & SEEK_STAT)
-				msg = "SeekComplete";
-			if (stat & DRQ_STAT)
-				msg = "DataRequest";
-			if (stat & ECC_STAT)
-				msg = "CorrectedError";
-			if (stat & INDEX_STAT)
-				msg = "Index";
-			if (stat & ERR_STAT)
-				msg = "Error";
-		}
-	}
-	printk("%s }\n", msg);
-#endif
+
+	printk("%s: %s: status=0x%02x", drive->name, msg, stat);
+	ata_dump_bits(ata_status_msgs, ARRAY_SIZE(ata_status_msgs), stat);
+	printk("\n");
+
 	if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
 		err = GET_ERR();
 		printk("%s: %s: error=0x%02x", drive->name, msg, err);
 #if FANCY_STATUS_DUMPS
 		if (drive->type == ATA_DISK) {
-			printk(" { ");
-			if (err & ABRT_ERR)	printk("DriveStatusError ");
-			if (err & ICRC_ERR)	printk("%s", (err & ABRT_ERR) ? "BadCRC " : "BadSector ");
-			if (err & ECC_ERR)	printk("UncorrectableError ");
-			if (err & ID_ERR)	printk("SectorIdNotFound ");
-			if (err & TRK0_ERR)	printk("TrackZeroNotFound ");
-			if (err & MARK_ERR)	printk("AddrMarkNotFound ");
-			printk("}");
+			ata_dump_bits(ata_error_msgs, ARRAY_SIZE(ata_error_msgs), err);
+
 			if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || (err & (ECC_ERR|ID_ERR|MARK_ERR))) {
 				if ((drive->id->command_set_2 & 0x0400) &&
 				    (drive->id->cfs_enable_2 & 0x0400) &&
@@ -988,11 +983,6 @@
 	 */
 	if (block == 0 && drive->remap_0_to_1 == 1)
 		block = 1;  /* redirect MBR access to EZ-Drive partn table */
-
-#if (DISK_RECOVERY_TIME > 0)
-	while ((read_timer() - ch->last_time) < DISK_RECOVERY_TIME);
-#endif
-
 	{
 		ide_startstop_t res;
 
@@ -1199,14 +1189,14 @@
 		if (timer_pending(&channel->timer))
 			printk(KERN_ERR "ide_set_handler: timer already active\n");
 #endif
-		set_bit(IDE_SLEEP, &channel->active);
+		set_bit(IDE_SLEEP, channel->active);
 		mod_timer(&channel->timer, sleep);
 		/* we purposely leave hwgroup busy while sleeping */
 	} else {
 		/* Ugly, but how can we sleep for the lock otherwise? perhaps
 		 * from tq_disk? */
 		ide_release_lock(&irq_lock);/* for atari only */
-		clear_bit(IDE_BUSY, &channel->active);
+		clear_bit(IDE_BUSY, channel->active);
 	}
 
 	return NULL;
@@ -1225,7 +1215,7 @@
 	for (;;) {
 		struct request *rq = NULL;
 
-		if (!test_bit(IDE_BUSY, &ch->active))
+		if (!test_bit(IDE_BUSY, ch->active))
 			printk(KERN_ERR "%s: error: not busy while queueing!\n", drive->name);
 
 		/* Abort early if we can't queue another command. for non
@@ -1234,13 +1224,13 @@
 		 */
 		if (!ata_can_queue(drive)) {
 			if (!ata_pending_commands(drive))
-				clear_bit(IDE_BUSY, &ch->active);
+				clear_bit(IDE_BUSY, ch->active);
 			break;
 		}
 
 		drive->sleep = 0;
 
-		if (test_bit(IDE_DMA, &ch->active)) {
+		if (test_bit(IDE_DMA, ch->active)) {
 			printk(KERN_ERR "%s: error: DMA in progress...\n", drive->name);
 			break;
 		}
@@ -1258,7 +1248,7 @@
 
 		if (!(rq = elv_next_request(&drive->queue))) {
 			if (!ata_pending_commands(drive))
-				clear_bit(IDE_BUSY, &ch->active);
+				clear_bit(IDE_BUSY, ch->active);
 			drive->rq = NULL;
 			break;
 		}
@@ -1305,7 +1295,7 @@
 	ide_get_lock(&irq_lock, ata_irq_request, hwgroup);/* for atari only: POSSIBLY BROKEN HERE(?) */
 //	__cli();	/* necessary paranoia: ensure IRQs are masked on local CPU */
 
-	while (!test_and_set_bit(IDE_BUSY, &channel->active)) {
+	while (!test_and_set_bit(IDE_BUSY, channel->active)) {
 		struct ata_channel *ch;
 		struct ata_device *drive;
 
@@ -1408,8 +1398,8 @@
 		 * complain about anything.
 		 */
 
-		if (test_and_clear_bit(IDE_SLEEP, &ch->active))
-			clear_bit(IDE_BUSY, &ch->active);
+		if (test_and_clear_bit(IDE_SLEEP, ch->active))
+			clear_bit(IDE_BUSY, ch->active);
 	} else {
 		struct ata_device *drive = ch->drive;
 		if (!drive) {
@@ -1419,7 +1409,7 @@
 			ide_startstop_t startstop;
 
 			/* paranoia */
-			if (!test_and_set_bit(IDE_BUSY, &ch->active))
+			if (!test_and_set_bit(IDE_BUSY, ch->active))
 				printk(KERN_ERR "%s: ide_timer_expiry: IRQ handler was not busy??\n", drive->name);
 			if ((expiry = ch->expiry) != NULL) {
 				/* continue */
@@ -1464,13 +1454,12 @@
 				} else
 					startstop = ide_error(drive, drive->rq, "irq timeout", GET_STAT());
 			}
-			set_recovery_timer(ch);
 			enable_irq(ch->irq);
 
 			spin_lock_irq(ch->lock);
 
 			if (startstop == ide_stopped)
-				clear_bit(IDE_BUSY, &ch->active);
+				clear_bit(IDE_BUSY, ch->active);
 		}
 	}
 
@@ -1593,7 +1582,7 @@
 		goto out_lock;
 	}
 	/* paranoia */
-	if (!test_and_set_bit(IDE_BUSY, &ch->active))
+	if (!test_and_set_bit(IDE_BUSY, ch->active))
 		printk(KERN_ERR "%s: %s: hwgroup was not busy!?\n", drive->name, __FUNCTION__);
 	ch->handler = NULL;
 	del_timer(&ch->timer);
@@ -1614,10 +1603,9 @@
 	 * same irq as is currently being serviced here, and Linux
 	 * won't allow another of the same (on any CPU) until we return.
 	 */
-	set_recovery_timer(drive->channel);
 	if (startstop == ide_stopped) {
 		if (!ch->handler) {	/* paranoia */
-			clear_bit(IDE_BUSY, &ch->active);
+			clear_bit(IDE_BUSY, ch->active);
 			do_request(ch);
 		} else {
 			printk("%s: %s: huh? expected NULL handler on exit\n", drive->name, __FUNCTION__);
@@ -1654,6 +1642,8 @@
 }
 
 /*
+ * FIXME: rename to ata_wipe_partitions.
+ *
  * This routine is called to flush all partitions and partition tables
  * for a changed disk, and then re-read the new partition table.
  * If we are revalidating a disk because of a media change, then we
@@ -1704,10 +1694,9 @@
 }
 
 /*
- * Look again for all drives in the system on all interfaces.  This is used
- * after a new driver category has been loaded as module.
+ * Look again for all drives in the system on all interfaces.
  */
-void revalidate_drives(void)
+static void revalidate_drives(void)
 {
 	int i;
 
@@ -1727,7 +1716,7 @@
 	}
 }
 
-static void ide_driver_module (void)
+static void ide_driver_module(void)
 {
 	int i;
 
@@ -1951,10 +1940,12 @@
 		free_irq(ch->irq, ch);
 	if (n_ch == 1) {
 		kfree(ch->lock);
+		kfree(ch->active);
 		ch->lock = NULL;
+		ch->active = NULL;
 	}
 
-#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
+#ifdef CONFIG_BLK_DEV_IDEDMA
 	ide_release_dma(ch);
 #endif
 
@@ -2035,10 +2026,10 @@
  * may set up the hw structure yourself OR use this routine to
  * do it for you.
  */
-void ide_setup_ports (	hw_regs_t *hw,
-			ide_ioreg_t base, int *offsets,
-			ide_ioreg_t ctrl, ide_ioreg_t intr,
-			ide_ack_intr_t *ack_intr, int irq)
+void ide_setup_ports(hw_regs_t *hw,
+		ide_ioreg_t base, int *offsets,
+		ide_ioreg_t ctrl, ide_ioreg_t intr,
+		ide_ack_intr_t *ack_intr, int irq)
 {
 	int i;
 
@@ -2060,6 +2051,46 @@
 	hw->ack_intr = ack_intr;
 }
 
+static int subdriver_match(struct ata_channel *channel, struct ata_operations *ops)
+{
+	int count, unit;
+
+	if (!channel->present)
+		return 0;
+
+	count = 0;
+	for (unit = 0; unit < MAX_DRIVES; ++unit) {
+		struct ata_device *drive = &channel->drives[unit];
+		if (drive->present && !drive->driver) {
+			(*ops->attach)(drive);
+			if (drive->driver != NULL)
+				count++;
+		}
+	}
+	return count;
+}
+
+static struct ata_operations * subdriver_interator(struct ata_operations *prev)
+{
+	struct ata_operations *tmp;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ata_drivers_lock, flags);
+
+	/* Restart from beginning if current ata_operations was deallocated,
+	   or if prev is NULL. */
+	for(tmp = ata_drivers; tmp != prev && tmp; tmp = tmp->next);
+	if (!tmp)
+		tmp = ata_drivers;
+	else
+		tmp = tmp->next;
+
+	spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+	return tmp;
+
+}
+
 /*
  * Register an IDE interface, specifing exactly the registers etc
  * Set init=1 iff calling before probes have taken place.
@@ -2068,18 +2099,19 @@
 {
 	int h;
 	int retry = 1;
-	struct ata_channel *hwif;
+	struct ata_channel *ch;
+	struct ata_operations *subdriver;
 
 	do {
 		for (h = 0; h < MAX_HWIFS; ++h) {
-			hwif = &ide_hwifs[h];
-			if (hwif->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET])
+			ch = &ide_hwifs[h];
+			if (ch->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET])
 				goto found;
 		}
 		for (h = 0; h < MAX_HWIFS; ++h) {
-			hwif = &ide_hwifs[h];
-			if ((!hwif->present && (hwif->unit == ATA_PRIMARY) && !initializing) ||
-			    (!hwif->hw.io_ports[IDE_DATA_OFFSET] && initializing))
+			ch = &ide_hwifs[h];
+			if ((!ch->present && (ch->unit == ATA_PRIMARY) && !initializing) ||
+			    (!ch->hw.io_ports[IDE_DATA_OFFSET] && initializing))
 				goto found;
 		}
 		for (h = 0; h < MAX_HWIFS; ++h)
@@ -2089,14 +2121,14 @@
 	return -1;
 
 found:
-	ide_unregister(hwif);
-	if (hwif->present)
+	ide_unregister(ch);
+	if (ch->present)
 		return -1;
-	memcpy(&hwif->hw, hw, sizeof(*hw));
-	memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
-	hwif->irq = hw->irq;
-	hwif->noprobe = 0;
-	hwif->chipset = hw->chipset;
+	memcpy(&ch->hw, hw, sizeof(*hw));
+	memcpy(ch->io_ports, ch->hw.io_ports, sizeof(ch->hw.io_ports));
+	ch->irq = hw->irq;
+	ch->noprobe = 0;
+	ch->chipset = hw->chipset;
 
 	if (!initializing) {
 		ideprobe_init();
@@ -2105,10 +2137,19 @@
 		ide_driver_module();
 	}
 
+	/* Look up whatever there is a subdriver, which will serve this
+	 * device.
+	 */
+	subdriver = NULL;
+	while ((subdriver = subdriver_interator(subdriver))) {
+		if (subdriver_match(ch, subdriver) > 0)
+			break;
+	}
+
 	if (hwifp)
-		*hwifp = hwif;
+		*hwifp = ch;
 
-	return (initializing || hwif->present) ? h : -1;
+	return (initializing || ch->present) ? h : -1;
 }
 
 /*
@@ -2133,7 +2174,7 @@
 
 	spin_lock_irq(drive->channel->lock);
 
-	while (test_bit(IDE_BUSY, &drive->channel->active)) {
+	while (test_bit(IDE_BUSY, drive->channel->active)) {
 
 		spin_unlock_irq(drive->channel->lock);
 
@@ -2197,7 +2238,7 @@
 #else
 	__set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(HZ/20);
-#endif /* CONFIG_BLK_DEV_IDECS */
+#endif
 }
 
 /*
@@ -2785,10 +2826,7 @@
 	if (!strncmp(s, "idebus", 6)) {
 		if (match_parm(&s[6], NULL, vals, 1) != 1)
 			goto bad_option;
-		if (vals[0] >= 20 && vals[0] <= 66) {
-			idebus_parameter = vals[0];
-		} else
-			printk(" -- BAD BUS SPEED! Expected value from 20 to 66");
+		idebus_parameter = vals[0];
 		goto done;
 	}
 
@@ -2963,34 +3001,7 @@
 }
 
 /*
- * Lookup ATA devices, which requested a particular driver.
- */
-struct ata_device *ide_scan_devices(byte type, const char *name, struct ata_operations *driver, int n)
-{
-	unsigned int unit, index, i;
-
-	for (index = 0, i = 0; index < MAX_HWIFS; ++index) {
-		struct ata_channel *ch = &ide_hwifs[index];
-
-		if (!ch->present)
-			continue;
-
-		for (unit = 0; unit < MAX_DRIVES; ++unit) {
-			struct ata_device *drive = &ch->drives[unit];
-			char *req = drive->driver_req;
-
-			if (*req && !strstr(name, req))
-				continue;
-			if (drive->present && drive->type == type && drive->driver == driver && ++i > n)
-				return drive;
-		}
-	}
-
-	return NULL;
-}
-
-/*
- * This is in fact registering a drive not a driver.
+ * This is in fact registering a device not a driver.
  */
 int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driver)
 {
@@ -3078,7 +3089,6 @@
 	pnpide_init(0);
 #endif
 	drive->driver = NULL;
-	drive->present = 0;
 
 	restore_flags(flags);		/* all CPUs */
 
@@ -3087,23 +3097,56 @@
 
 
 /*
- * Register an ATA driver for a particular device type.
+ * Register an ATA subdriver for a particular device type.
  */
 
-int register_ata_driver(unsigned int type, struct ata_operations *driver)
+int register_ata_driver(struct ata_operations *driver)
 {
-	return 0;
+	unsigned long flags;
+	int index;
+	int count = 0;
+
+	spin_lock_irqsave(&ata_drivers_lock, flags);
+	driver->next = ata_drivers;
+	ata_drivers = driver;
+	spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+	for (index = 0; index < MAX_HWIFS; ++index)
+		count += subdriver_match(&ide_hwifs[index], driver);
+
+	return count;
 }
 
 EXPORT_SYMBOL(register_ata_driver);
 
 /*
- * Unregister an ATA driver for a particular device type.
+ * Unregister an ATA subdriver for a particular device type.
  */
-
-int unregister_ata_driver(unsigned int type, struct ata_operations *driver)
+void unregister_ata_driver(struct ata_operations *driver)
 {
-	return 0;
+	struct ata_operations **tmp;
+	unsigned long flags;
+	int index;
+	int unit;
+
+	spin_lock_irqsave(&ata_drivers_lock, flags);
+	for (tmp = &ata_drivers; *tmp != NULL; tmp = &(*tmp)->next) {
+		if (*tmp == driver) {
+			*tmp = driver->next;
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+	for (index = 0; index < MAX_HWIFS; ++index) {
+		struct ata_channel *ch = &ide_hwifs[index];
+		for (unit = 0; unit < MAX_DRIVES; ++unit) {
+			struct ata_device *drive = &ch->drives[unit];
+
+			if (drive->driver == driver)
+				(*ata_ops(drive)->cleanup)(drive);
+		}
+	}
 }
 
 EXPORT_SYMBOL(unregister_ata_driver);
@@ -3120,21 +3163,14 @@
 EXPORT_SYMBOL(ide_fops);
 EXPORT_SYMBOL(ide_hwifs);
 EXPORT_SYMBOL(ide_spin_wait_hwgroup);
-EXPORT_SYMBOL(revalidate_drives);
 
-/*
- * Probe module
- */
 devfs_handle_t ide_devfs_handle;
 
 EXPORT_SYMBOL(ide_lock);
 EXPORT_SYMBOL(drive_is_flashcard);
 EXPORT_SYMBOL(ide_timer_expiry);
 EXPORT_SYMBOL(do_ide_request);
-/*
- * Driver module
- */
-EXPORT_SYMBOL(ide_scan_devices);
+
 EXPORT_SYMBOL(ide_register_subdriver);
 EXPORT_SYMBOL(ide_unregister_subdriver);
 EXPORT_SYMBOL(ide_set_handler);
@@ -3156,7 +3192,10 @@
 EXPORT_SYMBOL(ide_setup_ports);
 EXPORT_SYMBOL(get_info_ptr);
 
-static int ide_notify_reboot (struct notifier_block *this, unsigned long event, void *x)
+/*
+ * Handle power handling related events ths system informs us about.
+ */
+static int ata_sys_notify(struct notifier_block *this, unsigned long event, void *x)
 {
 	int i;
 
@@ -3200,8 +3239,8 @@
 	return NOTIFY_DONE;
 }
 
-static struct notifier_block ide_notifier = {
-	ide_notify_reboot,
+static struct notifier_block ata_notifier = {
+	ata_sys_notify,
 	NULL,
 	5
 };
@@ -3213,31 +3252,45 @@
 {
 	int h;
 
-	printk(KERN_INFO "ATA/ATAPI driver v" VERSION "\n");
+	printk(KERN_INFO "ATA/ATAPI device driver v" VERSION "\n");
 
 	ide_devfs_handle = devfs_mk_dir (NULL, "ide", NULL);
 
-	/* Initialize system bus speed.
-	 *
-	 * This can be changed by a particular chipse initialization module.
-	 * Otherwise we assume 33MHz as a safe value for PCI bus based systems.
-	 * 50MHz will be assumed for abolitions like VESA, since higher values
-	 * result in more conservative timing setups.
-	 *
-	 * The kernel parameter idebus=XX overrides the default settings.
+	/*
+	 * Because most of the ATA adapters represent the timings in unit of
+	 * bus clocks, and there is no known reliable way to detect the bus
+	 * clock frequency, we assume 50 MHz for non-PCI (VLB, EISA) and 33 MHz
+	 * for PCI based systems. Since assuming only hurts performance and not
+	 * stability, this is OK. The user can change this on the command line
+	 * by using the "idebus=XX" parameter. While the system_bus_speed
+	 * variable is in kHz units, we accept both MHz and kHz entry on the
+	 * command line for backward compatibility.
 	 */
 
-	system_bus_speed = 50;
-	if (idebus_parameter)
+	system_bus_speed = 50000;
+
+	if (pci_present())
+	    system_bus_speed = 33333;
+
+	if (idebus_parameter >= 20 && idebus_parameter <= 80) {
+
+		system_bus_speed = idebus_parameter * 1000;
+
+		switch (system_bus_speed) {
+			case 33000: system_bus_speed = 33333; break;
+			case 37000: system_bus_speed = 37500; break;
+			case 41000: system_bus_speed = 41666; break;
+			case 66000: system_bus_speed = 66666; break;
+		}
+	}
+
+	if (idebus_parameter >= 20000 && idebus_parameter <= 80000)
 	    system_bus_speed = idebus_parameter;
-#ifdef CONFIG_PCI
-	else if (pci_present())
-	    system_bus_speed = 33;
-#endif
 
-	printk(KERN_INFO "ATA: system bus speed %dMHz\n", system_bus_speed);
+	printk(KERN_INFO "ATA: %s bus speed %d.%dMHz\n",
+		pci_present() ? "PCI" : "System", system_bus_speed / 1000, system_bus_speed / 100 % 10);
 
-	init_ide_data ();
+	init_ide_data();
 
 	initializing = 1;
 
@@ -3394,7 +3447,7 @@
 # ifdef CONFIG_SCSI
 	idescsi_init();
 # else
-   #warning ATA SCSI emulation selected but no SCSI-subsystem in kernel
+   #error ATA SCSI emulation selected but no SCSI-subsystem in kernel
 # endif
 #endif
 
@@ -3406,14 +3459,12 @@
 			ide_geninit(channel);
 	}
 
-	register_reboot_notifier(&ide_notifier);
+	register_reboot_notifier(&ata_notifier);
 
 	return 0;
 }
 
 static char *options = NULL;
-MODULE_PARM(options,"s");
-MODULE_LICENSE("GPL");
 
 static int __init init_ata(void)
 {
@@ -3435,7 +3486,7 @@
 {
 	int h;
 
-	unregister_reboot_notifier(&ide_notifier);
+	unregister_reboot_notifier(&ata_notifier);
 	for (h = 0; h < MAX_HWIFS; ++h) {
 		ide_unregister(&ide_hwifs[h]);
 	}
diff -Nru a/drivers/ide/it8172.c b/drivers/ide/it8172.c
--- a/drivers/ide/it8172.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/it8172.c	Fri May 24 18:55:33 2002
@@ -48,17 +48,17 @@
 /*
  * Prototypes
  */
-static void it8172_tune_drive (ide_drive_t *drive, byte pio);
+static void it8172_tune_drive (struct ata_device *drive, byte pio);
 #if defined(CONFIG_BLK_DEV_IDEDMA) && defined(CONFIG_IT8172_TUNING)
 static byte it8172_dma_2_pio (byte xfer_rate);
-static int it8172_tune_chipset (ide_drive_t *drive, byte speed);
-static int it8172_config_chipset_for_dma (ide_drive_t *drive);
-static int it8172_dmaproc(ide_dma_action_t func, ide_drive_t *drive);
+static int it8172_tune_chipset (struct ata_device *drive, byte speed);
+static int it8172_config_chipset_for_dma (struct ata_device *drive);
+static int it8172_dmaproc(ide_dma_action_t func, struct ata_device *drive);
 #endif
 void __init ide_init_it8172(struct ata_channel *channel);
 
 
-static void it8172_tune_drive (ide_drive_t *drive, byte pio)
+static void it8172_tune_drive (struct ata_device *drive, byte pio)
 {
     unsigned long flags;
     u16 drive_enables;
@@ -139,7 +139,7 @@
     }
 }
 
-static int it8172_tune_chipset (ide_drive_t *drive, byte speed)
+static int it8172_tune_chipset (struct ata_device *drive, byte speed)
 {
     struct ata_channel *hwif = drive->channel;
     struct pci_dev *dev	= hwif->pci_dev;
@@ -194,7 +194,7 @@
     return err;
 }
 
-static int it8172_config_chipset_for_dma(ide_drive_t *drive)
+static int it8172_config_chipset_for_dma(struct ata_device *drive)
 {
     struct hd_driveid *id = drive->id;
     byte speed;
@@ -210,7 +210,7 @@
 	    ide_dma_off_quietly);
 }
 
-static int it8172_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
+static int it8172_dmaproc(ide_dma_action_t func, struct ata_device *drive)
 {
     switch (func) {
     case ide_dma_check:
diff -Nru a/drivers/ide/macide.c b/drivers/ide/macide.c
--- a/drivers/ide/macide.c	Fri May 24 18:55:33 2002
+++ b/drivers/ide/macide.c	Fri May 24 18:55:33 2002
@@ -119,7 +119,7 @@
 			/* hardware ID, and we cna't get that without	*/
 			/* probing the drive which freezes a 190.	*/
 
-			ide_drive_t *drive = &ide_hwifs[index].drives[0];
+			struct ata_device *drive = &ide_hwifs[index].drives[0];
         		drive->capacity = drive->cyl*drive->head*drive->sect;
 
 #ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
diff -Nru a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c
--- a/drivers/ide/ns87415.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/ns87415.c	Fri May 24 18:55:35 2002
@@ -33,7 +33,7 @@
  * the IRQ associated with the port (drive->channel),
  * and selects either PIO or DMA handshaking for the next I/O operation.
  */
-static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
+static void ns87415_prepare_drive(struct ata_device *drive, unsigned int use_dma)
 {
 	struct ata_channel *hwif = drive->channel;
 	unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data;
@@ -78,7 +78,7 @@
 	__restore_flags(flags);	/* local CPU only */
 }
 
-static void ns87415_selectproc (ide_drive_t *drive)
+static void ns87415_selectproc(struct ata_device *drive)
 {
 	ns87415_prepare_drive (drive, drive->using_dma);
 }
diff -Nru a/drivers/ide/opti621.c b/drivers/ide/opti621.c
--- a/drivers/ide/opti621.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/opti621.c	Fri May 24 18:55:34 2002
@@ -137,7 +137,7 @@
 
 /* there are stored pio numbers from other calls of opti621_tune_drive */
 
-static void compute_pios(ide_drive_t *drive, byte pio)
+static void compute_pios(struct ata_device *drive, byte pio)
 /* Store values into drive->drive_data
  *	second_contr - 0 for primary controller, 1 for secondary
  *	slave_drive - 0 -> pio is for master, 1 -> pio is for slave
@@ -175,7 +175,7 @@
  * Use idebus=xx to select right frequency.
  */
 {
-	return ((time*bus_speed+999)/1000);
+	return ((time*bus_speed+999999)/1000000);
 }
 
 static void write_reg(byte value, int reg)
@@ -245,7 +245,7 @@
 }
 
 /* Main tune procedure, called from tuneproc. */
-static void opti621_tune_drive (ide_drive_t *drive, byte pio)
+static void opti621_tune_drive(struct ata_device *drive, byte pio)
 {
 	/* primary and secondary drives share some registers,
 	 * so we have to program both drives
diff -Nru a/drivers/ide/pcidma.c b/drivers/ide/pcidma.c
--- a/drivers/ide/pcidma.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/pcidma.c	Fri May 24 18:55:34 2002
@@ -258,7 +258,7 @@
  * recovery" in the ATAPI drivers. This was just plain wrong before, in esp.
  * not portable, and just got uncovered now.
  */
-static void udma_pci_enable(struct ata_device *drive, int on, int verbose)
+void udma_pci_enable(struct ata_device *drive, int on, int verbose)
 {
 	struct ata_channel *ch = drive->channel;
 	int set_high = 1;
@@ -396,7 +396,7 @@
  * about addressing modes.
  */
 
-static int udma_pci_start(struct ata_device *drive, struct request *rq)
+int udma_pci_start(struct ata_device *drive, struct request *rq)
 {
 	struct ata_channel *ch = drive->channel;
 	unsigned long dma_base = ch->dma_base;
@@ -410,7 +410,7 @@
 	return 0;
 }
 
-static int udma_pci_stop(struct ata_device *drive)
+int udma_pci_stop(struct ata_device *drive)
 {
 	struct ata_channel *ch = drive->channel;
 	unsigned long dma_base = ch->dma_base;
@@ -425,12 +425,12 @@
 	return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;	/* verify good DMA status */
 }
 
-static int udma_pci_read(struct ata_device *drive, struct request *rq)
+int udma_pci_read(struct ata_device *drive, struct request *rq)
 {
 	return ata_do_udma(1, drive, rq);
 }
 
-static int udma_pci_write(struct ata_device *drive, struct request *rq)
+int udma_pci_write(struct ata_device *drive, struct request *rq)
 {
 	return ata_do_udma(0, drive, rq);
 }
@@ -438,7 +438,7 @@
 /*
  * FIXME: This should be attached to a channel as we can see now!
  */
-static int udma_pci_irq_status(struct ata_device *drive)
+int udma_pci_irq_status(struct ata_device *drive)
 {
 	struct ata_channel *ch = drive->channel;
 	u8 dma_stat;
@@ -449,12 +449,12 @@
 	return (dma_stat & 4) == 4;	/* return 1 if INTR asserted */
 }
 
-static void udma_pci_timeout(struct ata_device *drive)
+void udma_pci_timeout(struct ata_device *drive)
 {
 	printk(KERN_ERR "ATA: UDMA timeout occured %s!\n", drive->name);
 }
 
-static void udma_pci_irq_lost(struct ata_device *drive)
+void udma_pci_irq_lost(struct ata_device *drive)
 {
 }
 
@@ -553,3 +553,11 @@
 
 EXPORT_SYMBOL(ata_do_udma);
 EXPORT_SYMBOL(ide_dma_intr);
+EXPORT_SYMBOL(udma_pci_enable);
+EXPORT_SYMBOL(udma_pci_start);
+EXPORT_SYMBOL(udma_pci_stop);
+EXPORT_SYMBOL(udma_pci_read);
+EXPORT_SYMBOL(udma_pci_write);
+EXPORT_SYMBOL(udma_pci_irq_status);
+EXPORT_SYMBOL(udma_pci_timeout);
+EXPORT_SYMBOL(udma_pci_irq_lost);
diff -Nru a/drivers/ide/pdc202xx.c b/drivers/ide/pdc202xx.c
--- a/drivers/ide/pdc202xx.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/pdc202xx.c	Fri May 24 18:55:36 2002
@@ -166,10 +166,12 @@
 
 #endif /* PDC202XX_DECODE_REGISTER_INFO */
 
-int check_in_drive_lists(struct ata_device *drive) {
-	const char *pdc_quirk_drives[] = {
+int check_in_drive_lists(struct ata_device *drive)
+{
+	static const char *pdc_quirk_drives[] = {
 		"QUANTUM FIREBALLlct08 08",
 		"QUANTUM FIREBALLP KA6.4",
+		"QUANTUM FIREBALLP KA9.1",
 		"QUANTUM FIREBALLP LM20.4",
 		"QUANTUM FIREBALLP KX20.5",
 		"QUANTUM FIREBALLP KX27.3",
@@ -185,13 +187,38 @@
 	return 0;
 }
 
+static int pdc202xx_ratemask(struct ata_device *drive)
+{
+	struct pci_dev *dev = drive->channel->pci_dev;
+	int map = 0;
+
+	if (!eighty_ninty_three(drive))
+		return XFER_UDMA;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_PROMISE_20276:
+		case PCI_DEVICE_ID_PROMISE_20275:
+		case PCI_DEVICE_ID_PROMISE_20269:
+			map |= XFER_UDMA_133;
+		case PCI_DEVICE_ID_PROMISE_20268R:
+		case PCI_DEVICE_ID_PROMISE_20268:
+		case PCI_DEVICE_ID_PROMISE_20267:
+		case PCI_DEVICE_ID_PROMISE_20265:
+			map |= XFER_UDMA_100;
+		case PCI_DEVICE_ID_PROMISE_20262:
+			map |= XFER_UDMA_66;
+		case PCI_DEVICE_ID_PROMISE_20246:
+			map |= XFER_UDMA;
+	}
+	return map;
+}
+
 static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev = hwif->pci_dev;
 
 	unsigned int		drive_conf;
-	int			err;
 	byte			drive_pci, AP, BP, CP, DP;
 	byte			TA = 0, TB = 0, TC = 0;
 
@@ -296,7 +323,6 @@
 
 	if (!drive->init_speed)
 		drive->init_speed = speed;
-	err = ide_config_drive_speed(drive, speed);
 	drive->current_speed = speed;
 
 #if PDC202XX_DEBUG_DRIVE_INFO
@@ -306,7 +332,8 @@
 		pci_read_config_dword(dev, drive_pci, &drive_conf);
 	printk("0x%08x\n", drive_conf);
 #endif /* PDC202XX_DEBUG_DRIVE_INFO */
-	return err;
+
+	return ide_config_drive_speed(drive, speed);
 }
 
 #define set_2regs(a, b) \
@@ -333,8 +360,6 @@
 	byte thold		= 0x10;
 	byte adj		= (drive->dn%2) ? 0x08 : 0x00;
 
-	int                     err;
-
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (speed == XFER_UDMA_2) {
 		OUT_BYTE((thold + adj), indexreg);
@@ -424,10 +449,9 @@
 
 	if (!drive->init_speed)
 		drive->init_speed = speed;
-	err = ide_config_drive_speed(drive, speed);
 	drive->current_speed = speed;
 
-	return err;
+	return ide_config_drive_speed(drive, speed);
 }
 
 /*   0    1    2    3    4    5    6   7   8
@@ -449,10 +473,11 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
+static int config_chipset_for_dma(struct ata_device *drive, byte udma)
 {
 	struct hd_driveid *id	= drive->id;
 	struct ata_channel *hwif = drive->channel;
+	struct hd_driveid *mate_id = hwif->drives[!(drive->dn%2)].id;
 	struct pci_dev *dev	= hwif->pci_dev;
 	unsigned long high_16   = pci_resource_start(dev, 4);
 	unsigned long dma_base  = hwif->dma_base;
@@ -462,65 +487,41 @@
 	byte adj		= (drive->dn%2) ? 0x08 : 0x00;
 	byte cable		= 0;
 	byte jumpbit		= 0;
-	byte unit		= (drive->select.b.unit & 0x01);
 	unsigned int		drive_conf;
-	byte			drive_pci = 0;
-	byte			test1, test2, speed = -1;
+	byte drive_pci = 0, mate_pci = 0;
+	byte			test1, test2, mode = -1;
 	byte			AP;
 	unsigned short		EP;
 	byte CLKSPD		= 0;
-	byte udma_33		= ultra;
-//	byte udma_33		= ultra ? (IN_BYTE(high_16 + 0x001f) & 1) : 0;
-	byte udma_66		= ((eighty_ninty_three(drive)) && udma_33) ? 1 : 0;
-	byte udma_100		= 0;
-	byte udma_133		= 0;
+	/* primary - second bit, secondary - fourth bit */
 	byte mask		= hwif->unit ? 0x08 : 0x02;
 	unsigned short c_mask	= hwif->unit ? (1<<11) : (1<<10);
+	int map;
 
-	byte ultra_66		= ((id->dma_ultra & 0x0010) ||
-				   (id->dma_ultra & 0x0008)) ? 1 : 0;
-	byte ultra_100		= ((id->dma_ultra & 0x0020) ||
-				   (ultra_66)) ? 1 : 0;
-	byte ultra_133		= ((id->dma_ultra & 0x0040) ||
-				   (ultra_100)) ? 1 : 0;
+	byte needs_80w = ((id->dma_ultra & 0x0008) ||
+			  (id->dma_ultra & 0x0010) ||
+			  (id->dma_ultra & 0x0020) ||
+			  (id->dma_ultra & 0x0040));
 
 	switch(dev->device) {
 		case PCI_DEVICE_ID_PROMISE_20275:
 		case PCI_DEVICE_ID_PROMISE_20276:
 		case PCI_DEVICE_ID_PROMISE_20269:
-			udma_133 = (udma_66) ? 1 : 0;
-			udma_100 = (udma_66) ? 1 : 0;
-			OUT_BYTE(0x0b, (hwif->dma_base + 1));
-			cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
-			jumpbit = 1;
-			break;
 		case PCI_DEVICE_ID_PROMISE_20268R:
-			udma_100 = 1;
-			udma_66 = 1;
-			OUT_BYTE(0x0b, (hwif->dma_base + 1));
-			cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
-			jumpbit = 1;
-			break;
 		case PCI_DEVICE_ID_PROMISE_20268:
-			udma_100 = (udma_66) ? 1 : 0;
-			OUT_BYTE(0x0b, (hwif->dma_base + 1));
-			cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
+			OUT_BYTE(0x0b, indexreg);
+			cable = ((IN_BYTE(datareg) & 0x04));
 			jumpbit = 1;
 			break;
 		case PCI_DEVICE_ID_PROMISE_20267:
 		case PCI_DEVICE_ID_PROMISE_20265:
-			udma_100 = (udma_66) ? 1 : 0;
-			pci_read_config_word(dev, 0x50, &EP);
-			cable = (EP & c_mask);
-			jumpbit = 0;
-			break;
 		case PCI_DEVICE_ID_PROMISE_20262:
 			pci_read_config_word(dev, 0x50, &EP);
 			cable = (EP & c_mask);
 			jumpbit = 0;
 			break;
 		default:
-			udma_100 = 0; udma_133 = 0; cable = 1; jumpbit = 0;
+			cable = 1; jumpbit = 0;
 			break;
 	}
 
@@ -538,40 +539,26 @@
 	 * leave the 66Mhz clock on and readjust the timing
 	 * parameters.
 	 */
-
-	if (((ultra_66) || (ultra_100) || (ultra_133)) && (cable)) {
-#ifdef DEBUG
-		printk("ULTRA66: %s channel of Ultra 66 requires an 80-pin cable for Ultra66 operation.\n", hwif->unit ? "Secondary" : "Primary");
-		printk("         Switching to Ultra33 mode.\n");
-#endif /* DEBUG */
-		/* Primary   : zero out second bit */
-		/* Secondary : zero out fourth bit */
-		if (!jumpbit)
-			OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
-		printk("Warning: %s channel requires an 80-pin cable for operation.\n", hwif->unit ? "Secondary":"Primary");
-		printk("%s reduced to Ultra33 mode.\n", drive->name);
-		udma_66 = 0; udma_100 = 0; udma_133 = 0;
-	} else {
-		if ((ultra_66) || (ultra_100) || (ultra_133)) {
-			/*
-			 * check to make sure drive on same channel
-			 * is u66 capable
-			 */
-			if (hwif->drives[!(drive->dn%2)].id) {
-				if ((hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0040) ||
-				    (hwif->drives[!(drive->dn%2)].id->dma_ultra
-& 0x0020) ||
-				    (hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0010) ||
-				    (hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0008)) {
-					if (!jumpbit)
-						OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
+	if (needs_80w) {
+		/* FIXME: this check is wrong for 20246 --bkz */
+		if (cable) {
+			printk(KERN_WARNING "%s: channel requires an 80-pin cable.\n", hwif->name);
+			printk(KERN_WARNING "%s: reduced to UDMA(33) mode.\n", drive->name);
+			if (!jumpbit)
+				OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
+		}
+		if (!jumpbit) {
+			if (mate_id) {	/* check if mate is at least udma3 */
+				if ((mate_id->dma_ultra & 0x0040) ||
+				    (mate_id->dma_ultra & 0x0020) ||
+				    (mate_id->dma_ultra & 0x0010) ||
+				    (mate_id->dma_ultra & 0x0008)) {
+					OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
 				} else {
-					if (!jumpbit)
-						OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
+					OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
 				}
-			} else { /* udma4 drive by itself */
-				if (!jumpbit)
-					OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
+			} else {	/* single drive */
+				OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
 			}
 		}
 	}
@@ -587,38 +574,23 @@
 
 	switch(drive->dn) {
 		case 0:	drive_pci = 0x60;
-			pci_read_config_dword(dev, drive_pci, &drive_conf);
-			if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
-				goto chipset_is_set;
-			pci_read_config_byte(dev, (drive_pci), &test1);
-			if (!(test1 & SYNC_ERRDY_EN))
-				pci_write_config_byte(dev, (drive_pci), test1|SYNC_ERRDY_EN);
-			break;
-		case 1:	drive_pci = 0x64;
-			pci_read_config_dword(dev, drive_pci, &drive_conf);
-			if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
-				goto chipset_is_set;
-			pci_read_config_byte(dev, 0x60, &test1);
-			pci_read_config_byte(dev, (drive_pci), &test2);
-			if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN))
-				pci_write_config_byte(dev, (drive_pci), test2|SYNC_ERRDY_EN);
-			break;
 		case 2:	drive_pci = 0x68;
 			pci_read_config_dword(dev, drive_pci, &drive_conf);
 			if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
 				goto chipset_is_set;
-			pci_read_config_byte(dev, (drive_pci), &test1);
+			pci_read_config_byte(dev, drive_pci, &test1);
 			if (!(test1 & SYNC_ERRDY_EN))
-				pci_write_config_byte(dev, (drive_pci), test1|SYNC_ERRDY_EN);
+				pci_write_config_byte(dev, drive_pci, test1|SYNC_ERRDY_EN);
 			break;
-		case 3:	drive_pci = 0x6c;
+		case 1:	drive_pci = 0x64; mate_pci = 0x60;
+		case 3:	drive_pci = 0x6c; mate_pci = 0x68;
 			pci_read_config_dword(dev, drive_pci, &drive_conf);
 			if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
 				goto chipset_is_set;
-			pci_read_config_byte(dev, 0x68, &test1);
-			pci_read_config_byte(dev, (drive_pci), &test2);
+			pci_read_config_byte(dev, mate_pci, &test1);
+			pci_read_config_byte(dev, drive_pci, &test2);
 			if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN))
-				pci_write_config_byte(dev, (drive_pci), test2|SYNC_ERRDY_EN);
+				pci_write_config_byte(dev, drive_pci, test2|SYNC_ERRDY_EN);
 			break;
 		default:
 			return 0;
@@ -638,35 +610,24 @@
 
 jumpbit_is_set:
 
-	if ((id->dma_ultra & 0x0040)&&(udma_133))	speed = XFER_UDMA_6;
-	else if ((id->dma_ultra & 0x0020)&&(udma_100))	speed = XFER_UDMA_5;
-	else if ((id->dma_ultra & 0x0010)&&(udma_66))	speed = XFER_UDMA_4;
-	else if ((id->dma_ultra & 0x0008)&&(udma_66))	speed = XFER_UDMA_3;
-	else if ((id->dma_ultra & 0x0004)&&(udma_33))	speed = XFER_UDMA_2;
-	else if ((id->dma_ultra & 0x0002)&&(udma_33))	speed = XFER_UDMA_1;
-	else if ((id->dma_ultra & 0x0001)&&(udma_33))	speed = XFER_UDMA_0;
-	else if (id->dma_mword & 0x0004)		speed = XFER_MW_DMA_2;
-	else if (id->dma_mword & 0x0002)		speed = XFER_MW_DMA_1;
-	else if (id->dma_mword & 0x0001)		speed = XFER_MW_DMA_0;
-	else if ((id->dma_1word & 0x0004)&&(!jumpbit))	speed = XFER_SW_DMA_2;
-	else if ((id->dma_1word & 0x0002)&&(!jumpbit))	speed = XFER_SW_DMA_1;
-	else if ((id->dma_1word & 0x0001)&&(!jumpbit))	speed = XFER_SW_DMA_0;
-	else {
+	if (udma) {
+		map = pdc202xx_ratemask(drive);
+	} else {
+		if (!jumpbit)
+			map = XFER_SWDMA | XFER_MWDMA;
+		else
+			map = XFER_MWDMA;
+	}
+
+	mode = ata_timing_mode(drive, map);
+	if (mode < XFER_SW_DMA_0) {
 		/* restore original pci-config space */
 		if (!jumpbit)
 			pci_write_config_dword(dev, drive_pci, drive_conf);
 		return 0;
 	}
 
-	outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-	(void) hwif->speedproc(drive, speed);
-
-	return ((int)	((id->dma_ultra >> 14) & 3) ? 1 :
-			((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
+	return !(hwif->speedproc(drive, mode));
 }
 
 static int config_drive_xfer_rate(struct ata_device *drive)
@@ -727,31 +688,23 @@
 
 static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
 {
-	u8 clock		= 0;
-	u8 hardware48hack	= 0;
+	u8 lba48hack = 0, clock = 0;
 	struct ata_channel *ch = drive->channel;
 	struct pci_dev *dev	= ch->pci_dev;
 	unsigned long high_16	= pci_resource_start(dev, 4);
 	unsigned long atapi_reg	= high_16 + (ch->unit ? 0x24 : 0x00);
 
-
 	switch (dev->device) {
-		case PCI_DEVICE_ID_PROMISE_20275:
-		case PCI_DEVICE_ID_PROMISE_20276:
-		case PCI_DEVICE_ID_PROMISE_20269:
-		case PCI_DEVICE_ID_PROMISE_20268R:
-		case PCI_DEVICE_ID_PROMISE_20268:
-			break;
 		case PCI_DEVICE_ID_PROMISE_20267:
 		case PCI_DEVICE_ID_PROMISE_20265:
 		case PCI_DEVICE_ID_PROMISE_20262:
-			hardware48hack = 1;
+			lba48hack = 1;
 			clock = IN_BYTE(high_16 + 0x11);
 		default:
 			break;
 	}
 
-	if ((drive->addressing) && (hardware48hack)) {
+	if (drive->addressing && lba48hack) {
 		unsigned long word_count = 0;
 
 		outb(clock|(ch->unit ? 0x08 : 0x02), high_16 + 0x11);
@@ -772,9 +725,7 @@
 
 int pdc202xx_udma_stop(struct ata_device *drive)
 {
-	u8 newchip		= 0;
-	u8 clock		= 0;
-	u8 hardware48hack	= 0;
+	u8 lba48hack = 0, clock = 0;
 	struct ata_channel *ch = drive->channel;
 	struct pci_dev *dev	= ch->pci_dev;
 	unsigned long high_16	= pci_resource_start(dev, 4);
@@ -783,22 +734,17 @@
 	u8 dma_stat;
 
 	switch (dev->device) {
-		case PCI_DEVICE_ID_PROMISE_20275:
-		case PCI_DEVICE_ID_PROMISE_20276:
-		case PCI_DEVICE_ID_PROMISE_20269:
-		case PCI_DEVICE_ID_PROMISE_20268R:
-		case PCI_DEVICE_ID_PROMISE_20268:
-			newchip = 1;
-			break;
 		case PCI_DEVICE_ID_PROMISE_20267:
 		case PCI_DEVICE_ID_PROMISE_20265:
 		case PCI_DEVICE_ID_PROMISE_20262:
-			hardware48hack = 1;
+			lba48hack = 1;
+			/* FIXME: why do we need this here --bkz */
 			clock = IN_BYTE(high_16 + 0x11);
  		default:
 			break;
 	}
-	if ((drive->addressing) && (hardware48hack)) {
+
+	if (drive->addressing && lba48hack) {
 		outl(0, atapi_reg);	/* zero out extra */
 		clock = IN_BYTE(high_16 + 0x11);
 		OUT_BYTE(clock & ~(ch->unit ? 0x08:0x02), high_16 + 0x11);
@@ -820,7 +766,6 @@
 	u8 sc1d	= 0;
 	u8 newchip = 0;
 	u8 clock = 0;
-	u8 hardware48hack = 0;
 	struct pci_dev *dev = ch->pci_dev;
 	unsigned long high_16 = pci_resource_start(dev, 4);
 	unsigned long dma_base = ch->dma_base;
@@ -836,7 +781,7 @@
 		case PCI_DEVICE_ID_PROMISE_20267:
 		case PCI_DEVICE_ID_PROMISE_20265:
 		case PCI_DEVICE_ID_PROMISE_20262:
-			hardware48hack = 1;
+			/* FIXME: why do we need this here --bkz */
 			clock = IN_BYTE(high_16 + 0x11);
 		default:
 			break;
@@ -916,22 +861,21 @@
 			break;
 		case PCI_DEVICE_ID_PROMISE_20267:
 		case PCI_DEVICE_ID_PROMISE_20265:
-			set_reg_and_wait(udma_speed_flag | 0x10, high_16 + 0x001f, 100);
-			set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000);   /* 2 seconds ?! */
-			break;
 		case PCI_DEVICE_ID_PROMISE_20262:
 			/*
-			 * software reset -  this is required because the bios
-			 * will set UDMA timing on if the hdd supports it. The
-			 * user may want to turn udma off. A bug in the pdc20262
-			 * is that it cannot handle a downgrade in timing from
+			 * software reset - this is required because the BIOS
+			 * will set UDMA timing on if the drive supports it.
+			 * The user may want to turn udma off. A bug is that
+			 * that device cannot handle a downgrade in timing from
 			 * UDMA to DMA. Disk accesses after issuing a set
-			 * feature command will result in errors. A software
-			 * reset leaves the timing registers intact,
+			 * feature command will result in errors.
+			 *
+			 * A software reset leaves the timing registers intact,
 			 * but resets the drives.
 			 */
 			set_reg_and_wait(udma_speed_flag | 0x10, high_16 + 0x001f, 100);
-			set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000);	/* 2 seconds ?! */
+			set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000);   /* 2 seconds ?! */
+			break;
 		default:
 			if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
 				byte irq = 0, irq2 = 0;
@@ -1037,55 +981,15 @@
 
 /* module data table */
 static struct ata_pci_device chipsets[] __initdata = {
-#ifdef CONFIG_PDC202XX_FORCE
-        {
-		vendor: PCI_VENDOR_ID_PROMISE,
-		device: PCI_DEVICE_ID_PROMISE_20246,
-		init_chipset: pdc202xx_init_chipset,
-		ata66_check: NULL,
-		init_channel: ide_init_pdc202xx,
-		bootable: OFF_BOARD,
-		extra: 16,
-		flags: ATA_F_IRQ | ATA_F_DMA
-	},
-        {
-		vendor: PCI_VENDOR_ID_PROMISE,
-		device: PCI_DEVICE_ID_PROMISE_20262,
-		init_chipset: pdc202xx_init_chipset,
-		ata66_check: ata66_pdc202xx,
-		init_channel: ide_init_pdc202xx,
-		bootable: OFF_BOARD,
-		extra: 48,
-		flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
-	},
-        {
-		vendor: PCI_VENDOR_ID_PROMISE,
-		device: PCI_DEVICE_ID_PROMISE_20265,
-		init_chipset: pdc202xx_init_chipset,
-		ata66_check: ata66_pdc202xx,
-		init_channel: ide_init_pdc202xx,
-		bootable: ON_BOARD,
-		extra: 48,
-		flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
-	},
-        {
-		vendor: PCI_VENDOR_ID_PROMISE,
-		device: PCI_DEVICE_ID_PROMISE_20267,
-		init_chipset: pdc202xx_init_chipset,
-		ata66_check: ata66_pdc202xx,
-		init_channel: ide_init_pdc202xx,
-		bootable: OFF_BOARD,
-		extra: 48,
-		flags: ATA_F_IRQ | ATA_F_DMA
-	},
-#else
 	{
 		vendor: PCI_VENDOR_ID_PROMISE,
 		device: PCI_DEVICE_ID_PROMISE_20246,
 		init_chipset: pdc202xx_init_chipset,
 		ata66_check: NULL,
 		init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
 		enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
 		bootable: OFF_BOARD,
 		extra: 16,
 		flags: ATA_F_IRQ | ATA_F_DMA
@@ -1096,7 +1000,9 @@
 		init_chipset: pdc202xx_init_chipset,
 		ata66_check: ata66_pdc202xx,
 		init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
 		enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
 		bootable: OFF_BOARD,
 		extra: 48,
 		flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
@@ -1107,8 +1013,12 @@
 		init_chipset: pdc202xx_init_chipset,
 		ata66_check: ata66_pdc202xx,
 		init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
 		enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
 		bootable: OFF_BOARD,
+#else
+		bootable: ON_BOARD,
+#endif
 		extra: 48,
 		flags: ATA_F_IRQ | ATA_F_PHACK  | ATA_F_DMA
 	},
@@ -1118,12 +1028,13 @@
 		init_chipset: pdc202xx_init_chipset,
 		ata66_check: ata66_pdc202xx,
 		init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
 		enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
 		bootable: OFF_BOARD,
 		extra: 48,
 		flags: ATA_F_IRQ  | ATA_F_DMA
 	},
-#endif
 	{
 		vendor: PCI_VENDOR_ID_PROMISE,
 		device: PCI_DEVICE_ID_PROMISE_20268,
diff -Nru a/drivers/ide/pdcraid.c b/drivers/ide/pdcraid.c
--- a/drivers/ide/pdcraid.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/pdcraid.c	Fri May 24 18:55:35 2002
@@ -377,7 +377,7 @@
 static unsigned long calc_pdcblock_offset(struct block_device *bdev)
 {
 	unsigned long lba = 0;
-	ide_drive_t *ideinfo = get_info_ptr(to_kdev_t(bdev->bd_dev));
+	struct ata_device *ideinfo = get_info_ptr(to_kdev_t(bdev->bd_dev));
 
 	if (ideinfo==NULL)
 		return 0;
diff -Nru a/drivers/ide/piix.c b/drivers/ide/piix.c
--- a/drivers/ide/piix.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/piix.c	Fri May 24 18:55:35 2002
@@ -105,7 +105,6 @@
 static struct piix_ide_chip *piix_config;
 static unsigned char piix_enabled;
 static unsigned int piix_80w;
-static unsigned int piix_clock;
 
 static char *piix_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" };
 
@@ -147,7 +146,7 @@
 								: piix_dma[piix_config->flags & PIIX_UDMA]);
 
 	piix_print("BM-DMA base:                        %#x", piix_base);
-	piix_print("PCI clock:                          %d.%dMHz", piix_clock / 1000, piix_clock / 100 % 10);
+	piix_print("PCI clock:                          %d.%dMHz", system_bus_speed / 1000, system_bus_speed / 100 % 10);
 
 	piix_print("-----------------------Primary IDE-------Secondary IDE------");
 
@@ -160,7 +159,7 @@
 
 	piix_print("Cable Type:            %10s%20s", (piix_80w & 1) ? "80w" : "40w", (piix_80w & 2) ? "80w" : "40w");
 
-	if (!piix_clock)
+	if (!system_bus_speed)
                 return p - buffer;
 
 	piix_print("-------------------drive0----drive1----drive2----drive3-----");
@@ -192,8 +191,8 @@
 		}
 
 		dmaen[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
-		cycle[i] = 1000000 / piix_clock * (active[i] + recover[i]);
-		speed[i] = 2 * piix_clock / (active[i] + recover[i]);
+		cycle[i] = 1000000 / system_bus_speed * (active[i] + recover[i]);
+		speed[i] = 2 * system_bus_speed / (active[i] + recover[i]);
 
 		if (!(piix_config->flags & PIIX_UDMA))
 			continue;
@@ -213,17 +212,17 @@
 			udma[i] = (4 - ((e >> (i << 2)) & 3)) * umul;
 		} else  udma[i] = (8 - ((e >> (i << 2)) & 7)) * 2;
 
-		speed[i] = 8 * piix_clock / udma[i];
-		cycle[i] = 250000 * udma[i] / piix_clock;
+		speed[i] = 8 * system_bus_speed / udma[i];
+		cycle[i] = 250000 * udma[i] / system_bus_speed;
 	}
 
 	piix_print_drive("Transfer Mode: ", "%10s", dmaen[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
 
-	piix_print_drive("Address Setup: ", "%8dns", (1000000 / piix_clock) * 3);
-	piix_print_drive("Cmd Active:    ", "%8dns", (1000000 / piix_clock) * 12);
-	piix_print_drive("Cmd Recovery:  ", "%8dns", (1000000 / piix_clock) * 18);
-	piix_print_drive("Data Active:   ", "%8dns", (1000000 / piix_clock) * active[i]);
-	piix_print_drive("Data Recovery: ", "%8dns", (1000000 / piix_clock) * recover[i]);
+	piix_print_drive("Address Setup: ", "%8dns", (1000000 / system_bus_speed) * 3);
+	piix_print_drive("Cmd Active:    ", "%8dns", (1000000 / system_bus_speed) * 12);
+	piix_print_drive("Cmd Recovery:  ", "%8dns", (1000000 / system_bus_speed) * 18);
+	piix_print_drive("Data Active:   ", "%8dns", (1000000 / system_bus_speed) * active[i]);
+	piix_print_drive("Data Recovery: ", "%8dns", (1000000 / system_bus_speed) * recover[i]);
 	piix_print_drive("Cycle Time:    ", "%8dns", cycle[i]);
 	piix_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10);
 
@@ -324,9 +323,9 @@
  * by upper layers.
  */
 
-static int piix_set_drive(ide_drive_t *drive, unsigned char speed)
+static int piix_set_drive(struct ata_device *drive, unsigned char speed)
 {
-	ide_drive_t *peer = drive->channel->drives + (~drive->dn & 1);
+	struct ata_device *peer = drive->channel->drives + (~drive->dn & 1);
 	struct ata_timing t, p;
 	int err, T, UT, umul = 1;
 
@@ -339,7 +338,7 @@
 	if (speed > XFER_UDMA_4 && (piix_config->flags & PIIX_UDMA) >= PIIX_UDMA_100)
 		umul = 4;
 	
-	T = 1000000000 / piix_clock;
+	T = 1000000000 / system_bus_speed;
 	UT = T / umul;
 
 	ata_timing_compute(drive, speed, &t, T, UT);
@@ -364,7 +363,7 @@
  * PIO-only tuning.
  */
 
-static void piix_tune_drive(ide_drive_t *drive, unsigned char pio)
+static void piix_tune_drive(struct ata_device *drive, unsigned char pio)
 {
 	if (!((piix_enabled >> drive->channel->unit) & 1))
 		return;
@@ -491,24 +490,6 @@
 		if (~piix_config->flags & PIIX_NO_SITRE) w |= 0x4000;
 		w |= 0x44;
 		pci_write_config_word(dev, PIIX_IDETIM0 + (i << 1), w);
-	}
-
-/*
- * Determine the system bus clock.
- */
-
-	piix_clock = system_bus_speed * 1000;
-
-	switch (piix_clock) {
-		case 33000: piix_clock = 33333; break;
-		case 37000: piix_clock = 37500; break;
-		case 41000: piix_clock = 41666; break;
-	}
-
-	if (piix_clock < 20000 || piix_clock > 50000) {
-		printk(KERN_WARNING "PIIX: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", piix_clock);
-		printk(KERN_WARNING "PIIX: Use ide0=ata66 if you want to assume 80-wire cable\n");
-		piix_clock = 33333;
 	}
 
 /*
diff -Nru a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c
--- a/drivers/ide/qd65xx.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/qd65xx.c	Fri May 24 18:55:34 2002
@@ -112,7 +112,7 @@
  * This routine is invoked from ide.c to prepare for access to a given drive.
  */
 
-static void qd_select (ide_drive_t *drive)
+static void qd_select(struct ata_device *drive)
 {
 	byte index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
 			(QD_TIMREG(drive) & 0x02);
@@ -133,12 +133,12 @@
 {
 	byte active_cycle,recovery_cycle;
 
-	if (system_bus_speed <= 33) {
-		active_cycle =   9  - IDE_IN(active_time   * system_bus_speed / 1000 + 1, 2, 9);
-		recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 0, 15);
+	if (system_bus_speed <= 33333) {
+		active_cycle =   9  - IDE_IN(active_time   * system_bus_speed / 1000000 + 1, 2, 9);
+		recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_speed / 1000000 + 1, 0, 15);
 	} else {
-		active_cycle =   8  - IDE_IN(active_time   * system_bus_speed / 1000 + 1, 1, 8);
-		recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 3, 18);
+		active_cycle =   8  - IDE_IN(active_time   * system_bus_speed / 1000000 + 1, 1, 8);
+		recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_speed / 1000000 + 1, 3, 18);
 	}
 
 	return((recovery_cycle<<4) | 0x08 | active_cycle);
@@ -152,8 +152,8 @@
 
 static byte qd6580_compute_timing (int active_time, int recovery_time)
 {
-	byte active_cycle   = 17-IDE_IN(active_time   * system_bus_speed / 1000 + 1, 2, 17);
-	byte recovery_cycle = 15-IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 2, 15);
+	byte active_cycle   = 17-IDE_IN(active_time   * system_bus_speed / 1000000 + 1, 2, 17);
+	byte recovery_cycle = 15-IDE_IN(recovery_time * system_bus_speed / 1000000 + 1, 2, 15);
 
 	return((recovery_cycle<<4) | active_cycle);
 }
@@ -164,7 +164,7 @@
  * tries to find timing from dos driver's table
  */
 
-static int qd_find_disk_type (ide_drive_t *drive,
+static int qd_find_disk_type(struct ata_device *drive,
 		int *active_time, int *recovery_time)
 {
 	struct qd65xx_timing_s *p;
@@ -192,7 +192,7 @@
  * check whether timings don't conflict
  */
 
-static int qd_timing_ok (ide_drive_t drives[])
+static int qd_timing_ok(struct ata_device drives[])
 {
 	return (IDE_IMPLY(drives[0].present && drives[1].present,
 			IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1),
@@ -206,7 +206,7 @@
  * records the timing, and enables selectproc as needed
  */
 
-static void qd_set_timing (ide_drive_t *drive, byte timing)
+static void qd_set_timing(struct ata_device *drive, byte timing)
 {
 	struct ata_channel *hwif = drive->channel;
 
@@ -225,7 +225,7 @@
  * qd6500_tune_drive
  */
 
-static void qd6500_tune_drive (ide_drive_t *drive, byte pio)
+static void qd6500_tune_drive(struct ata_device *drive, byte pio)
 {
 	int active_time   = 175;
 	int recovery_time = 415; /* worst case values from the dos driver */
@@ -247,7 +247,7 @@
  * qd6580_tune_drive
  */
 
-static void qd6580_tune_drive (ide_drive_t *drive, byte pio)
+static void qd6580_tune_drive(struct ata_device *drive, byte pio)
 {
 	struct ata_timing *t;
 	int base = drive->channel->select_data;
diff -Nru a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
--- a/drivers/ide/serverworks.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/serverworks.c	Fri May 24 18:55:36 2002
@@ -240,22 +240,37 @@
 
 static struct pci_dev *isa_dev;
 
+static int svwks_ratemask(struct ata_device *drive)
+{
+	struct pci_dev *dev = drive->channel->pci_dev;
+	int map = 0;
+
+	if (!eighty_ninty_three(drive))
+		return XFER_UDMA;
+
+	switch(dev->device) {
+		case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
+			if (svwks_revision >= SVWKS_CSB5_REVISION_NEW)
+				map |= XFER_UDMA_100;
+			map |= XFER_UDMA_66;
+		case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
+			map |= XFER_UDMA;
+			break;
+	}
+	return map;
+}
+
 static int svwks_tune_chipset(struct ata_device *drive, byte speed)
 {
-	byte udma_modes[]	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
-	byte dma_modes[]	= { 0x77, 0x21, 0x20 };
-	byte pio_modes[]	= { 0x5d, 0x47, 0x34, 0x22, 0x20 };
+	static u8 udma_modes[]	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
+	static u8 dma_modes[]	= { 0x77, 0x21, 0x20 };
+	static u8 pio_modes[]	= { 0x5d, 0x47, 0x34, 0x22, 0x20 };
 
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev	= hwif->pci_dev;
 	byte unit		= (drive->select.b.unit & 0x01);
 	byte csb5		= (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;
 
-#ifdef CONFIG_BLK_DEV_IDEDMA
-	unsigned long dma_base	= hwif->dma_base;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-	int err;
-
 	byte drive_pci		= 0x00;
 	byte drive_pci2		= 0x00;
 	byte drive_pci3		= hwif->unit ? 0x57 : 0x56;
@@ -338,9 +353,6 @@
 	printk("%s: %s drive%d\n", drive->name, ide_xfer_verbose(speed), drive->dn);
 #endif /* SVWKS_DEBUG_DRIVE_INFO */
 
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
 	pci_write_config_byte(dev, drive_pci, pio_timing);
 	if (csb5)
 		pci_write_config_word(dev, 0x4A, csb5_pio);
@@ -349,16 +361,12 @@
 	pci_write_config_byte(dev, drive_pci2, dma_timing);
 	pci_write_config_byte(dev, drive_pci3, ultra_timing);
 	pci_write_config_byte(dev, 0x54, ultra_enable);
-
-	if (speed > XFER_PIO_4)
-		outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2);
-	else
-		outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
-	err = ide_config_drive_speed(drive, speed);
+#endif
+	if (!drive->init_speed)
+		drive->init_speed = speed;
 	drive->current_speed = speed;
-	return err;
+
+	return ide_config_drive_speed(drive, speed);
 }
 
 static void config_chipset_for_pio(struct ata_device *drive)
@@ -415,23 +423,14 @@
 #ifdef CONFIG_BLK_DEV_IDEDMA
 static int config_chipset_for_dma(struct ata_device *drive)
 {
-	struct hd_driveid *id	= drive->id;
-	struct pci_dev *dev	= drive->channel->pci_dev;
-	byte udma_66	= eighty_ninty_three(drive);
-	int ultra66	= (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;
-	int ultra100	= (ultra66 && svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 1 : 0;
-
-	byte speed = ata_timing_mode(drive, XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | XFER_UDMA
-				| ((udma_66 && ultra66) ? XFER_UDMA_66 : 0)
-				| ((udma_66 && ultra100) ? XFER_UDMA_100 : 0));
+	int map;
+	byte mode;
 
-	(void) svwks_tune_chipset(drive, speed);
+	/* FIXME: check SWDMA modes --bkz */
+	map = XFER_MWDMA | svwks_ratemask(drive);
+	mode = ata_timing_mode(drive, map);
 
-	return ((int)	((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
+	return !svwks_tune_chipset(drive, mode);
 }
 
 static int config_drive_xfer_rate(struct ata_device *drive)
diff -Nru a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
--- a/drivers/ide/sis5513.c	Fri May 24 18:55:35 2002
+++ b/drivers/ide/sis5513.c	Fri May 24 18:55:35 2002
@@ -409,18 +409,43 @@
 byte sis_proc = 0;
 extern char *ide_xfer_verbose (byte xfer_rate);
 
+static int sis5513_ratemask(struct ata_device *drive)
+{
+	int map = 0;
+
+	switch(chipset_family) {
+		case ATA_133:	/* map |= XFER_UDMA_133; */
+		case ATA_100:
+		case ATA_100a:
+			map |= XFER_UDMA_100;
+		case ATA_66:
+			map |= XFER_UDMA_66;
+		case ATA_33:
+			map |= XFER_UDMA;
+			break;
+		case ATA_16:
+		case ATA_00:
+		default:
+			return 0;
+	}
+
+	if (!eighty_ninty_three(drive))
+		return XFER_UDMA;
+
+	return map;
+}
 
 /*
  * Configuration functions
  */
 /* Enables per-drive prefetch and postwrite */
-static void config_drive_art_rwp (ide_drive_t *drive)
+static void config_drive_art_rwp(struct ata_device *drive)
 {
 	struct ata_channel *hwif = drive->channel;
-	struct pci_dev *dev	= hwif->pci_dev;
+	struct pci_dev *dev = hwif->pci_dev;
 
-	byte reg4bh		= 0;
-	byte rw_prefetch	= (0x11 << drive->dn);
+	u8 reg4bh = 0;
+	u8 rw_prefetch = (0x11 << drive->dn);
 
 #ifdef DEBUG
 	printk("SIS5513: config_drive_art_rwp, drive %d\n", drive->dn);
@@ -440,7 +465,7 @@
 
 
 /* Set per-drive active and recovery time */
-static void config_art_rwp_pio (ide_drive_t *drive, byte pio)
+static void config_art_rwp_pio(struct ata_device *drive, u8 pio)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev	= hwif->pci_dev;
@@ -523,9 +548,9 @@
 #endif
 }
 
-static int config_chipset_for_pio (ide_drive_t *drive, byte pio)
+static int config_chipset_for_pio(struct ata_device *drive, u8 pio)
 {
-	byte speed;
+	u8 speed;
 
 	switch(pio) {
 		case 4:		speed = XFER_PIO_4; break;
@@ -540,7 +565,7 @@
 	return ide_config_drive_speed(drive, speed);
 }
 
-static int sis5513_tune_chipset (ide_drive_t *drive, byte speed)
+static int sis5513_tune_chipset(struct ata_device *drive, u8 speed)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev	= hwif->pci_dev;
@@ -615,69 +640,35 @@
 	return ((int) ide_config_drive_speed(drive, speed));
 }
 
-static void sis5513_tune_drive (ide_drive_t *drive, byte pio)
+static void sis5513_tune_drive(struct ata_device *drive, u8 pio)
 {
 	(void) config_chipset_for_pio(drive, pio);
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-/*
- * ((id->hw_config & 0x4000|0x2000) && (drive->channel->udma_four))
- */
-static int config_chipset_for_dma (ide_drive_t *drive, byte ultra)
+static int config_chipset_for_dma(struct ata_device *drive, u8 udma)
 {
-	struct hd_driveid *id = drive->id;
-	struct ata_channel *hwif = drive->channel;
-
-	byte			speed = 0;
-
-	byte unit		= (drive->select.b.unit & 0x01);
-	byte udma_66		= eighty_ninty_three(drive);
+	int map;
+	u8 mode;
 
 #ifdef DEBUG
-	printk("SIS5513: config_chipset_for_dma, drive %d, ultra %d\n",
-	       drive->dn, ultra);
+	printk("SIS5513: config_chipset_for_dma, drive %d, udma %d\n",
+	       drive->dn, udma);
 #endif
 
-	if ((id->dma_ultra & 0x0020) && ultra && udma_66 && (chipset_family >= ATA_100a))
-		speed = XFER_UDMA_5;
-	else if ((id->dma_ultra & 0x0010) && ultra && udma_66 && (chipset_family >= ATA_66))
-		speed = XFER_UDMA_4;
-	else if ((id->dma_ultra & 0x0008) && ultra && udma_66 && (chipset_family >= ATA_66))
-		speed = XFER_UDMA_3;
-	else if ((id->dma_ultra & 0x0004) && ultra && (chipset_family >= ATA_33))
-		speed = XFER_UDMA_2;
-	else if ((id->dma_ultra & 0x0002) && ultra && (chipset_family >= ATA_33))
-		speed = XFER_UDMA_1;
-	else if ((id->dma_ultra & 0x0001) && ultra && (chipset_family >= ATA_33))
-		speed = XFER_UDMA_0;
-	else if (id->dma_mword & 0x0004)
-		speed = XFER_MW_DMA_2;
-	else if (id->dma_mword & 0x0002)
-		speed = XFER_MW_DMA_1;
-	else if (id->dma_mword & 0x0001)
-		speed = XFER_MW_DMA_0;
-	else if (id->dma_1word & 0x0004)
-		speed = XFER_SW_DMA_2;
-	else if (id->dma_1word & 0x0002)
-		speed = XFER_SW_DMA_1;
-	else if (id->dma_1word & 0x0001)
-		speed = XFER_SW_DMA_0;
+	if (udma)
+		map = sis5513_ratemask(drive);
 	else
-		return 0;
+		map = XFER_SWDMA | XFER_MWDMA;
 
-	outb(inb(hwif->dma_base+2)|(1<<(5+unit)), hwif->dma_base+2);
-
-	sis5513_tune_chipset(drive, speed);
+	mode = ata_timing_mode(drive, map);
+	if (mode < XFER_SW_DMA_0)
+		return 0;
 
-	return ((int)	((id->dma_ultra >> 11) & 7) ? 1 :
-			((id->dma_ultra >> 8) & 7) ? 1 :
-			((id->dma_mword >> 8) & 7) ? 1 :
-			((id->dma_1word >> 8) & 7) ? 1 :
-						     0);
+	return !sis5513_tune_chipset(drive, mode);
 }
 
-static int config_drive_xfer_rate (ide_drive_t *drive)
+static int config_drive_xfer_rate(struct ata_device *drive)
 {
 	struct hd_driveid *id = drive->id;
 	int on = 0;
diff -Nru a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
--- a/drivers/ide/sl82c105.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/sl82c105.c	Fri May 24 18:55:34 2002
@@ -5,8 +5,12 @@
  *
  * Maintainer unknown.
  *
- * Drive tuning added from Rebel.com's kernel sources
- *  -- Russell King (15/11/98) linux@arm.linux.org.uk
+ * Changelog:
+ *
+ * 15/11/1998	RMK	Drive tuning added from Rebel.com's kernel
+ *			sources
+ * 30/03/2002	RMK	Add fixes specified in W83C553F errata.
+ *			(with special thanks to Todd Inglett)
  */
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -28,6 +32,17 @@
 extern char *ide_xfer_verbose (byte xfer_rate);
 
 /*
+ * SL82C105 PCI config register 0x40 bits.
+ */
+#define CTRL_IDE_IRQB	(1 << 30)
+#define CTRL_IDE_IRQA	(1 << 28)
+#define CTRL_LEGIRQ	(1 << 11)
+#define CTRL_P1F16	(1 << 5)
+#define CTRL_P1EN	(1 << 4)
+#define CTRL_P0F16	(1 << 1)
+#define	CTRL_P0EN	(1 << 0)
+
+/*
  * Convert a PIO mode and cycle time to the required on/off
  * times for the interface.  This has protection against run-away
  * timings.
@@ -56,7 +71,7 @@
 /*
  * Configure the drive and chipset for PIO
  */
-static void config_for_pio(ide_drive_t *drive, int pio, int report)
+static void config_for_pio(struct ata_device *drive, int pio, int report)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev = hwif->pci_dev;
@@ -94,7 +109,7 @@
 /*
  * Configure the drive and the chipset for DMA
  */
-static int config_for_dma(ide_drive_t *drive)
+static int config_for_dma(struct ata_device *drive)
 {
 	struct ata_channel *hwif = drive->channel;
 	struct pci_dev *dev = hwif->pci_dev;
@@ -111,11 +126,12 @@
 	return 0;
 }
 
+
 /*
  * Check to see if the drive and
  * chipset is capable of DMA mode
  */
-static int sl82c105_check_drive(ide_drive_t *drive)
+static int sl82c105_check_drive(struct ata_device *drive)
 {
 	int on = 0;
 
@@ -146,6 +162,7 @@
 			break;
 		}
 	} while (0);
+
 	if (on)
 		config_for_dma(drive);
 	else
@@ -153,12 +170,12 @@
 
 	udma_enable(drive, on, 0);
 
-
 	return 0;
 }
 
 /*
- * Our own dmaproc, only to intercept ide_dma_check
+ * Our very own dmaproc.  We need to intercept various calls
+ * to fix up the SL82C105 specific behaviour.
  */
 static int sl82c105_dmaproc(struct ata_device *drive)
 {
@@ -166,10 +183,97 @@
 }
 
 /*
+ * The SL82C105 holds off all IDE interrupts while in DMA mode until
+ * all DMA activity is completed.  Sometimes this causes problems (eg,
+ * when the drive wants to report an error condition).
+ *
+ * 0x7e is a "chip testing" register.  Bit 2 resets the DMA controller
+ * state machine.  We need to kick this to work around various bugs.
+ */
+static inline void sl82c105_reset_host(struct pci_dev *dev)
+{
+	u16 val;
+
+	pci_read_config_word(dev, 0x7e, &val);
+	pci_write_config_word(dev, 0x7e, val | (1 << 2));
+	pci_write_config_word(dev, 0x7e, val & ~(1 << 2));
+}
+
+static void sl82c105_dma_enable(struct ata_device *drive, int on, int verbose)
+{
+	if (!on || config_for_dma(drive)) {
+		config_for_pio(drive, 4, 0);
+		on = 0;
+	}
+	udma_pci_enable(drive, on, verbose);
+}
+
+/*
+ * ATAPI devices can cause the SL82C105 DMA state machine to go gaga.
+ * Winbond recommend that the DMA state machine is reset prior to
+ * setting the bus master DMA enable bit.
+ *
+ * The generic IDE core will have disabled the BMEN bit before this
+ * function is called.
+ */
+static int sl82c105_dma_read(struct ata_device *drive, struct request *rq)
+{
+	sl82c105_reset_host(drive->channel->pci_dev);
+	return udma_pci_read(drive, rq);
+}
+
+static int sl82c105_dma_write(struct ata_device *drive, struct request *rq)
+{
+	sl82c105_reset_host(drive->channel->pci_dev);
+	return udma_pci_write(drive, rq);
+}
+
+static void sl82c105_timeout(struct ata_device *drive)
+{
+	sl82c105_reset_host(drive->channel->pci_dev);
+}
+
+/*
+ * If we get an IRQ timeout, it might be that the DMA state machine
+ * got confused.  Fix from Todd Inglett.  Details from Winbond.
+ *
+ * This function is called when the IDE timer expires, the drive
+ * indicates that it is READY, and we were waiting for DMA to complete.
+ */
+static void sl82c105_lostirq(struct ata_device *drive)
+{
+	struct ata_channel *ch = drive->channel;
+	struct pci_dev *dev = ch->pci_dev;
+	u32 val, mask = ch->unit ? CTRL_IDE_IRQB : CTRL_IDE_IRQA;
+	unsigned long dma_base = ch->dma_base;
+
+	printk("sl82c105: lost IRQ: resetting host\n");
+
+	/*
+	 * Check the raw interrupt from the drive.
+	 */
+	pci_read_config_dword(dev, 0x40, &val);
+	if (val & mask)
+		printk("sl82c105: drive was requesting IRQ, but host lost it\n");
+
+	/*
+	 * Was DMA enabled?  If so, disable it - we're resetting the
+	 * host.  The IDE layer will be handling the drive for us.
+	 */
+	val = inb(dma_base);
+	if (val & 1) {
+		outb(val & ~1, dma_base);
+		printk("sl82c105: DMA was enabled\n");
+	}
+
+	sl82c105_reset_host(dev);
+}
+
+/*
  * We only deal with PIO mode here - DMA mode 'using_dma' is not
  * initialised at the point that this function is called.
  */
-static void tune_sl82c105(ide_drive_t *drive, byte pio)
+static void tune_sl82c105(struct ata_device *drive, byte pio)
 {
 	config_for_pio(drive, pio, 1);
 
@@ -185,21 +289,25 @@
  * Return the revision of the Winbond bridge
  * which this function is part of.
  */
-static unsigned int sl82c105_bridge_revision(struct pci_dev *dev)
+static __init unsigned int sl82c105_bridge_revision(struct pci_dev *dev)
 {
 	struct pci_dev *bridge;
 	unsigned char rev;
 
-	bridge = pci_find_device(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_83C553, NULL);
-
 	/*
-	 * If we are part of a Winbond 553
+	 * The bridge should be part of the same device, but function 0.
 	 */
-	if (!bridge || bridge->class >> 8 != PCI_CLASS_BRIDGE_ISA)
+	bridge = pci_find_slot(dev->bus->number,
+			       PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+	if (!bridge)
 		return -1;
 
-	if (bridge->bus != dev->bus ||
-	    PCI_SLOT(bridge->devfn) != PCI_SLOT(dev->devfn))
+	/*
+	 * Make sure it is a Winbond 553 and is an ISA bridge.
+	 */
+	if (bridge->vendor != PCI_VENDOR_ID_WINBOND ||
+	    bridge->device != PCI_DEVICE_ID_WINBOND_83C553 ||
+	    bridge->class >> 8 != PCI_CLASS_BRIDGE_ISA)
 		return -1;
 
 	/*
@@ -215,49 +323,55 @@
  */
 static unsigned int __init sl82c105_init_chipset(struct pci_dev *dev)
 {
-	unsigned char ctrl_stat;
+	u32 val;
 
-	/*
-	 * Enable the ports
-	 */
-	pci_read_config_byte(dev, 0x40, &ctrl_stat);
-	pci_write_config_byte(dev, 0x40, ctrl_stat | 0x33);
+	pci_read_config_dword(dev, 0x40, &val);
+	val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1EN | CTRL_P1F16;
+	pci_write_config_dword(dev, 0x40, val);
 
 	return dev->irq;
 }
 
-static void __init sl82c105_init_dma(struct ata_channel *hwif, unsigned long dma_base)
+static void __init sl82c105_init_dma(struct ata_channel *ch, unsigned long dma_base)
 {
-	unsigned int rev;
+	unsigned int bridge_rev;
 	byte dma_state;
 
 	dma_state = inb(dma_base + 2);
-	rev = sl82c105_bridge_revision(hwif->pci_dev);
-	if (rev <= 5) {
-		hwif->autodma = 0;
-		hwif->drives[0].autotune = 1;
-		hwif->drives[1].autotune = 1;
+	bridge_rev = sl82c105_bridge_revision(ch->pci_dev);
+	if (bridge_rev <= 5) {
+		ch->autodma = 0;
+		ch->drives[0].autotune = 1;
+		ch->drives[1].autotune = 1;
 		printk("    %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
-		       hwif->name, rev);
+		       ch->name, bridge_rev);
 		dma_state &= ~0x60;
 	} else {
 		dma_state |= 0x60;
-		hwif->autodma = 1;
+		ch->autodma = 1;
 	}
 	outb(dma_state, dma_base + 2);
 
-	hwif->XXX_udma = NULL;
-	ata_init_dma(hwif, dma_base);
-	if (hwif->XXX_udma)
-		hwif->XXX_udma = sl82c105_dmaproc;
+	ata_init_dma(ch, dma_base);
+
+	if (bridge_rev <= 5)
+		ch->XXX_udma = NULL;
+	else {
+		ch->XXX_udma      = sl82c105_dmaproc;
+		ch->udma_enable   = sl82c105_dma_enable;
+		ch->udma_read     = sl82c105_dma_read;
+		ch->udma_write    = sl82c105_dma_write;
+		ch->udma_timeout  = sl82c105_timeout;
+		ch->udma_irq_lost = sl82c105_lostirq;
+	}
 }
 
 /*
  * Initialise the chip
  */
-static void __init sl82c105_init_channel(struct ata_channel *hwif)
+static void __init sl82c105_init_channel(struct ata_channel *ch)
 {
-	hwif->tuneproc = tune_sl82c105;
+	ch->tuneproc = tune_sl82c105;
 }
 
 
diff -Nru a/drivers/ide/tcq.c b/drivers/ide/tcq.c
--- a/drivers/ide/tcq.c	Fri May 24 18:55:36 2002
+++ b/drivers/ide/tcq.c	Fri May 24 18:55:36 2002
@@ -20,6 +20,7 @@
  * use tagged command queueing.
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -94,15 +95,15 @@
 
 	del_timer(&ch->timer);
 
-	if (test_bit(IDE_DMA, &ch->active))
+	if (test_bit(IDE_DMA, ch->active))
 		udma_stop(drive);
 
 	blk_queue_invalidate_tags(q);
 
 	drive->using_tcq = 0;
 	drive->queue_depth = 1;
-	clear_bit(IDE_BUSY, &ch->active);
-	clear_bit(IDE_DMA, &ch->active);
+	clear_bit(IDE_BUSY, ch->active);
+	clear_bit(IDE_DMA, ch->active);
 	ch->handler = NULL;
 
 	/*
@@ -158,7 +159,7 @@
 
 	spin_lock_irqsave(ch->lock, flags);
 
-	if (test_and_set_bit(IDE_BUSY, &ch->active))
+	if (test_and_set_bit(IDE_BUSY, ch->active))
 		printk(KERN_ERR "ATA: %s: IRQ handler not busy\n", __FUNCTION__);
 	if (!ch->handler)
 		printk(KERN_ERR "ATA: %s: missing ISR!\n", __FUNCTION__);
@@ -239,7 +240,7 @@
 	 * Could be called with IDE_DMA in-progress from invalidate
 	 * handler, refuse to do anything.
 	 */
-	if (test_bit(IDE_DMA, &drive->channel->active))
+	if (test_bit(IDE_DMA, drive->channel->active))
 		return ide_stopped;
 
 	/*
@@ -527,7 +528,7 @@
 	struct ata_channel *ch = drive->channel;
 
 	TCQ_PRINTK("%s: setting up queued %d\n", __FUNCTION__, rq->tag);
-	if (!test_bit(IDE_BUSY, &ch->active))
+	if (!test_bit(IDE_BUSY, ch->active))
 		printk("queued_rw: IDE_BUSY not set\n");
 
 	if (tcq_wait_dataphase(drive))
@@ -639,3 +640,6 @@
 	drive->using_tcq = 1;
 	return 0;
 }
+
+/* FIXME: This should go away! */
+EXPORT_SYMBOL(udma_tcq_enable);
diff -Nru a/drivers/ide/trm290.c b/drivers/ide/trm290.c
--- a/drivers/ide/trm290.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/trm290.c	Fri May 24 18:55:34 2002
@@ -142,7 +142,7 @@
 
 #include "pcihost.h"
 
-static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
+static void trm290_prepare_drive(struct ata_device *drive, unsigned int use_dma)
 {
 	struct ata_channel *hwif = drive->channel;
 	unsigned int reg;
@@ -170,7 +170,7 @@
 	__restore_flags(flags);	/* local CPU only */
 }
 
-static void trm290_selectproc (ide_drive_t *drive)
+static void trm290_selectproc(struct ata_device *drive)
 {
 	trm290_prepare_drive(drive, drive->using_dma);
 }
diff -Nru a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
--- a/drivers/ide/via82cxxx.c	Fri May 24 18:55:34 2002
+++ b/drivers/ide/via82cxxx.c	Fri May 24 18:55:34 2002
@@ -105,7 +105,7 @@
 	unsigned char rev_min;
 	unsigned char rev_max;
 	unsigned short flags;
-} via_isa_bridges[] = {
+} via_isa_bridges [] __initdata = {
 #ifdef FUTURE_BRIDGES
 	{ "vt8237",	PCI_DEVICE_ID_VIA_8237,     0x00, 0x2f, VIA_UDMA_133 },
 	{ "vt8235",	PCI_DEVICE_ID_VIA_8235,     0x00, 0x2f, VIA_UDMA_133 },
@@ -132,7 +132,6 @@
 static struct via_isa_bridge *via_config;
 static unsigned char via_enabled;
 static unsigned int via_80w;
-static unsigned int via_clock;
 static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" };
 
 /*
@@ -175,7 +174,7 @@
 	via_print("Highest DMA rate:                   %s", via_dma[via_config->flags & VIA_UDMA]);
 
 	via_print("BM-DMA base:                        %#x", via_base);
-	via_print("PCI clock:                          %d.%dMHz", via_clock / 1000, via_clock / 100 % 10);
+	via_print("PCI clock:                          %d.%dMHz", system_bus_speed / 1000, system_bus_speed / 100 % 10);
 
 	pci_read_config_byte(dev, VIA_MISC_1, &t);
 	via_print("Master Read  Cycle IRDY:            %dws", (t & 64) >> 6);
@@ -223,8 +222,8 @@
 		uen[i]       = ((u >> ((3 - i) << 3)) & 0x20);
 		den[i]       = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
 
-		speed[i] = 2 * via_clock / (active[i] + recover[i]);
-		cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock;
+		speed[i] = 2 * system_bus_speed / (active[i] + recover[i]);
+		cycle[i] = 1000000 * (active[i] + recover[i]) / system_bus_speed;
 
 		if (!uen[i] || !den[i])
 			continue;
@@ -232,34 +231,34 @@
 		switch (via_config->flags & VIA_UDMA) {
 
 			case VIA_UDMA_33:
-				speed[i] = 2 * via_clock / udma[i];
-				cycle[i] = 1000000 * udma[i] / via_clock;
+				speed[i] = 2 * system_bus_speed / udma[i];
+				cycle[i] = 1000000 * udma[i] / system_bus_speed;
 				break;
 
 			case VIA_UDMA_66:
-				speed[i] = 4 * via_clock / (udma[i] * umul[i]);
-				cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock;
+				speed[i] = 4 * system_bus_speed / (udma[i] * umul[i]);
+				cycle[i] = 500000 * (udma[i] * umul[i]) / system_bus_speed;
 				break;
 
 			case VIA_UDMA_100:
-				speed[i] = 6 * via_clock / udma[i];
-				cycle[i] = 333333 * udma[i] / via_clock;
+				speed[i] = 6 * system_bus_speed / udma[i];
+				cycle[i] = 333333 * udma[i] / system_bus_speed;
 				break;
 
 			case VIA_UDMA_133:
-				speed[i] = 8 * via_clock / udma[i];
-				cycle[i] = 250000 * udma[i] / via_clock;
+				speed[i] = 8 * system_bus_speed / udma[i];
+				cycle[i] = 250000 * udma[i] / system_bus_speed;
 				break;
 		}
 	}
 
 	via_print_drive("Transfer Mode: ", "%10s", den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
 
-	via_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / via_clock);
-	via_print_drive("Cmd Active:    ", "%8dns", 1000000 * active8b[i] / via_clock);
-	via_print_drive("Cmd Recovery:  ", "%8dns", 1000000 * recover8b[i] / via_clock);
-	via_print_drive("Data Active:   ", "%8dns", 1000000 * active[i] / via_clock);
-	via_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / via_clock);
+	via_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / system_bus_speed);
+	via_print_drive("Cmd Active:    ", "%8dns", 1000000 * active8b[i] / system_bus_speed);
+	via_print_drive("Cmd Recovery:  ", "%8dns", 1000000 * recover8b[i] / system_bus_speed);
+	via_print_drive("Data Active:   ", "%8dns", 1000000 * active[i] / system_bus_speed);
+	via_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / system_bus_speed);
 	via_print_drive("Cycle Time:    ", "%8dns", cycle[i]);
 	via_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10);
 
@@ -303,9 +302,9 @@
  * by upper layers.
  */
 
-static int via_set_drive(ide_drive_t *drive, unsigned char speed)
+static int via_set_drive(struct ata_device *drive, unsigned char speed)
 {
-	ide_drive_t *peer = drive->channel->drives + (~drive->dn & 1);
+	struct ata_device *peer = drive->channel->drives + (~drive->dn & 1);
 	struct ata_timing t, p;
 	unsigned int T, UT;
 
@@ -314,7 +313,7 @@
 			printk(KERN_WARNING "ide%d: Drive %d didn't accept speed setting. Oh, well.\n",
 				drive->dn >> 1, drive->dn & 1);
 
-	T = 1000000000 / via_clock;
+	T = 1000000000 / system_bus_speed;
 
 	switch (via_config->flags & VIA_UDMA) {
 		case VIA_UDMA_33:   UT = T;   break;
@@ -345,7 +344,7 @@
  * PIO-only tuning.
  */
 
-static void via82cxxx_tune_drive(ide_drive_t *drive, unsigned char pio)
+static void via82cxxx_tune_drive(struct ata_device *drive, unsigned char pio)
 {
 	if (!((via_enabled >> drive->channel->unit) & 1))
 		return;
@@ -471,44 +470,12 @@
 	pci_write_config_byte(dev, VIA_FIFO_CONFIG, t);
 
 /*
- * Determine system bus clock.
- */
-
-	via_clock = system_bus_speed * 1000;
-
-	switch (via_clock) {
-		case 33000: via_clock = 33333; break;
-		case 37000: via_clock = 37500; break;
-		case 41000: via_clock = 41666; break;
-	}
-
-	if (via_clock < 20000 || via_clock > 50000) {
-		printk(KERN_WARNING "VP_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", via_clock);
-		printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want to assume 80-wire cable.\n");
-		via_clock = 33333;
-	}
-
-/*
  * Print the boot message.
  */
 
 	pci_read_config_byte(isa, PCI_REVISION_ID, &t);
-	printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) IDE %s controller on pci%s\n",
+	printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) ATA %s controller on PCI %s\n",
 		via_config->name, t, via_dma[via_config->flags & VIA_UDMA], dev->slot_name);
-
-/*
- * Setup /proc/ide/via entry.
- */
-
-#if 0 && defined(CONFIG_PROC_FS)
-	if (!via_proc) {
-		via_base = pci_resource_start(dev, 4);
-		bmide_dev = dev;
-		isa_dev = isa;
-		via_display_info = &via_get_info;
-		via_proc = 1;
-	}
-#endif
 
 	return 0;
 }
diff -Nru a/drivers/ieee1394/ieee1394_types.h b/drivers/ieee1394/ieee1394_types.h
--- a/drivers/ieee1394/ieee1394_types.h	Fri May 24 18:55:36 2002
+++ b/drivers/ieee1394/ieee1394_types.h	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/version.h>
 #include <linux/list.h>
 #include <linux/init.h>
+#include <linux/string.h>
 #include <asm/byteorder.h>
 
 
diff -Nru a/drivers/input/Makefile b/drivers/input/Makefile
--- a/drivers/input/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/input/Makefile	Fri May 24 18:55:36 2002
@@ -19,11 +19,7 @@
 obj-$(CONFIG_INPUT_JOYDEV)	+= joydev.o
 obj-$(CONFIG_INPUT_EVDEV)	+= evdev.o
 
-subdir-$(CONFIG_INPUT_JOYSTICK)	+= joystick
-
-ifeq ($(CONFIG_INPUT_JOYSTICK),y)
-	obj-y += joystick/joydrv.o
-endif
+obj-$(CONFIG_INPUT_JOYSTICK)	+= joystick/
 
 # The global Rules.make.
 
diff -Nru a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
--- a/drivers/input/joystick/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/input/joystick/Makefile	Fri May 24 18:55:36 2002
@@ -2,10 +2,6 @@
 # Makefile for the input core drivers.
 #
 
-# The target object and module list name.
-
-O_TARGET	:= joydrv.o
-
 # I-Force may need both USB and RS-232
 
 CONFIG_JOYSTICK_IFORCE := n
diff -Nru a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
--- a/drivers/input/joystick/analog.c	Fri May 24 18:55:35 2002
+++ b/drivers/input/joystick/analog.c	Fri May 24 18:55:35 2002
@@ -137,10 +137,9 @@
  */
 
 #ifdef __i386__
-#define TSC_PRESENT	(test_bit(X86_FEATURE_TSC, &boot_cpu_data.x86_capability))
-#define GET_TIME(x)	do { if (TSC_PRESENT) rdtscl(x); else x = get_time_pit(); } while (0)
-#define DELTA(x,y)	(TSC_PRESENT?((y)-(x)):((x)-(y)+((x)<(y)?1193180L/HZ:0)))
-#define TIME_NAME	(TSC_PRESENT?"TSC":"PIT")
+#define GET_TIME(x)	do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
+#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?1193180L/HZ:0)))
+#define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
 static unsigned int get_time_pit(void)
 {
         extern spinlock_t i8253_lock;
diff -Nru a/drivers/isdn/Makefile b/drivers/isdn/Makefile
--- a/drivers/isdn/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/Makefile	Fri May 24 18:55:36 2002
@@ -7,21 +7,20 @@
 # Object files in subdirectories
 
 mod-subdirs				:= i4l hisax capi eicon
-subdir-$(CONFIG_ISDN)			+= i4l
-subdir-$(CONFIG_ISDN_CAPI)		+= capi
-subdir-$(CONFIG_ISDN_CAPI)		+= hardware
-subdir-$(CONFIG_ISDN_DIVERSION)		+= divert
-subdir-$(CONFIG_ISDN_DRV_HISAX)		+= hisax
-subdir-$(CONFIG_ISDN_DRV_ICN)		+= icn
-subdir-$(CONFIG_ISDN_DRV_PCBIT)		+= pcbit
-subdir-$(CONFIG_ISDN_DRV_SC)		+= sc
-subdir-$(CONFIG_ISDN_DRV_LOOP)		+= isdnloop
-subdir-$(CONFIG_ISDN_DRV_ACT2000)	+= act2000
-subdir-$(CONFIG_ISDN_DRV_EICON)		+= eicon
-subdir-$(CONFIG_HYSDN)			+= hysdn
-subdir-$(CONFIG_ISDN_DRV_TPAM)		+= tpam
 
-obj-y += $(addsuffix /vmlinux-obj.o, $(subdir-y))
+obj-$(CONFIG_ISDN)			+= i4l/
+obj-$(CONFIG_ISDN_CAPI)			+= capi/
+obj-$(CONFIG_ISDN_CAPI)			+= hardware/
+obj-$(CONFIG_ISDN_DIVERSION)		+= divert/
+obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax/
+obj-$(CONFIG_ISDN_DRV_ICN)		+= icn/
+obj-$(CONFIG_ISDN_DRV_PCBIT)		+= pcbit/
+obj-$(CONFIG_ISDN_DRV_SC)		+= sc/
+obj-$(CONFIG_ISDN_DRV_LOOP)		+= isdnloop/
+obj-$(CONFIG_ISDN_DRV_ACT2000)		+= act2000/
+obj-$(CONFIG_ISDN_DRV_EICON)		+= eicon/
+obj-$(CONFIG_HYSDN)			+= hysdn/
+obj-$(CONFIG_ISDN_DRV_TPAM)		+= tpam/
 
 # The global Rules.make.
 
diff -Nru a/drivers/isdn/act2000/Makefile b/drivers/isdn/act2000/Makefile
--- a/drivers/isdn/act2000/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/act2000/Makefile	Fri May 24 18:55:36 2002
@@ -1,15 +1,11 @@
 # Makefile for the act2000 ISDN device driver
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_ISDN_DRV_ACT2000)	+= act2000.o
 
 # Multipart objects.
 
 act2000-objs	:= module.o capi.o act2000_isa.o
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_ACT2000)	+= act2000.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
--- a/drivers/isdn/act2000/module.c	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/act2000/module.c	Fri May 24 18:55:34 2002
@@ -822,8 +822,6 @@
 		act2000_addcard(act_bus, act_port, act_irq, act_id);
         if (!cards)
                 printk(KERN_INFO "act2000: No cards defined yet\n");
-        /* No symbols to export, hide all symbols */
-        EXPORT_NO_SYMBOLS;
         return 0;
 }
 
diff -Nru a/drivers/isdn/capi/Config.help b/drivers/isdn/capi/Config.help
--- a/drivers/isdn/capi/Config.help	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/capi/Config.help	Fri May 24 18:55:36 2002
@@ -29,36 +29,3 @@
   supported by a CAPI driver, but still want to use old features like
   ippp interfaces or ttyI emulation, say Y/M here.
 
-CONFIG_ISDN_DRV_AVMB1_B1ISA
-  Enable support for the ISA version of the AVM B1 card.
-
-CONFIG_ISDN_DRV_AVMB1_B1PCI
-  Enable support for the PCI version of the AVM B1 card.
-
-CONFIG_ISDN_DRV_AVMB1_B1PCIV4
-  Enable support for the V4 version of AVM B1 PCI card.
-
-CONFIG_ISDN_DRV_AVMB1_T1ISA
-  Enable support for the AVM T1 T1B card.
-  Note: This is a PRI card and handle 30 B-channels.
-
-CONFIG_ISDN_DRV_AVMB1_B1PCMCIA
-  Enable support for the PCMCIA version of the AVM B1 card.
-
-CONFIG_ISDN_DRV_AVMB1_AVM_CS
-  Enable the PCMCIA client driver for the AVM B1/M1/M2
-  PCMCIA cards.
-
-CONFIG_ISDN_DRV_AVMB1_T1PCI
-  Enable support for the AVM T1 T1B card.
-  Note: This is a PRI card and handle 30 B-channels.
-
-CONFIG_ISDN_DRV_AVMB1_C4
-  Enable support for the AVM C4/C2 PCI cards.
-  These cards handle 4/2 BRI ISDN lines (8/4 channels).
-
-CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON
-  If you say Y here, the AVM B1 driver will give verbose reasons for
-  disconnecting. This will increase the size of the kernel by 7 KB. If
-  unsure, say Y.
-
diff -Nru a/drivers/isdn/capi/Makefile b/drivers/isdn/capi/Makefile
--- a/drivers/isdn/capi/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/capi/Makefile	Fri May 24 18:55:35 2002
@@ -1,17 +1,9 @@
 # Makefile for the CAPI subsystem.
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Objects that export symbols.
 
 export-objs	:= kcapi.o capiutil.o capilib.o capifs.o
 
-# Multipart objects.
-
-kernelcapi-objs	:= kcapi.o capiutil.o capilib.o
-
 # Ordering constraints: kernelcapi.o first
 
 # Each configuration option enables a list of files.
@@ -20,6 +12,10 @@
 obj-$(CONFIG_ISDN_CAPI_CAPI20)		+= capi.o 
 obj-$(CONFIG_ISDN_CAPI_CAPIDRV)		+= capidrv.o
 obj-$(CONFIG_ISDN_CAPI_CAPIFS)		+= capifs.o
+
+# Multipart objects.
+
+kernelcapi-objs	:= kcapi.o capiutil.o capilib.o
 
 # The global Rules.make.
 
diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
--- a/drivers/isdn/capi/capi.c	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/capi/capi.c	Fri May 24 18:55:36 2002
@@ -645,7 +645,6 @@
 {
 	struct capidev *cdev = (struct capidev *)file->private_data;
 	struct sk_buff *skb;
-	int retval;
 	size_t copied;
 
 	if (ppos != &file->f_pos)
@@ -689,7 +688,6 @@
 {
 	struct capidev *cdev = (struct capidev *)file->private_data;
 	struct sk_buff *skb;
-	int retval;
 	u16 mlen;
 
         if (ppos != &file->f_pos)
diff -Nru a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
--- a/drivers/isdn/capi/kcapi.c	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/capi/kcapi.c	Fri May 24 18:55:36 2002
@@ -1168,7 +1168,6 @@
 int capi20_manufacturer(unsigned int cmd, void *data)
 {
         struct capi_ctr *card;
-	int retval;
 
 	switch (cmd) {
 #ifdef CONFIG_AVMB1_COMPAT
diff -Nru a/drivers/isdn/divert/Makefile b/drivers/isdn/divert/Makefile
--- a/drivers/isdn/divert/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/divert/Makefile	Fri May 24 18:55:34 2002
@@ -1,18 +1,12 @@
-#
 # Makefile for the dss1_divert ISDN module
-#
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_ISDN_DIVERSION)	+= dss1_divert.o
 
 # Multipart objects.
 
 dss1_divert-objs	:= isdn_divert.o divert_procfs.o divert_init.o
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DIVERSION)	+= dss1_divert.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/isdn/eicon/Makefile b/drivers/isdn/eicon/Makefile
--- a/drivers/isdn/eicon/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/eicon/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,14 @@
 # Makefile for the eicon ISDN device driver
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Objects that export symbols.
 
 export-objs	:= Divas_mod.o eicon_mod.o
 
+# Each configuration option enables a list of files.
+
+obj-$(CONFIG_ISDN_DRV_EICON_OLD)    	+= eicon.o
+obj-$(CONFIG_ISDN_DRV_EICON_DIVAS)	+= divas.o
+
 # Multipart objects.
 
 eicon-objs	:= eicon_mod.o eicon_isa.o eicon_pci.o eicon_idi.o \
@@ -22,10 +23,5 @@
 		   linsys.o linio.o
 
 eicon-objs 	+= $(eicon-objs-y)
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_EICON_OLD)    	+= eicon.o
-obj-$(CONFIG_ISDN_DRV_EICON_DIVAS)	+= divas.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/hardware/Makefile b/drivers/isdn/hardware/Makefile
--- a/drivers/isdn/hardware/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/hardware/Makefile	Fri May 24 18:55:35 2002
@@ -1,15 +1,9 @@
 # Makefile for the CAPI hardware drivers
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Object files in subdirectories
 
-mod-subdirs				:= avm
-subdir-$(CONFIG_CAPI_AVM)		+= avm
-
-obj-y += $(addsuffix /vmlinux-obj.o, $(subdir-y))
+mod-subdirs			:= avm
+obj-$(CONFIG_CAPI_AVM)		+= avm/
 
 # The global Rules.make.
 
diff -Nru a/drivers/isdn/hardware/avm/Config.help b/drivers/isdn/hardware/avm/Config.help
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/isdn/hardware/avm/Config.help	Fri May 24 18:55:36 2002
@@ -0,0 +1,36 @@
+CONFIG_CAPI_AVM
+  Enable support for AVM active ISDN cards.
+
+CONFIG_ISDN_DRV_AVMB1_B1ISA
+  Enable support for the ISA version of the AVM B1 card.
+
+CONFIG_ISDN_DRV_AVMB1_B1PCI
+  Enable support for the PCI version of the AVM B1 card.
+
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4
+  Enable support for the V4 version of AVM B1 PCI card.
+
+CONFIG_ISDN_DRV_AVMB1_T1ISA
+  Enable support for the AVM T1 T1B card.
+  Note: This is a PRI card and handle 30 B-channels.
+
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA
+  Enable support for the PCMCIA version of the AVM B1 card.
+
+CONFIG_ISDN_DRV_AVMB1_AVM_CS
+  Enable the PCMCIA client driver for the AVM B1/M1/M2
+  PCMCIA cards.
+
+CONFIG_ISDN_DRV_AVMB1_T1PCI
+  Enable support for the AVM T1 T1B card.
+  Note: This is a PRI card and handle 30 B-channels.
+
+CONFIG_ISDN_DRV_AVMB1_C4
+  Enable support for the AVM C4/C2 PCI cards.
+  These cards handle 4/2 BRI ISDN lines (8/4 channels).
+
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON
+  If you say Y here, the AVM B1 driver will give verbose reasons for
+  disconnecting. This will increase the size of the kernel by 7 KB. If
+  unsure, say Y.
+
diff -Nru a/drivers/isdn/hardware/avm/Makefile b/drivers/isdn/hardware/avm/Makefile
--- a/drivers/isdn/hardware/avm/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/hardware/avm/Makefile	Fri May 24 18:55:35 2002
@@ -1,9 +1,5 @@
 # Makefile for the AVM ISDN device drivers
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Objects that export symbols.
 
 export-objs	:= b1dma.o b1pcmcia.o b1.o
diff -Nru a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
--- a/drivers/isdn/hisax/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/hisax/Makefile	Fri May 24 18:55:35 2002
@@ -1,9 +1,5 @@
 # Makefile for the hisax ISDN device driver
 
-# The target object and module list name.
-
-O_TARGET	  := vmlinux-obj.o
-
 # Define maximum number of cards
 
 EXTRA_CFLAGS      += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS)
@@ -12,12 +8,22 @@
 
 export-objs	  := config.o fsm.o hisax_isac.o hisax_hscx.o
 
+# Each configuration option enables a list of files.
+
+obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o
+obj-$(CONFIG_HISAX_SEDLBAUER_CS)	+= sedlbauer_cs.o
+obj-$(CONFIG_HISAX_ELSA_CS)		+= elsa_cs.o
+obj-$(CONFIG_HISAX_ST5481)		+= hisax_st5481.o
+obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
+obj-$(CONFIG_HISAX_FRITZ_CLASSIC)       += hisax_isac.o hisax_hscx.o hisax_fcclassic.o
+obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_hfcpci.o
+
 # Multipart objects.
 
-hisax-objs	  := config.o isdnl1.o tei.o isdnl2.o isdnl3.o \
-		     lmgr.o q931.o callc.o fsm.o cert.o
 hisax_st5481-objs := st5481_init.o st5481_usb.o st5481_d.o st5481_b.o \
 		     st5481_hdlc.o
+hisax-objs	  := config.o isdnl1.o tei.o isdnl2.o isdnl3.o \
+		     lmgr.o q931.o callc.o fsm.o cert.o
 
 # Optional parts of multipart objects.
 hisax-objs-$(CONFIG_HISAX_EURO) += l3dss1.o
@@ -54,16 +60,6 @@
 #hisax-objs-$(CONFIG_HISAX_TESTEMU) += testemu.o
 
 hisax-objs += $(hisax-objs-y)
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o
-obj-$(CONFIG_HISAX_SEDLBAUER_CS)	+= sedlbauer_cs.o
-obj-$(CONFIG_HISAX_ELSA_CS)		+= elsa_cs.o
-obj-$(CONFIG_HISAX_ST5481)		+= hisax_st5481.o
-obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
-obj-$(CONFIG_HISAX_FRITZ_CLASSIC)       += hisax_isac.o hisax_hscx.o hisax_fcclassic.o
-obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_hfcpci.o
 
 CERT := $(shell md5sum -c md5sums.asc >> /dev/null;echo $$?)
 CFLAGS_cert.o := -DCERTIFICATION=$(CERT)
diff -Nru a/drivers/isdn/hysdn/Makefile b/drivers/isdn/hysdn/Makefile
--- a/drivers/isdn/hysdn/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/hysdn/Makefile	Fri May 24 18:55:35 2002
@@ -1,8 +1,8 @@
 # Makefile for the hysdn ISDN device driver
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_HYSDN)	+= hysdn.o
 
 # Multipart objects.
 
@@ -14,9 +14,5 @@
 hysdn-objs-$(CONFIG_HYSDN_CAPI) += hycapi.o
 
 hysdn-objs 	+= $(hysdn-objs-y)
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_HYSDN)	+= hysdn.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
--- a/drivers/isdn/hysdn/hysdn_procconf.c	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/hysdn/hysdn_procconf.c	Fri May 24 18:55:34 2002
@@ -255,7 +255,7 @@
 	card = card_root;
 	while (card) {
 		pd = card->procconf;
-		if (pd->low_ino == (ino->i_ino & 0xFFFF))
+		if (pd == PDE(ino))
 			break;
 		card = card->next;	/* search next entry */
 	}
@@ -340,7 +340,7 @@
 	card = card_root;
 	while (card) {
 		pd = card->procconf;
-		if (pd->low_ino == (ino->i_ino & 0xFFFF))
+		if (pd == PDE(ino))
 			break;
 		card = card->next;	/* search next entry */
 	}
diff -Nru a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
--- a/drivers/isdn/hysdn/hysdn_proclog.c	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/hysdn/hysdn_proclog.c	Fri May 24 18:55:34 2002
@@ -207,7 +207,7 @@
 {
 	struct log_data *inf;
 	int len;
-	word ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	struct procdata *pd = NULL;
 	hysdn_card *card;
 
@@ -216,11 +216,10 @@
 			return (-EAGAIN);
 
 		/* sorry, but we need to search the card */
-		ino = file->f_dentry->d_inode->i_ino & 0xFFFF;	/* low-ino */
 		card = card_root;
 		while (card) {
 			pd = card->proclog;
-			if (pd->log->low_ino == ino)
+			if (pd->log == pde)
 				break;
 			card = card->next;	/* search next entry */
 		}
@@ -258,7 +257,7 @@
 	card = card_root;
 	while (card) {
 		pd = card->proclog;
-		if (pd->log->low_ino == (ino->i_ino & 0xFFFF))
+		if (pd->log == PDE(ino))
 			break;
 		card = card->next;	/* search next entry */
 	}
@@ -323,7 +322,7 @@
 			card = card_root;
 			while (card) {
 				pd = card->proclog;
-				if (pd->log->low_ino == (ino->i_ino & 0xFFFF))
+				if (pd->log == PDE(ino))
 					break;
 				card = card->next;	/* search next entry */
 			}
@@ -359,7 +358,7 @@
 hysdn_log_poll(struct file *file, poll_table * wait)
 {
 	unsigned int mask = 0;
-	word ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	hysdn_card *card;
 	struct procdata *pd = NULL;
 
@@ -367,11 +366,10 @@
 		return (mask);	/* no polling for write supported */
 
 	/* we need to search the card */
-	ino = file->f_dentry->d_inode->i_ino & 0xFFFF;	/* low-ino */
 	card = card_root;
 	while (card) {
 		pd = card->proclog;
-		if (pd->log->low_ino == ino)
+		if (pd->log == pde)
 			break;
 		card = card->next;	/* search next entry */
 	}
diff -Nru a/drivers/isdn/i4l/Makefile b/drivers/isdn/i4l/Makefile
--- a/drivers/isdn/i4l/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/i4l/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,18 @@
 # Makefile for the kernel ISDN subsystem and device drivers.
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Objects that export symbols.
 
 export-objs	:= isdn_common.o
 
+# Each configuration option enables a list of files.
+
+obj-$(CONFIG_ISDN)			+= isdn.o
+obj-$(CONFIG_ISDN_PPP_BSDCOMP)		+= isdn_bsdcomp.o
+
 # Multipart objects.
 
-isdn-objs	:= isdn_net.o isdn_tty.o isdn_v110.o isdn_common.o
+isdn-objs				:= isdn_net.o isdn_tty.o \
+					   isdn_v110.o isdn_common.o
 
 # Optional parts of multipart objects.
 
@@ -20,14 +22,5 @@
 isdn-objs-$(CONFIG_ISDN_TTY_FAX)	+= isdn_ttyfax.o
 
 isdn-objs				+= $(isdn-objs-y)
-
-# Ordering constraints: isdn.o first, rest doesn't matter
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN)			+= isdn.o
-obj-$(CONFIG_ISDN_PPP_BSDCOMP)		+= isdn_bsdcomp.o
-
-# The global Rules.make.
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/icn/Makefile b/drivers/isdn/icn/Makefile
--- a/drivers/isdn/icn/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/isdn/icn/Makefile	Fri May 24 18:55:35 2002
@@ -1,9 +1,5 @@
 # Makefile for the icn ISDN device driver
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_ISDN_DRV_ICN)	+= icn.o
diff -Nru a/drivers/isdn/isdnloop/Makefile b/drivers/isdn/isdnloop/Makefile
--- a/drivers/isdn/isdnloop/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/isdn/isdnloop/Makefile	Fri May 24 18:55:33 2002
@@ -2,10 +2,6 @@
 # Makefile for the isdnloop ISDN device driver
 #
 
-# The target object and module list name.
-
-O_TARGET	:= vmlinux-obj.o
-
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_ISDN_DRV_LOOP)	+= isdnloop.o
diff -Nru a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
--- a/drivers/isdn/isdnloop/isdnloop.c	Fri May 24 18:55:33 2002
+++ b/drivers/isdn/isdnloop/isdnloop.c	Fri May 24 18:55:33 2002
@@ -1535,9 +1535,6 @@
 	char *p;
 	char rev[10];
 
-	/* No symbols to export, hide all symbols */
-	EXPORT_NO_SYMBOLS;
-
 	if ((p = strchr(revision, ':'))) {
 		strcpy(rev, p + 1);
 		p = strchr(rev, '$');
diff -Nru a/drivers/isdn/pcbit/Makefile b/drivers/isdn/pcbit/Makefile
--- a/drivers/isdn/pcbit/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/pcbit/Makefile	Fri May 24 18:55:36 2002
@@ -1,15 +1,11 @@
 # Makefile for the pcbit ISDN device driver
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_ISDN_DRV_PCBIT)	+= pcbit.o
 
 # Multipart objects.
 
 pcbit-objs	:= module.o edss1.o drv.o layer2.o capi.o callbacks.o
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_PCBIT)	+= pcbit.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/sc/Makefile b/drivers/isdn/sc/Makefile
--- a/drivers/isdn/sc/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/sc/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,12 @@
 # Makefile for the sc ISDN device driver
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_ISDN_DRV_SC)	+= sc.o
 
 # Multipart objects.
 
 sc-objs		:= shmem.o init.o debug.o packet.o command.o event.o \
 		   ioctl.o interrupt.o message.o timer.o	
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_SC)	+= sc.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/isdn/sc/command.c b/drivers/isdn/sc/command.c
--- a/drivers/isdn/sc/command.c	Fri May 24 18:55:34 2002
+++ b/drivers/isdn/sc/command.c	Fri May 24 18:55:34 2002
@@ -123,7 +123,6 @@
 	{
 		unsigned long 	cmdptr;
 		scs_ioctl	ioc;
-		int		err;
 
 		memcpy(&cmdptr, cmd->parm.num, sizeof(unsigned long));
 		if (copy_from_user(&ioc, (scs_ioctl *)cmdptr,
diff -Nru a/drivers/isdn/sc/ioctl.c b/drivers/isdn/sc/ioctl.c
--- a/drivers/isdn/sc/ioctl.c	Fri May 24 18:55:36 2002
+++ b/drivers/isdn/sc/ioctl.c	Fri May 24 18:55:36 2002
@@ -43,7 +43,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		srec[SCIOC_SRECSIZE];
-		int		status, err;
+		int		status;
 
 		pr_debug("%s: SCIOLOAD: ioctl received\n", adapter[card]->devicename);
 		if(adapter[card]->EngineUp) {
@@ -89,7 +89,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		switchtype;
-		int 		status, err;
+		int 		status;
 
 		pr_debug("%s: SCIOSETSWITCH: ioctl received\n", adapter[card]->devicename);
 
@@ -119,7 +119,7 @@
 	{
 		RspMessage 	rcvmsg;
 		char		switchtype;
-		int		status, err;
+		int		status;
 
 		pr_debug("%s: SCIOGETSWITCH: ioctl received\n", adapter[card]->devicename);
 
@@ -153,7 +153,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		spid[SCIOC_SPIDSIZE];
-		int		status, err;
+		int		status;
 
 		pr_debug("%s: SCIOGETSPID: ioctl received\n", adapter[card]->devicename);
 
@@ -185,7 +185,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		spid[SCIOC_SPIDSIZE];
-		int 		status, err;
+		int 		status;
 
 		pr_debug("%s: DCBIOSETSPID: ioctl received\n", adapter[card]->devicename);
 
@@ -216,7 +216,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		dn[SCIOC_DNSIZE];
-		int		status, err;
+		int		status;
 
 		pr_debug("%s: SCIOGETDN: ioctl received\n", adapter[card]->devicename);
 
@@ -249,7 +249,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		dn[SCIOC_DNSIZE];
-		int 		status, err;
+		int 		status;
 
 		pr_debug("%s: SCIOSETDN: ioctl received\n", adapter[card]->devicename);
 
@@ -287,7 +287,6 @@
 	case SCIOCSTAT:
 	{
 		boardInfo bi;
-		int err;
 
 		pr_debug("%s: SCIOSTAT: ioctl received\n", adapter[card]->devicename);
 		GetStatus(card, &bi);
@@ -303,7 +302,7 @@
 	{
 		RspMessage	rcvmsg;
 		char		speed;
-		int		status, err;
+		int		status;
 
 		pr_debug("%s: SCIOGETSPEED: ioctl received\n", adapter[card]->devicename);
 
diff -Nru a/drivers/isdn/tpam/Makefile b/drivers/isdn/tpam/Makefile
--- a/drivers/isdn/tpam/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/isdn/tpam/Makefile	Fri May 24 18:55:33 2002
@@ -1,15 +1,12 @@
 # Makefile for the TurboPAM ISDN device driver
 
-# The target object and module list name.
+# Each configuration option enables a list of files.
 
-O_TARGET	:= vmlinux-obj.o
+obj-$(CONFIG_ISDN_DRV_TPAM)	+= tpam.o
 
 # Multipart objects.
 
-tpam-objs	:= tpam_main.o tpam_nco.o tpam_memory.o tpam_commands.o tpam_queues.o tpam_hdlc.o tpam_crcpc.o
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_TPAM)	+= tpam.o
+tpam-objs	:= tpam_main.o tpam_nco.o tpam_memory.o tpam_commands.o \
+		   tpam_queues.o tpam_hdlc.o tpam_crcpc.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
--- a/drivers/macintosh/apm_emu.c	Fri May 24 18:55:36 2002
+++ b/drivers/macintosh/apm_emu.c	Fri May 24 18:55:36 2002
@@ -550,5 +550,4 @@
 MODULE_AUTHOR("Benjamin Herrenschmidt");
 MODULE_DESCRIPTION("APM emulation layer for PowerMac");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
diff -Nru a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c
--- a/drivers/macintosh/macserial.c	Fri May 24 18:55:35 2002
+++ b/drivers/macintosh/macserial.c	Fri May 24 18:55:35 2002
@@ -2805,7 +2805,6 @@
 module_init(macserial_init);
 module_exit(macserial_cleanup);
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 #if 0
 /*
diff -Nru a/drivers/macintosh/rtc.c b/drivers/macintosh/rtc.c
--- a/drivers/macintosh/rtc.c	Fri May 24 18:55:35 2002
+++ b/drivers/macintosh/rtc.c	Fri May 24 18:55:35 2002
@@ -124,8 +124,6 @@
 
 static struct miscdevice rtc_dev = { RTC_MINOR, "rtc", &rtc_fops };
 
-EXPORT_NO_SYMBOLS;
-
 static int __init rtc_init(void)
 {
 	int error;
diff -Nru a/drivers/md/md.c b/drivers/md/md.c
--- a/drivers/md/md.c	Fri May 24 18:55:34 2002
+++ b/drivers/md/md.c	Fri May 24 18:55:34 2002
@@ -571,25 +571,13 @@
 	return ret;
 }
 
-static kdev_t dev_unit(kdev_t dev)
-{
-	unsigned int mask;
-	struct gendisk *hd = get_gendisk(dev);
-
-	if (!hd)
-		return NODEV;
-	mask = ~((1 << hd->minor_shift) - 1);
-
-	return mk_kdev(major(dev), minor(dev) & mask);
-}
-
-static mdk_rdev_t * match_dev_unit(mddev_t *mddev, kdev_t dev)
+static mdk_rdev_t * match_dev_unit(mddev_t *mddev, mdk_rdev_t *dev)
 {
 	struct list_head *tmp;
 	mdk_rdev_t *rdev;
 
 	ITERATE_RDEV(mddev,rdev,tmp)
-		if (kdev_same(dev_unit(rdev->dev), dev_unit(dev)))
+		if (rdev->bdev->bd_contains == dev->bdev->bd_contains)
 			return rdev;
 
 	return NULL;
@@ -601,7 +589,7 @@
 	mdk_rdev_t *rdev;
 
 	ITERATE_RDEV(mddev1,rdev,tmp)
-		if (match_dev_unit(mddev2, rdev->dev))
+		if (match_dev_unit(mddev2, rdev))
 			return 1;
 
 	return 0;
@@ -618,7 +606,7 @@
 		MD_BUG();
 		return;
 	}
-	same_pdev = match_dev_unit(mddev, rdev->dev);
+	same_pdev = match_dev_unit(mddev, rdev);
 	if (same_pdev)
 		printk( KERN_WARNING
 "md%d: WARNING: %s appears to be on the same physical disk as %s. True\n"
@@ -2297,7 +2285,7 @@
 	if (!disk_active(disk))
 		return -ENODEV;
 
-	q = blk_get_queue(rdev->dev);
+	q = bdev_get_queue(rdev->bdev);
 	if (!q) {
 		MD_BUG();
 		return -ENODEV;
diff -Nru a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c
--- a/drivers/media/radio/miropcm20-radio.c	Fri May 24 18:55:34 2002
+++ b/drivers/media/radio/miropcm20-radio.c	Fri May 24 18:55:34 2002
@@ -261,8 +261,6 @@
 MODULE_DESCRIPTION("A driver for the Miro PCM20 radio card.");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit pcm20_cleanup(void)
 {
 	unload_aci_rds();
diff -Nru a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
--- a/drivers/media/radio/radio-aimslab.c	Fri May 24 18:55:34 2002
+++ b/drivers/media/radio/radio-aimslab.c	Fri May 24 18:55:34 2002
@@ -362,8 +362,6 @@
 MODULE_PARM_DESC(io, "I/O address of the RadioTrack card (0x20f or 0x30f)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit cleanup_rtrack_module(void)
 {
 	video_unregister_device(&rtrack_radio);
diff -Nru a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
--- a/drivers/media/radio/radio-aztech.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-aztech.c	Fri May 24 18:55:35 2002
@@ -305,8 +305,6 @@
 MODULE_PARM(radio_nr, "i");
 MODULE_PARM_DESC(io, "I/O address of the Aztech card (0x350 or 0x358)");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit aztech_cleanup(void)
 {
 	video_unregister_device(&aztech_radio);
diff -Nru a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
--- a/drivers/media/radio/radio-cadet.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-cadet.c	Fri May 24 18:55:35 2002
@@ -639,8 +639,6 @@
 
 MODULE_DEVICE_TABLE(isapnp, id_table);
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit cadet_cleanup_module(void)
 {
 	video_unregister_device(&cadet_radio);
diff -Nru a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
--- a/drivers/media/radio/radio-gemtek-pci.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/radio/radio-gemtek-pci.c	Fri May 24 18:55:33 2002
@@ -412,8 +412,6 @@
 MODULE_PARM( nr_radio, "i");
 MODULE_PARM_DESC( nr_radio, "video4linux device number to use");
 
-EXPORT_NO_SYMBOLS;
-
 module_init( gemtek_pci_init_module );
 module_exit( gemtek_pci_cleanup_module );
 
diff -Nru a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
--- a/drivers/media/radio/radio-gemtek.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/radio/radio-gemtek.c	Fri May 24 18:55:33 2002
@@ -288,8 +288,6 @@
 MODULE_PARM_DESC(io, "I/O address of the GemTek card (0x20c, 0x30c, 0x24c or 0x34c (0x20c or 0x248 have been reported to work for the combined sound/radiocard)).");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit gemtek_cleanup(void)
 {
 	video_unregister_device(&gemtek_radio);
diff -Nru a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
--- a/drivers/media/radio/radio-maestro.c	Fri May 24 18:55:36 2002
+++ b/drivers/media/radio/radio-maestro.c	Fri May 24 18:55:36 2002
@@ -276,8 +276,6 @@
 MODULE_DESCRIPTION("Radio driver for the Maestro PCI sound card radio.");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 void __exit maestro_radio_exit(void)
 {
 	video_unregister_device(&maestro_radio);
diff -Nru a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
--- a/drivers/media/radio/radio-maxiradio.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-maxiradio.c	Fri May 24 18:55:35 2002
@@ -284,8 +284,6 @@
 MODULE_LICENSE("GPL");
 
 
-EXPORT_NO_SYMBOLS;
-
 static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	if(!request_region(pci_resource_start(pdev, 0),
diff -Nru a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
--- a/drivers/media/radio/radio-rtrack2.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/radio/radio-rtrack2.c	Fri May 24 18:55:33 2002
@@ -250,8 +250,6 @@
 MODULE_PARM_DESC(io, "I/O address of the RadioTrack card (0x20c or 0x30c)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit rtrack2_cleanup_module(void)
 {
 	video_unregister_device(&rtrack2_radio);
diff -Nru a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
--- a/drivers/media/radio/radio-sf16fmi.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-sf16fmi.c	Fri May 24 18:55:35 2002
@@ -331,8 +331,6 @@
 MODULE_PARM_DESC(io, "I/O address of the SF16MI card (0x284 or 0x384)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit fmi_cleanup_module(void)
 {
 	video_unregister_device(&fmi_radio);
diff -Nru a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
--- a/drivers/media/radio/radio-terratec.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-terratec.c	Fri May 24 18:55:35 2002
@@ -329,8 +329,6 @@
 MODULE_PARM_DESC(io, "I/O address of the TerraTec ActiveRadio card (0x590 or 0x591)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit terratec_cleanup_module(void)
 {
 	video_unregister_device(&terratec_radio);
diff -Nru a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
--- a/drivers/media/radio/radio-trust.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-trust.c	Fri May 24 18:55:35 2002
@@ -310,8 +310,6 @@
 MODULE_PARM_DESC(io, "I/O address of the Trust FM Radio card (0x350 or 0x358)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit cleanup_trust_module(void)
 {
 	video_unregister_device(&trust_radio);
diff -Nru a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
--- a/drivers/media/radio/radio-typhoon.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-typhoon.c	Fri May 24 18:55:35 2002
@@ -311,8 +311,6 @@
 MODULE_PARM_DESC(mutefreq, "Frequency used when muting the card (in kHz)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static int io = -1;
 static int radio_nr = -1;
 
diff -Nru a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
--- a/drivers/media/radio/radio-zoltrix.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/radio/radio-zoltrix.c	Fri May 24 18:55:35 2002
@@ -385,8 +385,6 @@
 MODULE_PARM_DESC(io, "I/O address of the Zoltrix Radio Plus (0x20c or 0x30c)");
 MODULE_PARM(radio_nr, "i");
 
-EXPORT_NO_SYMBOLS;
-
 static void __exit zoltrix_cleanup_module(void)
 {
 	video_unregister_device(&zoltrix_radio);
diff -Nru a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
--- a/drivers/media/video/adv7175.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/video/adv7175.c	Fri May 24 18:55:35 2002
@@ -457,8 +457,6 @@
 	adv7175_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int adv7175_init(void)
 {
 	int res_adv7175 = 0, res_adv7176 = 0;
diff -Nru a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
--- a/drivers/media/video/bt819.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/video/bt819.c	Fri May 24 18:55:33 2002
@@ -480,8 +480,6 @@
 	bt819_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int bt819_setup(void)
 {
 	return i2c_register_driver(&i2c_driver_bt819);
diff -Nru a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
--- a/drivers/media/video/bt856.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/video/bt856.c	Fri May 24 18:55:33 2002
@@ -286,8 +286,6 @@
 	bt856_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int bt856_init(void)
 {
 	return i2c_register_driver(&i2c_driver_bt856);
diff -Nru a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
--- a/drivers/media/video/cpia_usb.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/video/cpia_usb.c	Fri May 24 18:55:33 2002
@@ -163,6 +163,11 @@
 			}
 		}
 	}
+
+	/* resubmit */
+	urb->dev = ucpia->dev;
+	if ((i = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
+		printk(KERN_ERR __FUNCTION__ ": usb_submit_urb ret %d\n", i);
 }
 
 static int cpia_usb_open(void *privdata)
@@ -200,7 +205,9 @@
 	ucpia->curbuff = ucpia->buffers[0];
 	ucpia->workbuff = ucpia->buffers[1];
 
-	/* We double buffer the Iso lists */
+	/* We double buffer the Iso lists, and also know the polling
+	 * interval is every frame (1 == (1 << (bInterval -1))).
+	 */
 	urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
 	if (!urb) {
 		printk(KERN_ERR "cpia_init_isoc: usb_alloc_urb 0\n");
@@ -216,6 +223,7 @@
 	urb->transfer_buffer = ucpia->sbuf[0].data;
 	urb->complete = cpia_usb_complete;
 	urb->number_of_packets = FRAMES_PER_DESC;
+	urb->interval = 1;
 	urb->transfer_buffer_length = FRAME_SIZE_PER_DESC * FRAMES_PER_DESC;
 	for (fx = 0; fx < FRAMES_PER_DESC; fx++) {
 		urb->iso_frame_desc[fx].offset = FRAME_SIZE_PER_DESC * fx;
@@ -237,15 +245,14 @@
 	urb->transfer_buffer = ucpia->sbuf[1].data;
 	urb->complete = cpia_usb_complete;
 	urb->number_of_packets = FRAMES_PER_DESC;
+	urb->interval = 1;
 	urb->transfer_buffer_length = FRAME_SIZE_PER_DESC * FRAMES_PER_DESC;
 	for (fx = 0; fx < FRAMES_PER_DESC; fx++) {
 		urb->iso_frame_desc[fx].offset = FRAME_SIZE_PER_DESC * fx;
 		urb->iso_frame_desc[fx].length = FRAME_SIZE_PER_DESC;
 	}
 
-	ucpia->sbuf[1].urb->next = ucpia->sbuf[0].urb;
-	ucpia->sbuf[0].urb->next = ucpia->sbuf[1].urb;
-	
+	/* queue the ISO urbs, and resubmit in the completion handler */
 	err = usb_submit_urb(ucpia->sbuf[0].urb, GFP_KERNEL);
 	if (err) {
 		printk(KERN_ERR "cpia_init_isoc: usb_submit_urb 0 ret %d\n",
diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
--- a/drivers/media/video/meye.c	Fri May 24 18:55:36 2002
+++ b/drivers/media/video/meye.c	Fri May 24 18:55:36 2002
@@ -1445,8 +1445,6 @@
 MODULE_DESCRIPTION("video4linux driver for the MotionEye camera");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_PARM(gbuffers,"i");
 MODULE_PARM_DESC(gbuffers,"number of capture buffers, default is 2 (32 max)");
 MODULE_PARM(gbufsize,"i");
diff -Nru a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
--- a/drivers/media/video/saa7110.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/video/saa7110.c	Fri May 24 18:55:33 2002
@@ -412,8 +412,6 @@
 	saa7110_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int saa7110_init(void)
 {
 	return i2c_register_driver(&i2c_driver_saa7110);
diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
--- a/drivers/media/video/saa7111.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/video/saa7111.c	Fri May 24 18:55:35 2002
@@ -434,8 +434,6 @@
 	saa7111_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int saa7111_init(void)
 {
 	return i2c_register_driver(&i2c_driver_saa7111);
diff -Nru a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
--- a/drivers/media/video/saa7185.c	Fri May 24 18:55:33 2002
+++ b/drivers/media/video/saa7185.c	Fri May 24 18:55:33 2002
@@ -391,8 +391,6 @@
 	saa7185_command
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int saa7185_init(void)
 {
 	return i2c_register_driver(&i2c_driver_saa7185);
diff -Nru a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
--- a/drivers/media/video/tuner-3036.c	Fri May 24 18:55:35 2002
+++ b/drivers/media/video/tuner-3036.c	Fri May 24 18:55:35 2002
@@ -203,8 +203,6 @@
         &i2c_driver_tuner
 };
 
-EXPORT_NO_SYMBOLS;
-
 int __init
 tuner3036_init(void)
 {
diff -Nru a/drivers/media/video/tuner.c b/drivers/media/video/tuner.c
--- a/drivers/media/video/tuner.c	Fri May 24 18:55:34 2002
+++ b/drivers/media/video/tuner.c	Fri May 24 18:55:34 2002
@@ -988,7 +988,6 @@
 
 module_init(tuner_init_module);
 module_exit(tuner_cleanup_module);
-EXPORT_NO_SYMBOLS;
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
diff -Nru a/drivers/message/Makefile b/drivers/message/Makefile
--- a/drivers/message/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/message/Makefile	Fri May 24 18:55:35 2002
@@ -6,15 +6,8 @@
 
 mod-subdirs := i2o fusion 
 
-subdir-$(CONFIG_I2O)		+= i2o
-ifeq ($(CONFIG_I2O),y)
-  obj-y += i2o/i2o.o
-endif
-
-subdir-$(CONFIG_FUSION)		+= fusion
-ifeq ($(CONFIG_FUSION),y)
-  obj-y += fusion/fusion.o
-endif
+obj-$(CONFIG_I2O)	+= i2o/
+obj-$(CONFIG_FUSION)	+= fusion/
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
--- a/drivers/message/fusion/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/message/fusion/Makefile	Fri May 24 18:55:33 2002
@@ -43,8 +43,6 @@
 
 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC
 
-O_TARGET := fusion.o
-
 export-objs	:= mptbase.o mptscsih.o mptlan.o mptctl.o isense.o
 
 obj-$(CONFIG_FUSION)		+= mptbase.o mptscsih.o
diff -Nru a/drivers/message/fusion/isense.c b/drivers/message/fusion/isense.c
--- a/drivers/message/fusion/isense.c	Fri May 24 18:55:35 2002
+++ b/drivers/message/fusion/isense.c	Fri May 24 18:55:35 2002
@@ -84,7 +84,6 @@
 #define my_VERSION	MPT_LINUX_VERSION_COMMON
 #define MYNAM		"isense"
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR(MODULEAUTHOR);
 MODULE_DESCRIPTION(my_NAME);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
--- a/drivers/message/fusion/mptctl.c	Fri May 24 18:55:33 2002
+++ b/drivers/message/fusion/mptctl.c	Fri May 24 18:55:33 2002
@@ -91,7 +91,6 @@
 #define my_VERSION	MPT_LINUX_VERSION_COMMON
 #define MYNAM		"mptctl"
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR(MODULEAUTHOR);
 MODULE_DESCRIPTION(my_NAME);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/message/i2o/Makefile b/drivers/message/i2o/Makefile
--- a/drivers/message/i2o/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/message/i2o/Makefile	Fri May 24 18:55:34 2002
@@ -5,8 +5,6 @@
 # In the future, some of these should be built conditionally.
 #
 
-O_TARGET := i2o.o
-
 export-objs	:= i2o_pci.o i2o_core.o i2o_config.o i2o_block.o i2o_lan.o i2o_scsi.o i2o_proc.o
 
 obj-$(CONFIG_I2O_PCI)	+= i2o_pci.o
diff -Nru a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
--- a/drivers/message/i2o/i2o_block.c	Fri May 24 18:55:36 2002
+++ b/drivers/message/i2o/i2o_block.c	Fri May 24 18:55:36 2002
@@ -1891,7 +1891,6 @@
 
 #ifdef MODULE
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Red Hat Software");
 MODULE_DESCRIPTION("I2O Block Device OSM");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
--- a/drivers/message/i2o/i2o_config.c	Fri May 24 18:55:36 2002
+++ b/drivers/message/i2o/i2o_config.c	Fri May 24 18:55:36 2002
@@ -958,7 +958,6 @@
 		i2o_remove_handler(&cfg_handler);
 }
  
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Red Hat Software");
 MODULE_DESCRIPTION("I2O Configuration");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/message/i2o/i2o_lan.c b/drivers/message/i2o/i2o_lan.c
--- a/drivers/message/i2o/i2o_lan.c	Fri May 24 18:55:34 2002
+++ b/drivers/message/i2o/i2o_lan.c	Fri May 24 18:55:34 2002
@@ -1562,8 +1562,6 @@
 	i2o_remove_handler(&i2o_lan_receive_handler);
 }
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("University of Helsinki, Department of Computer Science");
 MODULE_DESCRIPTION("I2O Lan OSM");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
--- a/drivers/message/i2o/i2o_scsi.c	Fri May 24 18:55:34 2002
+++ b/drivers/message/i2o/i2o_scsi.c	Fri May 24 18:55:34 2002
@@ -38,7 +38,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
diff -Nru a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
--- a/drivers/mtd/ftl.c	Fri May 24 18:55:34 2002
+++ b/drivers/mtd/ftl.c	Fri May 24 18:55:34 2002
@@ -61,7 +61,7 @@
 /*#define PSYCHO_DEBUG */
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/ptrace.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -1191,11 +1191,14 @@
     partition_t *part;
 
     do {
-      //	    sti();
-	INIT_REQUEST;
+	//	    sti();
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
 
 	minor = minor(CURRENT->rq_dev);
-	
+
 	part = myparts[minor >> 4];
 	if (part) {
 	  ret = 0;
diff -Nru a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
--- a/drivers/mtd/mtdblock.c	Fri May 24 18:55:35 2002
+++ b/drivers/mtd/mtdblock.c	Fri May 24 18:55:35 2002
@@ -405,7 +405,11 @@
 	unsigned int res;
 
 	for (;;) {
-		INIT_REQUEST;
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
+
 		req = CURRENT;
 		spin_unlock_irq(QUEUE->queue_lock);
 		mtdblk = mtdblks[minor(req->rq_dev)];
diff -Nru a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
--- a/drivers/mtd/mtdblock_ro.c	Fri May 24 18:55:35 2002
+++ b/drivers/mtd/mtdblock_ro.c	Fri May 24 18:55:35 2002
@@ -112,11 +112,15 @@
 
    while (1)
    {
-      /* Grab the Request and unlink it from the request list, INIT_REQUEST
-       	 will execute a return if we are done. */
-      INIT_REQUEST;
+      /* Grab the Request and unlink it from the request list, we
+	 will execute a return if we are done. */
+	if (blk_queue_empty(QUEUE)) {
+		CLEAR_INTR;
+		return;
+	}
+
       current_request = CURRENT;
-   
+
       if (minor(current_request->rq_dev) >= MAX_MTD_DEVICES)
       {
 	 printk("mtd: Unsupported device!\n");
diff -Nru a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
--- a/drivers/mtd/nftlcore.c	Fri May 24 18:55:33 2002
+++ b/drivers/mtd/nftlcore.c	Fri May 24 18:55:33 2002
@@ -837,7 +837,11 @@
 	int res;
 
 	while (1) {
-		INIT_REQUEST;	/* blk.h */
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
+
 		req = CURRENT;
 		
 		/* We can do this because the generic code knows not to
diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
--- a/drivers/net/8390.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/8390.c	Fri May 24 18:55:33 2002
@@ -52,7 +52,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/fs.h>
 #include <linux/types.h>
 #include <linux/ptrace.h>
diff -Nru a/drivers/net/Makefile b/drivers/net/Makefile
--- a/drivers/net/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/net/Makefile	Fri May 24 18:55:34 2002
@@ -25,18 +25,8 @@
   obj-$(CONFIG_ISDN) += slhc.o
 endif
 
-subdir-$(CONFIG_NET_PCMCIA) += pcmcia
-subdir-$(CONFIG_NET_WIRELESS) += wireless
-
-subdir-$(CONFIG_E100) += e100
-ifeq ($(CONFIG_E100),y)
-  obj-y += e100/e100.o
-endif
-
-subdir-$(CONFIG_E1000) += e1000
-ifeq ($(CONFIG_E1000),y)
-  obj-y += e1000/e1000.o
-endif
+obj-$(CONFIG_E100) += e100/
+obj-$(CONFIG_E1000) += e1000/
 
 #
 # link order important here
@@ -75,17 +65,8 @@
 obj-$(CONFIG_FEALNX) += fealnx.o mii.o
 obj-$(CONFIG_TIGON3) += tg3.o
 obj-$(CONFIG_TC35815) += tc35815.o
-
-subdir-$(CONFIG_SK98LIN) += sk98lin
-ifeq ($(CONFIG_SK98LIN),y)
-obj-y += sk98lin/sk98lin.o
-endif
-
-subdir-$(CONFIG_SKFP) += skfp
-ifeq ($(CONFIG_SKFP),y)
-  obj-y += skfp/skfp.o
-endif
-
+obj-$(CONFIG_SK98LIN) += sk98lin/
+obj-$(CONFIG_SKFP) += skfp/
 obj-$(CONFIG_VIA_RHINE) += via-rhine.o mii.o
 obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o
 
@@ -210,60 +191,17 @@
 obj-$(CONFIG_TUN) += tun.o
 obj-$(CONFIG_DL2K) += dl2k.o
 
-subdir-$(CONFIG_ARCH_ACORN) += ../acorn/net
-ifeq ($(CONFIG_ARCH_ACORN),y)
-  obj-y		+= ../acorn/net/acorn-net.o
-endif
-
-subdir-$(CONFIG_NET_FC) += fc
-ifeq ($(CONFIG_NET_FC),y)
-  obj-y		+= fc/fc.o
-endif
-
-subdir-$(CONFIG_DEV_APPLETALK) += appletalk
-ifeq ($(CONFIG_DEV_APPLETALK),y)
-  obj-y		+= appletalk/appletalk.o
-endif
-
-subdir-$(CONFIG_TR) += tokenring
-ifeq ($(CONFIG_TR),y)
-  obj-y		+= tokenring/tr.o
-endif
-
-subdir-$(CONFIG_WAN) += wan
-ifeq ($(CONFIG_WAN),y)
-  obj-y		+= wan/wan.o
-endif
-
-subdir-$(CONFIG_ARCNET) += arcnet
-ifeq ($(CONFIG_ARCNET),y)
-  obj-y		+= arcnet/arcnetdrv.o
-endif
-
-subdir-$(CONFIG_NET_PCMCIA) += pcmcia
-ifeq ($(CONFIG_NET_PCMCIA),y)
-  obj-y		+= pcmcia/pcmcia_net.o
-endif
-
-subdir-$(CONFIG_NET_WIRELESS) += wireless
-ifeq ($(CONFIG_NET_WIRELESS),y)
-  obj-y		+= wireless/wireless_net.o
-endif
-
-subdir-$(CONFIG_NET_TULIP) += tulip
-ifeq ($(CONFIG_NET_TULIP),y)
-  obj-y		+= tulip/tulip_net.o
-endif
-
-subdir-$(CONFIG_HAMRADIO) += hamradio
-ifeq ($(CONFIG_HAMRADIO),y)
-  obj-y		+= hamradio/hamradio.o
-endif
-
-subdir-$(CONFIG_IRDA) += irda
-ifeq ($(CONFIG_IRDA),y)
-  obj-y		+= irda/irda.o
-endif
+obj-$(CONFIG_ARCH_ACORN) += ../acorn/net/
+obj-$(CONFIG_NET_FC) += fc/
+obj-$(CONFIG_DEV_APPLETALK) += appletalk/
+obj-$(CONFIG_TR) += tokenring/
+obj-$(CONFIG_WAN) += wan/
+obj-$(CONFIG_ARCNET) += arcnet/
+obj-$(CONFIG_NET_PCMCIA) += pcmcia/
+obj-$(CONFIG_NET_WIRELESS) += wireless/
+obj-$(CONFIG_NET_TULIP) += tulip/
+obj-$(CONFIG_HAMRADIO) += hamradio/
+obj-$(CONFIG_IRDA) += irda/
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/net/appletalk/Makefile b/drivers/net/appletalk/Makefile
--- a/drivers/net/appletalk/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/appletalk/Makefile	Fri May 24 18:55:33 2002
@@ -1,22 +1,12 @@
 #
 # Makefile for drivers/net/appletalk
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
 
-obj-y   :=
-obj-n   :=
-obj-m   :=
-obj-    :=
 export-objs :=
 
 obj-$(CONFIG_IPDDP) += ipddp.o
 obj-$(CONFIG_COPS) += cops.o
 obj-$(CONFIG_LTPC) += ltpc.o
-
-O_TARGET := appletalk.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/net/arcnet/Makefile b/drivers/net/arcnet/Makefile
--- a/drivers/net/arcnet/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/arcnet/Makefile	Fri May 24 18:55:33 2002
@@ -1,14 +1,6 @@
 # Makefile for linux/drivers/net/arcnet
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
 
-obj-y	:=
-obj-n	:=
-obj-m	:=
-obj-	:=
 export-objs := arcnet.o com20020.o
 
 obj-$(CONFIG_ARCNET) += arcnet.o
@@ -21,7 +13,5 @@
 obj-$(CONFIG_ARCNET_COM20020) += com20020.o
 obj-$(CONFIG_ARCNET_COM20020_ISA) += com20020-isa.o
 obj-$(CONFIG_ARCNET_COM20020_PCI) += com20020-pci.o
-
-O_TARGET := arcnetdrv.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/atari_bionet.c b/drivers/net/atari_bionet.c
--- a/drivers/net/atari_bionet.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/atari_bionet.c	Fri May 24 18:55:33 2002
@@ -86,7 +86,7 @@
 
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
diff -Nru a/drivers/net/atari_pamsnet.c b/drivers/net/atari_pamsnet.c
--- a/drivers/net/atari_pamsnet.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/atari_pamsnet.c	Fri May 24 18:55:35 2002
@@ -80,7 +80,7 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
diff -Nru a/drivers/net/auto_irq.c b/drivers/net/auto_irq.c
--- a/drivers/net/auto_irq.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/auto_irq.c	Fri May 24 18:55:33 2002
@@ -31,7 +31,7 @@
 #endif
 
 #include <linux/module.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/delay.h>
 #include <asm/bitops.h>
 #include <asm/io.h>
diff -Nru a/drivers/net/bmac.c b/drivers/net/bmac.c
--- a/drivers/net/bmac.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/bmac.c	Fri May 24 18:55:33 2002
@@ -1676,7 +1676,6 @@
 MODULE_AUTHOR("Randy Gobbel/Paul Mackerras");
 MODULE_DESCRIPTION("PowerMac BMAC ethernet driver.");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 static void __exit bmac_cleanup (void)
 {
diff -Nru a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
--- a/drivers/net/cs89x0.c	Fri May 24 18:55:36 2002
+++ b/drivers/net/cs89x0.c	Fri May 24 18:55:36 2002
@@ -1703,8 +1703,6 @@
 MODULE_LICENSE("GPL");
 
 
-EXPORT_NO_SYMBOLS;
-
 /*
 * media=t             - specify media type
    or media=2
diff -Nru a/drivers/net/declance.c b/drivers/net/declance.c
--- a/drivers/net/declance.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/declance.c	Fri May 24 18:55:33 2002
@@ -791,6 +791,8 @@
 	ib->mode = 0;
 	ib->filter [0] = 0;
 	ib->filter [2] = 0;
+	ib->filter [4] = 0;
+	ib->filter [6] = 0;
 
 	lance_init_ring(dev);
 	load_csrs(lp);
@@ -943,9 +945,9 @@
 		if (!(*addrs & 1))
 			continue;
 
-		crc = ether_crc(6, addrs);
+		crc = ether_crc_le(6, addrs);
 		crc = crc >> 26;
-		mcast_table[crc >> 3] |= 1 << (crc & 0xf);
+		mcast_table[2 * (crc >> 4)] |= 1 << (crc & 0xf);
 	}
 	return;
 }
diff -Nru a/drivers/net/e100/Makefile b/drivers/net/e100/Makefile
--- a/drivers/net/e100/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/net/e100/Makefile	Fri May 24 18:55:36 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the Intel's E100 ethernet driver
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := e100.o
+obj-$(CONFIG_E100) += e100.o
 
-obj-y   := e100_main.o e100_config.o e100_proc.o e100_phy.o \
-	   e100_eeprom.o e100_test.o
-obj-m   := $(O_TARGET)
+e100-objs := e100_main.o e100_config.o e100_proc.o e100_phy.o \
+	     e100_eeprom.o e100_test.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/e100/e100_main.c b/drivers/net/e100/e100_main.c
--- a/drivers/net/e100/e100_main.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/e100/e100_main.c	Fri May 24 18:55:35 2002
@@ -399,7 +399,6 @@
 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
 MODULE_DESCRIPTION(E100_FULL_DRIVER_NAME E100_VERSION);
 MODULE_LICENSE("Dual BSD/GPL");
-EXPORT_NO_SYMBOLS;
 
 E100_PARAM(TxDescriptors, "Number of transmit descriptors");
 E100_PARAM(RxDescriptors, "Number of receive descriptors");
diff -Nru a/drivers/net/e1000/Makefile b/drivers/net/e1000/Makefile
--- a/drivers/net/e1000/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/e1000/Makefile	Fri May 24 18:55:33 2002
@@ -1,15 +1,10 @@
 #
 # Makefile for the Intel(R) PRO/1000 ethernet driver
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := e1000.o
+obj-$(CONFIG_E1000) += e1000.o
 
-obj-y   := e1000_main.o e1000_hw.o e1000_ethtool.o e1000_param.o e1000_proc.o
-obj-m   := $(O_TARGET)
+e1000-objs := e1000_main.o e1000_hw.o e1000_ethtool.o e1000_param.o \
+	      e1000_proc.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
--- a/drivers/net/e1000/e1000_main.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/e1000/e1000_main.c	Fri May 24 18:55:35 2002
@@ -196,7 +196,6 @@
 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
 MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
 MODULE_LICENSE("Dual BSD/GPL");
-EXPORT_NO_SYMBOLS;
 
 /**
  * e1000_init_module - Driver Registration Routine
diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
--- a/drivers/net/epic100.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/epic100.c	Fri May 24 18:55:35 2002
@@ -582,7 +582,7 @@
 #define EE_READ256_CMD	(6 << 8)
 #define EE_ERASE_CMD	(7 << 6)
 
-static int read_eeprom(long ioaddr, int location)
+static int __devinit read_eeprom(long ioaddr, int location)
 {
 	int i;
 	int retval = 0;
diff -Nru a/drivers/net/ethertap.c b/drivers/net/ethertap.c
--- a/drivers/net/ethertap.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/ethertap.c	Fri May 24 18:55:34 2002
@@ -15,7 +15,7 @@
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
diff -Nru a/drivers/net/fc/Makefile b/drivers/net/fc/Makefile
--- a/drivers/net/fc/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/net/fc/Makefile	Fri May 24 18:55:34 2002
@@ -5,8 +5,6 @@
 # Rewritten to use lists instead of if-statements.
 #
 
-O_TARGET := fc.o
-
 obj-$(CONFIG_IPHASE5526)	+= iph5526.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/hamradio/Makefile b/drivers/net/hamradio/Makefile
--- a/drivers/net/hamradio/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/hamradio/Makefile	Fri May 24 18:55:33 2002
@@ -10,12 +10,8 @@
 #		Christoph Hellwig <hch@infradead.org>
 #
 
-
-O_TARGET := hamradio.o
-
 export-objs	= hdlcdrv.o
 
-
 obj-$(CONFIG_DMASCC)		+= dmascc.o
 obj-$(CONFIG_SCC)		+= scc.o
 obj-$(CONFIG_MKISS)		+= mkiss.o
@@ -26,12 +22,6 @@
 obj-$(CONFIG_BAYCOM_SER_HDX)	+= baycom_ser_hdx.o	hdlcdrv.o
 obj-$(CONFIG_BAYCOM_PAR)	+= baycom_par.o		hdlcdrv.o
 obj-$(CONFIG_BAYCOM_EPP)	+= baycom_epp.o		hdlcdrv.o
-obj-$(CONFIG_SOUNDMODEM)	+= 			hdlcdrv.o
-
-subdir-$(CONFIG_SOUNDMODEM) += soundmodem
-
-ifeq ($(CONFIG_SOUNDMODEM),y)
-obj-y += soundmodem/soundmodem.o
-endif
+obj-$(CONFIG_SOUNDMODEM)	+= soundmodem/		hdlcdrv.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/hamradio/soundmodem/Makefile b/drivers/net/hamradio/soundmodem/Makefile
--- a/drivers/net/hamradio/soundmodem/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/hamradio/soundmodem/Makefile	Fri May 24 18:55:33 2002
@@ -1,42 +1,34 @@
 #
 # Makefile for the soundmodem device driver.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now inherited from the
-# parent makes..
-#
-
-O_TARGET	:= soundmodem.o
-
-obj-y		:= sm.o
-obj-$(CONFIG_SOUNDMODEM_SBC) += sm_sbc.o
-obj-$(CONFIG_SOUNDMODEM_WSS) += sm_wss.o
-obj-$(CONFIG_SOUNDMODEM_AFSK1200) += sm_afsk1200.o
-obj-$(CONFIG_SOUNDMODEM_AFSK2400_7) += sm_afsk2400_7.o
-obj-$(CONFIG_SOUNDMODEM_AFSK2400_8) += sm_afsk2400_8.o
-obj-$(CONFIG_SOUNDMODEM_AFSK2666) += sm_afsk2666.o
-obj-$(CONFIG_SOUNDMODEM_HAPN4800) += sm_hapn4800.o
-obj-$(CONFIG_SOUNDMODEM_PSK4800) += sm_psk4800.o
-obj-$(CONFIG_SOUNDMODEM_FSK9600) += sm_fsk9600.o
 
-obj-m		:= $(O_TARGET)
+obj-$(CONFIG_SOUNDMODEM) += soundmodem.o
 
-all:		all_targets
-.PHONY:		all
+soundmodem-y					:= sm.o
+soundmodem-$(CONFIG_SOUNDMODEM_SBC)		+= sm_sbc.o
+soundmodem-$(CONFIG_SOUNDMODEM_WSS)		+= sm_wss.o
+soundmodem-$(CONFIG_SOUNDMODEM_AFSK1200)	+= sm_afsk1200.o
+soundmodem-$(CONFIG_SOUNDMODEM_AFSK2400_7)	+= sm_afsk2400_7.o
+soundmodem-$(CONFIG_SOUNDMODEM_AFSK2400_8)	+= sm_afsk2400_8.o
+soundmodem-$(CONFIG_SOUNDMODEM_AFSK2666)	+= sm_afsk2666.o
+soundmodem-$(CONFIG_SOUNDMODEM_HAPN4800)	+= sm_hapn4800.o
+soundmodem-$(CONFIG_SOUNDMODEM_PSK4800)		+= sm_psk4800.o
+soundmodem-$(CONFIG_SOUNDMODEM_FSK9600)		+= sm_fsk9600.o
+soundmodem-objs					:= $(soundmodem-y)
 
-gentbl:		gentbl.c
-		$(HOSTCC) $(HOSTCFLAGS) $< -o $@ -lm
+include $(TOPDIR)/Rules.make
+
+# Dependencies on generates files need to be listed explicitly
 
-TBLHDR		:= sm_tbl_afsk1200.h sm_tbl_afsk2400_8.h 
-TBLHDR		+= sm_tbl_afsk2666.h sm_tbl_psk4800.h
-TBLHDR		+= sm_tbl_hapn4800.h sm_tbl_fsk9600.h
+sm_%.o: sm_tbl_%.h
+
+TBLHDR		:= sm_tbl_afsk1200.h sm_tbl_afsk2400_7.h sm_tbl_afsk2400_8.h \
+		   sm_tbl_afsk2666.h sm_tbl_psk4800.h	 sm_tbl_hapn4800.h \
+		   sm_tbl_fsk9600.h
 
 $(TBLHDR):	gentbl
 		./gentbl
 
-fastdep:	$(TBLHDR)
+gentbl:		gentbl.c
+		$(HOSTCC) $(HOSTCFLAGS) $< -o $@ -lm
 
-include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/hp100.c b/drivers/net/hp100.c
--- a/drivers/net/hp100.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/hp100.c	Fri May 24 18:55:35 2002
@@ -121,7 +121,6 @@
 
 #define LINUX_2_1
 typedef struct net_device_stats hp100_stats_t;
-EXPORT_NO_SYMBOLS;
 
 #include "hp100.h"
 
diff -Nru a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
--- a/drivers/net/irda/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/net/irda/Makefile	Fri May 24 18:55:35 2002
@@ -1,4 +1,3 @@
-# File: drivers/irda/Makefile
 #
 # Makefile for the Linux IrDA infrared port device drivers.
 #
@@ -6,10 +5,7 @@
 # Rewritten to use lists instead of if-statements.
 #
 
-O_TARGET := irda.o
-
 export-objs	= irport.o
-
 
 obj-$(CONFIG_IRTTY_SIR)		+= irtty.o
 obj-$(CONFIG_IRPORT_SIR)	+= 		irport.o
diff -Nru a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
--- a/drivers/net/irda/sa1100_ir.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/irda/sa1100_ir.c	Fri May 24 18:55:35 2002
@@ -1195,4 +1195,3 @@
 MODULE_PARM_DESC(tx_lpm, "Enable transmitter low power (1.6us) mode");
 MODULE_PARM(max_rate, "i");
 MODULE_PARM_DESC(max_rate, "Maximum baud rate (4000000, 115200, 57600, 38400, 19200, 9600)");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/net/loopback.c b/drivers/net/loopback.c
--- a/drivers/net/loopback.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/loopback.c	Fri May 24 18:55:34 2002
@@ -29,7 +29,7 @@
  *		2 of the License, or (at your option) any later version.
  */
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/interrupt.h>
 #include <linux/fs.h>
 #include <linux/types.h>
diff -Nru a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
--- a/drivers/net/mac89x0.c	Fri May 24 18:55:36 2002
+++ b/drivers/net/mac89x0.c	Fri May 24 18:55:36 2002
@@ -629,8 +629,6 @@
 MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 int
 init_module(void)
 {
diff -Nru a/drivers/net/mace.c b/drivers/net/mace.c
--- a/drivers/net/mace.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/mace.c	Fri May 24 18:55:34 2002
@@ -948,7 +948,6 @@
 MODULE_PARM(port_aaui, "i");
 MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 static void __exit mace_cleanup (void)
 {
diff -Nru a/drivers/net/macsonic.c b/drivers/net/macsonic.c
--- a/drivers/net/macsonic.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/macsonic.c	Fri May 24 18:55:33 2002
@@ -585,8 +585,6 @@
 MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 int
 init_module(void)
 {
diff -Nru a/drivers/net/pcmcia/Makefile b/drivers/net/pcmcia/Makefile
--- a/drivers/net/pcmcia/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/pcmcia/Makefile	Fri May 24 18:55:33 2002
@@ -1,15 +1,6 @@
 #
-# drivers/net/pcmcia/Makefile
-#
 # Makefile for the Linux PCMCIA network device drivers.
 #
-
-O_TARGET := pcmcia_net.o
-
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
 
 # Things that need to export symbols
 export-objs	:= ray_cs.o
diff -Nru a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
--- a/drivers/net/sk98lin/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/sk98lin/Makefile	Fri May 24 18:55:33 2002
@@ -1,14 +1,12 @@
-# File: drivers/sk98lin/Makefile
 #
 # Makefile for the SysKonnect SK-98xx device driver.
 #
 
-O_TARGET := sk98lin.o
+obj-$(CONFIG_SK98LIN) += sk98lin.o
 
-obj-y :=     skge.o skaddr.o skgehwt.o skgeinit.o skgepnmi.o skgesirq.o \
-             ski2c.o sklm80.o skqueue.o skrlmt.o sktimer.o skvpd.o \
-             skxmac2.o skproc.o skcsum.o
-obj-m := $(O_TARGET)
+sk98lin-objs := skge.o skaddr.o skgehwt.o skgeinit.o skgepnmi.o skgesirq.o \
+		ski2c.o sklm80.o skqueue.o skrlmt.o sktimer.o skvpd.o \
+		skxmac2.o skproc.o skcsum.o
 
 # DBGDEF =  \
 # -DDEBUG
diff -Nru a/drivers/net/skfp/Makefile b/drivers/net/skfp/Makefile
--- a/drivers/net/skfp/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/net/skfp/Makefile	Fri May 24 18:55:36 2002
@@ -2,12 +2,12 @@
 # Makefile for the SysKonnect FDDI PCI adapter driver
 #
 
-O_TARGET := skfp.o
-obj-y :=      skfddi.o    hwmtm.o    fplustm.o  smt.o      cfm.o     \
+obj-$(CONFIG_SKFP) += skfp.o
+
+skfp-objs :=  skfddi.o    hwmtm.o    fplustm.o  smt.o      cfm.o     \
               ecm.o       pcmplc.o   pmf.o      queue.o    rmt.o     \
 	      smtdef.o    smtinit.o  smttimer.o srf.o      lnkstat.o \
               smtparse.o  hwt.o      drvfbi.o   ess.o
-obj-m := skfp.o
 
 # NOTE:
 #   Compiling this driver produces some warnings (and some more are 
@@ -16,7 +16,7 @@
 #   drivers, and fixing it for Linux might bring problems on other
 #   projects. To keep the source common for all those drivers (and
 #   thus simplify fixes to it), please do not clean it up!
- 
+
 EXTRA_CFLAGS += -I. -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes 
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
--- a/drivers/net/smc-ultra.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/smc-ultra.c	Fri May 24 18:55:33 2002
@@ -506,8 +506,6 @@
 MODULE_DESCRIPTION("SMC Ultra/EtherEZ ISA/PnP Ethernet driver");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 /* This is set up so that only a single autoprobe takes place per call.
 ISA device autoprobes on a running machine are not recommended. */
 int
diff -Nru a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/sundance.c	Fri May 24 18:55:33 2002
@@ -637,7 +637,7 @@
 
 
 /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. */
-static int eeprom_read(long ioaddr, int location)
+static int __devinit eeprom_read(long ioaddr, int location)
 {
 	int boguscnt = 1000;		/* Typical 190 ticks. */
 	writew(0x0200 | (location & 0xff), ioaddr + EECtrl);
diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
--- a/drivers/net/sunlance.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/sunlance.c	Fri May 24 18:55:34 2002
@@ -258,7 +258,7 @@
 	void (*tx)(struct net_device *);
 
 	char	       	       *name;
-	__u32			init_block_dvma;
+	dma_addr_t		init_block_dvma;
 	struct net_device      *dev;		  /* Backpointer	*/
 	struct lance_private   *next_module;
 	struct sbus_dev	       *sdev;
@@ -320,7 +320,7 @@
 {
 	struct lance_private *lp = (struct lance_private *) dev->priv;
 	volatile struct lance_init_block *ib = lp->init_block;
-	__u32 aib = lp->init_block_dvma;
+	dma_addr_t aib = lp->init_block_dvma;
 	__u32 leptr;
 	int i;
     
diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
--- a/drivers/net/tg3.c	Fri May 24 18:55:36 2002
+++ b/drivers/net/tg3.c	Fri May 24 18:55:36 2002
@@ -152,6 +152,8 @@
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
 	{ PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1000,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
 	{ 0, }
 };
 
@@ -5682,7 +5684,8 @@
 	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_5701 &&
 	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_5702FE &&
 	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_5703 &&
-	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_5703S)
+	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_5703S &&
+	    grc_misc_cfg != GRC_MISC_CFG_BOARD_ID_AC91002A1)
 		return -ENODEV;
 
 	/* ROFL, you should see Broadcom's driver code implementing
diff -Nru a/drivers/net/tg3.h b/drivers/net/tg3.h
--- a/drivers/net/tg3.h	Fri May 24 18:55:34 2002
+++ b/drivers/net/tg3.h	Fri May 24 18:55:34 2002
@@ -1126,6 +1126,7 @@
 #define  GRC_MISC_CFG_BOARD_ID_5702FE	0x00004000
 #define  GRC_MISC_CFG_BOARD_ID_5703	0x00000000
 #define  GRC_MISC_CFG_BOARD_ID_5703S	0x00002000
+#define  GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00001800
 #define GRC_LOCAL_CTRL			0x00006808
 #define  GRC_LCLCTRL_INT_ACTIVE		0x00000001
 #define  GRC_LCLCTRL_CLEARINT		0x00000002
diff -Nru a/drivers/net/tlan.c b/drivers/net/tlan.c
--- a/drivers/net/tlan.c	Fri May 24 18:55:33 2002
+++ b/drivers/net/tlan.c	Fri May 24 18:55:33 2002
@@ -209,7 +209,6 @@
 MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
 MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
 MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
-EXPORT_NO_SYMBOLS;
 
 /* Define this to enable Link beat monitoring */
 #undef MONITOR
diff -Nru a/drivers/net/tokenring/Makefile b/drivers/net/tokenring/Makefile
--- a/drivers/net/tokenring/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/net/tokenring/Makefile	Fri May 24 18:55:34 2002
@@ -1,15 +1,7 @@
 #
 # Makefile for drivers/net/tokenring
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
 
-obj-y   :=
-obj-n   :=
-obj-m   :=
-obj-    :=
 export-objs := tms380tr.o
 
 obj-$(CONFIG_IBMTR) 	+= ibmtr.o
@@ -22,7 +14,5 @@
 obj-$(CONFIG_TMSISA) 	+= tmsisa.o
 obj-$(CONFIG_SMCTR) 	+= smctr.o
 obj-$(CONFIG_3C359)	+= 3c359.o
-
-O_TARGET := tr.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/net/tulip/Makefile b/drivers/net/tulip/Makefile
--- a/drivers/net/tulip/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/net/tulip/Makefile	Fri May 24 18:55:36 2002
@@ -1,18 +1,6 @@
 #
-# drivers/net/tulip/Makefile
-#
 # Makefile for the Linux "Tulip" family network device drivers.
 #
-
-O_TARGET := tulip_net.o
-
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
-
-# Things that need to export symbols
-export-objs	:=
 
 obj-$(CONFIG_PCMCIA_XIRTULIP)	+= xircom_tulip_cb.o
 obj-$(CONFIG_PCMCIA_XIRCOM)	+= xircom_cb.o
diff -Nru a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
--- a/drivers/net/wan/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/wan/Makefile	Fri May 24 18:55:33 2002
@@ -5,8 +5,6 @@
 # Rewritten to use lists instead of if-statements.
 #
 
-O_TARGET := wan.o
-
 export-objs :=	z85230.o syncppp.o comx.o sdladrv.o cycx_drv.o hdlc_generic.o \
 		dlci.o pc300_drv.o
 
@@ -51,12 +49,8 @@
 obj-$(CONFIG_SYNCLINK_SYNCPPP)	+=		syncppp.o
 obj-$(CONFIG_X25_ASY)		+= x25_asy.o
 
-subdir-$(CONFIG_LANMEDIA) += lmc
+obj-$(CONFIG_LANMEDIA)		+= lmc/
 
-ifeq ($(CONFIG_LANMEDIA),y)
-  obj-y += lmc/lmc.o
-endif
- 
 obj-$(CONFIG_DLCI)		+= dlci.o 
 obj-$(CONFIG_SDLA)		+= sdla.o
 ifeq ($(CONFIG_WANPIPE_MULTPPP),y)
diff -Nru a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
--- a/drivers/net/wan/c101.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/c101.c	Fri May 24 18:55:34 2002
@@ -380,4 +380,3 @@
 MODULE_DESCRIPTION("Moxa C101 serial port driver");
 MODULE_LICENSE("GPL");
 MODULE_PARM(hw, "s");		/* hw=irq,ram:irq,... */
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/net/wan/comx-hw-munich.c b/drivers/net/wan/comx-hw-munich.c
--- a/drivers/net/wan/comx-hw-munich.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/comx-hw-munich.c	Fri May 24 18:55:34 2002
@@ -2409,7 +2409,7 @@
 
     /* Paranoia checking: */
 
-    if (file->f_dentry->d_inode->i_ino != entry->low_ino)
+    if (PDE(file->f_dentry->d_inode) != entry)
     {
 	printk(KERN_ERR "munich_write_proc: file <-> data internal error\n");
 	return -EIO;
diff -Nru a/drivers/net/wan/comx-proto-fr.c b/drivers/net/wan/comx-proto-fr.c
--- a/drivers/net/wan/comx-proto-fr.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/comx-proto-fr.c	Fri May 24 18:55:34 2002
@@ -39,7 +39,7 @@
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/if_arp.h>
diff -Nru a/drivers/net/wan/comx-proto-ppp.c b/drivers/net/wan/comx-proto-ppp.c
--- a/drivers/net/wan/comx-proto-ppp.c	Fri May 24 18:55:36 2002
+++ b/drivers/net/wan/comx-proto-ppp.c	Fri May 24 18:55:36 2002
@@ -36,7 +36,7 @@
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/if_arp.h>
diff -Nru a/drivers/net/wan/comx.c b/drivers/net/wan/comx.c
--- a/drivers/net/wan/comx.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/wan/comx.c	Fri May 24 18:55:35 2002
@@ -58,7 +58,7 @@
 #include <linux/version.h>
 
 #include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <asm/uaccess.h>
@@ -942,8 +942,7 @@
 	lock_kernel();
 	if ((de = PDE(dir)) != NULL) {
 		for (de = de->subdir ; de ; de = de->next) {
-			if ((de && de->low_ino) && 
-			    (de->namelen == dentry->d_name.len) &&
+			if ((de->namelen == dentry->d_name.len) &&
 			    (memcmp(dentry->d_name.name, de->name, 
 			    de->namelen) == 0))	{
 			 	if ((inode = proc_get_inode(dir->i_sb, 
diff -Nru a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
--- a/drivers/net/wan/dscc4.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/dscc4.c	Fri May 24 18:55:34 2002
@@ -126,8 +126,6 @@
 MODULE_PARM(quartz,"i");
 MODULE_PARM_DESC(quartz,"If present, on-board quartz frequency (Hz)");
 
-EXPORT_NO_SYMBOLS;
-
 /* Structures */
 
 struct thingie {
diff -Nru a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
--- a/drivers/net/wan/farsync.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/farsync.c	Fri May 24 18:55:34 2002
@@ -33,9 +33,6 @@
 MODULE_DESCRIPTION("FarSync T-Series X21 driver. FarSite Communications Ltd.");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
-
 /*      Driver configuration and global parameters
  *      ==========================================
  */
diff -Nru a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c
--- a/drivers/net/wan/hd6457x.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/hd6457x.c	Fri May 24 18:55:34 2002
@@ -16,7 +16,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
diff -Nru a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
--- a/drivers/net/wan/lapbether.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/wan/lapbether.c	Fri May 24 18:55:35 2002
@@ -505,8 +505,6 @@
 }
 module_exit(lapbeth_cleanup_driver);
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>");
 MODULE_DESCRIPTION("The unofficial LAPB over Ethernet driver");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/net/wan/lmc/Makefile b/drivers/net/wan/lmc/Makefile
--- a/drivers/net/wan/lmc/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/net/wan/lmc/Makefile	Fri May 24 18:55:33 2002
@@ -1,13 +1,11 @@
-# File: drivers/lmc/Makefile
 #
 # Makefile for the Lan Media 21140 based WAN cards
 # Specifically the 1000,1200,5200,5245
 #
 
-O_TARGET := lmc.o
+obj-$(CONFIG_LANMEDIA) += lmc.o
 
-obj-y := lmc_debug.o lmc_media.o lmc_main.o lmc_proto.o
-obj-m := lmc.o
+lmc-objs := lmc_debug.o lmc_media.o lmc_main.o lmc_proto.o
 
 # Like above except every packet gets echoed to KERN_DEBUG
 # in hex
diff -Nru a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
--- a/drivers/net/wan/n2.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/n2.c	Fri May 24 18:55:34 2002
@@ -594,4 +594,3 @@
 MODULE_DESCRIPTION("RISCom/N2 serial port driver");
 MODULE_LICENSE("GPL");
 MODULE_PARM(hw, "s");		/* hw=io,irq,ram,ports:io,irq,... */
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c
--- a/drivers/net/wan/sdladrv.c	Fri May 24 18:55:34 2002
+++ b/drivers/net/wan/sdladrv.c	Fri May 24 18:55:34 2002
@@ -97,7 +97,7 @@
 #include <linux/errno.h>	/* return codes */
 #include <linux/string.h>	/* inline memset(), etc. */
 #include <linux/module.h>	/* support for loadable modules */
-#include <linux/sched.h>	/* for jiffies, HZ, etc. */
+#include <linux/jiffies.h>	/* for jiffies, HZ, etc. */
 #include <linux/sdladrv.h>	/* API definitions */
 #include <linux/sdlasfm.h>	/* SDLA firmware module definitions */
 #include <linux/sdlapci.h>	/* SDLA PCI hardware definitions */
diff -Nru a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
--- a/drivers/net/wireless/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/net/wireless/Makefile	Fri May 24 18:55:36 2002
@@ -1,15 +1,6 @@
 #
-# drivers/net/wireless/Makefile
-#
 # Makefile for the Linux Wireless network device drivers.
 #
-
-O_TARGET := wireless_net.o
-
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
 
 # Things that need to export symbols
 export-objs	:= airo.o orinoco.o hermes.o
diff -Nru a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
--- a/drivers/net/wireless/airport.c	Fri May 24 18:55:35 2002
+++ b/drivers/net/wireless/airport.c	Fri May 24 18:55:35 2002
@@ -46,7 +46,6 @@
 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
 MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
 MODULE_LICENSE("Dual MPL/GPL");
-EXPORT_NO_SYMBOLS;
 
 #define AIRPORT_IO_LEN	(0x1000)	/* one page */
 
diff -Nru a/drivers/nubus/Makefile b/drivers/nubus/Makefile
--- a/drivers/nubus/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/nubus/Makefile	Fri May 24 18:55:36 2002
@@ -1,15 +1,6 @@
 #
 # Makefile for the nubus specific drivers.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now inherited from the
-# parent makefile.
-#
-
-L_TARGET := nubus.a
 
 export-objs := nubus_syms.o
 
diff -Nru a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
--- a/drivers/parport/parport_gsc.c	Fri May 24 18:55:35 2002
+++ b/drivers/parport/parport_gsc.c	Fri May 24 18:55:35 2002
@@ -550,7 +550,5 @@
 	}
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(parport_gsc_init_module);
 module_exit(parport_gsc_exit_module);
diff -Nru a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
--- a/drivers/parport/parport_sunbpp.c	Fri May 24 18:55:33 2002
+++ b/drivers/parport/parport_sunbpp.c	Fri May 24 18:55:33 2002
@@ -364,8 +364,6 @@
 	return 1;
 }
 
-EXPORT_NO_SYMBOLS;
-
 #ifdef MODULE
 int init_module(void)
 #else
diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
--- a/drivers/pci/pci.ids	Fri May 24 18:55:33 2002
+++ b/drivers/pci/pci.ids	Fri May 24 18:55:33 2002
@@ -4699,6 +4699,7 @@
 1668  Action Tec Electronics Inc
 173b  Altima (nee BroadCom)
 	03e8  AC1000 Gigabit Ethernet
+	03ea  AC9100 Gigabit Ethernet
 1813  Ambient Technologies Inc
 1a08  Sierra semiconductor
 	0000  SC15064
diff -Nru a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c
--- a/drivers/pcmcia/sa1100_assabet.c	Fri May 24 18:55:34 2002
+++ b/drivers/pcmcia/sa1100_assabet.c	Fri May 24 18:55:34 2002
@@ -7,6 +7,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/errno.h>
 #include <linux/init.h>
 
 #include <asm/hardware.h>
diff -Nru a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c
--- a/drivers/pcmcia/sa1100_badge4.c	Fri May 24 18:55:34 2002
+++ b/drivers/pcmcia/sa1100_badge4.c	Fri May 24 18:55:34 2002
@@ -14,6 +14,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/init.h>
 
 #include <asm/hardware.h>
@@ -56,7 +58,7 @@
 
 static int badge4_pcmvcc = 50;
 static int badge4_pcmvpp = 50;
-static int badge4_cfvcc = 0;
+static int badge4_cfvcc = 33;
 
 static int badge4_pcmcia_init(struct pcmcia_init *init)
 {
@@ -90,8 +92,6 @@
 	       supply,
 	       given / 10, given % 10);
 }
-
-static unsigned badge4_need_5V_bitmap = 0;
 
 static int
 badge4_pcmcia_configure_socket(const struct pcmcia_configure *conf)
diff -Nru a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
--- a/drivers/pcmcia/sa1100_generic.c	Fri May 24 18:55:36 2002
+++ b/drivers/pcmcia/sa1100_generic.c	Fri May 24 18:55:36 2002
@@ -95,10 +95,11 @@
  * "Expansion Memory (PCMCIA) Configuration Register (MECR)"
  * that's section 10.2.5 in _my_ version of the manuial ;)
  */
-static int sa1100_pcmcia_default_mecr_timing(unsigned int sock, unsigned int cpu_speed,
-		unsigned int cmd_time )
+static unsigned int
+sa1100_pcmcia_default_mecr_timing(unsigned int sock, unsigned int cpu_speed,
+				  unsigned int cmd_time)
 {
-	return sa1100_pcmcia_mecr_bs( cmd_time, cpu_speed );
+	return sa1100_pcmcia_mecr_bs(cmd_time, cpu_speed);
 }
 
 /* sa1100_pcmcia_set_mecr()
@@ -109,7 +110,7 @@
  * Call board specific BS value calculation to allow boards
  * to tweak the BS values.
  */
-static int sa1100_pcmcia_set_mecr( int sock )
+static int sa1100_pcmcia_set_mecr(int sock)
 {
 	struct sa1100_pcmcia_socket *skt;
 	u32 mecr;
@@ -117,15 +118,15 @@
 	long flags;
 	unsigned int bs;
 
-	if ( sock<0 || sock>SA1100_PCMCIA_MAX_SOCK )
+	if (sock < 0 || sock > SA1100_PCMCIA_MAX_SOCK)
 		return -1;
 
-	skt = PCMCIA_SOCKET( sock );
+	skt = PCMCIA_SOCKET(sock);
 
 	local_irq_save(flags);
 
 	clock = cpufreq_get(0);
-	bs = pcmcia_low_level->socket_get_timing( sock, clock, skt->speed_io);
+	bs = pcmcia_low_level->socket_get_timing(sock, clock, skt->speed_io);
 
 	mecr = MECR;
 	MECR_FAST_SET(mecr, sock, 0);
@@ -136,10 +137,10 @@
 
 	local_irq_restore(flags);
 
-    DEBUG(4, "%s(): FAST%u %lx  BSM%u %lx  BSA%u %lx  BSIO%u %lx\n",
-	  __FUNCTION__, sock, MECR_FAST_GET(mecr, sock), sock,
-	  MECR_BSM_GET(mecr, sock), sock, MECR_BSA_GET(mecr, sock),
-	  sock, MECR_BSIO_GET(mecr, sock));
+	DEBUG(4, "%s(): FAST%u %lx  BSM%u %lx  BSA%u %lx  BSIO%u %lx\n",
+	      __FUNCTION__, sock, MECR_FAST_GET(mecr, sock), sock,
+	      MECR_BSM_GET(mecr, sock), sock, MECR_BSA_GET(mecr, sock),
+	      sock, MECR_BSIO_GET(mecr, sock));
 
 	return 0;
 }
@@ -882,11 +883,11 @@
  */
 static void sa1100_pcmcia_update_mecr(unsigned int clock)
 {
-  unsigned int sock;
+	unsigned int sock;
 
-  for (sock = 0; sock < SA1100_PCMCIA_MAX_SOCK; ++sock) {
-	  sa1100_pcmcia_set_mecr( sock );
-  }
+	for (sock = 0; sock < SA1100_PCMCIA_MAX_SOCK; ++sock) {
+		sa1100_pcmcia_set_mecr(sock);
+	}
 }
 
 /* sa1100_pcmcia_notifier()
diff -Nru a/drivers/pcmcia/sa1100_generic.h b/drivers/pcmcia/sa1100_generic.h
--- a/drivers/pcmcia/sa1100_generic.h	Fri May 24 18:55:33 2002
+++ b/drivers/pcmcia/sa1100_generic.h	Fri May 24 18:55:33 2002
@@ -73,8 +73,8 @@
   /*
    * Calculate MECR timing clock wait states
    */
-  int (*socket_get_timing)(unsigned int sock, unsigned int cpu_speed,
-		  unsigned int cmd_time );
+  unsigned int (*socket_get_timing)(unsigned int sock,
+		unsigned int cpu_speed, unsigned int cmd_time);
 };
 
 extern int sa1100_register_pcmcia(struct pcmcia_low_level *);
diff -Nru a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c
--- a/drivers/pcmcia/sa1100_neponset.c	Fri May 24 18:55:36 2002
+++ b/drivers/pcmcia/sa1100_neponset.c	Fri May 24 18:55:36 2002
@@ -5,6 +5,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/init.h>
 
 #include <asm/hardware.h>
@@ -133,7 +135,7 @@
 {
 	int ret = -ENODEV;
 
-	if (machine_is_assabet() && machine_has_neponset())
+	if (machine_is_assabet() && sa1111)
 		ret = sa1100_register_pcmcia(&neponset_pcmcia_ops);
 
 	return ret;
diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
--- a/drivers/pcmcia/sa1111_generic.c	Fri May 24 18:55:34 2002
+++ b/drivers/pcmcia/sa1111_generic.c	Fri May 24 18:55:34 2002
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/ioport.h>
+#include <linux/device.h>
 
 #include <asm/hardware.h>
 #include <asm/hardware/sa1111.h>
diff -Nru a/drivers/pnp/pnpbios_core.c b/drivers/pnp/pnpbios_core.c
--- a/drivers/pnp/pnpbios_core.c	Fri May 24 18:55:33 2002
+++ b/drivers/pnp/pnpbios_core.c	Fri May 24 18:55:33 2002
@@ -118,7 +118,7 @@
 	"	pushl %ecx	\n"
 	"	pushl %ebx	\n"
 	"	pushl %eax	\n"
-	"	lcallw pnp_bios_callpoint\n"
+	"	lcallw *pnp_bios_callpoint\n"
 	"	addl $16, %esp	\n"
 	"	lret		\n"
 	".previous		\n"
diff -Nru a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
--- a/drivers/s390/block/xpram.c	Fri May 24 18:55:36 2002
+++ b/drivers/s390/block/xpram.c	Fri May 24 18:55:36 2002
@@ -747,7 +747,10 @@
 #endif /* V24 */
 
 	while(1) {
-		INIT_REQUEST;
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
 
 		fault=0;
 #if ( XPRAM_VERSION == 24 )
diff -Nru a/drivers/s390/char/tape.c b/drivers/s390/char/tape.c
--- a/drivers/s390/char/tape.c	Fri May 24 18:55:36 2002
+++ b/drivers/s390/char/tape.c	Fri May 24 18:55:36 2002
@@ -210,12 +210,6 @@
 	release:tape_devices_release,	/* close */
 };
 
-static struct inode_operations tape_devices_inode_ops =
-{
-#if !(LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
-	default_file_ops:&tape_devices_file_ops		/* file ops */
-#endif				/* LINUX_IS_24 */
-};
 #endif /* CONFIG_PROC_FS */
 
 /* SECTION: Parameters for tape */
@@ -271,9 +265,7 @@
 	return 1;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,2,16))
 __setup("tape=", tape_parm_call_setup);
-#endif   /* kernel <2.2.19 */
 #endif   /* not defined MODULE */
 
 static inline int
@@ -909,30 +901,10 @@
 	/* Allocate local buffer for the ccwcache       */
 	tape_init_emergency_req ();
 #ifdef CONFIG_PROC_FS
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
 	tape_devices_entry = create_proc_entry ("tapedevices",
 						S_IFREG | S_IRUGO | S_IWUSR,
 						&proc_root);
 	tape_devices_entry->proc_fops = &tape_devices_file_ops;
-	tape_devices_entry->proc_iops = &tape_devices_inode_ops;
-#else
-	tape_devices_entry = (struct proc_dir_entry *) kmalloc 
-            (sizeof (struct proc_dir_entry), GFP_ATOMIC);
-        if (tape_devices_entry) {
-            memset (tape_devices_entry, 0, sizeof (struct proc_dir_entry));
-            tape_devices_entry->name = "tapedevices";
-            tape_devices_entry->namelen = strlen ("tapedevices");
-            tape_devices_entry->low_ino = 0;
-            tape_devices_entry->mode = (S_IFREG | S_IRUGO | S_IWUSR);
-            tape_devices_entry->nlink = 1;
-            tape_devices_entry->uid = 0;
-            tape_devices_entry->gid = 0;
-            tape_devices_entry->size = 0;
-            tape_devices_entry->get_info = NULL;
-            tape_devices_entry->ops = &tape_devices_inode_ops;
-            proc_register (&proc_root, tape_devices_entry);
-	}
-#endif
 #endif /* CONFIG_PROC_FS */
 
 	return 0;
@@ -996,12 +968,7 @@
         devfs_unregister (tape_devfs_root_entry);
 #endif CONFIG_DEVFS_FS
 #ifdef CONFIG_PROC_FS
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
 	remove_proc_entry ("tapedevices", &proc_root);
-#else
-	proc_unregister (&proc_root, tape_devices_entry->low_ino);
-	kfree (tape_devices_entry);
-#endif				/* LINUX_IS_24 */
 #endif 
 #ifdef CONFIG_S390_TAPE_CHAR
 	tapechar_uninit();
diff -Nru a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
--- a/drivers/s390/net/ctcmain.c	Fri May 24 18:55:35 2002
+++ b/drivers/s390/net/ctcmain.c	Fri May 24 18:55:35 2002
@@ -77,16 +77,7 @@
 #define FREE_IRQ free_irq
 #endif
 
-#if LINUX_VERSION_CODE >= 0x020213
-#  include <asm/idals.h>
-#else
-#  define set_normalized_cda(ccw, addr) ((ccw)->cda = (addr),0)
-#  define clear_normalized_cda(ccw)
-#endif
-#if LINUX_VERSION_CODE < 0x020400
-#  define s390_dev_info_t dev_info_t
-#  define dev_kfree_skb_irq(a) dev_kfree_skb(a)
-#endif
+#include <asm/idals.h>
 
 #include <asm/irq.h>
 
@@ -319,9 +310,7 @@
 
 typedef struct ctc_priv_t {
 	struct net_device_stats stats;
-#if LINUX_VERSION_CODE >= 0x02032D
 	unsigned long           tbusy;
-#endif
 	/**
 	 * The finite state machine of this interface.
 	 */
@@ -351,20 +340,6 @@
  * Compatibility macros for busy handling
  * of network devices.
  */
-#if LINUX_VERSION_CODE < 0x02032D
-static __inline__ void ctc_clear_busy(net_device *dev)
-{
-	clear_bit(0 ,(void *)&dev->tbusy);
-	mark_bh(NET_BH);
-}
-
-static __inline__ int ctc_test_and_set_busy(net_device *dev)
-{
-	return(test_and_set_bit(0, (void *)&dev->tbusy));
-}
-
-#define SET_DEVICE_START(device, value) dev->start = value
-#else
 static __inline__ void ctc_clear_busy(net_device *dev)
 {
 	clear_bit(0, &(((ctc_priv *)dev->priv)->tbusy));
@@ -378,7 +353,6 @@
 }
 
 #define SET_DEVICE_START(device, value)
-#endif
 
 /**
  * Print Banner.
@@ -1351,11 +1325,7 @@
 		       dev->name, 
 		       (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
 
-#if LINUX_VERSION_CODE >= 0x020400
 	INIT_LIST_HEAD(&ch->tq.list);
-#else
-	ch->tq.next = NULL;
-#endif
 	ch->tq.sync    = 0;
 	ch->tq.routine = (void *)(void *)ctc_bh;
 	ch->tq.data    = ch;
@@ -2695,7 +2665,7 @@
  * procfs related structures and routines
  *****************************************************************************/
 
-static net_device *find_netdev_by_ino(unsigned long ino)
+static net_device *find_netdev_by_ino(struct proc_dir_entry *pde)
 {
 	channel *ch = channels;
 	net_device *dev = NULL;
@@ -2706,8 +2676,8 @@
 			dev = ch->netdev;
 			privptr = (ctc_priv *)dev->priv;
 
-			if ((privptr->proc_ctrl_entry->low_ino == ino) ||
-			    (privptr->proc_stat_entry->low_ino == ino))
+			if ((privptr->proc_ctrl_entry == pde) ||
+			    (privptr->proc_stat_entry == pde))
 				return dev;
 		}
 		ch = ch->next;
@@ -2715,20 +2685,6 @@
 	return NULL;
 }
 
-#if LINUX_VERSION_CODE < 0x020363
-/**
- * Lock the module, if someone changes into
- * our proc directory.
- */
-static void ctc_fill_inode(struct inode *inode, int fill)
-{
-	if (fill) {
-		MOD_INC_USE_COUNT;
-	} else
-		MOD_DEC_USE_COUNT;
-}
-#endif
-
 #define CTRL_BUFSIZE 40
 
 static int ctc_ctrl_open(struct inode *inode, struct file *file)
@@ -2750,14 +2706,14 @@
 static ssize_t ctc_ctrl_write(struct file *file, const char *buf, size_t count,
 			   loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	net_device   *dev;
 	ctc_priv     *privptr;
 	char         *e;
 	int          bs1;
 	char         tmp[40];
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -2795,7 +2751,7 @@
 static ssize_t ctc_ctrl_read(struct file *file, char *buf, size_t count,
 			  loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	char *sbuf = (char *)file->private_data;
 	net_device *dev;
 	ctc_priv *privptr;
@@ -2803,7 +2759,7 @@
 	char *p = sbuf;
 	int l;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -2847,11 +2803,11 @@
 static ssize_t ctc_stat_write(struct file *file, const char *buf, size_t count,
 			      loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	net_device *dev;
 	ctc_priv *privptr;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	privptr = (ctc_priv *)dev->priv;
 	privptr->channel[WRITE]->prof.maxmulti = 0;
@@ -2866,7 +2822,7 @@
 static ssize_t ctc_stat_read(struct file *file, char *buf, size_t count,
 			      loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	char *sbuf = (char *)file->private_data;
 	net_device *dev;
 	ctc_priv *privptr;
@@ -2874,7 +2830,7 @@
 	char *p = sbuf;
 	int l;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -2928,74 +2884,7 @@
 	release: ctc_ctrl_close,
 };
 
-static struct inode_operations ctc_stat_iops = {
-#if LINUX_VERSION_CODE < 0x020363
-	default_file_ops: &ctc_stat_fops
-#endif
-};
-static struct inode_operations ctc_ctrl_iops = {
-#if LINUX_VERSION_CODE < 0x020363
-	default_file_ops: &ctc_ctrl_fops
-#endif
-};
-
-static struct proc_dir_entry stat_entry = {
-	0,                           /* low_ino */
-	10,                          /* namelen */
-	"statistics",                /* name    */
-	S_IFREG | S_IRUGO | S_IWUSR, /* mode    */
-	1,                           /* nlink   */
-	0,                           /* uid     */
-	0,                           /* gid     */
-	0,                           /* size    */
-	&ctc_stat_iops               /* ops     */
-};
-
-static struct proc_dir_entry ctrl_entry = {
-	0,                           /* low_ino */
-	10,                          /* namelen */
-	"buffersize",                /* name    */
-	S_IFREG | S_IRUSR | S_IWUSR, /* mode    */
-	1,                           /* nlink   */
-	0,                           /* uid     */
-	0,                           /* gid     */
-	0,                           /* size    */
-	&ctc_ctrl_iops               /* ops     */
-};
-
-#if LINUX_VERSION_CODE < 0x020363
-static struct proc_dir_entry ctc_dir = {
-	0,                           /* low_ino  */
-	3,                           /* namelen  */
-	"ctc",                       /* name     */
-	S_IFDIR | S_IRUGO | S_IXUGO, /* mode     */
-	2,                           /* nlink    */
-	0,                           /* uid      */
-	0,                           /* gid      */
-	0,                           /* size     */
-	0,                           /* ops      */
-	0,                           /* get_info */
-	ctc_fill_inode               /* fill_ino (for locking) */
-};
-
-static struct proc_dir_entry ctc_template =
-{
-	0,                           /* low_ino  */
-	0,                           /* namelen  */
-	"",                          /* name     */
-	S_IFDIR | S_IRUGO | S_IXUGO, /* mode     */
-	2,                           /* nlink    */
-	0,                           /* uid      */
-	0,                           /* gid      */
-	0,                           /* size     */
-	0,                           /* ops      */
-	0,                           /* get_info */
-	ctc_fill_inode               /* fill_ino (for locking) */
-};
-#else
 static struct proc_dir_entry *ctc_dir = NULL;
-static struct proc_dir_entry *ctc_template = NULL;
-#endif
 
 /**
  * Create the driver's main directory /proc/net/ctc
@@ -3004,13 +2893,8 @@
 	/**
 	 * If not registered, register main proc dir-entry now
 	 */
-#if LINUX_VERSION_CODE > 0x020362
 	if (!ctc_dir)
 		ctc_dir = proc_mkdir("ctc", proc_net);
-#else
-	if (ctc_dir.low_ino == 0)
-		proc_net_register(&ctc_dir);
-#endif
 }
 
 #ifdef MODULE
@@ -3018,11 +2902,7 @@
  * Destroy /proc/net/ctc
  */
 static void ctc_proc_destroy_main(void) {
-#if LINUX_VERSION_CODE > 0x020362
 	remove_proc_entry("ctc", proc_net);
-#else
-	proc_net_unregister(ctc_dir.low_ino);
-#endif
 }
 #endif MODULE
 
@@ -3037,27 +2917,17 @@
 static void ctc_proc_create_sub(net_device *dev) {
 	ctc_priv *privptr = dev->priv;
 
-#if LINUX_VERSION_CODE > 0x020362
 	privptr->proc_dentry = proc_mkdir(dev->name, ctc_dir);
 	privptr->proc_stat_entry =
 		create_proc_entry("statistics",
 				  S_IFREG | S_IRUSR | S_IWUSR,
 				  privptr->proc_dentry);
 	privptr->proc_stat_entry->proc_fops = &ctc_stat_fops;
-	privptr->proc_stat_entry->proc_iops = &ctc_stat_iops;
 	privptr->proc_ctrl_entry =
 		create_proc_entry("buffersize",
 				  S_IFREG | S_IRUSR | S_IWUSR,
 				  privptr->proc_dentry);
 	privptr->proc_ctrl_entry->proc_fops = &ctc_ctrl_fops;
-	privptr->proc_ctrl_entry->proc_iops = &ctc_ctrl_iops;
-#else
-	privptr->proc_dentry->name = dev->name;
-	privptr->proc_dentry->namelen = strlen(dev->name);
-	proc_register(&ctc_dir, privptr->proc_dentry);
-	proc_register(privptr->proc_dentry, privptr->proc_stat_entry);
-	proc_register(privptr->proc_dentry, privptr->proc_ctrl_entry);
-#endif
 	privptr->proc_registered = 1;
 }
 
@@ -3070,18 +2940,9 @@
 static void ctc_proc_destroy_sub(ctc_priv *privptr) {
 	if (!privptr->proc_registered)
 		return;
-#if LINUX_VERSION_CODE > 0x020362
 	remove_proc_entry("statistics", privptr->proc_dentry);
 	remove_proc_entry("buffersize", privptr->proc_dentry);
 	remove_proc_entry(privptr->proc_dentry->name, ctc_dir);
-#else
-	proc_unregister(privptr->proc_dentry,
-			privptr->proc_stat_entry->low_ino);
-	proc_unregister(privptr->proc_dentry,
-			privptr->proc_ctrl_entry->low_ino);
-	proc_unregister(&ctc_dir,
-			privptr->proc_dentry->low_ino);
-#endif
 	privptr->proc_registered = 0;
 }
 
@@ -3263,14 +3124,8 @@
    static void ctc_setup(char *setup)
 #  define ctc_setup_return return
 #else MODULE
-#  if LINUX_VERSION_CODE < 0x020300
-     __initfunc(void ctc_setup(char *setup, int *ints))
-#    define ctc_setup_return return
-#    define ints local_ints
-#  else
      static int __init ctc_setup(char *setup)
 #    define ctc_setup_return return(1)
-#  endif
 #endif MODULE
 {
 	int write_dev;
@@ -3368,9 +3223,7 @@
 	ctc_setup_return;
 }
 
-#if LINUX_VERSION_CODE >= 0x020300
 __setup("ctc=", ctc_setup);
-#endif
 #endif /* !CTC_CHANDEV */
 
 
@@ -3443,17 +3296,12 @@
 	ctc_priv *privptr;
 	int      priv_size;
 	if (alloc_device) {
-		dev = kmalloc(sizeof(net_device)
-#if LINUX_VERSION_CODE < 0x020300
-			      + 11 /* name + zero */
-#endif
-			      , GFP_KERNEL);
+		dev = kmalloc(sizeof(net_device), GFP_KERNEL);
 		if (!dev)
 			return NULL;
 		memset(dev, 0, sizeof(net_device));
 	}
-	priv_size = sizeof(ctc_priv) + sizeof(ctc_template) +
-		sizeof(stat_entry) + sizeof(ctrl_entry);
+	priv_size = sizeof(ctc_priv);
 	dev->priv = kmalloc(priv_size, GFP_KERNEL);
 	if (dev->priv == NULL) {
 		if (alloc_device)
@@ -3462,17 +3310,6 @@
 	}
         memset(dev->priv, 0, priv_size);
         privptr = (ctc_priv *)dev->priv;
-        privptr->proc_dentry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(ctc_priv));
-        privptr->proc_stat_entry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(ctc_priv) +
-		 sizeof(ctc_template));
-        privptr->proc_ctrl_entry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(ctc_priv) +
-		 sizeof(ctc_template) + sizeof(stat_entry));
-	memcpy(privptr->proc_dentry, &ctc_template, sizeof(ctc_template));
-	memcpy(privptr->proc_stat_entry, &stat_entry, sizeof(stat_entry));
-	memcpy(privptr->proc_ctrl_entry, &ctrl_entry, sizeof(ctrl_entry));
 	privptr->fsm = init_fsm("ctcdev", dev_state_names,
 			dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
 			dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
@@ -3890,9 +3727,6 @@
 				ret = -ENOMEM;
 				break;
 			}
-#if LINUX_VERSION_CODE < 0x020300
-			dev->name = (unsigned char *)dev + sizeof(net_device);
-#endif
 			if (par && par->name) {
 				char *p;
 				int  n;
@@ -3989,9 +3823,7 @@
 }
 
 #ifndef MODULE
-#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0))
 __initcall(ctc_init);
-#endif /* LINUX_VERSION_CODE */
 #endif /* MODULE */
 
 /* --- This is the END my friend --- */
diff -Nru a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
--- a/drivers/s390/net/netiucv.c	Fri May 24 18:55:36 2002
+++ b/drivers/s390/net/netiucv.c	Fri May 24 18:55:36 2002
@@ -75,14 +75,7 @@
 
 static char *iucv = "";
 
-/**
- * compatibility stuff
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
 typedef struct net_device net_device;
-#else
-typedef struct device net_device;
-#endif
 
 
 /**
@@ -141,9 +134,7 @@
  */
 typedef struct netiucv_priv_t {
 	struct net_device_stats stats;
-#if LINUX_VERSION_CODE >= 0x02032D
 	unsigned long           tbusy;
-#endif
 	fsm_instance            *fsm;
         iucv_connection         *conn;
 	struct proc_dir_entry   *proc_dentry;
@@ -172,20 +163,6 @@
  * Compatibility macros for busy handling
  * of network devices.
  */
-#if LINUX_VERSION_CODE < 0x02032D
-static __inline__ void netiucv_clear_busy(net_device *dev)
-{
-	clear_bit(0 ,(void *)&dev->tbusy);
-	mark_bh(NET_BH);
-}
-
-static __inline__ int netiucv_test_and_set_busy(net_device *dev)
-{
-	return(test_and_set_bit(0, (void *)&dev->tbusy));
-}
-
-#define SET_DEVICE_START(device, value) dev->start = value
-#else
 static __inline__ void netiucv_clear_busy(net_device *dev)
 {
 	clear_bit(0, &(((netiucv_priv *)dev->priv)->tbusy));
@@ -199,11 +176,6 @@
 }
 
 #define SET_DEVICE_START(device, value)
-#endif
-
-#if LINUX_VERSION_CODE < 0x020400
-#  define dev_kfree_skb_irq(a) dev_kfree_skb(a)
-#endif
 
 __u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 __u8 iucvMagic[16] = {
@@ -1282,7 +1254,7 @@
  *****************************************************************************/
 
 static net_device *
-find_netdev_by_ino(unsigned long ino)
+find_netdev_by_ino(struct proc_dir_entry *pde)
 {
 	iucv_connection *conn = connections;
 	net_device *dev = NULL;
@@ -1293,9 +1265,9 @@
 			dev = conn->netdev;
 			privptr = (netiucv_priv *)dev->priv;
 
-			if ((privptr->proc_buffer_entry->low_ino == ino) ||
-			    (privptr->proc_user_entry->low_ino == ino)   ||
-			    (privptr->proc_stat_entry->low_ino == ino)     )
+			if ((privptr->proc_buffer_entry == pde) ||
+			    (privptr->proc_user_entry == pde)   ||
+			    (privptr->proc_stat_entry == pde)     )
 				return dev;
 		}
 		conn = conn->next;
@@ -1303,21 +1275,6 @@
 	return NULL;
 }
 
-#if LINUX_VERSION_CODE < 0x020363
-/**
- * Lock the module, if someone changes into
- * our proc directory.
- */
-static void
-netiucv_fill_inode(struct inode *inode, int fill)
-{
-	if (fill) {
-		MOD_INC_USE_COUNT;
-	} else
-		MOD_DEC_USE_COUNT;
-}
-#endif
-
 #define CTRL_BUFSIZE 40
 
 static int
@@ -1342,14 +1299,14 @@
 netiucv_buffer_write(struct file *file, const char *buf, size_t count,
 			   loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	net_device   *dev;
 	netiucv_priv *privptr;
 	char         *e;
 	int          bs1;
 	char         tmp[CTRL_BUFSIZE];
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -1385,7 +1342,7 @@
 static ssize_t
 netiucv_buffer_read(struct file *file, char *buf, size_t count, loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	char *sbuf = (char *)file->private_data;
 	net_device *dev;
 	netiucv_priv *privptr;
@@ -1393,7 +1350,7 @@
 	char *p = sbuf;
 	int l;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -1438,7 +1395,7 @@
 netiucv_user_write(struct file *file, const char *buf, size_t count,
 			   loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	net_device   *dev;
 	netiucv_priv *privptr;
 	int          i;
@@ -1446,7 +1403,7 @@
 	char         tmp[CTRL_BUFSIZE];
 	char         user[9];
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -1480,7 +1437,7 @@
 static ssize_t
 netiucv_user_read(struct file *file, char *buf, size_t count, loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	char *sbuf = (char *)file->private_data;
 	net_device *dev;
 	netiucv_priv *privptr;
@@ -1488,7 +1445,7 @@
 	char *p = sbuf;
 	int l;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -1536,11 +1493,11 @@
 static ssize_t
 netiucv_stat_write(struct file *file, const char *buf, size_t count, loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	net_device *dev;
 	netiucv_priv *privptr;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	privptr = (netiucv_priv *)dev->priv;
 	privptr->conn->prof.maxmulti = 0;
@@ -1555,7 +1512,7 @@
 static ssize_t
 netiucv_stat_read(struct file *file, char *buf, size_t count, loff_t *off)
 {
-	unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
 	char *sbuf = (char *)file->private_data;
 	net_device *dev;
 	netiucv_priv *privptr;
@@ -1563,7 +1520,7 @@
 	char *p = sbuf;
 	int l;
 
-	if (!(dev = find_netdev_by_ino(ino)))
+	if (!(dev = find_netdev_by_ino(pde)))
 		return -ENODEV;
 	if (off != &file->f_pos)
 		return -ESPIPE;
@@ -1624,92 +1581,8 @@
 	release: netiucv_user_close,
 };
 
-static struct inode_operations netiucv_stat_iops = {
-#if LINUX_VERSION_CODE < 0x020363
-	default_file_ops: &netiucv_stat_fops
-#endif
-};
-static struct inode_operations netiucv_buffer_iops = {
-#if LINUX_VERSION_CODE < 0x020363
-	default_file_ops: &netiucv_buffer_fops
-#endif
-};
-
-static struct inode_operations netiucv_user_iops = {
-#if LINUX_VERSION_CODE < 0x020363
-	default_file_ops: &netiucv_user_fops
-#endif
-};
-
-static struct proc_dir_entry stat_entry = {
-	0,                           /* low_ino */
-	10,                          /* namelen */
-	"statistics",                /* name    */
-	S_IFREG | S_IRUGO | S_IWUSR, /* mode    */
-	1,                           /* nlink   */
-	0,                           /* uid     */
-	0,                           /* gid     */
-	0,                           /* size    */
-	&netiucv_stat_iops           /* ops     */
-};
-
-static struct proc_dir_entry buffer_entry = {
-	0,                           /* low_ino */
-	10,                          /* namelen */
-	"buffersize",                /* name    */
-	S_IFREG | S_IRUSR | S_IWUSR, /* mode    */
-	1,                           /* nlink   */
-	0,                           /* uid     */
-	0,                           /* gid     */
-	0,                           /* size    */
-	&netiucv_buffer_iops         /* ops     */
-};
-
-static struct proc_dir_entry user_entry = {
-	0,                           /* low_ino */
-	8,                           /* namelen */
-	"username",                  /* name    */
-	S_IFREG | S_IRUSR | S_IWUSR, /* mode    */
-	1,                           /* nlink   */
-	0,                           /* uid     */
-	0,                           /* gid     */
-	0,                           /* size    */
-	&netiucv_user_iops           /* ops     */
-};
-
-#if LINUX_VERSION_CODE < 0x020363
-static struct proc_dir_entry netiucv_dir = {
-	0,                           /* low_ino  */
-	4,                           /* namelen  */
-	"iucv",                      /* name     */
-	S_IFDIR | S_IRUGO | S_IXUGO, /* mode     */
-	2,                           /* nlink    */
-	0,                           /* uid      */
-	0,                           /* gid      */
-	0,                           /* size     */
-	0,                           /* ops      */
-	0,                           /* get_info */
-	netiucv_fill_inode           /* fill_ino (for locking) */
-};
-
-static struct proc_dir_entry netiucv_template =
-{
-	0,                           /* low_ino  */
-	0,                           /* namelen  */
-	"",                          /* name     */
-	S_IFDIR | S_IRUGO | S_IXUGO, /* mode     */
-	2,                           /* nlink    */
-	0,                           /* uid      */
-	0,                           /* gid      */
-	0,                           /* size     */
-	0,                           /* ops      */
-	0,                           /* get_info */
-	netiucv_fill_inode           /* fill_ino (for locking) */
-};
-#else
 static struct proc_dir_entry *netiucv_dir = NULL;
 static struct proc_dir_entry *netiucv_template = NULL;
-#endif
 
 /**
  * Create the driver's main directory /proc/net/iucv
@@ -1720,13 +1593,8 @@
 	/**
 	 * If not registered, register main proc dir-entry now
 	 */
-#if LINUX_VERSION_CODE > 0x020362
 	if (!netiucv_dir)
 		netiucv_dir = proc_mkdir("iucv", proc_net);
-#else
-	if (netiucv_dir.low_ino == 0)
-		proc_net_register(&netiucv_dir);
-#endif
 }
 
 #ifdef MODULE
@@ -1736,11 +1604,7 @@
 static void
 netiucv_proc_destroy_main(void)
 {
-#if LINUX_VERSION_CODE > 0x020362
 	remove_proc_entry("iucv", proc_net);
-#else
-	proc_net_unregister(netiucv_dir.low_ino);
-#endif
 }
 #endif MODULE
 
@@ -1756,34 +1620,22 @@
 netiucv_proc_create_sub(net_device *dev) {
 	netiucv_priv *privptr = dev->priv;
 
-#if LINUX_VERSION_CODE > 0x020362
 	privptr->proc_dentry = proc_mkdir(dev->name, netiucv_dir);
 	privptr->proc_stat_entry =
 		create_proc_entry("statistics",
 				  S_IFREG | S_IRUSR | S_IWUSR,
 				  privptr->proc_dentry);
 	privptr->proc_stat_entry->proc_fops = &netiucv_stat_fops;
-	privptr->proc_stat_entry->proc_iops = &netiucv_stat_iops;
 	privptr->proc_buffer_entry =
 		create_proc_entry("buffersize",
 				  S_IFREG | S_IRUSR | S_IWUSR,
 				  privptr->proc_dentry);
 	privptr->proc_buffer_entry->proc_fops = &netiucv_buffer_fops;
-	privptr->proc_buffer_entry->proc_iops = &netiucv_buffer_iops;
 	privptr->proc_user_entry =
 		create_proc_entry("username",
 				  S_IFREG | S_IRUSR | S_IWUSR,
 				  privptr->proc_dentry);
 	privptr->proc_user_entry->proc_fops = &netiucv_user_fops;
-	privptr->proc_user_entry->proc_iops = &netiucv_user_iops;
-#else
-	privptr->proc_dentry->name = dev->name;
-	privptr->proc_dentry->namelen = strlen(dev->name);
-	proc_register(&netiucv_dir, privptr->proc_dentry);
-	proc_register(privptr->proc_dentry, privptr->proc_stat_entry);
-	proc_register(privptr->proc_dentry, privptr->proc_buffer_entry);
-	proc_register(privptr->proc_dentry, privptr->proc_user_entry);
-#endif
 	privptr->proc_registered = 1;
 }
 
@@ -1797,21 +1649,10 @@
 netiucv_proc_destroy_sub(netiucv_priv *privptr) {
 	if (!privptr->proc_registered)
 		return;
-#if LINUX_VERSION_CODE > 0x020362
 	remove_proc_entry("statistics", privptr->proc_dentry);
 	remove_proc_entry("buffersize", privptr->proc_dentry);
 	remove_proc_entry("username", privptr->proc_dentry);
 	remove_proc_entry(privptr->proc_dentry->name, netiucv_dir);
-#else
-	proc_unregister(privptr->proc_dentry,
-			privptr->proc_stat_entry->low_ino);
-	proc_unregister(privptr->proc_dentry,
-			privptr->proc_buffer_entry->low_ino);
-	proc_unregister(privptr->proc_dentry,
-			privptr->proc_user_entry->low_ino);
-	proc_unregister(&netiucv_dir,
-			privptr->proc_dentry->low_ino);
-#endif
 	privptr->proc_registered = 0;
 }
 
@@ -1904,21 +1745,13 @@
 	netiucv_priv *privptr;
 	int          priv_size;
 
-	net_device *dev = kmalloc(sizeof(net_device)
-#if LINUX_VERSION_CODE < 0x020300
-		      + 11 /* name + zero */
-#endif
-		      , GFP_KERNEL);
+	net_device *dev = kmalloc(sizeof(net_device), GFP_KERNEL);
 	if (!dev)
 		return NULL;
 	memset(dev, 0, sizeof(net_device));
-#if LINUX_VERSION_CODE < 0x020300
-	dev->name = (char *)dev + sizeof(net_device);
-#endif
 	sprintf(dev->name, "iucv%d", ifno);
 
-	priv_size = sizeof(netiucv_priv) + sizeof(netiucv_template) +
-		sizeof(stat_entry) + sizeof(buffer_entry) + sizeof(user_entry);
+	priv_size = sizeof(netiucv_priv);
 	dev->priv = kmalloc(priv_size, GFP_KERNEL);
 	if (dev->priv == NULL) {
 		kfree(dev);
@@ -1926,23 +1759,6 @@
 	}
         memset(dev->priv, 0, priv_size);
         privptr = (netiucv_priv *)dev->priv;
-        privptr->proc_dentry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(netiucv_priv));
-        privptr->proc_stat_entry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(netiucv_priv) +
-		 sizeof(netiucv_template));
-        privptr->proc_buffer_entry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(netiucv_priv) +
-		 sizeof(netiucv_template) + sizeof(stat_entry));
-        privptr->proc_user_entry = (struct proc_dir_entry *)
-		(((char *)privptr) + sizeof(netiucv_priv) +
-		 sizeof(netiucv_template) + sizeof(stat_entry) +
-		 sizeof(buffer_entry));
-	memcpy(privptr->proc_dentry, &netiucv_template,
-	       sizeof(netiucv_template));
-	memcpy(privptr->proc_stat_entry, &stat_entry, sizeof(stat_entry));
-	memcpy(privptr->proc_buffer_entry, &buffer_entry, sizeof(buffer_entry));
-	memcpy(privptr->proc_user_entry, &user_entry, sizeof(user_entry));
 	privptr->fsm = init_fsm("netiucvdev", dev_state_names,
 				dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
 				dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
@@ -2015,14 +1831,9 @@
 }
 
 #ifndef MODULE
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
 #  define init_return(a) return a
 static int __init
 iucv_setup(char *param)
-# else
-#  define init_return(a) return
-__initfunc (void iucv_setup(char *param, int *ints))
-# endif
 {
 	/**
 	* We do not parse parameters here because at the time of
@@ -2034,9 +1845,7 @@
 	init_return(1);
 }
 
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
 __setup ("iucv=", iucv_setup);
-# endif
 #else
 static void
 netiucv_exit(void)
diff -Nru a/drivers/s390/s390io.c b/drivers/s390/s390io.c
--- a/drivers/s390/s390io.c	Fri May 24 18:55:34 2002
+++ b/drivers/s390/s390io.c	Fri May 24 18:55:34 2002
@@ -6981,8 +6981,7 @@
 	int len = 0;
 	tempinfo_t *info;
 	int irq;
-	int devno;
-	char * devno_str;
+	int devno = PDE(inode)->data;
 
 	info = (tempinfo_t *) vmalloc(sizeof(tempinfo_t));
 	if (info == NULL) {
@@ -6997,10 +6996,6 @@
 			vfree(info);
 			rc = -ENOMEM;
 		} else {
-			devno_str = kmalloc(6*sizeof(char), GFP_KERNEL);
-			memset(devno_str, 0, 6*sizeof(char));
-			memcpy(devno_str,file->f_dentry->d_parent->d_name.name, strlen(file->f_dentry->d_parent->d_name.name)+1);
-			devno = simple_strtoul(devno_str, &devno_str, 16);
 			irq = get_irq_by_devno(devno);
 			if (irq != -1) {
 				len += sprintf(info->data+len, "Dev Type/Mod: ");
@@ -7031,8 +7026,7 @@
 	int len = 0;
 	tempinfo_t *info;
 	int irq;
-	int devno;
-	char * devno_str;
+	int devno = PDE(inode)->data;
 
 	info = (tempinfo_t *) vmalloc(sizeof(tempinfo_t));
 	if (info == NULL) {
@@ -7047,10 +7041,6 @@
 			vfree(info);
 			rc = -ENOMEM;
 		} else {
-			devno_str = kmalloc(6*sizeof(char), GFP_KERNEL);
-			memset(devno_str, 0, 6*sizeof(char));
-			memcpy(devno_str,file->f_dentry->d_parent->d_name.name, strlen(file->f_dentry->d_parent->d_name.name)+1);
-			devno = simple_strtoul(devno_str, &devno_str, 16);
 			irq = get_irq_by_devno(devno);
 			if (irq != -1) {
 				len += sprintf(info->data+len, "%s\n", ioinfo[irq]->ui.flags.ready?"yes":"no");
@@ -7069,9 +7059,8 @@
 	int len = 0;
 	tempinfo_t *info;
 	int irq;
-	int devno;
+	int devno = PDE(inode)->data;
 	int i;
-	char * devno_str;
 
 	info = (tempinfo_t *) vmalloc(sizeof(tempinfo_t));
 	if (info == NULL) {
@@ -7086,10 +7075,6 @@
 			vfree(info);
 			rc = -ENOMEM;
 		} else {
-			devno_str = kmalloc(6*sizeof(char), GFP_KERNEL);
-			memset(devno_str, 0, 6*sizeof(char));
-			memcpy(devno_str,file->f_dentry->d_parent->d_name.name, strlen(file->f_dentry->d_parent->d_name.name)+1);
-			devno = simple_strtoul(devno_str, &devno_str, 16);
 			irq = get_irq_by_devno(devno);
 			if (irq != -1) {
 				for (i=0; i<8; i++) {
@@ -7172,10 +7157,13 @@
 				}
 				/* create the different entries */
 				entry->cio_sensedata_entry = create_proc_entry( "sensedata", S_IFREG|S_IRUGO, entry->cio_device_entry);
+				entry->cio_sensedata_entry->data = devno;
 				entry->cio_sensedata_entry->proc_fops = &cio_sensedata_entry_file_ops;
 				entry->cio_in_use_entry = create_proc_entry( "in_use", S_IFREG|S_IRUGO, entry->cio_device_entry);
+				entry->cio_in_use_entry->data = devno;
 				entry->cio_in_use_entry->proc_fops = &cio_in_use_entry_file_ops;
 				entry->cio_chpid_entry = create_proc_entry( "chpids", S_IFREG|S_IRUGO, entry->cio_device_entry);
+				entry->cio_chpid_entry->data = devno;
 				entry->cio_chpid_entry->proc_fops = &cio_chpid_entry_file_ops;
 			} else {
 				printk( KERN_WARNING "Error, could not allocate procfs structure!\n");
diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
--- a/drivers/sbus/char/cpwatchdog.c	Fri May 24 18:55:36 2002
+++ b/drivers/sbus/char/cpwatchdog.c	Fri May 24 18:55:36 2002
@@ -180,8 +180,6 @@
 static int wd2_timeout = 0;
 
 #ifdef MODULE
-EXPORT_NO_SYMBOLS;
-
 MODULE_PARM		(wd0_timeout, "i");
 MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
 MODULE_PARM 	(wd1_timeout, "i");
diff -Nru a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
--- a/drivers/sbus/char/display7seg.c	Fri May 24 18:55:34 2002
+++ b/drivers/sbus/char/display7seg.c	Fri May 24 18:55:34 2002
@@ -29,7 +29,6 @@
 static int sol_compat = 0;		/* Solaris compatibility mode	*/
 
 #ifdef MODULE
-EXPORT_NO_SYMBOLS;
 
 /* Solaris compatibility flag -
  * The Solaris implementation omits support for several
diff -Nru a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
--- a/drivers/sbus/char/flash.c	Fri May 24 18:55:36 2002
+++ b/drivers/sbus/char/flash.c	Fri May 24 18:55:36 2002
@@ -158,8 +158,6 @@
 
 static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops };
 
-EXPORT_NO_SYMBOLS;
-
 static int __init flash_init(void)
 {
 	struct sbus_bus *sbus;
diff -Nru a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
--- a/drivers/sbus/char/jsflash.c	Fri May 24 18:55:35 2002
+++ b/drivers/sbus/char/jsflash.c	Fri May 24 18:55:35 2002
@@ -207,7 +207,11 @@
 	size_t len;
 
 	for (;;) {
-		INIT_REQUEST;	/* if (QUEUE_EMPTY) return; */
+		if (blk_queue_empty(QUEUE)) {
+			CLEAR_INTR;
+			return;
+		}
+
 		req = CURRENT;
 
 		dev = MINOR(req->rq_dev);
@@ -558,8 +562,6 @@
 	release:	jsfd_release,
 	ioctl:		jsfd_ioctl,
 };
-
-EXPORT_NO_SYMBOLS;
 
 int jsflash_init(void)
 {
diff -Nru a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
--- a/drivers/sbus/char/openprom.c	Fri May 24 18:55:36 2002
+++ b/drivers/sbus/char/openprom.c	Fri May 24 18:55:36 2002
@@ -619,8 +619,6 @@
 	SUN_OPENPROM_MINOR, "openprom", &openprom_fops
 };
 
-EXPORT_NO_SYMBOLS;
-
 static int __init openprom_init(void)
 {
 	unsigned long flags;
diff -Nru a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
--- a/drivers/sbus/char/rtc.c	Fri May 24 18:55:34 2002
+++ b/drivers/sbus/char/rtc.c	Fri May 24 18:55:34 2002
@@ -146,8 +146,6 @@
 
 static struct miscdevice rtc_dev = { RTC_MINOR, "rtc", &rtc_fops };
 
-EXPORT_NO_SYMBOLS;
-
 static int __init rtc_sun_init(void)
 {
 	int error;
diff -Nru a/drivers/scsi/Makefile b/drivers/scsi/Makefile
--- a/drivers/scsi/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/Makefile	Fri May 24 18:55:34 2002
@@ -25,10 +25,8 @@
 mod-subdirs	:= pcmcia ../acorn/scsi
 
 
-subdir-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx
 subdir-$(CONFIG_PCMCIA)		+= pcmcia
 
-
 obj-$(CONFIG_SCSI)		+= scsi_mod.o
 
 obj-$(CONFIG_A4000T_SCSI)	+= amiga7xx.o	53c7xx.o
@@ -64,9 +62,7 @@
 obj-$(CONFIG_SCSI_AHA152X)	+= aha152x.o
 obj-$(CONFIG_SCSI_AHA1542)	+= aha1542.o
 obj-$(CONFIG_SCSI_AHA1740)	+= aha1740.o
-ifeq ($(CONFIG_SCSI_AIC7XXX),y)
-obj-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx/aic7xxx_drv.o
-endif
+obj-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx/
 obj-$(CONFIG_SCSI_AIC7XXX_OLD)	+= aic7xxx_old.o
 obj-$(CONFIG_SCSI_IPS)		+= ips.o
 obj-$(CONFIG_SCSI_FD_MCS)	+= fd_mcs.o
@@ -87,10 +83,7 @@
 obj-$(CONFIG_SCSI_DMX3191D)	+= dmx3191d.o
 obj-$(CONFIG_SCSI_DTC3280)	+= dtc.o
 obj-$(CONFIG_SCSI_NCR53C7xx)	+= 53c7,8xx.o 
-subdir-$(CONFIG_SCSI_SYM53C8XX_2)	+= sym53c8xx_2
-ifeq ($(CONFIG_SCSI_SYM53C8XX_2),y)
-  obj-$(CONFIG_SCSI_SYM53C8XX_2)	+= sym53c8xx_2/sym53c8xx_2.o
-endif
+obj-$(CONFIG_SCSI_SYM53C8XX_2)	+= sym53c8xx_2/
 obj-$(CONFIG_SCSI_SYM53C8XX)	+= sym53c8xx.o 
 obj-$(CONFIG_SCSI_NCR53C8XX)	+= ncr53c8xx.o 
 obj-$(CONFIG_SCSI_EATA_DMA)	+= eata_dma.o
@@ -123,8 +116,7 @@
 obj-$(CONFIG_SCSI_CPQFCTS)	+= cpqfc.o
 obj-$(CONFIG_SCSI_LASI700)	+= lasi700.o 53c700.o
 
-subdir-$(CONFIG_ARCH_ACORN)	+= ../acorn/scsi
-obj-$(CONFIG_ARCH_ACORN)	+= ../acorn/scsi/acorn-scsi.o
+obj-$(CONFIG_ARCH_ACORN)	+= ../acorn/scsi/
 
 obj-$(CONFIG_CHR_DEV_ST)	+= st.o
 obj-$(CONFIG_CHR_DEV_OSST)	+= osst.o
diff -Nru a/drivers/scsi/aic7xxx/Makefile b/drivers/scsi/aic7xxx/Makefile
--- a/drivers/scsi/aic7xxx/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/scsi/aic7xxx/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for the Linux aic7xxx SCSI driver.
 #
 
-O_TARGET := aic7xxx_drv.o
-
 obj-$(CONFIG_SCSI_AIC7XXX)	+= aic7xxx.o
 
 # Core files
@@ -24,9 +22,22 @@
 
 include $(TOPDIR)/Rules.make
 
+# Dependencies for generated files need to be listed explicitly
+
+aic7xxx_core.o: aic7xxx_seq.h
+
+$(aic7xxx-objs): aic7xxx_reg.h
+
 ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
+
 aic7xxx_seq.h aic7xxx_reg.h: aic7xxx.seq aic7xxx.reg aicasm/aicasm
 	aicasm/aicasm -I. -r aic7xxx_reg.h -o aic7xxx_seq.h aic7xxx.seq
+
+else
+
+aic7xxx_seq.h aic7xxx_reg.h: %.h : shipped_%.h
+	cp $< $@
+
 endif
 
 aicasm/aicasm: aicasm/*.[chyl]
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_reg.h b/drivers/scsi/aic7xxx/aic7xxx_reg.h
--- a/drivers/scsi/aic7xxx/aic7xxx_reg.h	Fri May 24 18:55:33 2002
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,716 +0,0 @@
-/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#37 $
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#24 $
- */
-
-#define	SCSISEQ         		0x00
-#define		TEMODE          	0x80
-#define		SCSIRSTO        	0x01
-
-#define	SXFRCTL0        		0x01
-#define		DFON            	0x80
-#define		DFPEXP          	0x40
-#define		FAST20          	0x20
-#define		CLRSTCNT        	0x10
-#define		SPIOEN          	0x08
-#define		SCAMEN          	0x04
-#define		CLRCHN          	0x02
-
-#define	SXFRCTL1        		0x02
-#define		BITBUCKET       	0x80
-#define		SWRAPEN         	0x40
-#define		STIMESEL        	0x18
-#define		ENSTIMER        	0x04
-#define		ACTNEGEN        	0x02
-#define		STPWEN          	0x01
-
-#define	SCSISIGO        		0x03
-#define		CDO             	0x80
-#define		IOO             	0x40
-#define		MSGO            	0x20
-#define		ATNO            	0x10
-#define		SELO            	0x08
-#define		BSYO            	0x04
-#define		REQO            	0x02
-#define		ACKO            	0x01
-
-#define	SCSISIGI        		0x03
-#define		P_DATAIN_DT     	0x60
-#define		P_DATAOUT_DT    	0x20
-#define		ATNI            	0x10
-#define		SELI            	0x08
-#define		BSYI            	0x04
-#define		REQI            	0x02
-#define		ACKI            	0x01
-
-#define	SCSIRATE        		0x04
-#define		WIDEXFER        	0x80
-#define		SXFR            	0x70
-#define		ENABLE_CRC      	0x40
-#define		SINGLE_EDGE     	0x10
-#define		SOFS            	0x0f
-#define		SXFR_ULTRA2     	0x0f
-
-#define	SCSIID          		0x05
-#define	SCSIOFFSET      		0x05
-#define		SOFS_ULTRA2     	0x7f
-
-#define	SCSIDATL        		0x06
-
-#define	SCSIDATH        		0x07
-
-#define	STCNT           		0x08
-
-#define	OPTIONMODE      		0x08
-#define		AUTORATEEN      	0x80
-#define		AUTOACKEN       	0x40
-#define		ATNMGMNTEN      	0x20
-#define		BUSFREEREV      	0x10
-#define		EXPPHASEDIS     	0x08
-#define		SCSIDATL_IMGEN  	0x04
-#define		OPTIONMODE_DEFAULTS	0x03
-#define		AUTO_MSGOUT_DE  	0x02
-#define		DIS_MSGIN_DUALEDGE	0x01
-
-#define	TARGCRCCNT      		0x0a
-
-#define	CLRSINT0        		0x0b
-#define		CLRSELDO        	0x40
-#define		CLRSELDI        	0x20
-#define		CLRSELINGO      	0x10
-#define		CLRIOERR        	0x08
-#define		CLRSWRAP        	0x08
-#define		CLRSPIORDY      	0x02
-
-#define	SSTAT0          		0x0b
-#define		TARGET          	0x80
-#define		SELDO           	0x40
-#define		SELDI           	0x20
-#define		SELINGO         	0x10
-#define		SWRAP           	0x08
-#define		IOERR           	0x08
-#define		SDONE           	0x04
-#define		SPIORDY         	0x02
-#define		DMADONE         	0x01
-
-#define	CLRSINT1        		0x0c
-#define		CLRSELTIMEO     	0x80
-#define		CLRATNO         	0x40
-#define		CLRSCSIRSTI     	0x20
-#define		CLRBUSFREE      	0x08
-#define		CLRSCSIPERR     	0x04
-#define		CLRPHASECHG     	0x02
-#define		CLRREQINIT      	0x01
-
-#define	SSTAT1          		0x0c
-#define		SELTO           	0x80
-#define		ATNTARG         	0x40
-#define		SCSIRSTI        	0x20
-#define		PHASEMIS        	0x10
-#define		BUSFREE         	0x08
-#define		SCSIPERR        	0x04
-#define		PHASECHG        	0x02
-#define		REQINIT         	0x01
-
-#define	SSTAT2          		0x0d
-#define		OVERRUN         	0x80
-#define		SHVALID         	0x40
-#define		SFCNT           	0x1f
-#define		EXP_ACTIVE      	0x10
-#define		CRCVALERR       	0x08
-#define		CRCENDERR       	0x04
-#define		CRCREQERR       	0x02
-#define		DUAL_EDGE_ERR   	0x01
-
-#define	SSTAT3          		0x0e
-#define		SCSICNT         	0xf0
-#define		U2OFFCNT        	0x7f
-#define		OFFCNT          	0x0f
-
-#define	SCSIID_ULTRA2   		0x0f
-
-#define	SIMODE0         		0x10
-#define		ENSELDO         	0x40
-#define		ENSELDI         	0x20
-#define		ENSELINGO       	0x10
-#define		ENIOERR         	0x08
-#define		ENSWRAP         	0x08
-#define		ENSDONE         	0x04
-#define		ENSPIORDY       	0x02
-#define		ENDMADONE       	0x01
-
-#define	SIMODE1         		0x11
-#define		ENSELTIMO       	0x80
-#define		ENATNTARG       	0x40
-#define		ENSCSIRST       	0x20
-#define		ENPHASEMIS      	0x10
-#define		ENBUSFREE       	0x08
-#define		ENSCSIPERR      	0x04
-#define		ENPHASECHG      	0x02
-#define		ENREQINIT       	0x01
-
-#define	SCSIBUSL        		0x12
-
-#define	SCSIBUSH        		0x13
-
-#define	SHADDR          		0x14
-
-#define	SELTIMER        		0x18
-#define	TARGIDIN        		0x18
-#define		STAGE6          	0x20
-#define		STAGE5          	0x10
-#define		STAGE4          	0x08
-#define		STAGE3          	0x04
-#define		STAGE2          	0x02
-#define		STAGE1          	0x01
-
-#define	SELID           		0x19
-#define		SELID_MASK      	0xf0
-#define		ONEBIT          	0x08
-
-#define	SCAMCTL         		0x1a
-#define		ENSCAMSELO      	0x80
-#define		CLRSCAMSELID    	0x40
-#define		ALTSTIM         	0x20
-#define		DFLTTID         	0x10
-#define		SCAMLVL         	0x03
-
-#define	TARGID          		0x1b
-
-#define	SPIOCAP         		0x1b
-#define		SOFT1           	0x80
-#define		SOFT0           	0x40
-#define		SOFTCMDEN       	0x20
-#define		HAS_BRDCTL      	0x10
-#define		SEEPROM         	0x08
-#define		EEPROM          	0x04
-#define		ROM             	0x02
-#define		SSPIOCPS        	0x01
-
-#define	BRDCTL          		0x1d
-#define		BRDDAT7         	0x80
-#define		BRDDAT6         	0x40
-#define		BRDDAT5         	0x20
-#define		BRDDAT4         	0x10
-#define		BRDSTB          	0x10
-#define		BRDDAT3         	0x08
-#define		BRDCS           	0x08
-#define		BRDDAT2         	0x04
-#define		BRDRW           	0x04
-#define		BRDRW_ULTRA2    	0x02
-#define		BRDCTL1         	0x02
-#define		BRDCTL0         	0x01
-#define		BRDSTB_ULTRA2   	0x01
-
-#define	SEECTL          		0x1e
-#define		EXTARBACK       	0x80
-#define		EXTARBREQ       	0x40
-#define		SEEMS           	0x20
-#define		SEERDY          	0x10
-#define		SEECS           	0x08
-#define		SEECK           	0x04
-#define		SEEDO           	0x02
-#define		SEEDI           	0x01
-
-#define	SBLKCTL         		0x1f
-#define		DIAGLEDEN       	0x80
-#define		DIAGLEDON       	0x40
-#define		AUTOFLUSHDIS    	0x20
-#define		ENAB40          	0x08
-#define		SELBUSB         	0x08
-#define		ENAB20          	0x04
-#define		SELWIDE         	0x02
-#define		XCVR            	0x01
-
-#define	BUSY_TARGETS    		0x20
-#define	TARG_SCSIRATE   		0x20
-
-#define	SRAM_BASE       		0x20
-
-#define	ULTRA_ENB       		0x30
-#define	CMDSIZE_TABLE   		0x30
-
-#define	DISC_DSB        		0x32
-
-#define	CMDSIZE_TABLE_TAIL		0x34
-
-#define	MWI_RESIDUAL    		0x38
-
-#define	NEXT_QUEUED_SCB 		0x39
-
-#define	MSG_OUT         		0x3a
-
-#define	DMAPARAMS       		0x3b
-#define		PRELOADEN       	0x80
-#define		WIDEODD         	0x40
-#define		SCSIEN          	0x20
-#define		SDMAEN          	0x10
-#define		SDMAENACK       	0x10
-#define		HDMAEN          	0x08
-#define		HDMAENACK       	0x08
-#define		DIRECTION       	0x04
-#define		FIFOFLUSH       	0x02
-#define		FIFORESET       	0x01
-
-#define	SEQ_FLAGS       		0x3c
-#define		IDENTIFY_SEEN   	0x80
-#define		TARGET_CMD_IS_TAGGED	0x40
-#define		DPHASE          	0x20
-#define		TARG_CMD_PENDING	0x10
-#define		CMDPHASE_PENDING	0x08
-#define		DPHASE_PENDING  	0x04
-#define		SPHASE_PENDING  	0x02
-#define		NO_DISCONNECT   	0x01
-
-#define	SAVED_SCSIID    		0x3d
-
-#define	SAVED_LUN       		0x3e
-
-#define	LASTPHASE       		0x3f
-#define		P_MESGIN        	0xe0
-#define		PHASE_MASK      	0xe0
-#define		P_STATUS        	0xc0
-#define		P_MESGOUT       	0xa0
-#define		P_COMMAND       	0x80
-#define		CDI             	0x80
-#define		P_DATAIN        	0x40
-#define		IOI             	0x40
-#define		MSGI            	0x20
-#define		P_BUSFREE       	0x01
-#define		P_DATAOUT       	0x00
-
-#define	WAITING_SCBH    		0x40
-
-#define	DISCONNECTED_SCBH		0x41
-
-#define	FREE_SCBH       		0x42
-
-#define	COMPLETE_SCBH   		0x43
-
-#define	HSCB_ADDR       		0x44
-
-#define	SHARED_DATA_ADDR		0x48
-
-#define	KERNEL_QINPOS   		0x4c
-
-#define	QINPOS          		0x4d
-
-#define	QOUTPOS         		0x4e
-
-#define	KERNEL_TQINPOS  		0x4f
-
-#define	TQINPOS         		0x50
-
-#define	ARG_1           		0x51
-#define	RETURN_1        		0x51
-#define		SEND_MSG        	0x80
-#define		SEND_SENSE      	0x40
-#define		SEND_REJ        	0x20
-#define		MSGOUT_PHASEMIS 	0x10
-#define		EXIT_MSG_LOOP   	0x08
-#define		CONT_MSG_LOOP   	0x04
-#define		CONT_TARG_SESSION	0x02
-
-#define	ARG_2           		0x52
-#define	RETURN_2        		0x52
-
-#define	LAST_MSG        		0x53
-
-#define	SCSISEQ_TEMPLATE		0x54
-#define		ENSELO          	0x40
-#define		ENSELI          	0x20
-#define		ENRSELI         	0x10
-#define		ENAUTOATNO      	0x08
-#define		ENAUTOATNI      	0x04
-#define		ENAUTOATNP      	0x02
-
-#define	DATA_COUNT_ODD  		0x55
-
-#define	INITIATOR_TAG   		0x56
-
-#define	SEQ_FLAGS2      		0x57
-#define		TARGET_MSG_PENDING	0x02
-#define		SCB_DMA         	0x01
-
-#define	SCSICONF        		0x5a
-#define		TERM_ENB        	0x80
-#define		RESET_SCSI      	0x40
-#define		ENSPCHK         	0x20
-#define		HWSCSIID        	0x0f
-#define		HSCSIID         	0x07
-
-#define	INTDEF          		0x5c
-#define		EDGE_TRIG       	0x80
-#define		VECTOR          	0x0f
-
-#define	HOSTCONF        		0x5d
-
-#define	HA_274_BIOSCTRL 		0x5f
-#define		BIOSDISABLED    	0x30
-#define		BIOSMODE        	0x30
-#define		CHANNEL_B_PRIMARY	0x08
-
-#define	SEQCTL          		0x60
-#define		PERRORDIS       	0x80
-#define		PAUSEDIS        	0x40
-#define		FAILDIS         	0x20
-#define		FASTMODE        	0x10
-#define		BRKADRINTEN     	0x08
-#define		STEP            	0x04
-#define		SEQRESET        	0x02
-#define		LOADRAM         	0x01
-
-#define	SEQRAM          		0x61
-
-#define	SEQADDR0        		0x62
-
-#define	SEQADDR1        		0x63
-#define		SEQADDR1_MASK   	0x01
-
-#define	ACCUM           		0x64
-
-#define	SINDEX          		0x65
-
-#define	DINDEX          		0x66
-
-#define	ALLONES         		0x69
-
-#define	ALLZEROS        		0x6a
-
-#define	NONE            		0x6a
-
-#define	FLAGS           		0x6b
-#define		ZERO            	0x02
-#define		CARRY           	0x01
-
-#define	SINDIR          		0x6c
-
-#define	DINDIR          		0x6d
-
-#define	FUNCTION1       		0x6e
-
-#define	STACK           		0x6f
-
-#define	TARG_OFFSET     		0x70
-
-#define	BCTL            		0x84
-#define		ACE             	0x08
-#define		ENABLE          	0x01
-
-#define	DSCOMMAND0      		0x84
-#define		CACHETHEN       	0x80
-#define		DPARCKEN        	0x40
-#define		MPARCKEN        	0x20
-#define		EXTREQLCK       	0x10
-#define		INTSCBRAMSEL    	0x08
-#define		RAMPS           	0x04
-#define		USCBSIZE32      	0x02
-#define		CIOPARCKEN      	0x01
-
-#define	BUSTIME         		0x85
-#define		BOFF            	0xf0
-#define		BON             	0x0f
-
-#define	DSCOMMAND1      		0x85
-#define		DSLATT          	0xfc
-#define		HADDLDSEL1      	0x02
-#define		HADDLDSEL0      	0x01
-
-#define	BUSSPD          		0x86
-#define		DFTHRSH         	0xc0
-#define		DFTHRSH_75      	0x80
-#define		STBOFF          	0x38
-#define		STBON           	0x07
-
-#define	HS_MAILBOX      		0x86
-#define		HOST_MAILBOX    	0xf0
-#define		HOST_TQINPOS    	0x80
-#define		SEQ_MAILBOX     	0x0f
-
-#define	DSPCISTATUS     		0x86
-#define		DFTHRSH_100     	0xc0
-
-#define	HCNTRL          		0x87
-#define		POWRDN          	0x40
-#define		SWINT           	0x10
-#define		IRQMS           	0x08
-#define		PAUSE           	0x04
-#define		INTEN           	0x02
-#define		CHIPRST         	0x01
-#define		CHIPRSTACK      	0x01
-
-#define	HADDR           		0x88
-
-#define	HCNT            		0x8c
-
-#define	SCBPTR          		0x90
-
-#define	INTSTAT         		0x91
-#define		SEQINT_MASK     	0xf1
-#define		OUT_OF_RANGE    	0xe1
-#define		NO_FREE_SCB     	0xd1
-#define		SCB_MISMATCH    	0xc1
-#define		MISSED_BUSFREE  	0xb1
-#define		MKMSG_FAILED    	0xa1
-#define		DATA_OVERRUN    	0x91
-#define		PERR_DETECTED   	0x81
-#define		BAD_STATUS      	0x71
-#define		HOST_MSG_LOOP   	0x61
-#define		PDATA_REINIT    	0x51
-#define		IGN_WIDE_RES    	0x41
-#define		NO_MATCH        	0x31
-#define		NO_IDENT        	0x21
-#define		SEND_REJECT     	0x11
-#define		INT_PEND        	0x0f
-#define		BRKADRINT       	0x08
-#define		SCSIINT         	0x04
-#define		CMDCMPLT        	0x02
-#define		BAD_PHASE       	0x01
-#define		SEQINT          	0x01
-
-#define	CLRINT          		0x92
-#define		CLRPARERR       	0x10
-#define		CLRBRKADRINT    	0x08
-#define		CLRSCSIINT      	0x04
-#define		CLRCMDINT       	0x02
-#define		CLRSEQINT       	0x01
-
-#define	ERROR           		0x92
-#define		CIOPARERR       	0x80
-#define		PCIERRSTAT      	0x40
-#define		MPARERR         	0x20
-#define		DPARERR         	0x10
-#define		SQPARERR        	0x08
-#define		ILLOPCODE       	0x04
-#define		ILLSADDR        	0x02
-#define		ILLHADDR        	0x01
-
-#define	DFCNTRL         		0x93
-
-#define	DFSTATUS        		0x94
-#define		PRELOAD_AVAIL   	0x80
-#define		DFCACHETH       	0x40
-#define		FIFOQWDEMP      	0x20
-#define		MREQPEND        	0x10
-#define		HDONE           	0x08
-#define		DFTHRESH        	0x04
-#define		FIFOFULL        	0x02
-#define		FIFOEMP         	0x01
-
-#define	DFWADDR         		0x95
-
-#define	DFRADDR         		0x97
-
-#define	DFDAT           		0x99
-
-#define	SCBCNT          		0x9a
-#define		SCBAUTO         	0x80
-#define		SCBCNT_MASK     	0x1f
-
-#define	QINFIFO         		0x9b
-
-#define	QINCNT          		0x9c
-
-#define	QOUTFIFO        		0x9d
-
-#define	CRCCONTROL1     		0x9d
-#define		CRCONSEEN       	0x80
-#define		CRCVALCHKEN     	0x40
-#define		CRCENDCHKEN     	0x20
-#define		CRCREQCHKEN     	0x10
-#define		TARGCRCENDEN    	0x08
-#define		TARGCRCCNTEN    	0x04
-
-#define	QOUTCNT         		0x9e
-
-#define	SCSIPHASE       		0x9e
-#define		STATUS_PHASE    	0x20
-#define		COMMAND_PHASE   	0x10
-#define		MSG_IN_PHASE    	0x08
-#define		MSG_OUT_PHASE   	0x04
-#define		DATA_PHASE_MASK 	0x03
-#define		DATA_IN_PHASE   	0x02
-#define		DATA_OUT_PHASE  	0x01
-
-#define	SFUNCT          		0x9f
-#define		ALT_MODE        	0x80
-
-#define	SCB_BASE        		0xa0
-
-#define	SCB_CDB_PTR     		0xa0
-#define	SCB_RESIDUAL_DATACNT		0xa0
-#define	SCB_CDB_STORE   		0xa0
-
-#define	SCB_RESIDUAL_SGPTR		0xa4
-
-#define	SCB_SCSI_STATUS 		0xa8
-
-#define	SCB_TARGET_PHASES		0xa9
-
-#define	SCB_TARGET_DATA_DIR		0xaa
-
-#define	SCB_TARGET_ITAG 		0xab
-
-#define	SCB_DATAPTR     		0xac
-
-#define	SCB_DATACNT     		0xb0
-#define		SG_LAST_SEG     	0x80
-#define		SG_HIGH_ADDR_BITS	0x7f
-
-#define	SCB_SGPTR       		0xb4
-#define		SG_RESID_VALID  	0x04
-#define		SG_FULL_RESID   	0x02
-#define		SG_LIST_NULL    	0x01
-
-#define	SCB_CONTROL     		0xb8
-#define		TARGET_SCB      	0x80
-#define		DISCENB         	0x40
-#define		TAG_ENB         	0x20
-#define		MK_MESSAGE      	0x10
-#define		ULTRAENB        	0x08
-#define		DISCONNECTED    	0x04
-#define		SCB_TAG_TYPE    	0x03
-
-#define	SCB_SCSIID      		0xb9
-#define		TID             	0xf0
-#define		TWIN_CHNLB      	0x80
-#define		TWIN_TID        	0x70
-#define		OID             	0x0f
-
-#define	SCB_LUN         		0xba
-#define		LID             	0xff
-
-#define	SCB_TAG         		0xbb
-
-#define	SCB_CDB_LEN     		0xbc
-
-#define	SCB_SCSIRATE    		0xbd
-
-#define	SCB_SCSIOFFSET  		0xbe
-
-#define	SCB_NEXT        		0xbf
-
-#define	SCB_64_SPARE    		0xc0
-
-#define	SEECTL_2840     		0xc0
-#define		CS_2840         	0x04
-#define		CK_2840         	0x02
-#define		DO_2840         	0x01
-
-#define	STATUS_2840     		0xc1
-#define		EEPROM_TF       	0x80
-#define		BIOS_SEL        	0x60
-#define		ADSEL           	0x1e
-#define		DI_2840         	0x01
-
-#define	SCB_64_BTT      		0xd0
-
-#define	CCHADDR         		0xe0
-
-#define	CCHCNT          		0xe8
-
-#define	CCSGRAM         		0xe9
-
-#define	CCSGADDR        		0xea
-
-#define	CCSGCTL         		0xeb
-#define		CCSGDONE        	0x80
-#define		CCSGEN          	0x08
-#define		SG_FETCH_NEEDED 	0x02
-#define		CCSGRESET       	0x01
-
-#define	CCSCBRAM        		0xec
-
-#define	CCSCBADDR       		0xed
-
-#define	CCSCBCTL        		0xee
-#define		CCSCBDONE       	0x80
-#define		ARRDONE         	0x40
-#define		CCARREN         	0x10
-#define		CCSCBEN         	0x08
-#define		CCSCBDIR        	0x04
-#define		CCSCBRESET      	0x01
-
-#define	CCSCBCNT        		0xef
-
-#define	SCBBADDR        		0xf0
-
-#define	CCSCBPTR        		0xf1
-
-#define	HNSCB_QOFF      		0xf4
-
-#define	SNSCB_QOFF      		0xf6
-
-#define	SDSCB_QOFF      		0xf8
-
-#define	QOFF_CTLSTA     		0xfa
-#define		SCB_AVAIL       	0x40
-#define		SNSCB_ROLLOVER  	0x20
-#define		SDSCB_ROLLOVER  	0x10
-#define		SCB_QSIZE       	0x07
-#define		SCB_QSIZE_256   	0x06
-
-#define	DFF_THRSH       		0xfb
-#define		WR_DFTHRSH      	0x70
-#define		WR_DFTHRSH_MAX  	0x70
-#define		WR_DFTHRSH_90   	0x60
-#define		WR_DFTHRSH_85   	0x50
-#define		WR_DFTHRSH_75   	0x40
-#define		WR_DFTHRSH_63   	0x30
-#define		WR_DFTHRSH_50   	0x20
-#define		WR_DFTHRSH_25   	0x10
-#define		RD_DFTHRSH      	0x07
-#define		RD_DFTHRSH_MAX  	0x07
-#define		RD_DFTHRSH_90   	0x06
-#define		RD_DFTHRSH_85   	0x05
-#define		RD_DFTHRSH_75   	0x04
-#define		RD_DFTHRSH_63   	0x03
-#define		RD_DFTHRSH_50   	0x02
-#define		RD_DFTHRSH_25   	0x01
-#define		RD_DFTHRSH_MIN  	0x00
-#define		WR_DFTHRSH_MIN  	0x00
-
-#define	SG_CACHE_SHADOW 		0xfc
-#define		SG_ADDR_MASK    	0xf8
-#define		ODD_SEG         	0x04
-#define		LAST_SEG        	0x02
-#define		LAST_SEG_DONE   	0x01
-
-#define	SG_CACHE_PRE    		0xfc
-
-
-#define	MAX_OFFSET_ULTRA2	0x7f
-#define	MAX_OFFSET_16BIT	0x08
-#define	BUS_8_BIT	0x00
-#define	TARGET_CMD_CMPLT	0xfe
-#define	STATUS_QUEUE_FULL	0x28
-#define	STATUS_BUSY	0x08
-#define	MAX_OFFSET_8BIT	0x0f
-#define	BUS_32_BIT	0x02
-#define	CCSGADDR_MAX	0x80
-#define	TID_SHIFT	0x04
-#define	SCB_DOWNLOAD_SIZE_64	0x30
-#define	HOST_MAILBOX_SHIFT	0x04
-#define	CMD_GROUP_CODE_SHIFT	0x05
-#define	CCSGRAM_MAXSEGS	0x10
-#define	SCB_LIST_NULL	0xff
-#define	SG_SIZEOF	0x08
-#define	SCB_DOWNLOAD_SIZE	0x20
-#define	SEQ_MAILBOX_SHIFT	0x00
-#define	TARGET_DATA_IN	0x01
-#define	HOST_MSG	0xff
-#define	BUS_16_BIT	0x01
-#define	SCB_UPLOAD_SIZE	0x20
-
-
-/* Downloaded Constant Definitions */
-#define	INVERTED_CACHESIZE_MASK	0x03
-#define	SG_PREFETCH_ADDR_MASK	0x06
-#define	SG_PREFETCH_ALIGN_MASK	0x05
-#define	QOUTFIFO_OFFSET	0x00
-#define	SG_PREFETCH_CNT	0x04
-#define	CACHESIZE_MASK	0x02
-#define	QINFIFO_OFFSET	0x01
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_seq.h b/drivers/scsi/aic7xxx/aic7xxx_seq.h
--- a/drivers/scsi/aic7xxx/aic7xxx_seq.h	Fri May 24 18:55:36 2002
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,1299 +0,0 @@
-/*
- * DO NOT EDIT - This file is automatically generated
- *		 from the following source files:
- *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#37 $
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#24 $
- */
-static uint8_t seqprog[] = {
-	0xb2, 0x00, 0x00, 0x08,
-	0xf7, 0x11, 0x22, 0x08,
-	0x00, 0x65, 0xe0, 0x59,
-	0xf7, 0x01, 0x02, 0x08,
-	0xff, 0x6a, 0x24, 0x08,
-	0x40, 0x00, 0x40, 0x68,
-	0x08, 0x1f, 0x3e, 0x10,
-	0x40, 0x00, 0x40, 0x68,
-	0xff, 0x40, 0x3c, 0x60,
-	0x08, 0x1f, 0x3e, 0x10,
-	0x60, 0x0b, 0x42, 0x68,
-	0x40, 0xfa, 0x12, 0x78,
-	0x01, 0x4d, 0xc8, 0x30,
-	0x00, 0x4c, 0x12, 0x70,
-	0x01, 0x39, 0xa2, 0x30,
-	0x00, 0x6a, 0xb2, 0x5e,
-	0x01, 0x51, 0x20, 0x31,
-	0x01, 0x57, 0xae, 0x00,
-	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0x51, 0x04, 0x5e,
-	0x01, 0x51, 0xc8, 0x30,
-	0x00, 0x39, 0xc8, 0x60,
-	0x00, 0xbb, 0x30, 0x70,
-	0xc1, 0x6a, 0xca, 0x5e,
-	0x01, 0xbf, 0x72, 0x30,
-	0x01, 0x40, 0x7e, 0x31,
-	0x01, 0x90, 0x80, 0x30,
-	0x01, 0xf6, 0xd4, 0x30,
-	0x01, 0x4d, 0x9a, 0x18,
-	0xfe, 0x57, 0xae, 0x08,
-	0x01, 0x40, 0x20, 0x31,
-	0x00, 0x65, 0xcc, 0x58,
-	0x60, 0x0b, 0x40, 0x78,
-	0x08, 0x6a, 0x18, 0x00,
-	0x08, 0x11, 0x22, 0x00,
-	0x60, 0x0b, 0x00, 0x78,
-	0x40, 0x0b, 0xfc, 0x68,
-	0x80, 0x0b, 0xb6, 0x78,
-	0x20, 0x6a, 0x16, 0x00,
-	0xa4, 0x6a, 0x06, 0x00,
-	0x08, 0x3c, 0x78, 0x00,
-	0x01, 0x50, 0xc8, 0x30,
-	0xe0, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xee, 0x5d,
-	0x01, 0x6a, 0xdc, 0x01,
-	0x88, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xee, 0x5d,
-	0x01, 0x6a, 0x26, 0x01,
-	0xf0, 0x19, 0x7a, 0x08,
-	0x0f, 0x18, 0xc8, 0x08,
-	0x0f, 0x0f, 0xc8, 0x08,
-	0x0f, 0x05, 0xc8, 0x08,
-	0x00, 0x3d, 0x7a, 0x00,
-	0x08, 0x1f, 0x6e, 0x78,
-	0x80, 0x3d, 0x7a, 0x00,
-	0x01, 0x3d, 0xd8, 0x31,
-	0x01, 0x3d, 0x32, 0x31,
-	0x10, 0x03, 0x46, 0x79,
-	0x00, 0x65, 0xf4, 0x58,
-	0x80, 0x66, 0xae, 0x78,
-	0x01, 0x66, 0xd8, 0x31,
-	0x01, 0x66, 0x32, 0x31,
-	0x3f, 0x66, 0x7c, 0x08,
-	0x40, 0x66, 0x82, 0x68,
-	0x01, 0x3c, 0x78, 0x00,
-	0x10, 0x03, 0x9e, 0x78,
-	0x00, 0x65, 0xf4, 0x58,
-	0xe0, 0x66, 0xc8, 0x18,
-	0x00, 0x65, 0xaa, 0x50,
-	0xdd, 0x66, 0xc8, 0x18,
-	0x00, 0x65, 0xaa, 0x48,
-	0x01, 0x66, 0xd8, 0x31,
-	0x01, 0x66, 0x32, 0x31,
-	0x10, 0x03, 0x46, 0x79,
-	0x00, 0x65, 0xf4, 0x58,
-	0x01, 0x66, 0xd8, 0x31,
-	0x01, 0x66, 0x32, 0x31,
-	0x01, 0x66, 0xac, 0x30,
-	0x40, 0x3c, 0x78, 0x00,
-	0xff, 0x6a, 0xd8, 0x01,
-	0xff, 0x6a, 0x32, 0x01,
-	0x90, 0x3c, 0x78, 0x00,
-	0x02, 0x57, 0x3a, 0x69,
-	0x10, 0x03, 0x38, 0x69,
-	0x00, 0x65, 0x1e, 0x41,
-	0x02, 0x57, 0xae, 0x00,
-	0x00, 0x65, 0x9e, 0x40,
-	0x61, 0x6a, 0xca, 0x5e,
-	0x08, 0x51, 0x1e, 0x71,
-	0x02, 0x0b, 0xb2, 0x78,
-	0x00, 0x65, 0xae, 0x40,
-	0x1a, 0x01, 0x02, 0x00,
-	0xf0, 0x19, 0x7a, 0x08,
-	0x0f, 0x0f, 0xc8, 0x08,
-	0x0f, 0x05, 0xc8, 0x08,
-	0x00, 0x3d, 0x7a, 0x00,
-	0x08, 0x1f, 0xc4, 0x78,
-	0x80, 0x3d, 0x7a, 0x00,
-	0x20, 0x6a, 0x16, 0x00,
-	0x00, 0x65, 0xc0, 0x41,
-	0x00, 0x65, 0xa4, 0x5e,
-	0x00, 0x65, 0x12, 0x40,
-	0x20, 0x11, 0xd2, 0x68,
-	0x20, 0x6a, 0x18, 0x00,
-	0x20, 0x11, 0x22, 0x00,
-	0xf7, 0x1f, 0xca, 0x08,
-	0x80, 0xb9, 0xd8, 0x78,
-	0x08, 0x65, 0xca, 0x00,
-	0x01, 0x65, 0x3e, 0x30,
-	0x01, 0xb9, 0x1e, 0x30,
-	0x7f, 0xb9, 0x0a, 0x08,
-	0x01, 0xb9, 0x0a, 0x30,
-	0x01, 0x54, 0xca, 0x30,
-	0x80, 0xb8, 0xe6, 0x78,
-	0x80, 0x65, 0xca, 0x00,
-	0x01, 0x65, 0x00, 0x34,
-	0x01, 0x54, 0x00, 0x34,
-	0x1a, 0x01, 0x02, 0x00,
-	0x08, 0xb8, 0xf0, 0x78,
-	0x20, 0x01, 0x02, 0x00,
-	0x02, 0xbd, 0x08, 0x34,
-	0x01, 0xbd, 0x08, 0x34,
-	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0xf6, 0x78,
-	0xf7, 0x01, 0x02, 0x08,
-	0x01, 0x06, 0xcc, 0x34,
-	0xb2, 0x00, 0x00, 0x08,
-	0x40, 0x6a, 0x16, 0x00,
-	0x01, 0x40, 0x20, 0x31,
-	0x01, 0xbf, 0x80, 0x30,
-	0x01, 0xb9, 0x7a, 0x30,
-	0x01, 0xba, 0x7c, 0x30,
-	0x00, 0x65, 0xea, 0x58,
-	0x80, 0x0b, 0xbc, 0x79,
-	0xe4, 0x6a, 0x60, 0x5d,
-	0x80, 0xba, 0x76, 0x5d,
-	0x20, 0xb8, 0x16, 0x79,
-	0x20, 0x6a, 0x76, 0x5d,
-	0x00, 0xab, 0x76, 0x5d,
-	0x01, 0xa9, 0x78, 0x30,
-	0x10, 0xb8, 0x1e, 0x79,
-	0xe4, 0x6a, 0x60, 0x5d,
-	0x00, 0x65, 0xae, 0x40,
-	0x10, 0x03, 0x36, 0x69,
-	0x08, 0x3c, 0x52, 0x69,
-	0x04, 0x3c, 0x8a, 0x69,
-	0x02, 0x3c, 0x90, 0x69,
-	0x01, 0x3c, 0x3c, 0x79,
-	0x01, 0x6a, 0xa2, 0x30,
-	0x00, 0x65, 0x9c, 0x59,
-	0x04, 0x51, 0x2c, 0x61,
-	0x00, 0x6a, 0xb2, 0x5e,
-	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x04, 0x5e,
-	0x00, 0x65, 0x16, 0x41,
-	0xa4, 0x6a, 0x06, 0x00,
-	0x00, 0x65, 0xf4, 0x58,
-	0x00, 0x65, 0xae, 0x40,
-	0xe4, 0x6a, 0x60, 0x5d,
-	0x20, 0x3c, 0x42, 0x79,
-	0x02, 0x6a, 0x76, 0x5d,
-	0x04, 0x6a, 0x76, 0x5d,
-	0x01, 0x03, 0x44, 0x69,
-	0xf7, 0x11, 0x22, 0x08,
-	0xff, 0x6a, 0x24, 0x08,
-	0xff, 0x6a, 0x06, 0x08,
-	0x01, 0x6a, 0x7e, 0x00,
-	0x00, 0x65, 0x9c, 0x59,
-	0x00, 0x65, 0x04, 0x40,
-	0x80, 0x86, 0xc8, 0x08,
-	0x01, 0x4f, 0xc8, 0x30,
-	0x00, 0x50, 0x64, 0x61,
-	0xc4, 0x6a, 0x60, 0x5d,
-	0x40, 0x3c, 0x60, 0x79,
-	0x28, 0x6a, 0x76, 0x5d,
-	0x00, 0x65, 0x44, 0x41,
-	0x08, 0x6a, 0x76, 0x5d,
-	0x00, 0x65, 0x44, 0x41,
-	0x84, 0x6a, 0x60, 0x5d,
-	0x00, 0x65, 0xf4, 0x58,
-	0x01, 0x66, 0xc8, 0x30,
-	0x01, 0x64, 0xd8, 0x31,
-	0x01, 0x64, 0x32, 0x31,
-	0x5b, 0x64, 0xc8, 0x28,
-	0x30, 0x64, 0xca, 0x18,
-	0x01, 0x6c, 0xc8, 0x30,
-	0xff, 0x64, 0x86, 0x79,
-	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0x78, 0x79,
-	0x01, 0x64, 0x7e, 0x61,
-	0xf7, 0x01, 0x02, 0x08,
-	0x01, 0x06, 0xd8, 0x31,
-	0x01, 0x06, 0x32, 0x31,
-	0xff, 0x64, 0xc8, 0x18,
-	0xff, 0x64, 0x78, 0x69,
-	0xf7, 0x3c, 0x78, 0x08,
-	0x00, 0x65, 0x1e, 0x41,
-	0x40, 0xaa, 0x7e, 0x10,
-	0x04, 0xaa, 0x60, 0x5d,
-	0x00, 0x65, 0x52, 0x42,
-	0xc4, 0x6a, 0x60, 0x5d,
-	0xc0, 0x6a, 0x7e, 0x00,
-	0x00, 0xa8, 0x76, 0x5d,
-	0xe4, 0x6a, 0x06, 0x00,
-	0x00, 0x6a, 0x76, 0x5d,
-	0x00, 0x65, 0x44, 0x41,
-	0x10, 0x3c, 0xa0, 0x69,
-	0x00, 0xbb, 0x80, 0x44,
-	0x18, 0x6a, 0xda, 0x01,
-	0x01, 0x69, 0xd8, 0x31,
-	0x1c, 0x6a, 0xd0, 0x01,
-	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0xa8, 0x79,
-	0xff, 0x6a, 0xdc, 0x09,
-	0x01, 0x93, 0x26, 0x01,
-	0x03, 0x6a, 0x2a, 0x01,
-	0x01, 0x69, 0x32, 0x31,
-	0x1c, 0x6a, 0xd2, 0x5d,
-	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9a, 0x5e,
-	0x01, 0x50, 0xa0, 0x18,
-	0x02, 0x6a, 0x22, 0x05,
-	0x80, 0x6a, 0x74, 0x00,
-	0x80, 0x3c, 0x78, 0x00,
-	0x00, 0x65, 0xca, 0x5d,
-	0x01, 0x3f, 0xc8, 0x30,
-	0xbf, 0x64, 0x52, 0x7a,
-	0x80, 0x64, 0xa6, 0x73,
-	0xa0, 0x64, 0x04, 0x74,
-	0xc0, 0x64, 0xf8, 0x73,
-	0xe0, 0x64, 0x34, 0x74,
-	0x01, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0xc0, 0x41,
-	0xf7, 0x11, 0x22, 0x08,
-	0x01, 0x06, 0xd4, 0x30,
-	0xff, 0x6a, 0x24, 0x08,
-	0xf7, 0x01, 0x02, 0x08,
-	0x09, 0x0c, 0xda, 0x79,
-	0x08, 0x0c, 0x04, 0x68,
-	0xb1, 0x6a, 0xca, 0x5e,
-	0xff, 0x6a, 0x26, 0x09,
-	0x12, 0x01, 0x02, 0x00,
-	0x02, 0x6a, 0x08, 0x30,
-	0xff, 0x6a, 0x08, 0x08,
-	0xdf, 0x01, 0x02, 0x08,
-	0x01, 0x6a, 0x7e, 0x00,
-	0xff, 0x6a, 0x78, 0x0c,
-	0xff, 0x6a, 0xc8, 0x08,
-	0x08, 0xa4, 0x48, 0x19,
-	0x00, 0xa5, 0x4a, 0x21,
-	0x00, 0xa6, 0x4c, 0x21,
-	0x00, 0xa7, 0x4e, 0x25,
-	0x08, 0xeb, 0xce, 0x7e,
-	0x80, 0xeb, 0xfa, 0x79,
-	0xff, 0x6a, 0xd6, 0x09,
-	0x08, 0xeb, 0xfe, 0x69,
-	0xff, 0x6a, 0xd4, 0x0c,
-	0x80, 0xa3, 0xce, 0x6e,
-	0x88, 0xeb, 0x14, 0x72,
-	0x08, 0xeb, 0xce, 0x6e,
-	0x04, 0xea, 0x18, 0xe2,
-	0x08, 0xee, 0xce, 0x6e,
-	0x04, 0x6a, 0xd0, 0x81,
-	0x05, 0xa4, 0xc0, 0x89,
-	0x03, 0xa5, 0xc2, 0x31,
-	0x09, 0x6a, 0xd6, 0x05,
-	0x00, 0x65, 0xfc, 0x59,
-	0x06, 0xa4, 0xd4, 0x89,
-	0x80, 0x94, 0xce, 0x7e,
-	0x07, 0xe9, 0x10, 0x31,
-	0x01, 0x8c, 0x20, 0x7a,
-	0x01, 0x55, 0xaa, 0x10,
-	0x01, 0xe9, 0x46, 0x31,
-	0x00, 0xa3, 0xac, 0x5e,
-	0x00, 0x65, 0xee, 0x59,
-	0x01, 0xa4, 0xca, 0x30,
-	0x01, 0x55, 0x2c, 0x7a,
-	0x04, 0x65, 0xca, 0x00,
-	0x80, 0xa3, 0x30, 0x7a,
-	0x02, 0x65, 0xca, 0x00,
-	0x01, 0x65, 0xf8, 0x31,
-	0x80, 0x93, 0x26, 0x01,
-	0xff, 0x6a, 0xd4, 0x0c,
-	0x01, 0x8c, 0xc8, 0x30,
-	0x00, 0x88, 0xc8, 0x18,
-	0x02, 0x64, 0xc8, 0x88,
-	0xff, 0x64, 0xce, 0x7e,
-	0xff, 0x8d, 0x46, 0x6a,
-	0xff, 0x8e, 0x46, 0x6a,
-	0x03, 0x8c, 0xd4, 0x98,
-	0x00, 0x65, 0xce, 0x56,
-	0x01, 0x64, 0x70, 0x30,
-	0xff, 0x64, 0xc8, 0x10,
-	0x01, 0x64, 0xc8, 0x18,
-	0x00, 0x8c, 0x18, 0x19,
-	0xff, 0x8d, 0x1a, 0x21,
-	0xff, 0x8e, 0x1c, 0x25,
-	0x80, 0x3c, 0x56, 0x6a,
-	0x21, 0x6a, 0xca, 0x46,
-	0xa8, 0x6a, 0x76, 0x00,
-	0x79, 0x6a, 0x76, 0x00,
-	0x40, 0x3f, 0x5e, 0x6a,
-	0x04, 0x3b, 0x76, 0x00,
-	0x04, 0x6a, 0xd4, 0x81,
-	0x20, 0x3c, 0x66, 0x7a,
-	0x51, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0x80, 0x42,
-	0x20, 0x3c, 0x78, 0x00,
-	0x00, 0xb3, 0xac, 0x5e,
-	0x07, 0xac, 0x10, 0x31,
-	0x05, 0xb3, 0x46, 0x31,
-	0x88, 0x6a, 0xcc, 0x00,
-	0xac, 0x6a, 0xe0, 0x5d,
-	0xa3, 0x6a, 0xcc, 0x00,
-	0xb3, 0x6a, 0xe4, 0x5d,
-	0x00, 0x65, 0x36, 0x5a,
-	0xfd, 0xa4, 0x48, 0x09,
-	0x01, 0x8c, 0xaa, 0x08,
-	0x03, 0x8c, 0x10, 0x30,
-	0x00, 0x65, 0xd8, 0x5d,
-	0x01, 0xa4, 0x92, 0x7a,
-	0x04, 0x3b, 0x76, 0x08,
-	0x01, 0x3b, 0x26, 0x31,
-	0x80, 0x02, 0x04, 0x00,
-	0x10, 0x0c, 0x88, 0x7a,
-	0x03, 0x9e, 0x8a, 0x6a,
-	0x7f, 0x02, 0x04, 0x08,
-	0x91, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0xc0, 0x41,
-	0x01, 0xa4, 0xca, 0x30,
-	0x80, 0xa3, 0x98, 0x7a,
-	0x02, 0x65, 0xca, 0x00,
-	0x01, 0x55, 0x9c, 0x7a,
-	0x04, 0x65, 0xca, 0x00,
-	0x01, 0x65, 0xf8, 0x31,
-	0x01, 0x3b, 0x26, 0x31,
-	0x00, 0x65, 0x02, 0x5a,
-	0x01, 0xfc, 0xaa, 0x6a,
-	0x80, 0x0b, 0xa0, 0x6a,
-	0x10, 0x0c, 0xa0, 0x7a,
-	0x20, 0x93, 0xa0, 0x6a,
-	0x02, 0x93, 0x26, 0x01,
-	0x02, 0xfc, 0xb4, 0x7a,
-	0x40, 0x0d, 0xce, 0x6a,
-	0x01, 0xa4, 0x48, 0x01,
-	0x00, 0x65, 0xce, 0x42,
-	0x40, 0x0d, 0xba, 0x6a,
-	0x00, 0x65, 0x02, 0x5a,
-	0x00, 0x65, 0xac, 0x42,
-	0x80, 0xfc, 0xc4, 0x7a,
-	0x80, 0xa4, 0xc4, 0x6a,
-	0xff, 0xa5, 0x4a, 0x19,
-	0xff, 0xa6, 0x4c, 0x21,
-	0xff, 0xa7, 0x4e, 0x21,
-	0xf8, 0xfc, 0x48, 0x09,
-	0xff, 0x6a, 0xaa, 0x08,
-	0x04, 0xfc, 0xcc, 0x7a,
-	0x01, 0x55, 0xaa, 0x00,
-	0xff, 0x6a, 0x46, 0x09,
-	0x04, 0x3b, 0xe6, 0x6a,
-	0x02, 0x93, 0x26, 0x01,
-	0x01, 0x94, 0xd0, 0x7a,
-	0x01, 0x94, 0xd0, 0x7a,
-	0x01, 0x94, 0xd0, 0x7a,
-	0x01, 0x94, 0xd0, 0x7a,
-	0x01, 0x94, 0xd0, 0x7a,
-	0x01, 0xa4, 0xe4, 0x7a,
-	0x01, 0xfc, 0xde, 0x7a,
-	0x01, 0x94, 0xe6, 0x6a,
-	0x00, 0x65, 0x80, 0x42,
-	0x01, 0x94, 0xe4, 0x7a,
-	0x10, 0x94, 0xe6, 0x6a,
-	0xd7, 0x93, 0x26, 0x09,
-	0x28, 0x93, 0xea, 0x6a,
-	0x01, 0x85, 0x0a, 0x01,
-	0x02, 0xfc, 0xf2, 0x6a,
-	0x01, 0x14, 0x46, 0x31,
-	0xff, 0x6a, 0x10, 0x09,
-	0xfe, 0x85, 0x0a, 0x09,
-	0xff, 0x38, 0x00, 0x6b,
-	0x80, 0xa3, 0x00, 0x7b,
-	0x80, 0x0b, 0xfe, 0x7a,
-	0x04, 0x3b, 0x00, 0x7b,
-	0xbf, 0x3b, 0x76, 0x08,
-	0x01, 0x3b, 0x26, 0x31,
-	0x00, 0x65, 0x02, 0x5a,
-	0x01, 0x0b, 0x0e, 0x6b,
-	0x10, 0x0c, 0x02, 0x7b,
-	0x04, 0x93, 0x0c, 0x6b,
-	0x01, 0x94, 0x0a, 0x7b,
-	0x10, 0x94, 0x0c, 0x6b,
-	0xc7, 0x93, 0x26, 0x09,
-	0x01, 0x99, 0xd4, 0x30,
-	0x38, 0x93, 0x10, 0x6b,
-	0xff, 0x08, 0x62, 0x6b,
-	0xff, 0x09, 0x62, 0x6b,
-	0xff, 0x0a, 0x62, 0x6b,
-	0xff, 0x38, 0x2c, 0x7b,
-	0x04, 0x14, 0x10, 0x31,
-	0x01, 0x38, 0x18, 0x31,
-	0x02, 0x6a, 0x1a, 0x31,
-	0x88, 0x6a, 0xcc, 0x00,
-	0x14, 0x6a, 0xe6, 0x5d,
-	0x00, 0x38, 0xd2, 0x5d,
-	0xff, 0x6a, 0x70, 0x08,
-	0x00, 0x65, 0x58, 0x43,
-	0x80, 0xa3, 0x32, 0x7b,
-	0x01, 0xa4, 0x48, 0x01,
-	0x00, 0x65, 0x62, 0x43,
-	0x08, 0xeb, 0x38, 0x7b,
-	0x00, 0x65, 0x02, 0x5a,
-	0x08, 0xeb, 0x34, 0x6b,
-	0x07, 0xe9, 0x10, 0x31,
-	0x01, 0xe9, 0xca, 0x30,
-	0x01, 0x65, 0x46, 0x31,
-	0x00, 0x6a, 0xac, 0x5e,
-	0x88, 0x6a, 0xcc, 0x00,
-	0xa4, 0x6a, 0xe6, 0x5d,
-	0x08, 0x6a, 0xd2, 0x5d,
-	0x0d, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9a, 0x5e,
-	0x88, 0x6a, 0xcc, 0x00,
-	0x00, 0x65, 0x7c, 0x5e,
-	0x01, 0x99, 0x46, 0x31,
-	0x00, 0xa3, 0xac, 0x5e,
-	0x01, 0x88, 0x10, 0x31,
-	0x00, 0x65, 0x36, 0x5a,
-	0x00, 0x65, 0xee, 0x59,
-	0x03, 0x8c, 0x10, 0x30,
-	0x00, 0x65, 0xd8, 0x5d,
-	0x01, 0x8c, 0x60, 0x7b,
-	0x01, 0x55, 0xaa, 0x10,
-	0x80, 0x0b, 0x80, 0x6a,
-	0x80, 0x0b, 0x6a, 0x6b,
-	0x01, 0x0c, 0x64, 0x7b,
-	0x10, 0x0c, 0x80, 0x7a,
-	0x03, 0x9e, 0x80, 0x6a,
-	0x00, 0x65, 0xf8, 0x59,
-	0x00, 0x6a, 0xac, 0x5e,
-	0x01, 0xa4, 0x8a, 0x6b,
-	0xff, 0x38, 0x80, 0x7b,
-	0x01, 0x38, 0xc8, 0x30,
-	0x00, 0x08, 0x40, 0x19,
-	0xff, 0x6a, 0xc8, 0x08,
-	0x00, 0x09, 0x42, 0x21,
-	0x00, 0x0a, 0x44, 0x21,
-	0xff, 0x6a, 0x70, 0x08,
-	0x00, 0x65, 0x82, 0x43,
-	0x03, 0x08, 0x40, 0x31,
-	0x03, 0x08, 0x40, 0x31,
-	0x01, 0x08, 0x40, 0x31,
-	0x01, 0x09, 0x42, 0x31,
-	0x01, 0x0a, 0x44, 0x31,
-	0xfd, 0xb4, 0x68, 0x09,
-	0x12, 0x01, 0x02, 0x00,
-	0x12, 0x01, 0x02, 0x00,
-	0x04, 0x3c, 0xc0, 0x79,
-	0xfb, 0x3c, 0x78, 0x08,
-	0x04, 0x93, 0x1e, 0x79,
-	0x01, 0x0c, 0x96, 0x6b,
-	0x01, 0x55, 0x1e, 0x79,
-	0x80, 0x04, 0x1e, 0x79,
-	0xe4, 0x6a, 0x60, 0x5d,
-	0x23, 0x6a, 0x76, 0x5d,
-	0x01, 0x6a, 0x76, 0x5d,
-	0x00, 0x65, 0x1e, 0x41,
-	0x00, 0x65, 0xc0, 0x41,
-	0x80, 0x3c, 0xaa, 0x6b,
-	0x21, 0x6a, 0xca, 0x46,
-	0x01, 0xbc, 0x18, 0x31,
-	0x02, 0x6a, 0x1a, 0x31,
-	0x02, 0x6a, 0xf8, 0x01,
-	0x01, 0xbc, 0x10, 0x30,
-	0x02, 0x6a, 0x12, 0x30,
-	0x01, 0xbc, 0x10, 0x30,
-	0xff, 0x6a, 0x12, 0x08,
-	0xff, 0x6a, 0x14, 0x08,
-	0xf3, 0xbc, 0xd4, 0x18,
-	0xa0, 0x6a, 0xd0, 0x53,
-	0x04, 0xa0, 0x10, 0x31,
-	0xac, 0x6a, 0x26, 0x01,
-	0x04, 0xa0, 0x10, 0x31,
-	0x03, 0x08, 0x18, 0x31,
-	0x88, 0x6a, 0xcc, 0x00,
-	0xa0, 0x6a, 0xe6, 0x5d,
-	0x00, 0xbc, 0xd2, 0x5d,
-	0x3d, 0x6a, 0x26, 0x01,
-	0x00, 0x65, 0xe8, 0x43,
-	0xff, 0x6a, 0x10, 0x09,
-	0xa4, 0x6a, 0x26, 0x01,
-	0x0c, 0xa0, 0x32, 0x31,
-	0x05, 0x6a, 0x26, 0x01,
-	0x35, 0x6a, 0x26, 0x01,
-	0x0c, 0xa0, 0x32, 0x31,
-	0x36, 0x6a, 0x26, 0x01,
-	0x02, 0x93, 0x26, 0x01,
-	0x35, 0x6a, 0x26, 0x01,
-	0x00, 0x65, 0x8e, 0x5e,
-	0x00, 0x65, 0x8e, 0x5e,
-	0x02, 0x93, 0x26, 0x01,
-	0x04, 0x0b, 0xec, 0x6b,
-	0x10, 0x0c, 0xe8, 0x7b,
-	0x01, 0x03, 0xec, 0x6b,
-	0x20, 0x93, 0xe8, 0x6b,
-	0xc7, 0x93, 0x26, 0x09,
-	0x38, 0x93, 0xf2, 0x6b,
-	0x10, 0x01, 0x02, 0x00,
-	0x00, 0x65, 0xc0, 0x41,
-	0x80, 0x3c, 0xfc, 0x6b,
-	0x21, 0x6a, 0xca, 0x46,
-	0x01, 0x06, 0x50, 0x31,
-	0x00, 0x65, 0xc0, 0x41,
-	0x10, 0x3f, 0x06, 0x00,
-	0x10, 0x6a, 0x06, 0x00,
-	0x01, 0x3a, 0xca, 0x30,
-	0x80, 0x65, 0x20, 0x64,
-	0x10, 0xb8, 0x44, 0x6c,
-	0xc0, 0xba, 0xca, 0x00,
-	0x40, 0xb8, 0x10, 0x6c,
-	0xbf, 0x65, 0xca, 0x08,
-	0x20, 0xb8, 0x24, 0x7c,
-	0x01, 0x65, 0x0c, 0x30,
-	0x00, 0x65, 0xca, 0x5d,
-	0xa0, 0x3f, 0x2c, 0x64,
-	0x23, 0xb8, 0x0c, 0x08,
-	0x00, 0x65, 0xca, 0x5d,
-	0xa0, 0x3f, 0x2c, 0x64,
-	0x00, 0xbb, 0x24, 0x44,
-	0xff, 0x65, 0x24, 0x64,
-	0x00, 0x65, 0x44, 0x44,
-	0x40, 0x6a, 0x18, 0x00,
-	0x01, 0x65, 0x0c, 0x30,
-	0x00, 0x65, 0xca, 0x5d,
-	0xa0, 0x3f, 0x00, 0x74,
-	0x40, 0x6a, 0x18, 0x00,
-	0x01, 0x3a, 0xa6, 0x30,
-	0x08, 0x6a, 0x74, 0x00,
-	0x00, 0x65, 0xc0, 0x41,
-	0x64, 0x6a, 0x5a, 0x5d,
-	0x80, 0x64, 0xca, 0x6c,
-	0x04, 0x64, 0x90, 0x74,
-	0x02, 0x64, 0x9e, 0x74,
-	0x00, 0x6a, 0x60, 0x74,
-	0x03, 0x64, 0xbc, 0x74,
-	0x23, 0x64, 0x4c, 0x74,
-	0x08, 0x64, 0x5c, 0x74,
-	0x61, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0xca, 0x5d,
-	0x08, 0x51, 0xc2, 0x71,
-	0x00, 0x65, 0x44, 0x44,
-	0x80, 0x04, 0x5a, 0x7c,
-	0x51, 0x6a, 0x50, 0x5d,
-	0x01, 0x51, 0x5a, 0x64,
-	0x01, 0xa4, 0x56, 0x7c,
-	0x01, 0x55, 0x5c, 0x7c,
-	0x41, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0x5c, 0x44,
-	0x07, 0x6a, 0x46, 0x5d,
-	0x01, 0x06, 0xd4, 0x30,
-	0x00, 0x65, 0xc0, 0x41,
-	0x10, 0xb8, 0x64, 0x7c,
-	0xa1, 0x6a, 0xca, 0x5e,
-	0x01, 0xb4, 0x6a, 0x6c,
-	0x02, 0xb4, 0x6c, 0x6c,
-	0x01, 0xa4, 0x6c, 0x7c,
-	0xff, 0xa8, 0x7c, 0x7c,
-	0x04, 0xb4, 0x68, 0x01,
-	0x01, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x04, 0x5e,
-	0xff, 0xa8, 0x7c, 0x7c,
-	0x71, 0x6a, 0xca, 0x5e,
-	0x40, 0x51, 0x7c, 0x64,
-	0x00, 0x65, 0xa4, 0x5e,
-	0x00, 0x65, 0xd2, 0x41,
-	0x00, 0xbb, 0x80, 0x5c,
-	0x00, 0x65, 0xd2, 0x41,
-	0x00, 0x65, 0xa4, 0x5e,
-	0x01, 0x65, 0xa2, 0x30,
-	0x01, 0xf8, 0xc8, 0x30,
-	0x01, 0x4e, 0xc8, 0x30,
-	0x00, 0x6a, 0xa8, 0xdd,
-	0x00, 0x51, 0xba, 0x5d,
-	0x01, 0x4e, 0x9c, 0x18,
-	0x02, 0x6a, 0x22, 0x05,
-	0x04, 0xb8, 0x70, 0x01,
-	0x00, 0x65, 0xc6, 0x5e,
-	0x20, 0xb8, 0xd2, 0x69,
-	0x01, 0xbb, 0xa2, 0x30,
-	0x01, 0xba, 0x7c, 0x30,
-	0x00, 0xb9, 0xc0, 0x5c,
-	0x00, 0x65, 0xd2, 0x41,
-	0x01, 0x06, 0xd4, 0x30,
-	0x20, 0x3c, 0xc0, 0x79,
-	0x20, 0x3c, 0x5c, 0x7c,
-	0x01, 0xa4, 0xac, 0x7c,
-	0x01, 0xb4, 0x68, 0x01,
-	0x00, 0x65, 0xc0, 0x41,
-	0x00, 0x65, 0x5c, 0x44,
-	0x04, 0x14, 0x58, 0x31,
-	0x01, 0x06, 0xd4, 0x30,
-	0x08, 0xa0, 0x60, 0x31,
-	0xac, 0x6a, 0xcc, 0x00,
-	0x14, 0x6a, 0xe6, 0x5d,
-	0x01, 0x06, 0xd4, 0x30,
-	0xa0, 0x6a, 0xde, 0x5d,
-	0x00, 0x65, 0xc0, 0x41,
-	0xdf, 0x3c, 0x78, 0x08,
-	0x00, 0x65, 0x5c, 0x44,
-	0x4c, 0x65, 0xcc, 0x28,
-	0x01, 0x3e, 0x20, 0x31,
-	0xd0, 0x66, 0xcc, 0x18,
-	0x20, 0x66, 0xcc, 0x18,
-	0x01, 0x51, 0xda, 0x34,
-	0x4c, 0x3d, 0xca, 0x28,
-	0x3f, 0x64, 0x7c, 0x08,
-	0xd0, 0x65, 0xca, 0x18,
-	0x01, 0x3e, 0x20, 0x31,
-	0x30, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xd8, 0x4c,
-	0xe1, 0x6a, 0x22, 0x01,
-	0xff, 0x6a, 0xd4, 0x08,
-	0x20, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xe0, 0x54,
-	0xe1, 0x6a, 0x22, 0x01,
-	0xff, 0x6a, 0xd4, 0x08,
-	0x20, 0x65, 0xca, 0x18,
-	0xe0, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xea, 0x4c,
-	0xe1, 0x6a, 0x22, 0x01,
-	0xff, 0x6a, 0xd4, 0x08,
-	0xd0, 0x65, 0xd4, 0x18,
-	0x00, 0x65, 0xf2, 0x54,
-	0xe1, 0x6a, 0x22, 0x01,
-	0xff, 0x6a, 0xd4, 0x08,
-	0x01, 0x6c, 0xa2, 0x30,
-	0xff, 0x51, 0x04, 0x75,
-	0x00, 0x51, 0x80, 0x5d,
-	0x01, 0x51, 0x20, 0x31,
-	0x00, 0x65, 0x26, 0x45,
-	0x01, 0xba, 0xc8, 0x30,
-	0x00, 0x3e, 0x26, 0x75,
-	0x00, 0x65, 0xa2, 0x5e,
-	0x80, 0x3c, 0x78, 0x00,
-	0x01, 0x06, 0xd4, 0x30,
-	0x00, 0x65, 0xca, 0x5d,
-	0x01, 0x3c, 0x78, 0x00,
-	0xe0, 0x3f, 0x42, 0x65,
-	0x02, 0x3c, 0x78, 0x00,
-	0x20, 0x12, 0x42, 0x65,
-	0x51, 0x6a, 0x50, 0x5d,
-	0x00, 0x51, 0x80, 0x5d,
-	0x51, 0x6a, 0x50, 0x5d,
-	0x01, 0x51, 0x20, 0x31,
-	0x04, 0x3c, 0x78, 0x00,
-	0x01, 0xb9, 0xc8, 0x30,
-	0x00, 0x3d, 0x40, 0x65,
-	0x08, 0x3c, 0x78, 0x00,
-	0x01, 0xba, 0xc8, 0x30,
-	0x00, 0x3e, 0x40, 0x65,
-	0x10, 0x3c, 0x78, 0x00,
-	0x04, 0xb8, 0x40, 0x7d,
-	0xfb, 0xb8, 0x70, 0x09,
-	0x20, 0xb8, 0x36, 0x6d,
-	0x01, 0x90, 0xc8, 0x30,
-	0xff, 0x6a, 0xa2, 0x00,
-	0x00, 0x3d, 0xc0, 0x5c,
-	0x01, 0x64, 0x20, 0x31,
-	0x80, 0x6a, 0x78, 0x00,
-	0x00, 0x65, 0xec, 0x58,
-	0x10, 0xb8, 0x5c, 0x7c,
-	0xff, 0x6a, 0x46, 0x5d,
-	0x00, 0x65, 0x5c, 0x44,
-	0x00, 0x65, 0xa2, 0x5e,
-	0x31, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0x5c, 0x44,
-	0x10, 0x3f, 0x06, 0x00,
-	0x10, 0x6a, 0x06, 0x00,
-	0x01, 0x65, 0x74, 0x34,
-	0x81, 0x6a, 0xca, 0x5e,
-	0x00, 0x65, 0x52, 0x45,
-	0x01, 0x06, 0xd4, 0x30,
-	0x01, 0x0c, 0x52, 0x7d,
-	0x04, 0x0c, 0x4c, 0x6d,
-	0xe0, 0x03, 0x7e, 0x08,
-	0xe0, 0x3f, 0xc0, 0x61,
-	0x01, 0x65, 0xcc, 0x30,
-	0x01, 0x12, 0xda, 0x34,
-	0x01, 0x06, 0xd4, 0x34,
-	0x01, 0x03, 0x60, 0x6d,
-	0x40, 0x03, 0xcc, 0x08,
-	0x01, 0x65, 0x06, 0x30,
-	0x40, 0x65, 0xc8, 0x08,
-	0x00, 0x66, 0x6e, 0x75,
-	0x40, 0x65, 0x6e, 0x7d,
-	0x00, 0x65, 0x6e, 0x5d,
-	0xff, 0x6a, 0xd4, 0x08,
-	0xff, 0x6a, 0xd4, 0x08,
-	0xff, 0x6a, 0xd4, 0x08,
-	0xff, 0x6a, 0xd4, 0x0c,
-	0x08, 0x01, 0x02, 0x00,
-	0x02, 0x0b, 0x78, 0x7d,
-	0x01, 0x65, 0x0c, 0x30,
-	0x02, 0x0b, 0x7c, 0x7d,
-	0xf7, 0x01, 0x02, 0x0c,
-	0x01, 0x65, 0xc8, 0x30,
-	0xff, 0x41, 0xa0, 0x75,
-	0x01, 0x41, 0x20, 0x31,
-	0xff, 0x6a, 0xa4, 0x00,
-	0x00, 0x65, 0x90, 0x45,
-	0xff, 0xbf, 0xa0, 0x75,
-	0x01, 0x90, 0xa4, 0x30,
-	0x01, 0xbf, 0x20, 0x31,
-	0x00, 0xbb, 0x8a, 0x65,
-	0xff, 0x52, 0x9e, 0x75,
-	0x01, 0xbf, 0xcc, 0x30,
-	0x01, 0x90, 0xca, 0x30,
-	0x01, 0x52, 0x20, 0x31,
-	0x01, 0x66, 0x7e, 0x31,
-	0x01, 0x65, 0x20, 0x35,
-	0x01, 0xbf, 0x82, 0x34,
-	0x01, 0x64, 0xa2, 0x30,
-	0x00, 0x6a, 0xb2, 0x5e,
-	0x0d, 0x6a, 0x76, 0x00,
-	0x00, 0x51, 0x04, 0x46,
-	0x01, 0x65, 0xa4, 0x30,
-	0xe0, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xf8, 0x5d,
-	0x01, 0x6a, 0xd0, 0x01,
-	0x01, 0x6a, 0xdc, 0x05,
-	0x88, 0x6a, 0xcc, 0x00,
-	0x48, 0x6a, 0xf8, 0x5d,
-	0x01, 0x6a, 0xd2, 0x5d,
-	0x01, 0x6a, 0x26, 0x05,
-	0x01, 0x65, 0xd8, 0x31,
-	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0xbe, 0x7d,
-	0xff, 0x6a, 0xdc, 0x0d,
-	0x01, 0x65, 0x32, 0x31,
-	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9a, 0x46,
-	0x81, 0x6a, 0xca, 0x5e,
-	0x01, 0x0c, 0xca, 0x7d,
-	0x04, 0x0c, 0xc8, 0x6d,
-	0xe0, 0x03, 0x06, 0x08,
-	0xe0, 0x03, 0x7e, 0x0c,
-	0x01, 0x65, 0x18, 0x31,
-	0xff, 0x6a, 0x1a, 0x09,
-	0xff, 0x6a, 0x1c, 0x0d,
-	0x01, 0x8c, 0x10, 0x30,
-	0x01, 0x8d, 0x12, 0x30,
-	0x01, 0x8e, 0x14, 0x34,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x30,
-	0x01, 0x6c, 0xda, 0x34,
-	0x3d, 0x64, 0xa4, 0x28,
-	0x55, 0x64, 0xc8, 0x28,
-	0x00, 0x65, 0xf8, 0x45,
-	0x2e, 0x64, 0xa4, 0x28,
-	0x66, 0x64, 0xc8, 0x28,
-	0x00, 0x6c, 0xda, 0x18,
-	0x01, 0x52, 0xc8, 0x30,
-	0x00, 0x6c, 0xda, 0x20,
-	0xff, 0x6a, 0xc8, 0x08,
-	0x00, 0x6c, 0xda, 0x20,
-	0x00, 0x6c, 0xda, 0x24,
-	0x01, 0x65, 0xc8, 0x30,
-	0xe0, 0x6a, 0xcc, 0x00,
-	0x44, 0x6a, 0xf4, 0x5d,
-	0x01, 0x90, 0xe2, 0x31,
-	0x04, 0x3b, 0x18, 0x7e,
-	0x30, 0x6a, 0xd0, 0x01,
-	0x20, 0x6a, 0xd0, 0x01,
-	0x1d, 0x6a, 0xdc, 0x01,
-	0xdc, 0xee, 0x14, 0x66,
-	0x00, 0x65, 0x30, 0x46,
-	0x20, 0x6a, 0xd0, 0x01,
-	0x01, 0x6a, 0xdc, 0x01,
-	0x20, 0xa0, 0xd8, 0x31,
-	0x09, 0xee, 0xdc, 0x01,
-	0x80, 0xee, 0x20, 0x7e,
-	0x11, 0x6a, 0xdc, 0x01,
-	0x50, 0xee, 0x24, 0x66,
-	0x20, 0x6a, 0xd0, 0x01,
-	0x09, 0x6a, 0xdc, 0x01,
-	0x88, 0xee, 0x2a, 0x66,
-	0x19, 0x6a, 0xdc, 0x01,
-	0xd8, 0xee, 0x2e, 0x66,
-	0xff, 0x6a, 0xdc, 0x09,
-	0x18, 0xee, 0x32, 0x6e,
-	0xff, 0x6a, 0xd4, 0x0c,
-	0x88, 0x6a, 0xcc, 0x00,
-	0x44, 0x6a, 0xf4, 0x5d,
-	0x20, 0x6a, 0xd2, 0x5d,
-	0x01, 0x3b, 0x26, 0x31,
-	0x04, 0x3b, 0x4c, 0x6e,
-	0xa0, 0x6a, 0xca, 0x00,
-	0x20, 0x65, 0xc8, 0x18,
-	0x00, 0x65, 0x8a, 0x5e,
-	0x00, 0x65, 0x44, 0x66,
-	0x0a, 0x93, 0x26, 0x01,
-	0x00, 0x65, 0x9a, 0x46,
-	0xa0, 0x6a, 0xcc, 0x00,
-	0xff, 0x6a, 0xc8, 0x08,
-	0x20, 0x94, 0x50, 0x6e,
-	0x10, 0x94, 0x52, 0x6e,
-	0x08, 0x94, 0x6c, 0x6e,
-	0x08, 0x94, 0x6c, 0x6e,
-	0x08, 0x94, 0x6c, 0x6e,
-	0xff, 0x8c, 0xc8, 0x10,
-	0xc1, 0x64, 0xc8, 0x18,
-	0xf8, 0x64, 0xc8, 0x08,
-	0x01, 0x99, 0xda, 0x30,
-	0x00, 0x66, 0x60, 0x66,
-	0xc0, 0x66, 0x9c, 0x76,
-	0x60, 0x66, 0xc8, 0x18,
-	0x3d, 0x64, 0xc8, 0x28,
-	0x00, 0x65, 0x50, 0x46,
-	0xf7, 0x93, 0x26, 0x09,
-	0x08, 0x93, 0x6e, 0x6e,
-	0x00, 0x62, 0xc4, 0x18,
-	0x00, 0x65, 0x9a, 0x5e,
-	0x00, 0x65, 0x7a, 0x5e,
-	0x00, 0x65, 0x7a, 0x5e,
-	0x00, 0x65, 0x7a, 0x5e,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x30,
-	0x01, 0x99, 0xda, 0x34,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x31,
-	0x01, 0x6c, 0x32, 0x35,
-	0x08, 0x94, 0x9a, 0x7e,
-	0xf7, 0x93, 0x26, 0x09,
-	0x08, 0x93, 0x9e, 0x6e,
-	0xff, 0x6a, 0xd4, 0x0c,
-	0x04, 0xb8, 0xc6, 0x6e,
-	0x01, 0x42, 0x7e, 0x31,
-	0xff, 0x6a, 0x76, 0x01,
-	0x01, 0x90, 0x84, 0x34,
-	0xff, 0x6a, 0x76, 0x05,
-	0x01, 0x85, 0x0a, 0x01,
-	0x7f, 0x65, 0x10, 0x09,
-	0xfe, 0x85, 0x0a, 0x0d,
-	0xff, 0x42, 0xc2, 0x66,
-	0xff, 0x41, 0xba, 0x66,
-	0xd1, 0x6a, 0xca, 0x5e,
-	0xff, 0x6a, 0xca, 0x04,
-	0x01, 0x41, 0x20, 0x31,
-	0x01, 0xbf, 0x82, 0x30,
-	0x01, 0x6a, 0x76, 0x00,
-	0x00, 0xbb, 0x04, 0x46,
-	0x01, 0x42, 0x20, 0x31,
-	0x01, 0xbf, 0x84, 0x34,
-	0x01, 0x41, 0x7e, 0x31,
-	0x01, 0x90, 0x82, 0x34,
-	0x01, 0x65, 0x22, 0x31,
-	0xff, 0x6a, 0xd4, 0x08,
-	0xff, 0x6a, 0xd4, 0x0c
-};
-
-static int ahc_patch23_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch23_func(struct ahc_softc *ahc)
-{
-	return ((ahc->bugs & AHC_SCBCHAN_UPLOAD_BUG) != 0);
-}
-
-static int ahc_patch22_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch22_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_CMD_CHAN) == 0);
-}
-
-static int ahc_patch21_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch21_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_QUEUE_REGS) == 0);
-}
-
-static int ahc_patch20_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch20_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_WIDE) != 0);
-}
-
-static int ahc_patch19_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch19_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_SCB_BTT) != 0);
-}
-
-static int ahc_patch18_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch18_func(struct ahc_softc *ahc)
-{
-	return ((ahc->bugs & AHC_PCI_2_1_RETRY_BUG) != 0);
-}
-
-static int ahc_patch17_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch17_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0);
-}
-
-static int ahc_patch16_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch16_func(struct ahc_softc *ahc)
-{
-	return ((ahc->bugs & AHC_AUTOFLUSH_BUG) != 0);
-}
-
-static int ahc_patch15_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch15_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_ULTRA2) == 0);
-}
-
-static int ahc_patch14_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch14_func(struct ahc_softc *ahc)
-{
-	return ((ahc->bugs & AHC_PCI_MWI_BUG) != 0 && ahc->pci_cachesize != 0);
-}
-
-static int ahc_patch13_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch13_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_39BIT_ADDRESSING) != 0);
-}
-
-static int ahc_patch12_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch12_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_HS_MAILBOX) != 0);
-}
-
-static int ahc_patch11_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch11_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_ULTRA) != 0);
-}
-
-static int ahc_patch10_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch10_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_MULTI_TID) != 0);
-}
-
-static int ahc_patch9_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch9_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_CMD_CHAN) != 0);
-}
-
-static int ahc_patch8_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch8_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_INITIATORROLE) != 0);
-}
-
-static int ahc_patch7_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch7_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_TARGETROLE) != 0);
-}
-
-static int ahc_patch6_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch6_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_DT) == 0);
-}
-
-static int ahc_patch5_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch5_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0);
-}
-
-static int ahc_patch4_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch4_func(struct ahc_softc *ahc)
-{
-	return ((ahc->flags & AHC_PAGESCBS) != 0);
-}
-
-static int ahc_patch3_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch3_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_QUEUE_REGS) != 0);
-}
-
-static int ahc_patch2_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch2_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_TWIN) != 0);
-}
-
-static int ahc_patch1_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch1_func(struct ahc_softc *ahc)
-{
-	return ((ahc->features & AHC_ULTRA2) != 0);
-}
-
-static int ahc_patch0_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch0_func(struct ahc_softc *ahc)
-{
-	return (0);
-}
-
-typedef int patch_func_t (struct ahc_softc *);
-struct patch {
-	patch_func_t	*patch_func;
-	uint32_t	begin	   :10,
-			skip_instr :10,
-			skip_patch :12;
-} patches[] = {
-	{ ahc_patch1_func, 4, 1, 1 },
-	{ ahc_patch2_func, 6, 2, 1 },
-	{ ahc_patch2_func, 9, 1, 1 },
-	{ ahc_patch3_func, 11, 1, 2 },
-	{ ahc_patch0_func, 12, 2, 1 },
-	{ ahc_patch4_func, 15, 1, 2 },
-	{ ahc_patch0_func, 16, 1, 1 },
-	{ ahc_patch5_func, 22, 2, 1 },
-	{ ahc_patch3_func, 27, 1, 2 },
-	{ ahc_patch0_func, 28, 1, 1 },
-	{ ahc_patch6_func, 34, 1, 1 },
-	{ ahc_patch7_func, 37, 54, 19 },
-	{ ahc_patch8_func, 37, 1, 1 },
-	{ ahc_patch9_func, 42, 3, 2 },
-	{ ahc_patch0_func, 45, 3, 1 },
-	{ ahc_patch10_func, 49, 1, 2 },
-	{ ahc_patch0_func, 50, 2, 3 },
-	{ ahc_patch1_func, 50, 1, 2 },
-	{ ahc_patch0_func, 51, 1, 1 },
-	{ ahc_patch2_func, 53, 2, 1 },
-	{ ahc_patch9_func, 55, 1, 2 },
-	{ ahc_patch0_func, 56, 1, 1 },
-	{ ahc_patch9_func, 60, 1, 2 },
-	{ ahc_patch0_func, 61, 1, 1 },
-	{ ahc_patch9_func, 71, 1, 2 },
-	{ ahc_patch0_func, 72, 1, 1 },
-	{ ahc_patch9_func, 75, 1, 2 },
-	{ ahc_patch0_func, 76, 1, 1 },
-	{ ahc_patch9_func, 79, 1, 2 },
-	{ ahc_patch0_func, 80, 1, 1 },
-	{ ahc_patch8_func, 91, 9, 4 },
-	{ ahc_patch1_func, 93, 1, 2 },
-	{ ahc_patch0_func, 94, 1, 1 },
-	{ ahc_patch2_func, 96, 2, 1 },
-	{ ahc_patch2_func, 105, 4, 1 },
-	{ ahc_patch1_func, 109, 1, 2 },
-	{ ahc_patch0_func, 110, 2, 3 },
-	{ ahc_patch2_func, 110, 1, 2 },
-	{ ahc_patch0_func, 111, 1, 1 },
-	{ ahc_patch7_func, 112, 4, 2 },
-	{ ahc_patch0_func, 116, 1, 1 },
-	{ ahc_patch11_func, 118, 2, 1 },
-	{ ahc_patch1_func, 120, 1, 2 },
-	{ ahc_patch0_func, 121, 1, 1 },
-	{ ahc_patch7_func, 122, 4, 1 },
-	{ ahc_patch7_func, 133, 89, 11 },
-	{ ahc_patch4_func, 151, 1, 1 },
-	{ ahc_patch1_func, 164, 1, 1 },
-	{ ahc_patch12_func, 169, 1, 2 },
-	{ ahc_patch0_func, 170, 1, 1 },
-	{ ahc_patch9_func, 181, 1, 2 },
-	{ ahc_patch0_func, 182, 1, 1 },
-	{ ahc_patch9_func, 191, 1, 2 },
-	{ ahc_patch0_func, 192, 1, 1 },
-	{ ahc_patch9_func, 208, 6, 2 },
-	{ ahc_patch0_func, 214, 6, 1 },
-	{ ahc_patch8_func, 222, 18, 2 },
-	{ ahc_patch1_func, 235, 1, 1 },
-	{ ahc_patch1_func, 242, 1, 2 },
-	{ ahc_patch0_func, 243, 2, 2 },
-	{ ahc_patch11_func, 244, 1, 1 },
-	{ ahc_patch9_func, 252, 31, 3 },
-	{ ahc_patch1_func, 268, 14, 2 },
-	{ ahc_patch13_func, 273, 1, 1 },
-	{ ahc_patch14_func, 283, 14, 1 },
-	{ ahc_patch1_func, 299, 1, 2 },
-	{ ahc_patch0_func, 300, 1, 1 },
-	{ ahc_patch9_func, 303, 1, 1 },
-	{ ahc_patch13_func, 308, 1, 1 },
-	{ ahc_patch9_func, 309, 2, 2 },
-	{ ahc_patch0_func, 311, 4, 1 },
-	{ ahc_patch14_func, 315, 1, 1 },
-	{ ahc_patch15_func, 318, 2, 3 },
-	{ ahc_patch9_func, 318, 1, 2 },
-	{ ahc_patch0_func, 319, 1, 1 },
-	{ ahc_patch6_func, 324, 1, 2 },
-	{ ahc_patch0_func, 325, 1, 1 },
-	{ ahc_patch1_func, 329, 50, 11 },
-	{ ahc_patch6_func, 338, 2, 4 },
-	{ ahc_patch7_func, 338, 1, 1 },
-	{ ahc_patch8_func, 339, 1, 1 },
-	{ ahc_patch0_func, 340, 1, 1 },
-	{ ahc_patch16_func, 341, 1, 1 },
-	{ ahc_patch6_func, 360, 6, 3 },
-	{ ahc_patch16_func, 360, 5, 1 },
-	{ ahc_patch0_func, 366, 5, 1 },
-	{ ahc_patch13_func, 374, 5, 1 },
-	{ ahc_patch0_func, 379, 54, 17 },
-	{ ahc_patch14_func, 379, 1, 1 },
-	{ ahc_patch7_func, 381, 2, 2 },
-	{ ahc_patch17_func, 382, 1, 1 },
-	{ ahc_patch9_func, 385, 1, 1 },
-	{ ahc_patch18_func, 392, 1, 1 },
-	{ ahc_patch14_func, 397, 9, 3 },
-	{ ahc_patch9_func, 398, 3, 2 },
-	{ ahc_patch0_func, 401, 3, 1 },
-	{ ahc_patch9_func, 409, 6, 2 },
-	{ ahc_patch0_func, 415, 9, 2 },
-	{ ahc_patch13_func, 415, 1, 1 },
-	{ ahc_patch13_func, 424, 2, 1 },
-	{ ahc_patch14_func, 426, 1, 1 },
-	{ ahc_patch9_func, 428, 1, 2 },
-	{ ahc_patch0_func, 429, 1, 1 },
-	{ ahc_patch7_func, 432, 1, 1 },
-	{ ahc_patch7_func, 433, 1, 1 },
-	{ ahc_patch8_func, 434, 3, 3 },
-	{ ahc_patch6_func, 435, 1, 2 },
-	{ ahc_patch0_func, 436, 1, 1 },
-	{ ahc_patch9_func, 437, 1, 1 },
-	{ ahc_patch15_func, 438, 1, 2 },
-	{ ahc_patch13_func, 438, 1, 1 },
-	{ ahc_patch14_func, 440, 9, 4 },
-	{ ahc_patch9_func, 440, 1, 1 },
-	{ ahc_patch9_func, 447, 2, 1 },
-	{ ahc_patch0_func, 449, 4, 3 },
-	{ ahc_patch9_func, 449, 1, 2 },
-	{ ahc_patch0_func, 450, 3, 1 },
-	{ ahc_patch1_func, 454, 2, 1 },
-	{ ahc_patch7_func, 456, 10, 2 },
-	{ ahc_patch0_func, 466, 1, 1 },
-	{ ahc_patch8_func, 467, 109, 23 },
-	{ ahc_patch1_func, 469, 3, 2 },
-	{ ahc_patch0_func, 472, 5, 3 },
-	{ ahc_patch9_func, 472, 2, 2 },
-	{ ahc_patch0_func, 474, 3, 1 },
-	{ ahc_patch1_func, 479, 2, 2 },
-	{ ahc_patch0_func, 481, 6, 3 },
-	{ ahc_patch9_func, 481, 2, 2 },
-	{ ahc_patch0_func, 483, 3, 1 },
-	{ ahc_patch1_func, 489, 2, 2 },
-	{ ahc_patch0_func, 491, 9, 7 },
-	{ ahc_patch9_func, 491, 5, 6 },
-	{ ahc_patch19_func, 491, 1, 2 },
-	{ ahc_patch0_func, 492, 1, 1 },
-	{ ahc_patch19_func, 494, 1, 2 },
-	{ ahc_patch0_func, 495, 1, 1 },
-	{ ahc_patch0_func, 496, 4, 1 },
-	{ ahc_patch6_func, 500, 3, 2 },
-	{ ahc_patch0_func, 503, 1, 1 },
-	{ ahc_patch1_func, 506, 1, 1 },
-	{ ahc_patch6_func, 512, 1, 2 },
-	{ ahc_patch0_func, 513, 1, 1 },
-	{ ahc_patch20_func, 550, 7, 1 },
-	{ ahc_patch3_func, 578, 1, 2 },
-	{ ahc_patch0_func, 579, 1, 1 },
-	{ ahc_patch21_func, 582, 1, 1 },
-	{ ahc_patch8_func, 584, 104, 33 },
-	{ ahc_patch4_func, 585, 1, 1 },
-	{ ahc_patch1_func, 591, 2, 2 },
-	{ ahc_patch0_func, 593, 1, 1 },
-	{ ahc_patch1_func, 596, 1, 2 },
-	{ ahc_patch0_func, 597, 1, 1 },
-	{ ahc_patch9_func, 598, 3, 3 },
-	{ ahc_patch15_func, 599, 1, 1 },
-	{ ahc_patch0_func, 601, 4, 1 },
-	{ ahc_patch19_func, 609, 2, 2 },
-	{ ahc_patch0_func, 611, 1, 1 },
-	{ ahc_patch19_func, 615, 10, 3 },
-	{ ahc_patch5_func, 617, 8, 1 },
-	{ ahc_patch0_func, 625, 9, 2 },
-	{ ahc_patch5_func, 626, 8, 1 },
-	{ ahc_patch4_func, 636, 1, 2 },
-	{ ahc_patch0_func, 637, 1, 1 },
-	{ ahc_patch19_func, 638, 1, 2 },
-	{ ahc_patch0_func, 639, 3, 2 },
-	{ ahc_patch4_func, 641, 1, 1 },
-	{ ahc_patch5_func, 642, 1, 1 },
-	{ ahc_patch5_func, 645, 1, 1 },
-	{ ahc_patch5_func, 647, 1, 1 },
-	{ ahc_patch4_func, 649, 2, 2 },
-	{ ahc_patch0_func, 651, 2, 1 },
-	{ ahc_patch5_func, 653, 1, 1 },
-	{ ahc_patch5_func, 656, 1, 1 },
-	{ ahc_patch5_func, 659, 1, 1 },
-	{ ahc_patch19_func, 663, 1, 1 },
-	{ ahc_patch19_func, 666, 1, 1 },
-	{ ahc_patch4_func, 672, 1, 1 },
-	{ ahc_patch6_func, 675, 1, 2 },
-	{ ahc_patch0_func, 676, 1, 1 },
-	{ ahc_patch7_func, 688, 16, 1 },
-	{ ahc_patch4_func, 704, 20, 1 },
-	{ ahc_patch9_func, 725, 4, 2 },
-	{ ahc_patch0_func, 729, 4, 1 },
-	{ ahc_patch9_func, 733, 4, 2 },
-	{ ahc_patch0_func, 737, 3, 1 },
-	{ ahc_patch6_func, 743, 1, 1 },
-	{ ahc_patch22_func, 745, 14, 1 },
-	{ ahc_patch7_func, 759, 3, 1 },
-	{ ahc_patch9_func, 771, 24, 8 },
-	{ ahc_patch19_func, 775, 1, 2 },
-	{ ahc_patch0_func, 776, 1, 1 },
-	{ ahc_patch15_func, 781, 4, 2 },
-	{ ahc_patch0_func, 785, 7, 3 },
-	{ ahc_patch23_func, 785, 5, 2 },
-	{ ahc_patch0_func, 790, 2, 1 },
-	{ ahc_patch0_func, 795, 42, 3 },
-	{ ahc_patch18_func, 807, 18, 2 },
-	{ ahc_patch0_func, 825, 1, 1 },
-	{ ahc_patch4_func, 849, 1, 1 },
-	{ ahc_patch4_func, 850, 3, 2 },
-	{ ahc_patch0_func, 853, 1, 1 },
-	{ ahc_patch13_func, 854, 3, 1 },
-	{ ahc_patch4_func, 857, 12, 1 }
-};
-struct cs {
-	u_int16_t	begin;
-	u_int16_t	end;
-} critical_sections[] = {
-	{ 11, 18 },
-	{ 21, 30 },
-	{ 704, 720 },
-	{ 850, 853 },
-	{ 857, 863 },
-	{ 865, 867 },
-	{ 867, 869 }
-};
-const int num_critical_sections = sizeof(critical_sections)
-				 / sizeof(*critical_sections);
diff -Nru a/drivers/scsi/aic7xxx/shipped_aic7xxx_reg.h b/drivers/scsi/aic7xxx/shipped_aic7xxx_reg.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/aic7xxx/shipped_aic7xxx_reg.h	Fri May 24 18:55:33 2002
@@ -0,0 +1,716 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#37 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#24 $
+ */
+
+#define	SCSISEQ         		0x00
+#define		TEMODE          	0x80
+#define		SCSIRSTO        	0x01
+
+#define	SXFRCTL0        		0x01
+#define		DFON            	0x80
+#define		DFPEXP          	0x40
+#define		FAST20          	0x20
+#define		CLRSTCNT        	0x10
+#define		SPIOEN          	0x08
+#define		SCAMEN          	0x04
+#define		CLRCHN          	0x02
+
+#define	SXFRCTL1        		0x02
+#define		BITBUCKET       	0x80
+#define		SWRAPEN         	0x40
+#define		STIMESEL        	0x18
+#define		ENSTIMER        	0x04
+#define		ACTNEGEN        	0x02
+#define		STPWEN          	0x01
+
+#define	SCSISIGO        		0x03
+#define		CDO             	0x80
+#define		IOO             	0x40
+#define		MSGO            	0x20
+#define		ATNO            	0x10
+#define		SELO            	0x08
+#define		BSYO            	0x04
+#define		REQO            	0x02
+#define		ACKO            	0x01
+
+#define	SCSISIGI        		0x03
+#define		P_DATAIN_DT     	0x60
+#define		P_DATAOUT_DT    	0x20
+#define		ATNI            	0x10
+#define		SELI            	0x08
+#define		BSYI            	0x04
+#define		REQI            	0x02
+#define		ACKI            	0x01
+
+#define	SCSIRATE        		0x04
+#define		WIDEXFER        	0x80
+#define		SXFR            	0x70
+#define		ENABLE_CRC      	0x40
+#define		SINGLE_EDGE     	0x10
+#define		SOFS            	0x0f
+#define		SXFR_ULTRA2     	0x0f
+
+#define	SCSIID          		0x05
+#define	SCSIOFFSET      		0x05
+#define		SOFS_ULTRA2     	0x7f
+
+#define	SCSIDATL        		0x06
+
+#define	SCSIDATH        		0x07
+
+#define	STCNT           		0x08
+
+#define	OPTIONMODE      		0x08
+#define		AUTORATEEN      	0x80
+#define		AUTOACKEN       	0x40
+#define		ATNMGMNTEN      	0x20
+#define		BUSFREEREV      	0x10
+#define		EXPPHASEDIS     	0x08
+#define		SCSIDATL_IMGEN  	0x04
+#define		OPTIONMODE_DEFAULTS	0x03
+#define		AUTO_MSGOUT_DE  	0x02
+#define		DIS_MSGIN_DUALEDGE	0x01
+
+#define	TARGCRCCNT      		0x0a
+
+#define	CLRSINT0        		0x0b
+#define		CLRSELDO        	0x40
+#define		CLRSELDI        	0x20
+#define		CLRSELINGO      	0x10
+#define		CLRIOERR        	0x08
+#define		CLRSWRAP        	0x08
+#define		CLRSPIORDY      	0x02
+
+#define	SSTAT0          		0x0b
+#define		TARGET          	0x80
+#define		SELDO           	0x40
+#define		SELDI           	0x20
+#define		SELINGO         	0x10
+#define		SWRAP           	0x08
+#define		IOERR           	0x08
+#define		SDONE           	0x04
+#define		SPIORDY         	0x02
+#define		DMADONE         	0x01
+
+#define	CLRSINT1        		0x0c
+#define		CLRSELTIMEO     	0x80
+#define		CLRATNO         	0x40
+#define		CLRSCSIRSTI     	0x20
+#define		CLRBUSFREE      	0x08
+#define		CLRSCSIPERR     	0x04
+#define		CLRPHASECHG     	0x02
+#define		CLRREQINIT      	0x01
+
+#define	SSTAT1          		0x0c
+#define		SELTO           	0x80
+#define		ATNTARG         	0x40
+#define		SCSIRSTI        	0x20
+#define		PHASEMIS        	0x10
+#define		BUSFREE         	0x08
+#define		SCSIPERR        	0x04
+#define		PHASECHG        	0x02
+#define		REQINIT         	0x01
+
+#define	SSTAT2          		0x0d
+#define		OVERRUN         	0x80
+#define		SHVALID         	0x40
+#define		SFCNT           	0x1f
+#define		EXP_ACTIVE      	0x10
+#define		CRCVALERR       	0x08
+#define		CRCENDERR       	0x04
+#define		CRCREQERR       	0x02
+#define		DUAL_EDGE_ERR   	0x01
+
+#define	SSTAT3          		0x0e
+#define		SCSICNT         	0xf0
+#define		U2OFFCNT        	0x7f
+#define		OFFCNT          	0x0f
+
+#define	SCSIID_ULTRA2   		0x0f
+
+#define	SIMODE0         		0x10
+#define		ENSELDO         	0x40
+#define		ENSELDI         	0x20
+#define		ENSELINGO       	0x10
+#define		ENIOERR         	0x08
+#define		ENSWRAP         	0x08
+#define		ENSDONE         	0x04
+#define		ENSPIORDY       	0x02
+#define		ENDMADONE       	0x01
+
+#define	SIMODE1         		0x11
+#define		ENSELTIMO       	0x80
+#define		ENATNTARG       	0x40
+#define		ENSCSIRST       	0x20
+#define		ENPHASEMIS      	0x10
+#define		ENBUSFREE       	0x08
+#define		ENSCSIPERR      	0x04
+#define		ENPHASECHG      	0x02
+#define		ENREQINIT       	0x01
+
+#define	SCSIBUSL        		0x12
+
+#define	SCSIBUSH        		0x13
+
+#define	SHADDR          		0x14
+
+#define	SELTIMER        		0x18
+#define	TARGIDIN        		0x18
+#define		STAGE6          	0x20
+#define		STAGE5          	0x10
+#define		STAGE4          	0x08
+#define		STAGE3          	0x04
+#define		STAGE2          	0x02
+#define		STAGE1          	0x01
+
+#define	SELID           		0x19
+#define		SELID_MASK      	0xf0
+#define		ONEBIT          	0x08
+
+#define	SCAMCTL         		0x1a
+#define		ENSCAMSELO      	0x80
+#define		CLRSCAMSELID    	0x40
+#define		ALTSTIM         	0x20
+#define		DFLTTID         	0x10
+#define		SCAMLVL         	0x03
+
+#define	TARGID          		0x1b
+
+#define	SPIOCAP         		0x1b
+#define		SOFT1           	0x80
+#define		SOFT0           	0x40
+#define		SOFTCMDEN       	0x20
+#define		HAS_BRDCTL      	0x10
+#define		SEEPROM         	0x08
+#define		EEPROM          	0x04
+#define		ROM             	0x02
+#define		SSPIOCPS        	0x01
+
+#define	BRDCTL          		0x1d
+#define		BRDDAT7         	0x80
+#define		BRDDAT6         	0x40
+#define		BRDDAT5         	0x20
+#define		BRDDAT4         	0x10
+#define		BRDSTB          	0x10
+#define		BRDDAT3         	0x08
+#define		BRDCS           	0x08
+#define		BRDDAT2         	0x04
+#define		BRDRW           	0x04
+#define		BRDRW_ULTRA2    	0x02
+#define		BRDCTL1         	0x02
+#define		BRDCTL0         	0x01
+#define		BRDSTB_ULTRA2   	0x01
+
+#define	SEECTL          		0x1e
+#define		EXTARBACK       	0x80
+#define		EXTARBREQ       	0x40
+#define		SEEMS           	0x20
+#define		SEERDY          	0x10
+#define		SEECS           	0x08
+#define		SEECK           	0x04
+#define		SEEDO           	0x02
+#define		SEEDI           	0x01
+
+#define	SBLKCTL         		0x1f
+#define		DIAGLEDEN       	0x80
+#define		DIAGLEDON       	0x40
+#define		AUTOFLUSHDIS    	0x20
+#define		ENAB40          	0x08
+#define		SELBUSB         	0x08
+#define		ENAB20          	0x04
+#define		SELWIDE         	0x02
+#define		XCVR            	0x01
+
+#define	BUSY_TARGETS    		0x20
+#define	TARG_SCSIRATE   		0x20
+
+#define	SRAM_BASE       		0x20
+
+#define	ULTRA_ENB       		0x30
+#define	CMDSIZE_TABLE   		0x30
+
+#define	DISC_DSB        		0x32
+
+#define	CMDSIZE_TABLE_TAIL		0x34
+
+#define	MWI_RESIDUAL    		0x38
+
+#define	NEXT_QUEUED_SCB 		0x39
+
+#define	MSG_OUT         		0x3a
+
+#define	DMAPARAMS       		0x3b
+#define		PRELOADEN       	0x80
+#define		WIDEODD         	0x40
+#define		SCSIEN          	0x20
+#define		SDMAEN          	0x10
+#define		SDMAENACK       	0x10
+#define		HDMAEN          	0x08
+#define		HDMAENACK       	0x08
+#define		DIRECTION       	0x04
+#define		FIFOFLUSH       	0x02
+#define		FIFORESET       	0x01
+
+#define	SEQ_FLAGS       		0x3c
+#define		IDENTIFY_SEEN   	0x80
+#define		TARGET_CMD_IS_TAGGED	0x40
+#define		DPHASE          	0x20
+#define		TARG_CMD_PENDING	0x10
+#define		CMDPHASE_PENDING	0x08
+#define		DPHASE_PENDING  	0x04
+#define		SPHASE_PENDING  	0x02
+#define		NO_DISCONNECT   	0x01
+
+#define	SAVED_SCSIID    		0x3d
+
+#define	SAVED_LUN       		0x3e
+
+#define	LASTPHASE       		0x3f
+#define		P_MESGIN        	0xe0
+#define		PHASE_MASK      	0xe0
+#define		P_STATUS        	0xc0
+#define		P_MESGOUT       	0xa0
+#define		P_COMMAND       	0x80
+#define		CDI             	0x80
+#define		P_DATAIN        	0x40
+#define		IOI             	0x40
+#define		MSGI            	0x20
+#define		P_BUSFREE       	0x01
+#define		P_DATAOUT       	0x00
+
+#define	WAITING_SCBH    		0x40
+
+#define	DISCONNECTED_SCBH		0x41
+
+#define	FREE_SCBH       		0x42
+
+#define	COMPLETE_SCBH   		0x43
+
+#define	HSCB_ADDR       		0x44
+
+#define	SHARED_DATA_ADDR		0x48
+
+#define	KERNEL_QINPOS   		0x4c
+
+#define	QINPOS          		0x4d
+
+#define	QOUTPOS         		0x4e
+
+#define	KERNEL_TQINPOS  		0x4f
+
+#define	TQINPOS         		0x50
+
+#define	ARG_1           		0x51
+#define	RETURN_1        		0x51
+#define		SEND_MSG        	0x80
+#define		SEND_SENSE      	0x40
+#define		SEND_REJ        	0x20
+#define		MSGOUT_PHASEMIS 	0x10
+#define		EXIT_MSG_LOOP   	0x08
+#define		CONT_MSG_LOOP   	0x04
+#define		CONT_TARG_SESSION	0x02
+
+#define	ARG_2           		0x52
+#define	RETURN_2        		0x52
+
+#define	LAST_MSG        		0x53
+
+#define	SCSISEQ_TEMPLATE		0x54
+#define		ENSELO          	0x40
+#define		ENSELI          	0x20
+#define		ENRSELI         	0x10
+#define		ENAUTOATNO      	0x08
+#define		ENAUTOATNI      	0x04
+#define		ENAUTOATNP      	0x02
+
+#define	DATA_COUNT_ODD  		0x55
+
+#define	INITIATOR_TAG   		0x56
+
+#define	SEQ_FLAGS2      		0x57
+#define		TARGET_MSG_PENDING	0x02
+#define		SCB_DMA         	0x01
+
+#define	SCSICONF        		0x5a
+#define		TERM_ENB        	0x80
+#define		RESET_SCSI      	0x40
+#define		ENSPCHK         	0x20
+#define		HWSCSIID        	0x0f
+#define		HSCSIID         	0x07
+
+#define	INTDEF          		0x5c
+#define		EDGE_TRIG       	0x80
+#define		VECTOR          	0x0f
+
+#define	HOSTCONF        		0x5d
+
+#define	HA_274_BIOSCTRL 		0x5f
+#define		BIOSDISABLED    	0x30
+#define		BIOSMODE        	0x30
+#define		CHANNEL_B_PRIMARY	0x08
+
+#define	SEQCTL          		0x60
+#define		PERRORDIS       	0x80
+#define		PAUSEDIS        	0x40
+#define		FAILDIS         	0x20
+#define		FASTMODE        	0x10
+#define		BRKADRINTEN     	0x08
+#define		STEP            	0x04
+#define		SEQRESET        	0x02
+#define		LOADRAM         	0x01
+
+#define	SEQRAM          		0x61
+
+#define	SEQADDR0        		0x62
+
+#define	SEQADDR1        		0x63
+#define		SEQADDR1_MASK   	0x01
+
+#define	ACCUM           		0x64
+
+#define	SINDEX          		0x65
+
+#define	DINDEX          		0x66
+
+#define	ALLONES         		0x69
+
+#define	ALLZEROS        		0x6a
+
+#define	NONE            		0x6a
+
+#define	FLAGS           		0x6b
+#define		ZERO            	0x02
+#define		CARRY           	0x01
+
+#define	SINDIR          		0x6c
+
+#define	DINDIR          		0x6d
+
+#define	FUNCTION1       		0x6e
+
+#define	STACK           		0x6f
+
+#define	TARG_OFFSET     		0x70
+
+#define	BCTL            		0x84
+#define		ACE             	0x08
+#define		ENABLE          	0x01
+
+#define	DSCOMMAND0      		0x84
+#define		CACHETHEN       	0x80
+#define		DPARCKEN        	0x40
+#define		MPARCKEN        	0x20
+#define		EXTREQLCK       	0x10
+#define		INTSCBRAMSEL    	0x08
+#define		RAMPS           	0x04
+#define		USCBSIZE32      	0x02
+#define		CIOPARCKEN      	0x01
+
+#define	BUSTIME         		0x85
+#define		BOFF            	0xf0
+#define		BON             	0x0f
+
+#define	DSCOMMAND1      		0x85
+#define		DSLATT          	0xfc
+#define		HADDLDSEL1      	0x02
+#define		HADDLDSEL0      	0x01
+
+#define	BUSSPD          		0x86
+#define		DFTHRSH         	0xc0
+#define		DFTHRSH_75      	0x80
+#define		STBOFF          	0x38
+#define		STBON           	0x07
+
+#define	HS_MAILBOX      		0x86
+#define		HOST_MAILBOX    	0xf0
+#define		HOST_TQINPOS    	0x80
+#define		SEQ_MAILBOX     	0x0f
+
+#define	DSPCISTATUS     		0x86
+#define		DFTHRSH_100     	0xc0
+
+#define	HCNTRL          		0x87
+#define		POWRDN          	0x40
+#define		SWINT           	0x10
+#define		IRQMS           	0x08
+#define		PAUSE           	0x04
+#define		INTEN           	0x02
+#define		CHIPRST         	0x01
+#define		CHIPRSTACK      	0x01
+
+#define	HADDR           		0x88
+
+#define	HCNT            		0x8c
+
+#define	SCBPTR          		0x90
+
+#define	INTSTAT         		0x91
+#define		SEQINT_MASK     	0xf1
+#define		OUT_OF_RANGE    	0xe1
+#define		NO_FREE_SCB     	0xd1
+#define		SCB_MISMATCH    	0xc1
+#define		MISSED_BUSFREE  	0xb1
+#define		MKMSG_FAILED    	0xa1
+#define		DATA_OVERRUN    	0x91
+#define		PERR_DETECTED   	0x81
+#define		BAD_STATUS      	0x71
+#define		HOST_MSG_LOOP   	0x61
+#define		PDATA_REINIT    	0x51
+#define		IGN_WIDE_RES    	0x41
+#define		NO_MATCH        	0x31
+#define		NO_IDENT        	0x21
+#define		SEND_REJECT     	0x11
+#define		INT_PEND        	0x0f
+#define		BRKADRINT       	0x08
+#define		SCSIINT         	0x04
+#define		CMDCMPLT        	0x02
+#define		BAD_PHASE       	0x01
+#define		SEQINT          	0x01
+
+#define	CLRINT          		0x92
+#define		CLRPARERR       	0x10
+#define		CLRBRKADRINT    	0x08
+#define		CLRSCSIINT      	0x04
+#define		CLRCMDINT       	0x02
+#define		CLRSEQINT       	0x01
+
+#define	ERROR           		0x92
+#define		CIOPARERR       	0x80
+#define		PCIERRSTAT      	0x40
+#define		MPARERR         	0x20
+#define		DPARERR         	0x10
+#define		SQPARERR        	0x08
+#define		ILLOPCODE       	0x04
+#define		ILLSADDR        	0x02
+#define		ILLHADDR        	0x01
+
+#define	DFCNTRL         		0x93
+
+#define	DFSTATUS        		0x94
+#define		PRELOAD_AVAIL   	0x80
+#define		DFCACHETH       	0x40
+#define		FIFOQWDEMP      	0x20
+#define		MREQPEND        	0x10
+#define		HDONE           	0x08
+#define		DFTHRESH        	0x04
+#define		FIFOFULL        	0x02
+#define		FIFOEMP         	0x01
+
+#define	DFWADDR         		0x95
+
+#define	DFRADDR         		0x97
+
+#define	DFDAT           		0x99
+
+#define	SCBCNT          		0x9a
+#define		SCBAUTO         	0x80
+#define		SCBCNT_MASK     	0x1f
+
+#define	QINFIFO         		0x9b
+
+#define	QINCNT          		0x9c
+
+#define	QOUTFIFO        		0x9d
+
+#define	CRCCONTROL1     		0x9d
+#define		CRCONSEEN       	0x80
+#define		CRCVALCHKEN     	0x40
+#define		CRCENDCHKEN     	0x20
+#define		CRCREQCHKEN     	0x10
+#define		TARGCRCENDEN    	0x08
+#define		TARGCRCCNTEN    	0x04
+
+#define	QOUTCNT         		0x9e
+
+#define	SCSIPHASE       		0x9e
+#define		STATUS_PHASE    	0x20
+#define		COMMAND_PHASE   	0x10
+#define		MSG_IN_PHASE    	0x08
+#define		MSG_OUT_PHASE   	0x04
+#define		DATA_PHASE_MASK 	0x03
+#define		DATA_IN_PHASE   	0x02
+#define		DATA_OUT_PHASE  	0x01
+
+#define	SFUNCT          		0x9f
+#define		ALT_MODE        	0x80
+
+#define	SCB_BASE        		0xa0
+
+#define	SCB_CDB_PTR     		0xa0
+#define	SCB_RESIDUAL_DATACNT		0xa0
+#define	SCB_CDB_STORE   		0xa0
+
+#define	SCB_RESIDUAL_SGPTR		0xa4
+
+#define	SCB_SCSI_STATUS 		0xa8
+
+#define	SCB_TARGET_PHASES		0xa9
+
+#define	SCB_TARGET_DATA_DIR		0xaa
+
+#define	SCB_TARGET_ITAG 		0xab
+
+#define	SCB_DATAPTR     		0xac
+
+#define	SCB_DATACNT     		0xb0
+#define		SG_LAST_SEG     	0x80
+#define		SG_HIGH_ADDR_BITS	0x7f
+
+#define	SCB_SGPTR       		0xb4
+#define		SG_RESID_VALID  	0x04
+#define		SG_FULL_RESID   	0x02
+#define		SG_LIST_NULL    	0x01
+
+#define	SCB_CONTROL     		0xb8
+#define		TARGET_SCB      	0x80
+#define		DISCENB         	0x40
+#define		TAG_ENB         	0x20
+#define		MK_MESSAGE      	0x10
+#define		ULTRAENB        	0x08
+#define		DISCONNECTED    	0x04
+#define		SCB_TAG_TYPE    	0x03
+
+#define	SCB_SCSIID      		0xb9
+#define		TID             	0xf0
+#define		TWIN_CHNLB      	0x80
+#define		TWIN_TID        	0x70
+#define		OID             	0x0f
+
+#define	SCB_LUN         		0xba
+#define		LID             	0xff
+
+#define	SCB_TAG         		0xbb
+
+#define	SCB_CDB_LEN     		0xbc
+
+#define	SCB_SCSIRATE    		0xbd
+
+#define	SCB_SCSIOFFSET  		0xbe
+
+#define	SCB_NEXT        		0xbf
+
+#define	SCB_64_SPARE    		0xc0
+
+#define	SEECTL_2840     		0xc0
+#define		CS_2840         	0x04
+#define		CK_2840         	0x02
+#define		DO_2840         	0x01
+
+#define	STATUS_2840     		0xc1
+#define		EEPROM_TF       	0x80
+#define		BIOS_SEL        	0x60
+#define		ADSEL           	0x1e
+#define		DI_2840         	0x01
+
+#define	SCB_64_BTT      		0xd0
+
+#define	CCHADDR         		0xe0
+
+#define	CCHCNT          		0xe8
+
+#define	CCSGRAM         		0xe9
+
+#define	CCSGADDR        		0xea
+
+#define	CCSGCTL         		0xeb
+#define		CCSGDONE        	0x80
+#define		CCSGEN          	0x08
+#define		SG_FETCH_NEEDED 	0x02
+#define		CCSGRESET       	0x01
+
+#define	CCSCBRAM        		0xec
+
+#define	CCSCBADDR       		0xed
+
+#define	CCSCBCTL        		0xee
+#define		CCSCBDONE       	0x80
+#define		ARRDONE         	0x40
+#define		CCARREN         	0x10
+#define		CCSCBEN         	0x08
+#define		CCSCBDIR        	0x04
+#define		CCSCBRESET      	0x01
+
+#define	CCSCBCNT        		0xef
+
+#define	SCBBADDR        		0xf0
+
+#define	CCSCBPTR        		0xf1
+
+#define	HNSCB_QOFF      		0xf4
+
+#define	SNSCB_QOFF      		0xf6
+
+#define	SDSCB_QOFF      		0xf8
+
+#define	QOFF_CTLSTA     		0xfa
+#define		SCB_AVAIL       	0x40
+#define		SNSCB_ROLLOVER  	0x20
+#define		SDSCB_ROLLOVER  	0x10
+#define		SCB_QSIZE       	0x07
+#define		SCB_QSIZE_256   	0x06
+
+#define	DFF_THRSH       		0xfb
+#define		WR_DFTHRSH      	0x70
+#define		WR_DFTHRSH_MAX  	0x70
+#define		WR_DFTHRSH_90   	0x60
+#define		WR_DFTHRSH_85   	0x50
+#define		WR_DFTHRSH_75   	0x40
+#define		WR_DFTHRSH_63   	0x30
+#define		WR_DFTHRSH_50   	0x20
+#define		WR_DFTHRSH_25   	0x10
+#define		RD_DFTHRSH      	0x07
+#define		RD_DFTHRSH_MAX  	0x07
+#define		RD_DFTHRSH_90   	0x06
+#define		RD_DFTHRSH_85   	0x05
+#define		RD_DFTHRSH_75   	0x04
+#define		RD_DFTHRSH_63   	0x03
+#define		RD_DFTHRSH_50   	0x02
+#define		RD_DFTHRSH_25   	0x01
+#define		RD_DFTHRSH_MIN  	0x00
+#define		WR_DFTHRSH_MIN  	0x00
+
+#define	SG_CACHE_SHADOW 		0xfc
+#define		SG_ADDR_MASK    	0xf8
+#define		ODD_SEG         	0x04
+#define		LAST_SEG        	0x02
+#define		LAST_SEG_DONE   	0x01
+
+#define	SG_CACHE_PRE    		0xfc
+
+
+#define	MAX_OFFSET_ULTRA2	0x7f
+#define	MAX_OFFSET_16BIT	0x08
+#define	BUS_8_BIT	0x00
+#define	TARGET_CMD_CMPLT	0xfe
+#define	STATUS_QUEUE_FULL	0x28
+#define	STATUS_BUSY	0x08
+#define	MAX_OFFSET_8BIT	0x0f
+#define	BUS_32_BIT	0x02
+#define	CCSGADDR_MAX	0x80
+#define	TID_SHIFT	0x04
+#define	SCB_DOWNLOAD_SIZE_64	0x30
+#define	HOST_MAILBOX_SHIFT	0x04
+#define	CMD_GROUP_CODE_SHIFT	0x05
+#define	CCSGRAM_MAXSEGS	0x10
+#define	SCB_LIST_NULL	0xff
+#define	SG_SIZEOF	0x08
+#define	SCB_DOWNLOAD_SIZE	0x20
+#define	SEQ_MAILBOX_SHIFT	0x00
+#define	TARGET_DATA_IN	0x01
+#define	HOST_MSG	0xff
+#define	BUS_16_BIT	0x01
+#define	SCB_UPLOAD_SIZE	0x20
+
+
+/* Downloaded Constant Definitions */
+#define	INVERTED_CACHESIZE_MASK	0x03
+#define	SG_PREFETCH_ADDR_MASK	0x06
+#define	SG_PREFETCH_ALIGN_MASK	0x05
+#define	QOUTFIFO_OFFSET	0x00
+#define	SG_PREFETCH_CNT	0x04
+#define	CACHESIZE_MASK	0x02
+#define	QINFIFO_OFFSET	0x01
diff -Nru a/drivers/scsi/aic7xxx/shipped_aic7xxx_seq.h b/drivers/scsi/aic7xxx/shipped_aic7xxx_seq.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/aic7xxx/shipped_aic7xxx_seq.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,1299 @@
+/*
+ * DO NOT EDIT - This file is automatically generated
+ *		 from the following source files:
+ *
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.seq#37 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.reg#24 $
+ */
+static uint8_t seqprog[] = {
+	0xb2, 0x00, 0x00, 0x08,
+	0xf7, 0x11, 0x22, 0x08,
+	0x00, 0x65, 0xe0, 0x59,
+	0xf7, 0x01, 0x02, 0x08,
+	0xff, 0x6a, 0x24, 0x08,
+	0x40, 0x00, 0x40, 0x68,
+	0x08, 0x1f, 0x3e, 0x10,
+	0x40, 0x00, 0x40, 0x68,
+	0xff, 0x40, 0x3c, 0x60,
+	0x08, 0x1f, 0x3e, 0x10,
+	0x60, 0x0b, 0x42, 0x68,
+	0x40, 0xfa, 0x12, 0x78,
+	0x01, 0x4d, 0xc8, 0x30,
+	0x00, 0x4c, 0x12, 0x70,
+	0x01, 0x39, 0xa2, 0x30,
+	0x00, 0x6a, 0xb2, 0x5e,
+	0x01, 0x51, 0x20, 0x31,
+	0x01, 0x57, 0xae, 0x00,
+	0x0d, 0x6a, 0x76, 0x00,
+	0x00, 0x51, 0x04, 0x5e,
+	0x01, 0x51, 0xc8, 0x30,
+	0x00, 0x39, 0xc8, 0x60,
+	0x00, 0xbb, 0x30, 0x70,
+	0xc1, 0x6a, 0xca, 0x5e,
+	0x01, 0xbf, 0x72, 0x30,
+	0x01, 0x40, 0x7e, 0x31,
+	0x01, 0x90, 0x80, 0x30,
+	0x01, 0xf6, 0xd4, 0x30,
+	0x01, 0x4d, 0x9a, 0x18,
+	0xfe, 0x57, 0xae, 0x08,
+	0x01, 0x40, 0x20, 0x31,
+	0x00, 0x65, 0xcc, 0x58,
+	0x60, 0x0b, 0x40, 0x78,
+	0x08, 0x6a, 0x18, 0x00,
+	0x08, 0x11, 0x22, 0x00,
+	0x60, 0x0b, 0x00, 0x78,
+	0x40, 0x0b, 0xfc, 0x68,
+	0x80, 0x0b, 0xb6, 0x78,
+	0x20, 0x6a, 0x16, 0x00,
+	0xa4, 0x6a, 0x06, 0x00,
+	0x08, 0x3c, 0x78, 0x00,
+	0x01, 0x50, 0xc8, 0x30,
+	0xe0, 0x6a, 0xcc, 0x00,
+	0x48, 0x6a, 0xee, 0x5d,
+	0x01, 0x6a, 0xdc, 0x01,
+	0x88, 0x6a, 0xcc, 0x00,
+	0x48, 0x6a, 0xee, 0x5d,
+	0x01, 0x6a, 0x26, 0x01,
+	0xf0, 0x19, 0x7a, 0x08,
+	0x0f, 0x18, 0xc8, 0x08,
+	0x0f, 0x0f, 0xc8, 0x08,
+	0x0f, 0x05, 0xc8, 0x08,
+	0x00, 0x3d, 0x7a, 0x00,
+	0x08, 0x1f, 0x6e, 0x78,
+	0x80, 0x3d, 0x7a, 0x00,
+	0x01, 0x3d, 0xd8, 0x31,
+	0x01, 0x3d, 0x32, 0x31,
+	0x10, 0x03, 0x46, 0x79,
+	0x00, 0x65, 0xf4, 0x58,
+	0x80, 0x66, 0xae, 0x78,
+	0x01, 0x66, 0xd8, 0x31,
+	0x01, 0x66, 0x32, 0x31,
+	0x3f, 0x66, 0x7c, 0x08,
+	0x40, 0x66, 0x82, 0x68,
+	0x01, 0x3c, 0x78, 0x00,
+	0x10, 0x03, 0x9e, 0x78,
+	0x00, 0x65, 0xf4, 0x58,
+	0xe0, 0x66, 0xc8, 0x18,
+	0x00, 0x65, 0xaa, 0x50,
+	0xdd, 0x66, 0xc8, 0x18,
+	0x00, 0x65, 0xaa, 0x48,
+	0x01, 0x66, 0xd8, 0x31,
+	0x01, 0x66, 0x32, 0x31,
+	0x10, 0x03, 0x46, 0x79,
+	0x00, 0x65, 0xf4, 0x58,
+	0x01, 0x66, 0xd8, 0x31,
+	0x01, 0x66, 0x32, 0x31,
+	0x01, 0x66, 0xac, 0x30,
+	0x40, 0x3c, 0x78, 0x00,
+	0xff, 0x6a, 0xd8, 0x01,
+	0xff, 0x6a, 0x32, 0x01,
+	0x90, 0x3c, 0x78, 0x00,
+	0x02, 0x57, 0x3a, 0x69,
+	0x10, 0x03, 0x38, 0x69,
+	0x00, 0x65, 0x1e, 0x41,
+	0x02, 0x57, 0xae, 0x00,
+	0x00, 0x65, 0x9e, 0x40,
+	0x61, 0x6a, 0xca, 0x5e,
+	0x08, 0x51, 0x1e, 0x71,
+	0x02, 0x0b, 0xb2, 0x78,
+	0x00, 0x65, 0xae, 0x40,
+	0x1a, 0x01, 0x02, 0x00,
+	0xf0, 0x19, 0x7a, 0x08,
+	0x0f, 0x0f, 0xc8, 0x08,
+	0x0f, 0x05, 0xc8, 0x08,
+	0x00, 0x3d, 0x7a, 0x00,
+	0x08, 0x1f, 0xc4, 0x78,
+	0x80, 0x3d, 0x7a, 0x00,
+	0x20, 0x6a, 0x16, 0x00,
+	0x00, 0x65, 0xc0, 0x41,
+	0x00, 0x65, 0xa4, 0x5e,
+	0x00, 0x65, 0x12, 0x40,
+	0x20, 0x11, 0xd2, 0x68,
+	0x20, 0x6a, 0x18, 0x00,
+	0x20, 0x11, 0x22, 0x00,
+	0xf7, 0x1f, 0xca, 0x08,
+	0x80, 0xb9, 0xd8, 0x78,
+	0x08, 0x65, 0xca, 0x00,
+	0x01, 0x65, 0x3e, 0x30,
+	0x01, 0xb9, 0x1e, 0x30,
+	0x7f, 0xb9, 0x0a, 0x08,
+	0x01, 0xb9, 0x0a, 0x30,
+	0x01, 0x54, 0xca, 0x30,
+	0x80, 0xb8, 0xe6, 0x78,
+	0x80, 0x65, 0xca, 0x00,
+	0x01, 0x65, 0x00, 0x34,
+	0x01, 0x54, 0x00, 0x34,
+	0x1a, 0x01, 0x02, 0x00,
+	0x08, 0xb8, 0xf0, 0x78,
+	0x20, 0x01, 0x02, 0x00,
+	0x02, 0xbd, 0x08, 0x34,
+	0x01, 0xbd, 0x08, 0x34,
+	0x08, 0x01, 0x02, 0x00,
+	0x02, 0x0b, 0xf6, 0x78,
+	0xf7, 0x01, 0x02, 0x08,
+	0x01, 0x06, 0xcc, 0x34,
+	0xb2, 0x00, 0x00, 0x08,
+	0x40, 0x6a, 0x16, 0x00,
+	0x01, 0x40, 0x20, 0x31,
+	0x01, 0xbf, 0x80, 0x30,
+	0x01, 0xb9, 0x7a, 0x30,
+	0x01, 0xba, 0x7c, 0x30,
+	0x00, 0x65, 0xea, 0x58,
+	0x80, 0x0b, 0xbc, 0x79,
+	0xe4, 0x6a, 0x60, 0x5d,
+	0x80, 0xba, 0x76, 0x5d,
+	0x20, 0xb8, 0x16, 0x79,
+	0x20, 0x6a, 0x76, 0x5d,
+	0x00, 0xab, 0x76, 0x5d,
+	0x01, 0xa9, 0x78, 0x30,
+	0x10, 0xb8, 0x1e, 0x79,
+	0xe4, 0x6a, 0x60, 0x5d,
+	0x00, 0x65, 0xae, 0x40,
+	0x10, 0x03, 0x36, 0x69,
+	0x08, 0x3c, 0x52, 0x69,
+	0x04, 0x3c, 0x8a, 0x69,
+	0x02, 0x3c, 0x90, 0x69,
+	0x01, 0x3c, 0x3c, 0x79,
+	0x01, 0x6a, 0xa2, 0x30,
+	0x00, 0x65, 0x9c, 0x59,
+	0x04, 0x51, 0x2c, 0x61,
+	0x00, 0x6a, 0xb2, 0x5e,
+	0x0d, 0x6a, 0x76, 0x00,
+	0x00, 0xbb, 0x04, 0x5e,
+	0x00, 0x65, 0x16, 0x41,
+	0xa4, 0x6a, 0x06, 0x00,
+	0x00, 0x65, 0xf4, 0x58,
+	0x00, 0x65, 0xae, 0x40,
+	0xe4, 0x6a, 0x60, 0x5d,
+	0x20, 0x3c, 0x42, 0x79,
+	0x02, 0x6a, 0x76, 0x5d,
+	0x04, 0x6a, 0x76, 0x5d,
+	0x01, 0x03, 0x44, 0x69,
+	0xf7, 0x11, 0x22, 0x08,
+	0xff, 0x6a, 0x24, 0x08,
+	0xff, 0x6a, 0x06, 0x08,
+	0x01, 0x6a, 0x7e, 0x00,
+	0x00, 0x65, 0x9c, 0x59,
+	0x00, 0x65, 0x04, 0x40,
+	0x80, 0x86, 0xc8, 0x08,
+	0x01, 0x4f, 0xc8, 0x30,
+	0x00, 0x50, 0x64, 0x61,
+	0xc4, 0x6a, 0x60, 0x5d,
+	0x40, 0x3c, 0x60, 0x79,
+	0x28, 0x6a, 0x76, 0x5d,
+	0x00, 0x65, 0x44, 0x41,
+	0x08, 0x6a, 0x76, 0x5d,
+	0x00, 0x65, 0x44, 0x41,
+	0x84, 0x6a, 0x60, 0x5d,
+	0x00, 0x65, 0xf4, 0x58,
+	0x01, 0x66, 0xc8, 0x30,
+	0x01, 0x64, 0xd8, 0x31,
+	0x01, 0x64, 0x32, 0x31,
+	0x5b, 0x64, 0xc8, 0x28,
+	0x30, 0x64, 0xca, 0x18,
+	0x01, 0x6c, 0xc8, 0x30,
+	0xff, 0x64, 0x86, 0x79,
+	0x08, 0x01, 0x02, 0x00,
+	0x02, 0x0b, 0x78, 0x79,
+	0x01, 0x64, 0x7e, 0x61,
+	0xf7, 0x01, 0x02, 0x08,
+	0x01, 0x06, 0xd8, 0x31,
+	0x01, 0x06, 0x32, 0x31,
+	0xff, 0x64, 0xc8, 0x18,
+	0xff, 0x64, 0x78, 0x69,
+	0xf7, 0x3c, 0x78, 0x08,
+	0x00, 0x65, 0x1e, 0x41,
+	0x40, 0xaa, 0x7e, 0x10,
+	0x04, 0xaa, 0x60, 0x5d,
+	0x00, 0x65, 0x52, 0x42,
+	0xc4, 0x6a, 0x60, 0x5d,
+	0xc0, 0x6a, 0x7e, 0x00,
+	0x00, 0xa8, 0x76, 0x5d,
+	0xe4, 0x6a, 0x06, 0x00,
+	0x00, 0x6a, 0x76, 0x5d,
+	0x00, 0x65, 0x44, 0x41,
+	0x10, 0x3c, 0xa0, 0x69,
+	0x00, 0xbb, 0x80, 0x44,
+	0x18, 0x6a, 0xda, 0x01,
+	0x01, 0x69, 0xd8, 0x31,
+	0x1c, 0x6a, 0xd0, 0x01,
+	0x09, 0xee, 0xdc, 0x01,
+	0x80, 0xee, 0xa8, 0x79,
+	0xff, 0x6a, 0xdc, 0x09,
+	0x01, 0x93, 0x26, 0x01,
+	0x03, 0x6a, 0x2a, 0x01,
+	0x01, 0x69, 0x32, 0x31,
+	0x1c, 0x6a, 0xd2, 0x5d,
+	0x0a, 0x93, 0x26, 0x01,
+	0x00, 0x65, 0x9a, 0x5e,
+	0x01, 0x50, 0xa0, 0x18,
+	0x02, 0x6a, 0x22, 0x05,
+	0x80, 0x6a, 0x74, 0x00,
+	0x80, 0x3c, 0x78, 0x00,
+	0x00, 0x65, 0xca, 0x5d,
+	0x01, 0x3f, 0xc8, 0x30,
+	0xbf, 0x64, 0x52, 0x7a,
+	0x80, 0x64, 0xa6, 0x73,
+	0xa0, 0x64, 0x04, 0x74,
+	0xc0, 0x64, 0xf8, 0x73,
+	0xe0, 0x64, 0x34, 0x74,
+	0x01, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0xc0, 0x41,
+	0xf7, 0x11, 0x22, 0x08,
+	0x01, 0x06, 0xd4, 0x30,
+	0xff, 0x6a, 0x24, 0x08,
+	0xf7, 0x01, 0x02, 0x08,
+	0x09, 0x0c, 0xda, 0x79,
+	0x08, 0x0c, 0x04, 0x68,
+	0xb1, 0x6a, 0xca, 0x5e,
+	0xff, 0x6a, 0x26, 0x09,
+	0x12, 0x01, 0x02, 0x00,
+	0x02, 0x6a, 0x08, 0x30,
+	0xff, 0x6a, 0x08, 0x08,
+	0xdf, 0x01, 0x02, 0x08,
+	0x01, 0x6a, 0x7e, 0x00,
+	0xff, 0x6a, 0x78, 0x0c,
+	0xff, 0x6a, 0xc8, 0x08,
+	0x08, 0xa4, 0x48, 0x19,
+	0x00, 0xa5, 0x4a, 0x21,
+	0x00, 0xa6, 0x4c, 0x21,
+	0x00, 0xa7, 0x4e, 0x25,
+	0x08, 0xeb, 0xce, 0x7e,
+	0x80, 0xeb, 0xfa, 0x79,
+	0xff, 0x6a, 0xd6, 0x09,
+	0x08, 0xeb, 0xfe, 0x69,
+	0xff, 0x6a, 0xd4, 0x0c,
+	0x80, 0xa3, 0xce, 0x6e,
+	0x88, 0xeb, 0x14, 0x72,
+	0x08, 0xeb, 0xce, 0x6e,
+	0x04, 0xea, 0x18, 0xe2,
+	0x08, 0xee, 0xce, 0x6e,
+	0x04, 0x6a, 0xd0, 0x81,
+	0x05, 0xa4, 0xc0, 0x89,
+	0x03, 0xa5, 0xc2, 0x31,
+	0x09, 0x6a, 0xd6, 0x05,
+	0x00, 0x65, 0xfc, 0x59,
+	0x06, 0xa4, 0xd4, 0x89,
+	0x80, 0x94, 0xce, 0x7e,
+	0x07, 0xe9, 0x10, 0x31,
+	0x01, 0x8c, 0x20, 0x7a,
+	0x01, 0x55, 0xaa, 0x10,
+	0x01, 0xe9, 0x46, 0x31,
+	0x00, 0xa3, 0xac, 0x5e,
+	0x00, 0x65, 0xee, 0x59,
+	0x01, 0xa4, 0xca, 0x30,
+	0x01, 0x55, 0x2c, 0x7a,
+	0x04, 0x65, 0xca, 0x00,
+	0x80, 0xa3, 0x30, 0x7a,
+	0x02, 0x65, 0xca, 0x00,
+	0x01, 0x65, 0xf8, 0x31,
+	0x80, 0x93, 0x26, 0x01,
+	0xff, 0x6a, 0xd4, 0x0c,
+	0x01, 0x8c, 0xc8, 0x30,
+	0x00, 0x88, 0xc8, 0x18,
+	0x02, 0x64, 0xc8, 0x88,
+	0xff, 0x64, 0xce, 0x7e,
+	0xff, 0x8d, 0x46, 0x6a,
+	0xff, 0x8e, 0x46, 0x6a,
+	0x03, 0x8c, 0xd4, 0x98,
+	0x00, 0x65, 0xce, 0x56,
+	0x01, 0x64, 0x70, 0x30,
+	0xff, 0x64, 0xc8, 0x10,
+	0x01, 0x64, 0xc8, 0x18,
+	0x00, 0x8c, 0x18, 0x19,
+	0xff, 0x8d, 0x1a, 0x21,
+	0xff, 0x8e, 0x1c, 0x25,
+	0x80, 0x3c, 0x56, 0x6a,
+	0x21, 0x6a, 0xca, 0x46,
+	0xa8, 0x6a, 0x76, 0x00,
+	0x79, 0x6a, 0x76, 0x00,
+	0x40, 0x3f, 0x5e, 0x6a,
+	0x04, 0x3b, 0x76, 0x00,
+	0x04, 0x6a, 0xd4, 0x81,
+	0x20, 0x3c, 0x66, 0x7a,
+	0x51, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0x80, 0x42,
+	0x20, 0x3c, 0x78, 0x00,
+	0x00, 0xb3, 0xac, 0x5e,
+	0x07, 0xac, 0x10, 0x31,
+	0x05, 0xb3, 0x46, 0x31,
+	0x88, 0x6a, 0xcc, 0x00,
+	0xac, 0x6a, 0xe0, 0x5d,
+	0xa3, 0x6a, 0xcc, 0x00,
+	0xb3, 0x6a, 0xe4, 0x5d,
+	0x00, 0x65, 0x36, 0x5a,
+	0xfd, 0xa4, 0x48, 0x09,
+	0x01, 0x8c, 0xaa, 0x08,
+	0x03, 0x8c, 0x10, 0x30,
+	0x00, 0x65, 0xd8, 0x5d,
+	0x01, 0xa4, 0x92, 0x7a,
+	0x04, 0x3b, 0x76, 0x08,
+	0x01, 0x3b, 0x26, 0x31,
+	0x80, 0x02, 0x04, 0x00,
+	0x10, 0x0c, 0x88, 0x7a,
+	0x03, 0x9e, 0x8a, 0x6a,
+	0x7f, 0x02, 0x04, 0x08,
+	0x91, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0xc0, 0x41,
+	0x01, 0xa4, 0xca, 0x30,
+	0x80, 0xa3, 0x98, 0x7a,
+	0x02, 0x65, 0xca, 0x00,
+	0x01, 0x55, 0x9c, 0x7a,
+	0x04, 0x65, 0xca, 0x00,
+	0x01, 0x65, 0xf8, 0x31,
+	0x01, 0x3b, 0x26, 0x31,
+	0x00, 0x65, 0x02, 0x5a,
+	0x01, 0xfc, 0xaa, 0x6a,
+	0x80, 0x0b, 0xa0, 0x6a,
+	0x10, 0x0c, 0xa0, 0x7a,
+	0x20, 0x93, 0xa0, 0x6a,
+	0x02, 0x93, 0x26, 0x01,
+	0x02, 0xfc, 0xb4, 0x7a,
+	0x40, 0x0d, 0xce, 0x6a,
+	0x01, 0xa4, 0x48, 0x01,
+	0x00, 0x65, 0xce, 0x42,
+	0x40, 0x0d, 0xba, 0x6a,
+	0x00, 0x65, 0x02, 0x5a,
+	0x00, 0x65, 0xac, 0x42,
+	0x80, 0xfc, 0xc4, 0x7a,
+	0x80, 0xa4, 0xc4, 0x6a,
+	0xff, 0xa5, 0x4a, 0x19,
+	0xff, 0xa6, 0x4c, 0x21,
+	0xff, 0xa7, 0x4e, 0x21,
+	0xf8, 0xfc, 0x48, 0x09,
+	0xff, 0x6a, 0xaa, 0x08,
+	0x04, 0xfc, 0xcc, 0x7a,
+	0x01, 0x55, 0xaa, 0x00,
+	0xff, 0x6a, 0x46, 0x09,
+	0x04, 0x3b, 0xe6, 0x6a,
+	0x02, 0x93, 0x26, 0x01,
+	0x01, 0x94, 0xd0, 0x7a,
+	0x01, 0x94, 0xd0, 0x7a,
+	0x01, 0x94, 0xd0, 0x7a,
+	0x01, 0x94, 0xd0, 0x7a,
+	0x01, 0x94, 0xd0, 0x7a,
+	0x01, 0xa4, 0xe4, 0x7a,
+	0x01, 0xfc, 0xde, 0x7a,
+	0x01, 0x94, 0xe6, 0x6a,
+	0x00, 0x65, 0x80, 0x42,
+	0x01, 0x94, 0xe4, 0x7a,
+	0x10, 0x94, 0xe6, 0x6a,
+	0xd7, 0x93, 0x26, 0x09,
+	0x28, 0x93, 0xea, 0x6a,
+	0x01, 0x85, 0x0a, 0x01,
+	0x02, 0xfc, 0xf2, 0x6a,
+	0x01, 0x14, 0x46, 0x31,
+	0xff, 0x6a, 0x10, 0x09,
+	0xfe, 0x85, 0x0a, 0x09,
+	0xff, 0x38, 0x00, 0x6b,
+	0x80, 0xa3, 0x00, 0x7b,
+	0x80, 0x0b, 0xfe, 0x7a,
+	0x04, 0x3b, 0x00, 0x7b,
+	0xbf, 0x3b, 0x76, 0x08,
+	0x01, 0x3b, 0x26, 0x31,
+	0x00, 0x65, 0x02, 0x5a,
+	0x01, 0x0b, 0x0e, 0x6b,
+	0x10, 0x0c, 0x02, 0x7b,
+	0x04, 0x93, 0x0c, 0x6b,
+	0x01, 0x94, 0x0a, 0x7b,
+	0x10, 0x94, 0x0c, 0x6b,
+	0xc7, 0x93, 0x26, 0x09,
+	0x01, 0x99, 0xd4, 0x30,
+	0x38, 0x93, 0x10, 0x6b,
+	0xff, 0x08, 0x62, 0x6b,
+	0xff, 0x09, 0x62, 0x6b,
+	0xff, 0x0a, 0x62, 0x6b,
+	0xff, 0x38, 0x2c, 0x7b,
+	0x04, 0x14, 0x10, 0x31,
+	0x01, 0x38, 0x18, 0x31,
+	0x02, 0x6a, 0x1a, 0x31,
+	0x88, 0x6a, 0xcc, 0x00,
+	0x14, 0x6a, 0xe6, 0x5d,
+	0x00, 0x38, 0xd2, 0x5d,
+	0xff, 0x6a, 0x70, 0x08,
+	0x00, 0x65, 0x58, 0x43,
+	0x80, 0xa3, 0x32, 0x7b,
+	0x01, 0xa4, 0x48, 0x01,
+	0x00, 0x65, 0x62, 0x43,
+	0x08, 0xeb, 0x38, 0x7b,
+	0x00, 0x65, 0x02, 0x5a,
+	0x08, 0xeb, 0x34, 0x6b,
+	0x07, 0xe9, 0x10, 0x31,
+	0x01, 0xe9, 0xca, 0x30,
+	0x01, 0x65, 0x46, 0x31,
+	0x00, 0x6a, 0xac, 0x5e,
+	0x88, 0x6a, 0xcc, 0x00,
+	0xa4, 0x6a, 0xe6, 0x5d,
+	0x08, 0x6a, 0xd2, 0x5d,
+	0x0d, 0x93, 0x26, 0x01,
+	0x00, 0x65, 0x9a, 0x5e,
+	0x88, 0x6a, 0xcc, 0x00,
+	0x00, 0x65, 0x7c, 0x5e,
+	0x01, 0x99, 0x46, 0x31,
+	0x00, 0xa3, 0xac, 0x5e,
+	0x01, 0x88, 0x10, 0x31,
+	0x00, 0x65, 0x36, 0x5a,
+	0x00, 0x65, 0xee, 0x59,
+	0x03, 0x8c, 0x10, 0x30,
+	0x00, 0x65, 0xd8, 0x5d,
+	0x01, 0x8c, 0x60, 0x7b,
+	0x01, 0x55, 0xaa, 0x10,
+	0x80, 0x0b, 0x80, 0x6a,
+	0x80, 0x0b, 0x6a, 0x6b,
+	0x01, 0x0c, 0x64, 0x7b,
+	0x10, 0x0c, 0x80, 0x7a,
+	0x03, 0x9e, 0x80, 0x6a,
+	0x00, 0x65, 0xf8, 0x59,
+	0x00, 0x6a, 0xac, 0x5e,
+	0x01, 0xa4, 0x8a, 0x6b,
+	0xff, 0x38, 0x80, 0x7b,
+	0x01, 0x38, 0xc8, 0x30,
+	0x00, 0x08, 0x40, 0x19,
+	0xff, 0x6a, 0xc8, 0x08,
+	0x00, 0x09, 0x42, 0x21,
+	0x00, 0x0a, 0x44, 0x21,
+	0xff, 0x6a, 0x70, 0x08,
+	0x00, 0x65, 0x82, 0x43,
+	0x03, 0x08, 0x40, 0x31,
+	0x03, 0x08, 0x40, 0x31,
+	0x01, 0x08, 0x40, 0x31,
+	0x01, 0x09, 0x42, 0x31,
+	0x01, 0x0a, 0x44, 0x31,
+	0xfd, 0xb4, 0x68, 0x09,
+	0x12, 0x01, 0x02, 0x00,
+	0x12, 0x01, 0x02, 0x00,
+	0x04, 0x3c, 0xc0, 0x79,
+	0xfb, 0x3c, 0x78, 0x08,
+	0x04, 0x93, 0x1e, 0x79,
+	0x01, 0x0c, 0x96, 0x6b,
+	0x01, 0x55, 0x1e, 0x79,
+	0x80, 0x04, 0x1e, 0x79,
+	0xe4, 0x6a, 0x60, 0x5d,
+	0x23, 0x6a, 0x76, 0x5d,
+	0x01, 0x6a, 0x76, 0x5d,
+	0x00, 0x65, 0x1e, 0x41,
+	0x00, 0x65, 0xc0, 0x41,
+	0x80, 0x3c, 0xaa, 0x6b,
+	0x21, 0x6a, 0xca, 0x46,
+	0x01, 0xbc, 0x18, 0x31,
+	0x02, 0x6a, 0x1a, 0x31,
+	0x02, 0x6a, 0xf8, 0x01,
+	0x01, 0xbc, 0x10, 0x30,
+	0x02, 0x6a, 0x12, 0x30,
+	0x01, 0xbc, 0x10, 0x30,
+	0xff, 0x6a, 0x12, 0x08,
+	0xff, 0x6a, 0x14, 0x08,
+	0xf3, 0xbc, 0xd4, 0x18,
+	0xa0, 0x6a, 0xd0, 0x53,
+	0x04, 0xa0, 0x10, 0x31,
+	0xac, 0x6a, 0x26, 0x01,
+	0x04, 0xa0, 0x10, 0x31,
+	0x03, 0x08, 0x18, 0x31,
+	0x88, 0x6a, 0xcc, 0x00,
+	0xa0, 0x6a, 0xe6, 0x5d,
+	0x00, 0xbc, 0xd2, 0x5d,
+	0x3d, 0x6a, 0x26, 0x01,
+	0x00, 0x65, 0xe8, 0x43,
+	0xff, 0x6a, 0x10, 0x09,
+	0xa4, 0x6a, 0x26, 0x01,
+	0x0c, 0xa0, 0x32, 0x31,
+	0x05, 0x6a, 0x26, 0x01,
+	0x35, 0x6a, 0x26, 0x01,
+	0x0c, 0xa0, 0x32, 0x31,
+	0x36, 0x6a, 0x26, 0x01,
+	0x02, 0x93, 0x26, 0x01,
+	0x35, 0x6a, 0x26, 0x01,
+	0x00, 0x65, 0x8e, 0x5e,
+	0x00, 0x65, 0x8e, 0x5e,
+	0x02, 0x93, 0x26, 0x01,
+	0x04, 0x0b, 0xec, 0x6b,
+	0x10, 0x0c, 0xe8, 0x7b,
+	0x01, 0x03, 0xec, 0x6b,
+	0x20, 0x93, 0xe8, 0x6b,
+	0xc7, 0x93, 0x26, 0x09,
+	0x38, 0x93, 0xf2, 0x6b,
+	0x10, 0x01, 0x02, 0x00,
+	0x00, 0x65, 0xc0, 0x41,
+	0x80, 0x3c, 0xfc, 0x6b,
+	0x21, 0x6a, 0xca, 0x46,
+	0x01, 0x06, 0x50, 0x31,
+	0x00, 0x65, 0xc0, 0x41,
+	0x10, 0x3f, 0x06, 0x00,
+	0x10, 0x6a, 0x06, 0x00,
+	0x01, 0x3a, 0xca, 0x30,
+	0x80, 0x65, 0x20, 0x64,
+	0x10, 0xb8, 0x44, 0x6c,
+	0xc0, 0xba, 0xca, 0x00,
+	0x40, 0xb8, 0x10, 0x6c,
+	0xbf, 0x65, 0xca, 0x08,
+	0x20, 0xb8, 0x24, 0x7c,
+	0x01, 0x65, 0x0c, 0x30,
+	0x00, 0x65, 0xca, 0x5d,
+	0xa0, 0x3f, 0x2c, 0x64,
+	0x23, 0xb8, 0x0c, 0x08,
+	0x00, 0x65, 0xca, 0x5d,
+	0xa0, 0x3f, 0x2c, 0x64,
+	0x00, 0xbb, 0x24, 0x44,
+	0xff, 0x65, 0x24, 0x64,
+	0x00, 0x65, 0x44, 0x44,
+	0x40, 0x6a, 0x18, 0x00,
+	0x01, 0x65, 0x0c, 0x30,
+	0x00, 0x65, 0xca, 0x5d,
+	0xa0, 0x3f, 0x00, 0x74,
+	0x40, 0x6a, 0x18, 0x00,
+	0x01, 0x3a, 0xa6, 0x30,
+	0x08, 0x6a, 0x74, 0x00,
+	0x00, 0x65, 0xc0, 0x41,
+	0x64, 0x6a, 0x5a, 0x5d,
+	0x80, 0x64, 0xca, 0x6c,
+	0x04, 0x64, 0x90, 0x74,
+	0x02, 0x64, 0x9e, 0x74,
+	0x00, 0x6a, 0x60, 0x74,
+	0x03, 0x64, 0xbc, 0x74,
+	0x23, 0x64, 0x4c, 0x74,
+	0x08, 0x64, 0x5c, 0x74,
+	0x61, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0xca, 0x5d,
+	0x08, 0x51, 0xc2, 0x71,
+	0x00, 0x65, 0x44, 0x44,
+	0x80, 0x04, 0x5a, 0x7c,
+	0x51, 0x6a, 0x50, 0x5d,
+	0x01, 0x51, 0x5a, 0x64,
+	0x01, 0xa4, 0x56, 0x7c,
+	0x01, 0x55, 0x5c, 0x7c,
+	0x41, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0x5c, 0x44,
+	0x07, 0x6a, 0x46, 0x5d,
+	0x01, 0x06, 0xd4, 0x30,
+	0x00, 0x65, 0xc0, 0x41,
+	0x10, 0xb8, 0x64, 0x7c,
+	0xa1, 0x6a, 0xca, 0x5e,
+	0x01, 0xb4, 0x6a, 0x6c,
+	0x02, 0xb4, 0x6c, 0x6c,
+	0x01, 0xa4, 0x6c, 0x7c,
+	0xff, 0xa8, 0x7c, 0x7c,
+	0x04, 0xb4, 0x68, 0x01,
+	0x01, 0x6a, 0x76, 0x00,
+	0x00, 0xbb, 0x04, 0x5e,
+	0xff, 0xa8, 0x7c, 0x7c,
+	0x71, 0x6a, 0xca, 0x5e,
+	0x40, 0x51, 0x7c, 0x64,
+	0x00, 0x65, 0xa4, 0x5e,
+	0x00, 0x65, 0xd2, 0x41,
+	0x00, 0xbb, 0x80, 0x5c,
+	0x00, 0x65, 0xd2, 0x41,
+	0x00, 0x65, 0xa4, 0x5e,
+	0x01, 0x65, 0xa2, 0x30,
+	0x01, 0xf8, 0xc8, 0x30,
+	0x01, 0x4e, 0xc8, 0x30,
+	0x00, 0x6a, 0xa8, 0xdd,
+	0x00, 0x51, 0xba, 0x5d,
+	0x01, 0x4e, 0x9c, 0x18,
+	0x02, 0x6a, 0x22, 0x05,
+	0x04, 0xb8, 0x70, 0x01,
+	0x00, 0x65, 0xc6, 0x5e,
+	0x20, 0xb8, 0xd2, 0x69,
+	0x01, 0xbb, 0xa2, 0x30,
+	0x01, 0xba, 0x7c, 0x30,
+	0x00, 0xb9, 0xc0, 0x5c,
+	0x00, 0x65, 0xd2, 0x41,
+	0x01, 0x06, 0xd4, 0x30,
+	0x20, 0x3c, 0xc0, 0x79,
+	0x20, 0x3c, 0x5c, 0x7c,
+	0x01, 0xa4, 0xac, 0x7c,
+	0x01, 0xb4, 0x68, 0x01,
+	0x00, 0x65, 0xc0, 0x41,
+	0x00, 0x65, 0x5c, 0x44,
+	0x04, 0x14, 0x58, 0x31,
+	0x01, 0x06, 0xd4, 0x30,
+	0x08, 0xa0, 0x60, 0x31,
+	0xac, 0x6a, 0xcc, 0x00,
+	0x14, 0x6a, 0xe6, 0x5d,
+	0x01, 0x06, 0xd4, 0x30,
+	0xa0, 0x6a, 0xde, 0x5d,
+	0x00, 0x65, 0xc0, 0x41,
+	0xdf, 0x3c, 0x78, 0x08,
+	0x00, 0x65, 0x5c, 0x44,
+	0x4c, 0x65, 0xcc, 0x28,
+	0x01, 0x3e, 0x20, 0x31,
+	0xd0, 0x66, 0xcc, 0x18,
+	0x20, 0x66, 0xcc, 0x18,
+	0x01, 0x51, 0xda, 0x34,
+	0x4c, 0x3d, 0xca, 0x28,
+	0x3f, 0x64, 0x7c, 0x08,
+	0xd0, 0x65, 0xca, 0x18,
+	0x01, 0x3e, 0x20, 0x31,
+	0x30, 0x65, 0xd4, 0x18,
+	0x00, 0x65, 0xd8, 0x4c,
+	0xe1, 0x6a, 0x22, 0x01,
+	0xff, 0x6a, 0xd4, 0x08,
+	0x20, 0x65, 0xd4, 0x18,
+	0x00, 0x65, 0xe0, 0x54,
+	0xe1, 0x6a, 0x22, 0x01,
+	0xff, 0x6a, 0xd4, 0x08,
+	0x20, 0x65, 0xca, 0x18,
+	0xe0, 0x65, 0xd4, 0x18,
+	0x00, 0x65, 0xea, 0x4c,
+	0xe1, 0x6a, 0x22, 0x01,
+	0xff, 0x6a, 0xd4, 0x08,
+	0xd0, 0x65, 0xd4, 0x18,
+	0x00, 0x65, 0xf2, 0x54,
+	0xe1, 0x6a, 0x22, 0x01,
+	0xff, 0x6a, 0xd4, 0x08,
+	0x01, 0x6c, 0xa2, 0x30,
+	0xff, 0x51, 0x04, 0x75,
+	0x00, 0x51, 0x80, 0x5d,
+	0x01, 0x51, 0x20, 0x31,
+	0x00, 0x65, 0x26, 0x45,
+	0x01, 0xba, 0xc8, 0x30,
+	0x00, 0x3e, 0x26, 0x75,
+	0x00, 0x65, 0xa2, 0x5e,
+	0x80, 0x3c, 0x78, 0x00,
+	0x01, 0x06, 0xd4, 0x30,
+	0x00, 0x65, 0xca, 0x5d,
+	0x01, 0x3c, 0x78, 0x00,
+	0xe0, 0x3f, 0x42, 0x65,
+	0x02, 0x3c, 0x78, 0x00,
+	0x20, 0x12, 0x42, 0x65,
+	0x51, 0x6a, 0x50, 0x5d,
+	0x00, 0x51, 0x80, 0x5d,
+	0x51, 0x6a, 0x50, 0x5d,
+	0x01, 0x51, 0x20, 0x31,
+	0x04, 0x3c, 0x78, 0x00,
+	0x01, 0xb9, 0xc8, 0x30,
+	0x00, 0x3d, 0x40, 0x65,
+	0x08, 0x3c, 0x78, 0x00,
+	0x01, 0xba, 0xc8, 0x30,
+	0x00, 0x3e, 0x40, 0x65,
+	0x10, 0x3c, 0x78, 0x00,
+	0x04, 0xb8, 0x40, 0x7d,
+	0xfb, 0xb8, 0x70, 0x09,
+	0x20, 0xb8, 0x36, 0x6d,
+	0x01, 0x90, 0xc8, 0x30,
+	0xff, 0x6a, 0xa2, 0x00,
+	0x00, 0x3d, 0xc0, 0x5c,
+	0x01, 0x64, 0x20, 0x31,
+	0x80, 0x6a, 0x78, 0x00,
+	0x00, 0x65, 0xec, 0x58,
+	0x10, 0xb8, 0x5c, 0x7c,
+	0xff, 0x6a, 0x46, 0x5d,
+	0x00, 0x65, 0x5c, 0x44,
+	0x00, 0x65, 0xa2, 0x5e,
+	0x31, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0x5c, 0x44,
+	0x10, 0x3f, 0x06, 0x00,
+	0x10, 0x6a, 0x06, 0x00,
+	0x01, 0x65, 0x74, 0x34,
+	0x81, 0x6a, 0xca, 0x5e,
+	0x00, 0x65, 0x52, 0x45,
+	0x01, 0x06, 0xd4, 0x30,
+	0x01, 0x0c, 0x52, 0x7d,
+	0x04, 0x0c, 0x4c, 0x6d,
+	0xe0, 0x03, 0x7e, 0x08,
+	0xe0, 0x3f, 0xc0, 0x61,
+	0x01, 0x65, 0xcc, 0x30,
+	0x01, 0x12, 0xda, 0x34,
+	0x01, 0x06, 0xd4, 0x34,
+	0x01, 0x03, 0x60, 0x6d,
+	0x40, 0x03, 0xcc, 0x08,
+	0x01, 0x65, 0x06, 0x30,
+	0x40, 0x65, 0xc8, 0x08,
+	0x00, 0x66, 0x6e, 0x75,
+	0x40, 0x65, 0x6e, 0x7d,
+	0x00, 0x65, 0x6e, 0x5d,
+	0xff, 0x6a, 0xd4, 0x08,
+	0xff, 0x6a, 0xd4, 0x08,
+	0xff, 0x6a, 0xd4, 0x08,
+	0xff, 0x6a, 0xd4, 0x0c,
+	0x08, 0x01, 0x02, 0x00,
+	0x02, 0x0b, 0x78, 0x7d,
+	0x01, 0x65, 0x0c, 0x30,
+	0x02, 0x0b, 0x7c, 0x7d,
+	0xf7, 0x01, 0x02, 0x0c,
+	0x01, 0x65, 0xc8, 0x30,
+	0xff, 0x41, 0xa0, 0x75,
+	0x01, 0x41, 0x20, 0x31,
+	0xff, 0x6a, 0xa4, 0x00,
+	0x00, 0x65, 0x90, 0x45,
+	0xff, 0xbf, 0xa0, 0x75,
+	0x01, 0x90, 0xa4, 0x30,
+	0x01, 0xbf, 0x20, 0x31,
+	0x00, 0xbb, 0x8a, 0x65,
+	0xff, 0x52, 0x9e, 0x75,
+	0x01, 0xbf, 0xcc, 0x30,
+	0x01, 0x90, 0xca, 0x30,
+	0x01, 0x52, 0x20, 0x31,
+	0x01, 0x66, 0x7e, 0x31,
+	0x01, 0x65, 0x20, 0x35,
+	0x01, 0xbf, 0x82, 0x34,
+	0x01, 0x64, 0xa2, 0x30,
+	0x00, 0x6a, 0xb2, 0x5e,
+	0x0d, 0x6a, 0x76, 0x00,
+	0x00, 0x51, 0x04, 0x46,
+	0x01, 0x65, 0xa4, 0x30,
+	0xe0, 0x6a, 0xcc, 0x00,
+	0x48, 0x6a, 0xf8, 0x5d,
+	0x01, 0x6a, 0xd0, 0x01,
+	0x01, 0x6a, 0xdc, 0x05,
+	0x88, 0x6a, 0xcc, 0x00,
+	0x48, 0x6a, 0xf8, 0x5d,
+	0x01, 0x6a, 0xd2, 0x5d,
+	0x01, 0x6a, 0x26, 0x05,
+	0x01, 0x65, 0xd8, 0x31,
+	0x09, 0xee, 0xdc, 0x01,
+	0x80, 0xee, 0xbe, 0x7d,
+	0xff, 0x6a, 0xdc, 0x0d,
+	0x01, 0x65, 0x32, 0x31,
+	0x0a, 0x93, 0x26, 0x01,
+	0x00, 0x65, 0x9a, 0x46,
+	0x81, 0x6a, 0xca, 0x5e,
+	0x01, 0x0c, 0xca, 0x7d,
+	0x04, 0x0c, 0xc8, 0x6d,
+	0xe0, 0x03, 0x06, 0x08,
+	0xe0, 0x03, 0x7e, 0x0c,
+	0x01, 0x65, 0x18, 0x31,
+	0xff, 0x6a, 0x1a, 0x09,
+	0xff, 0x6a, 0x1c, 0x0d,
+	0x01, 0x8c, 0x10, 0x30,
+	0x01, 0x8d, 0x12, 0x30,
+	0x01, 0x8e, 0x14, 0x34,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x30,
+	0x01, 0x6c, 0xda, 0x34,
+	0x3d, 0x64, 0xa4, 0x28,
+	0x55, 0x64, 0xc8, 0x28,
+	0x00, 0x65, 0xf8, 0x45,
+	0x2e, 0x64, 0xa4, 0x28,
+	0x66, 0x64, 0xc8, 0x28,
+	0x00, 0x6c, 0xda, 0x18,
+	0x01, 0x52, 0xc8, 0x30,
+	0x00, 0x6c, 0xda, 0x20,
+	0xff, 0x6a, 0xc8, 0x08,
+	0x00, 0x6c, 0xda, 0x20,
+	0x00, 0x6c, 0xda, 0x24,
+	0x01, 0x65, 0xc8, 0x30,
+	0xe0, 0x6a, 0xcc, 0x00,
+	0x44, 0x6a, 0xf4, 0x5d,
+	0x01, 0x90, 0xe2, 0x31,
+	0x04, 0x3b, 0x18, 0x7e,
+	0x30, 0x6a, 0xd0, 0x01,
+	0x20, 0x6a, 0xd0, 0x01,
+	0x1d, 0x6a, 0xdc, 0x01,
+	0xdc, 0xee, 0x14, 0x66,
+	0x00, 0x65, 0x30, 0x46,
+	0x20, 0x6a, 0xd0, 0x01,
+	0x01, 0x6a, 0xdc, 0x01,
+	0x20, 0xa0, 0xd8, 0x31,
+	0x09, 0xee, 0xdc, 0x01,
+	0x80, 0xee, 0x20, 0x7e,
+	0x11, 0x6a, 0xdc, 0x01,
+	0x50, 0xee, 0x24, 0x66,
+	0x20, 0x6a, 0xd0, 0x01,
+	0x09, 0x6a, 0xdc, 0x01,
+	0x88, 0xee, 0x2a, 0x66,
+	0x19, 0x6a, 0xdc, 0x01,
+	0xd8, 0xee, 0x2e, 0x66,
+	0xff, 0x6a, 0xdc, 0x09,
+	0x18, 0xee, 0x32, 0x6e,
+	0xff, 0x6a, 0xd4, 0x0c,
+	0x88, 0x6a, 0xcc, 0x00,
+	0x44, 0x6a, 0xf4, 0x5d,
+	0x20, 0x6a, 0xd2, 0x5d,
+	0x01, 0x3b, 0x26, 0x31,
+	0x04, 0x3b, 0x4c, 0x6e,
+	0xa0, 0x6a, 0xca, 0x00,
+	0x20, 0x65, 0xc8, 0x18,
+	0x00, 0x65, 0x8a, 0x5e,
+	0x00, 0x65, 0x44, 0x66,
+	0x0a, 0x93, 0x26, 0x01,
+	0x00, 0x65, 0x9a, 0x46,
+	0xa0, 0x6a, 0xcc, 0x00,
+	0xff, 0x6a, 0xc8, 0x08,
+	0x20, 0x94, 0x50, 0x6e,
+	0x10, 0x94, 0x52, 0x6e,
+	0x08, 0x94, 0x6c, 0x6e,
+	0x08, 0x94, 0x6c, 0x6e,
+	0x08, 0x94, 0x6c, 0x6e,
+	0xff, 0x8c, 0xc8, 0x10,
+	0xc1, 0x64, 0xc8, 0x18,
+	0xf8, 0x64, 0xc8, 0x08,
+	0x01, 0x99, 0xda, 0x30,
+	0x00, 0x66, 0x60, 0x66,
+	0xc0, 0x66, 0x9c, 0x76,
+	0x60, 0x66, 0xc8, 0x18,
+	0x3d, 0x64, 0xc8, 0x28,
+	0x00, 0x65, 0x50, 0x46,
+	0xf7, 0x93, 0x26, 0x09,
+	0x08, 0x93, 0x6e, 0x6e,
+	0x00, 0x62, 0xc4, 0x18,
+	0x00, 0x65, 0x9a, 0x5e,
+	0x00, 0x65, 0x7a, 0x5e,
+	0x00, 0x65, 0x7a, 0x5e,
+	0x00, 0x65, 0x7a, 0x5e,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x30,
+	0x01, 0x99, 0xda, 0x34,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x31,
+	0x01, 0x6c, 0x32, 0x35,
+	0x08, 0x94, 0x9a, 0x7e,
+	0xf7, 0x93, 0x26, 0x09,
+	0x08, 0x93, 0x9e, 0x6e,
+	0xff, 0x6a, 0xd4, 0x0c,
+	0x04, 0xb8, 0xc6, 0x6e,
+	0x01, 0x42, 0x7e, 0x31,
+	0xff, 0x6a, 0x76, 0x01,
+	0x01, 0x90, 0x84, 0x34,
+	0xff, 0x6a, 0x76, 0x05,
+	0x01, 0x85, 0x0a, 0x01,
+	0x7f, 0x65, 0x10, 0x09,
+	0xfe, 0x85, 0x0a, 0x0d,
+	0xff, 0x42, 0xc2, 0x66,
+	0xff, 0x41, 0xba, 0x66,
+	0xd1, 0x6a, 0xca, 0x5e,
+	0xff, 0x6a, 0xca, 0x04,
+	0x01, 0x41, 0x20, 0x31,
+	0x01, 0xbf, 0x82, 0x30,
+	0x01, 0x6a, 0x76, 0x00,
+	0x00, 0xbb, 0x04, 0x46,
+	0x01, 0x42, 0x20, 0x31,
+	0x01, 0xbf, 0x84, 0x34,
+	0x01, 0x41, 0x7e, 0x31,
+	0x01, 0x90, 0x82, 0x34,
+	0x01, 0x65, 0x22, 0x31,
+	0xff, 0x6a, 0xd4, 0x08,
+	0xff, 0x6a, 0xd4, 0x0c
+};
+
+static int ahc_patch23_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch23_func(struct ahc_softc *ahc)
+{
+	return ((ahc->bugs & AHC_SCBCHAN_UPLOAD_BUG) != 0);
+}
+
+static int ahc_patch22_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch22_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_CMD_CHAN) == 0);
+}
+
+static int ahc_patch21_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch21_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_QUEUE_REGS) == 0);
+}
+
+static int ahc_patch20_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch20_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_WIDE) != 0);
+}
+
+static int ahc_patch19_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch19_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_SCB_BTT) != 0);
+}
+
+static int ahc_patch18_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch18_func(struct ahc_softc *ahc)
+{
+	return ((ahc->bugs & AHC_PCI_2_1_RETRY_BUG) != 0);
+}
+
+static int ahc_patch17_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch17_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0);
+}
+
+static int ahc_patch16_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch16_func(struct ahc_softc *ahc)
+{
+	return ((ahc->bugs & AHC_AUTOFLUSH_BUG) != 0);
+}
+
+static int ahc_patch15_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch15_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_ULTRA2) == 0);
+}
+
+static int ahc_patch14_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch14_func(struct ahc_softc *ahc)
+{
+	return ((ahc->bugs & AHC_PCI_MWI_BUG) != 0 && ahc->pci_cachesize != 0);
+}
+
+static int ahc_patch13_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch13_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_39BIT_ADDRESSING) != 0);
+}
+
+static int ahc_patch12_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch12_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_HS_MAILBOX) != 0);
+}
+
+static int ahc_patch11_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch11_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_ULTRA) != 0);
+}
+
+static int ahc_patch10_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch10_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_MULTI_TID) != 0);
+}
+
+static int ahc_patch9_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch9_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_CMD_CHAN) != 0);
+}
+
+static int ahc_patch8_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch8_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_INITIATORROLE) != 0);
+}
+
+static int ahc_patch7_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch7_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_TARGETROLE) != 0);
+}
+
+static int ahc_patch6_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch6_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_DT) == 0);
+}
+
+static int ahc_patch5_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch5_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0);
+}
+
+static int ahc_patch4_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch4_func(struct ahc_softc *ahc)
+{
+	return ((ahc->flags & AHC_PAGESCBS) != 0);
+}
+
+static int ahc_patch3_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch3_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_QUEUE_REGS) != 0);
+}
+
+static int ahc_patch2_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch2_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_TWIN) != 0);
+}
+
+static int ahc_patch1_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch1_func(struct ahc_softc *ahc)
+{
+	return ((ahc->features & AHC_ULTRA2) != 0);
+}
+
+static int ahc_patch0_func(struct ahc_softc *ahc);
+
+static int
+ahc_patch0_func(struct ahc_softc *ahc)
+{
+	return (0);
+}
+
+typedef int patch_func_t (struct ahc_softc *);
+struct patch {
+	patch_func_t	*patch_func;
+	uint32_t	begin	   :10,
+			skip_instr :10,
+			skip_patch :12;
+} patches[] = {
+	{ ahc_patch1_func, 4, 1, 1 },
+	{ ahc_patch2_func, 6, 2, 1 },
+	{ ahc_patch2_func, 9, 1, 1 },
+	{ ahc_patch3_func, 11, 1, 2 },
+	{ ahc_patch0_func, 12, 2, 1 },
+	{ ahc_patch4_func, 15, 1, 2 },
+	{ ahc_patch0_func, 16, 1, 1 },
+	{ ahc_patch5_func, 22, 2, 1 },
+	{ ahc_patch3_func, 27, 1, 2 },
+	{ ahc_patch0_func, 28, 1, 1 },
+	{ ahc_patch6_func, 34, 1, 1 },
+	{ ahc_patch7_func, 37, 54, 19 },
+	{ ahc_patch8_func, 37, 1, 1 },
+	{ ahc_patch9_func, 42, 3, 2 },
+	{ ahc_patch0_func, 45, 3, 1 },
+	{ ahc_patch10_func, 49, 1, 2 },
+	{ ahc_patch0_func, 50, 2, 3 },
+	{ ahc_patch1_func, 50, 1, 2 },
+	{ ahc_patch0_func, 51, 1, 1 },
+	{ ahc_patch2_func, 53, 2, 1 },
+	{ ahc_patch9_func, 55, 1, 2 },
+	{ ahc_patch0_func, 56, 1, 1 },
+	{ ahc_patch9_func, 60, 1, 2 },
+	{ ahc_patch0_func, 61, 1, 1 },
+	{ ahc_patch9_func, 71, 1, 2 },
+	{ ahc_patch0_func, 72, 1, 1 },
+	{ ahc_patch9_func, 75, 1, 2 },
+	{ ahc_patch0_func, 76, 1, 1 },
+	{ ahc_patch9_func, 79, 1, 2 },
+	{ ahc_patch0_func, 80, 1, 1 },
+	{ ahc_patch8_func, 91, 9, 4 },
+	{ ahc_patch1_func, 93, 1, 2 },
+	{ ahc_patch0_func, 94, 1, 1 },
+	{ ahc_patch2_func, 96, 2, 1 },
+	{ ahc_patch2_func, 105, 4, 1 },
+	{ ahc_patch1_func, 109, 1, 2 },
+	{ ahc_patch0_func, 110, 2, 3 },
+	{ ahc_patch2_func, 110, 1, 2 },
+	{ ahc_patch0_func, 111, 1, 1 },
+	{ ahc_patch7_func, 112, 4, 2 },
+	{ ahc_patch0_func, 116, 1, 1 },
+	{ ahc_patch11_func, 118, 2, 1 },
+	{ ahc_patch1_func, 120, 1, 2 },
+	{ ahc_patch0_func, 121, 1, 1 },
+	{ ahc_patch7_func, 122, 4, 1 },
+	{ ahc_patch7_func, 133, 89, 11 },
+	{ ahc_patch4_func, 151, 1, 1 },
+	{ ahc_patch1_func, 164, 1, 1 },
+	{ ahc_patch12_func, 169, 1, 2 },
+	{ ahc_patch0_func, 170, 1, 1 },
+	{ ahc_patch9_func, 181, 1, 2 },
+	{ ahc_patch0_func, 182, 1, 1 },
+	{ ahc_patch9_func, 191, 1, 2 },
+	{ ahc_patch0_func, 192, 1, 1 },
+	{ ahc_patch9_func, 208, 6, 2 },
+	{ ahc_patch0_func, 214, 6, 1 },
+	{ ahc_patch8_func, 222, 18, 2 },
+	{ ahc_patch1_func, 235, 1, 1 },
+	{ ahc_patch1_func, 242, 1, 2 },
+	{ ahc_patch0_func, 243, 2, 2 },
+	{ ahc_patch11_func, 244, 1, 1 },
+	{ ahc_patch9_func, 252, 31, 3 },
+	{ ahc_patch1_func, 268, 14, 2 },
+	{ ahc_patch13_func, 273, 1, 1 },
+	{ ahc_patch14_func, 283, 14, 1 },
+	{ ahc_patch1_func, 299, 1, 2 },
+	{ ahc_patch0_func, 300, 1, 1 },
+	{ ahc_patch9_func, 303, 1, 1 },
+	{ ahc_patch13_func, 308, 1, 1 },
+	{ ahc_patch9_func, 309, 2, 2 },
+	{ ahc_patch0_func, 311, 4, 1 },
+	{ ahc_patch14_func, 315, 1, 1 },
+	{ ahc_patch15_func, 318, 2, 3 },
+	{ ahc_patch9_func, 318, 1, 2 },
+	{ ahc_patch0_func, 319, 1, 1 },
+	{ ahc_patch6_func, 324, 1, 2 },
+	{ ahc_patch0_func, 325, 1, 1 },
+	{ ahc_patch1_func, 329, 50, 11 },
+	{ ahc_patch6_func, 338, 2, 4 },
+	{ ahc_patch7_func, 338, 1, 1 },
+	{ ahc_patch8_func, 339, 1, 1 },
+	{ ahc_patch0_func, 340, 1, 1 },
+	{ ahc_patch16_func, 341, 1, 1 },
+	{ ahc_patch6_func, 360, 6, 3 },
+	{ ahc_patch16_func, 360, 5, 1 },
+	{ ahc_patch0_func, 366, 5, 1 },
+	{ ahc_patch13_func, 374, 5, 1 },
+	{ ahc_patch0_func, 379, 54, 17 },
+	{ ahc_patch14_func, 379, 1, 1 },
+	{ ahc_patch7_func, 381, 2, 2 },
+	{ ahc_patch17_func, 382, 1, 1 },
+	{ ahc_patch9_func, 385, 1, 1 },
+	{ ahc_patch18_func, 392, 1, 1 },
+	{ ahc_patch14_func, 397, 9, 3 },
+	{ ahc_patch9_func, 398, 3, 2 },
+	{ ahc_patch0_func, 401, 3, 1 },
+	{ ahc_patch9_func, 409, 6, 2 },
+	{ ahc_patch0_func, 415, 9, 2 },
+	{ ahc_patch13_func, 415, 1, 1 },
+	{ ahc_patch13_func, 424, 2, 1 },
+	{ ahc_patch14_func, 426, 1, 1 },
+	{ ahc_patch9_func, 428, 1, 2 },
+	{ ahc_patch0_func, 429, 1, 1 },
+	{ ahc_patch7_func, 432, 1, 1 },
+	{ ahc_patch7_func, 433, 1, 1 },
+	{ ahc_patch8_func, 434, 3, 3 },
+	{ ahc_patch6_func, 435, 1, 2 },
+	{ ahc_patch0_func, 436, 1, 1 },
+	{ ahc_patch9_func, 437, 1, 1 },
+	{ ahc_patch15_func, 438, 1, 2 },
+	{ ahc_patch13_func, 438, 1, 1 },
+	{ ahc_patch14_func, 440, 9, 4 },
+	{ ahc_patch9_func, 440, 1, 1 },
+	{ ahc_patch9_func, 447, 2, 1 },
+	{ ahc_patch0_func, 449, 4, 3 },
+	{ ahc_patch9_func, 449, 1, 2 },
+	{ ahc_patch0_func, 450, 3, 1 },
+	{ ahc_patch1_func, 454, 2, 1 },
+	{ ahc_patch7_func, 456, 10, 2 },
+	{ ahc_patch0_func, 466, 1, 1 },
+	{ ahc_patch8_func, 467, 109, 23 },
+	{ ahc_patch1_func, 469, 3, 2 },
+	{ ahc_patch0_func, 472, 5, 3 },
+	{ ahc_patch9_func, 472, 2, 2 },
+	{ ahc_patch0_func, 474, 3, 1 },
+	{ ahc_patch1_func, 479, 2, 2 },
+	{ ahc_patch0_func, 481, 6, 3 },
+	{ ahc_patch9_func, 481, 2, 2 },
+	{ ahc_patch0_func, 483, 3, 1 },
+	{ ahc_patch1_func, 489, 2, 2 },
+	{ ahc_patch0_func, 491, 9, 7 },
+	{ ahc_patch9_func, 491, 5, 6 },
+	{ ahc_patch19_func, 491, 1, 2 },
+	{ ahc_patch0_func, 492, 1, 1 },
+	{ ahc_patch19_func, 494, 1, 2 },
+	{ ahc_patch0_func, 495, 1, 1 },
+	{ ahc_patch0_func, 496, 4, 1 },
+	{ ahc_patch6_func, 500, 3, 2 },
+	{ ahc_patch0_func, 503, 1, 1 },
+	{ ahc_patch1_func, 506, 1, 1 },
+	{ ahc_patch6_func, 512, 1, 2 },
+	{ ahc_patch0_func, 513, 1, 1 },
+	{ ahc_patch20_func, 550, 7, 1 },
+	{ ahc_patch3_func, 578, 1, 2 },
+	{ ahc_patch0_func, 579, 1, 1 },
+	{ ahc_patch21_func, 582, 1, 1 },
+	{ ahc_patch8_func, 584, 104, 33 },
+	{ ahc_patch4_func, 585, 1, 1 },
+	{ ahc_patch1_func, 591, 2, 2 },
+	{ ahc_patch0_func, 593, 1, 1 },
+	{ ahc_patch1_func, 596, 1, 2 },
+	{ ahc_patch0_func, 597, 1, 1 },
+	{ ahc_patch9_func, 598, 3, 3 },
+	{ ahc_patch15_func, 599, 1, 1 },
+	{ ahc_patch0_func, 601, 4, 1 },
+	{ ahc_patch19_func, 609, 2, 2 },
+	{ ahc_patch0_func, 611, 1, 1 },
+	{ ahc_patch19_func, 615, 10, 3 },
+	{ ahc_patch5_func, 617, 8, 1 },
+	{ ahc_patch0_func, 625, 9, 2 },
+	{ ahc_patch5_func, 626, 8, 1 },
+	{ ahc_patch4_func, 636, 1, 2 },
+	{ ahc_patch0_func, 637, 1, 1 },
+	{ ahc_patch19_func, 638, 1, 2 },
+	{ ahc_patch0_func, 639, 3, 2 },
+	{ ahc_patch4_func, 641, 1, 1 },
+	{ ahc_patch5_func, 642, 1, 1 },
+	{ ahc_patch5_func, 645, 1, 1 },
+	{ ahc_patch5_func, 647, 1, 1 },
+	{ ahc_patch4_func, 649, 2, 2 },
+	{ ahc_patch0_func, 651, 2, 1 },
+	{ ahc_patch5_func, 653, 1, 1 },
+	{ ahc_patch5_func, 656, 1, 1 },
+	{ ahc_patch5_func, 659, 1, 1 },
+	{ ahc_patch19_func, 663, 1, 1 },
+	{ ahc_patch19_func, 666, 1, 1 },
+	{ ahc_patch4_func, 672, 1, 1 },
+	{ ahc_patch6_func, 675, 1, 2 },
+	{ ahc_patch0_func, 676, 1, 1 },
+	{ ahc_patch7_func, 688, 16, 1 },
+	{ ahc_patch4_func, 704, 20, 1 },
+	{ ahc_patch9_func, 725, 4, 2 },
+	{ ahc_patch0_func, 729, 4, 1 },
+	{ ahc_patch9_func, 733, 4, 2 },
+	{ ahc_patch0_func, 737, 3, 1 },
+	{ ahc_patch6_func, 743, 1, 1 },
+	{ ahc_patch22_func, 745, 14, 1 },
+	{ ahc_patch7_func, 759, 3, 1 },
+	{ ahc_patch9_func, 771, 24, 8 },
+	{ ahc_patch19_func, 775, 1, 2 },
+	{ ahc_patch0_func, 776, 1, 1 },
+	{ ahc_patch15_func, 781, 4, 2 },
+	{ ahc_patch0_func, 785, 7, 3 },
+	{ ahc_patch23_func, 785, 5, 2 },
+	{ ahc_patch0_func, 790, 2, 1 },
+	{ ahc_patch0_func, 795, 42, 3 },
+	{ ahc_patch18_func, 807, 18, 2 },
+	{ ahc_patch0_func, 825, 1, 1 },
+	{ ahc_patch4_func, 849, 1, 1 },
+	{ ahc_patch4_func, 850, 3, 2 },
+	{ ahc_patch0_func, 853, 1, 1 },
+	{ ahc_patch13_func, 854, 3, 1 },
+	{ ahc_patch4_func, 857, 12, 1 }
+};
+struct cs {
+	u_int16_t	begin;
+	u_int16_t	end;
+} critical_sections[] = {
+	{ 11, 18 },
+	{ 21, 30 },
+	{ 704, 720 },
+	{ 850, 853 },
+	{ 857, 863 },
+	{ 865, 867 },
+	{ 867, 869 }
+};
+const int num_critical_sections = sizeof(critical_sections)
+				 / sizeof(*critical_sections);
diff -Nru a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
--- a/drivers/scsi/dpt_i2o.c	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/dpt_i2o.c	Fri May 24 18:55:34 2002
@@ -3319,5 +3319,4 @@
 
 static Scsi_Host_Template driver_template = DPT_I2O;
 #include "scsi_module.c"
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/scsi/esp.c b/drivers/scsi/esp.c
--- a/drivers/scsi/esp.c	Fri May 24 18:55:36 2002
+++ b/drivers/scsi/esp.c	Fri May 24 18:55:36 2002
@@ -4345,4 +4345,3 @@
 
 #include "scsi_module.c"
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c
--- a/drivers/scsi/fcal.c	Fri May 24 18:55:33 2002
+++ b/drivers/scsi/fcal.c	Fri May 24 18:55:33 2002
@@ -300,4 +300,3 @@
 
 #include "scsi_module.c"
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/scsi/i60uscsi.c b/drivers/scsi/i60uscsi.c
--- a/drivers/scsi/i60uscsi.c	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/i60uscsi.c	Fri May 24 18:55:34 2002
@@ -69,7 +69,7 @@
  **************************************************************************/
 
 #include <linux/version.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <asm/io.h>
 #include "i60uscsi.h"
 
diff -Nru a/drivers/scsi/i91uscsi.c b/drivers/scsi/i91uscsi.c
--- a/drivers/scsi/i91uscsi.c	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/i91uscsi.c	Fri May 24 18:55:34 2002
@@ -88,7 +88,7 @@
 #include <linux/version.h>
 #endif
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/delay.h>
 #include <linux/blk.h>
 #include <asm/io.h>
diff -Nru a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
--- a/drivers/scsi/ide-scsi.c	Fri May 24 18:55:33 2002
+++ b/drivers/scsi/ide-scsi.c	Fri May 24 18:55:33 2002
@@ -42,6 +42,7 @@
 #include <linux/hdreg.h>
 #include <linux/slab.h>
 #include <linux/ide.h>
+#include <linux/atapi.h>
 
 #include <asm/io.h>
 #include <asm/bitops.h>
@@ -54,21 +55,6 @@
 
 #define IDESCSI_DEBUG_LOG		0
 
-typedef struct idescsi_pc_s {
-	u8 c[12];				/* Actual packet bytes */
-	int request_transfer;			/* Bytes to transfer */
-	int actually_transferred;		/* Bytes actually transferred */
-	int buffer_size;			/* Size of our data buffer */
-	byte *buffer;				/* Data buffer */
-	byte *current_position;			/* Pointer into the above buffer */
-	struct scatterlist *sg;			/* Scatter gather table */
-	int b_count;				/* Bytes transferred from current entry */
-	Scsi_Cmnd *scsi_cmd;			/* SCSI command */
-	void (*done)(Scsi_Cmnd *);		/* Scsi completion routine */
-	unsigned long flags;			/* Status/Action flags */
-	unsigned long timeout;			/* Command timeout */
-} idescsi_pc_t;
-
 /*
  *	Packet command status bits.
  */
@@ -88,8 +74,8 @@
 #define IDESCSI_LOG_CMD			0	/* Log SCSI commands */
 
 typedef struct {
-	ide_drive_t *drive;
-	idescsi_pc_t *pc;			/* Current packet command */
+	struct ata_device *drive;
+	struct atapi_packet_command *pc;	/* Current packet command */
 	unsigned long flags;			/* Status/Action flags */
 	unsigned long transform;		/* SCSI cmd translation layer */
 	unsigned long log;			/* log flags */
@@ -111,61 +97,49 @@
 #define IDESCSI_IREASON_COD	0x1		/* Information transferred is command */
 #define IDESCSI_IREASON_IO	0x2		/* The device requests us to read */
 
-static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
-{
-	while (bcount--)
-		IN_BYTE (IDE_DATA_REG);
-}
-
-static void idescsi_output_zeros (ide_drive_t *drive, unsigned int bcount)
-{
-	while (bcount--)
-		OUT_BYTE (0, IDE_DATA_REG);
-}
-
 /*
  *	PIO data transfer routines using the scatter gather table.
  */
-static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
+static void idescsi_input_buffers(struct ata_device *drive, struct atapi_packet_command *pc, unsigned int bcount)
 {
 	int count;
 	char *buf;
 
 	while (bcount) {
-		if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
+		if (pc->s.sg - (struct scatterlist *) pc->s.scsi_cmd->request_buffer > pc->s.scsi_cmd->use_sg) {
 			printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
-			idescsi_discard_data (drive, bcount);
+			atapi_discard_data(drive, bcount);
 			return;
 		}
-		count = min(pc->sg->length - pc->b_count, bcount);
-		buf = page_address(pc->sg->page) + pc->sg->offset;
-		atapi_read(drive, buf + pc->b_count, count);
-		bcount -= count; pc->b_count += count;
-		if (pc->b_count == pc->sg->length) {
-			pc->sg++;
-			pc->b_count = 0;
+		count = min(pc->s.sg->length - pc->s.b_count, bcount);
+		buf = page_address(pc->s.sg->page) + pc->s.sg->offset;
+		atapi_read(drive, buf + pc->s.b_count, count);
+		bcount -= count; pc->s.b_count += count;
+		if (pc->s.b_count == pc->s.sg->length) {
+			pc->s.sg++;
+			pc->s.b_count = 0;
 		}
 	}
 }
 
-static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
+static void idescsi_output_buffers(struct ata_device *drive, struct atapi_packet_command *pc, unsigned int bcount)
 {
 	int count;
 	char *buf;
 
 	while (bcount) {
-		if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
+		if (pc->s.sg - (struct scatterlist *) pc->s.scsi_cmd->request_buffer > pc->s.scsi_cmd->use_sg) {
 			printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
-			idescsi_output_zeros (drive, bcount);
+			atapi_write_zeros(drive, bcount);
 			return;
 		}
-		count = min(pc->sg->length - pc->b_count, bcount);
-		buf = page_address(pc->sg->page) + pc->sg->offset;
-		atapi_write(drive, buf + pc->b_count, count);
-		bcount -= count; pc->b_count += count;
-		if (pc->b_count == pc->sg->length) {
-			pc->sg++;
-			pc->b_count = 0;
+		count = min(pc->s.sg->length - pc->s.b_count, bcount);
+		buf = page_address(pc->s.sg->page) + pc->s.sg->offset;
+		atapi_write(drive, buf + pc->s.b_count, count);
+		bcount -= count; pc->s.b_count += count;
+		if (pc->s.b_count == pc->s.sg->length) {
+			pc->s.sg++;
+			pc->s.b_count = 0;
 		}
 	}
 }
@@ -174,9 +148,11 @@
  *	Most of the SCSI commands are supported directly by ATAPI devices.
  *	idescsi_transform_pc handles the few exceptions.
  */
-static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
+static inline void idescsi_transform_pc1(struct ata_device *drive, struct atapi_packet_command *pc)
 {
-	u8 *c = pc->c, *scsi_buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
+	u8 *c = pc->c;
+	char *scsi_buf = pc->buffer;
+	u8 *sc = pc->s.scsi_cmd->cmnd;
 	char *atapi_buf;
 
 	if (!test_bit(PC_TRANSFORM, &pc->flags))
@@ -212,11 +188,11 @@
 	}
 }
 
-static inline void idescsi_transform_pc2 (ide_drive_t *drive, idescsi_pc_t *pc)
+static inline void idescsi_transform_pc2(struct ata_device *drive, struct atapi_packet_command *pc)
 {
 	u8 *atapi_buf = pc->buffer;
-	u8 *sc = pc->scsi_cmd->cmnd;
-	u8 *scsi_buf = pc->scsi_cmd->request_buffer;
+	u8 *sc = pc->s.scsi_cmd->cmnd;
+	u8 *scsi_buf = pc->s.scsi_cmd->request_buffer;
 
 	if (!test_bit(PC_TRANSFORM, &pc->flags))
 		return;
@@ -261,7 +237,7 @@
 static int idescsi_end_request(struct ata_device *drive, struct request *rq, int uptodate)
 {
 	idescsi_scsi_t *scsi = drive->driver_data;
-	idescsi_pc_t *pc = (idescsi_pc_t *) rq->special;
+	struct atapi_packet_command *pc = (struct atapi_packet_command *) rq->special;
 	int log = test_bit(IDESCSI_LOG_CMD, &scsi->log);
 	struct Scsi_Host *host;
 	u8 *scsi_buf;
@@ -273,28 +249,28 @@
 	}
 	ide_end_drive_cmd(drive, rq, 0, 0);
 	if (rq->errors >= ERROR_MAX) {
-		pc->scsi_cmd->result = DID_ERROR << 16;
+		pc->s.scsi_cmd->result = DID_ERROR << 16;
 		if (log)
-			printk ("ide-scsi: %s: I/O error for %lu\n", drive->name, pc->scsi_cmd->serial_number);
+			printk ("ide-scsi: %s: I/O error for %lu\n", drive->name, pc->s.scsi_cmd->serial_number);
 	} else if (rq->errors) {
-		pc->scsi_cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16);
+		pc->s.scsi_cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16);
 		if (log)
-			printk ("ide-scsi: %s: check condition for %lu\n", drive->name, pc->scsi_cmd->serial_number);
+			printk ("ide-scsi: %s: check condition for %lu\n", drive->name, pc->s.scsi_cmd->serial_number);
 	} else {
-		pc->scsi_cmd->result = DID_OK << 16;
+		pc->s.scsi_cmd->result = DID_OK << 16;
 		idescsi_transform_pc2 (drive, pc);
 		if (log) {
-			printk ("ide-scsi: %s: suc %lu", drive->name, pc->scsi_cmd->serial_number);
+			printk ("ide-scsi: %s: suc %lu", drive->name, pc->s.scsi_cmd->serial_number);
 			if (!test_bit(PC_WRITING, &pc->flags) && pc->actually_transferred && pc->actually_transferred <= 1024 && pc->buffer) {
 				printk(", rst = ");
-				scsi_buf = pc->scsi_cmd->request_buffer;
-				hexdump(scsi_buf, min(16U, pc->scsi_cmd->request_bufflen));
+				scsi_buf = pc->s.scsi_cmd->request_buffer;
+				hexdump(scsi_buf, min(16U, pc->s.scsi_cmd->request_bufflen));
 			} else printk("\n");
 		}
 	}
-	host = pc->scsi_cmd->host;
+	host = pc->s.scsi_cmd->host;
 	spin_lock_irqsave(host->host_lock, flags);
-	pc->done(pc->scsi_cmd);
+	pc->s.done(pc->s.scsi_cmd);
 	spin_unlock_irqrestore(host->host_lock, flags);
 	idescsi_free_bio (rq->bio);
 	kfree(pc); kfree(rq);
@@ -303,9 +279,9 @@
 	return 0;
 }
 
-static inline unsigned long get_timeout(idescsi_pc_t *pc)
+static inline unsigned long get_timeout(struct atapi_packet_command *pc)
 {
-	return max((unsigned long) WAIT_CMD, pc->timeout - jiffies);
+	return max((unsigned long) WAIT_CMD, pc->s.timeout - jiffies);
 }
 
 /*
@@ -316,17 +292,17 @@
 	idescsi_scsi_t *scsi = drive->driver_data;
 	byte status, ireason;
 	int bcount;
-	idescsi_pc_t *pc=scsi->pc;
+	struct atapi_packet_command *pc = scsi->pc;
 	unsigned int temp;
 
 #if IDESCSI_DEBUG_LOG
 	printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
-#endif /* IDESCSI_DEBUG_LOG */
+#endif
 
-	if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
+	if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
 #if IDESCSI_DEBUG_LOG
 		printk ("ide-scsi: %s: DMA complete\n", drive->name);
-#endif /* IDESCSI_DEBUG_LOG */
+#endif
 		pc->actually_transferred=pc->request_transfer;
 		udma_stop(drive);
 	}
@@ -357,7 +333,7 @@
 				temp = pc->buffer_size - pc->actually_transferred;
 				if (temp) {
 					clear_bit(PC_WRITING, &pc->flags);
-					if (pc->sg)
+					if (pc->s.sg)
 						idescsi_input_buffers(drive, pc, temp);
 					else
 						atapi_read(drive, pc->current_position, temp);
@@ -365,24 +341,24 @@
 				}
 				pc->actually_transferred += temp;
 				pc->current_position += temp;
-				idescsi_discard_data (drive,bcount - temp);
+				atapi_discard_data(drive,bcount - temp);
 				ide_set_handler(drive, idescsi_pc_intr, get_timeout(pc), NULL);
 				return ide_started;
 			}
 #if IDESCSI_DEBUG_LOG
 			printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n");
-#endif /* IDESCSI_DEBUG_LOG */
+#endif
 		}
 	}
 	if (ireason & IDESCSI_IREASON_IO) {
 		clear_bit(PC_WRITING, &pc->flags);
-		if (pc->sg)
+		if (pc->s.sg)
 			idescsi_input_buffers (drive, pc, bcount);
 		else
 			atapi_read(drive,pc->current_position,bcount);
 	} else {
 		set_bit(PC_WRITING, &pc->flags);
-		if (pc->sg)
+		if (pc->s.sg)
 			idescsi_output_buffers (drive, pc, bcount);
 		else
 			atapi_write(drive,pc->current_position,bcount);
@@ -397,7 +373,7 @@
 static ide_startstop_t idescsi_transfer_pc(struct ata_device *drive, struct request *rq)
 {
 	idescsi_scsi_t *scsi = drive->driver_data;
-	idescsi_pc_t *pc = scsi->pc;
+	struct atapi_packet_command *pc = scsi->pc;
 	byte ireason;
 	ide_startstop_t startstop;
 
@@ -418,7 +394,8 @@
 /*
  *	Issue a packet command
  */
-static ide_startstop_t idescsi_issue_pc(struct ata_device *drive, struct request *rq, idescsi_pc_t *pc)
+static ide_startstop_t idescsi_issue_pc(struct ata_device *drive, struct request *rq,
+		struct atapi_packet_command *pc)
 {
 	idescsi_scsi_t *scsi = drive->driver_data;
 	int bcount;
@@ -465,10 +442,10 @@
 #if IDESCSI_DEBUG_LOG
 	printk (KERN_INFO "rq_status: %d, rq_dev: %u, cmd: %d, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->cmd,rq->errors);
 	printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %ld\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors);
-#endif /* IDESCSI_DEBUG_LOG */
+#endif
 
 	if (rq->flags & REQ_SPECIAL) {
-		return idescsi_issue_pc(drive, rq, (idescsi_pc_t *) rq->special);
+		return idescsi_issue_pc(drive, rq, (struct atapi_packet_command *) rq->special);
 	}
 	blk_dump_rq_flags(rq, "ide-scsi: unsup command");
 	idescsi_end_request(drive, rq, 0);
@@ -486,16 +463,14 @@
 	MOD_DEC_USE_COUNT;
 }
 
-static ide_drive_t *idescsi_drives[MAX_HWIFS * MAX_DRIVES];
+static struct ata_device *idescsi_drives[MAX_HWIFS * MAX_DRIVES];
 static int idescsi_initialized = 0;
 
 /*
  *	Driver initialization.
  */
-static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi, int id)
+static void idescsi_setup(struct ata_device *drive, idescsi_scsi_t *scsi, int id)
 {
-	MOD_INC_USE_COUNT;
-
 	idescsi_drives[id] = drive;
 	drive->driver_data = scsi;
 	drive->ready_stat = 0;
@@ -510,7 +485,7 @@
 #endif
 }
 
-static int idescsi_cleanup (ide_drive_t *drive)
+static int idescsi_cleanup(struct ata_device *drive)
 {
 	idescsi_scsi_t *scsi = drive->driver_data;
 
@@ -521,17 +496,20 @@
 	return 0;
 }
 
-static void idescsi_revalidate(ide_drive_t *_dummy)
+static void idescsi_revalidate(struct ata_device *_dummy)
 {
 	/* The partition information will be handled by the SCSI layer.
 	 */
 }
 
+static void idescsi_attach(struct ata_device *drive);
+
 /*
  *	IDE subdriver functions, registered with ide.c
  */
 static struct ata_operations idescsi_driver = {
 	owner:			THIS_MODULE,
+	attach:			idescsi_attach,
 	cleanup:		idescsi_cleanup,
 	standby:		NULL,
 	do_request:		idescsi_do_request,
@@ -544,45 +522,40 @@
 	capacity:		NULL,
 };
 
-/*
- *	idescsi_init will register the driver for each scsi.
- */
-int idescsi_init(void)
+static void idescsi_attach(struct ata_device *drive)
 {
-	ide_drive_t *drive;
 	idescsi_scsi_t *scsi;
-	/* FIXME: The following is just plain wrong, since those are definitely *not* the
-	 * media types supported by the ATA layer */
-	byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255};
-	int i, failed, id;
+	int i, id;
+	char *req;
+	struct ata_channel *channel;
+	int unit;
 
 	if (idescsi_initialized)
-		return 0;
+		return;
 	idescsi_initialized = 1;
 	for (i = 0; i < MAX_HWIFS * MAX_DRIVES; i++)
 		idescsi_drives[i] = NULL;
-	MOD_INC_USE_COUNT;
-	for (i = 0; media[i] != 255; i++) {
-		failed = 0;
-		while ((drive = ide_scan_devices (media[i], "ide-scsi", NULL, failed++)) != NULL) {
-
-			if ((scsi = (idescsi_scsi_t *) kmalloc (sizeof (idescsi_scsi_t), GFP_KERNEL)) == NULL) {
-				printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
-				continue;
-			}
-			if (ide_register_subdriver (drive, &idescsi_driver)) {
-				printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
-				kfree (scsi);
-				continue;
-			}
-			for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
-				idescsi_setup (drive, scsi, id);
-			failed--;
-		}
+
+	req = drive->driver_req;
+	if (req[0] != '\0' && strcmp(req, "ide-scsi"))
+		return;
+
+	if ((scsi = (idescsi_scsi_t *) kmalloc (sizeof (idescsi_scsi_t), GFP_KERNEL)) == NULL) {
+		printk(KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
+		return;
 	}
-	revalidate_drives();
-	MOD_DEC_USE_COUNT;
-	return 0;
+	if (ide_register_subdriver (drive, &idescsi_driver)) {
+		printk(KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
+		kfree (scsi);
+		return;
+	}
+	for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
+	idescsi_setup (drive, scsi, id);
+
+	channel = drive->channel;
+	unit = drive - channel->drives;
+
+	ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
 }
 
 int idescsi_detect (Scsi_Host_Template *host_template)
@@ -606,7 +579,7 @@
 
 int idescsi_release (struct Scsi_Host *host)
 {
-	ide_drive_t *drive;
+	struct ata_device *drive;
 	int id;
 
 	for (id = 0; id < MAX_HWIFS * MAX_DRIVES; id++) {
@@ -625,7 +598,7 @@
 
 int idescsi_ioctl (Scsi_Device *dev, int cmd, void *arg)
 {
-	ide_drive_t *drive = idescsi_drives[dev->id];
+	struct ata_device *drive = idescsi_drives[dev->id];
 	idescsi_scsi_t *scsi = drive->driver_data;
 
 	if (cmd == SG_SET_TRANSFORM) {
@@ -662,25 +635,29 @@
 	return NULL;
 }
 
-static inline int idescsi_set_direction (idescsi_pc_t *pc)
+static inline int idescsi_set_direction(struct atapi_packet_command *pc)
 {
 	switch (pc->c[0]) {
-		case READ_6: case READ_10: case READ_12:
-			clear_bit (PC_WRITING, &pc->flags);
+		case READ_6:
+		case READ_10:
+		case READ_12:
+			clear_bit(PC_WRITING, &pc->flags);
 			return 0;
-		case WRITE_6: case WRITE_10: case WRITE_12:
-			set_bit (PC_WRITING, &pc->flags);
+		case WRITE_6:
+		case WRITE_10:
+		case WRITE_12:
+			set_bit(PC_WRITING, &pc->flags);
 			return 0;
 		default:
 			return 1;
 	}
 }
 
-static inline struct bio *idescsi_dma_bio(ide_drive_t *drive, idescsi_pc_t *pc)
+static inline struct bio *idescsi_dma_bio(struct ata_device *drive, struct atapi_packet_command *pc)
 {
 	struct bio *bh = NULL, *first_bh = NULL;
-	int segments = pc->scsi_cmd->use_sg;
-	struct scatterlist *sg = pc->scsi_cmd->request_buffer;
+	int segments = pc->s.scsi_cmd->use_sg;
+	struct scatterlist *sg = pc->s.scsi_cmd->request_buffer;
 
 	if (!drive->using_dma || !pc->request_transfer || pc->request_transfer % 1024)
 		return NULL;
@@ -691,7 +668,7 @@
 			return NULL;
 #if IDESCSI_DEBUG_LOG
 		printk ("ide-scsi: %s: building DMA table, %d segments, %dkB total\n", drive->name, segments, pc->request_transfer >> 10);
-#endif /* IDESCSI_DEBUG_LOG */
+#endif
 		while (segments--) {
 			bh->bi_io_vec[0].bv_page = sg->page;
 			bh->bi_io_vec[0].bv_len = sg->length;
@@ -705,16 +682,16 @@
 			return NULL;
 #if IDESCSI_DEBUG_LOG
 		printk ("ide-scsi: %s: building DMA table for a single buffer (%dkB)\n", drive->name, pc->request_transfer >> 10);
-#endif /* IDESCSI_DEBUG_LOG */
-		bh->bi_io_vec[0].bv_page = virt_to_page(pc->scsi_cmd->request_buffer);
+#endif
+		bh->bi_io_vec[0].bv_page = virt_to_page(pc->s.scsi_cmd->request_buffer);
 		bh->bi_io_vec[0].bv_len = pc->request_transfer;
-		bh->bi_io_vec[0].bv_offset = (unsigned long) pc->scsi_cmd->request_buffer & ~PAGE_MASK;
+		bh->bi_io_vec[0].bv_offset = (unsigned long) pc->s.scsi_cmd->request_buffer & ~PAGE_MASK;
 		bh->bi_size = pc->request_transfer;
 	}
 	return first_bh;
 }
 
-static inline int should_transform(ide_drive_t *drive, Scsi_Cmnd *cmd)
+static inline int should_transform(struct ata_device *drive, Scsi_Cmnd *cmd)
 {
 	idescsi_scsi_t *scsi = drive->driver_data;
 
@@ -725,18 +702,18 @@
 
 int idescsi_queue (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
 {
-	ide_drive_t *drive = idescsi_drives[cmd->target];
+	struct ata_device *drive = idescsi_drives[cmd->target];
 	idescsi_scsi_t *scsi;
 	struct request *rq = NULL;
-	idescsi_pc_t *pc = NULL;
+	struct atapi_packet_command *pc = NULL;
 
 	if (!drive) {
 		printk (KERN_ERR "ide-scsi: drive id %d not present\n", cmd->target);
 		goto abort;
 	}
 	scsi = drive->driver_data;
-	pc = kmalloc (sizeof (idescsi_pc_t), GFP_ATOMIC);
-	rq = kmalloc (sizeof (struct request), GFP_ATOMIC);
+	pc = kmalloc(sizeof(*pc), GFP_ATOMIC);
+	rq = kmalloc(sizeof(*rq), GFP_ATOMIC);
 	if (rq == NULL || pc == NULL) {
 		printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name);
 		goto abort;
@@ -747,16 +724,16 @@
 	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
 	if (cmd->use_sg) {
 		pc->buffer = NULL;
-		pc->sg = cmd->request_buffer;
+		pc->s.sg = cmd->request_buffer;
 	} else {
 		pc->buffer = cmd->request_buffer;
-		pc->sg = NULL;
+		pc->s.sg = NULL;
 	}
-	pc->b_count = 0;
+	pc->s.b_count = 0;
 	pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
-	pc->scsi_cmd = cmd;
-	pc->done = done;
-	pc->timeout = jiffies + cmd->timeout_per_command;
+	pc->s.scsi_cmd = cmd;
+	pc->s.done = done;
+	pc->s.timeout = jiffies + cmd->timeout_per_command;
 
 	if (should_transform(drive, cmd))
 		set_bit(PC_TRANSFORM, &pc->flags);
@@ -797,7 +774,7 @@
 
 int idescsi_bios (Disk *disk, kdev_t dev, int *parm)
 {
-	ide_drive_t *drive = idescsi_drives[disk->device->id];
+	struct ata_device *drive = idescsi_drives[disk->device->id];
 
 	if (drive->bios_cyl && drive->bios_head && drive->bios_sect) {
 		parm[0] = drive->bios_head;
@@ -826,38 +803,31 @@
 	emulated:	1,
 };
 
-static int __init init_idescsi_module(void)
+
+static int __init idescsi_init(void)
 {
-	idescsi_init();
+	int ret;
+	ret = ata_driver_module(&idescsi_driver);
 	scsi_register_host(&idescsi_template);
 	return 0;
 }
 
 static void __exit exit_idescsi_module(void)
 {
-	ide_drive_t *drive;
-	byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255};
-	int i, failed;
-
 	scsi_unregister_host(&idescsi_template);
 
-	/* FIXME: The media types scanned here have literally nothing to do
-	 * with the media types used by the overall ATA code!
-	 *
-	 * This is basically showing us, that there is something wrong with the
-	 * ide_scan_devices function.
-	 */
+#if 0
+	/* FIXME: what about this cleanup stuff here? This all should be done
+	 * on close time perhaps? */
 
-	for (i = 0; media[i] != 255; i++) {
-		failed = 0;
-		while ((drive = ide_scan_devices (media[i], "ide-scsi", &idescsi_driver, failed)) != NULL)
-			if (idescsi_cleanup (drive)) {
-				printk ("%s: exit_idescsi_module() called while still busy\n", drive->name);
-				failed++;
-			}
+	if (idescsi_cleanup (drive)) {
+		printk ("%s: exit_idescsi_module() called while still busy\n", drive->name);
 	}
+#endif
+
+	unregister_ata_driver(&idescsi_driver);
 }
 
-module_init(init_idescsi_module);
+module_init(idescsi_init);
 module_exit(exit_idescsi_module);
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
--- a/drivers/scsi/pluto.c	Fri May 24 18:55:35 2002
+++ b/drivers/scsi/pluto.c	Fri May 24 18:55:35 2002
@@ -339,4 +339,3 @@
 
 #include "scsi_module.c"
 
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
--- a/drivers/scsi/qlogicpti.c	Fri May 24 18:55:33 2002
+++ b/drivers/scsi/qlogicpti.c	Fri May 24 18:55:33 2002
@@ -1533,5 +1533,3 @@
 static Scsi_Host_Template driver_template = QLOGICPTI;
 
 #include "scsi_module.c"
-
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c
--- a/drivers/scsi/scsicam.c	Fri May 24 18:55:33 2002
+++ b/drivers/scsi/scsicam.c	Fri May 24 18:55:33 2002
@@ -16,6 +16,7 @@
 #include <linux/genhd.h>
 #include <linux/kernel.h>
 #include <linux/blk.h>
+#include <linux/buffer_head.h>
 #include <asm/unaligned.h>
 #include "scsi.h"
 #include "hosts.h"
diff -Nru a/drivers/scsi/sd.c b/drivers/scsi/sd.c
--- a/drivers/scsi/sd.c	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/sd.c	Fri May 24 18:55:34 2002
@@ -1242,11 +1242,6 @@
 	}
 
 	for (k = 0; k < N_USED_SD_MAJORS; k++) {
-		request_queue_t *q = blk_get_queue(mk_kdev(SD_MAJOR(k), 0));
-		blk_queue_hardsect_size(q, 512);
- 	}
-
-	for (k = 0; k < N_USED_SD_MAJORS; k++) {
 		int N = SCSI_DISKS_PER_MAJOR;
 
 		sd_gendisks[k] = sd_gendisk;
diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
--- a/drivers/scsi/sr.c	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/sr.c	Fri May 24 18:55:34 2002
@@ -697,8 +697,6 @@
 
 static int sr_init()
 {
-	int i;
-
 	if (sr_template.dev_noticed == 0)
 		return 0;
 
@@ -723,8 +721,7 @@
 		goto cleanup_cds;
 	memset(sr_sizes, 0, sr_template.dev_max * sizeof(int));
 	return 0;
-cleanup_sizes:
-	kfree(sr_sizes);
+
 cleanup_cds:
 	kfree(scsi_CDs);
 cleanup_devfs:
diff -Nru a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
--- a/drivers/scsi/sr_ioctl.c	Fri May 24 18:55:36 2002
+++ b/drivers/scsi/sr_ioctl.c	Fri May 24 18:55:36 2002
@@ -5,6 +5,7 @@
 #include <asm/uaccess.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>		/* for invalidate_buffers() */
 
 #include <linux/blk.h>
 #include <linux/blkpg.h>
diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
--- a/drivers/scsi/st.c	Fri May 24 18:55:36 2002
+++ b/drivers/scsi/st.c	Fri May 24 18:55:36 2002
@@ -86,8 +86,6 @@
 MODULE_PARM(max_sg_segs, "i");
 MODULE_PARM_DESC(max_sg_segs, "Maximum number of scatter/gather segments to use (32)");
 
-EXPORT_NO_SYMBOLS;
-
 #ifndef MODULE
 static struct st_dev_parm {
 	char *name;
diff -Nru a/drivers/scsi/sym53c8xx_2/Makefile b/drivers/scsi/sym53c8xx_2/Makefile
--- a/drivers/scsi/sym53c8xx_2/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/scsi/sym53c8xx_2/Makefile	Fri May 24 18:55:34 2002
@@ -1,7 +1,5 @@
 # Makefile for the NCR/SYMBIOS/LSI 53C8XX PCI SCSI controllers driver.
 
-O_TARGET := sym53c8xx_2.o
-
 sym53c8xx-objs := sym_fw.o sym_glue.o sym_hipd.o sym_malloc.o sym_misc.o sym_nvram.o
 obj-$(CONFIG_SCSI_SYM53C8XX_2) := sym53c8xx.o
 
diff -Nru a/drivers/sgi/Makefile b/drivers/sgi/Makefile
--- a/drivers/sgi/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/sgi/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the linux kernel.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-L_TARGET := sgi.a
 
 #
 # Character and Audio devices for SGI machines.
diff -Nru a/drivers/sgi/char/sgiserial.c b/drivers/sgi/char/sgiserial.c
--- a/drivers/sgi/char/sgiserial.c	Fri May 24 18:55:34 2002
+++ b/drivers/sgi/char/sgiserial.c	Fri May 24 18:55:34 2002
@@ -422,10 +422,6 @@
 		} else if (ch == 1) {
 			show_state();
 			return;
-		} else if (ch == 2) {
-			printk("%ld buffermem pages\n",
-					nr_buffermem_pages());
-			return;
 		}
 	}
 	/* Look for kgdb 'stop' character, consult the gdb documentation
diff -Nru a/drivers/tc/Makefile b/drivers/tc/Makefile
--- a/drivers/tc/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/tc/Makefile	Fri May 24 18:55:34 2002
@@ -1,11 +1,6 @@
 #
 # Makefile for the linux kernel.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
 # All of the (potential) objects that export symbols.
 # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
@@ -14,27 +9,9 @@
 
 # Object file lists.
 
-obj-y		:=
-obj-m		:=
-obj-n		:=
-obj-		:=
-
 obj-$(CONFIG_TC) += tc.o
 obj-$(CONFIG_ZS) += zs.o
 obj-$(CONFIG_VT) += lk201.o lk201-map.o lk201-remap.o
-
-# Files that are both resident and modular: remove from modular.
-
-obj-m		:= $(filter-out $(obj-y), $(obj-m))
-
-# Translate to Rules.make lists.
-
-L_TARGET	:= tc.a
-
-L_OBJS		:= $(sort $(filter-out $(export-objs), $(obj-y)))
-LX_OBJS		:= $(sort $(filter     $(export-objs), $(obj-y)))
-M_OBJS		:= $(sort $(filter-out $(export-objs), $(obj-m)))
-MX_OBJS		:= $(sort $(filter     $(export-objs), $(obj-m)))
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/usb/Makefile b/drivers/usb/Makefile
--- a/drivers/usb/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/usb/Makefile	Fri May 24 18:55:36 2002
@@ -9,16 +9,18 @@
 
 subdir-$(CONFIG_USB)		+= core
 
-subdir-$(CONFIG_USB_EHCI_HCD)	+= host
-subdir-$(CONFIG_USB_OHCI_HCD)	+= host
-subdir-$(CONFIG_USB_OHCI)	+= host
-subdir-$(CONFIG_USB_UHCI_ALT)	+= host
-subdir-$(CONFIG_USB_UHCI)	+= host
+subdir-$(CONFIG_USB_EHCI_HCD)		+= host
+subdir-$(CONFIG_USB_OHCI_HCD)		+= host
+subdir-$(CONFIG_USB_OHCI)		+= host
+subdir-$(CONFIG_USB_UHCI_ALT)		+= host
+subdir-$(CONFIG_USB_UHCI_HCD_ALT)	+= host
+subdir-$(CONFIG_USB_UHCI_HCD)		+= host
+subdir-$(CONFIG_USB_UHCI)		+= host
 
-subdir-$(CONFIG_USB_ACM)	+= class
-subdir-$(CONFIG_USB_AUDIO)	+= class
+subdir-$(CONFIG_USB_ACM)		+= class
+subdir-$(CONFIG_USB_AUDIO)		+= class
 subdir-$(CONFIG_USB_BLUETOOTH_TTY)	+= class
-subdir-$(CONFIG_USB_PRINTER)	+= class
+subdir-$(CONFIG_USB_PRINTER)		+= class
 
 subdir-$(CONFIG_USB_STORAGE)	+= storage
 
diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
--- a/drivers/usb/class/audio.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/class/audio.c	Fri May 24 18:55:35 2002
@@ -1221,6 +1221,7 @@
 		offs += cnt;
 		cp += cnt;
 	}
+	urb->interval = 1;
 	if (err)
 		u->dma.error++;
 	if (u->dma.mapped) {
@@ -1291,6 +1292,7 @@
 		urb->iso_frame_desc[i].length = 3;
 		urb->iso_frame_desc[i].offset = offs;
 	}
+	urb->interval = 1;
 	return 0;
 }
 
diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
--- a/drivers/usb/class/bluetty.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/class/bluetty.c	Fri May 24 18:55:34 2002
@@ -104,17 +104,14 @@
 
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
+#include <asm/uaccess.h>
 
 #define DEBUG
 #include <linux/usb.h>
diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
--- a/drivers/usb/class/cdc-acm.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/class/cdc-acm.c	Fri May 24 18:55:33 2002
@@ -43,18 +43,15 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/smp_lock.h>
+#include <asm/uaccess.h>
 #undef DEBUG
 #include <linux/usb.h>
 #include <asm/byteorder.h>
diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
--- a/drivers/usb/core/devio.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/core/devio.c	Fri May 24 18:55:35 2002
@@ -892,7 +892,6 @@
 		free_async(as);
 		return -ENOMEM;
 	}
-        as->urb->next = NULL;
         as->urb->dev = ps->dev;
         as->urb->pipe = (uurb.type << 30) | __create_pipe(ps->dev, uurb.endpoint & 0xf) | (uurb.endpoint & USB_DIR_IN);
         as->urb->transfer_flags = uurb.flags;
diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/core/hcd.c	Fri May 24 18:55:36 2002
@@ -23,7 +23,9 @@
  */
 
 #include <linux/config.h>
+#include <linux/version.h>
 #include <linux/module.h>
+#include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
@@ -1407,11 +1409,6 @@
 	if (urb->transfer_buffer_length < 0)
 		return -EINVAL;
 
-	if (urb->next) {
-		warn ("use explicit queuing not urb->next");
-		return -EINVAL;
-	}
-
 #ifdef DEBUG
 	/* stuff that drivers shouldn't do, but which shouldn't
 	 * cause problems in HCDs if they get it wrong.
@@ -1785,10 +1782,6 @@
  * HCDs must not use this for periodic URBs that are still scheduled
  * and will be reissued.  They should just call their completion handlers
  * until the urb is returned to the device driver by unlinking.
- *
- * NOTE that no urb->next processing is done, even for isochronous URBs.
- * ISO streaming functionality can be achieved by having completion handlers
- * re-queue URBs.  Such explicit queuing doesn't discard error reports.
  */
 void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb)
 {
diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/core/hub.c	Fri May 24 18:55:35 2002
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/ioctl.h>
 #ifdef CONFIG_USB_DEBUG
 	#define DEBUG
 #else
diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
--- a/drivers/usb/core/inode.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/core/inode.c	Fri May 24 18:55:33 2002
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/usb.h>
+#include <linux/namei.h>
 #include <linux/usbdevice_fs.h>
 #include <linux/smp_lock.h>
 #include <asm/byteorder.h>
diff -Nru a/drivers/usb/core/usb-debug.c b/drivers/usb/core/usb-debug.c
--- a/drivers/usb/core/usb-debug.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/core/usb-debug.c	Fri May 24 18:55:35 2002
@@ -184,7 +184,6 @@
 void usb_dump_urb (struct urb *urb)
 {
 	printk ("urb                   :%p\n", urb);
-	printk ("next                  :%p\n", urb->next);
 	printk ("dev                   :%p\n", urb->dev);
 	printk ("pipe                  :%08X\n", urb->pipe);
 	printk ("status                :%d\n", urb->status);
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/core/usb.c	Fri May 24 18:55:36 2002
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
+#include <linux/errno.h>
 #include <asm/byteorder.h>
 
 #ifdef CONFIG_USB_DEBUG
diff -Nru a/drivers/usb/host/Config.in b/drivers/usb/host/Config.in
--- a/drivers/usb/host/Config.in	Fri May 24 18:55:34 2002
+++ b/drivers/usb/host/Config.in	Fri May 24 18:55:34 2002
@@ -10,12 +10,12 @@
 if [ "$CONFIG_USB_UHCI_HCD" != "y" ]; then
    dep_tristate '  UHCI HCD Alternate (most Intel and VIA) support (EXPERIMENTAL)' CONFIG_USB_UHCI_HCD_ALT $CONFIG_USB $CONFIG_EXPERIMENTAL
 fi
-if [ "$CONFIG_USB_UHCI_ALT" != "y" ]; then
-   dep_tristate '  UHCI (Intel PIIX4, VIA, ...) support' CONFIG_USB_UHCI $CONFIG_USB
-fi
-if [ "$CONFIG_USB_UHCI" != "y" ]; then
-   dep_tristate '  UHCI Alternate Driver (JE) support' CONFIG_USB_UHCI_ALT $CONFIG_USB
-else
-   define_bool CONFIG_USB_UHCI_ALT n
-fi
+#if [ "$CONFIG_USB_UHCI_ALT" != "y" ]; then
+#   dep_tristate '  UHCI (Intel PIIX4, VIA, ...) support' CONFIG_USB_UHCI $CONFIG_USB
+#fi
+#if [ "$CONFIG_USB_UHCI" != "y" ]; then
+#   dep_tristate '  UHCI Alternate Driver (JE) support' CONFIG_USB_UHCI_ALT $CONFIG_USB
+#else
+#   define_bool CONFIG_USB_UHCI_ALT n
+#fi
 #dep_tristate '  OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support' CONFIG_USB_OHCI $CONFIG_USB
diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
--- a/drivers/usb/host/ehci-hcd.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/host/ehci-hcd.c	Fri May 24 18:55:36 2002
@@ -780,7 +780,6 @@
 
 #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
 
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION (DRIVER_INFO);
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_LICENSE ("GPL");
diff -Nru a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
--- a/drivers/usb/host/ehci-sched.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/host/ehci-sched.c	Fri May 24 18:55:34 2002
@@ -964,15 +964,6 @@
 	if (urb->iso_frame_desc [0].offset != 0)
 		return -EINVAL;
 	
-	/*
-	 * NOTE doing this for now, anticipating periodic URB models
-	 * get updated to be "explicit resubmit".
-	 */
-	if (urb->next) {
-		dbg ("use explicit resubmit for ISO");
-		return -EINVAL;
-	}
-
 	/* allocate ITDs w/o locking anything */
 	status = itd_urb_transaction (ehci, urb, mem_flags);
 	if (status < 0)
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/host/ohci-hcd.c	Fri May 24 18:55:33 2002
@@ -894,7 +894,6 @@
 
 #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_DESCRIPTION (DRIVER_INFO);
 MODULE_LICENSE ("GPL");
diff -Nru a/drivers/usb/host/uhci.c b/drivers/usb/host/uhci.c
--- a/drivers/usb/host/uhci.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/host/uhci.c	Fri May 24 18:55:36 2002
@@ -106,8 +106,6 @@
 /* to make sure it doesn't hog all of the bandwidth */
 #define DEPTH_INTERVAL	5
 
-#define MAX_URB_LOOP	2048		/* Maximum number of linked URB's */
-
 /*
  * Technically, updating td->status here is a race, but it's not really a
  * problem. The worst that can happen is that we set the IOC bit again
@@ -2296,8 +2294,7 @@
 	struct urb_priv *urbp;
 	struct usb_device *dev = urb->dev;
 	struct uhci *uhci = (struct uhci *)dev->bus->hcpriv;
-	int is_ring = 0, killed, resubmit_interrupt, status;
-	struct urb *nurb;
+	int killed, resubmit_interrupt, status;
 	unsigned long flags;
 
 	spin_lock_irqsave(&urb->lock, flags);
@@ -2313,29 +2310,6 @@
 	resubmit_interrupt = (usb_pipetype(urb->pipe) == PIPE_INTERRUPT &&
 			urb->interval);
 
-	nurb = urb->next;
-	if (nurb && !killed) {
-		int count = 0;
-
-		while (nurb && nurb != urb && count < MAX_URB_LOOP) {
-			if (nurb->status == -ENOENT ||
-			    nurb->status == -ECONNABORTED ||
-			    nurb->status == -ECONNRESET) {
-				killed = 1;
-				break;
-			}
-
-			nurb = nurb->next;
-			count++;
-		}
-
-		if (count == MAX_URB_LOOP)
-			err("uhci_call_completion: too many linked URB's, loop? (first loop)");
-
-		/* Check to see if chain is a ring */
-		is_ring = (nurb == urb);
-	}
-
 	if (urbp->transfer_buffer_dma_handle)
 		pci_dma_sync_single(uhci->dev, urbp->transfer_buffer_dma_handle,
 			urb->transfer_buffer_length, usb_pipein(urb->pipe) ?
@@ -2370,15 +2344,10 @@
 		urb->dev = dev;
 		uhci_reset_interrupt(urb);
 	} else {
-		if (is_ring && !killed) {
-			urb->dev = dev;
-			uhci_submit_urb(urb, GFP_ATOMIC);
-		} else {
-			/* We decrement the usage count after we're done */
-			/*  with everything */
-			usb_put_dev(dev);
-			usb_put_urb(urb);
-		}
+		/* We decrement the usage count after we're done */
+		/*  with everything */
+		usb_put_dev(dev);
+		usb_put_urb(urb);
 	}
 }
 
diff -Nru a/drivers/usb/host/usb-uhci-hcd.c b/drivers/usb/host/usb-uhci-hcd.c
--- a/drivers/usb/host/usb-uhci-hcd.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/host/usb-uhci-hcd.c	Fri May 24 18:55:34 2002
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/errno.h>
@@ -100,9 +100,6 @@
 //                   NO serviceable parts below!
 /*--------------------------------------------------------------------------*/
 
-// How much URBs with ->next are walked
-#define MAX_NEXT_COUNT 2048
-
 static struct uhci *devs = NULL;
 
 /* used by userspace UHCI data structure dumper */
@@ -589,7 +586,6 @@
 
 #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_DESCRIPTION (DRIVER_INFO);
 MODULE_LICENSE ("GPL");
diff -Nru a/drivers/usb/host/usb-uhci-q.c b/drivers/usb/host/usb-uhci-q.c
--- a/drivers/usb/host/usb-uhci-q.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/host/usb-uhci-q.c	Fri May 24 18:55:33 2002
@@ -1215,10 +1215,9 @@
 // called with urb_list_lock set
 static int process_urb (struct uhci_hcd *uhci, struct list_head *p)
 {
-	struct urb *urb, *urbt;	
-	struct usb_device *usb_dev;
+	struct urb *urb;	
 	urb_priv_t *priv;
-	int type, n, ret = 0;
+	int type, ret = 0;
 
 	priv=list_entry (p,  urb_priv_t, urb_list);
 	urb=priv->urb;
@@ -1251,40 +1250,11 @@
 		uhci_free_priv(uhci, urb, urb->hcpriv);
 
 		if (type != PIPE_INTERRUPT) {  // process_interrupt does completion on its own		
-			// FIXME: How to detect killed URBs in a ring?			
-
-			if (type == PIPE_ISOCHRONOUS) {
-				for (n=0, urbt = urb->next; urbt && (urbt != urb) && (n<MAX_NEXT_COUNT); urbt = urbt->next, n++)
-					continue;
-
-				if (urbt && (n<MAX_NEXT_COUNT)) {
-					usb_dev=urb->dev;
-					urb->dev = NULL;
-					spin_unlock(&uhci->urb_list_lock);
-					if (urb->complete)
-						urb->complete (urb);
-
-					urb->dev=usb_dev;
-					uhci_urb_enqueue(&uhci->hcd, urb, GFP_ATOMIC); // FIXME memflags!
-					spin_lock(&uhci->urb_list_lock);					
-				}
-				else {
-					spin_unlock(&uhci->urb_list_lock);
-					dbg("giveback iso urb %p, status %i, length %i\n", 
-					    urb, urb->status, urb->transfer_buffer_length);
-
-					usb_hcd_giveback_urb(&uhci->hcd, urb);
-					spin_lock(&uhci->urb_list_lock);
-				}
-			}
-			else {
-				spin_unlock(&uhci->urb_list_lock);
-				dbg("giveback urb %p, status %i, length %i\n", 
-				    urb, urb->status, urb->transfer_buffer_length);
-
-				usb_hcd_giveback_urb(&uhci->hcd, urb);
-				spin_lock(&uhci->urb_list_lock);
-			}
+			spin_unlock(&uhci->urb_list_lock);
+			dbg("giveback urb %p, status %i, length %i\n", 
+			    urb, urb->status, urb->transfer_buffer_length);
+			usb_hcd_giveback_urb(&uhci->hcd, urb);
+			spin_lock(&uhci->urb_list_lock);
 		}
 	}
 	return ret;
diff -Nru a/drivers/usb/host/usb-uhci.c b/drivers/usb/host/usb-uhci.c
--- a/drivers/usb/host/usb-uhci.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/host/usb-uhci.c	Fri May 24 18:55:35 2002
@@ -125,9 +125,6 @@
 _static int process_interrupt (uhci_t *s, struct urb *urb);
 _static int process_iso (uhci_t *s, struct urb *urb, int force);
 
-// How much URBs with ->next are walked
-#define MAX_NEXT_COUNT 2048
-
 static uhci_t *devs = NULL;
 
 /* used by userspace UHCI data structure dumper */
@@ -2662,78 +2659,12 @@
 #endif
 
 		if ((usb_pipetype (urb->pipe) != PIPE_INTERRUPT)) {  // process_interrupt does completion on its own		
-			struct urb *next_urb = urb->next;
-			int is_ring = 0;
-			int contains_killed = 0;
-			int loop_count=0;
-			
-			if (next_urb) {
-				// Find out if the URBs are linked to a ring
-				while  (next_urb != NULL && next_urb != urb && loop_count < MAX_NEXT_COUNT) {
-					if (next_urb->status == -ENOENT) {// killed URBs break ring structure & resubmission
-						contains_killed = 1;
-						break;
-					}	
-					next_urb = next_urb->next;
-					loop_count++;
-				}
-				
-				if (loop_count == MAX_NEXT_COUNT)
-					err("process_urb: Too much linked URBs in ring detection!");
-
-				if (next_urb == urb)
-					is_ring=1;
-			}			
-
-			// Submit idle/non-killed URBs linked with urb->next
-			// Stop before the current URB				
 			
-			next_urb = urb->next;	
-			if (next_urb && !contains_killed) {
-				int ret_submit;
-				next_urb = urb->next;	
-				
-				loop_count=0;
-				while (next_urb != NULL && next_urb != urb && loop_count < MAX_NEXT_COUNT) {
-					if (next_urb->status != -EINPROGRESS) {
-					
-						if (next_urb->status == -ENOENT) 
-							break;
-
-						spin_unlock(&s->urb_list_lock);
-
-						// FIXME!!!
-						// We need to know the real state, so 
-						// GFP_ATOMIC is probably not correct
-						ret_submit=uhci_submit_urb(next_urb, GFP_ATOMIC);
-						spin_lock(&s->urb_list_lock);
-						
-						if (ret_submit)
-							break;						
-					}
-					loop_count++;
-					next_urb = next_urb->next;
-				}
-				if (loop_count == MAX_NEXT_COUNT)
-					err("process_urb: Too much linked URBs in resubmission!");
-			}
-
 			// Completion
 			if (urb->complete) {
-				int was_unlinked = (urb->status == -ENOENT);
 				urb->dev = NULL;
 				spin_unlock(&s->urb_list_lock);
-
 				urb->complete ((struct urb *) urb);
-
-				// Re-submit the URB if ring-linked
-				if (is_ring && !was_unlinked && !contains_killed) {
-					urb->dev=usb_dev;
-					// FIXME!!!
-					// We need to know the real state, so 
-					// GFP_ATOMIC is probably not correct
-					uhci_submit_urb (urb, GFP_ATOMIC);
-				}
 				spin_lock(&s->urb_list_lock);
 			}
 			
diff -Nru a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c
--- a/drivers/usb/image/scanner.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/image/scanner.c	Fri May 24 18:55:34 2002
@@ -300,6 +300,8 @@
  *      Frank Zago <fzago@greshamstorage.com> and
  *      Oliver Neukum <520047054719-0001@t-online.de> for reviewing/testing.
  *
+ * 05/21/02 Currently maintained by Brian Beattie <beattie@beattie-home.net>
+ *
  * TODO
  *    - Performance
  *    - Select/poll methods
diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h
--- a/drivers/usb/image/scanner.h	Fri May 24 18:55:35 2002
+++ b/drivers/usb/image/scanner.h	Fri May 24 18:55:35 2002
@@ -19,6 +19,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
+ * 05/21/02 Currently maintained by Brian Beattie <beattie@beattie-home.net>
+ *
+ *
  */ 
 
 #include <linux/module.h>
diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
--- a/drivers/usb/media/ov511.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/media/ov511.c	Fri May 24 18:55:34 2002
@@ -227,7 +227,11 @@
 static int i2c_detect_tries = 5;
 
 /* MMX support is present in kernel and CPU. Checked upon decomp module load. */
-static int ov51x_mmx_available;
+#if defined(__i386__) || defined(__x86_64__)
+#define ov51x_mmx_available (cpu_has_mmx)
+#else
+#define ov51x_mmx_available (0)
+#endif
 
 static __devinitdata struct usb_device_id device_table [] = {
 	{ USB_DEVICE(VEND_OMNIVISION, PROD_OV511) },
@@ -6472,11 +6476,6 @@
 
 	if (usb_register(&ov511_driver) < 0)
 		return -1;
-
-#if defined (__i386__)
-	if (test_bit(X86_FEATURE_MMX, boot_cpu_data.x86_capability))
-		ov51x_mmx_available = 1;
-#endif
 
 	info(DRIVER_VERSION " : " DRIVER_DESC);
 
diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
--- a/drivers/usb/media/se401.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/media/se401.c	Fri May 24 18:55:34 2002
@@ -71,8 +71,6 @@
 MODULE_PARM(flickerless, "i");
 MODULE_PARM_DESC(flickerless, "Net frequency to adjust exposure time to (0/50/60)");
 MODULE_PARM(video_nr, "i");
-EXPORT_NO_SYMBOLS;
-
 
 static struct usb_driver se401_driver;
 
@@ -632,7 +630,6 @@
 	se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
 
 	for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) {
-		se401->urb[i]->next=NULL;
 		usb_unlink_urb(se401->urb[i]);
 		usb_free_urb(se401->urb[i]);
 		se401->urb[i]=NULL;
@@ -1506,7 +1503,6 @@
 	wake_up_interruptible(&se401->wq);
 
 	for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) {
-		se401->urb[i]->next = NULL;
 		usb_unlink_urb(se401->urb[i]);
 		usb_free_urb(se401->urb[i]);
 		se401->urb[i] = NULL;
diff -Nru a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
--- a/drivers/usb/media/stv680.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/media/stv680.c	Fri May 24 18:55:33 2002
@@ -105,7 +105,6 @@
 MODULE_PARM (swapRGB_on, "i");
 MODULE_PARM_DESC (swapRGB_on, "Red/blue swap: 1=always, 0=auto, -1=never");
 MODULE_PARM (video_nr, "i");
-EXPORT_NO_SYMBOLS;
 
 /********************************************************************
  *
@@ -799,7 +798,6 @@
 
 	for (i = 0; i < STV680_NUMSBUF; i++)
 		if (stv680->urb[i]) {
-			stv680->urb[i]->next = NULL;
 			usb_unlink_urb (stv680->urb[i]);
 			usb_free_urb (stv680->urb[i]);
 			stv680->urb[i] = NULL;
@@ -1516,7 +1514,6 @@
 
 	for (i = 0; i < STV680_NUMSBUF; i++)
 		if (stv680->urb[i]) {
-			stv680->urb[i]->next = NULL;
 			usb_unlink_urb (stv680->urb[i]);
 			usb_free_urb (stv680->urb[i]);
 			stv680->urb[i] = NULL;
diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c
--- a/drivers/usb/misc/tiglusb.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/misc/tiglusb.c	Fri May 24 18:55:33 2002
@@ -488,8 +488,6 @@
 MODULE_DESCRIPTION (DRIVER_DESC);
 MODULE_LICENSE (DRIVER_LICENSE);
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_PARM (timeout, "i");
 MODULE_PARM_DESC (timeout, "Timeout (default=1.5 seconds)");
 
diff -Nru a/drivers/usb/net/cdc-ether.c b/drivers/usb/net/cdc-ether.c
--- a/drivers/usb/net/cdc-ether.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/net/cdc-ether.c	Fri May 24 18:55:33 2002
@@ -18,8 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-
-#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
diff -Nru a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
--- a/drivers/usb/net/pegasus.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/net/pegasus.c	Fri May 24 18:55:36 2002
@@ -62,7 +62,7 @@
 #define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
 
-static const char driver_name [] = "pegasus";
+static const char driver_name[] = "pegasus";
 
 #define	PEGASUS_USE_INTR
 #define	PEGASUS_WRITE_EEPROM
diff -Nru a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
--- a/drivers/usb/net/pegasus.h	Fri May 24 18:55:35 2002
+++ b/drivers/usb/net/pegasus.h	Fri May 24 18:55:35 2002
@@ -123,6 +123,7 @@
 #define	VENDOR_ABOCOM		0x07b8
 #define	VENDOR_ACCTON		0x083a
 #define	VENDOR_ADMTEK		0x07a6
+#define	VENDOR_AEILAB		0x3334
 #define	VENDOR_ALLIEDTEL	0x07c9
 #define	VENDOR_BELKIN		0x050d
 #define	VENDOR_BILLIONTON	0x08dd
@@ -178,6 +179,8 @@
 		VENDOR_ADMTEK, 0x0986,
 		DEFAULT_GPIO_RESET | HAS_HOME_PNA )
 PEGASUS_DEV( "AN986A USB MAC", VENDOR_ADMTEK, 1986,
+		DEFAULT_GPIO_RESET | PEGASUS_II )
+PEGASUS_DEV( "AEI USB Fast Ethernet Adapter", VENDOR_AEILAB, 0x1701,
 		DEFAULT_GPIO_RESET | PEGASUS_II )
 PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100,
 		DEFAULT_GPIO_RESET | PEGASUS_II )
diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
--- a/drivers/usb/net/usbnet.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/net/usbnet.c	Fri May 24 18:55:33 2002
@@ -2159,7 +2159,6 @@
 }
 module_exit (usbnet_exit);
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR ("David Brownell <dbrownell@users.sourceforge.net>");
 MODULE_DESCRIPTION ("USB Host-to-Host Link Drivers (numerous vendors)");
 MODULE_LICENSE ("GPL");
diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
--- a/drivers/usb/serial/belkin_sa.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/serial/belkin_sa.c	Fri May 24 18:55:36 2002
@@ -65,18 +65,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
--- a/drivers/usb/serial/cyberjack.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/serial/cyberjack.c	Fri May 24 18:55:36 2002
@@ -25,18 +25,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
--- a/drivers/usb/serial/digi_acceleport.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/digi_acceleport.c	Fri May 24 18:55:35 2002
@@ -235,19 +235,16 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/tqueue.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
--- a/drivers/usb/serial/empeg.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/empeg.c	Fri May 24 18:55:35 2002
@@ -53,18 +53,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/serial/ftdi_sio.c	Fri May 24 18:55:34 2002
@@ -93,18 +93,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 #ifdef CONFIG_USB_SERIAL_DEBUG
 	static int debug = 1;
diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
--- a/drivers/usb/serial/io_edgeport.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/serial/io_edgeport.c	Fri May 24 18:55:33 2002
@@ -242,13 +242,10 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
+#include <linux/jiffies.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
@@ -256,7 +253,7 @@
 #include <linux/spinlock.h>
 #include <linux/serial.h>
 #include <linux/ioctl.h>
-#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
--- a/drivers/usb/serial/ipaq.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/serial/ipaq.c	Fri May 24 18:55:34 2002
@@ -34,18 +34,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
--- a/drivers/usb/serial/ir-usb.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/ir-usb.c	Fri May 24 18:55:35 2002
@@ -48,18 +48,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
--- a/drivers/usb/serial/keyspan.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/serial/keyspan.c	Fri May 24 18:55:33 2002
@@ -76,18 +76,16 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
+#include <linux/jiffies.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
--- a/drivers/usb/serial/keyspan_pda.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/serial/keyspan_pda.c	Fri May 24 18:55:36 2002
@@ -68,19 +68,16 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/tqueue.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
--- a/drivers/usb/serial/kl5kusb105.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/serial/kl5kusb105.c	Fri May 24 18:55:36 2002
@@ -47,16 +47,14 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
--- a/drivers/usb/serial/mct_u232.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/serial/mct_u232.c	Fri May 24 18:55:36 2002
@@ -61,18 +61,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
--- a/drivers/usb/serial/omninet.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/serial/omninet.c	Fri May 24 18:55:34 2002
@@ -37,18 +37,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
--- a/drivers/usb/serial/pl2303.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/pl2303.c	Fri May 24 18:55:35 2002
@@ -36,19 +36,16 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/serial.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
--- a/drivers/usb/serial/safe_serial.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/serial/safe_serial.c	Fri May 24 18:55:34 2002
@@ -62,18 +62,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 
diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/usbserial.c	Fri May 24 18:55:35 2002
@@ -308,13 +308,9 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
@@ -322,6 +318,7 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/smp_lock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef MODULE
diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
--- a/drivers/usb/serial/visor.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/serial/visor.c	Fri May 24 18:55:34 2002
@@ -133,18 +133,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/serial/whiteheat.c	Fri May 24 18:55:35 2002
@@ -61,18 +61,15 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
diff -Nru a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
--- a/drivers/usb/storage/Makefile	Fri May 24 18:55:36 2002
+++ b/drivers/usb/storage/Makefile	Fri May 24 18:55:36 2002
@@ -11,14 +11,14 @@
 obj-$(CONFIG_USB_STORAGE)	+= usb-storage.o
 
 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG)	+= debug.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_HP8200e)	+= shuttle_usbat.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09)	+= sddr09.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55)	+= sddr55.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_HP8200e)	+= shuttle_usbat.o raw_bulk.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09)	+= sddr09.o raw_bulk.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55)	+= sddr55.o raw_bulk.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM)	+= freecom.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM)	+= dpcm.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200)	+= isd200.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB)	+= datafab.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT)	+= jumpshot.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB)	+= datafab.o raw_bulk.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT)	+= jumpshot.o raw_bulk.o
 
 usb-storage-objs :=	scsiglue.o protocol.o transport.o usb.o \
 			initializers.o $(usb-storage-obj-y)
diff -Nru a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
--- a/drivers/usb/storage/datafab.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/storage/datafab.c	Fri May 24 18:55:36 2002
@@ -51,6 +51,7 @@
  */
 
 #include "transport.h"
+#include "raw_bulk.h"
 #include "protocol.h"
 #include "usb.h"
 #include "debug.h"
@@ -60,131 +61,48 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 
-extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
-			     unsigned int len, unsigned int *act_len);
-
-static int datafab_determine_lun(struct us_data *us, struct datafab_info *info);
-
-
-static void datafab_dump_data(unsigned char *data, int len)
-{
-	unsigned char buf[80];
-	int sofar = 0;
-
-	if (!data)
-		return;
-
-	memset(buf, 0, sizeof(buf));
-
-	for (sofar = 0; sofar < len; sofar++) {
-		sprintf(buf + strlen(buf), "%02x ",
-			((unsigned int) data[sofar]) & 0xFF);
-
-		if (sofar % 16 == 15) {
-			US_DEBUGP("datafab:  %s\n", buf);
-			memset(buf, 0, sizeof(buf));
-		}
-	}
-
-	if (strlen(buf) != 0)
-		US_DEBUGP("datafab:  %s\n", buf);
-}
-
-
-static int datafab_raw_bulk(int direction,
-			    struct us_data *us,
-			    unsigned char *data, 
-		            unsigned int len)
-{
-	int result;
-	int act_len;
-	int pipe;
-
-	if (direction == SCSI_DATA_READ)
-		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
-	else
-		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
-
-	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
-
-	// if we stall, we need to clear it before we go on 
-	if (result == -EPIPE) {
-		US_DEBUGP("datafab_raw_bulk: EPIPE. clearing endpoint halt for"
-			  " pipe 0x%x, stalled at %d bytes\n", pipe, act_len);
-		usb_stor_clear_halt(us, pipe);
-	}
-
-	if (result) {
-		// NAK - that means we've retried a few times already 
-		if (result == -ETIMEDOUT) {
-			US_DEBUGP("datafab_raw_bulk:  device NAKed\n");
-			return US_BULK_TRANSFER_FAILED;
-		}
-
-		// -ENOENT -- we canceled this transfer
-		if (result == -ENOENT) {
-			US_DEBUGP("datafab_raw_bulk:  transfer aborted\n");
-			return US_BULK_TRANSFER_ABORTED;
-		}
-
-		if (result == -EPIPE) {
-			US_DEBUGP("datafab_raw_bulk:  output pipe stalled\n");
-			return USB_STOR_TRANSPORT_FAILED;
-		}
-
-		// the catch-all case
-		US_DEBUGP("datafab_raw_bulk:  unknown error\n");
-		return US_BULK_TRANSFER_FAILED;
-	}
+static int datafab_determine_lun(struct us_data *us,
+				 struct datafab_info *info);
 
-	if (act_len != len) {
-		US_DEBUGP("datafab_raw_bulk:  Warning. Transferred only %d bytes\n", act_len);
-		return US_BULK_TRANSFER_SHORT;
-	}
 
-	US_DEBUGP("datafab_raw_bulk:  Transfered %d of %d bytes\n", act_len, len);
-	return US_BULK_TRANSFER_GOOD;
-}
+static inline int
+datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
+	unsigned int act_len;	/* ignored */
 
-static inline int datafab_bulk_read(struct us_data *us,
-			            unsigned char *data, 
-		                    unsigned int len)
-{
 	if (len == 0)
 		return USB_STOR_TRANSPORT_GOOD;
 
 	US_DEBUGP("datafab_bulk_read:  len = %d\n", len);
-	return datafab_raw_bulk(SCSI_DATA_READ, us, data, len);
+	return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
 }
 
 
-static inline int datafab_bulk_write(struct us_data *us,
-			             unsigned char *data, 
-		                     unsigned int len)
-{
+static inline int
+datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) {
+	unsigned int act_len;	/* ignored */
+
 	if (len == 0)
 		return USB_STOR_TRANSPORT_GOOD;
 
 	US_DEBUGP("datafab_bulk_write:  len = %d\n", len);
-	return datafab_raw_bulk(SCSI_DATA_WRITE, us, data, len);
+	return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
 }
 
 
 static int datafab_read_data(struct us_data *us,
-		             struct datafab_info *info,
-		             u32 sector,
-		             u32 sectors, 
-		             unsigned char *dest, 
-		             int use_sg)
+			     struct datafab_info *info,
+			     u32 sector,
+			     u32 sectors, 
+			     unsigned char *dest, 
+			     int use_sg)
 {
 	unsigned char command[8] = { 0, 0, 0, 0, 0, 0xE0, 0x20, 0x01 };
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
 	unsigned char  thistime;
-	struct scatterlist *sg = NULL;
 	int totallen, len, result;
-	int sg_idx = 0, current_sg_offset = 0;
-	int transferred, rc;
+	int sg_idx = 0, sg_offset = 0;
+	int rc;
 
 	// we're working in LBA mode.  according to the ATA spec, 
 	// we can support up to 28-bit addressing.  I don't know if Datafab
@@ -202,28 +120,17 @@
 
 	command[5] += (info->lun << 4);
 
-	// If we're using scatter-gather, we have to create a new
-	// buffer to read all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
-
 	totallen = sectors * info->ssize;
 
 	do {
-		// loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
+		// loop, never allocate or transfer more than 64k at once
+		// (min(128k, 255*info->ssize) is the real limit)
+
 		len = min_t(int, totallen, 65536);
 
-		if (use_sg) {
-			sg = (struct scatterlist *) dest;
-			buffer = kmalloc(len, GFP_NOIO);
-			if (buffer == NULL)
-				return USB_STOR_TRANSPORT_ERROR;
-			ptr = buffer;
-		} else {
-			ptr = dest;
-		}
+		ptr = buffer = (use_sg ? kmalloc(len, GFP_NOIO) : dest);
+		if (buffer == NULL)
+			return USB_STOR_TRANSPORT_ERROR;
 
 		thistime = (len / info->ssize) & 0xff;
 
@@ -235,53 +142,22 @@
 	
 		command[5] |= (sector >> 24) & 0x0F;
 
-		// send the command
-		US_DEBUGP("datafab_read_data:  sending following command\n");
-		datafab_dump_data(command, sizeof(command));
-
+		// send the read command
 		result = datafab_bulk_write(us, command, sizeof(command));
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		// read the result
 		result = datafab_bulk_read(us, ptr, len);
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
-
-		US_DEBUGP("datafab_read_data results:  %d bytes\n", len);
-		// datafab_dump_data(ptr, len);
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		sectors -= thistime;
 		sector  += thistime;
 
 		if (use_sg) {
-			transferred = 0;
-			while (sg_idx < use_sg && transferred < len) {
-				if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
-					US_DEBUGP("datafab_read_data:  adding %d bytes to %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
-					memcpy(page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-					       buffer + transferred,
-					       sg[sg_idx].length - current_sg_offset);
-					transferred += sg[sg_idx].length - current_sg_offset;
-					current_sg_offset = 0;
-					// on to the next sg buffer
-					++sg_idx;
-				} else {
-					US_DEBUGP("datafab_read_data:  adding %d bytes to %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
-					memcpy(page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-					       buffer + transferred,
-					       len - transferred);
-					current_sg_offset += len - transferred;
-					// this sg buffer is only partially full and we're out of data to copy in
-					break;
-				}
-			}
+			us_copy_to_sgbuf(buffer, len, dest,
+					 &sg_idx, &sg_offset, use_sg);
 			kfree(buffer);
 		} else {
 			dest += len;
@@ -291,25 +167,28 @@
 	} while (totallen > 0);
 
 	return USB_STOR_TRANSPORT_GOOD;
+
+ leave:
+	if (use_sg)
+		kfree(buffer);
+	return result;
 }
 
 
 static int datafab_write_data(struct us_data *us,
-		              struct datafab_info *info,
-		              u32 sector,
-		              u32 sectors, 
-		              unsigned char *src, 
-		              int use_sg)
+			      struct datafab_info *info,
+			      u32 sector,
+			      u32 sectors, 
+			      unsigned char *src, 
+			      int use_sg)
 {
 	unsigned char command[8] = { 0, 0, 0, 0, 0, 0xE0, 0x30, 0x02 };
 	unsigned char reply[2] = { 0, 0 };
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
 	unsigned char thistime;
-	struct scatterlist *sg = NULL;
-	int totallen, len, result;
-	int sg_idx = 0, current_sg_offset = 0;
-	int transferred, rc;
+	int totallen, len, result, rc;
+	int sg_idx = 0, sg_offset = 0;
 
 	// we're working in LBA mode.  according to the ATA spec, 
 	// we can support up to 28-bit addressing.  I don't know if Datafab
@@ -337,44 +216,20 @@
 	totallen = sectors * info->ssize;
 
 	do {
-		// loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
+		// loop, never allocate or transfer more than 64k at once
+		// (min(128k, 255*info->ssize) is the real limit)
+
 		len = min_t(int, totallen, 65536);
 
-		if (use_sg) {
-			sg = (struct scatterlist *) src;
-			buffer = kmalloc(len, GFP_NOIO);
-			if (buffer == NULL)
-				return USB_STOR_TRANSPORT_ERROR;
-			ptr = buffer;
-
-			memset(buffer, 0, len);
-
-			// copy the data from the sg bufs into the big contiguous buf
-			//
-			transferred = 0;
-			while (transferred < len) {
-				if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
-					US_DEBUGP("datafab_write_data:  getting %d bytes from %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
-					memcpy(ptr + transferred,
-					       page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-					       sg[sg_idx].length - current_sg_offset);
-					transferred += sg[sg_idx].length - current_sg_offset;
-					current_sg_offset = 0;
-					// on to the next sg buffer
-					++sg_idx;
-				} else {
-					US_DEBUGP("datafab_write_data:  getting %d bytes from %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
-					memcpy(ptr + transferred,
-					       page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-					       len - transferred);
-					current_sg_offset += len - transferred;
-					// we only copied part of this sg buffer
-					break;
-				}
-			}
-		} else {
-			ptr = src;
-		}
+		// if we are using scatter-gather,
+		// first copy all to one big buffer
+
+		buffer = us_copy_from_sgbuf(src, len, &sg_idx,
+					    &sg_offset, use_sg);
+		if (buffer == NULL)
+			return USB_STOR_TRANSPORT_ERROR;
+
+		ptr = buffer;
 
 		thistime = (len / info->ssize) & 0xff;
 
@@ -387,64 +242,57 @@
 		command[5] |= (sector >> 24) & 0x0F;
 
 		// send the command
-		US_DEBUGP("datafab_write_data:  sending following command\n");
-		datafab_dump_data(command, sizeof(command));
-
 		result = datafab_bulk_write(us, command, sizeof(command));
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		// send the data
 		result = datafab_bulk_write(us, ptr, len);
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		// read the result
 		result = datafab_bulk_read(us, reply, sizeof(reply));
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		if (reply[0] != 0x50 && reply[1] != 0) {
-			US_DEBUGP("datafab_write_data:  Gah! write return code: %02x %02x\n", reply[0], reply[1]);
-			if (use_sg)
-				kfree(buffer);
-			return USB_STOR_TRANSPORT_ERROR;
+			US_DEBUGP("datafab_write_data:  Gah! "
+				  "write return code: %02x %02x\n",
+				  reply[0], reply[1]);
+			result = USB_STOR_TRANSPORT_ERROR;
+			goto leave;
 		}
 
 		sectors -= thistime;
 		sector  += thistime;
 
-		if (use_sg) {
+		if (use_sg)
 			kfree(buffer);
-		} else {
+		else
 			src += len;
-		}
 
 		totallen -= len;
 	} while (totallen > 0);
 
 	return USB_STOR_TRANSPORT_GOOD;
+
+ leave:
+	if (use_sg)
+		kfree(buffer);
+	return result;
 }
 
 
 static int datafab_determine_lun(struct us_data *us,
 				 struct datafab_info *info)
 {
-	// dual-slot readers can be thought of as dual-LUN devices.  we need to
-	// determine which card slot is being used.  we'll send an IDENTIFY DEVICE
-	// command and see which LUN responds...
-	//
-	// there might be a better way of doing this?
+	// Dual-slot readers can be thought of as dual-LUN devices.
+	// We need to determine which card slot is being used.
+	// We'll send an IDENTIFY DEVICE command and see which LUN responds...
 	//
+	// There might be a better way of doing this?
+
 	unsigned char command[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 };
 	unsigned char buf[512];
 	int count = 0, rc;
@@ -454,9 +302,9 @@
 
 	US_DEBUGP("datafab_determine_lun:  locating...\n");
 
-	// we'll try 10 times before giving up...
+	// we'll try 3 times before giving up...
 	//
-	while (count++ < 10) {
+	while (count++ < 3) {
 		command[5] = 0xa0;
 
 		rc = datafab_bulk_write(us, command, 8);
@@ -481,7 +329,7 @@
 			return USB_STOR_TRANSPORT_GOOD;
 		}
 
-                wait_ms(20);
+		wait_ms(20);
 	}
 
 	return USB_STOR_TRANSPORT_FAILED;
@@ -531,7 +379,7 @@
 
 static int datafab_handle_mode_sense(struct us_data *us,
 				     Scsi_Cmnd * srb, 
-		                     unsigned char *ptr,
+				     unsigned char *ptr,
 				     int sense_6)
 {
 	unsigned char mode_param_header[8] = {
@@ -557,7 +405,7 @@
 	// datafab reader doesn't present a SCSI interface so we
 	// fudge the SCSI commands...
 	//
-        
+	
 	if (sense_6)
 		param_len = srb->cmnd[4];
 	else
@@ -676,7 +524,8 @@
 	if (!us->extra) {
 		us->extra = kmalloc(sizeof(struct datafab_info), GFP_NOIO);
 		if (!us->extra) {
-			US_DEBUGP("datafab_transport:  Gah! Can't allocate storage for Datafab info struct!\n");
+			US_DEBUGP("datafab_transport:  Gah! "
+				  "Can't allocate storage for Datafab info struct!\n");
 			return USB_STOR_TRANSPORT_ERROR;
 		}
 		memset(us->extra, 0, sizeof(struct datafab_info));
@@ -728,7 +577,7 @@
 	//
 	if (srb->cmnd[0] == READ_10) {
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
 
@@ -740,10 +589,10 @@
 		// we'll probably never see a READ_12 but we'll do it anyway...
 		//
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
-		         ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
+			 ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
 
 		US_DEBUGP("datafab_transport:  READ_12: read block 0x%04lx  count %ld\n", block, blocks);
 		return datafab_read_data(us, info, block, blocks, ptr, srb->use_sg);
@@ -751,7 +600,7 @@
 
 	if (srb->cmnd[0] == WRITE_10) {
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
 
@@ -763,10 +612,10 @@
 		// we'll probably never see a WRITE_12 but we'll do it anyway...
 		//
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
-		         ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
+			 ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
 
 		US_DEBUGP("datafab_transport:  WRITE_12: write block 0x%04lx  count %ld\n", block, blocks);
 		return datafab_write_data(us, info, block, blocks, ptr, srb->use_sg);
@@ -825,8 +674,9 @@
 			srb->result = CHECK_CONDITION << 1;
 		}
 		return rc;
-        }
+	}
 
-	US_DEBUGP("datafab_transport:  Gah! Unknown command: %d (0x%x)\n", srb->cmnd[0], srb->cmnd[0]);
+	US_DEBUGP("datafab_transport:  Gah! Unknown command: %d (0x%x)\n",
+		  srb->cmnd[0], srb->cmnd[0]);
 	return USB_STOR_TRANSPORT_ERROR;
 }
diff -Nru a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
--- a/drivers/usb/storage/initializers.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/storage/initializers.c	Fri May 24 18:55:35 2002
@@ -37,6 +37,8 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/sched.h>
+#include <linux/errno.h>
 #include "initializers.h"
 #include "debug.h"
 
diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
--- a/drivers/usb/storage/isd200.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/storage/isd200.c	Fri May 24 18:55:35 2002
@@ -49,7 +49,7 @@
 #include "scsiglue.h"
 #include "isd200.h"
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/hdreg.h>
diff -Nru a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
--- a/drivers/usb/storage/jumpshot.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/storage/jumpshot.c	Fri May 24 18:55:33 2002
@@ -48,6 +48,7 @@
   */
 
 #include "transport.h"
+#include "raw_bulk.h"
 #include "protocol.h"
 #include "usb.h"
 #include "debug.h"
@@ -57,176 +58,31 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 
-extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
-				u8 request, u8 requesttype, u16 value,
-				u16 index, void *data, u16 size);
-extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
-			     unsigned int len, unsigned int *act_len);
-
-#if 0
-static void jumpshot_dump_data(unsigned char *data, int len)
-{
-	unsigned char buf[80];
-	int sofar = 0;
-
-	if (!data)
-		return;
-
-	memset(buf, 0, sizeof(buf));
-
-	for (sofar = 0; sofar < len; sofar++) {
-		sprintf(buf + strlen(buf), "%02x ",
-			((unsigned int) data[sofar]) & 0xFF);
-
-		if (sofar % 16 == 15) {
-			US_DEBUGP("jumpshot:  %s\n", buf);
-			memset(buf, 0, sizeof(buf));
-		}
-	}
-
-	if (strlen(buf) != 0)
-		US_DEBUGP("jumpshot:  %s\n", buf);
-}
-#endif
-
-/*
- * Send a control message and wait for the response.
- *
- * us - the pointer to the us_data structure for the device to use
- *
- * request - the URB Setup Packet's first 6 bytes. The first byte always
- *  corresponds to the request type, and the second byte always corresponds
- *  to the request.  The other 4 bytes do not correspond to value and index,
- *  since they are used in a custom way by the SCM protocol.
- *
- * xfer_data - a buffer from which to get, or to which to store, any data
- *  that gets send or received, respectively, with the URB. Even though
- *  it looks like we allocate a buffer in this code for the data, xfer_data
- *  must contain enough allocated space.
- *
- * xfer_len - the number of bytes to send or receive with the URB.
- *
- * This routine snarfed from the SanDisk SDDR-09 driver
- *
- */
-static int jumpshot_send_control(struct us_data  *us,
-				 int pipe,
-				 unsigned char request,
-				 unsigned char requesttype,
-				 unsigned short value,
-				 unsigned short index,
-				 unsigned char *xfer_data,
-				 unsigned int xfer_len)
-{
-	int result;
-
-	// Send the URB to the device and wait for a response.
-
-	/* Why are request and request type reversed in this call? */
-
-	result = usb_stor_control_msg(us, pipe,
-				      request, requesttype,
-				      value, index, xfer_data, xfer_len);
-
-	// Check the return code for the command.
-
-	if (result < 0) {
-		/* if the command was aborted, indicate that */
-		if (result == -ENOENT)
-			return USB_STOR_TRANSPORT_ABORTED;
-
-		/* a stall is a fatal condition from the device */
-		if (result == -EPIPE) {
-			US_DEBUGP("jumpshot_send_control:  -- Stall on control pipe. Clearing\n");
-			result = usb_stor_clear_halt(us, pipe);
-			US_DEBUGP("jumpshot_send_control:  -- usb_stor_clear_halt() returns %d\n", result);
-			return USB_STOR_TRANSPORT_FAILED;
-		}
-
-		/* Uh oh... serious problem here */
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-
-static int jumpshot_raw_bulk(int direction,
-			     struct us_data *us,
-			     unsigned char *data, 
-		             unsigned int len)
-{
-	int result;
-	int act_len;
-	int pipe;
-
-	if (direction == SCSI_DATA_READ)
-		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
-	else
-		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
-
-	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
-
-	// if we stall, we need to clear it before we go on
-	if (result == -EPIPE) {
-		US_DEBUGP("jumpshot_raw_bulk:  EPIPE. clearing endpoint halt for"
-			  " pipe 0x%x, stalled at %d bytes\n", pipe, act_len);
-		usb_stor_clear_halt(us, pipe);
-	}
-
-	if (result) {
-		// NAK - that means we've retried a few times already
-		if (result == -ETIMEDOUT) {
-			US_DEBUGP("jumpshot_raw_bulk:  device NAKed\n");
-			return US_BULK_TRANSFER_FAILED;
-		}
-
-		// -ENOENT -- we canceled this transfer
-		if (result == -ENOENT) {
-			US_DEBUGP("jumpshot_raw_bulk:  transfer aborted\n");
-			return US_BULK_TRANSFER_ABORTED;
-		}
-
-		if (result == -EPIPE) {
-			US_DEBUGP("jumpshot_raw_bulk:  output pipe stalled\n");
-			return USB_STOR_TRANSPORT_FAILED;
-		}
-
-		// the catch-all case
-		US_DEBUGP("jumpshot_raw_bulk:  unknown error\n");
-		return US_BULK_TRANSFER_FAILED;
-	}
-
-	if (act_len != len) {
-		US_DEBUGP("jumpshot_raw_bulk:  Warning. Transferred only %d bytes\n", act_len);
-		return US_BULK_TRANSFER_SHORT;
-	}
-
-	US_DEBUGP("jumpshot_raw_bulk:  Transferred %d of %d bytes\n", act_len, len);
-	return US_BULK_TRANSFER_GOOD;
-}
-
 static inline int jumpshot_bulk_read(struct us_data *us,
-			             unsigned char *data, 
-		                     unsigned int len)
+				     unsigned char *data, 
+				     unsigned int len)
 {
+	unsigned int act_len;	/* ignored */
+
 	if (len == 0)
 		return USB_STOR_TRANSPORT_GOOD;
 
 	US_DEBUGP("jumpshot_bulk_read:  len = %d\n", len);
-	return jumpshot_raw_bulk(SCSI_DATA_READ, us, data, len);
+	return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
 }
 
 
 static inline int jumpshot_bulk_write(struct us_data *us,
-			              unsigned char *data, 
-		                      unsigned int len)
+				      unsigned char *data, 
+				      unsigned int len)
 {
+	unsigned int act_len;	/* ignored */
+
 	if (len == 0)
 		return USB_STOR_TRANSPORT_GOOD;
 
 	US_DEBUGP("jumpshot_bulk_write:  len = %d\n", len);
-	return jumpshot_raw_bulk(SCSI_DATA_WRITE, us, data, len);
+	return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
 }
 
 
@@ -239,7 +95,7 @@
 		return USB_STOR_TRANSPORT_ERROR;
 
 	// send the setup
-	rc = jumpshot_send_control(us,
+	rc = usb_storage_send_control(us,
 				   usb_rcvctrlpipe(us->pusb_dev, 0),
 				   0, 0xA0, 0, 7, &reply, 1);
 
@@ -256,53 +112,44 @@
 }
 
 static int jumpshot_read_data(struct us_data *us,
-		              struct jumpshot_info *info,
-		              u32 sector,
-		              u32 sectors, 
-		              unsigned char *dest, 
-		              int use_sg)
+			      struct jumpshot_info *info,
+			      u32 sector,
+			      u32 sectors, 
+			      unsigned char *dest, 
+			      int use_sg)
 {
 	unsigned char command[] = { 0, 0, 0, 0, 0, 0xe0, 0x20 };
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
 	unsigned char  thistime;
-	struct scatterlist *sg = NULL;
-        int totallen, len, result;
-        int sg_idx = 0, current_sg_offset = 0;
-        int transferred;
-
-        // we're working in LBA mode.  according to the ATA spec, 
-        // we can support up to 28-bit addressing.  I don't know if Jumpshot
-        // supports beyond 24-bit addressing.  It's kind of hard to test 
-        // since it requires > 8GB CF card.
-	//
+	int totallen, len, result;
+	int sg_idx = 0, current_sg_offset = 0;
+
+	// we're working in LBA mode.  according to the ATA spec, 
+	// we can support up to 28-bit addressing.  I don't know if Jumpshot
+	// supports beyond 24-bit addressing.  It's kind of hard to test 
+	// since it requires > 8GB CF card.
+
 	if (sector > 0x0FFFFFFF)
 		return USB_STOR_TRANSPORT_ERROR;
 
-	// If we're using scatter-gather, we have to create a new
-	// buffer to read all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
-
 	totallen = sectors * info->ssize;
 
 	do {
-               // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-                len = min_t(int, totallen, 65536);
-
-                if (use_sg) {
-                        sg = (struct scatterlist *) dest;
-                        buffer = kmalloc(len, GFP_NOIO);
-                        if (buffer == NULL)
-                                return USB_STOR_TRANSPORT_ERROR;
-                        ptr = buffer;
-                } else {
-                        ptr = dest;
-                }
+		// loop, never allocate or transfer more than 64k at once
+		// (min(128k, 255*info->ssize) is the real limit)
+		len = min_t(int, totallen, 65536);
+
+		if (use_sg) {
+			buffer = kmalloc(len, GFP_NOIO);
+			if (buffer == NULL)
+				return USB_STOR_TRANSPORT_ERROR;
+			ptr = buffer;
+		} else {
+			ptr = dest;
+		}
 
-                thistime = (len / info->ssize) & 0xff;
+		thistime = (len / info->ssize) & 0xff;
 
 		command[0] = 0;
 		command[1] = thistime;
@@ -313,137 +160,83 @@
 		command[5] |= (sector >> 24) & 0x0F;
 
 		// send the setup + command
-		result = jumpshot_send_control(us,
+		result = usb_storage_send_control(us,
 					       usb_sndctrlpipe(us->pusb_dev, 0),
 					       0, 0x20, 0, 1, command, 7);
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		// read the result
 		result = jumpshot_bulk_read(us, ptr, len);
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
 		US_DEBUGP("jumpshot_read_data:  %d bytes\n", len);
-		//jumpshot_dump_data(ptr, len);
 	
 		sectors -= thistime;
 		sector  += thistime;
 
-                if (use_sg) {
-                        transferred = 0;
-                        while (sg_idx < use_sg && transferred < len) {
-                                if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
-                                        US_DEBUGP("jumpshot_read_data:  adding %d bytes to %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
-                                        memcpy(page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-                                               buffer + transferred,
-                                               sg[sg_idx].length - current_sg_offset);
-                                        transferred += sg[sg_idx].length - current_sg_offset;
-                                        current_sg_offset = 0;
-                                        // on to the next sg buffer
-                                        ++sg_idx;
-                                } else {
-                                        US_DEBUGP("jumpshot_read_data:  adding %d bytes to %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
-                                        memcpy(page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-                                               buffer + transferred,
-                                               len - transferred);
-                                        current_sg_offset += len - transferred;
-                                        // this sg buffer is only partially full and we're out of data to copy in
-                                        break;
-                                }
-                        }
-                        kfree(buffer);
-                } else {
-                        dest += len;
-                }
+		if (use_sg) {
+			us_copy_to_sgbuf(buffer, len, dest,
+					 &sg_idx, &current_sg_offset, use_sg);
+			kfree(buffer);
+		} else {
+			dest += len;
+		}
 
-                totallen -= len;
-        } while (totallen > 0);
+		totallen -= len;
+	} while (totallen > 0);
 
 	return USB_STOR_TRANSPORT_GOOD;
+
+ leave:
+	if (use_sg)
+		kfree(buffer);
+	return result;
 }
 
 
 static int jumpshot_write_data(struct us_data *us,
-		               struct jumpshot_info *info,
+			       struct jumpshot_info *info,
 			       u32 sector,
 			       u32 sectors, 
-		               unsigned char *src, 
-		               int use_sg)
+			       unsigned char *src, 
+			       int use_sg)
 {
 	unsigned char command[7] = { 0, 0, 0, 0, 0, 0xE0, 0x30 };
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
 	unsigned char  thistime;
-	struct scatterlist *sg = NULL;
-        int totallen, len, result, waitcount;
-        int sg_idx = 0, current_sg_offset = 0;
-        int transferred;
-
-        // we're working in LBA mode.  according to the ATA spec, 
-        // we can support up to 28-bit addressing.  I don't know if Jumpshot
-        // supports beyond 24-bit addressing.  It's kind of hard to test 
-        // since it requires > 8GB CF card.
-        //
+	int totallen, len, result, waitcount;
+	int sg_idx = 0, sg_offset = 0;
+
+	// we're working in LBA mode.  according to the ATA spec, 
+	// we can support up to 28-bit addressing.  I don't know if Jumpshot
+	// supports beyond 24-bit addressing.  It's kind of hard to test 
+	// since it requires > 8GB CF card.
+	//
 	if (sector > 0x0FFFFFFF)
 		return USB_STOR_TRANSPORT_ERROR;
 
-	// If we're using scatter-gather, we have to create a new
-	// buffer to read all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
-
 	totallen = sectors * info->ssize;
 
 	do {
-                // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-                len = min_t(int, totallen, 65536);
+		// loop, never allocate or transfer more than 64k at once
+		// (min(128k, 255*info->ssize) is the real limit)
+
+		len = min_t(int, totallen, 65536);
+
+		// if we are using scatter-gather,
+		// first copy all to one big buffer
 
-                if (use_sg) {
-                        sg = (struct scatterlist *) src;
-                        buffer = kmalloc(len, GFP_NOIO);
-                        if (buffer == NULL)
-                                return USB_STOR_TRANSPORT_ERROR;
-                        ptr = buffer;
-
-                        memset(buffer, 0, len);
-
-                        // copy the data from the sg bufs into the big contiguous buf
-                        //
-                        transferred = 0;
-                        while (transferred < len) {
-                                if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
-                                        US_DEBUGP("jumpshot_write_data:  getting %d bytes from %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
-                                        memcpy(ptr + transferred,
-                                               page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-                                               sg[sg_idx].length - current_sg_offset);
-                                        transferred += sg[sg_idx].length - current_sg_offset;
-                                        current_sg_offset = 0;
-                                        // on to the next sg buffer
-                                        ++sg_idx;
-                                } else {
-                                        US_DEBUGP("jumpshot_write_data:  getting %d bytes from %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
-                                        memcpy(ptr + transferred,
-                                               page_address(sg[sg_idx].page) + sg[sg_idx].offset + current_sg_offset,
-                                               len - transferred);
-                                        current_sg_offset += len - transferred;
-                                        // we only copied part of this sg buffer
-                                        break;
-                                }
-                        }
-                } else {
-                        ptr = src;
-                }
+		buffer = us_copy_from_sgbuf(src, len, &sg_idx,
+					    &sg_offset, use_sg);
+		if (buffer == NULL)
+			return USB_STOR_TRANSPORT_ERROR;
+
+		ptr = buffer;
 
-                thistime = (len / info->ssize) & 0xff;
+		thistime = (len / info->ssize) & 0xff;
 
 		command[0] = 0;
 		command[1] = thistime;
@@ -454,21 +247,18 @@
 		command[5] |= (sector >> 24) & 0x0F;
 
 		// send the setup + command
-		result = jumpshot_send_control(us,
-					       usb_sndctrlpipe(us->pusb_dev, 0),
-					       0, 0x20, 0, 1, command, 7);
+		result = usb_storage_send_control(
+			us, usb_sndctrlpipe(us->pusb_dev, 0),
+			0, 0x20, 0, 1, command, 7);
 
 		// send the data
 		result = jumpshot_bulk_write(us, ptr, len);
-		if (result != USB_STOR_TRANSPORT_GOOD) {
-			if (use_sg)
-				kfree(buffer);
-			return result;
-		}
+		if (result != USB_STOR_TRANSPORT_GOOD)
+			goto leave;
 
-		// read the result.  apparently the bulk write can complete before the
-		// jumpshot drive is finished writing.  so we loop here until we
-		// get a good return code
+		// read the result.  apparently the bulk write can complete
+		// before the jumpshot drive is finished writing.  so we loop
+		// here until we get a good return code
 		waitcount = 0;
 		do {
 			result = jumpshot_get_status(us);
@@ -485,20 +275,24 @@
 		sectors -= thistime;
 		sector  += thistime;
 
-                if (use_sg) {
-                        kfree(buffer);
-                } else {
-                        src += len;
-                }
+		if (use_sg)
+			kfree(buffer);
+		else
+			src += len;
+
+		totallen -= len;
+	} while (totallen > 0);
 
-                totallen -= len;
-        } while (totallen > 0);
+	return result;
 
+ leave:
+	if (use_sg)
+		kfree(buffer);
 	return result;
 }
 
 static int jumpshot_id_device(struct us_data *us,
-		              struct jumpshot_info *info)
+			      struct jumpshot_info *info)
 {
 	unsigned char command[2] = { 0xe0, 0xec };
 	unsigned char reply[512];
@@ -508,12 +302,13 @@
 		return USB_STOR_TRANSPORT_ERROR;
 
 	// send the setup
-	rc = jumpshot_send_control(us,
+	rc = usb_storage_send_control(us,
 				   usb_sndctrlpipe(us->pusb_dev, 0),
 				   0, 0x20, 0, 6, command, 2);
 
 	if (rc != USB_STOR_TRANSPORT_GOOD) {
-		US_DEBUGP("jumpshot_id_device:  Gah! send_control for read_capacity failed\n");
+		US_DEBUGP("jumpshot_id_device:  Gah! "
+			  "send_control for read_capacity failed\n");
 		return rc;
 	}
 
@@ -532,8 +327,8 @@
 
 static int jumpshot_handle_mode_sense(struct us_data *us,
 				      Scsi_Cmnd * srb, 
-			              unsigned char *ptr,
-			              int sense_6)
+				      unsigned char *ptr,
+				      int sense_6)
 {
 	unsigned char mode_param_header[8] = {
 		0, 0, 0, 0, 0, 0, 0, 0
@@ -730,7 +525,7 @@
 
 	if (srb->cmnd[0] == READ_10) {
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
 
@@ -742,10 +537,10 @@
 		// I don't think we'll ever see a READ_12 but support it anyway...
 		//
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
-		         ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
+			 ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
 
 		US_DEBUGP("jumpshot_transport:  READ_12: read block 0x%04lx  count %ld\n", block, blocks);
 		return jumpshot_read_data(us, info, block, blocks, ptr, srb->use_sg);
@@ -753,7 +548,7 @@
 
 	if (srb->cmnd[0] == WRITE_10) {
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
 
@@ -765,10 +560,10 @@
 		// I don't think we'll ever see a WRITE_12 but support it anyway...
 		//
 		block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
-		        ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
+			((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
 
 		blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
-		         ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
+			 ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
 
 		US_DEBUGP("jumpshot_transport:  WRITE_12: write block 0x%04lx  count %ld\n", block, blocks);
 		return jumpshot_write_data(us, info, block, blocks, ptr, srb->use_sg);
@@ -824,8 +619,9 @@
 			srb->result = CHECK_CONDITION << 1;
 		}
 		return rc;
-        }
+	}
 
-	US_DEBUGP("jumpshot_transport:  Gah! Unknown command: %d (0x%x)\n", srb->cmnd[0], srb->cmnd[0]);
+	US_DEBUGP("jumpshot_transport:  Gah! Unknown command: %d (0x%x)\n",
+		  srb->cmnd[0], srb->cmnd[0]);
 	return USB_STOR_TRANSPORT_ERROR;
 }
diff -Nru a/drivers/usb/storage/raw_bulk.c b/drivers/usb/storage/raw_bulk.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/usb/storage/raw_bulk.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,337 @@
+/*
+ * Common routines for a handful of drivers.
+ * Unrelated to CF/SM - just USB stuff.
+ *
+ * This is mostly a thin layer on top of transport.c.
+ * It converts routines that return values like -ENOENT and -EPIPE
+ * into routines that return USB_STOR_TRANSPORT_ABORTED etc.
+ *
+ * There is also some debug printing here.
+ */
+
+#include "debug.h"
+#include "transport.h"
+#include "raw_bulk.h"
+
+#ifdef CONFIG_USB_STORAGE_DEBUG
+#define DEBUG_PRCT 12
+#else
+#define DEBUG_PRCT 0
+#endif
+
+/*
+ * Send a control message and wait for the response.
+ *
+ * us - the pointer to the us_data structure for the device to use
+ *
+ * request - the URB Setup Packet's first 6 bytes. The first byte always
+ *  corresponds to the request type, and the second byte always corresponds
+ *  to the request.  The other 4 bytes do not correspond to value and index,
+ *  since they are used in a custom way by the SCM protocol.
+ *
+ * xfer_data - a buffer from which to get, or to which to store, any data
+ *  that gets send or received, respectively, with the URB. Even though
+ *  it looks like we allocate a buffer in this code for the data, xfer_data
+ *  must contain enough allocated space.
+ *
+ * xfer_len - the number of bytes to send or receive with the URB.
+ *
+ */
+
+int
+usb_storage_send_control(struct us_data *us,
+			 int pipe,
+			 unsigned char request,
+			 unsigned char requesttype,
+			 unsigned int value,
+			 unsigned int index,
+			 unsigned char *xfer_data,
+			 unsigned int xfer_len) {
+
+	int result;
+
+	// Send the URB to the device and wait for a response.
+
+	/* Why are request and request type reversed in this call? */
+
+	result = usb_stor_control_msg(us, pipe,
+			request, requesttype, value, index,
+			xfer_data, xfer_len);
+
+
+	// Check the return code for the command.
+
+	if (result < 0) {
+		/* if the command was aborted, indicate that */
+		if (result == -ENOENT)
+			return USB_STOR_TRANSPORT_ABORTED;
+
+		/* a stall is a fatal condition from the device */
+		if (result == -EPIPE) {
+			US_DEBUGP("-- Stall on control pipe. Clearing\n");
+			result = usb_stor_clear_halt(us, pipe);
+			US_DEBUGP("-- usb_stor_clear_halt() returns %d\n",
+				  result);
+			return USB_STOR_TRANSPORT_FAILED;
+		}
+
+		/* Uh oh... serious problem here */
+		return USB_STOR_TRANSPORT_ERROR;
+	}
+
+	return USB_STOR_TRANSPORT_GOOD;
+}
+
+int
+usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
+		     unsigned int len, unsigned int *act_len) {
+
+	int result;
+	int pipe;
+
+	if (direction == SCSI_DATA_READ)
+		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
+	else
+		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
+
+	result = usb_stor_bulk_msg(us, data, pipe, len, act_len);
+
+	/* if we stall, we need to clear it before we go on */
+	if (result == -EPIPE) {
+		US_DEBUGP("EPIPE: clearing endpoint halt for"
+			  " pipe 0x%x, stalled at %d bytes\n",
+			  pipe, *act_len);
+		usb_stor_clear_halt(us, pipe);
+		/* return US_BULK_TRANSFER_SHORT; */
+	}
+
+	if (result) {
+		/* -ENOENT -- we canceled this transfer */
+		if (result == -ENOENT) {
+			US_DEBUGP("raw_bulk(): transfer aborted\n");
+			return US_BULK_TRANSFER_ABORTED;
+		}
+
+		/* NAK - that means we've retried a few times already */
+       		if (result == -ETIMEDOUT)
+			US_DEBUGP("raw_bulk(): device NAKed\n");
+		else if (result == -EOVERFLOW)
+			US_DEBUGP("raw_bulk(): babble/overflow\n");
+		else if (result == -ECONNRESET)
+			US_DEBUGP("raw_bulk(): asynchronous reset\n");
+		else if (result != -EPIPE)
+			US_DEBUGP("raw_bulk(): unknown error %d\n",
+				  result);
+
+		return US_BULK_TRANSFER_FAILED;
+	}
+
+	if (*act_len != len) {
+		US_DEBUGP("Warning: Transferred only %d of %d bytes\n",
+			  *act_len, len);
+		return US_BULK_TRANSFER_SHORT;
+	}
+
+#if 0
+	US_DEBUGP("raw_bulk(): Transferred %s %d of %d bytes\n",
+		  (direction == SCSI_DATA_READ) ? "in" : "out",
+		  *act_len, len);
+#endif
+
+	return US_BULK_TRANSFER_GOOD;
+}
+
+int
+usb_storage_bulk_transport(struct us_data *us, int direction,
+			   unsigned char *data, unsigned int len,
+			   int use_sg) {
+
+	int result = USB_STOR_TRANSPORT_GOOD;
+	int transferred = 0;
+	int i;
+	struct scatterlist *sg;
+	unsigned int act_len;
+
+	if (len == 0)
+		return USB_STOR_TRANSPORT_GOOD;
+
+#if DEBUG_PRCT
+
+	if (direction == SCSI_DATA_WRITE && !use_sg) {
+		char string[64];
+
+		/* Debug-print the first N bytes of the write transfer */
+
+		strcpy(string, "wr: ");
+		for (i=0; i<len && i<DEBUG_PRCT; i++) {
+			sprintf(string+strlen(string), "%02X ", data[i]);
+			if ((i%16) == 15) {
+				US_DEBUGP("%s\n", string);
+				strcpy(string, "wr: ");
+			}
+		}
+		if ((i%16)!=0)
+			US_DEBUGP("%s\n", string);
+	}
+
+	US_DEBUGP("SCM data %s transfer %d sg buffers %d\n",
+		  (direction == SCSI_DATA_READ) ? "in" : "out",
+		  len, use_sg);
+
+#endif /* DEBUG_PRCT */
+
+	if (!use_sg)
+		result = usb_storage_raw_bulk(us, direction,
+					      data, len, &act_len);
+	else {
+		sg = (struct scatterlist *)data;
+
+		for (i=0; i<use_sg && transferred<len; i++) {
+			unsigned char *buf;
+			unsigned int length;
+
+			buf = page_address(sg[i].page) + sg[i].offset;
+			length = len-transferred;
+			if (length > sg[i].length)
+				length = sg[i].length;
+
+			result = usb_storage_raw_bulk(us, direction,
+						      buf, length, &act_len);
+			if (result != US_BULK_TRANSFER_GOOD)
+				break;
+			transferred += length;
+		}
+	}
+
+#if DEBUG_PRCT
+
+	if (direction == SCSI_DATA_READ && !use_sg) {
+		char string[64];
+
+		/* Debug-print the first N bytes of the read transfer */
+
+		strcpy(string, "rd: ");
+		for (i=0; i<len && i<act_len && i<DEBUG_PRCT; i++) {
+			sprintf(string+strlen(string), "%02X ", data[i]);
+			if ((i%16) == 15) {
+				US_DEBUGP("%s\n", string);
+				strcpy(string, "rd: ");
+			}
+		}
+		if ((i%16)!=0)
+			US_DEBUGP("%s\n", string);
+	}
+
+#endif /* DEBUG_PRCT */
+
+	return result;
+}
+
+/*
+ * The routines below convert scatter-gather to single buffer.
+ * Some drivers claim this is necessary.
+ * Nothing is done when use_sg is zero.
+ */
+
+/*
+ * Copy from scatter-gather buffer into a newly allocated single buffer,
+ * starting at a given index and offset.
+ * When done, update index and offset.
+ * Return a pointer to the single buffer.
+ */
+unsigned char *
+us_copy_from_sgbuf(unsigned char *content, int len,
+		   int *index, int *offset, int use_sg) {
+	struct scatterlist *sg;
+	unsigned char *buffer;
+	int transferred, i;
+
+	if (!use_sg)
+		return content;
+
+	sg = (struct scatterlist *)content;
+	buffer = kmalloc(len, GFP_NOIO);
+	if (buffer == NULL)
+		return NULL;
+
+	transferred = 0;
+	i = *index;
+	while (i < use_sg && transferred < len) {
+		unsigned char *ptr;
+		unsigned int length, room;
+
+		ptr = page_address(sg[i].page) + sg[i].offset + *offset;
+
+		room = sg[i].length - *offset;
+		length = len - transferred;
+		if (length > room)
+			length = room;
+
+		memcpy(buffer+transferred, ptr, length);
+		transferred += length;
+		*offset += length;
+		if (length == room) {
+			i++;
+			*offset = 0;
+		}
+	}
+	*index = i;
+
+	return buffer;
+}
+
+unsigned char *
+us_copy_from_sgbuf_all(unsigned char *content, int len, int use_sg) {
+	int index, offset;
+
+	index = offset = 0;
+	return us_copy_from_sgbuf(content, len, &index, &offset, use_sg);
+}
+
+/*
+ * Copy from a single buffer into a scatter-gather buffer,
+ * starting at a given index and offset.
+ * When done, update index and offset.
+ */
+void
+us_copy_to_sgbuf(unsigned char *buffer, int buflen,
+		 void *content, int *index, int *offset, int use_sg) {
+	struct scatterlist *sg;
+	int i, transferred;
+
+	if (!use_sg)
+		return;
+
+	transferred = 0;
+	sg = content;
+	i = *index;
+	while (i < use_sg && transferred < buflen) {
+		unsigned char *ptr;
+		unsigned int length, room;
+
+		ptr = page_address(sg[i].page) + sg[i].offset + *offset;
+
+		room = sg[i].length - *offset;
+		length = buflen - transferred;
+		if (length > room)
+			length = room;
+		
+		memcpy(ptr, buffer+transferred, length);
+		transferred += sg[i].length;
+		*offset += length;
+		if (length == room) {
+			i++;
+			*offset = 0;
+		}
+	}
+	*index = i;
+}
+
+void
+us_copy_to_sgbuf_all(unsigned char *buffer, int buflen,
+		     void *content, int use_sg) {
+	int index, offset;
+
+	index = offset = 0;
+	us_copy_to_sgbuf(buffer, buflen, content, &index, &offset, use_sg);
+}
diff -Nru a/drivers/usb/storage/raw_bulk.h b/drivers/usb/storage/raw_bulk.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/usb/storage/raw_bulk.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,35 @@
+#ifndef _USB_STORAGE_RAW_BULK_H_
+#define _USB_STORAGE_RAW_BULK_H_
+
+/* usb bulk */
+extern int usb_storage_send_control(
+	struct us_data *us, int pipe,
+	unsigned char request, unsigned char requesttype,
+	unsigned int value, unsigned int index,
+	unsigned char *xfer_data, unsigned int xfer_len);
+
+extern int usb_storage_raw_bulk(
+	struct us_data *us, int direction,
+	unsigned char *data, unsigned int len, unsigned int *act_len);
+
+extern int usb_storage_bulk_transport(
+	struct us_data *us, int direction,
+	unsigned char *data, unsigned int len, int use_sg);
+
+/* scatter-gather */
+extern unsigned char *us_copy_from_sgbuf(
+	unsigned char *content, int buflen,
+	int *index, int *offset, int use_sg);
+
+extern unsigned char *us_copy_from_sgbuf_all(
+	unsigned char *content, int len, int use_sg);
+
+extern void us_copy_to_sgbuf(
+	unsigned char *buffer, int buflen,
+	void *content, int *index, int *offset, int use_sg);
+
+extern void us_copy_to_sgbuf_all(
+	unsigned char *buffer, int buflen,
+	void *content, int use_sg);
+
+#endif
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/storage/scsiglue.c	Fri May 24 18:55:35 2002
@@ -255,7 +255,7 @@
 	/* FIXME: This needs to lock out driver probing while it's working
 	 * or we can have race conditions */
 	/* Is that still true?  I don't see how...  AS */
-        for (i = 0; i < pusb_dev_save->actconfig->bNumInterfaces; i++) {
+	for (i = 0; i < pusb_dev_save->actconfig->bNumInterfaces; i++) {
  		struct usb_interface *intf =
 			&pusb_dev_save->actconfig->interface[i];
 		const struct usb_device_id *id;
@@ -560,11 +560,11 @@
 
 	  /* copy one byte */
 	  {
-	        char *src = page_address(sg[sb].page) + sg[sb].offset + si;
-	        char *dst = page_address(sg[db].page) + sg[db].offset + di;
+		char *src = page_address(sg[sb].page) + sg[sb].offset + si;
+		char *dst = page_address(sg[db].page) + sg[db].offset + di;
 
-                 *dst = *src;
-          }
+		 *dst = *src;
+	  }
 
 	  /* get next destination */
 	  if ( sg[db].length-1 == di )
@@ -753,11 +753,11 @@
 
 	  /* copy one byte */
 	  {
-	        char *src = page_address(sg[sb].page) + sg[sb].offset + si;
-	        char *dst = page_address(sg[db].page) + sg[db].offset + di;
+		char *src = page_address(sg[sb].page) + sg[sb].offset + si;
+		char *dst = page_address(sg[db].page) + sg[db].offset + di;
 
-                 *dst = *src;
-          }
+		 *dst = *src;
+	  }
 
 	  /* get next destination */
 	  if ( di == 0 )
@@ -794,11 +794,11 @@
 	      break;
 	    }
 
-         {
-                 char *dst = page_address(sg[db].page) + sg[db].offset + di;
+	 {
+		 char *dst = page_address(sg[db].page) + sg[db].offset + di;
 
-                 *dst = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
-         }
+		 *dst = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
+	 }
 
 
 	  /* get next destination */
@@ -852,14 +852,14 @@
 		      the6->array[element] = page_address(sg[i].page) +
 			      			sg[i].offset + j;
 		      the10->array[element] = page_address(sg[i].page) +
-			                        sg[i].offset + j;
+						sg[i].offset + j;
 
 		    }
 		  else if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
 		    {
 		      /* only the longer headers still cares now */
 		      the10->array[element] = page_address(sg[i].page) +
-			                        sg[i].offset + j;
+						sg[i].offset + j;
 		       
 		    }
 		  /* increase element counter */
diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
--- a/drivers/usb/storage/sddr09.c	Fri May 24 18:55:36 2002
+++ b/drivers/usb/storage/sddr09.c	Fri May 24 18:55:36 2002
@@ -28,6 +28,7 @@
  */
 
 #include "transport.h"
+#include "raw_bulk.h"
 #include "protocol.h"
 #include "usb.h"
 #include "debug.h"
@@ -215,67 +216,6 @@
 
 static int erase_bad_lba_entries = 0;
 
-/*
- * Send a control message and wait for the response.
- *
- * us - the pointer to the us_data structure for the device to use
- *
- * request - the URB Setup Packet's first 6 bytes. The first byte always
- *  corresponds to the request type, and the second byte always corresponds
- *  to the request.  The other 4 bytes do not correspond to value and index,
- *  since they are used in a custom way by the SCM protocol.
- *
- * xfer_data - a buffer from which to get, or to which to store, any data
- *  that gets send or received, respectively, with the URB. Even though
- *  it looks like we allocate a buffer in this code for the data, xfer_data
- *  must contain enough allocated space.
- *
- * xfer_len - the number of bytes to send or receive with the URB.
- *
- */
-
-static int
-sddr09_send_control(struct us_data *us,
-		    int pipe,
-		    unsigned char request,
-		    unsigned char requesttype,
-		    unsigned int value,
-		    unsigned int index,
-		    unsigned char *xfer_data,
-		    unsigned int xfer_len) {
-
-	int result;
-
-	// Send the URB to the device and wait for a response.
-
-	/* Why are request and request type reversed in this call? */
-
-	result = usb_stor_control_msg(us, pipe,
-			request, requesttype, value, index,
-			xfer_data, xfer_len);
-
-
-	// Check the return code for the command.
-
-	if (result < 0) {
-		/* if the command was aborted, indicate that */
-		if (result == -ENOENT)
-			return USB_STOR_TRANSPORT_ABORTED;
-
-		/* a stall is a fatal condition from the device */
-		if (result == -EPIPE) {
-			US_DEBUGP("-- Stall on control pipe. Clearing\n");
-			result = usb_stor_clear_halt(us, pipe);
-			US_DEBUGP("-- usb_stor_clear_halt() returns %d\n", result);
-			return USB_STOR_TRANSPORT_FAILED;
-		}
-
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
 /* send vendor interface command (0x41) */
 /* called for requests 0, 1, 8 */
 static int
@@ -294,7 +234,7 @@
 	else
 		pipe = usb_sndctrlpipe(us->pusb_dev,0);
 
-	return sddr09_send_control(us, pipe, request, requesttype,
+	return usb_storage_send_control(us, pipe, request, requesttype,
 				   0, 0, xfer_data, xfer_len);
 }
 
@@ -305,135 +245,6 @@
 	return sddr09_send_command(us, 0, USB_DIR_OUT, command, command_len);
 }
 
-static int
-sddr09_raw_bulk(struct us_data *us, int direction,
-		unsigned char *data, unsigned int len) {
-
-	int result;
-	int act_len;
-	int pipe;
-
-	if (direction == SCSI_DATA_READ)
-		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
-	else
-		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
-
-	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
-
-        /* if we stall, we need to clear it before we go on */
-        if (result == -EPIPE) {
-       	        US_DEBUGP("EPIPE: clearing endpoint halt for"
-			" pipe 0x%x, stalled at %d bytes\n",
-			pipe, act_len);
-               	usb_stor_clear_halt(us, pipe);
-        }
-
-	if (result) {
-		/* -ENOENT -- we canceled this transfer */
-		if (result == -ENOENT) {
-			US_DEBUGP("usbat_raw_bulk(): transfer aborted\n");
-			return US_BULK_TRANSFER_ABORTED;
-		}
-
-		/* NAK - that means we've retried a few times already */
-       		if (result == -ETIMEDOUT)
-			US_DEBUGP("usbat_raw_bulk(): device NAKed\n");
-		else if (result == -EOVERFLOW)
-			US_DEBUGP("us_transfer_partial(): babble/overflow\n");
-		else if (result != -EPIPE)
-			US_DEBUGP("us_transfer_partial(): unknown error %d\n",
-				  result);
-
-		return US_BULK_TRANSFER_FAILED;
-	}
-
-	if (act_len != len) {
-		US_DEBUGP("Warning: Transferred only %d of %d bytes\n",
-			  act_len, len);
-		return US_BULK_TRANSFER_SHORT;
-	}
-
-	return US_BULK_TRANSFER_GOOD;
-}
-
-static int
-sddr09_bulk_transport(struct us_data *us, int direction,
-		      unsigned char *data, unsigned int len,
-		      int use_sg) {
-
-	int result = USB_STOR_TRANSPORT_GOOD;
-	int transferred = 0;
-	int i;
-	struct scatterlist *sg;
-	char string[64];
-
-#define DEBUG_PRCT 12
-
-	if (len == 0)
-		return USB_STOR_TRANSPORT_GOOD;
-
-	if (direction == SCSI_DATA_WRITE && !use_sg) {
-
-		/* Debug-print the first N bytes of the write transfer */
-
-		strcpy(string, "wr: ");
-		for (i=0; i<len && i<DEBUG_PRCT; i++) {
-			sprintf(string+strlen(string), "%02X ",
-				data[i]);
-			if ((i%16) == 15) {
-				US_DEBUGP("%s\n", string);
-				strcpy(string, "wr: ");
-			}
-		}
-		if ((i%16)!=0)
-			US_DEBUGP("%s\n", string);
-	}
-
-	US_DEBUGP("SCM data %s transfer %d sg buffers %d\n",
-		  (direction == SCSI_DATA_READ) ? "in" : "out",
-		  len, use_sg);
-
-	if (!use_sg)
-		result = sddr09_raw_bulk(us, direction, data, len);
-	else {
-		sg = (struct scatterlist *)data;
-
-		for (i=0; i<use_sg && transferred<len; i++) {
-			unsigned char *buf;
-			unsigned int length;
-
-			buf = page_address(sg[i].page) + sg[i].offset;
-			length = len-transferred;
-			if (length > sg[i].length)
-				length = sg[i].length;
-
-			result = sddr09_raw_bulk(us, direction, buf, length);
-			if (result != US_BULK_TRANSFER_GOOD)
-				break;
-			transferred += sg[i].length;
-		}
-	}
-
-	if (direction == SCSI_DATA_READ && !use_sg) {
-
-		/* Debug-print the first N bytes of the read transfer */
-
-		strcpy(string, "rd: ");
-		for (i=0; i<len && i<DEBUG_PRCT; i++) {
-			sprintf(string+strlen(string), "%02X ",
-				data[i]);
-			if ((i%16) == 15) {
-				US_DEBUGP("%s\n", string);
-				strcpy(string, "rd: ");
-			}
-		}
-		if ((i%16)!=0)
-			US_DEBUGP("%s\n", string);
-	}
-
-	return result;
-}
-
 #if 0
 /*
  * Test Unit Ready Command: 12 bytes.
@@ -465,6 +276,7 @@
 		0x03, LUNBITS, 0, 0, buflen, 0, 0, 0, 0, 0, 0, 0
 	};
 	int result;
+	unsigned int act_len;
 
 	result = sddr09_send_scsi_command(us, command, sizeof(command));
 	if (result != USB_STOR_TRANSPORT_GOOD) {
@@ -472,7 +284,7 @@
 		return result;
 	}
 
-	result = sddr09_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen);
+	result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len);
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		US_DEBUGP("request sense bulk in failed\n");
 	else
@@ -529,7 +341,7 @@
 		return result;
 	}
 
-	result = sddr09_bulk_transport(us, SCSI_DATA_READ,
+	result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
 				       buf, bulklen, use_sg);
 
 	if (result != USB_STOR_TRANSPORT_GOOD)
@@ -695,7 +507,7 @@
 		return result;
 	}
 
-	result = sddr09_bulk_transport(us, SCSI_DATA_WRITE,
+	result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE,
 				       buf, bulklen, use_sg);
 
 	if (result != USB_STOR_TRANSPORT_GOOD)
@@ -776,7 +588,7 @@
 	if (!buf)
 		return USB_STOR_TRANSPORT_ERROR;
 
-	result = sddr09_bulk_transport(us, SCSI_DATA_READ,
+	result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
 				       buf, bulklen, 0);
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		US_DEBUGP("Result for bulk_transport in sddr09_read_sg %d\n",
@@ -814,7 +626,7 @@
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
-	result = sddr09_bulk_transport(us, SCSI_DATA_READ,
+	result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
 				       data, sizeof(data), 0);
 	*status = data[0];
 	return result;
@@ -832,8 +644,7 @@
 	unsigned int page, pages;
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
-	struct scatterlist *sg = NULL;
-	int result, i, len;
+	int result, len;
 
 	// If we're using scatter-gather, we have to create a new
 	// buffer to read all of the data in first, since a
@@ -844,14 +655,11 @@
 
 	len = sectors*info->pagesize;
 
-	if (use_sg) {
-		sg = (struct scatterlist *)content;
-		buffer = kmalloc(len, GFP_NOIO);
-		if (buffer == NULL)
-			return USB_STOR_TRANSPORT_ERROR;
-		ptr = buffer;
-	} else
-		ptr = content;
+	buffer = (use_sg ? kmalloc(len, GFP_NOIO) : content);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
+
+	ptr = buffer;
 
 	// Figure out the initial LBA and page
 	lba = address >> info->blockshift;
@@ -913,23 +721,8 @@
 		ptr += (pages << info->pageshift);
 	}
 
-	if (use_sg && result == USB_STOR_TRANSPORT_GOOD) {
-		int transferred = 0;
-
-		for (i=0; i<use_sg && transferred<len; i++) {
-			unsigned char *buf;
-			unsigned int length;
-
-			buf = page_address(sg[i].page) + sg[i].offset;
-
-			length = len-transferred;
-			if (length > sg[i].length)
-				length = sg[i].length;
-
-			memcpy(buf, buffer+transferred, length);
-			transferred += sg[i].length;
-		}
-	}
+	if (use_sg && result == USB_STOR_TRANSPORT_GOOD)
+		us_copy_to_sgbuf_all(buffer, len, content, use_sg);
 
 	if (use_sg)
 		kfree(buffer);
@@ -1080,50 +873,20 @@
 	unsigned int lba, page, pages;
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
-	struct scatterlist *sg = NULL;
-	int result, i, len;
-
-	// If we're using scatter-gather, we have to create a new
-	// buffer to write all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
+	int result, len;
 
 	len = sectors*info->pagesize;
 
-	if (use_sg) {
-		int transferred = 0;
-
-		sg = (struct scatterlist *)content;
-		buffer = kmalloc(len, GFP_NOIO);
-		if (buffer == NULL)
-			return USB_STOR_TRANSPORT_ERROR;
-
-		for (i=0; i<use_sg && transferred<len; i++) {
-			unsigned char *buf;
-			unsigned int length;
-
-			buf = page_address(sg[i].page) + sg[i].offset;
-
-			length = len-transferred;
-			if (length > sg[i].length)
-				length = sg[i].length;
+	buffer = us_copy_from_sgbuf_all(content, len, use_sg);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
 
-			memcpy(buffer+transferred, buf, length);
-			transferred += sg[i].length;
-		}
-		ptr = buffer;
-	} else
-		ptr = content;
+	ptr = buffer;
 
 	// Figure out the initial LBA and page
 	lba = address >> info->blockshift;
 	page = (address & info->blockmask);
 
-	// This could be made much more efficient by checking for
-	// contiguous LBA's. Another exercise left to the student.
-
 	result = USB_STOR_TRANSPORT_GOOD;
 
 	while (sectors > 0) {
@@ -1185,7 +948,7 @@
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
-	result = sddr09_bulk_transport(us, SCSI_DATA_READ, content, 64, 0);
+	result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, 64, 0);
 
 	for (i = 0; i < 4; i++)
 		deviceID[i] = content[i];
@@ -1792,7 +1555,7 @@
 			  "sending" : "receiving",
 			  srb->request_bufflen);
 
-		result = sddr09_bulk_transport(us,
+		result = usb_storage_bulk_transport(us,
 					       srb->sc_data_direction,
 					       srb->request_buffer, 
 					       srb->request_bufflen,
diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
--- a/drivers/usb/storage/sddr55.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/storage/sddr55.c	Fri May 24 18:55:35 2002
@@ -25,12 +25,13 @@
  */
 
 #include "transport.h"
+#include "raw_bulk.h"
 #include "protocol.h"
 #include "usb.h"
 #include "debug.h"
 #include "sddr55.h"
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 
@@ -70,142 +71,16 @@
 #define CIS_BLOCK		0x400
 #define UNUSED_BLOCK		0x3ff
 
-
-
-static int sddr55_raw_bulk(struct us_data *us, 
-		int direction,
-		unsigned char *data,
-		unsigned int len) {
-
-	int result;
-	int act_len;
-	int pipe;
-
-	if (direction == SCSI_DATA_READ)
-		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
-	else
-		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
-
-	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
-
-	/* if we stall, we need to clear it before we go on */
-	if (result == -EPIPE) {
-		US_DEBUGP("EPIPE: clearing endpoint halt for"
-			" pipe 0x%x, stalled at %d bytes\n",
-			pipe, act_len);
-		usb_clear_halt(us->pusb_dev, pipe);
-	}
-
-	if (result) {
-
-		/* NAK - that means we've retried a few times already */
-		if (result == -ETIMEDOUT) {
-			US_DEBUGP("usbat_raw_bulk():"
-				" device NAKed\n");
-
-			return US_BULK_TRANSFER_FAILED;
-		}
-
-		/* -ENOENT -- we canceled this transfer */
-		if (result == -ENOENT) {
-			US_DEBUGP("usbat_raw_bulk():"
-				" transfer aborted\n");
-			return US_BULK_TRANSFER_ABORTED;
-		}
-
-		if (result == -EPIPE) {
-			US_DEBUGP("usbat_raw_bulk():"
-				" output pipe stalled\n");
-			return US_BULK_TRANSFER_FAILED;
-		}
-
-		/* the catch-all case */
-		US_DEBUGP("us_transfer_partial(): unknown error\n");
-		return US_BULK_TRANSFER_FAILED;
-	}
-
-	if (act_len != len) {
-		US_DEBUGP("Warning: Transferred only %d bytes\n",
-			act_len);
-		return US_BULK_TRANSFER_SHORT;
-	}
-
-	US_DEBUGP("Transferred %d of %d bytes\n", act_len, len);
-
-	return US_BULK_TRANSFER_GOOD;
-}
-
-/*
- * Note: direction must be set if command_len == 0.
- */
-
-static int sddr55_bulk_transport(struct us_data *us,
-			  int direction,
-			  unsigned char *data,
-			  unsigned int len) {
-
-	int result = USB_STOR_TRANSPORT_GOOD;
+static int
+sddr55_bulk_transport(struct us_data *us, int direction,
+		      unsigned char *data, unsigned int len) {
 	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
 
-	if (len==0)
-		return USB_STOR_TRANSPORT_GOOD;
-
-	info->last_access = jiffies;
-
-#ifdef CONFIG_USB_STORAGE_DEBUG
-	if (direction == SCSI_DATA_WRITE) {
-		int i;
-		char string[64];
-
-		/* Debug-print the first 48 bytes of the write transfer */
-
-		strcpy(string, "wr: ");
-		for (i=0; i<len && i<48; i++) {
-			sprintf(string+strlen(string), "%02X ",
-			  data[i]);
-			if ((i%16)==15) {
-				US_DEBUGP("%s\n", string);
-				strcpy(string, "wr: ");
-			}
-		}
-		if ((i%16)!=0)
-			US_DEBUGP("%s\n", string);
-	}
-#endif
-
-	/* transfer the data */
-
-	US_DEBUGP("SCM data %s transfer %d\n",
-		  ( direction==SCSI_DATA_READ ? "in" : "out"),
-		  len);
-
-	result = sddr55_raw_bulk(us, direction, data, len);
-
-#ifdef CONFIG_USB_STORAGE_DEBUG
-	if (direction == SCSI_DATA_READ) {
-		int i;
-		char string[64];
-
-		/* Debug-print the first 48 bytes of the read transfer */
-
-		strcpy(string, "rd: ");
-		for (i=0; i<len && i<48; i++) {
-			sprintf(string+strlen(string), "%02X ",
-			  data[i]);
-			if ((i%16)==15) {
-				US_DEBUGP("%s\n", string);
-				strcpy(string, "rd: ");
-			}
-		}
-		if ((i%16)!=0)
-			US_DEBUGP("%s\n", string);
-	}
-#endif
-
-	return result;
+	if (len)
+		info->last_access = jiffies;
+	return usb_storage_bulk_transport(us, direction, data, len, 0);
 }
 
-
 /* check if card inserted, if there is, update read_only status
  * return non zero if no card
  */
@@ -278,7 +153,7 @@
 		unsigned char *content,
 		int use_sg) {
 
-	int result;
+	int result = USB_STOR_TRANSPORT_GOOD;
 	unsigned char command[8] = {
 		0, 0, 0, 0, 0, 0xb0, 0, 0x85
 	};
@@ -291,31 +166,15 @@
 	unsigned short pages;
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
-	struct scatterlist *sg = NULL;
-	int i;
 	int len;
-	int transferred;
-
-	// If we're using scatter-gather, we have to create a new
-	// buffer to read all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
 
 	len = sectors * PAGESIZE;
 
-	if (use_sg) {
-		sg = (struct scatterlist *)content;
-		buffer = kmalloc(len, GFP_NOIO);
-		if (buffer == NULL)
-			return USB_STOR_TRANSPORT_ERROR;
-		ptr = buffer;
-	} else
-		ptr = content;
+	buffer = (use_sg ? kmalloc(len, GFP_NOIO) : content);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR; /* out of memory */
 
-	// This could be made much more efficient by checking for
-	// contiguous LBA's. Another exercise left to the student.
+	ptr = buffer;
 
 	while (sectors>0) {
 
@@ -355,42 +214,30 @@
 			US_DEBUGP("Result for send_command in read_data %d\n",
 				result);
 
-			if (result != US_BULK_TRANSFER_GOOD) {
-				if (use_sg)
-					kfree(buffer);
-				return result;
-			}
+			if (result != US_BULK_TRANSFER_GOOD)
+				goto leave;
 
 			/* read data */
 			result = sddr55_bulk_transport(us,
 				SCSI_DATA_READ, ptr,
 				pages<<info->pageshift);
 
-			if (result != US_BULK_TRANSFER_GOOD) {
-				if (use_sg)
-					kfree(buffer);
-				return result;
-			}
+			if (result != US_BULK_TRANSFER_GOOD)
+				goto leave;
 
 			/* now read status */
 			result = sddr55_bulk_transport(us,
 				SCSI_DATA_READ, status, 2);
 
-			if (result != US_BULK_TRANSFER_GOOD) {
-				if (use_sg)
-					kfree(buffer);
-				return result;
-			}
+			if (result != US_BULK_TRANSFER_GOOD)
+				goto leave;
 
 			/* check status for error */
 			if (status[0] == 0xff && status[1] == 0x4) {
 				set_sense_info (3, 0x11, 0);
-				if (use_sg)
-					kfree(buffer);
-
-				return USB_STOR_TRANSPORT_FAILED;
+				result = USB_STOR_TRANSPORT_FAILED;
+				goto leave;
 			}
-
 		}
 
 		page = 0;
@@ -399,18 +246,13 @@
 		ptr += (pages << info->pageshift);
 	}
 
-	if (use_sg) {
-		transferred = 0;
-		for (i=0; i<use_sg && transferred<len; i++) {
-			memcpy(page_address(sg[i].page) + sg[i].offset, buffer+transferred,
-				len-transferred > sg[i].length ?
-					sg[i].length : len-transferred);
-			transferred += sg[i].length;
-		}
+	us_copy_to_sgbuf_all(buffer, len, content, use_sg);
+
+leave:
+	if (use_sg)
 		kfree(buffer);
-	}
 
-	return USB_STOR_TRANSPORT_GOOD;
+	return result;
 }
 
 static int sddr55_write_data(struct us_data *us,
@@ -420,7 +262,7 @@
 		unsigned char *content,
 		int use_sg) {
 
-	int result;
+	int result = USB_STOR_TRANSPORT_GOOD;
 	unsigned char command[8] = {
 		0, 0, 0, 0, 0, 0xb0, 0, 0x86
 	};
@@ -434,10 +276,7 @@
 	unsigned short pages;
 	unsigned char *buffer = NULL;
 	unsigned char *ptr;
-	struct scatterlist *sg = NULL;
-	int i;
-	int len;
-	int transferred;
+	int i, len;
 
 	/* check if we are allowed to write */
 	if (info->read_only || info->force_read_only) {
@@ -445,33 +284,13 @@
 		return USB_STOR_TRANSPORT_FAILED;
 	}
 
-	// If we're using scatter-gather, we have to create a new
-	// buffer to write all of the data in first, since a
-	// scatter-gather buffer could in theory start in the middle
-	// of a page, which would be bad. A developer who wants a
-	// challenge might want to write a limited-buffer
-	// version of this code.
-
 	len = sectors * PAGESIZE;
 
-	if (use_sg) {
-		sg = (struct scatterlist *)content;
-		buffer = kmalloc(len, GFP_NOIO);
-		if (buffer == NULL)
-			return USB_STOR_TRANSPORT_ERROR;
-
-		transferred = 0;
-		for (i=0; i<use_sg && transferred<len; i++) {
-			memcpy(buffer+transferred, 
-				page_address(sg[i].page) + sg[i].offset,
-				len-transferred > sg[i].length ?
-					sg[i].length : len-transferred);
-			transferred += sg[i].length;
-		}
+	buffer = us_copy_from_sgbuf_all(content, len, use_sg);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
 
-		ptr = buffer;
-	} else
-		ptr = content;
+	ptr = buffer;
 
 	while (sectors > 0) {
 
@@ -508,10 +327,12 @@
 			if (max_pba > 1024)
 				max_pba = 1024;
 
-			/* scan through the map lookiong for an unused block
-			 * leave 16 unused blocks at start (or as many as possible)
-			 * since the sddr55 seems to reuse a used block when it shouldn't
-			 * if we don't leave space */
+			/*
+			 * Scan through the map looking for an unused block
+			 * leave 16 unused blocks at start (or as many as
+			 * possible) since the sddr55 seems to reuse a used
+			 * block when it shouldn't if we don't leave space.
+			 */
 			for (i = 0; i < max_pba; i++, pba++) {
 				if (info->pba_to_lba[pba] == UNUSED_BLOCK) {
 					found_pba = pba;
@@ -523,15 +344,12 @@
 			pba = found_pba;
 
 			if (pba == -1) {
-				/* oh dear, couldn't find an unallocated block */
+				/* oh dear */
 				US_DEBUGP("Couldn't find unallocated block\n");
 
 				set_sense_info (3, 0x31, 0);	/* medium error */
-
-				if (use_sg)
-					kfree(buffer);
-
-				return USB_STOR_TRANSPORT_FAILED;
+				result = USB_STOR_TRANSPORT_FAILED;
+				goto leave;
 			}
 
 			US_DEBUGP("Allocating PBA %04X for LBA %04X\n", pba, lba);
@@ -560,11 +378,9 @@
 			US_DEBUGP("Result for send_command in write_data %d\n",
 			result);
 
-			set_sense_info (3, 0x3, 0);	/* peripheral write error */
-			
-			if (use_sg)
-				kfree(buffer);
-			return result;
+			/* set_sense_info is superfluous here? */
+			set_sense_info (3, 0x3, 0);/* peripheral write error */
+			goto leave;
 		}
 
 		/* send the data */
@@ -574,41 +390,35 @@
 
 		if (result != US_BULK_TRANSFER_GOOD) {
 			US_DEBUGP("Result for send_data in write_data %d\n",
-			result);
+				  result);
 
-			set_sense_info (3, 0x3, 0);	/* peripheral write error */
-
-			if (use_sg)
-				kfree(buffer);
-			return result;
+			/* set_sense_info is superfluous here? */
+			set_sense_info (3, 0x3, 0);/* peripheral write error */
+			goto leave;
 		}
 
 		/* now read status */
-		result = sddr55_bulk_transport(us,
-			SCSI_DATA_READ, status,	6);
+		result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6);
 
 		if (result != US_BULK_TRANSFER_GOOD) {
 			US_DEBUGP("Result for get_status in write_data %d\n",
-			result);
-
-			set_sense_info (3, 0x3, 0);	/* peripheral write error */
+				  result);
 
-			if (use_sg)
-				kfree(buffer);
-			return result;
+			/* set_sense_info is superfluous here? */
+			set_sense_info (3, 0x3, 0);/* peripheral write error */
+			goto leave;
 		}
 
-		new_pba = (status[3] + (status[4] << 8) + (status[5] << 16)) >> info->blockshift;
+		new_pba = (status[3] + (status[4] << 8) + (status[5] << 16))
+						  >> info->blockshift;
 
 		/* check status for error */
 		if (status[0] == 0xff && status[1] == 0x4) {
-			set_sense_info (3, 0x0c, 0);
-			if (use_sg)
-				kfree(buffer);
-
 			info->pba_to_lba[new_pba] = BAD_BLOCK;
 
-			return USB_STOR_TRANSPORT_FAILED;
+			set_sense_info (3, 0x0c, 0);
+			result = USB_STOR_TRANSPORT_FAILED;
+			goto leave;
 		}
 
 		US_DEBUGP("Updating maps for LBA %04X: old PBA %04X, new PBA %04X\n",
@@ -624,10 +434,8 @@
 				new_pba, info->pba_to_lba[new_pba]);
 			info->fatal_error = 1;
 			set_sense_info (3, 0x31, 0);
-			if (use_sg)
-				kfree(buffer);
-
-			return USB_STOR_TRANSPORT_FAILED;
+			result = USB_STOR_TRANSPORT_FAILED;
+			goto leave;
 		}
 
 		/* update the pba<->lba maps for new_pba */
@@ -639,11 +447,10 @@
 		ptr += (pages << info->pageshift);
 	}
 
-	if (use_sg) {
+ leave:
+	if (use_sg)
 		kfree(buffer);
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
+	return result;
 }
 
 static int sddr55_read_deviceID(struct us_data *us,
@@ -982,7 +789,8 @@
 		}
 	}
 
-	/* if we detected a problem with the map when writing, don't allow any more access */
+	/* if we detected a problem with the map when writing,
+	   don't allow any more access */
 	if (info->fatal_error) {
 
 		set_sense_info (3, 0x31, 0);
@@ -994,14 +802,14 @@
 		capacity = sddr55_get_capacity(us);
 
 		if (!capacity) {
-			set_sense_info (3, 0x30, 0);	/* incompatible medium */
+			set_sense_info (3, 0x30, 0); /* incompatible medium */
 			return USB_STOR_TRANSPORT_FAILED;
 		}
 
 		info->capacity = capacity;
 
-                /* figure out the maximum logical block number, allowing for the fact
-                 * that only 250 out of every 256 are used */
+		/* figure out the maximum logical block number, allowing for
+		 * the fact that only 250 out of every 256 are used */
 		info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250;
 
 		/* Last page in the card, adjust as we only use 250 out of every 256 pages */
@@ -1106,14 +914,14 @@
 
 		if (srb->cmnd[0] == WRITE_10) {
 			US_DEBUGP("WRITE_10: write block %04X (LBA %04X) page %01X"
-			        " pages %d\n",
-			        pba, lba, page, pages);
+				" pages %d\n",
+				pba, lba, page, pages);
 
 			return sddr55_write_data(us, lba, page, pages, ptr, srb->use_sg);
 		} else {
 			US_DEBUGP("READ_10: read block %04X (LBA %04X) page %01X"
-			        " pages %d\n",
-			        pba, lba, page, pages);
+				" pages %d\n",
+				pba, lba, page, pages);
 
 			return sddr55_read_data(us, lba, page, pages, ptr, srb->use_sg);
 		}
diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
--- a/drivers/usb/storage/shuttle_usbat.c	Fri May 24 18:55:33 2002
+++ b/drivers/usb/storage/shuttle_usbat.c	Fri May 24 18:55:33 2002
@@ -40,6 +40,7 @@
  */
 
 #include "transport.h"
+#include "raw_bulk.h"
 #include "protocol.h"
 #include "usb.h"
 #include "debug.h"
@@ -61,174 +62,6 @@
 
 int transferred = 0;
 
-/*
- * Send a control message and wait for the response.
- *
- * us - the pointer to the us_data structure for the device to use
- *
- * request - the URB Setup Packet's first 6 bytes. The first byte always
- *  corresponds to the request type, and the second byte always corresponds
- *  to the request.  The other 4 bytes do not correspond to value and index,
- *  since they are used in a custom way by the SCM protocol.
- *
- * xfer_data - a buffer from which to get, or to which to store, any data
- *  that gets send or received, respectively, with the URB. Even though
- *  it looks like we allocate a buffer in this code for the data, xfer_data
- *  must contain enough allocated space.
- *
- * xfer_len - the number of bytes to send or receive with the URB.
- *
- */
-
-static int usbat_send_control(struct us_data *us,
-		int pipe,
-		unsigned char request,
-		unsigned char requesttype,
-		unsigned short value,
-		unsigned short index,
-		unsigned char *xfer_data,
-		unsigned int xfer_len) {
-
-	int result;
-
-	// Send the URB to the device and wait for a response.
-
-	/* Why are request and request type reversed in this call? */
-
-	result = usb_stor_control_msg(us, pipe,
-			request, requesttype, value, index,
-			xfer_data, xfer_len);
-
-
-	// Check the return code for the command.
-
-	if (result < 0) {
-		/* if the command was aborted, indicate that */
-		if (result == -ENOENT)
-			return USB_STOR_TRANSPORT_ABORTED;
-
-		/* a stall is a fatal condition from the device */
-		if (result == -EPIPE) {
-			US_DEBUGP("-- Stall on control pipe. Clearing\n");
-			result = usb_stor_clear_halt(us, pipe);
-			US_DEBUGP("-- usb_stor_clear_halt() returns %d\n", result);
-			return USB_STOR_TRANSPORT_FAILED;
-		}
-
-		/* Uh oh... serious problem here */
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-static int usbat_raw_bulk(struct us_data *us, 
-		int direction,
-		unsigned char *data,
-		unsigned short len) {
-
-	int result;
-	int act_len;
-	int pipe;
-
-	if (direction == SCSI_DATA_READ)
-		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
-	else
-		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
-
-	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
-
-        /* if we stall, we need to clear it before we go on */
-        if (result == -EPIPE) {
-       	        US_DEBUGP("EPIPE: clearing endpoint halt for"
-			" pipe 0x%x, stalled at %d bytes\n",
-			pipe, act_len);
-               	usb_stor_clear_halt(us, pipe);
-        }
-
-	if (result) {
-
-                /* NAK - that means we've retried a few times already */
-       	        if (result == -ETIMEDOUT) {
-                        US_DEBUGP("usbat_raw_bulk():"
-				" device NAKed\n");
-                        return US_BULK_TRANSFER_FAILED;
-                }
-
-                /* -ENOENT -- we canceled this transfer */
-                if (result == -ENOENT) {
-                        US_DEBUGP("usbat_raw_bulk():"
-				" transfer aborted\n");
-                        return US_BULK_TRANSFER_ABORTED;
-                }
-
-		if (result == -EPIPE) {
-			US_DEBUGP("usbat_raw_bulk():"
-				" output pipe stalled\n");
-			return US_BULK_TRANSFER_SHORT;
-		}
-
-                /* the catch-all case */
-                US_DEBUGP("us_transfer_partial(): unknown error\n");
-                return US_BULK_TRANSFER_FAILED;
-        }
-
-	if (act_len != len) {
-		US_DEBUGP("Warning: Transferred only %d bytes\n",
-			act_len);
-		return US_BULK_TRANSFER_SHORT;
-	}
-
-	US_DEBUGP("Transferred %s %d of %d bytes\n", 
-		direction==SCSI_DATA_READ ? "in" : "out", act_len, len);
-
-	return US_BULK_TRANSFER_GOOD;
-}
-
-/*
- * Note: direction must be set if command_len == 0.
- */
-
-static int usbat_bulk_transport(struct us_data *us,
-			  unsigned char *command,
-			  unsigned short command_len,
-			  int direction,
-			  unsigned char *data,
-			  unsigned short len,
-			  int use_sg) {
-
-	int result = USB_STOR_TRANSPORT_GOOD;
-	int transferred = 0;
-	int i;
-	struct scatterlist *sg;
-
-	if (len==0)
-		return USB_STOR_TRANSPORT_GOOD;
-
-	/* transfer the data payload for the command, if there is any */
-
-	if (command_len != 0)
-		direction = (command[0]&0x80) ? SCSI_DATA_READ :
-			SCSI_DATA_WRITE;
-
-	if (!use_sg)
-		result = usbat_raw_bulk(us, direction, data, len);
-	else {
-		sg = (struct scatterlist *)data;
-		for (i=0; i<use_sg && transferred<len; i++) {
-			result = usbat_raw_bulk(us, direction,
-				page_address(sg[i].page) + sg[i].offset, 
-				len-transferred > sg[i].length ?
-					sg[i].length : len-transferred);
-			if (result!=US_BULK_TRANSFER_GOOD)
-				break;
-			transferred += sg[i].length;
-		}
-	}
-
-	return result;
-}
-
 int usbat_read(struct us_data *us,
 	     unsigned char access,
 	     unsigned char reg, 
@@ -236,7 +69,7 @@
 
 	int result;
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_rcvctrlpipe(us->pusb_dev,0),
 		access,
 		0xC0,
@@ -255,7 +88,7 @@
 
 	int result;
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		access|0x01,
 		0x40,
@@ -281,7 +114,7 @@
 		test_pattern, mask_byte, subcountL, subcountH
 	};
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		0x80,
 		0x40,
@@ -306,7 +139,7 @@
 		LSB_of(len), MSB_of(len)
 	};
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		0x80,
 		0x40,
@@ -318,8 +151,7 @@
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
-	result = usbat_bulk_transport(us,
-		NULL, 0, SCSI_DATA_READ, content, len, use_sg);
+	result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg);
 
 	return result;
 }
@@ -388,7 +220,7 @@
 		LSB_of(len), MSB_of(len)
 	};
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		0x80,
 		0x40,
@@ -400,8 +232,7 @@
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
-	result = usbat_bulk_transport(us,
-		NULL, 0, SCSI_DATA_WRITE, content, len, use_sg);
+	result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg);
 
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
@@ -460,7 +291,7 @@
 		 * that, we just return a failure.
 		 */
 
-		result = usbat_send_control(us,
+		result = usb_storage_send_control(us,
 			  usb_sndctrlpipe(us->pusb_dev,0),
 			0x80,
 			0x40,
@@ -474,8 +305,8 @@
 
 		if (i==0) {
 
-			result = usbat_bulk_transport(us,
-				NULL, 0, SCSI_DATA_WRITE, 
+			result = usb_storage_bulk_transport(us,
+				SCSI_DATA_WRITE, 
 				data, num_registers*2, 0);
 
 			if (result!=USB_STOR_TRANSPORT_GOOD)
@@ -488,8 +319,8 @@
 		//	direction == SCSI_DATA_WRITE ? "out" : "in",
 		//	len, use_sg);
 
-		result = usbat_bulk_transport(us,
-			NULL, 0, direction, content, len, use_sg);
+		result = usb_storage_bulk_transport(us,
+			direction, content, len, use_sg);
 
 		/*
 		 * If we get a stall on the bulk download, we'll retry
@@ -576,7 +407,7 @@
 		data[1+(i<<1)] = data_out[i];
 	}
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		0x80,
 		0x40,
@@ -588,10 +419,10 @@
 	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
-	result = usbat_bulk_transport(us,
-		NULL, 0, SCSI_DATA_WRITE, data, num_registers*2, 0);
+	result = usb_storage_bulk_transport(us,
+		SCSI_DATA_WRITE, data, num_registers*2, 0);
 
-	if (result!=USB_STOR_TRANSPORT_GOOD)
+	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
 	return usbat_wait_not_busy(us, 0);
@@ -602,7 +433,7 @@
 
 	int result;
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_rcvctrlpipe(us->pusb_dev,0),
 		0x82,
 		0xC0,
@@ -620,7 +451,7 @@
 
 	int result;
 
-	result = usbat_send_control(us,
+	result = usb_storage_send_control(us,
 		usb_sndctrlpipe(us->pusb_dev,0),
 		0x82,
 		0x40,
@@ -646,7 +477,6 @@
 	unsigned char *buffer;
 	unsigned int len;
 	unsigned int sector;
-	unsigned int amount;
 	struct scatterlist *sg = NULL;
 	int sg_segment = 0;
 	int sg_offset = 0;
@@ -735,31 +565,11 @@
 
 		// Transfer the received data into the srb buffer
 
-		if (!srb->use_sg) {
+		if (srb->use_sg)
+			us_copy_to_sgbuf(buffer, len, sg,
+					 &sg_segment, &sg_offset, srb->use_sg);
+		else
 			memcpy(srb->request_buffer+transferred, buffer, len);
-		} else {
-			amount = 0;
-			while (amount<len) {
-				if (len - amount >= 
-					  sg[sg_segment].length-sg_offset) {
-				  memcpy(page_address(sg[sg_segment].page) +
-					 sg[sg_segment].offset + sg_offset,
-					 buffer + amount,
-					 sg[sg_segment].length - sg_offset);
-				  amount += 
-					  sg[sg_segment].length-sg_offset;
-				  sg_segment++;
-				  sg_offset=0;
-				} else {
-				  memcpy(page_address(sg[sg_segment].page) +
-					 sg[sg_segment].offset + sg_offset,
-					 buffer + amount,
-					 len - amount);
-				  sg_offset += (len - amount);
-				  amount = len;
-				}
-			}
-		}
 
 		// Update the amount transferred and the sector number
 
diff -Nru a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
--- a/drivers/usb/storage/transport.h	Fri May 24 18:55:35 2002
+++ b/drivers/usb/storage/transport.h	Fri May 24 18:55:35 2002
@@ -151,10 +151,13 @@
 extern void usb_stor_invoke_transport(Scsi_Cmnd*, struct us_data*);
 extern void usb_stor_abort_transport(struct us_data*);
 extern int usb_stor_transfer_partial(struct us_data*, char*, int);
-extern int usb_stor_bulk_msg(struct us_data*, void*, int, unsigned int,
-		unsigned int*);
-extern int usb_stor_control_msg(struct us_data*, unsigned int, u8, u8,
-		u16, u16, void*, u16);
+
+extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
+		unsigned int len, unsigned int *act_len);
+extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
+		u8 request, u8 requesttype, u16 value, u16 index,
+		void *data, u16 size);
+
 extern int usb_stor_clear_halt(struct us_data*, int );
 extern void usb_stor_transfer(Scsi_Cmnd*, struct us_data*);
 #endif
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c	Fri May 24 18:55:34 2002
+++ b/drivers/usb/storage/usb.c	Fri May 24 18:55:34 2002
@@ -47,6 +47,8 @@
  */
 
 #include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
@@ -323,6 +325,7 @@
 	/* avoid getting signals */
 	spin_lock_irq(&current->sigmask_lock);
 	flush_signals(current);
+	current->flags |= PF_IOTHREAD;
 	sigfillset(&current->blocked);
 	recalc_sigpending();
 	spin_unlock_irq(&current->sigmask_lock);
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h	Fri May 24 18:55:36 2002
+++ b/drivers/usb/storage/usb.h	Fri May 24 18:55:36 2002
@@ -48,6 +48,7 @@
 #include <linux/blk.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
+#include <linux/version.h>
 #include "scsi.h"
 #include "hosts.h"
 
diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
--- a/drivers/usb/usb-skeleton.c	Fri May 24 18:55:35 2002
+++ b/drivers/usb/usb-skeleton.c	Fri May 24 18:55:35 2002
@@ -37,18 +37,14 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/fcntl.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <linux/list.h>
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
+#include <asm/uaccess.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_USB_DEBUG
diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile
--- a/drivers/video/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/video/Makefile	Fri May 24 18:55:33 2002
@@ -88,26 +88,10 @@
 obj-$(CONFIG_FB_MAXINE)           += maxinefb.o
 obj-$(CONFIG_FB_TX3912)           += tx3912fb.o
 
-
-subdir-$(CONFIG_FB_MATROX)	  += matrox
-ifeq ($(CONFIG_FB_MATROX),y)
-obj-y				  += matrox/matrox.o
-endif
-
-subdir-$(CONFIG_FB_RIVA)	  += riva
-ifeq ($(CONFIG_FB_RIVA),y)
-obj-y				  += riva/rivafb.o
-endif
-
-subdir-$(CONFIG_FB_SIS)		  += sis
-ifeq ($(CONFIG_FB_SIS),y)
-obj-y				  += sis/sisfb.o
-endif
-
-subdir-$(CONFIG_FB_ATY)		  += aty
-ifeq ($(CONFIG_FB_ATY),y)
-obj-y				  += aty/atyfb.o
-endif
+obj-$(CONFIG_FB_MATROX)		  += matrox/
+obj-$(CONFIG_FB_RIVA)		  += riva/
+obj-$(CONFIG_FB_SIS)		  += sis/
+obj-$(CONFIG_FB_ATY)		  += aty/
 
 obj-$(CONFIG_FB_SUN3)             += sun3fb.o
 obj-$(CONFIG_FB_BWTWO)            += bwtwofb.o
diff -Nru a/drivers/video/acornfb.c b/drivers/video/acornfb.c
--- a/drivers/video/acornfb.c	Fri May 24 18:55:35 2002
+++ b/drivers/video/acornfb.c	Fri May 24 18:55:35 2002
@@ -601,13 +601,13 @@
 	/* Find int 'y', such that y * fll == s * sam < maxsize
 	 * y = s * sam / fll; s = maxsize / sam
 	 */
-	for (size = current_par.screen_size; min_size <= size;
+	for (size = current_par.screen_size;
+	     nr_y = size / font_line_len, min_size <= size;
 	     size -= sam_size) {
-		nr_y = size / font_line_len;
-
 		if (nr_y * font_line_len == size)
 			break;
 	}
+	nr_y *= fontht;
 
 	if (var->accel_flags & FB_ACCELF_TEXT) {
 		if (min_size > size) {
@@ -617,8 +617,9 @@
 			size = current_par.screen_size;
 			var->yres_virtual = size / (font_line_len / fontht);
 		} else
-			var->yres_virtual = nr_y * fontht;
-	}
+			var->yres_virtual = nr_y;
+	} else if (var->yres_virtual > nr_y)
+		var->yres_virtual = nr_y;
 
 	current_par.screen_end = current_par.screen_base_p + size;
 
@@ -1100,6 +1101,41 @@
 	return 0;
 }
 
+static int 
+acornfb_blank(int blank, struct fb_info *info)
+{
+	union palette p;
+	int i, bpp = fb_display[info->currcon].var.bits_per_pixel;
+
+#ifdef FBCON_HAS_CFB16
+	if (bpp == 16) {
+		p.p = 0;
+
+		for (i = 0; i < 256; i++) {
+			if (blank)
+				p = acornfb_palette_encode(i, 0, 0, 0, 0);
+			else {
+				p.vidc20.red   = current_par.palette[ i       & 31].vidc20.red;
+				p.vidc20.green = current_par.palette[(i >> 1) & 31].vidc20.green;
+				p.vidc20.blue  = current_par.palette[(i >> 2) & 31].vidc20.blue;
+			}
+			acornfb_palette_write(i, current_par.palette[i]);
+		}
+	} else
+#endif
+	{
+		for (i = 0; i < current_par.palette_size; i++) {
+			if (blank)
+				p = acornfb_palette_encode(i, 0, 0, 0, 0);
+			else
+				p = current_par.palette[i];
+
+			acornfb_palette_write(i, p);
+		}
+	}
+	return 0;
+}
+
 /*
  * Note that we are entered with the kernel locked.
  */
@@ -1146,7 +1182,7 @@
 	fb_set_var:	acornfb_set_var,
 	fb_get_cmap:	acornfb_get_cmap,
 	fb_set_cmap:	gen_set_cmap,
-	fb_set_colreg:	acornfb_setcolreg,
+	fb_setcolreg:	acornfb_setcolreg,
 	fb_pan_display:	acornfb_pan_display,
 	fb_blank:	acornfb_blank,
 	fb_mmap:	acornfb_mmap,
@@ -1182,41 +1218,6 @@
 	return 0;
 }
 
-static int 
-acornfb_blank(int blank, struct fb_info *info)
-{
-	union palette p;
-	int i, bpp = fb_display[info->currcon].var.bits_per_pixel;
-
-#ifdef FBCON_HAS_CFB16
-	if (bpp == 16) {
-		p.p = 0;
-
-		for (i = 0; i < 256; i++) {
-			if (blank)
-				p = acornfb_palette_encode(i, 0, 0, 0, 0);
-			else {
-				p.vidc20.red   = current_par.palette[ i       & 31].vidc20.red;
-				p.vidc20.green = current_par.palette[(i >> 1) & 31].vidc20.green;
-				p.vidc20.blue  = current_par.palette[(i >> 2) & 31].vidc20.blue;
-			}
-			acornfb_palette_write(i, current_par.palette[i]);
-		}
-	} else
-#endif
-	{
-		for (i = 0; i < current_par.palette_size; i++) {
-			if (blank)
-				p = acornfb_palette_encode(i, 0, 0, 0, 0);
-			else
-				p = current_par.palette[i];
-
-			acornfb_palette_write(i, p);
-		}
-	}
-	return 0;
-}
-
 /*
  * Everything after here is initialisation!!!
  */
@@ -1757,4 +1758,3 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("VIDC 1/1a/20 framebuffer driver");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/drivers/video/aty/Makefile b/drivers/video/aty/Makefile
--- a/drivers/video/aty/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/video/aty/Makefile	Fri May 24 18:55:34 2002
@@ -1,12 +1,12 @@
 
-O_TARGET := atyfb.o
-
 export-objs    :=  atyfb_base.o mach64_accel.o
 
-obj-y				:= atyfb_base.o mach64_accel.o
-obj-$(CONFIG_FB_ATY_GX)		+= mach64_gx.o
-obj-$(CONFIG_FB_ATY_CT)		+= mach64_ct.o mach64_cursor.o
-obj-m				:= $(O_TARGET)
+obj-$(CONFIG_FB_ATY) += atyfb.o
+
+atyfb-y				:= atyfb_base.o mach64_accel.o
+atyfb-$(CONFIG_FB_ATY_GX)	+= mach64_gx.o
+atyfb-$(CONFIG_FB_ATY_CT)	+= mach64_ct.o mach64_cursor.o
+atyfb-objs			:= $(atyfb-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/drivers/video/clps711xfb.c b/drivers/video/clps711xfb.c
--- a/drivers/video/clps711xfb.c	Fri May 24 18:55:34 2002
+++ b/drivers/video/clps711xfb.c	Fri May 24 18:55:34 2002
@@ -211,6 +211,53 @@
 	return 0;
 }
 
+static int clps7111fb_blank(int blank, struct fb_info *info)
+{
+    	if (blank) {
+		if (machine_is_edb7211()) {
+			int i;
+
+			/* Turn off the LCD backlight. */
+			clps_writeb(clps_readb(PDDR) & ~EDB_PD3_LCDBL, PDDR);
+
+			/* Power off the LCD DC-DC converter. */
+			clps_writeb(clps_readb(PDDR) & ~EDB_PD1_LCD_DC_DC_EN, PDDR);
+
+			/* Delay for a little while (half a second). */
+			for (i=0; i<65536*4; i++);
+
+			/* Power off the LCD panel. */
+			clps_writeb(clps_readb(PDDR) & ~EDB_PD2_LCDEN, PDDR);
+
+			/* Power off the LCD controller. */
+			clps_writel(clps_readl(SYSCON1) & ~SYSCON1_LCDEN, 
+					SYSCON1);
+		}
+	} else {
+		if (machine_is_edb7211()) {
+				int i;
+
+				/* Power up the LCD controller. */
+				clps_writel(clps_readl(SYSCON1) | SYSCON1_LCDEN,
+						SYSCON1);
+
+				/* Power up the LCD panel. */
+				clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
+
+				/* Delay for a little while. */
+				for (i=0; i<65536*4; i++);
+
+				/* Power up the LCD DC-DC converter. */
+				clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN,
+						PDDR);
+
+				/* Turn on the LCD backlight. */
+				clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
+		}
+	}
+	return 0;
+}
+
 static struct fb_ops clps7111fb_ops = {
 	owner:		THIS_MODULE,
 	fb_set_var:	clps7111fb_set_var,
@@ -266,53 +313,6 @@
 	return -EINVAL;
 }
 
-static int clps7111fb_blank(int blank, struct fb_info *info)
-{
-    	if (blank) {
-		if (machine_is_edb7211()) {
-			int i;
-
-			/* Turn off the LCD backlight. */
-			clps_writeb(clps_readb(PDDR) & ~EDB_PD3_LCDBL, PDDR);
-
-			/* Power off the LCD DC-DC converter. */
-			clps_writeb(clps_readb(PDDR) & ~EDB_PD1_LCD_DC_DC_EN, PDDR);
-
-			/* Delay for a little while (half a second). */
-			for (i=0; i<65536*4; i++);
-
-			/* Power off the LCD panel. */
-			clps_writeb(clps_readb(PDDR) & ~EDB_PD2_LCDEN, PDDR);
-
-			/* Power off the LCD controller. */
-			clps_writel(clps_readl(SYSCON1) & ~SYSCON1_LCDEN, 
-					SYSCON1);
-		}
-	} else {
-		if (machine_is_edb7211()) {
-				int i;
-
-				/* Power up the LCD controller. */
-				clps_writel(clps_readl(SYSCON1) | SYSCON1_LCDEN,
-						SYSCON1);
-
-				/* Power up the LCD panel. */
-				clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
-
-				/* Delay for a little while. */
-				for (i=0; i<65536*4; i++);
-
-				/* Power up the LCD DC-DC converter. */
-				clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN,
-						PDDR);
-
-				/* Turn on the LCD backlight. */
-				clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
-		}
-	}
-	return 0;
-}
-
 static int 
 clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
 		int count, int *eof, void *data)
@@ -430,7 +430,7 @@
 		clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
 
 		/* Delay for a little while. */
-		for (i=0; i<65536*4; i++);
+		udelay(100);
 
 		/* Power up the LCD DC-DC converter. */
 		clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN, PDDR);
@@ -463,3 +463,7 @@
 module_init(clps711xfb_init);
 #endif
 module_exit(clps711xfb_exit);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("CLPS711x framebuffer driver");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/matrox/Makefile b/drivers/video/matrox/Makefile
--- a/drivers/video/matrox/Makefile	Fri May 24 18:55:34 2002
+++ b/drivers/video/matrox/Makefile	Fri May 24 18:55:34 2002
@@ -2,8 +2,6 @@
 # 5 Aug 1999, James Simmons, <mailto:jsimmons@edgeglobal.com>
 # Rewritten to use lists instead of if-statements.
 
-O_TARGET := matrox.o
-
 # All of the (potential) objects that export symbols.
 # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
 
diff -Nru a/drivers/video/riva/Makefile b/drivers/video/riva/Makefile
--- a/drivers/video/riva/Makefile	Fri May 24 18:55:33 2002
+++ b/drivers/video/riva/Makefile	Fri May 24 18:55:33 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the Riva framebuffer driver
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := rivafb.o
+obj-$(CONFIG_FB_RIVA) += rivafb.o
 
-obj-y    := fbdev.o riva_hw.o accel.o
-obj-m    := $(O_TARGET)
+rivafb-objs := fbdev.o riva_hw.o accel.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
--- a/drivers/video/sa1100fb.c	Fri May 24 18:55:34 2002
+++ b/drivers/video/sa1100fb.c	Fri May 24 18:55:34 2002
@@ -1258,69 +1258,6 @@
 	return 0;
 }
 
-static struct fb_ops sa1100fb_ops = {
-	owner:		THIS_MODULE,
-	fb_get_fix:	sa1100fb_get_fix,
-	fb_get_var:	sa1100fb_get_var,
-	fb_set_var:	sa1100fb_set_var,
-	fb_get_cmap:	sa1100fb_get_cmap,
-	fb_set_cmap:	sa1100fb_set_cmap,
-	fb_setcolreg:	sa1100fb_setcolreg,
-	fb_blank:	sa1100fb_blank,
-};
-
-/*
- *  sa1100fb_switch():       
- *	Change to the specified console.  Palette and video mode
- *      are changed to the console's stored parameters.
- *
- *	Uh oh, this can be called from a tasklet (IRQ)
- */
-static int sa1100fb_switch(int con, struct fb_info *info)
-{
-	struct sa1100fb_info *fbi = (struct sa1100fb_info *)info;
-	struct display *disp;
-	struct fb_cmap *cmap;
-
-	DPRINTK("con=%d info->modename=%s\n", con, fbi->fb.modename);
-
-	if (con == info->currcon)
-		return 0;
-
-	if (info->currcon >= 0) {
-		disp = fb_display + info->currcon;
-
-		/*
-		 * Save the old colormap and video mode.
-		 */
-		disp->var = fbi->fb.var;
-
-		if (disp->cmap.len)
-			fb_copy_cmap(&fbi->fb.cmap, &disp->cmap, 0);
-	}
-
-	info->currcon = con;
-	disp = fb_display + con;
-
-	/*
-	 * Make sure that our colourmap contains 256 entries.
-	 */
-	fb_alloc_cmap(&fbi->fb.cmap, 256, 0);
-
-	if (disp->cmap.len)
-		cmap = &disp->cmap;
-	else
-		cmap = fb_default_cmap(1 << disp->var.bits_per_pixel);
-
-	fb_copy_cmap(cmap, &fbi->fb.cmap, 0);
-
-	fbi->fb.var = disp->var;
-	fbi->fb.var.activate = FB_ACTIVATE_NOW;
-
-	sa1100fb_set_var(&fbi->fb.var, con, info);
-	return 0;
-}
-
 /*
  * Formal definition of the VESA spec:
  *  On
@@ -1385,6 +1322,69 @@
 			fb_set_cmap(&fbi->fb.cmap, 1, info);
 		sa1100fb_schedule_task(fbi, C_ENABLE);
 	}
+	return 0;
+}
+
+static struct fb_ops sa1100fb_ops = {
+	owner:		THIS_MODULE,
+	fb_get_fix:	sa1100fb_get_fix,
+	fb_get_var:	sa1100fb_get_var,
+	fb_set_var:	sa1100fb_set_var,
+	fb_get_cmap:	sa1100fb_get_cmap,
+	fb_set_cmap:	sa1100fb_set_cmap,
+	fb_setcolreg:	sa1100fb_setcolreg,
+	fb_blank:	sa1100fb_blank,
+};
+
+/*
+ *  sa1100fb_switch():       
+ *	Change to the specified console.  Palette and video mode
+ *      are changed to the console's stored parameters.
+ *
+ *	Uh oh, this can be called from a tasklet (IRQ)
+ */
+static int sa1100fb_switch(int con, struct fb_info *info)
+{
+	struct sa1100fb_info *fbi = (struct sa1100fb_info *)info;
+	struct display *disp;
+	struct fb_cmap *cmap;
+
+	DPRINTK("con=%d info->modename=%s\n", con, fbi->fb.modename);
+
+	if (con == info->currcon)
+		return 0;
+
+	if (info->currcon >= 0) {
+		disp = fb_display + info->currcon;
+
+		/*
+		 * Save the old colormap and video mode.
+		 */
+		disp->var = fbi->fb.var;
+
+		if (disp->cmap.len)
+			fb_copy_cmap(&fbi->fb.cmap, &disp->cmap, 0);
+	}
+
+	info->currcon = con;
+	disp = fb_display + con;
+
+	/*
+	 * Make sure that our colourmap contains 256 entries.
+	 */
+	fb_alloc_cmap(&fbi->fb.cmap, 256, 0);
+
+	if (disp->cmap.len)
+		cmap = &disp->cmap;
+	else
+		cmap = fb_default_cmap(1 << disp->var.bits_per_pixel);
+
+	fb_copy_cmap(cmap, &fbi->fb.cmap, 0);
+
+	fbi->fb.var = disp->var;
+	fbi->fb.var.activate = FB_ACTIVATE_NOW;
+
+	sa1100fb_set_var(&fbi->fb.var, con, info);
 	return 0;
 }
 
diff -Nru a/drivers/video/sis/Makefile b/drivers/video/sis/Makefile
--- a/drivers/video/sis/Makefile	Fri May 24 18:55:35 2002
+++ b/drivers/video/sis/Makefile	Fri May 24 18:55:35 2002
@@ -2,12 +2,11 @@
 # Makefile for the SiS framebuffer device driver
 #
 
-O_TARGET := sisfb.o
-
 export-objs := sis_main.o
 
-obj-y  := sis_main.o init.o init301.o
-obj-m  := $(O_TARGET)
+obj-$(CONFIG_FB_SIS) += sisfb.o
+
+sisfb-objs := sis_main.o init.o init301.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/fs/Makefile b/fs/Makefile
--- a/fs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/Makefile	Fri May 24 18:55:33 2002
@@ -23,55 +23,6 @@
 endif
 endif
 
-subdir-$(CONFIG_PROC_FS)	+= proc
-subdir-y			+= partitions
-subdir-y			+= driverfs
-
-# Do not add any filesystems before this line
-subdir-$(CONFIG_EXT3_FS)	+= ext3    # Before ext2 so root fs can be ext3
-subdir-$(CONFIG_JBD)		+= jbd
-subdir-$(CONFIG_EXT2_FS)	+= ext2
-subdir-$(CONFIG_CRAMFS)		+= cramfs
-subdir-$(CONFIG_RAMFS)		+= ramfs
-subdir-$(CONFIG_CODA_FS)	+= coda
-subdir-$(CONFIG_INTERMEZZO_FS)	+= intermezzo
-subdir-$(CONFIG_MINIX_FS)	+= minix
-subdir-$(CONFIG_FAT_FS)		+= fat
-subdir-$(CONFIG_UMSDOS_FS)	+= umsdos
-subdir-$(CONFIG_MSDOS_FS)	+= msdos
-subdir-$(CONFIG_VFAT_FS)	+= vfat
-subdir-$(CONFIG_BFS_FS)		+= bfs
-subdir-$(CONFIG_ISO9660_FS)	+= isofs
-subdir-$(CONFIG_DEVFS_FS)	+= devfs
-subdir-$(CONFIG_HFS_FS)		+= hfs
-subdir-$(CONFIG_VXFS_FS)	+= freevxfs
-subdir-$(CONFIG_NFS_FS)		+= nfs
-subdir-$(CONFIG_EXPORTFS)	+= exportfs
-subdir-$(CONFIG_NFSD)		+= nfsd
-subdir-$(CONFIG_LOCKD)		+= lockd
-subdir-$(CONFIG_NLS)		+= nls
-subdir-$(CONFIG_SYSV_FS)	+= sysv
-subdir-$(CONFIG_SMB_FS)		+= smbfs
-subdir-$(CONFIG_NCP_FS)		+= ncpfs
-subdir-$(CONFIG_HPFS_FS)	+= hpfs
-subdir-$(CONFIG_NTFS_FS)	+= ntfs
-subdir-$(CONFIG_UFS_FS)		+= ufs
-subdir-$(CONFIG_EFS_FS)		+= efs
-subdir-$(CONFIG_JFFS_FS)	+= jffs
-subdir-$(CONFIG_JFFS2_FS)	+= jffs2
-subdir-$(CONFIG_AFFS_FS)	+= affs
-subdir-$(CONFIG_ROMFS_FS)	+= romfs
-subdir-$(CONFIG_QNX4FS_FS)	+= qnx4
-subdir-$(CONFIG_UDF_FS)		+= udf
-subdir-$(CONFIG_AUTOFS_FS)	+= autofs
-subdir-$(CONFIG_AUTOFS4_FS)	+= autofs4
-subdir-$(CONFIG_ADFS_FS)	+= adfs
-subdir-$(CONFIG_REISERFS_FS)	+= reiserfs
-subdir-$(CONFIG_DEVPTS_FS)	+= devpts
-subdir-$(CONFIG_SUN_OPENPROMFS)	+= openpromfs
-subdir-$(CONFIG_JFS_FS)		+= jfs
-
-
 obj-$(CONFIG_BINFMT_AOUT)	+= binfmt_aout.o
 obj-$(CONFIG_BINFMT_EM86)	+= binfmt_em86.o
 obj-$(CONFIG_BINFMT_MISC)	+= binfmt_misc.o
@@ -81,12 +32,56 @@
 
 obj-$(CONFIG_BINFMT_ELF)	+= binfmt_elf.o
 
-obj-$(CONFIG_QUOTA) += dquot.o
-obj-$(CONFIG_QFMT_V1) += quota_v1.o
-obj-$(CONFIG_QFMT_V2) += quota_v2.o
-
-# persistent filesystems
-obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
+obj-$(CONFIG_QUOTA)		+= dquot.o
+obj-$(CONFIG_QFMT_V1)		+= quota_v1.o
+obj-$(CONFIG_QFMT_V2)		+= quota_v2.o
+
+obj-$(CONFIG_PROC_FS)		+= proc/
+obj-y				+= partitions/
+obj-y				+= driverfs/
 
+# Do not add any filesystems before this line
+obj-$(CONFIG_EXT3_FS)		+= ext3/ # Before ext2 so root fs can be ext3
+obj-$(CONFIG_JBD)		+= jbd/
+obj-$(CONFIG_EXT2_FS)		+= ext2/
+obj-$(CONFIG_CRAMFS)		+= cramfs/
+obj-$(CONFIG_RAMFS)		+= ramfs/
+obj-$(CONFIG_CODA_FS)		+= coda/
+obj-$(CONFIG_INTERMEZZO_FS)	+= intermezzo/
+obj-$(CONFIG_MINIX_FS)		+= minix/
+obj-$(CONFIG_FAT_FS)		+= fat/
+obj-$(CONFIG_UMSDOS_FS)		+= umsdos/
+obj-$(CONFIG_MSDOS_FS)		+= msdos/
+obj-$(CONFIG_VFAT_FS)		+= vfat/
+obj-$(CONFIG_BFS_FS)		+= bfs/
+obj-$(CONFIG_ISO9660_FS)	+= isofs/
+obj-$(CONFIG_DEVFS_FS)		+= devfs/
+obj-$(CONFIG_HFS_FS)		+= hfs/
+obj-$(CONFIG_VXFS_FS)		+= freevxfs/
+obj-$(CONFIG_NFS_FS)		+= nfs/
+obj-$(CONFIG_EXPORTFS)		+= exportfs/
+obj-$(CONFIG_NFSD)		+= nfsd/
+obj-$(CONFIG_LOCKD)		+= lockd/
+obj-$(CONFIG_NLS)		+= nls/
+obj-$(CONFIG_SYSV_FS)		+= sysv/
+obj-$(CONFIG_SMB_FS)		+= smbfs/
+obj-$(CONFIG_NCP_FS)		+= ncpfs/
+obj-$(CONFIG_HPFS_FS)		+= hpfs/
+obj-$(CONFIG_NTFS_FS)		+= ntfs/
+obj-$(CONFIG_UFS_FS)		+= ufs/
+obj-$(CONFIG_EFS_FS)		+= efs/
+obj-$(CONFIG_JFFS_FS)		+= jffs/
+obj-$(CONFIG_JFFS2_FS)		+= jffs2/
+obj-$(CONFIG_AFFS_FS)		+= affs/
+obj-$(CONFIG_ROMFS_FS)		+= romfs/
+obj-$(CONFIG_QNX4FS_FS)		+= qnx4/
+obj-$(CONFIG_UDF_FS)		+= udf/
+obj-$(CONFIG_AUTOFS_FS)		+= autofs/
+obj-$(CONFIG_AUTOFS4_FS)	+= autofs4/
+obj-$(CONFIG_ADFS_FS)		+= adfs/
+obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
+obj-$(CONFIG_DEVPTS_FS)		+= devpts/
+obj-$(CONFIG_SUN_OPENPROMFS)	+= openpromfs/
+obj-$(CONFIG_JFS_FS)		+= jfs/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/adfs/Makefile b/fs/adfs/Makefile
--- a/fs/adfs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/adfs/Makefile	Fri May 24 18:55:33 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the linux adfs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := adfs.o
+obj-$(CONFIG_ADFS_FS) += adfs.o
 
-obj-y    := dir.o dir_f.o dir_fplus.o file.o inode.o map.o super.o
-obj-m    := $(O_TARGET)
+adfs-objs := dir.o dir_f.o dir_fplus.o file.o inode.o map.o super.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/adfs/adfs.h b/fs/adfs/adfs.h
--- a/fs/adfs/adfs.h	Fri May 24 18:55:36 2002
+++ b/fs/adfs/adfs.h	Fri May 24 18:55:36 2002
@@ -14,6 +14,8 @@
 
 #include "dir_f.h"
 
+struct buffer_head;
+
 /*
  * Directory handling
  */
diff -Nru a/fs/adfs/dir.c b/fs/adfs/dir.c
--- a/fs/adfs/dir.c	Fri May 24 18:55:33 2002
+++ b/fs/adfs/dir.c	Fri May 24 18:55:33 2002
@@ -18,6 +18,7 @@
 #include <linux/stat.h>
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>		/* for file_fsync() */
 
 #include "adfs.h"
 
diff -Nru a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
--- a/fs/adfs/dir_f.c	Fri May 24 18:55:36 2002
+++ b/fs/adfs/dir_f.c	Fri May 24 18:55:36 2002
@@ -16,6 +16,7 @@
 #include <linux/time.h>
 #include <linux/stat.h>
 #include <linux/spinlock.h>
+#include <linux/buffer_head.h>
 
 #include "adfs.h"
 #include "dir_f.h"
diff -Nru a/fs/adfs/dir_fplus.c b/fs/adfs/dir_fplus.c
--- a/fs/adfs/dir_fplus.c	Fri May 24 18:55:33 2002
+++ b/fs/adfs/dir_fplus.c	Fri May 24 18:55:33 2002
@@ -14,6 +14,7 @@
 #include <linux/time.h>
 #include <linux/stat.h>
 #include <linux/spinlock.h>
+#include <linux/buffer_head.h>
 
 #include "adfs.h"
 #include "dir_fplus.h"
diff -Nru a/fs/adfs/file.c b/fs/adfs/file.c
--- a/fs/adfs/file.c	Fri May 24 18:55:34 2002
+++ b/fs/adfs/file.c	Fri May 24 18:55:34 2002
@@ -25,6 +25,7 @@
 #include <linux/fcntl.h>
 #include <linux/time.h>
 #include <linux/stat.h>
+#include <linux/buffer_head.h>		/* for file_fsync() */
 
 #include "adfs.h"
 
diff -Nru a/fs/adfs/inode.c b/fs/adfs/inode.c
--- a/fs/adfs/inode.c	Fri May 24 18:55:34 2002
+++ b/fs/adfs/inode.c	Fri May 24 18:55:34 2002
@@ -17,7 +17,7 @@
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/module.h>
-
+#include <linux/buffer_head.h>
 
 #include "adfs.h"
 
diff -Nru a/fs/adfs/map.c b/fs/adfs/map.c
--- a/fs/adfs/map.c	Fri May 24 18:55:35 2002
+++ b/fs/adfs/map.c	Fri May 24 18:55:35 2002
@@ -12,6 +12,7 @@
 #include <linux/fs.h>
 #include <linux/adfs_fs.h>
 #include <linux/spinlock.h>
+#include <linux/buffer_head.h>
 
 #include <asm/unaligned.h>
 
diff -Nru a/fs/adfs/super.c b/fs/adfs/super.c
--- a/fs/adfs/super.c	Fri May 24 18:55:33 2002
+++ b/fs/adfs/super.c	Fri May 24 18:55:33 2002
@@ -17,6 +17,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/buffer_head.h>
 
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
@@ -476,8 +477,6 @@
 	unregister_filesystem(&adfs_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_adfs_fs)
 module_exit(exit_adfs_fs)
diff -Nru a/fs/affs/Makefile b/fs/affs/Makefile
--- a/fs/affs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/affs/Makefile	Fri May 24 18:55:36 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the Linux affs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
 #EXTRA_CFLAGS=-DDEBUG=1
 
-O_TARGET := affs.o
+obj-$(CONFIG_AFFS_FS) += affs.o
 
-obj-y   := super.o namei.o inode.o file.o dir.o amigaffs.o bitmap.o symlink.o
-obj-m   := $(O_TARGET)
+affs-objs := super.o namei.o inode.o file.o dir.o amigaffs.o bitmap.o symlink.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
--- a/fs/affs/amigaffs.c	Fri May 24 18:55:34 2002
+++ b/fs/affs/amigaffs.c	Fri May 24 18:55:34 2002
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/amigaffs.h>
+#include <linux/buffer_head.h>
 
 extern struct timezone sys_tz;
 
diff -Nru a/fs/affs/bitmap.c b/fs/affs/bitmap.c
--- a/fs/affs/bitmap.c	Fri May 24 18:55:36 2002
+++ b/fs/affs/bitmap.c	Fri May 24 18:55:36 2002
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/bitops.h>
 #include <linux/amigaffs.h>
+#include <linux/buffer_head.h>
 
 /* This is, of course, shamelessly stolen from fs/minix */
 
diff -Nru a/fs/affs/dir.c b/fs/affs/dir.c
--- a/fs/affs/dir.c	Fri May 24 18:55:34 2002
+++ b/fs/affs/dir.c	Fri May 24 18:55:34 2002
@@ -23,6 +23,7 @@
 #include <linux/mm.h>
 #include <linux/amigaffs.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 static int affs_readdir(struct file *, void *, filldir_t);
 
diff -Nru a/fs/affs/file.c b/fs/affs/file.c
--- a/fs/affs/file.c	Fri May 24 18:55:35 2002
+++ b/fs/affs/file.c	Fri May 24 18:55:35 2002
@@ -28,6 +28,7 @@
 #include <linux/amigaffs.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 #if PAGE_SIZE < 4096
 #error PAGE_SIZE must be at least 4096
diff -Nru a/fs/affs/inode.c b/fs/affs/inode.c
--- a/fs/affs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/affs/inode.c	Fri May 24 18:55:35 2002
@@ -26,6 +26,7 @@
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <linux/module.h>
diff -Nru a/fs/affs/namei.c b/fs/affs/namei.c
--- a/fs/affs/namei.c	Fri May 24 18:55:34 2002
+++ b/fs/affs/namei.c	Fri May 24 18:55:34 2002
@@ -16,6 +16,7 @@
 #include <linux/fcntl.h>
 #include <linux/amigaffs.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/uaccess.h>
 
 #include <linux/errno.h>
diff -Nru a/fs/affs/super.c b/fs/affs/super.c
--- a/fs/affs/super.c	Fri May 24 18:55:36 2002
+++ b/fs/affs/super.c	Fri May 24 18:55:36 2002
@@ -26,6 +26,7 @@
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
@@ -576,8 +577,6 @@
 	unregister_filesystem(&affs_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 MODULE_DESCRIPTION("Amiga filesystem support for Linux");
 MODULE_LICENSE("GPL");
diff -Nru a/fs/affs/symlink.c b/fs/affs/symlink.c
--- a/fs/affs/symlink.c	Fri May 24 18:55:34 2002
+++ b/fs/affs/symlink.c	Fri May 24 18:55:34 2002
@@ -15,6 +15,7 @@
 #include <linux/amigaffs.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 static int affs_symlink_readpage(struct file *file, struct page *page)
 {
diff -Nru a/fs/autofs/Makefile b/fs/autofs/Makefile
--- a/fs/autofs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/autofs/Makefile	Fri May 24 18:55:36 2002
@@ -1,12 +1,9 @@
 #
 # Makefile for the linux autofs-filesystem routines.
 #
-# We can build this either out of the kernel tree or the autofs tools tree.
-#
 
-O_TARGET := autofs.o
+obj-$(CONFIG_AUTOFS_FS) += autofs.o
 
-obj-y   := dirhash.o init.o inode.o root.o symlink.o waitq.o
-obj-m   := $(O_TARGET)
+autofs-objs := dirhash.o init.o inode.o root.o symlink.o waitq.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
--- a/fs/autofs/autofs_i.h	Fri May 24 18:55:36 2002
+++ b/fs/autofs/autofs_i.h	Fri May 24 18:55:36 2002
@@ -23,6 +23,8 @@
 #include <linux/time.h>
 #include <linux/string.h>
 #include <linux/wait.h>
+#include <linux/dcache.h>
+#include <linux/namei.h>
 #include <asm/uaccess.h>
 
 #ifdef DEBUG
diff -Nru a/fs/autofs4/Makefile b/fs/autofs4/Makefile
--- a/fs/autofs4/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/autofs4/Makefile	Fri May 24 18:55:33 2002
@@ -1,13 +1,9 @@
 #
 # Makefile for the linux autofs-filesystem routines.
 #
-# We can build this either out of the kernel tree or the autofs tools tree.
-#
 
-O_TARGET := autofs4.o
+obj-$(CONFIG_AUTOFS4_FS) += autofs4.o
 
-obj-y   := init.o inode.o root.o symlink.o waitq.o expire.o
-
-obj-m   := $(O_TARGET)
+autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/autofs4/root.c b/fs/autofs4/root.c
--- a/fs/autofs4/root.c	Fri May 24 18:55:33 2002
+++ b/fs/autofs4/root.c	Fri May 24 18:55:33 2002
@@ -27,6 +27,9 @@
 static struct dentry *autofs4_root_lookup(struct inode *,struct dentry *);
 
 struct file_operations autofs4_root_operations = {
+	open:		dcache_dir_open,
+	release:	dcache_dir_close,
+	llseek:		dcache_dir_lseek,
 	read:		generic_read_dir,
 	readdir:	dcache_readdir,
 	ioctl:		autofs4_root_ioctl,
diff -Nru a/fs/bad_inode.c b/fs/bad_inode.c
--- a/fs/bad_inode.c	Fri May 24 18:55:34 2002
+++ b/fs/bad_inode.c	Fri May 24 18:55:34 2002
@@ -60,7 +60,7 @@
 	follow_link:	bad_follow_link,
 	truncate:	EIO_ERROR,
 	permission:	EIO_ERROR,
-	revalidate:	EIO_ERROR,
+	getattr:	EIO_ERROR,
 };
 
 
diff -Nru a/fs/bfs/Makefile b/fs/bfs/Makefile
--- a/fs/bfs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/bfs/Makefile	Fri May 24 18:55:36 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for BFS filesystem.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main Makefile...
 
-O_TARGET := bfs.o
+obj-$(CONFIG_BFS_FS) += bfs.o
 
-obj-y   := inode.o file.o dir.o
-obj-m   := $(O_TARGET)
+bfs-objs := inode.o file.o dir.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/bfs/bfs.h b/fs/bfs/bfs.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/fs/bfs/bfs.h	Fri May 24 18:55:33 2002
@@ -0,0 +1,60 @@
+/*
+ *	fs/bfs/bfs.h
+ *	Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
+ */
+#ifndef _FS_BFS_BFS_H
+#define _FS_BFS_BFS_H
+
+#include <linux/bfs_fs.h>
+
+/*
+ * BFS file system in-core superblock info
+ */
+struct bfs_sb_info {
+	unsigned long si_blocks;
+	unsigned long si_freeb;
+	unsigned long si_freei;
+	unsigned long si_lf_ioff;
+	unsigned long si_lf_sblk;
+	unsigned long si_lf_eblk;
+	unsigned long si_lasti;
+	unsigned long * si_imap;
+	struct buffer_head * si_sbh;		/* buffer header w/superblock */
+	struct bfs_super_block * si_bfs_sb;	/* superblock in si_sbh->b_data */
+};
+
+/*
+ * BFS file system in-core inode info
+ */
+struct bfs_inode_info {
+	unsigned long i_dsk_ino; /* inode number from the disk, can be 0 */
+	unsigned long i_sblock;
+	unsigned long i_eblock;
+	struct inode vfs_inode;
+};
+
+static inline struct bfs_sb_info *BFS_SB(struct super_block *sb)
+{
+	return sb->u.generic_sbp;
+}
+
+static inline struct bfs_inode_info *BFS_I(struct inode *inode)
+{
+	return list_entry(inode, struct bfs_inode_info, vfs_inode);
+}
+
+
+#define printf(format, args...) \
+	printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args)
+
+
+/* file.c */
+extern struct inode_operations bfs_file_inops;
+extern struct file_operations bfs_file_operations;
+extern struct address_space_operations bfs_aops;
+
+/* dir.c */
+extern struct inode_operations bfs_dir_inops;
+extern struct file_operations bfs_dir_operations;
+
+#endif /* _FS_BFS_BFS_H */
diff -Nru a/fs/bfs/bfs_defs.h b/fs/bfs/bfs_defs.h
--- a/fs/bfs/bfs_defs.h	Fri May 24 18:55:33 2002
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,3 +0,0 @@
-#define printf(format, args...) \
-	printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args)
-
diff -Nru a/fs/bfs/dir.c b/fs/bfs/dir.c
--- a/fs/bfs/dir.c	Fri May 24 18:55:36 2002
+++ b/fs/bfs/dir.c	Fri May 24 18:55:36 2002
@@ -6,10 +6,11 @@
 
 #include <linux/time.h>
 #include <linux/string.h>
-#include <linux/bfs_fs.h>
+#include <linux/fs.h>
 #include <linux/smp_lock.h>
-
-#include "bfs_defs.h"
+#include <linux/buffer_head.h>
+#include <linux/sched.h>
+#include "bfs.h"
 
 #undef DEBUG
 
diff -Nru a/fs/bfs/file.c b/fs/bfs/file.c
--- a/fs/bfs/file.c	Fri May 24 18:55:34 2002
+++ b/fs/bfs/file.c	Fri May 24 18:55:34 2002
@@ -5,9 +5,9 @@
  */
 
 #include <linux/fs.h>
-#include <linux/bfs_fs.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
-#include "bfs_defs.h"
+#include "bfs.h"
 
 #undef DEBUG
 
diff -Nru a/fs/bfs/inode.c b/fs/bfs/inode.c
--- a/fs/bfs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/bfs/inode.c	Fri May 24 18:55:35 2002
@@ -9,17 +9,15 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/bfs_fs.h>
+#include <linux/fs.h>
 #include <linux/smp_lock.h>
-
+#include <linux/buffer_head.h>
 #include <asm/uaccess.h>
-
-#include "bfs_defs.h"
+#include "bfs.h"
 
 MODULE_AUTHOR("Tigran A. Aivazian <tigran@veritas.com>");
 MODULE_DESCRIPTION("SCO UnixWare BFS filesystem for Linux");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 #undef DEBUG
 
diff -Nru a/fs/binfmt_aout.c b/fs/binfmt_aout.c
--- a/fs/binfmt_aout.c	Fri May 24 18:55:34 2002
+++ b/fs/binfmt_aout.c	Fri May 24 18:55:34 2002
@@ -516,8 +516,6 @@
 	unregister_binfmt(&aout_format);
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_aout_binfmt);
 module_exit(exit_aout_binfmt);
 MODULE_LICENSE("GPL");
diff -Nru a/fs/binfmt_misc.c b/fs/binfmt_misc.c
--- a/fs/binfmt_misc.c	Fri May 24 18:55:35 2002
+++ b/fs/binfmt_misc.c	Fri May 24 18:55:35 2002
@@ -24,6 +24,7 @@
 #include <linux/ctype.h>
 #include <linux/file.h>
 #include <linux/pagemap.h>
+#include <linux/namei.h>
 
 #include <asm/uaccess.h>
 
@@ -714,8 +715,6 @@
 	unregister_binfmt(&misc_format);
 	unregister_filesystem(&bm_fs_type);
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_misc_binfmt);
 module_exit(exit_misc_binfmt);
diff -Nru a/fs/block_dev.c b/fs/block_dev.c
--- a/fs/block_dev.c	Fri May 24 18:55:35 2002
+++ b/fs/block_dev.c	Fri May 24 18:55:35 2002
@@ -19,6 +19,7 @@
 #include <linux/blkdev.h>
 #include <linux/module.h>
 #include <linux/blkpg.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
@@ -55,14 +56,13 @@
 int set_blocksize(struct block_device *bdev, int size)
 {
 	int oldsize;
-	kdev_t dev = to_kdev_t(bdev->bd_dev);
 
 	/* Size must be a power of two, and between 512 and PAGE_SIZE */
 	if (size > PAGE_SIZE || size < 512 || (size & (size-1)))
 		return -EINVAL;
 
 	/* Size cannot be smaller than the size supported by the device */
-	if (size < get_hardsect_size(dev))
+	if (size < bdev_hardsect_size(bdev))
 		return -EINVAL;
 
 	oldsize = bdev->bd_block_size;
@@ -322,6 +322,7 @@
 			atomic_set(&new_bdev->bd_count,1);
 			new_bdev->bd_dev = dev;
 			new_bdev->bd_op = NULL;
+			new_bdev->bd_queue = NULL;
 			new_bdev->bd_contains = NULL;
 			new_bdev->bd_inode = inode;
 			inode->i_mode = S_IFBLK;
@@ -607,6 +608,7 @@
 	}
 	bdev->bd_inode->i_size = blkdev_size(dev);
 	if (!bdev->bd_openers) {
+		struct blk_dev_struct *p = blk_dev + major(dev);
 		unsigned bsize = bdev_hardsect_size(bdev);
 		while (bsize < PAGE_CACHE_SIZE) {
 			if (bdev->bd_inode->i_size & bsize)
@@ -615,6 +617,10 @@
 		}
 		bdev->bd_block_size = bsize;
 		bdev->bd_inode->i_blkbits = blksize_bits(bsize);
+		if (p->queue)
+			bdev->bd_queue =  p->queue(dev);
+		else
+			bdev->bd_queue = &p->request_queue;
 	}
 	bdev->bd_openers++;
 	unlock_kernel();
@@ -624,6 +630,7 @@
 out2:
 	if (!bdev->bd_openers) {
 		bdev->bd_op = NULL;
+		bdev->bd_queue = NULL;
 		bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
 		if (bdev != bdev->bd_contains) {
 			blkdev_put(bdev->bd_contains, BDEV_RAW);
@@ -698,6 +705,7 @@
 		__MOD_DEC_USE_COUNT(bdev->bd_op->owner);
 	if (!bdev->bd_openers) {
 		bdev->bd_op = NULL;
+		bdev->bd_queue = NULL;
 		bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
 		if (bdev != bdev->bd_contains) {
 			blkdev_put(bdev->bd_contains, BDEV_RAW);
diff -Nru a/fs/buffer.c b/fs/buffer.c
--- a/fs/buffer.c	Fri May 24 18:55:33 2002
+++ b/fs/buffer.c	Fri May 24 18:55:33 2002
@@ -32,13 +32,12 @@
 #include <linux/writeback.h>
 #include <linux/mempool.h>
 #include <linux/hash.h>
+#include <linux/suspend.h>
+#include <linux/buffer_head.h>
 #include <asm/bitops.h>
 
 #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers)
 
-/* This is used by some architectures to estimate available memory. */
-atomic_t buffermem_pages = ATOMIC_INIT(0);
-
 /*
  * Hashed waitqueue_head's for wait_on_buffer()
  */
@@ -123,6 +122,8 @@
 	wake_up_buffer(bh);
 }
 
+DECLARE_TASK_QUEUE(tq_bdflush);
+
 /*
  * Block until a buffer comes unlocked.  This doesn't stop it
  * from becoming locked again - you have to lock it yourself
@@ -151,10 +152,6 @@
 static inline void
 __set_page_buffers(struct page *page, struct buffer_head *head)
 {
-	struct inode *inode = page->mapping->host;
-
-	if (inode && S_ISBLK(inode->i_mode))
-		atomic_inc(&buffermem_pages);
 	if (page_has_buffers(page))
 		buffer_error();
 	set_page_buffers(page, head);
@@ -164,14 +161,6 @@
 static inline void
 __clear_page_buffers(struct page *page)
 {
-	struct address_space *mapping = page->mapping;
-
-	if (mapping) {
-		struct inode *inode = mapping->host;
-
-		if (S_ISBLK(inode->i_mode))
-			atomic_dec(&buffermem_pages);
-	}
 	clear_page_buffers(page);
 	page_cache_release(page);
 }
diff -Nru a/fs/coda/Makefile b/fs/coda/Makefile
--- a/fs/coda/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/coda/Makefile	Fri May 24 18:55:34 2002
@@ -2,11 +2,10 @@
 # Makefile for the Linux Coda filesystem routines.
 #
 
-O_TARGET := coda.o
+obj-$(CONFIG_CODA_FS) += coda.o
 
-obj-y   := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o coda_linux.o\
-           symlink.o pioctl.o sysctl.o 
-obj-m   := $(O_TARGET)
+coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \
+	     coda_linux.o symlink.o pioctl.o sysctl.o 
 
 # If you want debugging output, please uncomment the following line.
 
diff -Nru a/fs/coda/cnode.c b/fs/coda/cnode.c
--- a/fs/coda/cnode.c	Fri May 24 18:55:34 2002
+++ b/fs/coda/cnode.c	Fri May 24 18:55:34 2002
@@ -28,7 +28,7 @@
 static struct inode_operations coda_symlink_inode_operations = {
 	readlink:	page_readlink,
 	follow_link:	page_follow_link,
-	setattr:	coda_notify_change,
+	setattr:	coda_setattr,
 };
 
 /* cnode.c */
diff -Nru a/fs/coda/dir.c b/fs/coda/dir.c
--- a/fs/coda/dir.c	Fri May 24 18:55:33 2002
+++ b/fs/coda/dir.c	Fri May 24 18:55:33 2002
@@ -72,8 +72,8 @@
 	mknod:		coda_mknod,
 	rename:		coda_rename,
 	permission:	coda_permission,
-        revalidate:	coda_revalidate_inode,
-	setattr:	coda_notify_change,
+        getattr:	coda_getattr,
+	setattr:	coda_setattr,
 };
 
 struct file_operations coda_dir_operations = {
@@ -147,7 +147,6 @@
 
 int coda_permission(struct inode *inode, int mask)
 {
-	umode_t mode = inode->i_mode;
         int error;
  
 	if (!mask)
diff -Nru a/fs/coda/inode.c b/fs/coda/inode.c
--- a/fs/coda/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/coda/inode.c	Fri May 24 18:55:35 2002
@@ -237,7 +237,15 @@
 	coda_cache_clear_inode(inode);
 }
 
-int coda_notify_change(struct dentry *de, struct iattr *iattr)
+int coda_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+	int err = coda_revalidate_inode(dentry);
+	if (!err)
+		generic_fillattr(dentry->d_inode, stat);
+	return err;
+}
+
+int coda_setattr(struct dentry *de, struct iattr *iattr)
 {
 	struct inode *inode = de->d_inode;
         struct coda_vattr vattr;
@@ -266,8 +274,8 @@
 
 struct inode_operations coda_file_inode_operations = {
 	permission:	coda_permission,
-	revalidate:	coda_revalidate_inode,
-	setattr:	coda_notify_change,
+	getattr:	coda_getattr,
+	setattr:	coda_setattr,
 };
 
 static int coda_statfs(struct super_block *sb, struct statfs *buf)
diff -Nru a/fs/coda/pioctl.c b/fs/coda/pioctl.c
--- a/fs/coda/pioctl.c	Fri May 24 18:55:36 2002
+++ b/fs/coda/pioctl.c	Fri May 24 18:55:36 2002
@@ -15,6 +15,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #define __NO_VERSION__
+#include <linux/namei.h>
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
@@ -32,7 +33,7 @@
 struct inode_operations coda_ioctl_inode_operations =
 {
 	permission:	coda_ioctl_permission,
-	setattr:	coda_notify_change,
+	setattr:	coda_setattr,
 };
 
 struct file_operations coda_ioctl_operations = {
diff -Nru a/fs/cramfs/Makefile b/fs/cramfs/Makefile
--- a/fs/cramfs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/cramfs/Makefile	Fri May 24 18:55:35 2002
@@ -2,10 +2,8 @@
 # Makefile for the linux cramfs routines.
 #
 
-O_TARGET := cramfs.o
+obj-$(CONFIG_CRAMFS) += cramfs.o
 
-obj-y  := inode.o uncompress.o
-
-obj-m := $(O_TARGET)
+cramfs-objs := inode.o uncompress.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/cramfs/inode.c b/fs/cramfs/inode.c
--- a/fs/cramfs/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/cramfs/inode.c	Fri May 24 18:55:33 2002
@@ -21,6 +21,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/cramfs_fs_sb.h>
+#include <linux/buffer_head.h>
 #include <asm/semaphore.h>
 
 #include <asm/uaccess.h>
diff -Nru a/fs/dcache.c b/fs/dcache.c
--- a/fs/dcache.c	Fri May 24 18:55:33 2002
+++ b/fs/dcache.c	Fri May 24 18:55:33 2002
@@ -32,9 +32,6 @@
 spinlock_t dcache_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
 rwlock_t dparent_lock __cacheline_aligned_in_smp = RW_LOCK_UNLOCKED;
 
-/* Right now the dcache depends on the kernel lock */
-#define check_lock()	if (!kernel_locked()) BUG()
-
 static kmem_cache_t *dentry_cache; 
 
 /*
@@ -812,7 +809,6 @@
 	struct dentry *new = NULL;
 
 	if (inode && S_ISDIR(inode->i_mode)) {
-		lock_kernel(); /* for d_move */
 		spin_lock(&dcache_lock);
 		if (!list_empty(&inode->i_dentry)) {
 			new = list_entry(inode->i_dentry.next, struct dentry, d_alias);
@@ -828,7 +824,6 @@
 			spin_unlock(&dcache_lock);
 			d_rehash(dentry);
 		}
-		unlock_kernel();
 	} else
 		d_add(dentry, inode);
 	return new;
@@ -1012,7 +1007,6 @@
 {
 	const unsigned char *old_name, *new_name;
 
-	check_lock();
 	memcpy(dentry->d_iname, target->d_iname, DNAME_INLINE_LEN); 
 	old_name = target->d_name.name;
 	new_name = dentry->d_name.name;
@@ -1051,8 +1045,6 @@
   
 void d_move(struct dentry * dentry, struct dentry * target)
 {
-	check_lock();
-
 	if (!dentry->d_inode)
 		printk(KERN_WARNING "VFS: moving negative dcache entry\n");
 
diff -Nru a/fs/devfs/Makefile b/fs/devfs/Makefile
--- a/fs/devfs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/devfs/Makefile	Fri May 24 18:55:33 2002
@@ -1,17 +1,12 @@
 #
 # Makefile for the linux devfs-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-O_TARGET := devfs.o
 
 export-objs := base.o util.o
 
-obj-y   := base.o util.o
+obj-$(CONFIG_DEVFS_FS) += devfs.o
+
+devfs-objs := base.o util.o
 
 # Special case to support building documentation
 ifndef TOPDIR
diff -Nru a/fs/devpts/Makefile b/fs/devpts/Makefile
--- a/fs/devpts/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/devpts/Makefile	Fri May 24 18:55:36 2002
@@ -2,10 +2,8 @@
 # Makefile for the Linux /dev/pts virtual filesystem.
 #
 
-O_TARGET := devpts.o
+obj-$(CONFIG_DEVPTS_FS) += devpts.o
 
-obj-y    := root.o inode.o
-
-obj-m    := $(O_TARGET)
+devpts-objs := root.o inode.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/dquot.c b/fs/dquot.c
--- a/fs/dquot.c	Fri May 24 18:55:33 2002
+++ b/fs/dquot.c	Fri May 24 18:55:33 2002
@@ -118,11 +118,11 @@
  * list is used for the sync and invalidate operations, which must look
  * at every dquot.
  *
- * Unused dquots (dq_count == 0) are added to the free_dquots list when
- * freed, and this list is searched whenever we need an available dquot.
- * Dquots are removed from the list as soon as they are used again, and
- * nr_free_dquots gives the number of dquots on the list. When dquot is
- * invalidated it's completely released from memory.
+ * Unused dquots (dq_count == 0) are added to the free_dquots list when freed,
+ * and this list is searched whenever we need an available dquot.  Dquots are
+ * removed from the list as soon as they are used again, and
+ * dqstats_array[DQSTATS_FREE] gives the number of dquots on the list. When
+ * dquot is invalidated it's completely released from memory.
  *
  * Dquots with a specific identity (device, type and id) are placed on
  * one of the dquot_hash[] hash chains. The provides an efficient search
@@ -148,7 +148,7 @@
 static LIST_HEAD(free_dquots);
 static struct list_head dquot_hash[NR_DQHASH];
 
-struct dqstats dqstats;
+__u32 dqstats_array[DQSTATS_SIZE];
 
 static void dqput(struct dquot *);
 static struct dquot *dqduplicate(struct dquot *);
@@ -207,14 +207,14 @@
 static inline void put_dquot_head(struct dquot *dquot)
 {
 	list_add(&dquot->dq_free, &free_dquots);
-	nr_free_dquots++;
+	++dqstats_array[DQSTATS_FREE];
 }
 
 /* Add a dquot to the tail of the free list */
 static inline void put_dquot_last(struct dquot *dquot)
 {
 	list_add(&dquot->dq_free, free_dquots.prev);
-	nr_free_dquots++;
+	++dqstats_array[DQSTATS_FREE];
 }
 
 /* Move dquot to the head of free list (it must be already on it) */
@@ -230,7 +230,7 @@
 		return;
 	list_del(&dquot->dq_free);
 	INIT_LIST_HEAD(&dquot->dq_free);
-	nr_free_dquots--;
+	--dqstats_array[DQSTATS_FREE];
 }
 
 static inline void put_inuse(struct dquot *dquot)
@@ -238,12 +238,12 @@
 	/* We add to the back of inuse list so we don't have to restart
 	 * when traversing this list and we block */
 	list_add(&dquot->dq_inuse, inuse_list.prev);
-	nr_dquots++;
+	++dqstats_array[DQSTATS_ALLOCATED];
 }
 
 static inline void remove_inuse(struct dquot *dquot)
 {
-	nr_dquots--;
+	--dqstats_array[DQSTATS_ALLOCATED];
 	list_del(&dquot->dq_inuse);
 }
 
@@ -403,7 +403,8 @@
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
 		if ((cnt == type || type == -1) && sb_has_quota_enabled(sb, cnt) && info_dirty(&dqopt->info[cnt]))
 			dqopt->ops[cnt]->write_file_info(sb, cnt);
-	dqstats.syncs++;
+	++dqstats_array[DQSTATS_SYNCS];
+
 	return 0;
 }
 
@@ -490,7 +491,7 @@
 	int count = 0;
 
 	lock_kernel();
-	count = nr_free_dquots / priority;
+	count = dqstats_array[DQSTATS_FREE] / priority;
 	prune_dqcache(count);
 	unlock_kernel();
 	kmem_cache_shrink(dquot_cachep);
@@ -516,7 +517,7 @@
 	}
 #endif
 
-	dqstats.drops++;
+	++dqstats_array[DQSTATS_DROPS];
 we_slept:
 	if (dquot->dq_dup_ref && dquot->dq_count - dquot->dq_dup_ref <= 1) {	/* Last unduplicated reference? */
 		__wait_dup_drop(dquot);
@@ -588,15 +589,15 @@
 			goto we_slept;
 		}
 		dquot = empty;
-        	dquot->dq_id = id;
+		dquot->dq_id = id;
 		/* hash it first so it can be found */
 		insert_dquot_hash(dquot);
-        	read_dqblk(dquot);
+		read_dqblk(dquot);
 	} else {
 		if (!dquot->dq_count)
 			remove_free_dquot(dquot);
 		get_dquot_ref(dquot);
-		dqstats.cache_hits++;
+		++dqstats_array[DQSTATS_CACHE_HITS];
 		wait_on_dquot(dquot);
 		if (empty)
 			dqput(empty);
@@ -607,8 +608,8 @@
 		dqput(dquot);
 		return NODQUOT;
 	}
-	dquot->dq_referenced++;
-	dqstats.lookups++;
+	++dquot->dq_referenced;
+	++dqstats_array[DQSTATS_LOOKUPS];
 
 	return dquot;
 }
@@ -628,7 +629,8 @@
 		printk(KERN_ERR "VFS: dqduplicate(): Locked quota to be duplicated!\n");
 	get_dquot_dup_ref(dquot);
 	dquot->dq_referenced++;
-	dqstats.lookups++;
+	++dqstats_array[DQSTATS_LOOKUPS];
+
 	return dquot;
 }
 
@@ -643,7 +645,7 @@
 	if (!dquot->dq_dup_ref)
 		wake_up(&dquot->dq_wait_free);
 	put_dquot_ref(dquot);
-	dqstats.drops++;
+	++dqstats_array[DQSTATS_DROPS];
 }
 
 static int dqinit_needed(struct inode *inode, int type)
@@ -1277,7 +1279,7 @@
 		dqopt->info[cnt].dqi_igrace = 0;
 		dqopt->info[cnt].dqi_bgrace = 0;
 		dqopt->ops[cnt] = NULL;
-	}	
+	}
 	up(&dqopt->dqoff_sem);
 out:
 	unlock_kernel();
@@ -1461,41 +1463,6 @@
 	return 0;
 }
 
-#ifdef CONFIG_PROC_FS
-static int read_stats(char *buffer, char **start, off_t offset, int count, int *eof, void *data)
-{
-	int len;
-	struct quota_format_type *actqf;
-
-	dqstats.allocated_dquots = nr_dquots;
-	dqstats.free_dquots = nr_free_dquots;
-
-	len = sprintf(buffer, "Version %u\n", __DQUOT_NUM_VERSION__);
-	len += sprintf(buffer + len, "Formats");
-	lock_kernel();
-	for (actqf = quota_formats; actqf; actqf = actqf->qf_next)
-		len += sprintf(buffer + len, " %u", actqf->qf_fmt_id);
-	unlock_kernel();
-	len += sprintf(buffer + len, "\n%u %u %u %u %u %u %u %u\n",
-			dqstats.lookups, dqstats.drops,
-			dqstats.reads, dqstats.writes,
-			dqstats.cache_hits, dqstats.allocated_dquots,
-			dqstats.free_dquots, dqstats.syncs);
-
-	if (offset >= len) {
-		*start = buffer;
-		*eof = 1;
-		return 0;
-	}
-	*start = buffer + offset;
-	if ((len -= offset) > count)
-		return count;
-	*eof = 1;
-
-	return len;
-}
-#endif
-
 struct quotactl_ops vfs_quotactl_ops = {
 	quota_on:	vfs_quota_on,
 	quota_off:	vfs_quota_off,
@@ -1507,8 +1474,7 @@
 };
 
 static ctl_table fs_table[] = {
-	{FS_NRDQUOT, "dquot-nr", &nr_dquots, 2*sizeof(int),
-	 0444, NULL, &proc_dointvec},
+	{FS_DQSTATS, "dqstats", dqstats_array, sizeof(dqstats_array), 0444, NULL, &proc_dointvec},
 	{},
 };
 
@@ -1524,14 +1490,12 @@
 	register_sysctl_table(dquot_table, 0);
 	for (i = 0; i < NR_DQHASH; i++)
 		INIT_LIST_HEAD(dquot_hash + i);
-	printk(KERN_NOTICE "VFS: Diskquotas version %s initialized\n", __DQUOT_VERSION__);
-#ifdef CONFIG_PROC_FS
-	create_proc_read_entry("fs/quota", 0, 0, read_stats, NULL);
-#endif
+	printk(KERN_NOTICE "VFS: Disk quotas v%s\n", __DQUOT_VERSION__);
+
 	return 0;
 }
 __initcall(dquot_init);
 
 EXPORT_SYMBOL(register_quota_format);
 EXPORT_SYMBOL(unregister_quota_format);
-EXPORT_SYMBOL(dqstats);
+EXPORT_SYMBOL(dqstats_array);
diff -Nru a/fs/driverfs/Makefile b/fs/driverfs/Makefile
--- a/fs/driverfs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/driverfs/Makefile	Fri May 24 18:55:35 2002
@@ -1,8 +1,9 @@
-O_TARGET := driverfs.o
+#
+# Makefile for the driverfs virtual filesystem.
+#
 
 export-objs := inode.o
 
 obj-y := inode.o
-obj-m := $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/driverfs/inode.c b/fs/driverfs/inode.c
--- a/fs/driverfs/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/driverfs/inode.c	Fri May 24 18:55:33 2002
@@ -29,6 +29,7 @@
 #include <linux/stat.h>
 #include <linux/fs.h>
 #include <linux/dcache.h>
+#include <linux/namei.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/device.h>
diff -Nru a/fs/efs/Makefile b/fs/efs/Makefile
--- a/fs/efs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/efs/Makefile	Fri May 24 18:55:34 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the linux efs-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := efs.o
+obj-$(CONFIG_EFS_FS) += efs.o
 
-obj-y    := super.o inode.o namei.o dir.o file.o symlink.o
-obj-m    := $(O_TARGET)
+efs-objs := super.o inode.o namei.o dir.o file.o symlink.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/efs/dir.c b/fs/efs/dir.c
--- a/fs/efs/dir.c	Fri May 24 18:55:36 2002
+++ b/fs/efs/dir.c	Fri May 24 18:55:36 2002
@@ -4,6 +4,7 @@
  * Copyright (c) 1999 Al Smith
  */
 
+#include <linux/buffer_head.h>
 #include <linux/efs_fs.h>
 #include <linux/smp_lock.h>
 
diff -Nru a/fs/efs/file.c b/fs/efs/file.c
--- a/fs/efs/file.c	Fri May 24 18:55:33 2002
+++ b/fs/efs/file.c	Fri May 24 18:55:33 2002
@@ -6,6 +6,7 @@
  * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
  */
 
+#include <linux/buffer_head.h>
 #include <linux/efs_fs.h>
 
 int efs_get_block(struct inode *inode, sector_t iblock,
diff -Nru a/fs/efs/inode.c b/fs/efs/inode.c
--- a/fs/efs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/efs/inode.c	Fri May 24 18:55:35 2002
@@ -9,6 +9,7 @@
 
 #include <linux/efs_fs.h>
 #include <linux/efs_fs_sb.h>
+#include <linux/buffer_head.h>
 #include <linux/module.h>
 #include <linux/fs.h>
 
diff -Nru a/fs/efs/namei.c b/fs/efs/namei.c
--- a/fs/efs/namei.c	Fri May 24 18:55:33 2002
+++ b/fs/efs/namei.c	Fri May 24 18:55:33 2002
@@ -6,6 +6,7 @@
  * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
  */
 
+#include <linux/buffer_head.h>
 #include <linux/string.h>
 #include <linux/efs_fs.h>
 #include <linux/smp_lock.h>
diff -Nru a/fs/efs/super.c b/fs/efs/super.c
--- a/fs/efs/super.c	Fri May 24 18:55:34 2002
+++ b/fs/efs/super.c	Fri May 24 18:55:34 2002
@@ -12,6 +12,7 @@
 #include <linux/efs_vh.h>
 #include <linux/efs_fs_sb.h>
 #include <linux/slab.h>
+#include <linux/buffer_head.h>
 
 static struct super_block *efs_get_sb(struct file_system_type *fs_type,
 	int flags, char *dev_name, void *data)
@@ -103,8 +104,6 @@
 	unregister_filesystem(&efs_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_efs_fs)
 module_exit(exit_efs_fs)
diff -Nru a/fs/efs/symlink.c b/fs/efs/symlink.c
--- a/fs/efs/symlink.c	Fri May 24 18:55:36 2002
+++ b/fs/efs/symlink.c	Fri May 24 18:55:36 2002
@@ -9,6 +9,7 @@
 #include <linux/string.h>
 #include <linux/efs_fs.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
 
 static int efs_symlink_readpage(struct file *file, struct page *page)
diff -Nru a/fs/exec.c b/fs/exec.c
--- a/fs/exec.c	Fri May 24 18:55:35 2002
+++ b/fs/exec.c	Fri May 24 18:55:35 2002
@@ -38,6 +38,7 @@
 #include <linux/binfmts.h>
 #define __NO_VERSION__
 #include <linux/module.h>
+#include <linux/namei.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
diff -Nru a/fs/exportfs/Makefile b/fs/exportfs/Makefile
--- a/fs/exportfs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/exportfs/Makefile	Fri May 24 18:55:34 2002
@@ -1,11 +1,10 @@
 #
 # Makefile for the filesystem export support routines.
 
-O_TARGET := exportfs.o
-
 export-objs := expfs.o
 
-obj-y :=    expfs.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_EXPORTFS) += exportfs.o
+
+exportfs-objs := expfs.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
--- a/fs/exportfs/expfs.c	Fri May 24 18:55:34 2002
+++ b/fs/exportfs/expfs.c	Fri May 24 18:55:34 2002
@@ -2,6 +2,7 @@
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/smp_lock.h>
+#include <linux/namei.h>
 
 struct export_operations export_op_default;
 
@@ -457,7 +458,6 @@
 		   int connectable)
 {
 	struct inode * inode = dentry->d_inode;
-	struct inode *parent = dentry->d_parent->d_inode;
 	int len = *max_len;
 	int type = 1;
 	
@@ -468,8 +468,12 @@
 	fh[0] = inode->i_ino;
 	fh[1] = inode->i_generation;
 	if (connectable && !S_ISDIR(inode->i_mode)) {
+		struct inode *parent;
+		read_lock(&dparent_lock);
+		parent = dentry->d_parent->d_inode;
 		fh[2] = parent->i_ino;
 		fh[3] = parent->i_generation;
+		read_unlock(&dparent_lock);
 		len = 4;
 		type = 2;
 	}
diff -Nru a/fs/ext2/Makefile b/fs/ext2/Makefile
--- a/fs/ext2/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/ext2/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the linux ext2-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := ext2.o
+obj-$(CONFIG_EXT2_FS) += ext2.o
 
-obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-		ioctl.o namei.o super.o symlink.o
-obj-m    := $(O_TARGET)
+ext2-objs := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+	     ioctl.o namei.o super.o symlink.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/ext2/balloc.c b/fs/ext2/balloc.c
--- a/fs/ext2/balloc.c	Fri May 24 18:55:35 2002
+++ b/fs/ext2/balloc.c	Fri May 24 18:55:35 2002
@@ -15,6 +15,7 @@
 #include "ext2.h"
 #include <linux/quotaops.h>
 #include <linux/sched.h>
+#include <linux/buffer_head.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
diff -Nru a/fs/ext2/bitmap.c b/fs/ext2/bitmap.c
--- a/fs/ext2/bitmap.c	Fri May 24 18:55:35 2002
+++ b/fs/ext2/bitmap.c	Fri May 24 18:55:35 2002
@@ -7,7 +7,7 @@
  * Universite Pierre et Marie Curie (Paris VI)
  */
 
-#include "ext2.h"
+#include <linux/buffer_head.h>
 
 static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
 
diff -Nru a/fs/ext2/fsync.c b/fs/ext2/fsync.c
--- a/fs/ext2/fsync.c	Fri May 24 18:55:36 2002
+++ b/fs/ext2/fsync.c	Fri May 24 18:55:36 2002
@@ -24,6 +24,7 @@
 
 #include "ext2.h"
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>		/* for fsync_inode_buffers() */
 
 
 /*
diff -Nru a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
--- a/fs/ext2/ialloc.c	Fri May 24 18:55:35 2002
+++ b/fs/ext2/ialloc.c	Fri May 24 18:55:36 2002
@@ -16,6 +16,7 @@
 #include "ext2.h"
 #include <linux/quotaops.h>
 #include <linux/sched.h>
+#include <linux/buffer_head.h>
 
 
 /*
diff -Nru a/fs/ext2/inode.c b/fs/ext2/inode.c
--- a/fs/ext2/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/ext2/inode.c	Fri May 24 18:55:33 2002
@@ -29,6 +29,7 @@
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
 #include <linux/module.h>
+#include <linux/buffer_head.h>
 
 MODULE_AUTHOR("Remy Card and others");
 MODULE_DESCRIPTION("Second Extended Filesystem");
diff -Nru a/fs/ext2/namei.c b/fs/ext2/namei.c
--- a/fs/ext2/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/ext2/namei.c	Fri May 24 18:55:36 2002
@@ -31,6 +31,7 @@
 
 #include "ext2.h"
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>		/* for block_symlink() */
 
 /*
  * Couple of helper functions - make the code slightly cleaner.
diff -Nru a/fs/ext2/super.c b/fs/ext2/super.c
--- a/fs/ext2/super.c	Fri May 24 18:55:36 2002
+++ b/fs/ext2/super.c	Fri May 24 18:55:36 2002
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/random.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
@@ -909,8 +910,6 @@
 	unregister_filesystem(&ext2_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_ext2_fs)
 module_exit(exit_ext2_fs)
diff -Nru a/fs/ext3/Makefile b/fs/ext3/Makefile
--- a/fs/ext3/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/ext3/Makefile	Fri May 24 18:55:33 2002
@@ -1,16 +1,10 @@
 #
-# Makefile for the linux ext2-filesystem routines.
+# Makefile for the linux ext3-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := ext3.o
+obj-$(CONFIG_EXT3_FS) += ext3.o
 
-obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+ext3-objs    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
 		ioctl.o namei.o super.o symlink.o
-obj-m    := $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/ext3/balloc.c b/fs/ext3/balloc.c
--- a/fs/ext3/balloc.c	Fri May 24 18:55:33 2002
+++ b/fs/ext3/balloc.c	Fri May 24 18:55:33 2002
@@ -18,6 +18,7 @@
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
diff -Nru a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c
--- a/fs/ext3/bitmap.c	Fri May 24 18:55:34 2002
+++ b/fs/ext3/bitmap.c	Fri May 24 18:55:34 2002
@@ -7,7 +7,7 @@
  * Universite Pierre et Marie Curie (Paris VI)
  */
 
-#include <linux/fs.h>
+#include <linux/buffer_head.h>
 
 
 static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
diff -Nru a/fs/ext3/dir.c b/fs/ext3/dir.c
--- a/fs/ext3/dir.c	Fri May 24 18:55:36 2002
+++ b/fs/ext3/dir.c	Fri May 24 18:55:36 2002
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/ext3_fs.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
 
 static unsigned char ext3_filetype_table[] = {
diff -Nru a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
--- a/fs/ext3/ialloc.c	Fri May 24 18:55:35 2002
+++ b/fs/ext3/ialloc.c	Fri May 24 18:55:35 2002
@@ -20,6 +20,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
 
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
diff -Nru a/fs/ext3/inode.c b/fs/ext3/inode.c
--- a/fs/ext3/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/ext3/inode.c	Fri May 24 18:55:36 2002
@@ -32,6 +32,7 @@
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 
 /*
  * SEARCH_FROM_ZERO forces each block allocation to search from the start
diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
--- a/fs/ext3/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/ext3/namei.c	Fri May 24 18:55:36 2002
@@ -27,6 +27,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
 
 
diff -Nru a/fs/ext3/super.c b/fs/ext3/super.c
--- a/fs/ext3/super.c	Fri May 24 18:55:36 2002
+++ b/fs/ext3/super.c	Fri May 24 18:55:36 2002
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/uaccess.h>
 
 #ifdef CONFIG_JBD_DEBUG
@@ -1808,8 +1809,6 @@
 	unregister_filesystem(&ext3_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
diff -Nru a/fs/fat/Makefile b/fs/fat/Makefile
--- a/fs/fat/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/fat/Makefile	Fri May 24 18:55:33 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the Linux fat filesystem support.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-O_TARGET := fat.o
 
 export-objs := fatfs_syms.o
 
-obj-y    := buffer.o cache.o dir.o file.o inode.o misc.o cvf.o fatfs_syms.o
-obj-m    := $(O_TARGET)
+obj-$(CONFIG_FAT_FS) += fat.o
+
+fat-objs := buffer.o cache.o dir.o file.o inode.o misc.o cvf.o fatfs_syms.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/fat/buffer.c b/fs/fat/buffer.c
--- a/fs/fat/buffer.c	Fri May 24 18:55:36 2002
+++ b/fs/fat/buffer.c	Fri May 24 18:55:36 2002
@@ -8,6 +8,7 @@
 #include <linux/fs.h>
 #include <linux/msdos_fs.h>
 #include <linux/fat_cvf.h>
+#include <linux/buffer_head.h>
 
 struct buffer_head *fat_bread(struct super_block *sb, int block)
 {
diff -Nru a/fs/fat/cache.c b/fs/fat/cache.c
--- a/fs/fat/cache.c	Fri May 24 18:55:34 2002
+++ b/fs/fat/cache.c	Fri May 24 18:55:34 2002
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/msdos_fs.h>
 #include <linux/fat_cvf.h>
+#include <linux/buffer_head.h>
 
 #if 0
 #  define PRINTK(x) printk x
diff -Nru a/fs/fat/cvf.c b/fs/fat/cvf.c
--- a/fs/fat/cvf.c	Fri May 24 18:55:34 2002
+++ b/fs/fat/cvf.c	Fri May 24 18:55:34 2002
@@ -13,6 +13,7 @@
 #include <linux/msdos_fs_sb.h>
 #include <linux/fat_cvf.h>
 #include <linux/config.h>
+#include <linux/buffer_head.h>
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
 #endif
diff -Nru a/fs/fat/dir.c b/fs/fat/dir.c
--- a/fs/fat/dir.c	Fri May 24 18:55:33 2002
+++ b/fs/fat/dir.c	Fri May 24 18:55:33 2002
@@ -18,6 +18,7 @@
 #include <linux/msdos_fs.h>
 #include <linux/dirent.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
diff -Nru a/fs/fat/file.c b/fs/fat/file.c
--- a/fs/fat/file.c	Fri May 24 18:55:34 2002
+++ b/fs/fat/file.c	Fri May 24 18:55:34 2002
@@ -10,6 +10,7 @@
 #include <linux/msdos_fs.h>
 #include <linux/fat_cvf.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #define PRINTK(x)
 #define Printk(x) printk x
diff -Nru a/fs/fat/inode.c b/fs/fat/inode.c
--- a/fs/fat/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/fat/inode.c	Fri May 24 18:55:35 2002
@@ -17,6 +17,7 @@
 #include <linux/msdos_fs.h>
 #include <linux/fat_cvf.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 //#include <asm/uaccess.h>
 #include <asm/unaligned.h>
diff -Nru a/fs/fat/misc.c b/fs/fat/misc.c
--- a/fs/fat/misc.c	Fri May 24 18:55:34 2002
+++ b/fs/fat/misc.c	Fri May 24 18:55:34 2002
@@ -8,6 +8,7 @@
 
 #include <linux/fs.h>
 #include <linux/msdos_fs.h>
+#include <linux/buffer_head.h>
 
 #if 0
 #  define PRINTK(x)	printk x
diff -Nru a/fs/fcntl.c b/fs/fcntl.c
--- a/fs/fcntl.c	Fri May 24 18:55:33 2002
+++ b/fs/fcntl.c	Fri May 24 18:55:33 2002
@@ -435,7 +435,7 @@
 			   back to SIGIO in that case. --sct */
 			si.si_signo = fown->signum;
 			si.si_errno = 0;
-		        si.si_code  = reason & ~__SI_MASK;
+		        si.si_code  = reason;
 			/* Make sure we are called with one of the POLL_*
 			   reasons, otherwise we could leak kernel stack into
 			   userspace.  */
diff -Nru a/fs/freevxfs/Makefile b/fs/freevxfs/Makefile
--- a/fs/freevxfs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/freevxfs/Makefile	Fri May 24 18:55:36 2002
@@ -2,10 +2,9 @@
 # VxFS Makefile
 #
 
-O_TARGET :=	freevxfs.o
+obj-$(CONFIG_VXFS_FS) += freevxfs.o
 
-obj-y :=	vxfs_bmap.o vxfs_fshead.o vxfs_immed.o vxfs_inode.o \
-		vxfs_lookup.o vxfs_olt.o vxfs_subr.o vxfs_super.o
-obj-m :=	$(O_TARGET)
+freevxfs-objs := vxfs_bmap.o vxfs_fshead.o vxfs_immed.o vxfs_inode.o \
+		 vxfs_lookup.o vxfs_olt.o vxfs_subr.o vxfs_super.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c
--- a/fs/freevxfs/vxfs_bmap.c	Fri May 24 18:55:35 2002
+++ b/fs/freevxfs/vxfs_bmap.c	Fri May 24 18:55:35 2002
@@ -33,6 +33,7 @@
  * Veritas filesystem driver - filesystem to disk block mapping.
  */
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/kernel.h>
 
 #include "vxfs.h"
diff -Nru a/fs/freevxfs/vxfs_fshead.c b/fs/freevxfs/vxfs_fshead.c
--- a/fs/freevxfs/vxfs_fshead.c	Fri May 24 18:55:33 2002
+++ b/fs/freevxfs/vxfs_fshead.c	Fri May 24 18:55:33 2002
@@ -33,6 +33,7 @@
  * Veritas filesystem driver - fileset header routines.
  */
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 
diff -Nru a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
--- a/fs/freevxfs/vxfs_inode.c	Fri May 24 18:55:34 2002
+++ b/fs/freevxfs/vxfs_inode.c	Fri May 24 18:55:34 2002
@@ -33,6 +33,7 @@
  * Veritas filesystem driver - inode routines.
  */
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
diff -Nru a/fs/freevxfs/vxfs_olt.c b/fs/freevxfs/vxfs_olt.c
--- a/fs/freevxfs/vxfs_olt.c	Fri May 24 18:55:35 2002
+++ b/fs/freevxfs/vxfs_olt.c	Fri May 24 18:55:35 2002
@@ -33,6 +33,7 @@
  * Veritas filesystem driver - object location table support.
  */
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/kernel.h>
 
 #include "vxfs.h"
diff -Nru a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c
--- a/fs/freevxfs/vxfs_subr.c	Fri May 24 18:55:34 2002
+++ b/fs/freevxfs/vxfs_subr.c	Fri May 24 18:55:34 2002
@@ -33,6 +33,7 @@
  * Veritas filesystem driver - shared subroutines.
  */
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/pagemap.h>
diff -Nru a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
--- a/fs/freevxfs/vxfs_super.c	Fri May 24 18:55:34 2002
+++ b/fs/freevxfs/vxfs_super.c	Fri May 24 18:55:34 2002
@@ -37,6 +37,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
diff -Nru a/fs/fs-writeback.c b/fs/fs-writeback.c
--- a/fs/fs-writeback.c	Fri May 24 18:55:35 2002
+++ b/fs/fs-writeback.c	Fri May 24 18:55:35 2002
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
+#include <linux/buffer_head.h>
 
 /**
  *	__mark_inode_dirty -	internal function
diff -Nru a/fs/hfs/Makefile b/fs/hfs/Makefile
--- a/fs/hfs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/hfs/Makefile	Fri May 24 18:55:35 2002
@@ -1,19 +1,12 @@
 #
 # Makefile for the Linux hfs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := hfs.o
+obj-$(CONFIG_HFS_FS) += hfs.o
 
-obj-y    := balloc.o bdelete.o bfind.o bins_del.o binsert.o bitmap.o bitops.o \
+hfs-objs := balloc.o bdelete.o bfind.o bins_del.o binsert.o bitmap.o bitops.o \
 	    bnode.o brec.o btree.o catalog.o dir.o dir_cap.o dir_dbl.o \
 	    dir_nat.o extent.o file.o file_cap.o file_hdr.o inode.o mdb.o \
             part_tbl.o string.o super.o sysdep.o trans.o version.o
-
-obj-m    := $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/hfs/file.c b/fs/hfs/file.c
--- a/fs/hfs/file.c	Fri May 24 18:55:34 2002
+++ b/fs/hfs/file.c	Fri May 24 18:55:34 2002
@@ -20,6 +20,7 @@
 #include <linux/hfs_fs_sb.h>
 #include <linux/hfs_fs_i.h>
 #include <linux/hfs_fs.h>
+#include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
 
 /*================ Forward declarations ================*/
diff -Nru a/fs/hpfs/Makefile b/fs/hpfs/Makefile
--- a/fs/hpfs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/hpfs/Makefile	Fri May 24 18:55:33 2002
@@ -1,6 +1,10 @@
-O_TARGET := hpfs.o
+#
+# Makefile for the Linux hpfs filesystem routines.
+#
 
-obj-y := alloc.o anode.o buffer.o dentry.o dir.o dnode.o ea.o file.o inode.o map.o name.o namei.o super.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_HPFS_FS) += hpfs.o
+
+hpfs-objs := alloc.o anode.o buffer.o dentry.o dir.o dnode.o ea.o file.o \
+	     inode.o map.o name.o namei.o super.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c
--- a/fs/hpfs/alloc.c	Fri May 24 18:55:34 2002
+++ b/fs/hpfs/alloc.c	Fri May 24 18:55:34 2002
@@ -6,6 +6,7 @@
  *  HPFS bitmap operations
  */
 
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 /*
diff -Nru a/fs/hpfs/anode.c b/fs/hpfs/anode.c
--- a/fs/hpfs/anode.c	Fri May 24 18:55:33 2002
+++ b/fs/hpfs/anode.c	Fri May 24 18:55:33 2002
@@ -6,6 +6,7 @@
  *  handling HPFS anode tree that contains file allocation info
  */
 
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 /* Find a sector in allocation tree */
diff -Nru a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c
--- a/fs/hpfs/buffer.c	Fri May 24 18:55:35 2002
+++ b/fs/hpfs/buffer.c	Fri May 24 18:55:35 2002
@@ -6,6 +6,7 @@
  *  general buffer i/o
  */
 
+#include <linux/buffer_head.h>
 #include <linux/string.h>
 #include "hpfs_fn.h"
 
diff -Nru a/fs/hpfs/dir.c b/fs/hpfs/dir.c
--- a/fs/hpfs/dir.c	Fri May 24 18:55:34 2002
+++ b/fs/hpfs/dir.c	Fri May 24 18:55:34 2002
@@ -7,6 +7,7 @@
  */
 
 #include "hpfs_fn.h"
+#include <linux/buffer_head.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
 
diff -Nru a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
--- a/fs/hpfs/dnode.c	Fri May 24 18:55:35 2002
+++ b/fs/hpfs/dnode.c	Fri May 24 18:55:35 2002
@@ -6,6 +6,7 @@
  *  handling directory dnode tree - adding, deleteing & searching for dirents
  */
 
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde)
diff -Nru a/fs/hpfs/ea.c b/fs/hpfs/ea.c
--- a/fs/hpfs/ea.c	Fri May 24 18:55:33 2002
+++ b/fs/hpfs/ea.c	Fri May 24 18:55:33 2002
@@ -6,6 +6,7 @@
  *  handling extended attributes
  */
 
+#include <linux/buffer_head.h>
 #include <linux/string.h>
 #include "hpfs_fn.h"
 
diff -Nru a/fs/hpfs/file.c b/fs/hpfs/file.c
--- a/fs/hpfs/file.c	Fri May 24 18:55:35 2002
+++ b/fs/hpfs/file.c	Fri May 24 18:55:35 2002
@@ -6,6 +6,7 @@
  *  file VFS functions
  */
 
+#include <linux/buffer_head.h>
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
diff -Nru a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
--- a/fs/hpfs/hpfs_fn.h	Fri May 24 18:55:36 2002
+++ b/fs/hpfs/hpfs_fn.h	Fri May 24 18:55:36 2002
@@ -9,6 +9,7 @@
 //#define DBG
 //#define DEBUG_LOCKS
 
+#include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include <linux/hpfs_fs.h>
 #include <linux/hpfs_fs_i.h>
diff -Nru a/fs/hpfs/inode.c b/fs/hpfs/inode.c
--- a/fs/hpfs/inode.c	Fri May 24 18:55:34 2002
+++ b/fs/hpfs/inode.c	Fri May 24 18:55:34 2002
@@ -9,6 +9,7 @@
 #include <linux/fs.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 static struct file_operations hpfs_file_ops =
diff -Nru a/fs/hpfs/map.c b/fs/hpfs/map.c
--- a/fs/hpfs/map.c	Fri May 24 18:55:34 2002
+++ b/fs/hpfs/map.c	Fri May 24 18:55:34 2002
@@ -6,6 +6,7 @@
  *  mapping structures to memory with some minimal checks
  */
 
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 unsigned *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh)
diff -Nru a/fs/hpfs/namei.c b/fs/hpfs/namei.c
--- a/fs/hpfs/namei.c	Fri May 24 18:55:35 2002
+++ b/fs/hpfs/namei.c	Fri May 24 18:55:35 2002
@@ -8,6 +8,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 #include "hpfs_fn.h"
 
 int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
diff -Nru a/fs/hpfs/super.c b/fs/hpfs/super.c
--- a/fs/hpfs/super.c	Fri May 24 18:55:36 2002
+++ b/fs/hpfs/super.c	Fri May 24 18:55:36 2002
@@ -6,6 +6,7 @@
  *  mounting, unmounting, error handling
  */
 
+#include <linux/buffer_head.h>
 #include <linux/string.h>
 #include "hpfs_fn.h"
 #include <linux/module.h>
@@ -645,8 +646,6 @@
 	unregister_filesystem(&hpfs_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_hpfs_fs)
 module_exit(exit_hpfs_fs)
diff -Nru a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/inode.c	Fri May 24 18:55:35 2002
@@ -14,6 +14,16 @@
 #include <linux/writeback.h>
 #include <linux/module.h>
 #include <linux/backing-dev.h>
+/*
+ * This is needed for the following functions:
+ *  - inode_has_buffers
+ *  - invalidate_inode_buffers
+ *  - fsync_bdev
+ *  - invalidate_bdev
+ *
+ * FIXME: remove all knowledge of the buffer layer from this file
+ */
+#include <linux/buffer_head.h>
 
 /*
  * New inode.c implementation.
diff -Nru a/fs/intermezzo/Makefile b/fs/intermezzo/Makefile
--- a/fs/intermezzo/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/intermezzo/Makefile	Fri May 24 18:55:34 2002
@@ -2,11 +2,11 @@
 # Makefile 1.00 Peter Braam <braam@clusterfs.com>
 #
 
-O_TARGET := intermezzo.o
+obj-$(CONFIG_INTERMEZZO_FS) += intermezzo.o
 
-obj-y :=  journal_reiserfs.o cache.o  journal.o presto.o vfs.o psdev.o upcall.o methods.o sysctl.o dcache.o  dir.o  super.o journal_ext2.o journal_ext3.o journal_xfs.o  inode.o  file.o journal_obdfs.o
-
-
-obj-m := $(O_TARGET)
+intermezzo-objs := journal_reiserfs.o cache.o journal.o presto.o vfs.o \
+		   psdev.o upcall.o methods.o sysctl.o dcache.o dir.o \
+		   super.o journal_ext2.o journal_ext3.o journal_xfs.o \
+		   inode.o  file.o journal_obdfs.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/isofs/Makefile b/fs/isofs/Makefile
--- a/fs/isofs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/isofs/Makefile	Fri May 24 18:55:35 2002
@@ -1,18 +1,12 @@
 #
 # Makefile for the Linux isofs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := isofs.o
+obj-$(CONFIG_ISO9660_FS) += isofs.o
 
-obj-y  := namei.o inode.o dir.o util.o rock.o
-obj-$(CONFIG_JOLIET) += joliet.o
-obj-$(CONFIG_ZISOFS) += compress.o
-
-obj-m  := $(O_TARGET)
+isofs-objs-y 			:= namei.o inode.o dir.o util.o rock.o
+isofs-objs-$(CONFIG_JOLIET)	+= joliet.o
+isofs-objs-$(CONFIG_ZISOFS)	+= compress.o
+isofs-objs			:= $(isofs-objs-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/isofs/compress.c b/fs/isofs/compress.c
--- a/fs/isofs/compress.c	Fri May 24 18:55:33 2002
+++ b/fs/isofs/compress.c	Fri May 24 18:55:33 2002
@@ -36,6 +36,7 @@
 #include <linux/blkdev.h>
 #include <linux/vmalloc.h>
 #include <linux/zlib.h>
+#include <linux/buffer_head.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
diff -Nru a/fs/isofs/dir.c b/fs/isofs/dir.c
--- a/fs/isofs/dir.c	Fri May 24 18:55:34 2002
+++ b/fs/isofs/dir.c	Fri May 24 18:55:34 2002
@@ -21,6 +21,7 @@
 #include <linux/time.h>
 #include <linux/config.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
diff -Nru a/fs/isofs/inode.c b/fs/isofs/inode.c
--- a/fs/isofs/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/isofs/inode.c	Fri May 24 18:55:36 2002
@@ -27,6 +27,7 @@
 #include <linux/ctype.h>
 #include <linux/smp_lock.h>
 #include <linux/blkdev.h>
+#include <linux/buffer_head.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -1468,8 +1469,6 @@
 #endif
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_iso9660_fs)
 module_exit(exit_iso9660_fs)
diff -Nru a/fs/isofs/namei.c b/fs/isofs/namei.c
--- a/fs/isofs/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/isofs/namei.c	Fri May 24 18:55:36 2002
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/config.h>	/* Joliet? */
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
diff -Nru a/fs/isofs/rock.c b/fs/isofs/rock.c
--- a/fs/isofs/rock.c	Fri May 24 18:55:33 2002
+++ b/fs/isofs/rock.c	Fri May 24 18:55:33 2002
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include "rock.h"
 
diff -Nru a/fs/jbd/Makefile b/fs/jbd/Makefile
--- a/fs/jbd/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/jbd/Makefile	Fri May 24 18:55:35 2002
@@ -1,15 +1,12 @@
 #
-# fs/jbd/Makefile
-# 
 # Makefile for the linux journaling routines.
 #
 
 export-objs := journal.o
-O_TARGET := jbd.o
 
-obj-y   := transaction.o commit.o recovery.o checkpoint.o revoke.o journal.o
+obj-$(CONFIG_JBD) += jbd.o
 
-obj-m   := $(O_TARGET)
+jbd-objs := transaction.o commit.o recovery.o checkpoint.o revoke.o journal.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
--- a/fs/jbd/journal.c	Fri May 24 18:55:34 2002
+++ b/fs/jbd/journal.c	Fri May 24 18:55:34 2002
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/suspend.h>
 #include <linux/pagemap.h>
 #include <asm/uaccess.h>
 #include <linux/proc_fs.h>
@@ -225,6 +226,7 @@
 			journal->j_commit_interval / HZ);
 	list_add(&journal->j_all_journals, &all_journals);
 
+	current->flags |= PF_KERNTHREAD;
 	/* And now, wait forever for commit wakeup events. */
 	while (1) {
 		if (journal->j_flags & JFS_UNMOUNT)
@@ -245,7 +247,15 @@
 		}
 
 		wake_up(&journal->j_wait_done_commit);
-		interruptible_sleep_on(&journal->j_wait_commit);
+		if (current->flags & PF_FREEZE) { /* The simpler the better. Flushing journal isn't a
+						     good idea, because that depends on threads that
+						     may be already stopped. */
+			jbd_debug(1, "Now suspending kjournald\n");
+			refrigerator(PF_IOTHREAD);
+			jbd_debug(1, "Resuming kjournald\n");						
+		} else		/* we assume on resume that commits are already there,
+				   so we don't sleep */
+			interruptible_sleep_on(&journal->j_wait_commit);
 
 		jbd_debug(1, "kjournald wakes\n");
 
diff -Nru a/fs/jffs/Makefile b/fs/jffs/Makefile
--- a/fs/jffs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/jffs/Makefile	Fri May 24 18:55:33 2002
@@ -4,21 +4,11 @@
 # $Id: Makefile,v 1.11 2001/09/25 20:59:41 dwmw2 Exp $
 #
 
-obj-y := jffs_fm.o intrep.o
+obj-$(CONFIG_JFFS_FS) += jffs.o
 
-ifeq ($(PATCHLEVEL),2)
-	obj-y += inode-v22.o
-else
-	obj-y += inode-v23.o
-endif
-
-ifeq ($(CONFIG_JFFS_PROC_FS),y)
-	obj-y += jffs_proc.o
-endif
-
-O_TARGET := jffs.o
-
-obj-m := $(O_TARGET)
+jffs-y 				:= jffs_fm.o intrep.o inode-v23.o
+jffs-$(CONFIG_JFFS_PROC_FS)	+= jffs_proc.o
+jffs-objs			:= $(jffs-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
--- a/fs/jffs/inode-v23.c	Fri May 24 18:55:33 2002
+++ b/fs/jffs/inode-v23.c	Fri May 24 18:55:33 2002
@@ -1803,8 +1803,6 @@
 	kmem_cache_destroy(node_cache);
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_jffs_fs)
 module_exit(exit_jffs_fs)
 
diff -Nru a/fs/jffs/intrep.h b/fs/jffs/intrep.h
--- a/fs/jffs/intrep.h	Fri May 24 18:55:36 2002
+++ b/fs/jffs/intrep.h	Fri May 24 18:55:36 2002
@@ -85,7 +85,4 @@
 void jffs_print_hash_table(struct jffs_control *c);
 void jffs_print_tree(struct jffs_file *first_file, int indent);
 
-struct buffer_head *jffs_get_write_buffer(kdev_t dev, int block);
-void jffs_put_write_buffer(struct buffer_head *bh);
-
 #endif /* __LINUX_JFFS_INTREP_H__  */
diff -Nru a/fs/jffs2/Makefile b/fs/jffs2/Makefile
--- a/fs/jffs2/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/jffs2/Makefile	Fri May 24 18:55:34 2002
@@ -3,12 +3,8 @@
 #
 # $Id: Makefile,v 1.34 2002/03/08 11:27:59 dwmw2 Exp $
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
+obj-$(CONFIG_JFFS2_FS) += jffs2.o
 
 COMPR_OBJS	:= compr.o compr_rubin.o compr_rtime.o compr_zlib.o
 JFFS2_OBJS	:= dir.o file.o ioctl.o nodelist.o malloc.o \
@@ -20,11 +16,8 @@
 
 NAND_OBJS-$(CONFIG_JFFS2_FS_NAND)	:= wbuf.o
 
-O_TARGET := jffs2.o
-
-obj-y := $(COMPR_OBJS) $(JFFS2_OBJS) $(VERS_OBJS) $(NAND_OBJS-y) \
-	$(LINUX_OBJS-$(VERSION)$(PATCHLEVEL))
-obj-m := $(O_TARGET)
+jffs2-objs := $(COMPR_OBJS) $(JFFS2_OBJS) $(VERS_OBJS) $(NAND_OBJS-y) \
+	      $(LINUX_OBJS-$(VERSION)$(PATCHLEVEL))
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/fs/jfs/Makefile b/fs/jfs/Makefile
--- a/fs/jfs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/jfs/Makefile	Fri May 24 18:55:36 2002
@@ -1,19 +1,14 @@
 #
 # Makefile for the Linux JFS filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := jfs.o
-obj-y   := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \
+obj-$(CONFIG_JFS_FS) += jfs.o
+
+jfs-objs := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \
 	    jfs_xtree.o jfs_imap.o jfs_debug.o jfs_dmap.o \
 	    jfs_unicode.o jfs_dtree.o jfs_inode.o \
 	    jfs_extent.o symlink.o jfs_metapage.o \
 	    jfs_logmgr.o jfs_txnmgr.o jfs_uniupr.o
-obj-m   := $(O_TARGET)
 
 EXTRA_CFLAGS += -D_JFS_4K
 
diff -Nru a/fs/jfs/inode.c b/fs/jfs/inode.c
--- a/fs/jfs/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/jfs/inode.c	Fri May 24 18:55:33 2002
@@ -17,6 +17,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include "jfs_incore.h"
 #include "jfs_filsys.h"
 #include "jfs_imap.h"
diff -Nru a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
--- a/fs/jfs/jfs_dtree.c	Fri May 24 18:55:34 2002
+++ b/fs/jfs/jfs_dtree.c	Fri May 24 18:55:34 2002
@@ -2868,8 +2868,6 @@
 	if (filp->f_pos == DIREND)
 		return 0;
 
-	lock_kernel();
-
 	if (DO_INDEX(ip)) {
 		/*
 		 * persistent index is stored in directory entries.
@@ -2887,14 +2885,12 @@
 
 			if (dtEmpty(ip)) {
 				filp->f_pos = DIREND;
-				unlock_kernel();
 				return 0;
 			}
 		      repeat:
 			rc = get_index(ip, dir_index, &dirtab_slot);
 			if (rc) {
 				filp->f_pos = DIREND;
-				unlock_kernel();
 				return rc;
 			}
 			if (dirtab_slot.flag == DIR_INDEX_FREE) {
@@ -2902,13 +2898,11 @@
 					jERROR(1, ("jfs_readdir detected "
 						   "infinite loop!\n"));
 					filp->f_pos = DIREND;
-					unlock_kernel();
 					return 0;
 				}
 				dir_index = le32_to_cpu(dirtab_slot.addr2);
 				if (dir_index == -1) {
 					filp->f_pos = DIREND;
-					unlock_kernel();
 					return 0;
 				}
 				goto repeat;
@@ -2918,14 +2912,12 @@
 			DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
 			if (rc) {
 				filp->f_pos = DIREND;
-				unlock_kernel();
 				return 0;
 			}
 			if (p->header.flag & BT_INTERNAL) {
 				jERROR(1,("jfs_readdir: bad index table\n"));
 				DT_PUTPAGE(mp);
 				filp->f_pos = -1;
-				unlock_kernel();
 				return 0;
 			}
 		} else {
@@ -2935,34 +2927,26 @@
 				 */
 				filp->f_pos = 0;
 				if (filldir(dirent, ".", 1, 0, ip->i_ino,
-					    DT_DIR)) {
-					unlock_kernel();	
+					    DT_DIR))
 					return 0;
-				}
 			}
 			/*
 			 * parent ".."
 			 */
 			filp->f_pos = 1;
-			if (filldir
-			    (dirent, "..", 2, 1, PARENT(ip), DT_DIR)) {
-				unlock_kernel();
+			if (filldir(dirent, "..", 2, 1, PARENT(ip), DT_DIR))
 				return 0;
-			}
 
 			/*
 			 * Find first entry of left-most leaf
 			 */
 			if (dtEmpty(ip)) {
 				filp->f_pos = DIREND;
-				unlock_kernel();
 				return 0;
 			}
 
-			if ((rc = dtReadFirst(ip, &btstack))) {
-				unlock_kernel();
+			if ((rc = dtReadFirst(ip, &btstack)))
 				return -rc;
-			}
 
 			DT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
 		}
@@ -2981,10 +2965,8 @@
 			/* build "." entry */
 
 			if (filldir(dirent, ".", 1, filp->f_pos, ip->i_ino,
-				    DT_DIR)) {
-				unlock_kernel();
+				    DT_DIR))
 				return 0;
-			}
 			dtoffset->index = 1;
 		}
 
@@ -2993,10 +2975,8 @@
 				/* build ".." entry */
 
 				if (filldir(dirent, "..", 2, filp->f_pos,
-					    PARENT(ip), DT_DIR)) {
-					unlock_kernel();
+					    PARENT(ip), DT_DIR))
 					return 0;
-				}
 			} else {
 				jERROR(1,
 				       ("jfs_readdir called with invalid offset!\n"));
@@ -3007,7 +2987,6 @@
 
 		if (dtEmpty(ip)) {
 			filp->f_pos = DIREND;
-			unlock_kernel();
 			return 0;
 		}
 
@@ -3016,7 +2995,6 @@
 			       ("jfs_readdir: unexpected rc = %d from dtReadNext\n",
 				rc));
 			filp->f_pos = DIREND;
-			unlock_kernel();
 			return 0;
 		}
 		/* get start leaf page and index */
@@ -3025,7 +3003,6 @@
 		/* offset beyond directory eof ? */
 		if (bn < 0) {
 			filp->f_pos = DIREND;
-			unlock_kernel();
 			return 0;
 		}
 	}
@@ -3035,7 +3012,6 @@
 		DT_PUTPAGE(mp);
 		jERROR(1, ("jfs_readdir: kmalloc failed!\n"));
 		filp->f_pos = DIREND;
-		unlock_kernel();
 		return 0;
 	}
 	while (1) {
@@ -3110,7 +3086,6 @@
 		DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
 		if (rc) {
 			kfree(d_name);
-			unlock_kernel();
 			return -rc;
 		}
 
@@ -3126,7 +3101,6 @@
       out:
 	kfree(d_name);
 	DT_PUTPAGE(mp);
-	unlock_kernel();
 	return rc;
 }
 
diff -Nru a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
--- a/fs/jfs/jfs_incore.h	Fri May 24 18:55:33 2002
+++ b/fs/jfs/jfs_incore.h	Fri May 24 18:55:33 2002
@@ -122,8 +122,11 @@
 	short		l2nbperpage;	/* 2: log2 blocks per page	*/
 	short		l2niperblk;	/* 2: log2 inodes per page	*/
 	kdev_t		logdev;		/* 2: external log device	*/
+	uint		aggregate;	/* volume identifier in log record */
 	pxd_t		logpxd;		/* 8: pxd describing log	*/
 	pxd_t		ait2;		/* 8: pxd describing AIT copy	*/
+	char		uuid[16];	/* 16: 128-bit uuid for volume	*/
+	char		loguuid[16];	/* 16: 128-bit uuid for log	*/
 	/* Formerly in ipimap */
 	uint		gengen;		/* 4: inode generation generator*/
 	uint		inostamp;	/* 4: shows inode belongs to fileset*/
diff -Nru a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
--- a/fs/jfs/jfs_logmgr.c	Fri May 24 18:55:36 2002
+++ b/fs/jfs/jfs_logmgr.c	Fri May 24 18:55:36 2002
@@ -63,6 +63,7 @@
 #include <linux/interrupt.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
+#include <linux/buffer_head.h>		/* for sync_blockdev() */
 #include "jfs_incore.h"
 #include "jfs_filsys.h"
 #include "jfs_metapage.h"
@@ -168,7 +169,7 @@
 			 tlock_t * tlck);
 
 static int lmNextPage(log_t * log);
-static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate);
+static int lmLogFileSystem(log_t * log, char *uuid, int activate);
 static int lmLogInit(log_t * log);
 static int lmLogShutdown(log_t * log);
 
@@ -1098,6 +1099,11 @@
 	 * file systems to log may have n-to-1 relationship;
 	 */
       externalLog:
+
+	/*
+	 * TODO: Check for already opened log devices
+	 */
+
 	if (!(bdev = bdget(kdev_t_to_nr(JFS_SBI(sb)->logdev)))) {
 		rc = ENODEV;
 		goto errout10;
@@ -1110,6 +1116,7 @@
 
 	log->sb = sb;		/* This should be a list */
 	log->bdev = bdev;
+	memcpy(log->uuid, JFS_SBI(sb)->loguuid, sizeof(log->uuid));
 	
 	/*
 	 * initialize log:
@@ -1120,7 +1127,7 @@
 	/*
 	 * add file system to log active file system list
 	 */
-	if ((rc = lmLogFileSystem(log, sb->s_dev, 1)))
+	if ((rc = lmLogFileSystem(log, JFS_SBI(sb)->uuid, 1)))
 		goto errout30;
 
       out:
@@ -1221,6 +1228,10 @@
 		     ("lmLogInit: inline log:0x%p base:0x%Lx size:0x%x\n",
 		      log, (unsigned long long) log->base, log->size));
 	} else {
+		if (memcmp(logsuper->uuid, log->uuid, 16)) {
+			jERROR(1,("wrong uuid on JFS log device\n"));
+			goto errout20;
+		}
 		log->size = le32_to_cpu(logsuper->size);
 		log->l2bsize = le32_to_cpu(logsuper->l2bsize);
 		jFYI(0,
@@ -1317,7 +1328,6 @@
 	logsuper->state = cpu_to_le32(LOGMOUNT);
 	log->serial = le32_to_cpu(logsuper->serial) + 1;
 	logsuper->serial = cpu_to_le32(log->serial);
-	logsuper->device = cpu_to_le32(log->bdev->bd_dev);
 	lbmDirectWrite(log, bpsuper, lbmWRITE | lbmRELEASE | lbmSYNC);
 	if ((rc = lbmIOWait(bpsuper, lbmFREE)))
 		goto errout30;
@@ -1374,7 +1384,7 @@
 	 *      external log as separate logical volume
 	 */
       externalLog:
-	lmLogFileSystem(log, sb->s_dev, 0);
+	lmLogFileSystem(log, JFS_SBI(sb)->uuid, 0);
 	rc = lmLogShutdown(log);
 	blkdev_put(log->bdev, BDEV_FS);
 
@@ -1509,11 +1519,10 @@
  *			
  * serialization: IWRITE_LOCK(log inode) held on entry/exit
  */
-static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate)
+static int lmLogFileSystem(log_t * log, char *uuid, int activate)
 {
 	int rc = 0;
 	int i;
-	u32 dev_le = cpu_to_le32(kdev_t_to_nr(fsdev));
 	logsuper_t *logsuper;
 	lbuf_t *bpsuper;
 
@@ -1526,8 +1535,8 @@
 	logsuper = (logsuper_t *) bpsuper->l_ldata;
 	if (activate) {
 		for (i = 0; i < MAX_ACTIVE; i++)
-			if (logsuper->active[i] == 0) {
-				logsuper->active[i] = dev_le;
+			if (!memcmp(logsuper->active[i].uuid, NULL_UUID, 16)) {
+				memcpy(logsuper->active[i].uuid, uuid, 16);
 				break;
 			}
 		if (i == MAX_ACTIVE) {
@@ -1537,8 +1546,8 @@
 		}
 	} else {
 		for (i = 0; i < MAX_ACTIVE; i++)
-			if (logsuper->active[i] == dev_le) {
-				logsuper->active[i] = 0;
+			if (!memcmp(logsuper->active[i].uuid, uuid, 16)) {
+				memcpy(logsuper->active[i].uuid, NULL_UUID, 16);
 				break;
 			}
 		assert(i < MAX_ACTIVE);
diff -Nru a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
--- a/fs/jfs/jfs_logmgr.h	Fri May 24 18:55:34 2002
+++ b/fs/jfs/jfs_logmgr.h	Fri May 24 18:55:34 2002
@@ -58,7 +58,7 @@
 #define	LOGMAGIC	0x87654321
 #define	LOGVERSION	1
 
-#define MAX_ACTIVE	512	/* Max active file systems sharing log */
+#define MAX_ACTIVE	128	/* Max active file systems sharing log */
 
 typedef struct {
 	u32 magic;		/* 4: log lv identifier */
@@ -72,10 +72,15 @@
 	u32 state;		/* 4: state - see below */
 
 	s32 end;		/* 4: addr of last log record set by logredo */
-	u32 device;		/* 4: save device in case location changes */
-	u32 active[MAX_ACTIVE];	/* 2048: active file systems list */
+	char uuid[16];		/* 16: 128-bit journal uuid */
+	char label[16];		/* 16: journal label */
+	struct {
+		char uuid[16];
+	} active[MAX_ACTIVE];	/* 2048: active file systems list */
 } logsuper_t;
 
+#define NULL_UUID "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+
 /* log flag: commit option (see jfs_filsys.h) */
 
 /* log state */
@@ -411,6 +416,7 @@
 	spinlock_t synclock;	/* 4: synclist lock */
 	struct lbuf *wqueue;	/* 4: log pageout queue */
 	int count;		/* 4: count */
+	char uuid[16];		/* 16: 128-bit uuid of log device */
 } log_t;
 
 /*
diff -Nru a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
--- a/fs/jfs/jfs_metapage.c	Fri May 24 18:55:34 2002
+++ b/fs/jfs/jfs_metapage.c	Fri May 24 18:55:34 2002
@@ -18,6 +18,7 @@
 
 #include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/buffer_head.h>
 #include "jfs_incore.h"
 #include "jfs_filsys.h"
 #include "jfs_metapage.h"
diff -Nru a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
--- a/fs/jfs/jfs_mount.c	Fri May 24 18:55:34 2002
+++ b/fs/jfs/jfs_mount.c	Fri May 24 18:55:34 2002
@@ -405,8 +405,11 @@
 	sbi->l2niperblk = sbi->l2bsize - L2DISIZE;
 	if (sbi->mntflag & JFS_INLINELOG)
 		sbi->logpxd = j_sb->s_logpxd;
-	else
+	else {
 		sbi->logdev = to_kdev_t(le32_to_cpu(j_sb->s_logdev));
+		memcpy(sbi->uuid, j_sb->s_uuid, sizeof(sbi->uuid));
+		memcpy(sbi->loguuid, j_sb->s_loguuid, sizeof(sbi->uuid));
+	}
 	sbi->ait2 = j_sb->s_ait2;
 
       out:
@@ -446,10 +449,6 @@
 		j_sb->s_logdev =
 			cpu_to_le32(JFS_SBI(sb)->log->bdev->bd_dev);
 		j_sb->s_logserial = cpu_to_le32(JFS_SBI(sb)->log->serial);
-		/* record our own device number in case the location
-		 * changes after a reboot
-		 */
-		j_sb->s_device = cpu_to_le32(kdev_t_to_nr(sb->s_dev));
 	} else if (state == FM_CLEAN) {
 		/*
 		 * If this volume is shared with OS/2, OS/2 will need to
diff -Nru a/fs/jfs/jfs_superblock.h b/fs/jfs/jfs_superblock.h
--- a/fs/jfs/jfs_superblock.h	Fri May 24 18:55:34 2002
+++ b/fs/jfs/jfs_superblock.h	Fri May 24 18:55:34 2002
@@ -91,6 +91,7 @@
 				 *     N.B. This must be 11 bytes to
 				 *          conform with the OS/2 BootSector
 				 *          requirements
+				 *          Only used when s_version is 1
 				 */
 
 	/* extendfs() parameter under s_state & FM_EXTENDFS */
@@ -99,9 +100,9 @@
 	pxd_t s_xlogpxd;	/* 8: extendfs logpxd */
 	/* - 128 byte boundary - */
 
-	u32 s_device;		/* Store device in case location changes
-				 * between reboots
-				 */
+	char s_uuid[16];	/* 16: 128-bit uuid for volume */
+	char s_label[16];	/* 16: volume label */
+	char s_loguuid[16];	/* 16: 128-bit uuid for log device */
 
 };
 
diff -Nru a/fs/jfs/super.c b/fs/jfs/super.c
--- a/fs/jfs/super.c	Fri May 24 18:55:35 2002
+++ b/fs/jfs/super.c	Fri May 24 18:55:35 2002
@@ -492,8 +492,5 @@
 	kmem_cache_destroy(jfs_inode_cachep);
 }
 
-
-EXPORT_NO_SYMBOLS;
-
 module_init(init_jfs_fs)
 module_exit(exit_jfs_fs)
diff -Nru a/fs/libfs.c b/fs/libfs.c
--- a/fs/libfs.c	Fri May 24 18:55:33 2002
+++ b/fs/libfs.c	Fri May 24 18:55:33 2002
@@ -29,6 +29,59 @@
 {
 	return 0;
 }
+ 
+int dcache_dir_open(struct inode *inode, struct file *file)
+{
+	static struct qstr cursor_name = {len:1, name:"."};
+
+	file->private_data = d_alloc(file->f_dentry, &cursor_name);
+
+	return file->private_data ? 0 : -ENOMEM;
+}
+
+int dcache_dir_close(struct inode *inode, struct file *file)
+{
+	dput(file->private_data);
+	return 0;
+}
+
+loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
+{
+	down(&file->f_dentry->d_inode->i_sem);
+	switch (origin) {
+		case 1:
+			offset += file->f_pos;
+		case 0:
+			if (offset >= 0)
+				break;
+		default:
+			up(&file->f_dentry->d_inode->i_sem);
+			return -EINVAL;
+	}
+	if (offset != file->f_pos) {
+		file->f_pos = offset;
+		if (file->f_pos >= 2) {
+			struct list_head *p;
+			struct dentry *cursor = file->private_data;
+			loff_t n = file->f_pos - 2;
+
+			spin_lock(&dcache_lock);
+			p = file->f_dentry->d_subdirs.next;
+			while (n && p != &file->f_dentry->d_subdirs) {
+				struct dentry *next;
+				next = list_entry(p, struct dentry, d_child);
+				if (!list_empty(&next->d_hash) && next->d_inode)
+					n--;
+				p = p->next;
+			}
+			list_del(&cursor->d_child);
+			list_add_tail(&cursor->d_child, p);
+			spin_unlock(&dcache_lock);
+		}
+	}
+	up(&file->f_dentry->d_inode->i_sem);
+	return offset;
+}
 
 /*
  * Directory is locked and all positive dentries in it are safe, since
@@ -38,67 +91,51 @@
 
 int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
 {
-	int i;
 	struct dentry *dentry = filp->f_dentry;
+	struct dentry *cursor = filp->private_data;
+	struct list_head *p, *q = &cursor->d_child;
+	ino_t ino;
+	int i = filp->f_pos;
 
-	lock_kernel();
-
-	i = filp->f_pos;
 	switch (i) {
 		case 0:
-			if (filldir(dirent, ".", 1, i, dentry->d_inode->i_ino, DT_DIR) < 0)
+			ino = dentry->d_inode->i_ino;
+			if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
 				break;
-			i++;
 			filp->f_pos++;
+			i++;
 			/* fallthrough */
 		case 1:
-			if (filldir(dirent, "..", 2, i, parent_ino(dentry), DT_DIR) < 0)
+			ino = parent_ino(dentry);
+			if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
 				break;
-			i++;
 			filp->f_pos++;
+			i++;
 			/* fallthrough */
-		default: {
-			struct list_head *list;
-			int j = i-2;
-
+		default:
 			spin_lock(&dcache_lock);
-			list = dentry->d_subdirs.next;
-
-			for (;;) {
-				if (list == &dentry->d_subdirs) {
-					spin_unlock(&dcache_lock);
-					unlock_kernel();
-					return 0;
-				}
-				if (!j)
-					break;
-				j--;
-				list = list->next;
+			if (filp->f_pos == 2) {
+				list_del(q);
+				list_add(q, &dentry->d_subdirs);
 			}
-
-			while(1) {
-				struct dentry *de = list_entry(list, struct dentry, d_child);
-
-				/*
-				 * See comment on top of function on why we
-				 * can just drop the lock here..
-				 */
-				if (!list_empty(&de->d_hash) && de->d_inode) {
-					spin_unlock(&dcache_lock);
-					if (filldir(dirent, de->d_name.name, de->d_name.len, filp->f_pos, de->d_inode->i_ino, DT_UNKNOWN) < 0)
-						break;
-					spin_lock(&dcache_lock);
-				}
-				filp->f_pos++;
-				list = list->next;
-				if (list != &dentry->d_subdirs)
+			for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
+				struct dentry *next;
+				next = list_entry(p, struct dentry, d_child);
+				if (list_empty(&next->d_hash) || !next->d_inode)
 					continue;
+
 				spin_unlock(&dcache_lock);
-				break;
+				if (filldir(dirent, next->d_name.name, next->d_name.len, filp->f_pos, next->d_inode->i_ino, DT_UNKNOWN) < 0)
+					return 0;
+				spin_lock(&dcache_lock);
+				/* next is still alive */
+				list_del(q);
+				list_add(q, p);
+				p = q;
+				filp->f_pos++;
 			}
-		}
+			spin_unlock(&dcache_lock);
 	}
-	unlock_kernel();
 	return 0;
 }
 
@@ -108,6 +145,9 @@
 }
 
 struct file_operations simple_dir_operations = {
+	open:		dcache_dir_open,
+	release:	dcache_dir_close,
+	llseek:		dcache_dir_lseek,
 	read:		generic_read_dir,
 	readdir:	dcache_readdir,
 };
diff -Nru a/fs/lockd/Makefile b/fs/lockd/Makefile
--- a/fs/lockd/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/lockd/Makefile	Fri May 24 18:55:33 2002
@@ -1,21 +1,14 @@
 #
 # Makefile for the linux lock manager stuff
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-O_TARGET := lockd.o
 
 export-objs := lockd_syms.o
 
-obj-y    := clntlock.o clntproc.o host.o svc.o svclock.o svcshare.o \
-	    svcproc.o svcsubs.o mon.o xdr.o lockd_syms.o
-
-obj-$(CONFIG_LOCKD_V4) += xdr4.o svc4proc.o
+obj-$(CONFIG_LOCKD) += lockd.o
 
-obj-m    := $(O_TARGET)
+lockd-objs-y := clntlock.o clntproc.o host.o svc.o svclock.o svcshare.o \
+	        svcproc.o svcsubs.o mon.o xdr.o lockd_syms.o
+lockd-objs-$(CONFIG_LOCKD_V4) += xdr4.o svc4proc.o
+lockd-objs		      := $(lockd-objs-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/minix/Makefile b/fs/minix/Makefile
--- a/fs/minix/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/minix/Makefile	Fri May 24 18:55:34 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the Linux minix filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := minix.o
+obj-$(CONFIG_MINIX_FS) += minix.o
 
-obj-y    := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o
-obj-m    := $(O_TARGET)
+minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/minix/bitmap.c b/fs/minix/bitmap.c
--- a/fs/minix/bitmap.c	Fri May 24 18:55:34 2002
+++ b/fs/minix/bitmap.c	Fri May 24 18:55:34 2002
@@ -13,6 +13,7 @@
 
 #include "minix.h"
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/bitops.h>
 
 static int nibblemap[] = { 4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0 };
diff -Nru a/fs/minix/file.c b/fs/minix/file.c
--- a/fs/minix/file.c	Fri May 24 18:55:35 2002
+++ b/fs/minix/file.c	Fri May 24 18:55:35 2002
@@ -6,6 +6,7 @@
  *  minix regular file handling primitives
  */
 
+#include <linux/buffer_head.h>		/* for fsync_inode_buffers() */
 #include "minix.h"
 
 /*
@@ -24,6 +25,7 @@
 
 struct inode_operations minix_file_inode_operations = {
 	truncate:	minix_truncate,
+	getattr:	minix_getattr,
 };
 
 int minix_sync_file(struct file * file, struct dentry *dentry, int datasync)
diff -Nru a/fs/minix/inode.c b/fs/minix/inode.c
--- a/fs/minix/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/minix/inode.c	Fri May 24 18:55:36 2002
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include "minix.h"
+#include <linux/buffer_head.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/highuid.h>
@@ -340,6 +341,12 @@
 	bmap: minix_bmap
 };
 
+static struct inode_operations minix_symlink_inode_operations = {
+	readlink:	page_readlink,
+	follow_link:	page_follow_link,
+	getattr:	minix_getattr,
+};
+
 void minix_set_inode(struct inode *inode, dev_t rdev)
 {
 	if (S_ISREG(inode->i_mode)) {
@@ -351,7 +358,7 @@
 		inode->i_fop = &minix_dir_operations;
 		inode->i_mapping->a_ops = &minix_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
-		inode->i_op = &page_symlink_inode_operations;
+		inode->i_op = &minix_symlink_inode_operations;
 		inode->i_mapping->a_ops = &minix_aops;
 	} else
 		init_special_inode(inode, inode->i_mode, rdev);
@@ -518,6 +525,17 @@
 	return err;
 }
 
+int minix_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+	generic_fillattr(dentry->d_inode, stat);
+	if (INODE_VERSION(dentry->d_inode) == MINIX_V1)
+		stat->blocks = (BLOCK_SIZE / 512) * V1_minix_blocks(stat->size);
+	else
+		stat->blocks = (BLOCK_SIZE / 512) * V2_minix_blocks(stat->size);
+	stat->blksize = BLOCK_SIZE;
+	return 0;
+}
+
 /*
  * The function that is called for file truncation.
  */
@@ -563,8 +581,6 @@
         unregister_filesystem(&minix_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_minix_fs)
 module_exit(exit_minix_fs)
diff -Nru a/fs/minix/itree_common.c b/fs/minix/itree_common.c
--- a/fs/minix/itree_common.c	Fri May 24 18:55:36 2002
+++ b/fs/minix/itree_common.c	Fri May 24 18:55:36 2002
@@ -345,3 +345,18 @@
 	inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 	mark_inode_dirty(inode);
 }
+
+static inline unsigned nblocks(loff_t size)
+{
+	unsigned blocks, res, direct = DIRECT, i = DEPTH;
+	blocks = (size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS;
+	res = blocks;
+	while (--i && blocks > direct) {
+		blocks -= direct;
+		blocks += BLOCK_SIZE/sizeof(block_t) - 1;
+		blocks /= BLOCK_SIZE/sizeof(block_t);
+		res += blocks;
+		direct = 1;
+	}
+	return blocks;
+}
diff -Nru a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
--- a/fs/minix/itree_v1.c	Fri May 24 18:55:35 2002
+++ b/fs/minix/itree_v1.c	Fri May 24 18:55:35 2002
@@ -1,3 +1,4 @@
+#include <linux/buffer_head.h>
 #include "minix.h"
 
 enum {DEPTH = 3, DIRECT = 7};	/* Only double indirect */
@@ -52,4 +53,9 @@
 void V1_minix_truncate(struct inode * inode)
 {
 	truncate(inode);
+}
+
+unsigned V1_minix_blocks(loff_t size)
+{
+	return nblocks(size);
 }
diff -Nru a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
--- a/fs/minix/itree_v2.c	Fri May 24 18:55:34 2002
+++ b/fs/minix/itree_v2.c	Fri May 24 18:55:34 2002
@@ -1,3 +1,4 @@
+#include <linux/buffer_head.h>
 #include "minix.h"
 
 enum {DIRECT = 7, DEPTH = 4};	/* Have triple indirect */
@@ -57,4 +58,9 @@
 void V2_minix_truncate(struct inode * inode)
 {
 	truncate(inode);
+}
+
+unsigned V2_minix_blocks(loff_t size)
+{
+	return nblocks(size);
 }
diff -Nru a/fs/minix/minix.h b/fs/minix/minix.h
--- a/fs/minix/minix.h	Fri May 24 18:55:35 2002
+++ b/fs/minix/minix.h	Fri May 24 18:55:35 2002
@@ -55,6 +55,9 @@
 extern void minix_free_block(struct inode * inode, int block);
 extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi);
 
+extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *);
+
+extern void V2_minix_truncate(struct inode *);
 extern void V1_minix_truncate(struct inode *);
 extern void V2_minix_truncate(struct inode *);
 extern void minix_truncate(struct inode *);
@@ -62,6 +65,8 @@
 extern void minix_set_inode(struct inode *, dev_t);
 extern int V1_minix_get_block(struct inode *, long, struct buffer_head *, int);
 extern int V2_minix_get_block(struct inode *, long, struct buffer_head *, int);
+extern unsigned V1_minix_blocks(loff_t);
+extern unsigned V2_minix_blocks(loff_t);
 
 extern struct minix_dir_entry *minix_find_entry(struct dentry*, struct page**);
 extern int minix_add_link(struct dentry*, struct inode*);
diff -Nru a/fs/minix/namei.c b/fs/minix/namei.c
--- a/fs/minix/namei.c	Fri May 24 18:55:35 2002
+++ b/fs/minix/namei.c	Fri May 24 18:55:35 2002
@@ -4,6 +4,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/buffer_head.h>	/* for block_symlink() */
 #include "minix.h"
 
 static inline void inc_count(struct inode *inode)
@@ -307,4 +308,5 @@
 	rmdir:		minix_rmdir,
 	mknod:		minix_mknod,
 	rename:		minix_rename,
+	getattr:	minix_getattr,
 };
diff -Nru a/fs/msdos/Makefile b/fs/msdos/Makefile
--- a/fs/msdos/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/msdos/Makefile	Fri May 24 18:55:36 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the Linux msdos filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-O_TARGET := msdos.o
 
 export-objs := msdosfs_syms.o
 
-obj-y := namei.o msdosfs_syms.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_MSDOS_FS) += msdos.o
+
+msdos-objs := namei.o msdosfs_syms.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/msdos/namei.c b/fs/msdos/namei.c
--- a/fs/msdos/namei.c	Fri May 24 18:55:35 2002
+++ b/fs/msdos/namei.c	Fri May 24 18:55:35 2002
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 
 #include <linux/time.h>
+#include <linux/buffer_head.h>
 #include <linux/msdos_fs.h>
 #include <linux/smp_lock.h>
 
diff -Nru a/fs/namei.c b/fs/namei.c
--- a/fs/namei.c	Fri May 24 18:55:35 2002
+++ b/fs/namei.c	Fri May 24 18:55:35 2002
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/namei.h>
 #include <linux/quotaops.h>
 #include <linux/pagemap.h>
 #include <linux/dnotify.h>
@@ -1865,11 +1866,8 @@
 			d_rehash(new_dentry);
 		dput(new_dentry);
 	}
-	if (!error) {
-		lock_kernel();
+	if (!error)
 		d_move(old_dentry,new_dentry);
-		unlock_kernel();
-	}
 	return error;
 }
 
@@ -1889,11 +1887,8 @@
 		error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
 	if (!error) {
 		/* The following d_move() should become unconditional */
-		if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME)) {
-			lock_kernel();
+		if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME))
 			d_move(old_dentry, new_dentry);
-			unlock_kernel();
-		}
 	}
 	if (target)
 		up(&target->i_sem);
diff -Nru a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c	Fri May 24 18:55:36 2002
+++ b/fs/namespace.c	Fri May 24 18:55:36 2002
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/seq_file.h>
 #include <linux/namespace.h>
+#include <linux/namei.h>
 
 #include <asm/uaccess.h>
 
diff -Nru a/fs/ncpfs/Makefile b/fs/ncpfs/Makefile
--- a/fs/ncpfs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/ncpfs/Makefile	Fri May 24 18:55:36 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the linux ncp filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := ncpfs.o
+obj-$(CONFIG_NCP_FS) += ncpfs.o
 
-obj-y    := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o \
+ncpfs-objs   := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o \
 		symlink.o ncpsign_kernel.o
-obj-m    := $(O_TARGET)
 
 # If you want debugging output, please uncomment the following line
 # EXTRA_CFLAGS += -DDEBUG_NCP=1
diff -Nru a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
--- a/fs/ncpfs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/ncpfs/inode.c	Fri May 24 18:55:35 2002
@@ -794,8 +794,6 @@
 #endif
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_ncp_fs)
 module_exit(exit_ncp_fs)
 MODULE_LICENSE("GPL");
diff -Nru a/fs/nfs/Makefile b/fs/nfs/Makefile
--- a/fs/nfs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/nfs/Makefile	Fri May 24 18:55:34 2002
@@ -1,20 +1,13 @@
 #
 # Makefile for the Linux nfs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := nfs.o
+obj-$(CONFIG_NFS_FS) += nfs.o
 
-obj-y    := dir.o file.o flushd.o inode.o nfs2xdr.o pagelist.o proc.o \
-	    read.o symlink.o unlink.o write.o
-
-obj-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o      
-obj-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o
-
-obj-m   := $(O_TARGET)
+nfs-y 			:= dir.o file.o flushd.o inode.o nfs2xdr.o pagelist.o \
+			   proc.o read.o symlink.o unlink.o write.o
+nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o mount_clnt.o      
+nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
+nfs-objs		:= $(nfs-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/nfs/dir.c b/fs/nfs/dir.c
--- a/fs/nfs/dir.c	Fri May 24 18:55:35 2002
+++ b/fs/nfs/dir.c	Fri May 24 18:55:35 2002
@@ -30,6 +30,7 @@
 #include <linux/nfs_mount.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/namei.h>
 
 #define NFS_PARANOIA 1
 /* #define NFS_DEBUG_VERBOSE 1 */
@@ -64,8 +65,8 @@
 	mknod:		nfs_mknod,
 	rename:		nfs_rename,
 	permission:	nfs_permission,
-	revalidate:	nfs_revalidate,
-	setattr:	nfs_notify_change,
+	getattr:	nfs_getattr,
+	setattr:	nfs_setattr,
 };
 
 typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int);
@@ -357,7 +358,7 @@
 
 	lock_kernel();
 
-	res = nfs_revalidate(dentry);
+	res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
 	if (res < 0) {
 		unlock_kernel();
 		return res;
diff -Nru a/fs/nfs/file.c b/fs/nfs/file.c
--- a/fs/nfs/file.c	Fri May 24 18:55:36 2002
+++ b/fs/nfs/file.c	Fri May 24 18:55:36 2002
@@ -54,8 +54,8 @@
 
 struct inode_operations nfs_file_inode_operations = {
 	permission:	nfs_permission,
-	revalidate:	nfs_revalidate,
-	setattr:	nfs_notify_change,
+	getattr:	nfs_getattr,
+	setattr:	nfs_setattr,
 };
 
 /* Hack for future NFS swap support */
diff -Nru a/fs/nfs/inode.c b/fs/nfs/inode.c
--- a/fs/nfs/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/nfs/inode.c	Fri May 24 18:55:36 2002
@@ -730,7 +730,7 @@
 }
 
 int
-nfs_notify_change(struct dentry *dentry, struct iattr *attr)
+nfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
 	struct inode *inode = dentry->d_inode;
 	struct nfs_fattr fattr;
@@ -744,7 +744,7 @@
 	error = nfs_revalidate_inode(NFS_SERVER(inode),inode);
 	if (error) {
 #ifdef NFS_PARANOIA
-printk("nfs_notify_change: revalidate failed, error=%d\n", error);
+printk("nfs_setattr: revalidate failed, error=%d\n", error);
 #endif
 		goto out;
 	}
@@ -768,7 +768,7 @@
 	 */
 	if (attr->ia_valid & ATTR_SIZE) {
 		if (attr->ia_size != fattr.size)
-			printk("nfs_notify_change: attr=%Ld, fattr=%Ld??\n",
+			printk("nfs_setattr: attr=%Ld, fattr=%Ld??\n",
 			       (long long) attr->ia_size, (long long)fattr.size);
 		vmtruncate(inode, attr->ia_size);
 	}
@@ -808,14 +808,13 @@
 	return error;
 }
 
-/*
- * Externally visible revalidation function
- */
-int
-nfs_revalidate(struct dentry *dentry)
+int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 {
 	struct inode *inode = dentry->d_inode;
-	return nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	int err = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	if (!err)
+		generic_fillattr(inode, stat);
+	return err;
 }
 
 /*
@@ -1335,7 +1334,6 @@
 	unregister_filesystem(&nfs_fs_type);
 }
 
-EXPORT_NO_SYMBOLS;
 /* Not quite true; I just maintain it */
 MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
 MODULE_LICENSE("GPL");
diff -Nru a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
--- a/fs/nfs/nfsroot.c	Fri May 24 18:55:36 2002
+++ b/fs/nfs/nfsroot.c	Fri May 24 18:55:36 2002
@@ -80,6 +80,7 @@
 #include <linux/in.h>
 #include <linux/major.h>
 #include <linux/utsname.h>
+#include <linux/inet.h>
 #include <net/ipconfig.h>
 
 /* Define this to allow debugging output */
diff -Nru a/fs/nfs/symlink.c b/fs/nfs/symlink.c
--- a/fs/nfs/symlink.c	Fri May 24 18:55:33 2002
+++ b/fs/nfs/symlink.c	Fri May 24 18:55:33 2002
@@ -59,7 +59,9 @@
 	struct page *page;
 	u32 *p;
 
-	/* Caller revalidated the directory inode already. */
+	page = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode));
+	if (page)
+		goto read_failed;
 	page = read_cache_page(&inode->i_data, 0,
 				(filler_t *)nfs_symlink_filler, inode);
 	if (IS_ERR(page))
@@ -69,10 +71,10 @@
 	*ppage = page;
 	p = kmap(page);
 	return (char*)(p+1);
-		
+
 getlink_read_error:
 	page_cache_release(page);
-	return ERR_PTR(-EIO);
+	page = ERR_PTR(-EIO);
 read_failed:
 	return (char*)page;
 }
@@ -107,6 +109,6 @@
 struct inode_operations nfs_symlink_inode_operations = {
 	readlink:	nfs_readlink,
 	follow_link:	nfs_follow_link,
-	revalidate:	nfs_revalidate,
-	setattr:	nfs_notify_change,
+	getattr:	nfs_getattr,
+	setattr:	nfs_setattr,
 };
diff -Nru a/fs/nfsctl.c b/fs/nfsctl.c
--- a/fs/nfsctl.c	Fri May 24 18:55:36 2002
+++ b/fs/nfsctl.c	Fri May 24 18:55:36 2002
@@ -11,6 +11,7 @@
 #include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/syscall.h>
 #include <linux/linkage.h>
+#include <linux/namei.h>
 #include <asm/uaccess.h>
 
 /*
diff -Nru a/fs/nfsd/Makefile b/fs/nfsd/Makefile
--- a/fs/nfsd/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/nfsd/Makefile	Fri May 24 18:55:35 2002
@@ -1,20 +1,12 @@
 #
-# Makefile for the Linux nfs filesystem routines.
+# Makefile for the Linux nfs server
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-O_TARGET := nfsd.o
-
-obj-y :=    nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
-	    export.o auth.o lockd.o nfscache.o nfsxdr.o \
-	    stats.o
 
-obj-$(CONFIG_NFSD_V3) += nfs3proc.o nfs3xdr.o
+obj-$(CONFIG_NFSD)	+= nfsd.o
 
-obj-m := $(O_TARGET)
+nfsd-y 			:= nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
+			   export.o auth.o lockd.o nfscache.o nfsxdr.o stats.o
+nfsd-$(CONFIG_NFSD_V3)	+= nfs3proc.o nfs3xdr.o
+nfsd-objs		:= $(nfsd-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/nfsd/export.c b/fs/nfsd/export.c
--- a/fs/nfsd/export.c	Fri May 24 18:55:36 2002
+++ b/fs/nfsd/export.c	Fri May 24 18:55:36 2002
@@ -21,6 +21,7 @@
 #include <linux/in.h>
 #include <linux/seq_file.h>
 #include <linux/rwsem.h>
+#include <linux/namei.h>
 
 #include <linux/sunrpc/svc.h>
 #include <linux/nfsd/nfsd.h>
diff -Nru a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
--- a/fs/nfsd/nfs3xdr.c	Fri May 24 18:55:33 2002
+++ b/fs/nfsd/nfs3xdr.c	Fri May 24 18:55:33 2002
@@ -9,6 +9,10 @@
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/nfs3.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/dcache.h>
+#include <linux/namei.h>
 
 #include <linux/sunrpc/xdr.h>
 #include <linux/sunrpc/svc.h>
diff -Nru a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
--- a/fs/nfsd/nfsctl.c	Fri May 24 18:55:34 2002
+++ b/fs/nfsd/nfsctl.c	Fri May 24 18:55:34 2002
@@ -406,7 +406,6 @@
 	unregister_filesystem(&nfsd_fs_type);
 }
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
 MODULE_LICENSE("GPL");
 module_init(init_nfsd)
diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c	Fri May 24 18:55:35 2002
+++ b/fs/nfsd/nfsfh.c	Fri May 24 18:55:35 2002
@@ -45,27 +45,26 @@
 	struct svc_export *exp = expv;
 	int rv;
 	struct dentry *tdentry;
+	struct dentry *parent;
 
 	if (exp->ex_flags & NFSEXP_NOSUBTREECHECK)
 		return 1;
 
-	dget(dentry);
-	read_lock(&dparent_lock);
-	for (tdentry = dentry;
-	     tdentry != exp->ex_dentry && ! IS_ROOT(tdentry);
-	     (dget(tdentry->d_parent),
-	      dput(tdentry),
-	      tdentry = tdentry->d_parent)
-		) {
+	tdentry = dget(dentry);
+	while (tdentry != exp->ex_dentry && ! IS_ROOT(tdentry)) {
 		/* make sure parents give x permission to user */
 		int err;
-		read_unlock(&dparent_lock);
-		err = permission(tdentry->d_parent->d_inode, S_IXOTH);
 		read_lock(&dparent_lock);
-		if (err < 0)
+		parent = dget(tdentry->d_parent);
+		read_unlock(&dparent_lock);
+		err = permission(parent->d_inode, S_IXOTH);
+		if (err < 0) {
+			dput(parent);
 			break;
+		}
+		dput(tdentry);
+		tdentry = parent;
 	}
-	read_unlock(&dparent_lock);
 	if (tdentry != exp->ex_dentry)
 		dprintk("nfsd_acceptable failed at %p %s\n", tdentry, tdentry->d_name.name);
 	rv = (tdentry == exp->ex_dentry);
diff -Nru a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
--- a/fs/nfsd/nfsproc.c	Fri May 24 18:55:35 2002
+++ b/fs/nfsd/nfsproc.c	Fri May 24 18:55:35 2002
@@ -15,6 +15,7 @@
 #include <linux/fcntl.h>
 #include <linux/net.h>
 #include <linux/in.h>
+#include <linux/namei.h>
 #include <linux/version.h>
 #include <linux/unistd.h>
 #include <linux/slab.h>
diff -Nru a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
--- a/fs/nfsd/vfs.c	Fri May 24 18:55:35 2002
+++ b/fs/nfsd/vfs.c	Fri May 24 18:55:35 2002
@@ -32,6 +32,7 @@
 #include <linux/in.h>
 #define __NO_VERSION__
 #include <linux/module.h>
+#include <linux/namei.h>
 
 #include <linux/sunrpc/svc.h>
 #include <linux/nfsd/nfsd.h>
diff -Nru a/fs/nls/Makefile b/fs/nls/Makefile
--- a/fs/nls/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/nls/Makefile	Fri May 24 18:55:34 2002
@@ -2,13 +2,9 @@
 # Makefile for native language support
 #
 
-O_TARGET = nls.o
 export-objs := nls_base.o
 
-obj-y	:=	nls_base.o
-obj-m	:=
-obj-n	:=
-obj-	:=
+obj-$(CONFIG_NLS)		+= nls_base.o
 
 obj-$(CONFIG_NLS_CODEPAGE_437)	+= nls_cp437.o
 obj-$(CONFIG_NLS_CODEPAGE_737)	+= nls_cp737.o
@@ -30,14 +26,8 @@
 obj-$(CONFIG_NLS_CODEPAGE_936)	+= nls_cp936.o nls_gb2312.o
 obj-$(CONFIG_NLS_CODEPAGE_949)	+= nls_cp949.o nls_euc-kr.o
 obj-$(CONFIG_NLS_CODEPAGE_950)	+= nls_cp950.o nls_big5.o
-obj-$(CONFIG_NLS_CODEPAGE_1250)	+= nls_cp1250.o
 obj-$(CONFIG_NLS_CODEPAGE_1251)	+= nls_cp1251.o
-obj-$(CONFIG_NLS_CODEPAGE_1252)	+= nls_cp1252.o
-obj-$(CONFIG_NLS_CODEPAGE_1253)	+= nls_cp1253.o
-obj-$(CONFIG_NLS_CODEPAGE_1254)	+= nls_cp1254.o
-obj-$(CONFIG_NLS_CODEPAGE_1256)	+= nls_cp1256.o
-obj-$(CONFIG_NLS_CODEPAGE_1257)	+= nls_cp1257.o
-obj-$(CONFIG_NLS_CODEPAGE_1258)	+= nls_cp1258.o
+obj-$(CONFIG_NLS_CODEPAGE_1255)	+= nls_cp1255.o
 obj-$(CONFIG_NLS_ISO8859_1)	+= nls_iso8859-1.o
 obj-$(CONFIG_NLS_ISO8859_2)	+= nls_iso8859-2.o
 obj-$(CONFIG_NLS_ISO8859_3)	+= nls_iso8859-3.o
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/ntfs/Makefile	Fri May 24 18:55:33 2002
@@ -1,11 +1,9 @@
 # Rules for making the NTFS driver.
 
-O_TARGET := ntfs.o
+obj-$(CONFIG_NTFS_FS) += ntfs.o
 
-obj-y   := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
-		mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o
-
-obj-m   := $(O_TARGET)
+ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
+	     mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o
 
 EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.7\"
 
diff -Nru a/fs/ntfs/aops.c b/fs/ntfs/aops.c
--- a/fs/ntfs/aops.c	Fri May 24 18:55:36 2002
+++ b/fs/ntfs/aops.c	Fri May 24 18:55:36 2002
@@ -25,6 +25,7 @@
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
+#include <linux/buffer_head.h>
 
 #include "ntfs.h"
 
diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
--- a/fs/ntfs/attrib.c	Fri May 24 18:55:35 2002
+++ b/fs/ntfs/attrib.c	Fri May 24 18:55:35 2002
@@ -20,6 +20,7 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/buffer_head.h>
 #include "ntfs.h"
 
 /* Temporary helper functions -- might become macros */
diff -Nru a/fs/ntfs/compress.c b/fs/ntfs/compress.c
--- a/fs/ntfs/compress.c	Fri May 24 18:55:35 2002
+++ b/fs/ntfs/compress.c	Fri May 24 18:55:35 2002
@@ -22,6 +22,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 
 #include "ntfs.h"
 
diff -Nru a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/ntfs/inode.c	Fri May 24 18:55:35 2002
@@ -20,6 +20,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 #include "ntfs.h"
 
diff -Nru a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c	Fri May 24 18:55:33 2002
+++ b/fs/ntfs/super.c	Fri May 24 18:55:33 2002
@@ -26,6 +26,7 @@
 #include <linux/spinlock.h>
 #include <linux/blkdev.h>	/* For bdev_hardsect_size(). */
 #include <linux/backing-dev.h>
+#include <linux/buffer_head.h>
 
 #include "ntfs.h"
 #include "sysctl.h"
@@ -1934,7 +1935,6 @@
 	ntfs_sysctl(0);
 }
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
 MODULE_DESCRIPTION("NTFS 1.2/3.x driver");
 MODULE_LICENSE("GPL");
diff -Nru a/fs/open.c b/fs/open.c
--- a/fs/open.c	Fri May 24 18:55:33 2002
+++ b/fs/open.c	Fri May 24 18:55:33 2002
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/iobuf.h>
+#include <linux/namei.h>
 #include <linux/backing-dev.h>
 
 #include <asm/uaccess.h>
diff -Nru a/fs/openpromfs/Makefile b/fs/openpromfs/Makefile
--- a/fs/openpromfs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/openpromfs/Makefile	Fri May 24 18:55:35 2002
@@ -1,15 +1,9 @@
 #
-# Makefile for the Linux minix filesystem routines.
+# Makefile for the Linux Sun Openprom filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := openpromfs.o
+obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs.o
 
-obj-y   := inode.o
-obj-m   := $(O_TARGET)
+openpromfs-objs := inode.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
--- a/fs/openpromfs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/openpromfs/inode.c	Fri May 24 18:55:35 2002
@@ -1064,8 +1064,6 @@
 	nodes = NULL;
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_openprom_fs)
 module_exit(exit_openprom_fs)
 MODULE_LICENSE("GPL");
diff -Nru a/fs/partitions/Makefile b/fs/partitions/Makefile
--- a/fs/partitions/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/partitions/Makefile	Fri May 24 18:55:35 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the linux kernel.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-O_TARGET := partitions.o
 
 export-objs := check.o ibm.o msdos.o
 
diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
--- a/fs/partitions/check.c	Fri May 24 18:55:35 2002
+++ b/fs/partitions/check.c	Fri May 24 18:55:35 2002
@@ -21,6 +21,7 @@
 #include <linux/blk.h>
 #include <linux/init.h>
 #include <linux/raid/md.h>
+#include <linux/buffer_head.h>	/* for invalidate_bdev() */
 
 #include "check.h"
 
@@ -254,12 +255,17 @@
 	bdev->bd_contains = bdev;
 	bdev->bd_inode->i_size = (loff_t)hd->part[minor(dev)].nr_sects << 9;
 	if (!bdev->bd_openers) {
+		struct blk_dev_struct *p = blk_dev + major(dev);
 		unsigned bsize = bdev_hardsect_size(bdev);
 		while (bsize < PAGE_CACHE_SIZE) {
 			if (bdev->bd_inode->i_size & bsize)
 				break;
 			bsize <<= 1;
 		}
+		if (p->queue)
+			bdev->bd_queue =  p->queue(dev);
+		else
+			bdev->bd_queue = &p->request_queue;
 		bdev->bd_block_size = bsize;
 		bdev->bd_inode->i_blkbits = blksize_bits(bsize);
 	}
diff -Nru a/fs/partitions/msdos.c b/fs/partitions/msdos.c
--- a/fs/partitions/msdos.c	Fri May 24 18:55:33 2002
+++ b/fs/partitions/msdos.c	Fri May 24 18:55:33 2002
@@ -26,6 +26,7 @@
 #include <linux/major.h>
 #include <linux/string.h>
 #include <linux/blk.h>
+#include <linux/buffer_head.h>		/* for invalidate_bdev() */
 
 #ifdef CONFIG_BLK_DEV_IDE
 #include <linux/ide.h>	/* IDE xlate */
diff -Nru a/fs/proc/Makefile b/fs/proc/Makefile
--- a/fs/proc/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/proc/Makefile	Fri May 24 18:55:33 2002
@@ -1,21 +1,16 @@
 #
 # Makefile for the Linux proc filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-O_TARGET := proc.o
 
 export-objs := root.o
 
-obj-y    := inode.o root.o base.o generic.o array.o \
+obj-$(CONFIG_PROC_FS) += proc.o
+
+proc-objs    := inode.o root.o base.o generic.o array.o \
 		kmsg.o proc_tty.o proc_misc.o kcore.o
 
 ifeq ($(CONFIG_PROC_DEVICETREE),y)
-obj-y += proc_devtree.o
+proc-objs    += proc_devtree.o
 endif
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/proc/base.c b/fs/proc/base.c
--- a/fs/proc/base.c	Fri May 24 18:55:33 2002
+++ b/fs/proc/base.c	Fri May 24 18:55:33 2002
@@ -24,6 +24,7 @@
 #include <linux/file.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
+#include <linux/namei.h>
 #include <linux/namespace.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
diff -Nru a/fs/proc/generic.c b/fs/proc/generic.c
--- a/fs/proc/generic.c	Fri May 24 18:55:36 2002
+++ b/fs/proc/generic.c	Fri May 24 18:55:36 2002
@@ -27,8 +27,6 @@
 
 int proc_match(int len, const char *name,struct proc_dir_entry * de)
 {
-	if (!de || !de->low_ino)
-		return 0;
 	if (de->namelen != len)
 		return 0;
 	return !memcmp(name, de->name, len);
@@ -266,8 +264,6 @@
 	de = PDE(dir);
 	if (de) {
 		for (de = de->subdir; de ; de = de->next) {
-			if (!de || !de->low_ino)
-				continue;
 			if (de->namelen != dentry->d_name.len)
 				continue;
 			if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
--- a/fs/proc/proc_misc.c	Fri May 24 18:55:33 2002
+++ b/fs/proc/proc_misc.c	Fri May 24 18:55:33 2002
@@ -130,7 +130,6 @@
 {
 	struct sysinfo i;
 	int len;
-	int pg_size ;
 	struct page_state ps;
 
 	get_page_state(&ps);
@@ -140,7 +139,6 @@
 #define K(x) ((x) << (PAGE_SHIFT - 10))
 	si_meminfo(&i);
 	si_swapinfo(&i);
-	pg_size = get_page_cache_size() - i.bufferram ;
 
 	/*
 	 * Tagged format, for easy grepping and expansion.
@@ -149,7 +147,6 @@
 		"MemTotal:     %8lu kB\n"
 		"MemFree:      %8lu kB\n"
 		"MemShared:    %8lu kB\n"
-		"Buffers:      %8lu kB\n"
 		"Cached:       %8lu kB\n"
 		"SwapCached:   %8lu kB\n"
 		"Active:       %8u kB\n"
@@ -165,8 +162,7 @@
 		K(i.totalram),
 		K(i.freeram),
 		K(i.sharedram),
-		K(i.bufferram),
-		K(pg_size - swapper_space.nrpages),
+		K(ps.nr_pagecache-swapper_space.nrpages),
 		K(swapper_space.nrpages),
 		K(nr_active_pages),
 		K(nr_inactive_pages),
@@ -361,25 +357,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
-static void *single_start(struct seq_file *p, loff_t *pos)
-{
-	return NULL + (*pos == 0);
-}
-static void *single_next(struct seq_file *p, void *v, loff_t *pos)
-{
-	++*pos;
-	return NULL;
-}
-static void single_stop(struct seq_file *p, void *v)
-{
-}
 extern int show_interrupts(struct seq_file *p, void *v);
-static struct seq_operations proc_interrupts_op = {
-	start:	single_start,
-	next:	single_next,
-	stop:	single_stop,
-	show:	show_interrupts,
-};
 static int interrupts_open(struct inode *inode, struct file *file)
 {
 	unsigned size = PAGE_SIZE;
@@ -393,7 +371,7 @@
 
 	if (!buf)
 		return -ENOMEM;
-	res = seq_open(file, &proc_interrupts_op);
+	res = single_open(file, show_interrupts, NULL);
 	if (!res) {
 		m = file->private_data;
 		m->buf = buf;
@@ -406,7 +384,7 @@
 	open:		interrupts_open,
 	read:		seq_read,
 	llseek:		seq_lseek,
-	release:	seq_release,
+	release:	single_release,
 };
 
 static int filesystems_read_proc(char *page, char **start, off_t off,
diff -Nru a/fs/qnx4/Makefile b/fs/qnx4/Makefile
--- a/fs/qnx4/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/qnx4/Makefile	Fri May 24 18:55:35 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the linux qnx4-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := qnx4.o
+obj-$(CONFIG_QNX4FS_FS) += qnx4.o
 
-obj-y   := inode.o dir.o namei.o file.o bitmap.o truncate.o fsync.o
-obj-m   := $(O_TARGET)
+qnx4-objs := inode.o dir.o namei.o file.o bitmap.o truncate.o fsync.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
--- a/fs/qnx4/bitmap.c	Fri May 24 18:55:36 2002
+++ b/fs/qnx4/bitmap.c	Fri May 24 18:55:36 2002
@@ -20,6 +20,7 @@
 #include <linux/stat.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 
 #include <asm/bitops.h>
 
diff -Nru a/fs/qnx4/dir.c b/fs/qnx4/dir.c
--- a/fs/qnx4/dir.c	Fri May 24 18:55:36 2002
+++ b/fs/qnx4/dir.c	Fri May 24 18:55:36 2002
@@ -18,6 +18,7 @@
 #include <linux/qnx4_fs.h>
 #include <linux/stat.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 
 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
diff -Nru a/fs/qnx4/fsync.c b/fs/qnx4/fsync.c
--- a/fs/qnx4/fsync.c	Fri May 24 18:55:34 2002
+++ b/fs/qnx4/fsync.c	Fri May 24 18:55:34 2002
@@ -16,6 +16,7 @@
 #include <linux/stat.h>
 #include <linux/fcntl.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include <linux/fs.h>
 #include <linux/qnx4_fs.h>
diff -Nru a/fs/qnx4/inode.c b/fs/qnx4/inode.c
--- a/fs/qnx4/inode.c	Fri May 24 18:55:34 2002
+++ b/fs/qnx4/inode.c	Fri May 24 18:55:34 2002
@@ -24,6 +24,7 @@
 #include <linux/highuid.h>
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
@@ -589,8 +590,6 @@
 	unregister_filesystem(&qnx4_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_qnx4_fs)
 module_exit(exit_qnx4_fs)
diff -Nru a/fs/qnx4/namei.c b/fs/qnx4/namei.c
--- a/fs/qnx4/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/qnx4/namei.c	Fri May 24 18:55:36 2002
@@ -22,6 +22,7 @@
 #include <linux/fcntl.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 
 /*
diff -Nru a/fs/quota.c b/fs/quota.c
--- a/fs/quota.c	Fri May 24 18:55:36 2002
+++ b/fs/quota.c	Fri May 24 18:55:36 2002
@@ -11,13 +11,12 @@
 #include <asm/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/smp_lock.h>
+#include <linux/namei.h>
 #ifdef CONFIG_QIFACE_COMPAT
 #include <linux/quotacompat.h>
 #endif
 
 
-int nr_dquots, nr_free_dquots;
-
 /* Check validity of quotactl */
 static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
 {
@@ -411,7 +410,7 @@
 
 static void v1_get_stats(struct v1c_dqstats *dst)
 {
-	memcpy(dst, &dqstats, sizeof(dqstats));
+	memcpy(dst, &dqstats_array, sizeof(dqstats_array));
 }
 #endif
 
@@ -490,7 +489,7 @@
 
 static void v2_get_stats(struct v2c_dqstats *dst)
 {
-	memcpy(dst, &dqstats, sizeof(dqstats));
+	memcpy(dst, &dqstats_array, sizeof(dqstats_array));
 	dst->version = __DQUOT_NUM_VERSION__;
 }
 #endif
diff -Nru a/fs/quota_v1.c b/fs/quota_v1.c
--- a/fs/quota_v1.c	Fri May 24 18:55:36 2002
+++ b/fs/quota_v1.c	Fri May 24 18:55:36 2002
@@ -57,7 +57,8 @@
 	if (dquot->dq_dqb.dqb_bhardlimit == 0 && dquot->dq_dqb.dqb_bsoftlimit == 0 &&
 	    dquot->dq_dqb.dqb_ihardlimit == 0 && dquot->dq_dqb.dqb_isoftlimit == 0)
 		dquot->dq_flags |= DQ_FAKE;
-	dqstats.reads++;
+	++dqstats_array[DQSTATS_READS];
+
 	return 0;
 }
 
@@ -100,7 +101,8 @@
 
 out:
 	set_fs(fs);
-	dqstats.writes++;
+	++dqstats_array[DQSTATS_WRITES];
+
 	return ret;
 }
 
@@ -231,8 +233,6 @@
 {
         unregister_quota_format(&v1_quota_format);
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_v1_quota_format);
 module_exit(exit_v1_quota_format);
diff -Nru a/fs/quota_v2.c b/fs/quota_v2.c
--- a/fs/quota_v2.c	Fri May 24 18:55:34 2002
+++ b/fs/quota_v2.c	Fri May 24 18:55:34 2002
@@ -430,7 +430,8 @@
 	}
 	else
 		ret = 0;
-	dqstats.writes++;
+	++dqstats_array[DQSTATS_WRITES];
+
 	return ret;
 }
 
@@ -644,7 +645,8 @@
 		set_fs(fs);
 		disk2memdqb(&dquot->dq_dqb, &ddquot);
 	}
-	dqstats.reads++;
+	++dqstats_array[DQSTATS_READS];
+
 	return ret;
 }
 
@@ -683,8 +685,6 @@
 {
 	unregister_quota_format(&v2_quota_format);
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_v2_quota_format);
 module_exit(exit_v2_quota_format);
diff -Nru a/fs/ramfs/Makefile b/fs/ramfs/Makefile
--- a/fs/ramfs/Makefile	Fri May 24 18:55:36 2002
+++ b/fs/ramfs/Makefile	Fri May 24 18:55:36 2002
@@ -2,9 +2,8 @@
 # Makefile for the linux ramfs routines.
 #
 
-O_TARGET := ramfs.o
+obj-$(CONFIG_RAMFS) += ramfs.o
 
-obj-y := inode.o
-obj-m := $(O_TARGET)
+ramfs-objs := inode.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/ramfs/inode.c b/fs/ramfs/inode.c
--- a/fs/ramfs/inode.c	Fri May 24 18:55:35 2002
+++ b/fs/ramfs/inode.c	Fri May 24 18:55:35 2002
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>		/* for block_symlink() */
 
 #include <asm/uaccess.h>
 
diff -Nru a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
--- a/fs/reiserfs/Makefile	Fri May 24 18:55:35 2002
+++ b/fs/reiserfs/Makefile	Fri May 24 18:55:35 2002
@@ -1,17 +1,13 @@
 #
 # Makefile for the linux reiser-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := reiserfs.o
-obj-y   := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o super.o prints.o objectid.o \
-lbalance.o ibalance.o stree.o hashes.o buffer2.o tail_conversion.o journal.o resize.o item_ops.o ioctl.o procfs.o
+obj-$(CONFIG_REISERFS_FS) += reiserfs.o
 
-obj-m   := $(O_TARGET)
+reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \
+		 super.o prints.o objectid.o lbalance.o ibalance.o stree.o \
+		 hashes.o buffer2.o tail_conversion.o journal.o resize.o \
+		 item_ops.o ioctl.o procfs.o
 
 # gcc -O2 (the kernel default)  is overaggressive on ppc32 when many inline
 # functions are used.  This causes the compiler to advance the stack
diff -Nru a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
--- a/fs/reiserfs/bitmap.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/bitmap.c	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/reiserfs_fs.h>
 #include <asm/bitops.h>
 #include <linux/list.h>
+#include <linux/buffer_head.h>
 
 #ifdef CONFIG_REISERFS_CHECK
 
diff -Nru a/fs/reiserfs/buffer2.c b/fs/reiserfs/buffer2.c
--- a/fs/reiserfs/buffer2.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/buffer2.c	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/reiserfs_fs.h>
 #include <linux/smp_lock.h>
 #include <linux/kernel_stat.h>
+#include <linux/buffer_head.h>
 
 /*
  *  wait_buffer_until_released
diff -Nru a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
--- a/fs/reiserfs/dir.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/dir.c	Fri May 24 18:55:36 2002
@@ -9,6 +9,7 @@
 #include <linux/reiserfs_fs.h>
 #include <linux/stat.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/uaccess.h>
 
 extern struct key  MIN_KEY;
diff -Nru a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
--- a/fs/reiserfs/do_balan.c	Fri May 24 18:55:34 2002
+++ b/fs/reiserfs/do_balan.c	Fri May 24 18:55:34 2002
@@ -20,6 +20,7 @@
 #include <asm/uaccess.h>
 #include <linux/time.h>
 #include <linux/reiserfs_fs.h>
+#include <linux/buffer_head.h>
 
 #ifdef CONFIG_REISERFS_CHECK
 
diff -Nru a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
--- a/fs/reiserfs/fix_node.c	Fri May 24 18:55:34 2002
+++ b/fs/reiserfs/fix_node.c	Fri May 24 18:55:34 2002
@@ -39,6 +39,7 @@
 #include <linux/time.h>
 #include <linux/string.h>
 #include <linux/reiserfs_fs.h>
+#include <linux/buffer_head.h>
 
 
 /* To make any changes in the tree we find a node, that contains item
@@ -2011,16 +2012,20 @@
 
 static int get_virtual_node_size (struct super_block * sb, struct buffer_head * bh)
 {
-  //  int size = sizeof (struct virtual_item); /* for new item in case of insert */
-  //  int i, nr_items;
-  //  struct item_head * ih;
-
-  // this is enough for _ALL_ currently possible cases. In 4 k block
-  // one may put < 170 empty items. Each virtual item eats 12
-  // byte. The biggest direntry item may have < 256 entries. Each
-  // entry would eat 2 byte of virtual node space
-  return sb->s_blocksize;
-
+    int max_num_of_items;
+    int max_num_of_entries;
+    unsigned long blocksize = sb->s_blocksize;
+
+#define MIN_NAME_LEN 1
+
+    max_num_of_items = (blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN);
+    max_num_of_entries = (blocksize - BLKH_SIZE - IH_SIZE) / 
+                         (DEH_SIZE + MIN_NAME_LEN);
+
+    return sizeof(struct virtual_node) + 
+           max(max_num_of_items * sizeof (struct virtual_item),
+	       sizeof (struct virtual_item) + sizeof(struct direntry_uarea) + 
+               (max_num_of_entries - 1) * sizeof (__u16));
 }
 
 
diff -Nru a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c
--- a/fs/reiserfs/ibalance.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/ibalance.c	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/reiserfs_fs.h>
+#include <linux/buffer_head.h>
 
 /* this is one and only function that is used outside (do_balance.c) */
 int	balance_internal (
diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c	Fri May 24 18:55:34 2002
+++ b/fs/reiserfs/inode.c	Fri May 24 18:55:34 2002
@@ -9,6 +9,7 @@
 #include <linux/pagemap.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
+#include <linux/buffer_head.h>
 
 /* args for the create parameter of reiserfs_get_block */
 #define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */
diff -Nru a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
--- a/fs/reiserfs/item_ops.c	Fri May 24 18:55:33 2002
+++ b/fs/reiserfs/item_ops.c	Fri May 24 18:55:33 2002
@@ -466,13 +466,6 @@
 
 #define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
 
-struct direntry_uarea {
-    int flags;
-    __u16 entry_count;
-    __u16 entry_sizes[1];
-} __attribute__ ((__packed__)) ;
-
-
 /*
  * function returns old entry number in directory item in real node
  * using new entry number in virtual item in virtual node */
diff -Nru a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c	Fri May 24 18:55:33 2002
+++ b/fs/reiserfs/journal.c	Fri May 24 18:55:33 2002
@@ -57,6 +57,8 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
+#include <linux/suspend.h> 
+#include <linux/buffer_head.h>
 
 /* the number of mounted filesystems.  This is used to decide when to
 ** start and kill the commit thread
@@ -1886,6 +1888,7 @@
   spin_unlock_irq(&current->sigmask_lock);
 
   sprintf(current->comm, "kreiserfsd") ;
+  current->flags |= PF_KERNTHREAD;
   lock_kernel() ;
   while(1) {
 
@@ -1899,6 +1902,8 @@
       break ;
     }
     wake_up(&reiserfs_commit_thread_done) ;
+    if (current->flags & PF_FREEZE)
+      refrigerator(PF_IOTHREAD);
     interruptible_sleep_on_timeout(&reiserfs_commit_thread_wait, 5 * HZ) ;
   }
   unlock_kernel() ;
diff -Nru a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c
--- a/fs/reiserfs/lbalance.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/lbalance.c	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/reiserfs_fs.h>
+#include <linux/buffer_head.h>
 
 /* these are used in do_balance.c */
 
diff -Nru a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
--- a/fs/reiserfs/prints.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/prints.c	Fri May 24 18:55:36 2002
@@ -7,6 +7,7 @@
 #include <linux/fs.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 
 #include <stdarg.h>
 
diff -Nru a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
--- a/fs/reiserfs/resize.c	Fri May 24 18:55:35 2002
+++ b/fs/reiserfs/resize.c	Fri May 24 18:55:35 2002
@@ -14,6 +14,7 @@
 #include <linux/errno.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/reiserfs_fs_sb.h>
+#include <linux/buffer_head.h>
 
 int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
 {
diff -Nru a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
--- a/fs/reiserfs/stree.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/stree.c	Fri May 24 18:55:36 2002
@@ -59,6 +59,7 @@
 #include <linux/pagemap.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 /* Does the buffer contain a disk block which is in the tree. */
 inline int B_IS_IN_TREE (const struct buffer_head * p_s_bh)
diff -Nru a/fs/reiserfs/super.c b/fs/reiserfs/super.c
--- a/fs/reiserfs/super.c	Fri May 24 18:55:35 2002
+++ b/fs/reiserfs/super.c	Fri May 24 18:55:35 2002
@@ -19,6 +19,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
+#include <linux/buffer_head.h>
 
 #define REISERFS_OLD_BLOCKSIZE 4096
 #define REISERFS_SUPER_MAGIC_STRING_OFFSET_NJ 20
@@ -1247,7 +1248,6 @@
 MODULE_DESCRIPTION("ReiserFS journaled filesystem");
 MODULE_AUTHOR("Hans Reiser <reiser@namesys.com>");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
 
 //
 // this is exactly what 2.3.99-pre9's init_ext2_fs is
diff -Nru a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
--- a/fs/reiserfs/tail_conversion.c	Fri May 24 18:55:36 2002
+++ b/fs/reiserfs/tail_conversion.c	Fri May 24 18:55:36 2002
@@ -5,6 +5,7 @@
 #include <linux/config.h>
 #include <linux/time.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 #include <linux/reiserfs_fs.h>
 
 /* access to tail : when one is going to read tail it must make sure, that is not running.
diff -Nru a/fs/romfs/Makefile b/fs/romfs/Makefile
--- a/fs/romfs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/romfs/Makefile	Fri May 24 18:55:34 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the linux romfs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := romfs.o
+obj-$(CONFIG_ROMFS_FS) += romfs.o
 
-obj-y  := inode.o
-obj-m  := $(O_TARGET)
+romfs-objs := inode.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/romfs/inode.c b/fs/romfs/inode.c
--- a/fs/romfs/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/romfs/inode.c	Fri May 24 18:55:36 2002
@@ -73,6 +73,7 @@
 #include <linux/init.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 
@@ -626,8 +627,6 @@
 }
 
 /* Yes, works even as a module... :) */
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_romfs_fs)
 module_exit(exit_romfs_fs)
diff -Nru a/fs/seq_file.c b/fs/seq_file.c
--- a/fs/seq_file.c	Fri May 24 18:55:36 2002
+++ b/fs/seq_file.c	Fri May 24 18:55:36 2002
@@ -293,3 +293,45 @@
 	m->count = m->size;
 	return -1;
 }
+
+static void *single_start(struct seq_file *p, loff_t *pos)
+{
+	return NULL + (*pos == 0);
+}
+
+static void *single_next(struct seq_file *p, void *v, loff_t *pos)
+{
+	++*pos;
+	return NULL;
+}
+
+static void single_stop(struct seq_file *p, void *v)
+{
+}
+
+int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
+{
+	struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
+	int res = -ENOMEM;
+
+	if (op) {
+		op->start = single_start;
+		op->next = single_next;
+		op->stop = single_stop;
+		op->show = show;
+		res = seq_open(file, op);
+		if (!res)
+			((struct seq_file *)file->private_data)->private = data;
+		else
+			kfree(op);
+	}
+	return res;
+}
+
+int single_release(struct inode *inode, struct file *file)
+{
+	struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
+	int res = seq_release(inode, file);
+	kfree(op);
+	return res;
+}
diff -Nru a/fs/smbfs/Makefile b/fs/smbfs/Makefile
--- a/fs/smbfs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/smbfs/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the linux smb-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
 
-O_TARGET := smbfs.o
+obj-$(CONFIG_SMB_FS) += smbfs.o
 
-obj-y   := proc.o dir.o cache.o sock.o inode.o file.o ioctl.o getopt.o
-obj-m   := $(O_TARGET)
+smbfs-objs := proc.o dir.o cache.o sock.o inode.o file.o ioctl.o getopt.o
 
 # If you want debugging output, you may add these flags to the EXTRA_CFLAGS
 # SMBFS_PARANOIA should normally be enabled.
diff -Nru a/fs/smbfs/dir.c b/fs/smbfs/dir.c
--- a/fs/smbfs/dir.c	Fri May 24 18:55:35 2002
+++ b/fs/smbfs/dir.c	Fri May 24 18:55:35 2002
@@ -47,7 +47,7 @@
 	mkdir:		smb_mkdir,
 	rmdir:		smb_rmdir,
 	rename:		smb_rename,
-	revalidate:	smb_revalidate_inode,
+	getattr:	smb_getattr,
 	setattr:	smb_notify_change,
 };
 
diff -Nru a/fs/smbfs/file.c b/fs/smbfs/file.c
--- a/fs/smbfs/file.c	Fri May 24 18:55:36 2002
+++ b/fs/smbfs/file.c	Fri May 24 18:55:36 2002
@@ -398,6 +398,6 @@
 struct inode_operations smb_file_inode_operations =
 {
 	permission:	smb_file_permission,
-	revalidate:	smb_revalidate_inode,
+	getattr:	smb_getattr,
 	setattr:	smb_notify_change,
 };
diff -Nru a/fs/smbfs/inode.c b/fs/smbfs/inode.c
--- a/fs/smbfs/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/smbfs/inode.c	Fri May 24 18:55:33 2002
@@ -611,6 +611,14 @@
 	return result;
 }
 
+int smb_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+	int err = smb_revalidate_inode(dentry);
+	if (!err)
+		generic_fillattr(dentry->d_inode, stat);
+	return err;
+}
+
 int
 smb_notify_change(struct dentry *dentry, struct iattr *attr)
 {
@@ -774,8 +782,6 @@
 	printk(KERN_DEBUG "smb_current_vmalloced: %d\n",smb_current_vmalloced);
 #endif
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_smb_fs)
 module_exit(exit_smb_fs)
diff -Nru a/fs/smbfs/proto.h b/fs/smbfs/proto.h
--- a/fs/smbfs/proto.h	Fri May 24 18:55:33 2002
+++ b/fs/smbfs/proto.h	Fri May 24 18:55:33 2002
@@ -49,6 +49,7 @@
 extern void smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr);
 extern void smb_invalidate_inodes(struct smb_sb_info *server);
 extern int smb_revalidate_inode(struct dentry *dentry);
+extern int smb_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
 extern int smb_notify_change(struct dentry *dentry, struct iattr *attr);
 /* file.c */
 extern struct address_space_operations smb_file_aops;
diff -Nru a/fs/stat.c b/fs/stat.c
--- a/fs/stat.c	Fri May 24 18:55:34 2002
+++ b/fs/stat.c	Fri May 24 18:55:34 2002
@@ -11,31 +11,12 @@
 #include <linux/smp_lock.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
+#include <linux/namei.h>
 
 #include <asm/uaccess.h>
 
-/*
- * Revalidate the inode. This is required for proper NFS attribute caching.
- */
-static __inline__ int
-do_revalidate(struct dentry *dentry)
-{
-	struct inode * inode = dentry->d_inode;
-	if (inode->i_op && inode->i_op->revalidate)
-		return inode->i_op->revalidate(dentry);
-	return 0;
-}
-
-static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+void generic_fillattr(struct inode *inode, struct kstat *stat)
 {
-	int res = 0;
-	unsigned int blocks, indirect;
-	struct inode *inode = dentry->d_inode;
-
-	res = do_revalidate(dentry);
-	if (res)
-		return res;
-
 	stat->dev = kdev_t_to_nr(inode->i_dev);
 	stat->ino = inode->i_ino;
 	stat->mode = inode->i_mode;
@@ -48,41 +29,24 @@
 	stat->ctime = inode->i_ctime;
 	stat->ctime = inode->i_ctime;
 	stat->size = inode->i_size;
-/*
- * st_blocks and st_blksize are approximated with a simple algorithm if
- * they aren't supported directly by the filesystem. The minix and msdos
- * filesystems don't keep track of blocks, so they would either have to
- * be counted explicitly (by delving into the file itself), or by using
- * this simple algorithm to get a reasonable (although not 100% accurate)
- * value.
- */
+	stat->blocks = inode->i_blocks;
+	stat->blksize = inode->i_blksize;
+}
 
-/*
- * Use minix fs values for the number of direct and indirect blocks.  The
- * count is now exact for the minix fs except that it counts zero blocks.
- * Everything is in units of BLOCK_SIZE until the assignment to
- * tmp.st_blksize.
- */
-#define D_B   7
-#define I_B   (BLOCK_SIZE / sizeof(unsigned short))
+static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+	struct inode *inode = dentry->d_inode;
+
+	if (inode->i_op->getattr)
+		return inode->i_op->getattr(mnt, dentry, stat);
 
-	if (!inode->i_blksize) {
-		blocks = (stat->size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS;
-		if (blocks > D_B) {
-			indirect = (blocks - D_B + I_B - 1) / I_B;
-			blocks += indirect;
-			if (indirect > 1) {
-				indirect = (indirect - 1 + I_B - 1) / I_B;
-				blocks += indirect;
-				if (indirect > 1)
-					blocks++;
-			}
-		}
-		stat->blocks = (BLOCK_SIZE / 512) * blocks;
-		stat->blksize = BLOCK_SIZE;
-	} else {
-		stat->blocks = inode->i_blocks;
-		stat->blksize = inode->i_blksize;
+	generic_fillattr(inode, stat);
+	if (!stat->blksize) {
+		struct super_block *s = inode->i_sb;
+		unsigned blocks;
+		blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits;
+		stat->blocks = (s->s_blocksize / 512) * blocks;
+		stat->blksize = s->s_blocksize;
 	}
 	return 0;
 }
@@ -267,8 +231,7 @@
 		struct inode * inode = nd.dentry->d_inode;
 
 		error = -EINVAL;
-		if (inode->i_op && inode->i_op->readlink &&
-		    !(error = do_revalidate(nd.dentry))) {
+		if (inode->i_op && inode->i_op->readlink) {
 			UPDATE_ATIME(inode);
 			error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
 		}
diff -Nru a/fs/super.c b/fs/super.c
--- a/fs/super.c	Fri May 24 18:55:35 2002
+++ b/fs/super.c	Fri May 24 18:55:35 2002
@@ -27,6 +27,8 @@
 #include <linux/acct.h>
 #include <linux/blkdev.h>
 #include <linux/quotaops.h>
+#include <linux/namei.h>
+#include <linux/buffer_head.h>		/* for fsync_super() */
 #include <asm/uaccess.h>
 
 void get_filesystem(struct file_system_type *fs);
diff -Nru a/fs/sysv/Makefile b/fs/sysv/Makefile
--- a/fs/sysv/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/sysv/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the Linux SystemV/Coherent filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := sysv.o
+obj-$(CONFIG_SYSV_FS) += sysv.o
 
-obj-y   := ialloc.o balloc.o inode.o itree.o file.o dir.o \
-	   namei.o super.o symlink.o
-obj-m   := $(O_TARGET)
+sysv-objs := ialloc.o balloc.o inode.o itree.o file.o dir.o \
+	     namei.o super.o symlink.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/sysv/balloc.c b/fs/sysv/balloc.c
--- a/fs/sysv/balloc.c	Fri May 24 18:55:35 2002
+++ b/fs/sysv/balloc.c	Fri May 24 18:55:35 2002
@@ -19,6 +19,7 @@
  *  This file contains code for allocating/freeing blocks.
  */
 
+#include <linux/buffer_head.h>
 #include "sysv.h"
 
 /* We don't trust the value of
diff -Nru a/fs/sysv/file.c b/fs/sysv/file.c
--- a/fs/sysv/file.c	Fri May 24 18:55:36 2002
+++ b/fs/sysv/file.c	Fri May 24 18:55:36 2002
@@ -29,6 +29,7 @@
 
 struct inode_operations sysv_file_inode_operations = {
 	truncate:	sysv_truncate,
+	getattr:	sysv_getattr,
 };
 
 int sysv_sync_file(struct file * file, struct dentry *dentry, int datasync)
diff -Nru a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
--- a/fs/sysv/ialloc.c	Fri May 24 18:55:34 2002
+++ b/fs/sysv/ialloc.c	Fri May 24 18:55:34 2002
@@ -24,6 +24,7 @@
 #include <linux/sched.h>
 #include <linux/stat.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 #include "sysv.h"
 
 /* We don't trust the value of
diff -Nru a/fs/sysv/inode.c b/fs/sysv/inode.c
--- a/fs/sysv/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/sysv/inode.c	Fri May 24 18:55:33 2002
@@ -25,6 +25,7 @@
 #include <linux/highuid.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/buffer_head.h>
 #include <asm/byteorder.h>
 #include "sysv.h"
 
@@ -132,6 +133,7 @@
 static struct inode_operations sysv_symlink_inode_operations = {
 	readlink:	page_readlink,
 	follow_link:	page_follow_link,
+	getattr:	sysv_getattr,
 };
 
 void sysv_set_inode(struct inode *inode, dev_t rdev)
diff -Nru a/fs/sysv/itree.c b/fs/sysv/itree.c
--- a/fs/sysv/itree.c	Fri May 24 18:55:34 2002
+++ b/fs/sysv/itree.c	Fri May 24 18:55:34 2002
@@ -5,6 +5,7 @@
  *  AV, Sep--Dec 2000
  */
 
+#include <linux/buffer_head.h>
 #include "sysv.h"
 
 enum {DIRECT = 10, DEPTH = 4};	/* Have triple indirect */
@@ -420,6 +421,30 @@
 		sysv_sync_inode (inode);
 	else
 		mark_inode_dirty(inode);
+}
+
+static unsigned sysv_nblocks(struct super_block *s, loff_t size)
+{
+	struct sysv_sb_info *sbi = SYSV_SB(s);
+	int ptrs_bits = sbi->s_ind_per_block_bits;
+	unsigned blocks, res, direct = DIRECT, i = DEPTH;
+	blocks = (size + s->s_blocksize - 1) >> s->s_blocksize_bits;
+	res = blocks;
+	while (--i && blocks > direct) {
+		blocks = ((blocks - direct - 1) >> ptrs_bits) + 1;
+		res += blocks;
+		direct = 1;
+	}
+	return blocks;
+}
+
+int sysv_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+	struct super_block *s = mnt->mnt_sb;
+	generic_fillattr(dentry->d_inode, stat);
+	stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size);
+	stat->blksize = s->s_blocksize;
+	return 0;
 }
 
 static int sysv_writepage(struct page *page)
diff -Nru a/fs/sysv/namei.c b/fs/sysv/namei.c
--- a/fs/sysv/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/sysv/namei.c	Fri May 24 18:55:36 2002
@@ -317,4 +317,5 @@
 	rmdir:		sysv_rmdir,
 	mknod:		sysv_mknod,
 	rename:		sysv_rename,
+	getattr:	sysv_getattr,
 };
diff -Nru a/fs/sysv/super.c b/fs/sysv/super.c
--- a/fs/sysv/super.c	Fri May 24 18:55:33 2002
+++ b/fs/sysv/super.c	Fri May 24 18:55:33 2002
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/buffer_head.h>
 #include "sysv.h"
 
 /*
@@ -555,8 +556,6 @@
 	unregister_filesystem(&v7_fs_type);
 	sysv_destroy_icache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_sysv_fs)
 module_exit(exit_sysv_fs)
diff -Nru a/fs/sysv/sysv.h b/fs/sysv/sysv.h
--- a/fs/sysv/sysv.h	Fri May 24 18:55:33 2002
+++ b/fs/sysv/sysv.h	Fri May 24 18:55:33 2002
@@ -1,7 +1,7 @@
 #ifndef _SYSV_H
 #define _SYSV_H
 
-#include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/sysv_fs.h>
 
 /*
@@ -137,6 +137,7 @@
 extern int sysv_sync_inode(struct inode *);
 extern int sysv_sync_file(struct file *, struct dentry *, int);
 extern void sysv_set_inode(struct inode *, dev_t);
+extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
 
 /* dir.c */
 extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
diff -Nru a/fs/udf/Makefile b/fs/udf/Makefile
--- a/fs/udf/Makefile	Fri May 24 18:55:33 2002
+++ b/fs/udf/Makefile	Fri May 24 18:55:33 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the linux udf-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .o file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile..
 
-O_TARGET := udf.o
+obj-$(CONFIG_UDF_FS) += udf.o
 
-obj-y    := balloc.o dir.o file.o ialloc.o inode.o lowlevel.o namei.o \
+udf-objs     := balloc.o dir.o file.o ialloc.o inode.o lowlevel.o namei.o \
 		partition.o super.o truncate.o symlink.o fsync.o \
 		crc.o directory.o misc.o udftime.o unicode.o
-obj-m    := $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/udf/balloc.c b/fs/udf/balloc.c
--- a/fs/udf/balloc.c	Fri May 24 18:55:34 2002
+++ b/fs/udf/balloc.c	Fri May 24 18:55:34 2002
@@ -27,6 +27,7 @@
 #include "udfdecl.h"
 
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
 #include <asm/bitops.h>
 
 #include "udf_i.h"
diff -Nru a/fs/udf/dir.c b/fs/udf/dir.c
--- a/fs/udf/dir.c	Fri May 24 18:55:34 2002
+++ b/fs/udf/dir.c	Fri May 24 18:55:34 2002
@@ -36,6 +36,7 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/directory.c b/fs/udf/directory.c
--- a/fs/udf/directory.c	Fri May 24 18:55:36 2002
+++ b/fs/udf/directory.c	Fri May 24 18:55:36 2002
@@ -20,6 +20,7 @@
 
 #include <linux/fs.h>
 #include <linux/string.h>
+#include <linux/buffer_head.h>
 
 uint8_t * udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
 	lb_addr fe_loc, int *pos, int *offset, struct buffer_head **bh, int *error)
diff -Nru a/fs/udf/file.c b/fs/udf/file.c
--- a/fs/udf/file.c	Fri May 24 18:55:33 2002
+++ b/fs/udf/file.c	Fri May 24 18:55:33 2002
@@ -39,6 +39,7 @@
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/ialloc.c b/fs/udf/ialloc.c
--- a/fs/udf/ialloc.c	Fri May 24 18:55:35 2002
+++ b/fs/udf/ialloc.c	Fri May 24 18:55:35 2002
@@ -27,6 +27,7 @@
 #include <linux/fs.h>
 #include <linux/quotaops.h>
 #include <linux/udf_fs.h>
+#include <linux/sched.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/inode.c b/fs/udf/inode.c
--- a/fs/udf/inode.c	Fri May 24 18:55:36 2002
+++ b/fs/udf/inode.c	Fri May 24 18:55:36 2002
@@ -38,6 +38,7 @@
 #include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
+#include <linux/buffer_head.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/misc.c b/fs/udf/misc.c
--- a/fs/udf/misc.c	Fri May 24 18:55:33 2002
+++ b/fs/udf/misc.c	Fri May 24 18:55:33 2002
@@ -29,6 +29,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/udf_fs.h>
+#include <linux/buffer_head.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/namei.c b/fs/udf/namei.c
--- a/fs/udf/namei.c	Fri May 24 18:55:34 2002
+++ b/fs/udf/namei.c	Fri May 24 18:55:34 2002
@@ -34,6 +34,7 @@
 #include <linux/slab.h>
 #include <linux/quotaops.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 static inline int udf_match(int len, const char * const name, struct qstr *qs)
 {
diff -Nru a/fs/udf/partition.c b/fs/udf/partition.c
--- a/fs/udf/partition.c	Fri May 24 18:55:33 2002
+++ b/fs/udf/partition.c	Fri May 24 18:55:33 2002
@@ -31,6 +31,7 @@
 #include <linux/string.h>
 #include <linux/udf_fs.h>
 #include <linux/slab.h>
+#include <linux/buffer_head.h>
 
 inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset)
 {
diff -Nru a/fs/udf/super.c b/fs/udf/super.c
--- a/fs/udf/super.c	Fri May 24 18:55:36 2002
+++ b/fs/udf/super.c	Fri May 24 18:55:36 2002
@@ -55,6 +55,7 @@
 #include <linux/cdrom.h>
 #include <linux/nls.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include <asm/byteorder.h>
 
 #include <linux/udf_fs.h>
@@ -207,8 +208,6 @@
 	unregister_filesystem(&udf_fstype);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_udf_fs)
 module_exit(exit_udf_fs)
diff -Nru a/fs/udf/symlink.c b/fs/udf/symlink.c
--- a/fs/udf/symlink.c	Fri May 24 18:55:34 2002
+++ b/fs/udf/symlink.c	Fri May 24 18:55:34 2002
@@ -35,6 +35,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 #include "udf_i.h"
 
 static void udf_pc_to_char(char *from, int fromlen, char *to)
diff -Nru a/fs/udf/truncate.c b/fs/udf/truncate.c
--- a/fs/udf/truncate.c	Fri May 24 18:55:35 2002
+++ b/fs/udf/truncate.c	Fri May 24 18:55:35 2002
@@ -28,6 +28,7 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/udf_fs.h>
+#include <linux/buffer_head.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
--- a/fs/udf/udfdecl.h	Fri May 24 18:55:35 2002
+++ b/fs/udf/udfdecl.h	Fri May 24 18:55:35 2002
@@ -10,6 +10,7 @@
 #include <linux/types.h>
 #include <linux/udf_fs_i.h>
 #include <linux/udf_fs_sb.h>
+#include <linux/buffer_head.h>
 
 #ifndef LINUX_VERSION_CODE
 #include <linux/version.h>
diff -Nru a/fs/ufs/Makefile b/fs/ufs/Makefile
--- a/fs/ufs/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/ufs/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the Linux ufs filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
 
-O_TARGET := ufs.o
+obj-$(CONFIG_UFS_FS) += ufs.o
 
-obj-y   := balloc.o cylinder.o dir.o file.o ialloc.o inode.o \
-		namei.o super.o symlink.o truncate.o util.o
-obj-m   := $(O_TARGET)
+ufs-objs := balloc.o cylinder.o dir.o file.o ialloc.o inode.o \
+	    namei.o super.o symlink.o truncate.o util.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/ufs/balloc.c b/fs/ufs/balloc.c
--- a/fs/ufs/balloc.c	Fri May 24 18:55:33 2002
+++ b/fs/ufs/balloc.c	Fri May 24 18:55:33 2002
@@ -12,6 +12,8 @@
 #include <linux/time.h>
 #include <linux/string.h>
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
+#include <linux/sched.h>
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
 
diff -Nru a/fs/ufs/dir.c b/fs/ufs/dir.c
--- a/fs/ufs/dir.c	Fri May 24 18:55:34 2002
+++ b/fs/ufs/dir.c	Fri May 24 18:55:34 2002
@@ -17,6 +17,8 @@
 #include <linux/fs.h>
 #include <linux/ufs_fs.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
+#include <linux/sched.h>
 
 #include "swab.h"
 #include "util.h"
diff -Nru a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
--- a/fs/ufs/ialloc.c	Fri May 24 18:55:35 2002
+++ b/fs/ufs/ialloc.c	Fri May 24 18:55:35 2002
@@ -26,6 +26,8 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/quotaops.h>
+#include <linux/buffer_head.h>
+#include <linux/sched.h>
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
 
diff -Nru a/fs/ufs/inode.c b/fs/ufs/inode.c
--- a/fs/ufs/inode.c	Fri May 24 18:55:34 2002
+++ b/fs/ufs/inode.c	Fri May 24 18:55:34 2002
@@ -36,6 +36,7 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include "swab.h"
 #include "util.h"
diff -Nru a/fs/ufs/namei.c b/fs/ufs/namei.c
--- a/fs/ufs/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/ufs/namei.c	Fri May 24 18:55:36 2002
@@ -28,6 +28,7 @@
 #include <linux/fs.h>
 #include <linux/ufs_fs.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #undef UFS_NAMEI_DEBUG
 
diff -Nru a/fs/ufs/super.c b/fs/ufs/super.c
--- a/fs/ufs/super.c	Fri May 24 18:55:33 2002
+++ b/fs/ufs/super.c	Fri May 24 18:55:33 2002
@@ -80,6 +80,7 @@
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #include "swab.h"
 #include "util.h"
@@ -1062,8 +1063,6 @@
 	unregister_filesystem(&ufs_fs_type);
 	destroy_inodecache();
 }
-
-EXPORT_NO_SYMBOLS;
 
 module_init(init_ufs_fs)
 module_exit(exit_ufs_fs)
diff -Nru a/fs/ufs/truncate.c b/fs/ufs/truncate.c
--- a/fs/ufs/truncate.c	Fri May 24 18:55:35 2002
+++ b/fs/ufs/truncate.c	Fri May 24 18:55:35 2002
@@ -37,6 +37,8 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
+#include <linux/sched.h>
 
 #include "swab.h"
 #include "util.h"
diff -Nru a/fs/ufs/util.c b/fs/ufs/util.c
--- a/fs/ufs/util.c	Fri May 24 18:55:35 2002
+++ b/fs/ufs/util.c	Fri May 24 18:55:35 2002
@@ -9,6 +9,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/ufs_fs.h>
+#include <linux/buffer_head.h>
 
 #include "swab.h"
 #include "util.h"
diff -Nru a/fs/ufs/util.h b/fs/ufs/util.h
--- a/fs/ufs/util.h	Fri May 24 18:55:36 2002
+++ b/fs/ufs/util.h	Fri May 24 18:55:36 2002
@@ -6,6 +6,7 @@
  * Charles University, Faculty of Mathematics and Physics
  */
 
+#include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include "swab.h"
 
diff -Nru a/fs/umsdos/Makefile b/fs/umsdos/Makefile
--- a/fs/umsdos/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/umsdos/Makefile	Fri May 24 18:55:34 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for the umsdos Unix-like filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2:  the CFLAGS definitions are now in the main makefile.
-O_TARGET := umsdos.o
 
-obj-y   := dir.o  inode.o ioctl.o mangle.o namei.o rdir.o emd.o
+obj-$(CONFIG_UMSDOS) += umsdos.o
 
-obj-m   := $(O_TARGET)
+umsdos-objs := dir.o  inode.o ioctl.o mangle.o namei.o rdir.o emd.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/fs/umsdos/inode.c b/fs/umsdos/inode.c
--- a/fs/umsdos/inode.c	Fri May 24 18:55:33 2002
+++ b/fs/umsdos/inode.c	Fri May 24 18:55:33 2002
@@ -476,8 +476,6 @@
 	unregister_filesystem (&umsdos_fs_type);
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(init_umsdos_fs)
 module_exit(exit_umsdos_fs)
 MODULE_LICENSE("GPL");
diff -Nru a/fs/vfat/Makefile b/fs/vfat/Makefile
--- a/fs/vfat/Makefile	Fri May 24 18:55:34 2002
+++ b/fs/vfat/Makefile	Fri May 24 18:55:34 2002
@@ -1,17 +1,11 @@
 #
 # Makefile for the linux vfat-filesystem routines.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-O_TARGET := vfat.o
 
 export-objs := vfatfs_syms.o
 
-obj-y := namei.o vfatfs_syms.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_VFAT_FS) += vfat.o
+
+vfat-objs := namei.o vfatfs_syms.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/fs/vfat/namei.c b/fs/vfat/namei.c
--- a/fs/vfat/namei.c	Fri May 24 18:55:36 2002
+++ b/fs/vfat/namei.c	Fri May 24 18:55:36 2002
@@ -17,11 +17,12 @@
 
 #include <linux/module.h>
 
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/msdos_fs.h>
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>
 
 #define DEBUG_LEVEL 0
 #if (DEBUG_LEVEL >= 1)
diff -Nru a/fs/xattr.c b/fs/xattr.c
--- a/fs/xattr.c	Fri May 24 18:55:35 2002
+++ b/fs/xattr.c	Fri May 24 18:55:35 2002
@@ -12,6 +12,7 @@
 #include <linux/smp_lock.h>
 #include <linux/file.h>
 #include <linux/xattr.h>
+#include <linux/namei.h>
 #include <asm/uaccess.h>
 
 /*
diff -Nru a/include/asm-arm/arch-clps711x/memory.h b/include/asm-arm/arch-clps711x/memory.h
--- a/include/asm-arm/arch-clps711x/memory.h	Fri May 24 18:55:33 2002
+++ b/include/asm-arm/arch-clps711x/memory.h	Fri May 24 18:55:33 2002
@@ -153,13 +153,13 @@
 #define NODE_MAX_MEM_SHIFT	24
 #define NODE_MAX_MEM_SIZE	(1<<NODE_MAX_MEM_SHIFT)
 
-#else
-
-#define PFN_TO_NID(pfn)		(0)
-
 #endif /* CONFIG_DISCONTIGMEM */
 
 #endif	/* CONFIG_ARCH_EDB7211 */
+
+#ifndef PFN_TO_NID
+#define PFN_TO_NID(pfn)		(0)
+#endif
 
 #endif
 
diff -Nru a/include/asm-arm/dma.h b/include/asm-arm/dma.h
--- a/include/asm-arm/dma.h	Fri May 24 18:55:36 2002
+++ b/include/asm-arm/dma.h	Fri May 24 18:55:36 2002
@@ -74,6 +74,10 @@
  */
 extern void disable_dma(dmach_t channel);
 
+/* Test whether the specified channel has an active DMA transfer
+ */
+extern int dma_channel_active(dmach_t channel);
+
 /* Set the DMA scatter gather list for this channel
  *
  * This should not be called if a DMA channel is enabled,
diff -Nru a/include/asm-arm/hardware/sa1111.h b/include/asm-arm/hardware/sa1111.h
--- a/include/asm-arm/hardware/sa1111.h	Fri May 24 18:55:35 2002
+++ b/include/asm-arm/hardware/sa1111.h	Fri May 24 18:55:35 2002
@@ -198,6 +198,12 @@
 #define USB_RESET_PWRSENSELOW	(1 << 6)
 #define USB_RESET_PWRCTRLLOW	(1 << 7)
 
+#define USB_STATUS_IRQHCIRMTWKUP  (1 <<  7)
+#define USB_STATUS_IRQHCIBUFFACC  (1 <<  8)
+#define USB_STATUS_NIRQHCIM       (1 <<  9)
+#define USB_STATUS_NHCIMFCLR      (1 << 10)
+#define USB_STATUS_USBPWRSENSE    (1 << 11)
+
 /*
  * Serial Audio Controller
  *
diff -Nru a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
--- a/include/asm-arm/mach/arch.h	Fri May 24 18:55:36 2002
+++ b/include/asm-arm/mach/arch.h	Fri May 24 18:55:36 2002
@@ -19,6 +19,8 @@
 extern void setup_initrd(unsigned int start, unsigned int size);
 extern void setup_ramdisk(int doload, int prompt, int start, unsigned int rd_sz);
 
+struct tag;
+
 struct machine_desc {
 	/*
 	 * Note! The first four elements are used
@@ -41,7 +43,7 @@
 	unsigned int		reserve_lp2 :1;	/* never has lp2	*/
 	unsigned int		soft_reboot :1;	/* soft reboot		*/
 	void			(*fixup)(struct machine_desc *,
-					 struct param_struct *, char **,
+					 struct tag *, char **,
 					 struct meminfo *);
 	void			(*map_io)(void);/* IO mapping function	*/
 	void			(*init_irq)(void);
diff -Nru a/include/asm-arm/mach/pci.h b/include/asm-arm/mach/pci.h
--- a/include/asm-arm/mach/pci.h	Fri May 24 18:55:35 2002
+++ b/include/asm-arm/mach/pci.h	Fri May 24 18:55:35 2002
@@ -12,27 +12,13 @@
 struct pci_bus;
 
 struct hw_pci {
-	/* START OF OLD STUFF */
-	/* Initialise the hardware */
-	void		(*init)(void *);
-
-	/* Setup bus resources */
-	void		(*setup_resources)(struct resource **);
-
-	/* IRQ swizzle */
-	u8		(*swizzle)(struct pci_dev *dev, u8 *pin);
-
-	/* IRQ mapping */
-	int		(*map_irq)(struct pci_dev *dev, u8 slot, u8 pin);
-
-	/* END OF OLD STUFF */
-
-	/* NEW STUFF */
 	int		nr_controllers;
 	int		(*setup)(int nr, struct pci_sys_data *);
 	struct pci_bus *(*scan)(int nr, struct pci_sys_data *);
 	void		(*preinit)(void);
 	void		(*postinit)(void);
+	u8		(*swizzle)(struct pci_dev *dev, u8 *pin);
+	int		(*map_irq)(struct pci_dev *dev, u8 slot, u8 pin);
 };
 
 /*
@@ -57,6 +43,11 @@
 u8 pci_std_swizzle(struct pci_dev *dev, u8 *pinp);
 
 /*
+ * Call this with your hw_pci struct to initialise the PCI system.
+ */
+void pci_common_init(struct hw_pci *);
+
+/*
  * PCI controllers
  */
 extern int iop310_setup(int nr, struct pci_sys_data *);
@@ -70,7 +61,7 @@
 
 extern int via82c505_setup(int nr, struct pci_sys_data *);
 extern struct pci_bus *via82c505_scan_bus(int nr, struct pci_sys_data *);
-extern void __init via82c505_init(void *sysdata);
+extern void via82c505_init(void *sysdata);
 
 extern int pci_v3_setup(int nr, struct pci_sys_data *);
 extern struct pci_bus *pci_v3_scan_bus(int nr, struct pci_sys_data *);
diff -Nru a/include/asm-arm/memory.h b/include/asm-arm/memory.h
--- a/include/asm-arm/memory.h	Fri May 24 18:55:36 2002
+++ b/include/asm-arm/memory.h	Fri May 24 18:55:36 2002
@@ -69,7 +69,7 @@
 
 #define page_to_pfn(page)	(((page) - mem_map) + PHYS_PFN_OFFSET)
 #define pfn_to_page(pfn)	((mem_map + (pfn)) - PHYS_PFN_OFFSET)
-#define pfn_valid(pfn)		((pfn) >= PHYS_PFN_OFFSET && (pfn) < max_mapnr)
+#define pfn_valid(pfn)		((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
 
 #define virt_to_page(kaddr)	(pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
 #define virt_addr_valid(kaddr)	((kaddr) >= PAGE_OFFSET && (kaddr) < (unsigned long)high_memory)
diff -Nru a/include/asm-arm/proc-armv/system.h b/include/asm-arm/proc-armv/system.h
--- a/include/asm-arm/proc-armv/system.h	Fri May 24 18:55:33 2002
+++ b/include/asm-arm/proc-armv/system.h	Fri May 24 18:55:33 2002
@@ -36,7 +36,7 @@
 extern unsigned long cr_no_alignment;	/* defined in entry-armv.S */
 extern unsigned long cr_alignment;	/* defined in entry-armv.S */
 
-#ifdef __ARM_ARCH_4__
+#if __LINUX_ARM_ARCH__ >= 4
 #define vectors_base()	((cr_alignment & CR_V) ? 0xffff0000 : 0)
 #else
 #define vectors_base()	(0)
@@ -192,7 +192,7 @@
 					: "memory");
 			break;
 #endif
-		default: __bad_xchg(ptr, size);
+		default: __bad_xchg(ptr, size), ret = 0;
 	}
 
 	return ret;
diff -Nru a/include/asm-arm/ptrace.h b/include/asm-arm/ptrace.h
--- a/include/asm-arm/ptrace.h	Fri May 24 18:55:33 2002
+++ b/include/asm-arm/ptrace.h	Fri May 24 18:55:33 2002
@@ -1,6 +1,16 @@
 #ifndef __ASM_ARM_PTRACE_H
 #define __ASM_ARM_PTRACE_H
 
+#define PTRACE_GETREGS		12
+#define PTRACE_SETREGS		13
+#define PTRACE_GETFPREGS	14
+#define PTRACE_SETFPREGS	15
+
+#define PTRACE_SETOPTIONS	21
+
+/* options set using PTRACE_SETOPTIONS */
+#define PTRACE_O_TRACESYSGOOD	0x00000001
+
 #include <asm/proc/ptrace.h>
 
 #ifndef __ASSEMBLY__
@@ -11,11 +21,6 @@
 	(pc_pointer((regs)->ARM_pc))
 
 #ifdef __KERNEL__
-#define PTRACE_GETREGS		12
-#define PTRACE_SETREGS		13
-#define PTRACE_GETFPREGS	14
-#define PTRACE_SETFPREGS	15
-
 extern void show_regs(struct pt_regs *);
 
 #define predicate(x)	(x & 0xf0000000)
diff -Nru a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
--- a/include/asm-arm/thread_info.h	Fri May 24 18:55:35 2002
+++ b/include/asm-arm/thread_info.h	Fri May 24 18:55:35 2002
@@ -28,7 +28,7 @@
  * low level task data that entry.S needs immediate access to.
  */
 struct thread_info {
-	__u32			flags;		/* low level flags */
+	unsigned long		flags;		/* low level flags */
 	__s32			preempt_count;	/* 0 => preemptable, <0 => bug */
 	mm_segment_t		addr_limit;	/* address limit */
 	__u32			cpu;		/* cpu */
diff -Nru a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
--- a/include/asm-arm/unistd.h	Fri May 24 18:55:35 2002
+++ b/include/asm-arm/unistd.h	Fri May 24 18:55:35 2002
@@ -13,6 +13,8 @@
 #ifndef __ASM_ARM_UNISTD_H
 #define __ASM_ARM_UNISTD_H
 
+#include <linux/linkage.h>
+
 #define __NR_SYSCALL_BASE	0x900000
 
 /*
diff -Nru a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h
--- a/include/asm-generic/bitops.h	Fri May 24 18:55:36 2002
+++ b/include/asm-generic/bitops.h	Fri May 24 18:55:36 2002
@@ -51,6 +51,12 @@
 	return ((mask & *addr) != 0);
 }
 
+/*
+ * fls: find last bit set.
+ */
+
+#define fls(x) generic_fls(x)
+
 #ifdef __KERNEL__
 
 /*
diff -Nru a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
--- a/include/asm-generic/tlb.h	Fri May 24 18:55:33 2002
+++ b/include/asm-generic/tlb.h	Fri May 24 18:55:33 2002
@@ -86,6 +86,9 @@
 		freed = rss;
 	mm->rss = rss - freed;
 	tlb_flush_mmu(tlb, start, end);
+
+	/* keep the page table cache within bounds */
+	check_pgt_cache();
 }
 
 
diff -Nru a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
--- a/include/asm-i386/bitops.h	Fri May 24 18:55:36 2002
+++ b/include/asm-i386/bitops.h	Fri May 24 18:55:36 2002
@@ -414,6 +414,12 @@
 	return word;
 }
 
+/*
+ * fls: find last bit set.
+ */
+
+#define fls(x) generic_fls(x)
+
 #ifdef __KERNEL__
 
 /*
diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
--- a/include/asm-i386/bugs.h	Fri May 24 18:55:34 2002
+++ b/include/asm-i386/bugs.h	Fri May 24 18:55:34 2002
@@ -186,7 +186,7 @@
  */
 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
 	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL
-	    && test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability)
+	    && cpu_has_apic
 	    && boot_cpu_data.x86 == 5
 	    && boot_cpu_data.x86_model == 2
 	    && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
diff -Nru a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
--- a/include/asm-i386/cpufeature.h	Fri May 24 18:55:34 2002
+++ b/include/asm-i386/cpufeature.h	Fri May 24 18:55:34 2002
@@ -7,9 +7,6 @@
 #ifndef __ASM_I386_CPUFEATURE_H
 #define __ASM_I386_CPUFEATURE_H
 
-/* Sample usage: CPU_FEATURE_P(cpu.x86_capability, FPU) */
-#define CPU_FEATURE_P(CAP, FEATURE) test_bit(CAP, X86_FEATURE_##FEATURE ##_BIT)
-
 #define NCAPINTS	4	/* Currently we have 4 32-bit words worth of info */
 
 /* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
@@ -64,6 +61,28 @@
 #define X86_FEATURE_K6_MTRR	(3*32+ 1) /* AMD K6 nonstandard MTRRs */
 #define X86_FEATURE_CYRIX_ARR	(3*32+ 2) /* Cyrix ARRs (= MTRRs) */
 #define X86_FEATURE_CENTAUR_MCR	(3*32+ 3) /* Centaur MCRs (= MTRRs) */
+
+
+#define cpu_has(c, bit)		test_bit(bit, (c)->x86_capability)
+#define boot_cpu_has(bit)	test_bit(bit, boot_cpu_data.x86_capability)
+
+#define cpu_has_fpu		boot_cpu_has(X86_FEATURE_FPU)
+#define cpu_has_vme		boot_cpu_has(X86_FEATURE_VME)
+#define cpu_has_de		boot_cpu_has(X86_FEATURE_DE)
+#define cpu_has_pse		boot_cpu_has(X86_FEATURE_PSE)
+#define cpu_has_tsc		boot_cpu_has(X86_FEATURE_TSC)
+#define cpu_has_pae		boot_cpu_has(X86_FEATURE_PAE)
+#define cpu_has_pge		boot_cpu_has(X86_FEATURE_PGE)
+#define cpu_has_apic		boot_cpu_has(X86_FEATURE_APIC)
+#define cpu_has_mtrr		boot_cpu_has(X86_FEATURE_MTRR)
+#define cpu_has_mmx		boot_cpu_has(X86_FEATURE_MMX)
+#define cpu_has_fxsr		boot_cpu_has(X86_FEATURE_FXSR)
+#define cpu_has_xmm		boot_cpu_has(X86_FEATURE_XMM)
+#define cpu_has_ht		boot_cpu_has(X86_FEATURE_HT)
+#define cpu_has_mp		boot_cpu_has(X86_FEATURE_MP)
+#define cpu_has_k6_mtrr		boot_cpu_has(X86_FEATURE_K6_MTRR)
+#define cpu_has_cyrix_arr	boot_cpu_has(X86_FEATURE_CYRIX_ARR)
+#define cpu_has_centaur_mcr	boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
 
 #endif /* __ASM_I386_CPUFEATURE_H */
 
diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
--- a/include/asm-i386/processor.h	Fri May 24 18:55:33 2002
+++ b/include/asm-i386/processor.h	Fri May 24 18:55:33 2002
@@ -77,18 +77,6 @@
 #define current_cpu_data boot_cpu_data
 #endif
 
-#define cpu_has_pge	(test_bit(X86_FEATURE_PGE,  boot_cpu_data.x86_capability))
-#define cpu_has_pse	(test_bit(X86_FEATURE_PSE,  boot_cpu_data.x86_capability))
-#define cpu_has_pae	(test_bit(X86_FEATURE_PAE,  boot_cpu_data.x86_capability))
-#define cpu_has_tsc	(test_bit(X86_FEATURE_TSC,  boot_cpu_data.x86_capability))
-#define cpu_has_de	(test_bit(X86_FEATURE_DE,   boot_cpu_data.x86_capability))
-#define cpu_has_vme	(test_bit(X86_FEATURE_VME,  boot_cpu_data.x86_capability))
-#define cpu_has_fxsr	(test_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability))
-#define cpu_has_xmm	(test_bit(X86_FEATURE_XMM,  boot_cpu_data.x86_capability))
-#define cpu_has_fpu	(test_bit(X86_FEATURE_FPU,  boot_cpu_data.x86_capability))
-#define cpu_has_apic	(test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability))
-#define cpu_has_mp (test_bit(X86_FEATURE_MP, boot_cpu_data.x86_capability))
-
 extern char ignore_irq13;
 
 extern void identify_cpu(struct cpuinfo_x86 *);
diff -Nru a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h
--- a/include/asm-i386/rwsem.h	Fri May 24 18:55:35 2002
+++ b/include/asm-i386/rwsem.h	Fri May 24 18:55:35 2002
@@ -111,8 +111,8 @@
 		"  jmp       1b\n"
 		LOCK_SECTION_END
 		"# ending down_read\n\t"
-		: "+m"(sem->count)
-		: "a"(sem)
+		: "=m"(sem->count)
+		: "a"(sem), "m"(sem->count)
 		: "memory", "cc");
 }
 
@@ -126,8 +126,8 @@
 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
 	__asm__ __volatile__(
 		"# beginning down_write\n\t"
-LOCK_PREFIX	"  xadd      %0,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
-		"  testl     %0,%0\n\t" /* was the count 0 before? */
+LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
+		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
 		"1:\n\t"
 		LOCK_SECTION_START("")
@@ -138,8 +138,8 @@
 		"  jmp       1b\n"
 		LOCK_SECTION_END
 		"# ending down_write"
-		: "+d"(tmp), "+m"(sem->count)
-		: "a"(sem)
+		: "=m"(sem->count), "=d"(tmp)
+		: "a"(sem), "1"(tmp), "m"(sem->count)
 		: "memory", "cc");
 }
 
@@ -164,8 +164,8 @@
 		"  jmp       1b\n"
 		LOCK_SECTION_END
 		"# ending __up_read\n"
-		: /*"+m"(sem->count),*/ "+d"(tmp)
-		: "a"(sem)
+		: "=m"(sem->count), "=d"(tmp)
+		: "a"(sem), "1"(tmp), "m"(sem->count)
 		: "memory", "cc");
 }
 
@@ -190,8 +190,8 @@
 		"  jmp       1b\n"
 		LOCK_SECTION_END
 		"# ending __up_write\n"
-		: "+m"(sem->count)
-		: "a"(sem), "i"(-RWSEM_ACTIVE_WRITE_BIAS)
+		: "=m"(sem->count)
+		: "a"(sem), "i"(-RWSEM_ACTIVE_WRITE_BIAS), "m"(sem->count)
 		: "memory", "cc", "edx");
 }
 
@@ -202,8 +202,8 @@
 {
 	__asm__ __volatile__(
 LOCK_PREFIX	"addl %1,%0"
-		:"=m"(sem->count)
-		:"ir"(delta), "m"(sem->count));
+		: "=m"(sem->count)
+		: "ir"(delta), "m"(sem->count));
 }
 
 /*
diff -Nru a/include/asm-i386/suspend.h b/include/asm-i386/suspend.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-i386/suspend.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,302 @@
+#ifndef __ASM_I386_SUSPEND_H
+#define __ASM_I386_SUSPEND_H
+#endif
+
+/*
+ * Copyright 2001-2002 Pavel Machek <pavel@suse.cz>
+ * Based on code
+ * Copyright 2001 Patrick Mochel <mochel@osdl.org>
+ */
+#if defined(SUSPEND_C) || defined(ACPI_C)
+#include <asm/desc.h>
+#include <asm/i387.h>
+
+static inline void
+arch_prepare_suspend(void)
+{
+	if (!cpu_has_pse)
+		panic("pse required");
+}
+
+/* image of the saved processor state */
+struct saved_context {
+	u32 eax, ebx, ecx, edx;
+	u32 esp, ebp, esi, edi;
+	u16 es, fs, gs, ss;
+	u32 cr0, cr2, cr3, cr4;
+	u16 gdt_pad;
+	u16 gdt_limit;
+	u32 gdt_base;
+	u16 idt_pad;
+	u16 idt_limit;
+	u32 idt_base;
+	u16 ldt;
+	u16 tss;
+	u32 tr;
+	u32 safety;
+	u32 return_address;
+	u32 eflags;
+} __attribute__((packed));
+
+static struct saved_context saved_context;
+
+#define loaddebug(thread,register) \
+               __asm__("movl %0,%%db" #register  \
+                       : /* no output */ \
+                       :"r" ((thread)->debugreg[register]))
+
+ 
+/*
+ * save_processor_context
+ * 
+ * Save the state of the processor before we go to sleep.
+ *
+ * return_stack is the value of the stack pointer (%esp) as the caller sees it.
+ * A good way could not be found to obtain it from here (don't want to make _too_
+ * many assumptions about the layout of the stack this far down.) Also, the 
+ * handy little __builtin_frame_pointer(level) where level > 0, is blatantly 
+ * buggy - it returns the value of the stack at the proper location, not the 
+ * location, like it should (as of gcc 2.91.66)
+ * 
+ * Note that the context and timing of this function is pretty critical.
+ * With a minimal amount of things going on in the caller and in here, gcc
+ * does a good job of being just a dumb compiler.  Watch the assembly output
+ * if anything changes, though, and make sure everything is going in the right
+ * place. 
+ */
+static inline void save_processor_context (void)
+{
+	kernel_fpu_begin();
+
+	/*
+	 * descriptor tables
+	 */
+	asm volatile ("sgdt (%0)" : "=m" (saved_context.gdt_limit));
+	asm volatile ("sidt (%0)" : "=m" (saved_context.idt_limit));
+	asm volatile ("sldt (%0)" : "=m" (saved_context.ldt));
+	asm volatile ("str (%0)"  : "=m" (saved_context.tr));
+
+	/*
+	 * save the general registers.
+	 * note that gcc has constructs to specify output of certain registers,
+	 * but they're not used here, because it assumes that you want to modify
+	 * those registers, so it tries to be smart and save them beforehand.
+	 * It's really not necessary, and kinda fishy (check the assembly output),
+	 * so it's avoided. 
+	 */
+	asm volatile ("movl %%esp, (%0)" : "=m" (saved_context.esp));
+	asm volatile ("movl %%eax, (%0)" : "=m" (saved_context.eax));
+	asm volatile ("movl %%ebx, (%0)" : "=m" (saved_context.ebx));
+	asm volatile ("movl %%ecx, (%0)" : "=m" (saved_context.ecx));
+	asm volatile ("movl %%edx, (%0)" : "=m" (saved_context.edx));
+	asm volatile ("movl %%ebp, (%0)" : "=m" (saved_context.ebp));
+	asm volatile ("movl %%esi, (%0)" : "=m" (saved_context.esi));
+	asm volatile ("movl %%edi, (%0)" : "=m" (saved_context.edi));
+
+	/*
+	 * segment registers
+	 */
+	asm volatile ("movw %%es, %0" : "=r" (saved_context.es));
+	asm volatile ("movw %%fs, %0" : "=r" (saved_context.fs));
+	asm volatile ("movw %%gs, %0" : "=r" (saved_context.gs));
+	asm volatile ("movw %%ss, %0" : "=r" (saved_context.ss));
+
+	/*
+	 * control registers 
+	 */
+	asm volatile ("movl %%cr0, %0" : "=r" (saved_context.cr0));
+	asm volatile ("movl %%cr2, %0" : "=r" (saved_context.cr2));
+	asm volatile ("movl %%cr3, %0" : "=r" (saved_context.cr3));
+	asm volatile ("movl %%cr4, %0" : "=r" (saved_context.cr4));
+
+	/*
+	 * eflags
+	 */
+	asm volatile ("pushfl ; popl (%0)" : "=m" (saved_context.eflags));
+}
+
+static void fix_processor_context(void)
+{
+	int nr = smp_processor_id();
+	struct tss_struct * t = &init_tss[nr];
+
+	set_tss_desc(nr,t);	/* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy tsc or some similar stupidity. */
+        gdt_table[__TSS(nr)].b &= 0xfffffdff;
+
+	load_TR(nr);		/* This does ltr */
+
+	load_LDT(&current->mm->context);	/* This does lldt */
+
+	/*
+	 * Now maybe reload the debug registers
+	 */
+	if (current->thread.debugreg[7]){
+                loaddebug(&current->thread, 0);
+                loaddebug(&current->thread, 1);
+                loaddebug(&current->thread, 2);
+                loaddebug(&current->thread, 3);
+                /* no 4 and 5 */
+                loaddebug(&current->thread, 6);
+                loaddebug(&current->thread, 7);
+	}
+
+}
+
+static void
+do_fpu_end(void)
+{
+        /* restore FPU regs if necessary */
+	/* Do it out of line so that gcc does not move cr0 load to some stupid place */
+        kernel_fpu_end();
+}
+
+/*
+ * restore_processor_context
+ * 
+ * Restore the processor context as it was before we went to sleep
+ * - descriptor tables
+ * - control registers
+ * - segment registers
+ * - flags
+ * 
+ * Note that it is critical that this function is declared inline.  
+ * It was separated out from restore_state to make that function
+ * a little clearer, but it needs to be inlined because we won't have a
+ * stack when we get here (so we can't push a return address).
+ */
+static inline void restore_processor_context (void)
+{
+	/*
+	 * first restore %ds, so we can access our data properly
+	 */
+	asm volatile (".align 4");
+	asm volatile ("movw %0, %%ds" :: "r" ((u16)__KERNEL_DS));
+
+
+	/*
+	 * control registers
+	 */
+	asm volatile ("movl %0, %%cr4" :: "r" (saved_context.cr4));
+	asm volatile ("movl %0, %%cr3" :: "r" (saved_context.cr3));
+	asm volatile ("movl %0, %%cr2" :: "r" (saved_context.cr2));
+	asm volatile ("movl %0, %%cr0" :: "r" (saved_context.cr0));
+	
+	/*
+	 * segment registers
+	 */
+	asm volatile ("movw %0, %%es" :: "r" (saved_context.es));
+	asm volatile ("movw %0, %%fs" :: "r" (saved_context.fs));
+	asm volatile ("movw %0, %%gs" :: "r" (saved_context.gs));
+	asm volatile ("movw %0, %%ss" :: "r" (saved_context.ss));
+
+	/*
+	 * the other general registers
+	 *
+	 * note that even though gcc has constructs to specify memory 
+	 * input into certain registers, it will try to be too smart
+	 * and save them at the beginning of the function.  This is esp.
+	 * bad since we don't have a stack set up when we enter, and we 
+	 * want to preserve the values on exit. So, we set them manually.
+	 */
+	asm volatile ("movl %0, %%esp" :: "m" (saved_context.esp));
+	asm volatile ("movl %0, %%ebp" :: "m" (saved_context.ebp));
+	asm volatile ("movl %0, %%eax" :: "m" (saved_context.eax));
+	asm volatile ("movl %0, %%ebx" :: "m" (saved_context.ebx));
+	asm volatile ("movl %0, %%ecx" :: "m" (saved_context.ecx));
+	asm volatile ("movl %0, %%edx" :: "m" (saved_context.edx));
+	asm volatile ("movl %0, %%esi" :: "m" (saved_context.esi));
+	asm volatile ("movl %0, %%edi" :: "m" (saved_context.edi));
+
+	/*
+	 * now restore the descriptor tables to their proper values
+	 * ltr is done i fix_processor_context().
+	 */
+	asm volatile ("lgdt (%0)" :: "m" (saved_context.gdt_limit));
+	asm volatile ("lidt (%0)" :: "m" (saved_context.idt_limit));
+	asm volatile ("lldt (%0)" :: "m" (saved_context.ldt));
+
+	fix_processor_context();
+
+	/*
+	 * the flags
+	 */
+	asm volatile ("pushl %0 ; popfl" :: "m" (saved_context.eflags));
+
+	do_fpu_end();
+}
+
+#endif
+#ifdef SUSPEND_C
+/* Local variables for do_magic */
+static int loop __nosavedata = 0;
+static int loop2 __nosavedata = 0;
+
+/*
+ * (KG): Since we affect stack here, we make this function as flat and easy
+ * as possible in order to not provoke gcc to use local variables on the stack.
+ * Note that on resume, all (expect nosave) variables will have the state from
+ * the time of writing (suspend_save_image) and the registers (including the
+ * stack pointer, but excluding the instruction pointer) will be loaded with 
+ * the values saved at save_processor_context() time.
+ */
+static void do_magic(int resume)
+{
+	/* DANGER WILL ROBINSON!
+	 *
+	 * If this function is too difficult for gcc to optimize, it will crash and burn!
+	 * see above.
+	 *
+	 * DO NOT TOUCH.
+	 */
+
+	if (!resume) {
+		do_magic_suspend_1();
+		save_processor_context();	/* We need to capture registers and memory at "same time" */
+		do_magic_suspend_2();		/* If everything goes okay, this function does not return */
+		return;
+	}
+
+	/* We want to run from swapper_pg_dir, since swapper_pg_dir is stored in constant
+	 * place in memory 
+	 */
+
+        __asm__( "movl %%ecx,%%cr3\n" ::"c"(__pa(swapper_pg_dir)));
+
+/*
+ * Final function for resuming: after copying the pages to their original
+ * position, it restores the register state.
+ *
+ * What about page tables? Writing data pages may toggle
+ * accessed/dirty bits in our page tables. That should be no problems
+ * with 4MB page tables. That's why we require have_pse.  
+ *
+ * This loops destroys stack from under itself, so it better should
+ * not use any stack space, itself. When this function is entered at
+ * resume time, we move stack to _old_ place.  This is means that this
+ * function must use no stack and no local variables in registers,
+ * until calling restore_processor_context();
+ *
+ * Critical section here: noone should touch saved memory after
+ * do_magic_resume_1; copying works, because nr_copy_pages,
+ * pagedir_nosave, loop and loop2 are nosavedata.
+ */
+	do_magic_resume_1();
+
+	for (loop=0; loop < nr_copy_pages; loop++) {
+		/* You may not call something (like copy_page) here: see above */
+		for (loop2=0; loop2 < PAGE_SIZE; loop2++) {
+			*(((char *)((pagedir_nosave+loop)->orig_address))+loop2) =
+				*(((char *)((pagedir_nosave+loop)->address))+loop2);
+			__flush_tlb();
+		}
+	}
+
+	restore_processor_context();
+
+/* Ahah, we now run with our old stack, and with registers copied from
+   suspend time */
+
+	do_magic_resume_2();
+}
+#endif 
+
diff -Nru a/include/asm-i386/xor.h b/include/asm-i386/xor.h
--- a/include/asm-i386/xor.h	Fri May 24 18:55:33 2002
+++ b/include/asm-i386/xor.h	Fri May 24 18:55:33 2002
@@ -839,8 +839,6 @@
 /* Also try the generic routines.  */
 #include <asm-generic/xor.h>
 
-#define cpu_has_mmx	(test_bit(X86_FEATURE_MMX,  boot_cpu_data.x86_capability))
-
 #undef XOR_TRY_TEMPLATES
 #define XOR_TRY_TEMPLATES				\
 	do {						\
diff -Nru a/include/asm-m68k/motorola_pgalloc.h b/include/asm-m68k/motorola_pgalloc.h
--- a/include/asm-m68k/motorola_pgalloc.h	Fri May 24 18:55:36 2002
+++ b/include/asm-m68k/motorola_pgalloc.h	Fri May 24 18:55:36 2002
@@ -1,175 +1,111 @@
 #ifndef _MOTOROLA_PGALLOC_H
 #define _MOTOROLA_PGALLOC_H
 
-#include <asm/tlbflush.h>
-
-extern struct pgtable_cache_struct {
-	unsigned long *pmd_cache;
-	unsigned long *pte_cache;
-/* This counts in units of pointer tables, of which can be eight per page. */
-	unsigned long pgtable_cache_sz;
-} quicklists;
-
-#define pgd_quicklist ((unsigned long *)0)
-#define pmd_quicklist (quicklists.pmd_cache)
-#define pte_quicklist (quicklists.pte_cache)
-/* This isn't accurate because of fragmentation of allocated pages for
-   pointer tables, but that should not be a problem. */
-#define pgtable_cache_size ((quicklists.pgtable_cache_sz+7)/8)
-
-extern pte_t *get_pte_slow(pmd_t *pmd, unsigned long offset);
-extern pmd_t *get_pmd_slow(pgd_t *pgd, unsigned long offset);
+#include <asm/tlb.h>
 
 extern pmd_t *get_pointer_table(void);
 extern int free_pointer_table(pmd_t *);
 
 
-extern inline pte_t *get_pte_fast(void)
+static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	unsigned long *ret;
-
-	ret = pte_quicklist;
-	if (ret) {
-		pte_quicklist = (unsigned long *)*ret;
-		ret[0] = 0;
-		quicklists.pgtable_cache_sz -= 8;
-	}
-	return (pte_t *)ret;
-}
-#define pte_alloc_one_fast(mm,addr)  get_pte_fast()
-
-static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
-{
- 	pte_t *pte;
+	pte_t *pte;
 
 	pte = (pte_t *) __get_free_page(GFP_KERNEL);
 	if (pte) {
-	         clear_page(pte);
-		 __flush_page_to_ram((unsigned long)pte);
-		 flush_tlb_kernel_page((unsigned long)pte);
-		 nocache_page((unsigned long)pte);
-		}
+		clear_page(pte);
+		__flush_page_to_ram((unsigned long)pte);
+		flush_tlb_kernel_page((unsigned long)pte);
+		nocache_page((unsigned long)pte);
+	}
 
 	return pte;
 }
 
-
-extern __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
-{
-        return get_pointer_table();
-}
-
-
-extern inline void free_pte_fast(pte_t *pte)
-{
-	*(unsigned long *)pte = (unsigned long)pte_quicklist;
-	pte_quicklist = (unsigned long *)pte;
-	quicklists.pgtable_cache_sz += 8;
-}
-
-extern inline void free_pte_slow(pte_t *pte)
+static inline void pte_free_kernel(pte_t *pte)
 {
 	cache_page((unsigned long)pte);
 	free_page((unsigned long) pte);
 }
 
-extern inline pmd_t *get_pmd_fast(void)
+static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	unsigned long *ret;
+	struct page *page = alloc_pages(GFP_KERNEL, 0);
+	pte_t *pte;
+
+	if(!page)
+		return NULL;
 
-	ret = pmd_quicklist;
-	if (ret) {
-		pmd_quicklist = (unsigned long *)*ret;
-		ret[0] = 0;
-		quicklists.pgtable_cache_sz--;
+	pte = kmap(page);
+	if (pte) {
+		clear_page(pte);
+		__flush_page_to_ram((unsigned long)pte);
+		flush_tlb_kernel_page((unsigned long)pte);
+		nocache_page((unsigned long)pte);
 	}
-	return (pmd_t *)ret;
-}
-#define pmd_alloc_one_fast(mm,addr) get_pmd_fast()
+	kunmap(pte);
 
-extern inline void free_pmd_fast(pmd_t *pmd)
-{
-	*(unsigned long *)pmd = (unsigned long)pmd_quicklist;
-	pmd_quicklist = (unsigned long *) pmd;
-	quicklists.pgtable_cache_sz++;
+	return page;
 }
 
-extern inline int free_pmd_slow(pmd_t *pmd)
+static inline void pte_free(struct page *page)
 {
-	return free_pointer_table(pmd);
+	cache_page((unsigned long)kmap(page));
+	kunmap(page);
+	__free_page(page);
 }
 
-/* The pgd cache is folded into the pmd cache, so these are dummy routines. */
-extern inline pgd_t *get_pgd_fast(void)
+static inline void pte_free_tlb(mmu_gather_t *tlb, struct page *page)
 {
-	return (pgd_t *)0;
+	cache_page((unsigned long)kmap(page));
+	kunmap(page);
+	__free_page(page);
 }
 
-extern inline void free_pgd_fast(pgd_t *pgd)
-{
-}
 
-extern inline void free_pgd_slow(pgd_t *pgd)
+static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
+	return get_pointer_table();
 }
 
-extern void __bad_pte(pmd_t *pmd);
-extern void __bad_pmd(pgd_t *pgd);
-
-extern inline void pte_free(pte_t *pte)
+static inline int pmd_free(pmd_t *pmd)
 {
-	free_pte_fast(pte);
+	return free_pointer_table(pmd);
 }
 
-extern inline void pmd_free(pmd_t *pmd)
+static inline int pmd_free_tlb(mmu_gather_t *tlb, pmd_t *pmd)
 {
-	free_pmd_fast(pmd);
+	return free_pointer_table(pmd);
 }
 
 
-extern inline void pte_free_kernel(pte_t *pte)
+static inline void pgd_free(pgd_t *pgd)
 {
-	free_pte_fast(pte);
+	pmd_free((pmd_t *)pgd);
 }
 
-extern inline pte_t *pte_alloc_kernel(pmd_t *pmd, unsigned long address)
+static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	return pte_alloc(&init_mm,pmd, address);
+	return (pgd_t *)get_pointer_table();
 }
 
-extern inline void pmd_free_kernel(pmd_t *pmd)
-{
-	free_pmd_fast(pmd);
-}
 
-extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
+static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
 {
-	return pmd_alloc(&init_mm,pgd, address);
+	pmd_set(pmd, pte);
 }
 
-extern inline void pgd_free(pgd_t *pgd)
+static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page)
 {
-	free_pmd_fast((pmd_t *)pgd);
+	pmd_set(pmd, page_address(page));
 }
 
-extern inline pgd_t *pgd_alloc(struct mm_struct *mm)
+static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
 {
-	pgd_t *pgd = (pgd_t *)get_pmd_fast();
-	if (!pgd)
-		pgd = (pgd_t *)get_pointer_table();
-	return pgd;
+	pgd_set(pgd, pmd);
 }
 
 
-#define pmd_populate(MM, PMD, PTE)	pmd_set(PMD, PTE)
-#define pgd_populate(MM, PGD, PMD)	pgd_set(PGD, PMD)
-
-
-extern int do_check_pgt_cache(int, int);
-
-extern inline void set_pgdir(unsigned long address, pgd_t entry)
-{
-}
-
+#define check_pgt_cache()	do { } while (0)
 
 #endif /* _MOTOROLA_PGALLOC_H */
diff -Nru a/include/asm-m68k/sun3_pgalloc.h b/include/asm-m68k/sun3_pgalloc.h
--- a/include/asm-m68k/sun3_pgalloc.h	Fri May 24 18:55:35 2002
+++ b/include/asm-m68k/sun3_pgalloc.h	Fri May 24 18:55:35 2002
@@ -1,88 +1,43 @@
 /* sun3_pgalloc.h --
  * reorganization around 2.3.39, routines moved from sun3_pgtable.h 
  *
+ *
+ * 02/27/2002 -- Modified to support "highpte" implementation in 2.5.5 (Sam)
+ *
  * moved 1/26/2000 Sam Creasey
  */
 
 #ifndef _SUN3_PGALLOC_H
 #define _SUN3_PGALLOC_H
 
-/* Pagetable caches. */
-//todo: should implement for at least ptes. --m
-#define pgd_quicklist ((unsigned long *) 0)
-#define pmd_quicklist ((unsigned long *) 0)
-#define pte_quicklist ((unsigned long *) 0)
-#define pgtable_cache_size (0L)
-
-/* Allocation and deallocation of various flavours of pagetables. */
-extern inline int free_pmd_fast (pmd_t *pmdp) { return 0; }
-extern inline int free_pmd_slow (pmd_t *pmdp) { return 0; }
-extern inline pmd_t *get_pmd_fast (void) { return (pmd_t *) 0; }
-
-//todo: implement the following properly.
-#define get_pte_fast() ((pte_t *) 0)
-#define get_pte_slow pte_alloc
-#define free_pte_fast(pte)
-#define free_pte_slow pte_free
+#include <asm/tlb.h>
 
 /* FIXME - when we get this compiling */
 /* erm, now that it's compiling, what do we do with it? */
 #define _KERNPG_TABLE 0
 
-extern inline void pte_free_kernel(pte_t * pte)
-{
-        free_page((unsigned long) pte);
-}
-
 extern const char bad_pmd_string[];
 
-extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address)
-{
-        address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
-        if (pmd_none(*pmd)) {
-                pte_t * page = (pte_t *) get_free_page(GFP_KERNEL);
-                if (pmd_none(*pmd)) {
-                        if (page) {
-                                pmd_val(*pmd) = _KERNPG_TABLE + __pa(page);
-                                return page + address;
-                        }
-                        pmd_val(*pmd) = _KERNPG_TABLE + __pa((unsigned long)BAD_PAGETABLE);
-                        return NULL;
-                }
-                free_page((unsigned long) page);
-        }
-        if (pmd_bad(*pmd)) {
-                printk(bad_pmd_string, pmd_val(*pmd));
-		printk("at kernel pgd off %08x\n", (unsigned int)pmd);
-                pmd_val(*pmd) = _KERNPG_TABLE + __pa((unsigned long)BAD_PAGETABLE);
-                return NULL;
-        }
-        return (pte_t *) __pmd_page(*pmd) + address;
-}
+#define pmd_alloc_one(mm,address)       ({ BUG(); ((pmd_t *)2); })
 
-/*
- * allocating and freeing a pmd is trivial: the 1-entry pmd is
- * inside the pgd, so has no extra memory associated with it.
- */
-extern inline void pmd_free_kernel(pmd_t * pmd)
+
+static inline void pte_free_kernel(pte_t * pte)
 {
-//        pmd_val(*pmd) = 0;
+        free_page((unsigned long) pte);
 }
 
-extern inline pmd_t * pmd_alloc_kernel(pgd_t * pgd, unsigned long address)
+static inline void pte_free(struct page *page)
 {
-        return (pmd_t *) pgd;
+        __free_page(page);
 }
 
-#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
-#define pmd_alloc_one(mm,address)       ({ BUG(); ((pmd_t *)2); })
-
-extern inline void pte_free(pte_t * pte)
+static inline void pte_free_tlb(mmu_gather_t *tlb, struct page *page)
 {
-        free_page((unsigned long) pte);
+	tlb_remove_page(tlb, page);
 }
 
-static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
+static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 
+					  unsigned long address)
 {
 	unsigned long page = __get_free_page(GFP_KERNEL);
 
@@ -90,30 +45,45 @@
 		return NULL;
 		
 	memset((void *)page, 0, PAGE_SIZE);
-//	pmd_val(*pmd) = SUN3_PMD_MAGIC + __pa(page);
-/*	pmd_val(*pmd) = __pa(page); */
 	return (pte_t *) (page);
 }
 
-#define pte_alloc_one_fast(mm,addr) pte_alloc_one(mm,addr)
+static inline struct page *pte_alloc_one(struct mm_struct *mm, 
+					 unsigned long address)
+{
+        struct page *page = alloc_pages(GFP_KERNEL, 0);
 
-#define pmd_populate(mm, pmd, pte) (pmd_val(*pmd) = __pa((unsigned long)pte))
+	if (page == NULL)
+		return NULL;
+		
+	clear_highpage(page);
+	return page;
+
+}
+
+static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
+{
+	pmd_val(*pmd) = __pa((unsigned long)pte);
+}
+
+static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page)
+{
+	pmd_val(*pmd) = __pa((unsigned long)page_address(page));
+}
 
 /*
  * allocating and freeing a pmd is trivial: the 1-entry pmd is
  * inside the pgd, so has no extra memory associated with it.
  */
-extern inline void pmd_free(pmd_t * pmd)
-{
-        pmd_val(*pmd) = 0;
-}
+#define pmd_free(x)			do { } while (0)
+#define pmd_free_tlb(tlb, x)		do { } while (0)
 
-extern inline void pgd_free(pgd_t * pgd)
+static inline void pgd_free(pgd_t * pgd)
 {
         free_page((unsigned long) pgd);
 }
 
-extern inline pgd_t * pgd_alloc(struct mm_struct *mm)
+static inline pgd_t * pgd_alloc(struct mm_struct *mm)
 {
      pgd_t *new_pgd;
 
@@ -125,14 +95,6 @@
 
 #define pgd_populate(mm, pmd, pte) BUG()
 
-/* FIXME: the sun3 doesn't have a page table cache! 
-   (but the motorola routine should just return 0) */
-
-extern int do_check_pgt_cache(int, int);
-
-extern inline void set_pgdir(unsigned long address, pgd_t entry)
-{
-}
 
 /* Reserved PMEGs. */
 extern char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
@@ -141,5 +103,6 @@
 extern unsigned char pmeg_ctx[SUN3_PMEGS_NUM];
 
 
+#define check_pgt_cache()	do { } while (0)
 
 #endif /* SUN3_PGALLOC_H */
diff -Nru a/include/asm-m68k/tlb.h b/include/asm-m68k/tlb.h
--- a/include/asm-m68k/tlb.h	Fri May 24 18:55:36 2002
+++ b/include/asm-m68k/tlb.h	Fri May 24 18:55:36 2002
@@ -1 +1,20 @@
+#ifndef _M68K_TLB_H
+#define _M68K_TLB_H
+
+/*
+ * m68k doesn't need any special per-pte or
+ * per-vma handling..
+ */
+#define tlb_start_vma(tlb, vma)	do { } while (0)
+#define tlb_end_vma(tlb, vma)	do { } while (0)
+#define tlb_remove_tlb_entry(tlb, pte, address)	do { } while (0)
+
+/*
+ * .. because we flush the whole mm when it
+ * fills up.
+ */
+#define tlb_flush(tlb)		flush_tlb_mm((tlb)->mm)
+
 #include <asm-generic/tlb.h>
+
+#endif /* _M68K_TLB_H */
diff -Nru a/include/asm-sparc/pgalloc.h b/include/asm-sparc/pgalloc.h
--- a/include/asm-sparc/pgalloc.h	Fri May 24 18:55:33 2002
+++ b/include/asm-sparc/pgalloc.h	Fri May 24 18:55:33 2002
@@ -117,7 +117,6 @@
 
 static __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	BUG();
 	return 0;
 }
 
diff -Nru a/include/asm-sparc/sbus.h b/include/asm-sparc/sbus.h
--- a/include/asm-sparc/sbus.h	Fri May 24 18:55:34 2002
+++ b/include/asm-sparc/sbus.h	Fri May 24 18:55:34 2002
@@ -112,13 +112,13 @@
 #define	SBUS_DMA_NONE		3
 
 /* All the rest use streaming mode mappings. */
-extern u32 sbus_map_single(struct sbus_dev *, void *, long, int);
-extern void sbus_unmap_single(struct sbus_dev *, u32, long, int);
+extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
+extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
 extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
 extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
 
 /* Finally, allow explicit synchronization of streamable mappings. */
-extern void sbus_dma_sync_single(struct sbus_dev *, u32, long, int);
+extern void sbus_dma_sync_single(struct sbus_dev *, dma_addr_t, size_t, int);
 extern void sbus_dma_sync_sg(struct sbus_dev *, struct scatterlist *, int, int);
 
 #endif /* !(_SPARC_SBUS_H) */
diff -Nru a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h
--- a/include/asm-sparc64/bitops.h	Fri May 24 18:55:34 2002
+++ b/include/asm-sparc64/bitops.h	Fri May 24 18:55:34 2002
@@ -112,6 +112,12 @@
 	return result;
 }
 
+/*
+ * fls: find last bit set.
+ */
+
+#define fls(x) generic_fls(x)
+
 #ifdef __KERNEL__
 
 /*
diff -Nru a/include/asm-sparc64/tlb.h b/include/asm-sparc64/tlb.h
--- a/include/asm-sparc64/tlb.h	Fri May 24 18:55:34 2002
+++ b/include/asm-sparc64/tlb.h	Fri May 24 18:55:34 2002
@@ -1 +1,18 @@
+#ifndef _SPARC64_TLB_H
+#define _SPARC64_TLB_H
+
+#define tlb_flush(tlb)		flush_tlb_mm((tlb)->mm)
+
+#define tlb_start_vma(tlb, vma) \
+	flush_cache_range(vma, vma->vm_start, vma->vm_end)
+#define tlb_end_vma(tlb, vma) \
+	flush_tlb_range(vma, vma->vm_start, vma->vm_end)
+
+#define tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
+
 #include <asm-generic/tlb.h>
+
+#define pmd_free_tlb(tlb, pmd)	pmd_free(pmd)
+#define pte_free_tlb(tlb, pte)	pte_free(pte)
+
+#endif /* _SPARC64_TLB_H */
diff -Nru a/include/asm-sparc64/tlbflush.h b/include/asm-sparc64/tlbflush.h
--- a/include/asm-sparc64/tlbflush.h	Fri May 24 18:55:36 2002
+++ b/include/asm-sparc64/tlbflush.h	Fri May 24 18:55:36 2002
@@ -36,6 +36,16 @@
      } \
 } while(0)
 
+#define flush_tlb_vpte_range(__mm, start, end) \
+do { if(CTX_VALID((__mm)->context)) { \
+	unsigned long __start = (start)&PAGE_MASK; \
+	unsigned long __end = PAGE_ALIGN(end); \
+	__flush_tlb_range(CTX_HWBITS((__mm)->context), __start, \
+			  SECONDARY_CONTEXT, __end, PAGE_SIZE, \
+			  (__end - __start)); \
+     } \
+} while(0)
+
 #define flush_tlb_page(vma, page) \
 do { struct mm_struct *__mm = (vma)->vm_mm; \
      if(CTX_VALID(__mm->context)) \
@@ -43,11 +53,18 @@
 			 SECONDARY_CONTEXT); \
 } while(0)
 
+#define flush_tlb_vpte_page(mm, addr) \
+do { struct mm_struct *__mm = (mm); \
+     if(CTX_VALID(__mm->context)) \
+	__flush_tlb_page(CTX_HWBITS(__mm->context), (addr)&PAGE_MASK, \
+			 SECONDARY_CONTEXT); \
+} while(0)
+
 #else /* CONFIG_SMP */
 
 extern void smp_flush_tlb_all(void);
 extern void smp_flush_tlb_mm(struct mm_struct *mm);
-extern void smp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
+extern void smp_flush_tlb_range(struct mm_struct *mm, unsigned long start,
 				unsigned long end);
 extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
 extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long page);
@@ -56,11 +73,15 @@
 #define flush_tlb_all()		smp_flush_tlb_all()
 #define flush_tlb_mm(mm)	smp_flush_tlb_mm(mm)
 #define flush_tlb_range(vma, start, end) \
-	smp_flush_tlb_range(vma, start, end)
+	smp_flush_tlb_range((vma)->vm_mm, start, end)
+#define flush_tlb_vpte_range(mm, start, end) \
+	smp_flush_tlb_range(mm, start, end)
 #define flush_tlb_kernel_range(start, end) \
 	smp_flush_tlb_kernel_range(start, end)
 #define flush_tlb_page(vma, page) \
 	smp_flush_tlb_page((vma)->vm_mm, page)
+#define flush_tlb_vpte_page(mm, page) \
+	smp_flush_tlb_page((mm), page)
 
 #endif /* ! CONFIG_SMP */
 
@@ -81,13 +102,10 @@
 	vpte_base = (tlb_type == spitfire ?
 		     VPTE_BASE_SPITFIRE :
 		     VPTE_BASE_CHEETAH);
-	{
-		struct vm_area_struct vma;
-		vma.vm_mm = mm;
-		flush_tlb_range(&vma,
-				vpte_base + (s >> (PAGE_SHIFT - 3)),
-				vpte_base + (e >> (PAGE_SHIFT - 3)));
-	}
+
+	flush_tlb_vpte_range(mm,
+			     vpte_base + (s >> (PAGE_SHIFT - 3)),
+			     vpte_base + (e >> (PAGE_SHIFT - 3)));
 }
 
 #endif /* _SPARC64_TLBFLUSH_H */
diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
--- a/include/asm-x86_64/processor.h	Fri May 24 18:55:35 2002
+++ b/include/asm-x86_64/processor.h	Fri May 24 18:55:35 2002
@@ -91,6 +91,7 @@
 #define cpu_has_de 1
 #define cpu_has_vme 1
 #define cpu_has_fxsr 1
+#define cpu_has_mmx 1
 #define cpu_has_xmm 1
 #define cpu_has_apic 1
 
diff -Nru a/include/linux/amigaffs.h b/include/linux/amigaffs.h
--- a/include/linux/amigaffs.h	Fri May 24 18:55:34 2002
+++ b/include/linux/amigaffs.h	Fri May 24 18:55:34 2002
@@ -2,7 +2,7 @@
 #define AMIGAFFS_H
 
 #include <linux/types.h>
-
+#include <linux/buffer_head.h>
 #include <asm/byteorder.h>
 
 /* AmigaOS allows file names with up to 30 characters length.
diff -Nru a/include/linux/atapi.h b/include/linux/atapi.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/atapi.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,65 @@
+/**** vi:set ts=8 sts=8 sw=8:************************************************
+ *
+ * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * With each packet command, we allocate a buffer.
+ * This is used for several packet
+ * commands (Not for READ/WRITE commands).
+ */
+#define IDEFLOPPY_PC_BUFFER_SIZE	256
+#define IDETAPE_PC_BUFFER_SIZE		256
+
+/* This struct get's shared between different drivers.
+ */
+struct atapi_packet_command {
+	u8 c[12];			/* Actual packet bytes */
+	char *buffer;			/* Data buffer */
+	int buffer_size;		/* Size of our data buffer */
+	char *current_position;		/* Pointer into the above buffer */
+	int request_transfer;		/* Bytes to transfer */
+	int actually_transferred;	/* Bytes actually transferred */
+
+	unsigned long flags;		/* Status/Action bit flags: long for set_bit */
+
+	/* FIXME: the following is ugly as hell, but the only way we can start
+	 * actually to unify the code.
+	 */
+	/* driver specific data. */
+	/* floppy/tape */
+	int retries;				/* On each retry, we increment retries */
+	int error;				/* Error code */
+	char *b_data;				/* Pointer which runs on the buffers */
+	unsigned int b_count;			/* Missing/Available data on the current buffer */
+	u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE];	/* Temporary buffer */
+	/* Called when this packet command is completed */
+	void (*callback) (struct ata_device *, struct request *);
+
+	/* only tape */
+	struct bio *bio;
+
+	/* only scsi */
+	struct {
+		unsigned int b_count;			/* Bytes transferred from current entry */
+		struct scatterlist *sg;			/* Scatter gather table */
+		struct scsi_cmnd *scsi_cmd;		/* SCSI command */
+		void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
+		unsigned long timeout;			/* Command timeout */
+	} s;
+};
+
+
+extern void atapi_discard_data(struct ata_device *drive, unsigned int bcount);
+extern void atapi_write_zeros(struct ata_device *drive, unsigned int bcount);
+
+extern void atapi_init_pc(struct atapi_packet_command *pc);
diff -Nru a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h
--- a/include/linux/bfs_fs.h	Fri May 24 18:55:35 2002
+++ b/include/linux/bfs_fs.h	Fri May 24 18:55:35 2002
@@ -6,9 +6,6 @@
 #ifndef _LINUX_BFS_FS_H
 #define _LINUX_BFS_FS_H
 
-#include <linux/bfs_fs_i.h>
-#include <linux/bfs_fs_sb.h>
-
 #define BFS_BSIZE_BITS		9
 #define BFS_BSIZE		(1<<BFS_BSIZE_BITS)
 
@@ -79,26 +76,4 @@
 #define BFS_UNCLEAN(bfs_sb, sb)	\
 	((bfs_sb->s_from != -1) && (bfs_sb->s_to != -1) && !(sb->s_flags & MS_RDONLY))
 
-#ifdef __KERNEL__
-
-/* file.c */
-extern struct inode_operations bfs_file_inops;
-extern struct file_operations bfs_file_operations;
-extern struct address_space_operations bfs_aops;
-
-/* dir.c */
-extern struct inode_operations bfs_dir_inops;
-extern struct file_operations bfs_dir_operations;
-
-static inline struct bfs_sb_info *BFS_SB(struct super_block *sb)
-{
-	return sb->u.generic_sbp;
-}
-
-static inline struct bfs_inode_info *BFS_I(struct inode *inode)
-{
-	return list_entry(inode, struct bfs_inode_info, vfs_inode);
-}
-
-#endif /* __KERNEL__ */
 #endif	/* _LINUX_BFS_FS_H */
diff -Nru a/include/linux/bfs_fs_i.h b/include/linux/bfs_fs_i.h
--- a/include/linux/bfs_fs_i.h	Fri May 24 18:55:34 2002
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,21 +0,0 @@
-/*
- *	include/linux/bfs_fs_i.h
- *	Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
- */
-
-#ifndef _LINUX_BFS_FS_I
-#define _LINUX_BFS_FS_I
-
-#include <linux/fs.h>
-
-/*
- * BFS file system in-core inode info
- */
-struct bfs_inode_info {
-	unsigned long i_dsk_ino; /* inode number from the disk, can be 0 */
-	unsigned long i_sblock;
-	unsigned long i_eblock;
-	struct inode vfs_inode;
-};
-
-#endif	/* _LINUX_BFS_FS_I */
diff -Nru a/include/linux/bfs_fs_sb.h b/include/linux/bfs_fs_sb.h
--- a/include/linux/bfs_fs_sb.h	Fri May 24 18:55:36 2002
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,25 +0,0 @@
-/*
- *	include/linux/bfs_fs_sb.h
- *	Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
- */
-
-#ifndef _LINUX_BFS_FS_SB
-#define _LINUX_BFS_FS_SB
-
-/*
- * BFS file system in-core superblock info
- */
-struct bfs_sb_info {
-	unsigned long si_blocks;
-	unsigned long si_freeb;
-	unsigned long si_freei;
-	unsigned long si_lf_ioff;
-	unsigned long si_lf_sblk;
-	unsigned long si_lf_eblk;
-	unsigned long si_lasti;
-	char * si_imap;
-	struct buffer_head * si_sbh;		/* buffer header w/superblock */
-	struct bfs_super_block * si_bfs_sb;	/* superblock in si_sbh->b_data */
-};
-
-#endif	/* _LINUX_BFS_FS_SB */
diff -Nru a/include/linux/bitops.h b/include/linux/bitops.h
--- a/include/linux/bitops.h	Fri May 24 18:55:36 2002
+++ b/include/linux/bitops.h	Fri May 24 18:55:36 2002
@@ -1,6 +1,6 @@
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
-
+#include <asm/bitops.h>
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -35,6 +35,47 @@
 		r += 1;
 	}
 	return r;
+}
+
+/*
+ * fls: find last bit set.
+ */
+
+extern __inline__ int generic_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000)) {
+		x <<= 1;
+		r -= 1;
+	}
+	return r;
+}
+
+extern __inline__ int get_bitmask_order(unsigned int count)
+{
+	int order;
+	
+	order = fls(count);
+	return order;	/* We could be slightly more clever with -1 here... */
 }
 
 /*
diff -Nru a/include/linux/blk.h b/include/linux/blk.h
--- a/include/linux/blk.h	Fri May 24 18:55:34 2002
+++ b/include/linux/blk.h	Fri May 24 18:55:34 2002
@@ -313,22 +313,11 @@
 
 #define SET_INTR(x) (DEVICE_INTR = (x))
 
-#ifdef DEVICE_INTR
-#define CLEAR_INTR SET_INTR(NULL)
-#else
-#define CLEAR_INTR
-#endif
-
-#define INIT_REQUEST						\
-	if (QUEUE_EMPTY) {					\
-		CLEAR_INTR;					\
-		return;						\
-	}							\
-	if (major(CURRENT->rq_dev) != MAJOR_NR) 			\
-		panic(DEVICE_NAME ": request list destroyed");	\
-	if (!CURRENT->bio)					\
-		panic(DEVICE_NAME ": no bio");			\
-
+# ifdef DEVICE_INTR
+#  define CLEAR_INTR SET_INTR(NULL)
+# else
+#  define CLEAR_INTR
+# endif
 #endif /* !defined(IDE_DRIVER) */
 
 /*
diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
--- a/include/linux/blkdev.h	Fri May 24 18:55:34 2002
+++ b/include/linux/blkdev.h	Fri May 24 18:55:34 2002
@@ -293,7 +293,7 @@
 extern int wipe_partitions(kdev_t dev);
 extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size);
 extern void generic_make_request(struct bio *bio);
-extern inline request_queue_t *blk_get_queue(kdev_t dev);
+extern inline request_queue_t *bdev_get_queue(struct block_device *bdev);
 extern void blkdev_release_request(struct request *);
 extern void blk_attempt_remerge(request_queue_t *, struct request *);
 extern struct request *blk_get_request(request_queue_t *, int, int);
@@ -303,7 +303,6 @@
 extern inline int blk_phys_contig_segment(request_queue_t *q, struct bio *, struct bio *);
 extern inline int blk_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *);
 extern int block_ioctl(struct block_device *, unsigned int, unsigned long);
-extern int ll_10byte_cmd_build(request_queue_t *, struct request *);
 
 /*
  * get ready for proper ref counting
@@ -374,14 +373,9 @@
 	return retval;
 }
 
-extern inline int get_hardsect_size(kdev_t dev)
-{
-	return queue_hardsect_size(blk_get_queue(dev));
-}
-
 extern inline int bdev_hardsect_size(struct block_device *bdev)
 {
-	return queue_hardsect_size(blk_get_queue(to_kdev_t(bdev->bd_dev)));
+	return queue_hardsect_size(bdev_get_queue(bdev));
 }
 
 #define blk_finished_io(nsects)	do { } while (0)
diff -Nru a/include/linux/buffer_head.h b/include/linux/buffer_head.h
--- a/include/linux/buffer_head.h	Fri May 24 18:55:33 2002
+++ b/include/linux/buffer_head.h	Fri May 24 18:55:33 2002
@@ -4,8 +4,13 @@
  * Everything to do with buffer_heads.
  */
 
-#ifndef BUFFER_FLAGS_H
-#define BUFFER_FLAGS_H
+#ifndef _LINUX_BUFFER_HEAD_H
+#define _LINUX_BUFFER_HEAD_H
+
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/linkage.h>
+#include <asm/atomic.h>
 
 enum bh_state_bits {
 	BH_Uptodate,	/* Contains valid data */
@@ -138,7 +143,6 @@
  */
 
 void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
-void buffer_init(void);
 void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
 void set_bh_page(struct buffer_head *bh,
 		struct page *page, unsigned long offset);
@@ -297,4 +301,4 @@
 void __buffer_error(char *file, int line);
 #define buffer_error() __buffer_error(__FILE__, __LINE__)
 
-#endif		/* BUFFER_FLAGS_H */
+#endif /* _LINUX_BUFFER_HEAD_H */
diff -Nru a/include/linux/coda_linux.h b/include/linux/coda_linux.h
--- a/include/linux/coda_linux.h	Fri May 24 18:55:34 2002
+++ b/include/linux/coda_linux.h	Fri May 24 18:55:34 2002
@@ -40,7 +40,8 @@
 int coda_release(struct inode *i, struct file *f);
 int coda_permission(struct inode *inode, int mask);
 int coda_revalidate_inode(struct dentry *);
-int coda_notify_change(struct dentry *, struct iattr *);
+int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
+int coda_setattr(struct dentry *, struct iattr *);
 int coda_isnullfid(ViceFid *fid);
 
 /* global variables */
diff -Nru a/include/linux/dcache.h b/include/linux/dcache.h
--- a/include/linux/dcache.h	Fri May 24 18:55:35 2002
+++ b/include/linux/dcache.h	Fri May 24 18:55:35 2002
@@ -5,6 +5,8 @@
 
 #include <asm/atomic.h>
 #include <linux/mount.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
 #include <asm/page.h>			/* for BUG() */
 
 /*
diff -Nru a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	Fri May 24 18:55:34 2002
+++ b/include/linux/fs.h	Fri May 24 18:55:34 2002
@@ -27,6 +27,7 @@
 #include <asm/atomic.h>
 
 struct poll_table_struct;
+struct nameidata;
 
 
 /*
@@ -340,6 +341,7 @@
 	dev_t			bd_dev;  /* not a kdev_t - it's a search key */
 	int			bd_openers;
 	const struct block_device_operations *bd_op;
+	struct request_queue	*bd_queue;
 	struct semaphore	bd_sem;	/* open/close mutex */
 	struct list_head	bd_inodes;
 	void *			bd_holder;
@@ -605,16 +607,6 @@
 /* only for net: no internal synchronization */
 extern void __kill_fasync(struct fasync_struct *, int, int);
 
-struct nameidata {
-	struct dentry *dentry;
-	struct vfsmount *mnt;
-	struct qstr last;
-	unsigned int flags;
-	int last_type;
-	struct dentry *old_dentry;
-	struct vfsmount *old_mnt;
-};
-
 /*
  *	Umount options
  */
@@ -707,9 +699,6 @@
 extern int vfs_unlink(struct inode *, struct dentry *);
 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 
-extern struct dentry *lock_rename(struct dentry *, struct dentry *);
-extern void unlock_rename(struct dentry *, struct dentry *);
-
 /*
  * File types
  */
@@ -781,9 +770,8 @@
 	int (*follow_link) (struct dentry *, struct nameidata *);
 	void (*truncate) (struct inode *);
 	int (*permission) (struct inode *, int);
-	int (*revalidate) (struct dentry *);
 	int (*setattr) (struct dentry *, struct iattr *);
-	int (*getattr) (struct dentry *, struct iattr *);
+	int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
 	int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
@@ -1168,25 +1156,6 @@
 #include <linux/err.h>
 
 /*
- * The bitmask for a lookup event:
- *  - follow links at the end
- *  - require a directory
- *  - ending slashes ok even for nonexistent files
- *  - internal "there are more path compnents" flag
- *  - locked when lookup done with dcache_lock held
- */
-#define LOOKUP_FOLLOW		(1)
-#define LOOKUP_DIRECTORY	(2)
-#define LOOKUP_CONTINUE		(4)
-#define LOOKUP_PARENT		(16)
-#define LOOKUP_NOALT		(32)
-
-/*
- * Type of the last component on LOOKUP_PARENT
- */
-enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
-
-/*
  * "descriptor" for what we're up to with a read for sendfile().
  * This allows us to use the same read code yet
  * have multiple different users of the data that
@@ -1207,19 +1176,6 @@
 /* needed for stackable file system support */
 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
 
-extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
-extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
-extern int FASTCALL(path_walk(const char *, struct nameidata *));
-extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
-extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
-extern void path_release(struct nameidata *);
-extern int follow_down(struct vfsmount **, struct dentry **);
-extern int follow_up(struct vfsmount **, struct dentry **);
-extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
-extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
-#define user_path_walk(name,nd)	 __user_walk(name, LOOKUP_FOLLOW, nd)
-#define user_path_walk_link(name,nd) __user_walk(name, 0, nd)
-
 extern void inode_init_once(struct inode *);
 extern void iput(struct inode *);
 extern void force_delete(struct inode *);
@@ -1283,6 +1239,7 @@
 extern int page_readlink(struct dentry *, char *, int);
 extern int page_follow_link(struct dentry *, struct nameidata *);
 extern struct inode_operations page_symlink_inode_operations;
+extern void generic_fillattr(struct inode *, struct kstat *);
 
 extern int vfs_readdir(struct file *, filldir_t, void *);
 
@@ -1296,6 +1253,9 @@
 extern kdev_t ROOT_DEV;
 extern char root_device_name[];
 
+extern int dcache_dir_open(struct inode *, struct file *);
+extern int dcache_dir_close(struct inode *, struct file *);
+extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
 extern int dcache_readdir(struct file *, void *, filldir_t);
 extern int simple_statfs(struct super_block *, struct statfs *);
 extern struct dentry *simple_lookup(struct inode *, struct dentry *);
@@ -1324,8 +1284,5 @@
 	return res;
 }
 
-#include <linux/buffer_head.h>
-
 #endif /* __KERNEL__ */
-
 #endif /* _LINUX_FS_H */
diff -Nru a/include/linux/futex.h b/include/linux/futex.h
--- a/include/linux/futex.h	Fri May 24 18:55:36 2002
+++ b/include/linux/futex.h	Fri May 24 18:55:36 2002
@@ -2,7 +2,7 @@
 #define _LINUX_FUTEX_H
 
 /* Second argument to futex syscall */
-#define FUTEX_UP (0)
-#define FUTEX_DOWN (1)
+#define FUTEX_WAIT (0)
+#define FUTEX_WAKE (1)
 
 #endif
diff -Nru a/include/linux/gameport.h b/include/linux/gameport.h
--- a/include/linux/gameport.h	Fri May 24 18:55:35 2002
+++ b/include/linux/gameport.h	Fri May 24 18:55:35 2002
@@ -79,8 +79,8 @@
 void gameport_register_port(struct gameport *gameport);
 void gameport_unregister_port(struct gameport *gameport);
 #else
-void __inline__ gameport_register_port(struct gameport *gameport) { return; }
-void __inline__ gameport_unregister_port(struct gameport *gameport) { return; }
+static inline void gameport_register_port(struct gameport *gameport) { return; }
+static inline void gameport_unregister_port(struct gameport *gameport) { return; }
 #endif
 
 void gameport_register_device(struct gameport_dev *dev);
diff -Nru a/include/linux/hfs_sysdep.h b/include/linux/hfs_sysdep.h
--- a/include/linux/hfs_sysdep.h	Fri May 24 18:55:33 2002
+++ b/include/linux/hfs_sysdep.h	Fri May 24 18:55:33 2002
@@ -21,6 +21,7 @@
 #include <linux/types.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/buffer_head.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
diff -Nru a/include/linux/highmem.h b/include/linux/highmem.h
--- a/include/linux/highmem.h	Fri May 24 18:55:34 2002
+++ b/include/linux/highmem.h	Fri May 24 18:55:34 2002
@@ -18,16 +18,6 @@
 extern void create_bounce(unsigned long pfn, int gfp, struct bio **bio_orig);
 extern void check_highmem_ptes(void);
 
-static inline char *bh_kmap(struct buffer_head *bh)
-{
-	return kmap(bh->b_page) + bh_offset(bh);
-}
-
-static inline void bh_kunmap(struct buffer_head *bh)
-{
-	kunmap(bh->b_page);
-}
-
 /*
  * remember to add offset! and never ever reenable interrupts between a
  * bio_kmap_irq and bio_kunmap_irq!!
diff -Nru a/include/linux/ide.h b/include/linux/ide.h
--- a/include/linux/ide.h	Fri May 24 18:55:34 2002
+++ b/include/linux/ide.h	Fri May 24 18:55:34 2002
@@ -40,9 +40,6 @@
 
 /* Right now this is only needed by a promise controlled.
  */
-#ifndef DISK_RECOVERY_TIME		/* off=0; on=access_delay_time */
-# define DISK_RECOVERY_TIME	0	/*  for hardware that needs it */
-#endif
 #ifndef OK_TO_RESET_CONTROLLER		/* 1 needed for good error recovery */
 # define OK_TO_RESET_CONTROLLER	0	/* 0 for use with AH2372A/B interface */
 #endif
@@ -202,7 +199,8 @@
 	ide_cmd646,
 	ide_cy82c693,
 	ide_pmac,
-	ide_etrax100
+	ide_etrax100,
+	ide_acorn
 } hwif_chipset_t;
 
 
@@ -319,7 +317,6 @@
 /*
  * ATA/ATAPI device structure :
  */
-typedef
 struct ata_device {
 	struct ata_channel *	channel;
 	char			name[6];	/* device name */
@@ -411,7 +408,7 @@
 	unsigned long	immed_comp;
 	int		max_last_depth;
 	int		max_depth;
-} ide_drive_t;
+};
 
 /*
  * Status returned by various functions.
@@ -447,6 +444,7 @@
 	 * between differen queues sharing the same irq line.
 	 */
 	spinlock_t *lock;
+	unsigned long *active;		/* active processing request */
 
 	ide_startstop_t (*handler)(struct ata_device *, struct request *);	/* irq handler, if active */
 	struct timer_list timer;				/* failsafe timer */
@@ -454,7 +452,6 @@
 	unsigned long poll_timeout;				/* timeout value during polled operations */
 	struct ata_device *drive;				/* last serviced drive */
 
-	unsigned long active;		/* active processing request */
 
 	ide_ioreg_t io_ports[IDE_NR_PORTS];	/* task file registers */
 	hw_regs_t hw;				/* hardware info */
@@ -547,10 +544,6 @@
 	unsigned slow		: 1;	/* flag: slow data port */
 	unsigned io_32bit	: 1;	/* 0=16-bit, 1=32-bit */
 	unsigned char bus_state;	/* power state of the IDE bus */
-
-#if (DISK_RECOVERY_TIME > 0)
-	unsigned long last_time;	/* time when previous rq was done */
-#endif
 };
 
 /*
@@ -596,6 +589,7 @@
 
 struct ata_operations {
 	struct module *owner;
+	void (*attach) (struct ata_device *);
 	int (*cleanup)(struct ata_device *);
 	int (*standby)(struct ata_device *);
 	ide_startstop_t	(*do_request)(struct ata_device *, struct request *, sector_t);
@@ -608,6 +602,9 @@
 	void (*revalidate)(struct ata_device *);
 
 	sector_t (*capacity)(struct ata_device *);
+
+	/* linked list of rgistered device type drivers */
+	struct ata_operations *next;
 };
 
 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
@@ -624,11 +621,20 @@
 
 extern sector_t ata_capacity(struct ata_device *drive);
 
-/* FIXME: Actually implement and use them as soon as possible!  to make the
- * ide_scan_devices() go away! */
-
-extern int unregister_ata_driver(unsigned int type, struct ata_operations *driver);
-extern int register_ata_driver(unsigned int type, struct ata_operations *driver);
+extern void unregister_ata_driver(struct ata_operations *driver);
+extern int register_ata_driver(struct ata_operations *driver);
+static inline int ata_driver_module(struct ata_operations *driver)
+{
+#ifdef MODULE
+	if (register_ata_driver(driver) <= 0) {
+		unregister_ata_driver(driver);
+		return -ENODEV;
+	}
+#else
+	register_ata_driver(driver);
+#endif
+	return 0;
+}
 
 #define ata_ops(drive)		((drive)->driver)
 
@@ -642,7 +648,7 @@
 #define LOCAL_END_REQUEST	/* Don't generate end_request in blk.h */
 #include <linux/blk.h>
 
-extern int __ide_end_request(struct ata_device *, struct request *, int, int);
+extern int __ide_end_request(struct ata_device *, struct request *, int, unsigned int);
 extern int ide_end_request(struct ata_device *drive, struct request *, int);
 
 /*
@@ -784,11 +790,9 @@
 
 extern struct block_device_operations ide_fops[];
 
-#ifdef CONFIG_BLK_DEV_IDE
 /* Probe for devices attached to the systems host controllers.
  */
-extern int ideprobe_init (void);
-#endif
+extern int ideprobe_init(void);
 #ifdef CONFIG_BLK_DEV_IDEDISK
 extern int idedisk_init (void);
 #endif
@@ -805,9 +809,9 @@
 extern int idescsi_init (void);
 #endif
 
-extern struct ata_device *ide_scan_devices(byte, const char *, struct ata_operations *, int);
 extern int ide_register_subdriver(struct ata_device *, struct ata_operations *);
 extern int ide_unregister_subdriver(struct ata_device *drive);
+extern int ide_revalidate_disk(kdev_t i_rdev);
 
 #ifdef CONFIG_PCI
 # define ON_BOARD		0
@@ -863,6 +867,15 @@
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
 
+void udma_pci_enable(struct ata_device *drive, int on, int verbose);
+int udma_pci_start(struct ata_device *drive, struct request *rq);
+int udma_pci_stop(struct ata_device *drive);
+int udma_pci_read(struct ata_device *drive, struct request *rq);
+int udma_pci_write(struct ata_device *drive, struct request *rq);
+int udma_pci_irq_status(struct ata_device *drive);
+void udma_pci_timeout(struct ata_device *drive);
+void udma_pci_irq_lost(struct ata_device *);
+
 extern int udma_new_table(struct ata_channel *, struct request *);
 extern void udma_destroy_table(struct ata_channel *);
 extern void udma_print(struct ata_device *);
@@ -889,6 +902,5 @@
 #define DRIVE_LOCK(drive)		((drive)->queue.queue_lock)
 
 extern int drive_is_ready(struct ata_device *drive);
-extern void revalidate_drives(void);
 
 #endif
diff -Nru a/include/linux/init.h b/include/linux/init.h
--- a/include/linux/init.h	Fri May 24 18:55:33 2002
+++ b/include/linux/init.h	Fri May 24 18:55:33 2002
@@ -169,6 +169,9 @@
 
 #endif
 
+/* Data marked not to be saved by software_suspend() */
+#define __nosavedata __attribute__ ((__section__ (".data.nosave")))
+
 #ifdef CONFIG_HOTPLUG
 #define __devinit
 #define __devinitdata
diff -Nru a/include/linux/interrupt.h b/include/linux/interrupt.h
--- a/include/linux/interrupt.h	Fri May 24 18:55:33 2002
+++ b/include/linux/interrupt.h	Fri May 24 18:55:33 2002
@@ -124,14 +124,6 @@
 	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
 };
 
-struct tasklet_head
-{
-	struct tasklet_struct *list;
-} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
-
-extern struct tasklet_head tasklet_vec[NR_CPUS];
-extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
-
 #ifdef CONFIG_SMP
 static inline int tasklet_trylock(struct tasklet_struct *t)
 {
diff -Nru a/include/linux/jbd.h b/include/linux/jbd.h
--- a/include/linux/jbd.h	Fri May 24 18:55:36 2002
+++ b/include/linux/jbd.h	Fri May 24 18:55:36 2002
@@ -25,6 +25,7 @@
 #define jfs_debug jbd_debug
 #else
 
+#include <linux/buffer_head.h>
 #include <linux/journal-head.h>
 #include <linux/stddef.h>
 #include <asm/semaphore.h>
diff -Nru a/include/linux/jiffies.h b/include/linux/jiffies.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/jiffies.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,32 @@
+#ifndef _LINUX_JIFFIES_H
+#define _LINUX_JIFFIES_H
+
+#include <linux/types.h>
+
+/*
+ * The 64-bit value is not volatile - you MUST NOT read it
+ * without holding read_lock_irq(&xtime_lock)
+ */
+extern u64 jiffies_64;
+extern unsigned long volatile jiffies;
+
+/*
+ *	These inlines deal with timer wrapping correctly. You are 
+ *	strongly encouraged to use them
+ *	1. Because people otherwise forget
+ *	2. Because if the timer wrap changes in future you wont have to
+ *	   alter your driver code.
+ *
+ * time_after(a,b) returns true if the time a is after time b.
+ *
+ * Do this with "<0" and ">=0" to only test the sign of the result. A
+ * good compiler would generate better code (and a really good compiler
+ * wouldn't care). Gcc is currently neither.
+ */
+#define time_after(a,b)		((long)(b) - (long)(a) < 0)
+#define time_before(a,b)	time_after(b,a)
+
+#define time_after_eq(a,b)	((long)(a) - (long)(b) >= 0)
+#define time_before_eq(a,b)	time_after_eq(b,a)
+
+#endif
diff -Nru a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h	Fri May 24 18:55:36 2002
+++ b/include/linux/module.h	Fri May 24 18:55:36 2002
@@ -349,13 +349,6 @@
 
 /* We want the EXPORT_SYMBOL tag left intact for recognition.  */
 
-#elif !defined(AUTOCONF_INCLUDED)
-
-#define __EXPORT_SYMBOL(sym,str)   error config_must_be_included_before_module
-#define EXPORT_SYMBOL(var)	   error config_must_be_included_before_module
-#define EXPORT_SYMBOL_NOVERS(var)  error config_must_be_included_before_module
-#define EXPORT_SYMBOL_GPL(var)  error config_must_be_included_before_module
-
 #elif !defined(CONFIG_MODULES)
 
 #define __EXPORT_SYMBOL(sym,str)
@@ -370,8 +363,6 @@
 #define EXPORT_SYMBOL_NOVERS(var)  error this_object_must_be_defined_as_export_objs_in_the_Makefile
 #define EXPORT_SYMBOL_GPL(var)  error this_object_must_be_defined_as_export_objs_in_the_Makefile
 
-__asm__(".section __ksymtab,\"a\"\n.previous");
-
 #else
 
 #define __EXPORT_SYMBOL(sym, str)			\
@@ -400,12 +391,23 @@
 
 #endif /* __GENKSYMS__ */
 
-#ifdef MODULE
-/* Force a module to export no symbols.  */
-#define EXPORT_NO_SYMBOLS  __asm__(".section __ksymtab\n.previous")
-#else
+/* 
+ * Force a module to export no symbols.
+ * EXPORT_NO_SYMBOLS is default now, leave the define around for sources
+ * which still have it
+ */
 #define EXPORT_NO_SYMBOLS
-#endif /* MODULE */
+
+#ifdef CONFIG_MODULES
+/* 
+ * Always allocate a section "__ksymtab". If we encounter EXPORT_SYMBOL,
+ * the exported symbol will be added to it.
+ * If it remains empty, that tells modutils that we do not want to
+ * export any symbols (as opposed to it not being present, which means
+ * "export all symbols" to modutils)
+ */
+__asm__(".section __ksymtab,\"a\"\n.previous");
+#endif
 
 #ifdef CONFIG_MODULES
 #define SET_MODULE_OWNER(some_struct) do { (some_struct)->owner = THIS_MODULE; } while (0)
diff -Nru a/include/linux/mount.h b/include/linux/mount.h
--- a/include/linux/mount.h	Fri May 24 18:55:33 2002
+++ b/include/linux/mount.h	Fri May 24 18:55:33 2002
@@ -12,6 +12,8 @@
 #define _LINUX_MOUNT_H
 #ifdef __KERNEL__
 
+#include <linux/list.h>
+
 #define MNT_NOSUID	1
 #define MNT_NODEV	2
 #define MNT_NOEXEC	4
diff -Nru a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
--- a/include/linux/msdos_fs.h	Fri May 24 18:55:36 2002
+++ b/include/linux/msdos_fs.h	Fri May 24 18:55:36 2002
@@ -4,6 +4,7 @@
 /*
  * The MS-DOS filesystem constants/structures
  */
+#include <linux/buffer_head.h>
 #include <asm/byteorder.h>
 
 #define SECTOR_SIZE	512		/* sector size (bytes) */
diff -Nru a/include/linux/namei.h b/include/linux/namei.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/namei.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,58 @@
+#ifndef _LINUX_NAMEI_H
+#define _LINUX_NAMEI_H
+
+#include <linux/linkage.h>
+
+struct vfsmount;
+
+struct nameidata {
+	struct dentry	*dentry;
+	struct vfsmount *mnt;
+	struct qstr	last;
+	unsigned int	flags;
+	int		last_type;
+	struct dentry	*old_dentry;
+	struct vfsmount	*old_mnt;
+};
+
+/*
+ * Type of the last component on LOOKUP_PARENT
+ */
+enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
+
+/*
+ * The bitmask for a lookup event:
+ *  - follow links at the end
+ *  - require a directory
+ *  - ending slashes ok even for nonexistent files
+ *  - internal "there are more path compnents" flag
+ *  - locked when lookup done with dcache_lock held
+ */
+#define LOOKUP_FOLLOW		 1
+#define LOOKUP_DIRECTORY	 2
+#define LOOKUP_CONTINUE		 4
+#define LOOKUP_PARENT		16
+#define LOOKUP_NOALT		32
+
+
+extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
+#define user_path_walk(name,nd) \
+	__user_walk(name, LOOKUP_FOLLOW, nd)
+#define user_path_walk_link(name,nd) \
+	__user_walk(name, 0, nd)
+extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
+extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+extern int FASTCALL(path_walk(const char *, struct nameidata *));
+extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
+extern void path_release(struct nameidata *);
+
+extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
+extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
+
+extern int follow_down(struct vfsmount **, struct dentry **);
+extern int follow_up(struct vfsmount **, struct dentry **);
+
+extern struct dentry *lock_rename(struct dentry *, struct dentry *);
+extern void unlock_rename(struct dentry *, struct dentry *);
+
+#endif /* _LINUX_NAMEI_H */
diff -Nru a/include/linux/netfilter.h b/include/linux/netfilter.h
--- a/include/linux/netfilter.h	Fri May 24 18:55:35 2002
+++ b/include/linux/netfilter.h	Fri May 24 18:55:35 2002
@@ -158,26 +158,5 @@
 #define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
 #endif /*CONFIG_NETFILTER*/
 
-/* From arch/i386/kernel/smp.c:
- *
- *	Why isn't this somewhere standard ??
- *
- * Maybe because this procedure is horribly buggy, and does
- * not deserve to live.  Think about signedness issues for five
- * seconds to see why.		- Linus
- */
-
-/* Two signed, return a signed. */
-#define SMAX(a,b) ((ssize_t)(a)>(ssize_t)(b) ? (ssize_t)(a) : (ssize_t)(b))
-#define SMIN(a,b) ((ssize_t)(a)<(ssize_t)(b) ? (ssize_t)(a) : (ssize_t)(b))
-
-/* Two unsigned, return an unsigned. */
-#define UMAX(a,b) ((size_t)(a)>(size_t)(b) ? (size_t)(a) : (size_t)(b))
-#define UMIN(a,b) ((size_t)(a)<(size_t)(b) ? (size_t)(a) : (size_t)(b))
-
-/* Two unsigned, return a signed. */
-#define SUMAX(a,b) ((size_t)(a)>(size_t)(b) ? (ssize_t)(a) : (ssize_t)(b))
-#define SUMIN(a,b) ((size_t)(a)<(size_t)(b) ? (ssize_t)(a) : (ssize_t)(b))
 #endif /*__KERNEL__*/
-
 #endif /*__LINUX_NETFILTER_H*/
diff -Nru a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
--- a/include/linux/nfs_fs.h	Fri May 24 18:55:35 2002
+++ b/include/linux/nfs_fs.h	Fri May 24 18:55:35 2002
@@ -234,12 +234,12 @@
 extern struct inode *nfs_fhget(struct dentry *, struct nfs_fh *,
 				struct nfs_fattr *);
 extern int __nfs_refresh_inode(struct inode *, struct nfs_fattr *);
-extern int nfs_revalidate(struct dentry *);
+extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
 extern int nfs_permission(struct inode *, int);
 extern int nfs_open(struct inode *, struct file *);
 extern int nfs_release(struct inode *, struct file *);
 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
-extern int nfs_notify_change(struct dentry *, struct iattr *);
+extern int nfs_setattr(struct dentry *, struct iattr *);
 
 /*
  * linux/fs/nfs/file.c
diff -Nru a/include/linux/page-flags.h b/include/linux/page-flags.h
--- a/include/linux/page-flags.h	Fri May 24 18:55:34 2002
+++ b/include/linux/page-flags.h	Fri May 24 18:55:34 2002
@@ -64,6 +64,7 @@
 
 #define PG_private		12	/* Has something at ->private */
 #define PG_writeback		13	/* Page is under writeback */
+#define PG_nosave		15	/* Used for system suspend/resume */
 
 /*
  * Global page accounting.  One instance per CPU.
@@ -206,6 +207,12 @@
 			dec_page_state(nr_writeback);			\
 		ret;							\
 	})
+
+#define PageNosave(page)	test_bit(PG_nosave, &(page)->flags)
+#define SetPageNosave(page)	set_bit(PG_nosave, &(page)->flags)
+#define TestSetPageNosave(page)	test_and_set_bit(PG_nosave, &(page)->flags)
+#define ClearPageNosave(page)		clear_bit(PG_nosave, &(page)->flags)
+#define TestClearPageNosave(page)	test_and_clear_bit(PG_nosave, &(page)->flags)
 
 /*
  * The PageSwapCache predicate doesn't use a PG_flag at this time,
diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
--- a/include/linux/pci_ids.h	Fri May 24 18:55:35 2002
+++ b/include/linux/pci_ids.h	Fri May 24 18:55:35 2002
@@ -1551,6 +1551,7 @@
 
 #define PCI_VENDOR_ID_ALTIMA		0x173b
 #define PCI_DEVICE_ID_ALTIMA_AC1000	0x03e8
+#define PCI_DEVICE_ID_ALTIMA_AC9100	0x03ea
 
 #define PCI_VENDOR_ID_SYMPHONY		0x1c1c
 #define PCI_DEVICE_ID_SYMPHONY_101	0x0001
diff -Nru a/include/linux/quota.h b/include/linux/quota.h
--- a/include/linux/quota.h	Fri May 24 18:55:34 2002
+++ b/include/linux/quota.h	Fri May 24 18:55:34 2002
@@ -184,20 +184,22 @@
 
 #define sb_dqopt(sb) (&(sb)->s_dquot)
 
-extern int nr_dquots, nr_free_dquots;
-
-struct dqstats {
-	__u32 lookups;
-	__u32 drops;
-	__u32 reads;
-	__u32 writes;
-	__u32 cache_hits;
-	__u32 allocated_dquots;
-	__u32 free_dquots;
-	__u32 syncs;
+/*
+ * Statistics about disc quota.
+ */
+enum {
+	DQSTATS_LOOKUPS,
+	DQSTATS_DROPS,
+	DQSTATS_READS,
+	DQSTATS_WRITES,
+	DQSTATS_CACHE_HITS,
+	DQSTATS_ALLOCATED,
+	DQSTATS_FREE,
+	DQSTATS_SYNCS,
+	DQSTATS_SIZE
 };
 
-extern struct dqstats dqstats;
+extern __u32 dqstats_array[DQSTATS_SIZE];
 
 #define NR_DQHASH 43            /* Just an arbitrary number */
 
diff -Nru a/include/linux/reboot.h b/include/linux/reboot.h
--- a/include/linux/reboot.h	Fri May 24 18:55:35 2002
+++ b/include/linux/reboot.h	Fri May 24 18:55:35 2002
@@ -20,6 +20,7 @@
  * CAD_OFF     Ctrl-Alt-Del sequence sends SIGINT to init task.
  * POWER_OFF   Stop OS and remove all power from system, if possible.
  * RESTART2    Restart system using given command string.
+ * SW_SUSPEND  Suspend system using Software Suspend if compiled in
  */
 
 #define	LINUX_REBOOT_CMD_RESTART	0x01234567
@@ -28,6 +29,7 @@
 #define	LINUX_REBOOT_CMD_CAD_OFF	0x00000000
 #define	LINUX_REBOOT_CMD_POWER_OFF	0x4321FEDC
 #define	LINUX_REBOOT_CMD_RESTART2	0xA1B2C3D4
+#define	LINUX_REBOOT_CMD_SW_SUSPEND	0xD000FCE2
 
 
 #ifdef __KERNEL__
@@ -45,6 +47,13 @@
 extern void machine_restart(char *cmd);
 extern void machine_halt(void);
 extern void machine_power_off(void);
+
+/*
+ * Architecture-independent suspend facility
+ */
+
+extern void software_suspend(void);
+extern unsigned char software_suspend_enabled;
 
 #endif
 
diff -Nru a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
--- a/include/linux/reiserfs_fs.h	Fri May 24 18:55:36 2002
+++ b/include/linux/reiserfs_fs.h	Fri May 24 18:55:36 2002
@@ -20,6 +20,7 @@
 #include <asm/unaligned.h>
 #include <linux/bitops.h>
 #include <linux/proc_fs.h>
+#include <linux/buffer_head.h>
 #include <linux/reiserfs_fs_i.h>
 #include <linux/reiserfs_fs_sb.h>
 #endif
@@ -1341,6 +1342,13 @@
   const void * vn_data;
   struct virtual_item * vn_vi;	/* array of items (including a new one, excluding item to be deleted) */
 };
+
+/* used by directory items when creating virtual nodes */
+struct direntry_uarea {
+    int flags;
+    __u16 entry_count;
+    __u16 entry_sizes[1];
+} __attribute__ ((__packed__)) ;
 
 
 /***************************************************************************/
diff -Nru a/include/linux/sched.h b/include/linux/sched.h
--- a/include/linux/sched.h	Fri May 24 18:55:33 2002
+++ b/include/linux/sched.h	Fri May 24 18:55:33 2002
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/times.h>
 #include <linux/timex.h>
+#include <linux/jiffies.h>
 #include <linux/rbtree.h>
 #include <linux/thread_info.h>
 
@@ -388,6 +389,11 @@
 #define PF_FLUSHER	0x00004000	/* responsible for disk writeback */
 #define PF_RADIX_TREE	0x00008000	/* debug: performing radix tree alloc */
 
+#define PF_FREEZE	0x00010000	/* this task should be frozen for suspend */
+#define PF_IOTHREAD	0x00020000	/* this thread is needed for doing I/O to swap */
+#define PF_KERNTHREAD	0x00040000	/* this thread is a kernel thread that cannot be sent signals to */
+#define PF_FROZEN	0x00080000	/* frozen for system suspend */
+
 /*
  * Ptrace flags
  */
@@ -476,12 +482,6 @@
 
 #include <asm/current.h>
 
-/*
- * The 64-bit value is not volatile - you MUST NOT read it
- * without holding read_lock_irq(&xtime_lock)
- */
-extern u64 jiffies_64;
-extern unsigned long volatile jiffies;
 extern unsigned long itimer_ticks;
 extern unsigned long itimer_next;
 extern void do_timer(struct pt_regs *);
diff -Nru a/include/linux/seq_file.h b/include/linux/seq_file.h
--- a/include/linux/seq_file.h	Fri May 24 18:55:35 2002
+++ b/include/linux/seq_file.h	Fri May 24 18:55:35 2002
@@ -58,5 +58,7 @@
 int seq_printf(struct seq_file *, const char *, ...)
 	__attribute__ ((format (printf,2,3)));
 
+int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
+int single_release(struct inode *, struct file *);
 #endif
 #endif
diff -Nru a/include/linux/smp.h b/include/linux/smp.h
--- a/include/linux/smp.h	Fri May 24 18:55:36 2002
+++ b/include/linux/smp.h	Fri May 24 18:55:36 2002
@@ -96,5 +96,9 @@
 #define per_cpu(var, cpu)			var
 #define this_cpu(var)				var
 
-#endif
-#endif
+#endif /* !SMP */
+
+#define get_cpu()	({ preempt_disable(); smp_processor_id(); })
+#define put_cpu()	preempt_enable()
+
+#endif /* __LINUX_SMP_H */
diff -Nru a/include/linux/suspend.h b/include/linux/suspend.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/suspend.h	Fri May 24 18:55:36 2002
@@ -0,0 +1,67 @@
+#ifndef _LINUX_SWSUSP_H
+#define _LINUX_SWSUSP_H
+
+#include <asm/suspend.h>
+#include <linux/swap.h>
+#include <linux/notifier.h>
+#include <linux/config.h>
+
+extern unsigned char software_suspend_enabled;
+
+#define NORESUME	 1
+#define RESUME_SPECIFIED 2
+
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/* page backup entry */
+typedef struct pbe {
+	unsigned long address;		/* address of the copy */
+	unsigned long orig_address;	/* original address of page */
+	swp_entry_t swap_address;	
+	swp_entry_t dummy;		/* we need scratch space at 
+					 * end of page (see link, diskpage)
+					 */
+} suspend_pagedir_t;
+
+#define SWAP_FILENAME_MAXLENGTH	32
+
+struct suspend_header {
+	__u32 version_code;
+	unsigned long num_physpages;
+	char machine[8];
+	char version[20];
+	int num_cpus;
+	int page_size;
+	unsigned long suspend_pagedir;
+	unsigned int num_pbes;
+	struct swap_location {
+		char filename[SWAP_FILENAME_MAXLENGTH];
+	} swap_location[MAX_SWAPFILES];
+};
+
+#define SUSPEND_PD_PAGES(x)     (((x)*sizeof(struct pbe))/PAGE_SIZE+1)
+   
+extern struct tq_struct suspend_tq;
+
+/* mm/vmscan.c */
+extern int shrink_mem(void);
+
+/* kernel/suspend.c */
+extern void software_suspend(void);
+extern void software_resume(void);
+extern int resume_setup(char *str);
+
+extern int register_suspend_notifier(struct notifier_block *);
+extern int unregister_suspend_notifier(struct notifier_block *);
+extern void refrigerator(unsigned long);
+
+#else
+#define software_suspend()		do { } while(0)
+#define software_resume()		do { } while(0)
+#define register_suspend_notifier(a)	do { } while(0)
+#define unregister_suspend_notifier(a)	do { } while(0)
+#define refrigerator(a)			do { BUG(); } while(0)
+#define freeze_processes()		do { panic("You need CONFIG_SOFTWARE_SUSPEND to do sleeps."); } while(0)
+#define thaw_processes()		do { } while(0)
+#endif
+
+#endif /* _LINUX_SWSUSP_H */
diff -Nru a/include/linux/swap.h b/include/linux/swap.h
--- a/include/linux/swap.h	Fri May 24 18:55:33 2002
+++ b/include/linux/swap.h	Fri May 24 18:55:33 2002
@@ -102,12 +102,8 @@
 extern unsigned int nr_free_pages(void);
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
-extern unsigned long nr_buffermem_pages(void);
 extern int nr_active_pages;
 extern int nr_inactive_pages;
-extern atomic_t nr_async_pages;
-extern atomic_t buffermem_pages;
-extern spinlock_t pagecache_lock;
 extern void __remove_inode_page(struct page *);
 
 /* Incomplete types for prototype declarations: */
diff -Nru a/include/linux/sysctl.h b/include/linux/sysctl.h
--- a/include/linux/sysctl.h	Fri May 24 18:55:33 2002
+++ b/include/linux/sysctl.h	Fri May 24 18:55:33 2002
@@ -544,6 +544,7 @@
 	FS_LEASES=13,	/* int: leases enabled */
 	FS_DIR_NOTIFY=14,	/* int: directory notification enabled */
 	FS_LEASE_TIME=15,	/* int: maximum time to wait for a lease break */
+	FS_DQSTATS=16,	/* int: disc quota suage statistics */
 };
 
 /* CTL_DEBUG names: */
diff -Nru a/include/linux/timer.h b/include/linux/timer.h
--- a/include/linux/timer.h	Fri May 24 18:55:34 2002
+++ b/include/linux/timer.h	Fri May 24 18:55:34 2002
@@ -52,23 +52,4 @@
 	return timer->list.next != NULL;
 }
 
-/*
- *	These inlines deal with timer wrapping correctly. You are 
- *	strongly encouraged to use them
- *	1. Because people otherwise forget
- *	2. Because if the timer wrap changes in future you wont have to
- *	   alter your driver code.
- *
- * time_after(a,b) returns true if the time a is after time b.
- *
- * Do this with "<0" and ">=0" to only test the sign of the result. A
- * good compiler would generate better code (and a really good compiler
- * wouldn't care). Gcc is currently neither.
- */
-#define time_after(a,b)		((long)(b) - (long)(a) < 0)
-#define time_before(a,b)	time_after(b,a)
-
-#define time_after_eq(a,b)	((long)(a) - (long)(b) >= 0)
-#define time_before_eq(a,b)	time_after_eq(b,a)
-
 #endif
diff -Nru a/include/linux/tqueue.h b/include/linux/tqueue.h
--- a/include/linux/tqueue.h	Fri May 24 18:55:33 2002
+++ b/include/linux/tqueue.h	Fri May 24 18:55:33 2002
@@ -66,7 +66,7 @@
 #define DECLARE_TASK_QUEUE(q)	LIST_HEAD(q)
 #define TQ_ACTIVE(q)		(!list_empty(&q))
 
-extern task_queue tq_timer, tq_immediate, tq_disk;
+extern task_queue tq_timer, tq_immediate, tq_disk, tq_bdflush;
 
 /*
  * To implement your own list of active bottom halfs, use the following
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h	Fri May 24 18:55:35 2002
+++ b/include/linux/usb.h	Fri May 24 18:55:35 2002
@@ -1,9 +1,6 @@
 #ifndef __LINUX_USB_H
 #define __LINUX_USB_H
 
-#include <linux/device.h>
-#include <linux/errno.h>
-
 /* USB constants */
 
 /*
@@ -19,8 +16,8 @@
 #define USB_CLASS_MASS_STORAGE		8
 #define USB_CLASS_HUB			9
 #define USB_CLASS_CDC_DATA		0x0a
-#define USB_CLASS_CSCID		0x0b /* chip+ smart card */
-#define USB_CLASS_CONTENT_SEC		0x0d /* content security */
+#define USB_CLASS_CSCID			0x0b	/* chip+ smart card */
+#define USB_CLASS_CONTENT_SEC		0x0d	/* content security */
 #define USB_CLASS_APP_SPEC		0xfe
 #define USB_CLASS_VENDOR_SPEC		0xff
 
@@ -63,23 +60,23 @@
 /*
  * USB Packet IDs (PIDs)
  */
-#define USB_PID_UNDEF_0                        0xf0
-#define USB_PID_OUT                            0xe1
-#define USB_PID_ACK                            0xd2
-#define USB_PID_DATA0                          0xc3
-#define USB_PID_PING                           0xb4	/* USB 2.0 */
-#define USB_PID_SOF                            0xa5
-#define USB_PID_NYET                           0x96	/* USB 2.0 */
-#define USB_PID_DATA2                          0x87	/* USB 2.0 */
-#define USB_PID_SPLIT                          0x78	/* USB 2.0 */
-#define USB_PID_IN                             0x69
-#define USB_PID_NAK                            0x5a
-#define USB_PID_DATA1                          0x4b
-#define USB_PID_PREAMBLE                       0x3c	/* Token mode */
-#define USB_PID_ERR                            0x3c	/* USB 2.0: handshake mode */
-#define USB_PID_SETUP                          0x2d
-#define USB_PID_STALL                          0x1e
-#define USB_PID_MDATA                          0x0f	/* USB 2.0 */
+#define USB_PID_UNDEF_0			0xf0
+#define USB_PID_OUT			0xe1
+#define USB_PID_ACK			0xd2
+#define USB_PID_DATA0			0xc3
+#define USB_PID_PING			0xb4	/* USB 2.0 */
+#define USB_PID_SOF			0xa5
+#define USB_PID_NYET			0x96	/* USB 2.0 */
+#define USB_PID_DATA2			0x87	/* USB 2.0 */
+#define USB_PID_SPLIT			0x78	/* USB 2.0 */
+#define USB_PID_IN			0x69
+#define USB_PID_NAK			0x5a
+#define USB_PID_DATA1			0x4b
+#define USB_PID_PREAMBLE		0x3c	/* Token mode */
+#define USB_PID_ERR			0x3c	/* USB 2.0: handshake mode */
+#define USB_PID_SETUP			0x2d
+#define USB_PID_STALL			0x1e
+#define USB_PID_MDATA			0x0f	/* USB 2.0 */
 
 /*
  * Standard requests
@@ -96,19 +93,18 @@
 #define USB_REQ_SET_INTERFACE		0x0B
 #define USB_REQ_SYNCH_FRAME		0x0C
 
+#define USB_MAJOR			180
+
 
 #ifdef __KERNEL__
 
-#include <linux/types.h>
-#include <linux/ioctl.h>
-#include <linux/version.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>	/* for in_interrupt() */
 #include <linux/config.h>
-#include <linux/list.h>
+#include <linux/errno.h>        /* for -ENODEV */
+#include <linux/delay.h>	/* for mdelay() */
+#include <linux/interrupt.h>	/* for in_interrupt() */
+#include <linux/list.h>		/* for struct list_head */
+#include <linux/device.h>	/* for struct device */
 
-#define USB_MAJOR 180
 
 static __inline__ void wait_ms(unsigned int ms)
 {
@@ -184,11 +180,11 @@
 #define USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */
 
 /* most of these maximums are arbitrary */
-#define USB_MAXCONFIG		8
-#define USB_ALTSETTINGALLOC     4
-#define USB_MAXALTSETTING	128  /* Hard limit */
-#define USB_MAXINTERFACES	32
-#define USB_MAXENDPOINTS	32   /* Hard limit */
+#define USB_MAXCONFIG			8
+#define USB_ALTSETTINGALLOC		4
+#define USB_MAXALTSETTING		128	/* Hard limit */
+#define USB_MAXINTERFACES		32
+#define USB_MAXENDPOINTS		32	/* Hard limit */
 
 /* All standard descriptors have these 2 fields in common */
 struct usb_descriptor_header {
@@ -226,7 +222,7 @@
 	__u8  bSynchAddress	__attribute__ ((packed));
 
 	/* the rest is internal to the Linux implementation */
-   	unsigned char *extra;   /* Extra descriptors */
+	unsigned char *extra;   /* Extra descriptors */
 	int extralen;
 };
 
@@ -243,9 +239,9 @@
 	__u8  iInterface	__attribute__ ((packed));
 
 	/* the rest is internal to the Linux implementation */
-  	struct usb_endpoint_descriptor *endpoint;
+	struct usb_endpoint_descriptor *endpoint;
 
-   	unsigned char *extra;   /* Extra descriptors */
+	unsigned char *extra;   /* Extra descriptors */
 	int extralen;
 };
 
@@ -254,7 +250,7 @@
 
 	int act_altsetting;		/* active alternate setting */
 	int num_altsetting;		/* number of alternate settings */
-	int max_altsetting;             /* total memory allocated */
+	int max_altsetting;		/* total memory allocated */
  
 	struct usb_driver *driver;	/* driver */
 	struct device dev;		/* interface specific device info */
@@ -281,7 +277,7 @@
 	/* the rest is internal to the Linux implementation */
 	struct usb_interface *interface;
 
-   	unsigned char *extra;   /* Extra descriptors */
+	unsigned char *extra;   /* Extra descriptors */
 	int extralen;
 };
 
@@ -334,12 +330,12 @@
 	char *bus_name;			/* stable id (PCI slot_name etc) */
 
 #ifdef DEVNUM_ROUND_ROBIN
-	int devnum_next;                /* Next open device number in round-robin allocation */
+	int devnum_next;		/* Next open device number in round-robin allocation */
 #endif /* DEVNUM_ROUND_ROBIN */
 
-	struct usb_devmap devmap;       /* device address allocation map */
-	struct usb_operations *op;      /* Operations (specific to the HC) */
-	struct usb_device *root_hub;    /* Root hub */
+	struct usb_devmap devmap;	/* device address allocation map */
+	struct usb_operations *op;	/* Operations (specific to the HC) */
+	struct usb_device *root_hub;	/* Root hub */
 	struct list_head bus_list;	/* list of busses */
 	void *hcpriv;                   /* Host Controller private data */
 
@@ -408,7 +404,7 @@
 
 	int have_langid;		/* whether string_langid is valid yet */
 	int string_langid;		/* language ID for strings */
-  
+
 	void *hcpriv;			/* Host Controller private data */
 	
 	struct list_head filelist;
@@ -467,7 +463,7 @@
  * in host controller driver modules, does not change these path identifers;
  * neither does rebooting or re-enumerating.  These are more useful identifiers
  * than changeable ("unstable") ones like bus numbers or device addresses.
- * 
+ *
  * With a partial exception for devices connected to USB 2.0 root hubs, these
  * identifiers are also predictable:  so long as the device tree isn't changed,
  * plugging any USB device into a given hub port always gives it the same path.
@@ -492,7 +488,7 @@
  * The third probe() parameter will point to a matching entry from this
  * table.  (Null value reserved.)  Use the driver_data field for each
  * match to hold information tied to that match:  device quirks, etc.
- * 
+ *
  * Terminate the driver's table with an all-zeroes entry.
  * Use the flag values to control which fields are compared.
  */
@@ -743,12 +739,12 @@
  *
  * FIXME should be URB_* flags
  */
-#define USB_DISABLE_SPD         0x0001
-#define USB_ISO_ASAP            0x0002
-#define USB_ASYNC_UNLINK        0x0008
-#define USB_QUEUE_BULK          0x0010
+#define USB_DISABLE_SPD		0x0001
+#define USB_ISO_ASAP		0x0002
+#define USB_ASYNC_UNLINK	0x0008
+#define USB_QUEUE_BULK		0x0010
 #define USB_NO_FSBR		0x0020
-#define USB_ZERO_PACKET         0x0040  /* Finish bulk OUTs with short packet */
+#define USB_ZERO_PACKET		0x0040	/* Finish bulk OUTs with short packet */
 #define URB_NO_INTERRUPT	0x0080	/* HINT: no non-error interrupt needed */
 					/* ... less overhead for QUEUE_BULK */
 #define USB_TIMEOUT_KILLED	0x1000	/* only set by HCD! */
@@ -767,7 +763,6 @@
 /**
  * struct urb - USB Request Block
  * @urb_list: For use by current owner of the URB.
- * @next: Used to link ISO requests into rings.
  * @pipe: Holds endpoint number, direction, type, and max packet size.
  *	Create these values with the eight macros available;
  *	usb_{snd,rcv}TYPEpipe(dev,endpoint), where the type is "ctrl"
@@ -827,7 +822,7 @@
  *
  * Initialization:
  *
- * All URBs submitted must initialize dev, pipe, next (may be null),
+ * All URBs submitted must initialize dev, pipe,
  * transfer_flags (may be zero), complete, timeout (may be zero).
  * The USB_ASYNC_UNLINK transfer flag affects later invocations of
  * the usb_unlink_urb() routine.
@@ -873,7 +868,9 @@
  * the quality of service is only "best effort".  Callers provide specially
  * allocated URBs, with number_of_packets worth of iso_frame_desc structures
  * at the end.  Each such packet is an individual ISO transfer.  Isochronous
- * URBs are normally submitted with urb->next fields set up as a ring, so
+ * URBs are normally queued (no flag like USB_BULK_QUEUE is needed) so that
+ * transfers are at least double buffered, and then explicitly resubmitted
+ * in completion handlers, so
  * that data (such as audio or video) streams at as constant a rate as the
  * host controller scheduler can support.
  *
@@ -891,14 +888,15 @@
  * When completion callback is invoked for non-isochronous URBs, the
  * actual_length field tells how many bytes were transferred.
  *
- * For interrupt and isochronous URBs, the URB provided to the callback
+ * For interrupt URBs, the URB provided to the callback
  * function is still "owned" by the USB core subsystem unless the status
  * indicates that the URB has been unlinked.  Completion handlers should
  * not modify such URBs until they have been unlinked.
  *
  * ISO transfer status is reported in the status and actual_length fields
  * of the iso_frame_desc array, and the number of errors is reported in
- * error_count.
+ * error_count.  Completion callbacks for ISO transfers will normally
+ * (re)submit URBs to ensure a constant transfer rate.
  */
 struct urb
 {
@@ -906,19 +904,18 @@
 	atomic_t count;			/* reference count of the URB */
 	void *hcpriv;			/* private data for host controller */
 	struct list_head urb_list;	/* list pointer to all active urbs */
-	struct urb *next; 		/* (in) pointer to next URB */
 	struct usb_device *dev; 	/* (in) pointer to associated device */
 	unsigned int pipe;		/* (in) pipe information */
 	int status;			/* (return) non-ISO status */
 	unsigned int transfer_flags;	/* (in) USB_DISABLE_SPD | ...*/
 	void *transfer_buffer;		/* (in) associated data buffer */
 	int transfer_buffer_length;	/* (in) data buffer length */
-	int actual_length;              /* (return) actual transfer length */
+	int actual_length;		/* (return) actual transfer length */
 	int bandwidth;			/* bandwidth for INT/ISO request */
 	unsigned char *setup_packet;	/* (in) setup packet (control only) */
 	int start_frame;		/* (modify) start frame (INT/ISO) */
 	int number_of_packets;		/* (in) number of ISO packets */
-	int interval;                   /* (in) transfer interval (INT/ISO) */
+	int interval;			/* (in) transfer interval (INT/ISO) */
 	int error_count;		/* (return) number of ISO errors */
 	int timeout;			/* (in) timeout, in jiffies */
 	void *context;			/* (in) context for completion */
@@ -979,7 +976,6 @@
 				      int buffer_length,
 				      usb_complete_t complete,
 				      void *context)
-				      
 {
 	spin_lock_init(&urb->lock);
 	urb->dev = dev;
@@ -989,7 +985,7 @@
 	urb->complete = complete;
 	urb->context = context;
 }
-    
+
 /**
  * usb_fill_int_urb - macro to help initialize a interrupt urb
  * @urb: pointer to the urb to initialize.
@@ -1079,12 +1075,12 @@
  * they typically complete within a few frames (msec) after they're issued
  */
 #ifdef CONFIG_USB_LONG_TIMEOUT
-#define USB_CTRL_GET_TIMEOUT 4
+#define USB_CTRL_GET_TIMEOUT	4
 #else
-#define USB_CTRL_GET_TIMEOUT 3
+#define USB_CTRL_GET_TIMEOUT	3
 #endif
 
-#define USB_CTRL_SET_TIMEOUT 3
+#define USB_CTRL_SET_TIMEOUT	3
 
 /* -------------------------------------------------------------------------- */
 
diff -Nru a/include/linux/uts.h b/include/linux/uts.h
--- a/include/linux/uts.h	Fri May 24 18:55:34 2002
+++ b/include/linux/uts.h	Fri May 24 18:55:34 2002
@@ -8,10 +8,6 @@
 #define UTS_SYSNAME "Linux"
 #endif
 
-#ifndef UTS_MACHINE
-#define UTS_MACHINE "unknown"
-#endif
-
 #ifndef UTS_NODENAME
 #define UTS_NODENAME "(none)"	/* set by sethostname() */
 #endif
diff -Nru a/include/net/inetpeer.h b/include/net/inetpeer.h
--- a/include/net/inetpeer.h	Fri May 24 18:55:33 2002
+++ b/include/net/inetpeer.h	Fri May 24 18:55:33 2002
@@ -11,7 +11,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
 
diff -Nru a/init/do_mounts.c b/init/do_mounts.c
--- a/init/do_mounts.c	Fri May 24 18:55:35 2002
+++ b/init/do_mounts.c	Fri May 24 18:55:35 2002
@@ -10,6 +10,7 @@
 #include <linux/fd.h>
 #include <linux/tty.h>
 #include <linux/init.h>
+#include <linux/suspend.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -825,6 +826,11 @@
 #endif
 
 	create_dev("/dev/root", ROOT_DEV, NULL);
+
+	/* This has to be before mounting root, because even readonly mount of reiserfs would replay
+	   log corrupting stuff */
+	software_resume();
+
 	if (mount_initrd) {
 		if (initrd_load() && !kdev_same(ROOT_DEV, mk_kdev(RAMDISK_MAJOR, 0))) {
 			handle_initrd();
diff -Nru a/init/main.c b/init/main.c
--- a/init/main.c	Fri May 24 18:55:34 2002
+++ b/init/main.c	Fri May 24 18:55:34 2002
@@ -68,6 +68,7 @@
 extern void sbus_init(void);
 extern void sysctl_init(void);
 extern void signals_init(void);
+extern void buffer_init(void);
 
 extern void radix_tree_init(void);
 extern void free_initmem(void);
diff -Nru a/init/version.c b/init/version.c
--- a/init/version.c	Fri May 24 18:55:35 2002
+++ b/init/version.c	Fri May 24 18:55:35 2002
@@ -6,10 +6,10 @@
  *  May be freely distributed as part of Linux.
  */
 
+#include <linux/compile.h>
 #include <linux/uts.h>
 #include <linux/utsname.h>
 #include <linux/version.h>
-#include <linux/compile.h>
 
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile	Fri May 24 18:55:34 2002
+++ b/kernel/Makefile	Fri May 24 18:55:34 2002
@@ -10,7 +10,7 @@
 O_TARGET := kernel.o
 
 export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \
-		printk.o platform.o 
+		printk.o platform.o suspend.o
 
 obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
 	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
@@ -21,6 +21,7 @@
 obj-$(CONFIG_MODULES) += ksyms.o
 obj-$(CONFIG_PM) += pm.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
+obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o
 
 ifneq ($(CONFIG_IA64),y)
 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff -Nru a/kernel/context.c b/kernel/context.c
--- a/kernel/context.c	Fri May 24 18:55:35 2002
+++ b/kernel/context.c	Fri May 24 18:55:35 2002
@@ -72,6 +72,7 @@
 
 	daemonize();
 	strcpy(curtask->comm, "keventd");
+	current->flags |= PF_IOTHREAD;
 	keventd_running = 1;
 	keventd_task = curtask;
 
diff -Nru a/kernel/futex.c b/kernel/futex.c
--- a/kernel/futex.c	Fri May 24 18:55:34 2002
+++ b/kernel/futex.c	Fri May 24 18:55:34 2002
@@ -32,7 +32,8 @@
 #include <linux/fs.h>
 #include <linux/futex.h>
 #include <linux/highmem.h>
-#include <asm/atomic.h>
+#include <linux/time.h>
+#include <asm/uaccess.h>
 
 /* These mutexes are a very simple counter: the winner is the one who
    decrements from 1 to 0.  The counter starts at 1 when the lock is
@@ -68,22 +69,27 @@
 	return &futex_queues[hash_long(h, FUTEX_HASHBITS)];
 }
 
-static inline void wake_one_waiter(struct list_head *head,
-				   struct page *page,
-				   unsigned int offset)
+static int futex_wake(struct list_head *head,
+		      struct page *page,
+		      unsigned int offset,
+		      int num)
 {
-	struct list_head *i;
+	struct list_head *i, *next;
+	int num_woken = 0;
 
 	spin_lock(&futex_lock);
-	list_for_each(i, head) {
+	list_for_each_safe(i, next, head) {
 		struct futex_q *this = list_entry(i, struct futex_q, list);
 
 		if (this->page == page && this->offset == offset) {
+			list_del_init(i);
 			wake_up_process(this->task);
-			break;
+			num_woken++;
+			if (num_woken >= num) break;
 		}
 	}
 	spin_unlock(&futex_lock);
+	return num_woken;
 }
 
 /* Add at end to avoid starvation */
@@ -101,11 +107,17 @@
 	spin_unlock(&futex_lock);
 }
 
-static inline void unqueue_me(struct futex_q *q)
+/* Return 1 if we were still queued (ie. 0 means we were woken) */
+static inline int unqueue_me(struct futex_q *q)
 {
+	int ret = 0;
 	spin_lock(&futex_lock);
-	list_del(&q->list);
+	if (!list_empty(&q->list)) {
+		list_del(&q->list);
+		ret = 1;
+	}
 	spin_unlock(&futex_lock);
+	return ret;
 }
 
 /* Get kernel address of the user page and pin it. */
@@ -129,74 +141,65 @@
 	return page;
 }
 
-/* Try to decrement the user count to zero. */
-static int decrement_to_zero(struct page *page, unsigned int offset)
-{
-	atomic_t *count;
-	int ret = 0;
-
-	count = kmap(page) + offset;
-	/* If we take the semaphore from 1 to 0, it's ours.  If it's
-           zero, decrement anyway, to indicate we are waiting.  If
-           it's negative, don't decrement so we don't wrap... */
-	if (atomic_read(count) >= 0 && atomic_dec_and_test(count))
-		ret = 1;
-	kunmap(page);
-	return ret;
-}
-
-/* Simplified from arch/ppc/kernel/semaphore.c: Paul M. is a genius. */
-static int futex_down(struct list_head *head, struct page *page, int offset)
+static int futex_wait(struct list_head *head,
+		      struct page *page,
+		      int offset,
+		      int val,
+		      int *uaddr,
+		      unsigned long time)
 {
-	int retval = 0;
+	int curval;
 	struct futex_q q;
+	int ret = 0;
 
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	queue_me(head, &q, page, offset);
 
-	while (!decrement_to_zero(page, offset)) {
-		if (signal_pending(current)) {
-			retval = -EINTR;
-			break;
-		}
-		schedule();
-		current->state = TASK_INTERRUPTIBLE;
+	/* Page is pinned, can't fail */
+	if (get_user(curval, uaddr) != 0)
+		BUG();
+
+	if (curval != val) {
+		ret = -EWOULDBLOCK;
+		set_current_state(TASK_RUNNING);
+		goto out;
 	}
-	current->state = TASK_RUNNING;
-	unqueue_me(&q);
-	/* If we were signalled, we might have just been woken: we
-	   must wake another one.  Otherwise we need to wake someone
-	   else (if they are waiting) so they drop the count below 0,
-	   and when we "up" in userspace, we know there is a
-	   waiter. */
-	wake_one_waiter(head, page, offset);
-	return retval;
-}
-
-static int futex_up(struct list_head *head, struct page *page, int offset)
-{
-	atomic_t *count;
-
-	count = kmap(page) + offset;
-	atomic_set(count, 1);
-	smp_wmb();
-	kunmap(page);
-	wake_one_waiter(head, page, offset);
-	return 0;
+	time = schedule_timeout(time);
+	if (time == 0) {
+		ret = -ETIMEDOUT;
+		goto out;
+	}
+	if (signal_pending(current)) {
+		ret = -EINTR;
+		goto out;
+	}
+ out:
+	/* Were we woken up anyway? */
+	if (!unqueue_me(&q))
+		return 0;
+	return ret;
 }
 
-asmlinkage int sys_futex(void *uaddr, int op)
+asmlinkage int sys_futex(void *uaddr, int op, int val, struct timespec *utime)
 {
 	int ret;
 	unsigned long pos_in_page;
 	struct list_head *head;
 	struct page *page;
+	unsigned long time = MAX_SCHEDULE_TIMEOUT;
+
+	if (utime) {
+		struct timespec t;
+		if (copy_from_user(&t, utime, sizeof(t)) != 0)
+			return -EFAULT;
+		time = timespec_to_jiffies(&t) + 1;
+	}
 
 	pos_in_page = ((unsigned long)uaddr) % PAGE_SIZE;
 
 	/* Must be "naturally" aligned, and not on page boundary. */
-	if ((pos_in_page % __alignof__(atomic_t)) != 0
-	    || pos_in_page + sizeof(atomic_t) > PAGE_SIZE)
+	if ((pos_in_page % __alignof__(int)) != 0
+	    || pos_in_page + sizeof(int) > PAGE_SIZE)
 		return -EINVAL;
 
 	/* Simpler if it doesn't vanish underneath us. */
@@ -206,13 +209,12 @@
 
 	head = hash_futex(page, pos_in_page);
 	switch (op) {
-	case FUTEX_UP:
-		ret = futex_up(head, page, pos_in_page);
+	case FUTEX_WAIT:
+		ret = futex_wait(head, page, pos_in_page, val, uaddr, time);
 		break;
-	case FUTEX_DOWN:
-		ret = futex_down(head, page, pos_in_page);
+	case FUTEX_WAKE:
+		ret = futex_wake(head, page, pos_in_page, val);
 		break;
-	/* Add other lock types here... */
 	default:
 		ret = -EINVAL;
 	}
diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
--- a/kernel/ksyms.c	Fri May 24 18:55:33 2002
+++ b/kernel/ksyms.c	Fri May 24 18:55:33 2002
@@ -47,6 +47,8 @@
 #include <linux/completion.h>
 #include <linux/seq_file.h>
 #include <linux/binfmts.h>
+#include <linux/namei.h>
+#include <linux/buffer_head.h>
 #include <asm/checksum.h>
 
 #if defined(CONFIG_PROC_FS)
@@ -258,6 +260,7 @@
 EXPORT_SYMBOL(lock_rename);
 EXPORT_SYMBOL(unlock_rename);
 EXPORT_SYMBOL(generic_read_dir);
+EXPORT_SYMBOL(generic_fillattr);
 EXPORT_SYMBOL(generic_file_llseek);
 EXPORT_SYMBOL(remote_llseek);
 EXPORT_SYMBOL(no_llseek);
@@ -280,6 +283,9 @@
 EXPORT_SYMBOL(lease_get_mtime);
 EXPORT_SYMBOL(lock_may_read);
 EXPORT_SYMBOL(lock_may_write);
+EXPORT_SYMBOL(dcache_dir_open);
+EXPORT_SYMBOL(dcache_dir_close);
+EXPORT_SYMBOL(dcache_dir_lseek);
 EXPORT_SYMBOL(dcache_readdir);
 EXPORT_SYMBOL(simple_statfs);
 EXPORT_SYMBOL(simple_lookup);
@@ -518,6 +524,8 @@
 EXPORT_SYMBOL(seq_release);
 EXPORT_SYMBOL(seq_read);
 EXPORT_SYMBOL(seq_lseek);
+EXPORT_SYMBOL(single_open);
+EXPORT_SYMBOL(single_release);
 
 /* Program loader interfaces */
 EXPORT_SYMBOL(setup_arg_pages);
@@ -568,8 +576,6 @@
 EXPORT_SYMBOL(strsep);
 
 /* software interrupts */
-EXPORT_SYMBOL(tasklet_hi_vec);
-EXPORT_SYMBOL(tasklet_vec);
 EXPORT_SYMBOL(bh_task_vec);
 EXPORT_SYMBOL(init_bh);
 EXPORT_SYMBOL(remove_bh);
diff -Nru a/kernel/signal.c b/kernel/signal.c
--- a/kernel/signal.c	Fri May 24 18:55:35 2002
+++ b/kernel/signal.c	Fri May 24 18:55:35 2002
@@ -493,7 +493,7 @@
  * No need to set need_resched since signal event passing
  * goes through ->blocked
  */
-static inline void signal_wake_up(struct task_struct *t)
+inline void signal_wake_up(struct task_struct *t)
 {
 	set_tsk_thread_flag(t,TIF_SIGPENDING);
 
diff -Nru a/kernel/softirq.c b/kernel/softirq.c
--- a/kernel/softirq.c	Fri May 24 18:55:34 2002
+++ b/kernel/softirq.c	Fri May 24 18:55:34 2002
@@ -16,6 +16,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/tqueue.h>
+#include <linux/percpu.h>
 
 /*
    - No shared variables, all the data are CPU local.
@@ -145,42 +146,43 @@
 
 
 /* Tasklets */
+struct tasklet_head
+{
+	struct tasklet_struct *list;
+};
 
-struct tasklet_head tasklet_vec[NR_CPUS] __cacheline_aligned_in_smp;
-struct tasklet_head tasklet_hi_vec[NR_CPUS] __cacheline_aligned_in_smp;
+static struct tasklet_head tasklet_vec __per_cpu_data;
+static struct tasklet_head tasklet_hi_vec __per_cpu_data;
 
 void __tasklet_schedule(struct tasklet_struct *t)
 {
-	int cpu = smp_processor_id();
 	unsigned long flags;
 
 	local_irq_save(flags);
-	t->next = tasklet_vec[cpu].list;
-	tasklet_vec[cpu].list = t;
-	cpu_raise_softirq(cpu, TASKLET_SOFTIRQ);
+	t->next = this_cpu(tasklet_vec).list;
+	this_cpu(tasklet_vec).list = t;
+	cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ);
 	local_irq_restore(flags);
 }
 
 void __tasklet_hi_schedule(struct tasklet_struct *t)
 {
-	int cpu = smp_processor_id();
 	unsigned long flags;
 
 	local_irq_save(flags);
-	t->next = tasklet_hi_vec[cpu].list;
-	tasklet_hi_vec[cpu].list = t;
-	cpu_raise_softirq(cpu, HI_SOFTIRQ);
+	t->next = this_cpu(tasklet_hi_vec).list;
+	this_cpu(tasklet_hi_vec).list = t;
+	cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ);
 	local_irq_restore(flags);
 }
 
 static void tasklet_action(struct softirq_action *a)
 {
-	int cpu = smp_processor_id();
 	struct tasklet_struct *list;
 
 	local_irq_disable();
-	list = tasklet_vec[cpu].list;
-	tasklet_vec[cpu].list = NULL;
+	list = this_cpu(tasklet_vec).list;
+	this_cpu(tasklet_vec).list = NULL;
 	local_irq_enable();
 
 	while (list) {
@@ -200,21 +202,20 @@
 		}
 
 		local_irq_disable();
-		t->next = tasklet_vec[cpu].list;
-		tasklet_vec[cpu].list = t;
-		__cpu_raise_softirq(cpu, TASKLET_SOFTIRQ);
+		t->next = this_cpu(tasklet_vec).list;
+		this_cpu(tasklet_vec).list = t;
+		__cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ);
 		local_irq_enable();
 	}
 }
 
 static void tasklet_hi_action(struct softirq_action *a)
 {
-	int cpu = smp_processor_id();
 	struct tasklet_struct *list;
 
 	local_irq_disable();
-	list = tasklet_hi_vec[cpu].list;
-	tasklet_hi_vec[cpu].list = NULL;
+	list = this_cpu(tasklet_hi_vec).list;
+	this_cpu(tasklet_hi_vec).list = NULL;
 	local_irq_enable();
 
 	while (list) {
@@ -234,9 +235,9 @@
 		}
 
 		local_irq_disable();
-		t->next = tasklet_hi_vec[cpu].list;
-		tasklet_hi_vec[cpu].list = t;
-		__cpu_raise_softirq(cpu, HI_SOFTIRQ);
+		t->next = this_cpu(tasklet_hi_vec).list;
+		this_cpu(tasklet_hi_vec).list = t;
+		__cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ);
 		local_irq_enable();
 	}
 }
@@ -365,6 +366,7 @@
 
 	daemonize();
 	set_user_nice(current, 19);
+	current->flags |= PF_IOTHREAD;
 	sigfillset(&current->blocked);
 
 	/* Migrate to the right CPU */
diff -Nru a/kernel/suspend.c b/kernel/suspend.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/kernel/suspend.c	Fri May 24 18:55:36 2002
@@ -0,0 +1,1256 @@
+/*
+ * linux/kernel/swsusp.c
+ *
+ * This file is to realize architecture-independent
+ * machine suspend feature using pretty near only high-level routines
+ *
+ * Copyright (C) 1998-2001 Gabor Kuti <seasons@fornax.hu>
+ * Copyright (C) 1998,2001,2002 Pavel Machek <pavel@suse.cz>
+ *
+ * I'd like to thank the following people for their work:
+ * 
+ * Pavel Machek <pavel@ucw.cz>:
+ * Modifications, defectiveness pointing, being with me at the very beginning,
+ * suspend to swap space, stop all tasks. Port to 2.4.18-ac and 2.5.17.
+ *
+ * Steve Doddi <dirk@loth.demon.co.uk>: 
+ * Support the possibility of hardware state restoring.
+ *
+ * Raph <grey.havens@earthling.net>:
+ * Support for preserving states of network devices and virtual console
+ * (including X and svgatextmode)
+ *
+ * Kurt Garloff <garloff@suse.de>:
+ * Straightened the critical function in order to prevent compilers from
+ * playing tricks with local variables.
+ *
+ * Andreas Mohr <a.mohr@mailto.de>
+ *
+ * Alex Badea <vampire@go.ro>:
+ * Fixed runaway init
+ *
+ * More state savers are welcome. Especially for the scsi layer...
+ *
+ * For TODOs,FIXMEs also look in Documentation/swsusp.txt
+ */
+
+/*
+ * TODO:
+ *
+ * - we should launch a kernel_thread to process suspend request, cleaning up
+ * bdflush from this task. (check apm.c for something similar).
+ */
+
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/swapctl.h>
+#include <linux/suspend.h>
+#include <linux/smp_lock.h>
+#include <linux/file.h>
+#include <linux/utsname.h>
+#include <linux/version.h>
+#include <linux/compile.h>
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+#include <linux/vt_kern.h>
+#include <linux/bitops.h>
+#include <linux/interrupt.h>
+#include <linux/kbd_kern.h>
+#include <linux/keyboard.h>
+#include <linux/spinlock.h>
+#include <linux/genhd.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/blk.h>
+#include <linux/swap.h>
+#include <linux/pm.h>
+#include <linux/device.h>
+
+#include <asm/uaccess.h>
+#include <asm/mmu_context.h>
+#include <asm/pgtable.h>
+#include <asm/io.h>
+
+unsigned char software_suspend_enabled = 0;
+
+/* #define SUSPEND_CONSOLE	(MAX_NR_CONSOLES-1) */
+/* With SUSPEND_CONSOLE defined, it suspend looks *really* cool, but
+   we probably do not take enough locks for switching consoles, etc,
+   so bad things might happen.
+*/
+#ifndef CONFIG_VT
+#undef SUSPEND_CONSOLE
+#endif
+
+#define TIMEOUT	(6 * HZ)			/* Timeout for stopping processes */
+#define ADDRESS(x) ((unsigned long) phys_to_virt(((x) << PAGE_SHIFT)))
+
+extern void wakeup_bdflush(void);
+extern int C_A_D;
+
+/* References to section boundaries */
+extern char _text, _etext, _edata, __bss_start, _end;
+extern char __nosave_begin, __nosave_end;
+
+extern int console_loglevel;
+extern int is_head_of_free_region(struct page *);
+
+/* Locks */
+spinlock_t suspend_pagedir_lock __nosavedata = SPIN_LOCK_UNLOCKED;
+
+/* Variables to be preserved over suspend */
+static int new_loglevel = 7;
+static int orig_loglevel = 0;
+static int orig_fgconsole;
+static int pagedir_order_check;
+static int nr_copy_pages_check;
+
+static int resume_status = 0;
+static char resume_file[256] = "";			/* For resume= kernel option */
+static kdev_t resume_device;
+/* Local variables that should not be affected by save */
+static unsigned int nr_copy_pages __nosavedata = 0;
+
+static int pm_suspend_state = 0;
+
+/* Suspend pagedir is allocated before final copy, therefore it
+   must be freed after resume 
+
+   Warning: this is evil. There are actually two pagedirs at time of
+   resume. One is "pagedir_save", which is empty frame allocated at
+   time of suspend, that must be freed. Second is "pagedir_nosave", 
+   allocated at time of resume, that travels through memory not to
+   collide with anything.
+ */
+static suspend_pagedir_t *pagedir_nosave __nosavedata = NULL;
+static unsigned long pagedir_save;
+static int pagedir_order __nosavedata = 0;
+
+struct link {
+	char dummy[PAGE_SIZE - sizeof(swp_entry_t)];
+	swp_entry_t next;
+};
+
+union diskpage {
+	union swap_header swh;
+	struct link link;
+	struct suspend_header sh;
+};
+
+/*
+ * XXX: We try to keep some more pages free so that I/O operations succeed
+ * without paging. Might this be more?
+ */
+#define PAGES_FOR_IO	512
+
+static const char *name_suspend = "Suspend Machine: ";
+static const char *name_resume = "Resume Machine: ";
+
+/*
+ * Debug
+ */
+#define	DEBUG_DEFAULT	1
+#undef	DEBUG_PROCESS
+#undef	DEBUG_SLOW
+#define TEST_SWSUSP 0		/* Set to 1 to reboot instead of halt machine after suspension */
+
+#ifdef DEBUG_DEFAULT
+#define PRINTD(func, f, a...)	\
+	do { \
+		printk("%s", func); \
+		printk(f, ## a); \
+	} while(0)
+#define PRINTS(f, a...)	PRINTD(name_suspend, f, ## a)
+#define PRINTR(f, a...)	PRINTD(name_resume, f, ## a)
+#define PRINTK(f, a...)	printk(f, ## a)
+#else
+#define PRINTD(func, f, a...)
+#define PRINTS(f, a...)
+#define PRINTR(f, a...)
+#define PRINTK(f, a...)
+#endif
+#ifdef DEBUG_SLOW
+#define MDELAY(a) mdelay(a)
+#else
+#define MDELAY(a)
+#endif
+
+/*
+ * Refrigerator and related stuff
+ */
+
+#define INTERESTING(p) \
+			/* We don't want to touch kernel_threads..*/ \
+			if (p->flags & PF_IOTHREAD) \
+				continue; \
+			if (p == current) \
+				continue; \
+			if (p->state == TASK_ZOMBIE) \
+				continue;
+
+/* Refrigerator is place where frozen processes are stored :-). */
+void refrigerator(unsigned long flag)
+{
+	/* You need correct to work with real-time processes.
+	   OTOH, this way one process may see (via /proc/) some other
+	   process in stopped state (and thereby discovered we were
+	   suspended. We probably do not care. 
+	 */
+	long save;
+	save = current->state;
+	current->state = TASK_STOPPED;
+//	PRINTK("%s entered refrigerator\n", current->comm);
+	printk(":");
+	current->flags &= ~PF_FREEZE;
+	if (flag)
+		flush_signals(current); /* We have signaled a kernel thread, which isn't normal behaviour
+					   and that may lead to 100%CPU sucking because those threads
+					   just don't manage signals. */
+	current->flags |= PF_FROZEN;
+	while (current->flags & PF_FROZEN)
+		schedule();
+//	PRINTK("%s left refrigerator\n", current->comm);
+	printk(":");
+	current->state = save;
+}
+
+/* 0 = success, else # of processes that we failed to stop */
+int freeze_processes(void)
+{
+	int todo, start_time;
+	struct task_struct *p;
+	
+	PRINTS( "Waiting for tasks to stop... " );
+	
+	start_time = jiffies;
+	do {
+		todo = 0;
+		read_lock(&tasklist_lock);
+		for_each_task(p) {
+			unsigned long flags;
+			INTERESTING(p);
+			if (p->flags & PF_FROZEN)
+				continue;
+
+			/* FIXME: smp problem here: we may not access other process' flags
+			   without locking */
+			p->flags |= PF_FREEZE;
+			spin_lock_irqsave(&p->sigmask_lock, flags);
+			signal_wake_up(p);
+			spin_unlock_irqrestore(&p->sigmask_lock, flags);
+			todo++;
+		}
+		read_unlock(&tasklist_lock);
+		sys_sched_yield();
+		schedule();
+		if (time_after(jiffies, start_time + TIMEOUT)) {
+			PRINTK( "\n" );
+			printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
+			return todo;
+		}
+	} while(todo);
+	
+	PRINTK( " ok\n" );
+	return 0;
+}
+
+void thaw_processes(void)
+{
+	struct task_struct *p;
+
+	PRINTR( "Restarting tasks..." );
+	read_lock(&tasklist_lock);
+	for_each_task(p) {
+		INTERESTING(p);
+		
+		if (p->flags & PF_FROZEN) p->flags &= ~PF_FROZEN;
+		else
+			printk(KERN_INFO " Strange, %s not stopped\n", p->comm );
+		wake_up_process(p);
+	}
+	read_unlock(&tasklist_lock);
+	PRINTK( " done\n" );
+	MDELAY(500);
+}
+
+/*
+ * Saving part...
+ */
+
+static __inline__ int fill_suspend_header(struct suspend_header *sh)
+{
+	memset((char *)sh, 0, sizeof(*sh));
+
+	sh->version_code = LINUX_VERSION_CODE;
+	sh->num_physpages = num_physpages;
+	strncpy(sh->machine, system_utsname.machine, 8);
+	strncpy(sh->version, system_utsname.version, 20);
+	sh->num_cpus = smp_num_cpus;
+	sh->page_size = PAGE_SIZE;
+	sh->suspend_pagedir = (unsigned long)pagedir_nosave;
+	if (pagedir_save != pagedir_nosave)
+		panic("Must not happen");
+	sh->num_pbes = nr_copy_pages;
+	/* TODO: needed? mounted fs' last mounted date comparison
+	 * [so they haven't been mounted since last suspend.
+	 * Maybe it isn't.] [we'd need to do this for _all_ fs-es]
+	 */
+	return 0;
+}
+
+/*
+ * This is our sync function. With this solution we probably won't sleep
+ * but that should not be a problem since tasks are stopped..
+ */
+
+static void do_suspend_sync(void)
+{
+	while (1) {
+		run_task_queue(&tq_disk);
+		if (!TQ_ACTIVE(tq_disk))
+			break;
+		printk(KERN_ERR "Hm, tq_disk is not empty after run_task_queue\n");
+	}
+}
+
+/* We memorize in swapfile_used what swap devices are used for suspension */
+#define SWAPFILE_UNUSED    0
+#define SWAPFILE_SUSPEND   1	/* This is the suspending device */
+#define SWAPFILE_IGNORED   2	/* Those are other swap devices ignored for suspension */
+
+static unsigned short swapfile_used[MAX_SWAPFILES];
+static unsigned short root_swap;
+#define MARK_SWAP_SUSPEND 0
+#define MARK_SWAP_RESUME 2
+
+static void mark_swapfiles(swp_entry_t prev, int mode)
+{
+	swp_entry_t entry;
+	union diskpage *cur;
+	
+	cur = (union diskpage *)get_free_page(GFP_ATOMIC);
+	if (!cur)
+		panic("Out of memory in mark_swapfiles");
+	/* XXX: this is dirty hack to get first page of swap file */
+	entry = SWP_ENTRY(root_swap, 0);
+	lock_page(virt_to_page((unsigned long)cur));
+	rw_swap_page_nolock(READ, entry, (char *) cur);
+
+	if (mode == MARK_SWAP_RESUME) {
+	  	if (!memcmp("SUSP1R",cur->swh.magic.magic,6))
+		  	memcpy(cur->swh.magic.magic,"SWAP-SPACE",10);
+		else if (!memcmp("SUSP2R",cur->swh.magic.magic,6))
+			memcpy(cur->swh.magic.magic,"SWAPSPACE2",10);
+		else printk("%sUnable to find suspended-data signature (%.10s - misspelled?\n", 
+		      	name_resume, cur->swh.magic.magic);
+	} else {
+	  	if ((!memcmp("SWAP-SPACE",cur->swh.magic.magic,10)))
+		  	memcpy(cur->swh.magic.magic,"SUSP1R....",10);
+		else if ((!memcmp("SWAPSPACE2",cur->swh.magic.magic,10)))
+			memcpy(cur->swh.magic.magic,"SUSP2R....",10);
+		else panic("\nSwapspace is not swapspace (%.10s)\n", cur->swh.magic.magic);
+		cur->link.next = prev; /* prev is the first/last swap page of the resume area */
+		/* link.next lies *no more* in last 4 bytes of magic */
+	}
+	lock_page(virt_to_page((unsigned long)cur));
+	rw_swap_page_nolock(WRITE, entry, (char *)cur);
+	
+	free_page((unsigned long)cur);
+}
+
+static void read_swapfiles(void) /* This is called before saving image */
+{
+	int i, len;
+	
+	len=strlen(resume_file);
+	root_swap = 0xFFFF;
+	
+	swap_list_lock();
+	for(i=0; i<MAX_SWAPFILES; i++) {
+		if (swap_info[i].flags == 0) {
+			swapfile_used[i]=SWAPFILE_UNUSED;
+		} else {
+			if(!len) {
+	    			printk(KERN_WARNING "resume= option should be used to set suspend device" );
+				if(root_swap == 0xFFFF) {
+					swapfile_used[i] = SWAPFILE_SUSPEND;
+					root_swap = i;
+				} else
+					swapfile_used[i] = SWAPFILE_IGNORED;				  
+			} else {
+	  			/* we ignore all swap devices that are not the resume_file */
+				if (1) {
+// FIXME				if(resume_device == swap_info[i].swap_device) {
+					swapfile_used[i] = SWAPFILE_SUSPEND;
+					root_swap = i;
+				} else {
+#if 0
+					PRINTS( "device %s (%x != %x) ignored\n", swap_info[i].swap_file->d_name.name, swap_info[i].swap_device, resume_device );				  
+#endif
+				  	swapfile_used[i] = SWAPFILE_IGNORED;
+				}
+			}
+		}
+	}
+	swap_list_unlock();
+}
+
+static void lock_swapdevices(void) /* This is called after saving image so modification
+				      will be lost after resume... and that's what we want. */
+{
+	int i;
+
+	swap_list_lock();
+	for(i = 0; i< MAX_SWAPFILES; i++)
+		if(swapfile_used[i] == SWAPFILE_IGNORED) {
+			swap_info[i].flags ^= 0xFF; /* we make the device unusable. A new call to
+						       lock_swapdevices can unlock the devices. */
+		}
+	swap_list_unlock();
+}
+
+static int write_suspend_image(void)
+{
+	int i;
+	swp_entry_t entry, prev = { 0 };
+	int nr_pgdir_pages = SUSPEND_PD_PAGES(nr_copy_pages);
+	union diskpage *cur,  *buffer = (union diskpage *)get_free_page(GFP_ATOMIC);
+	unsigned long address;
+	kdev_t suspend_device;
+
+	PRINTS( "Writing data to swap (%d pages): ", nr_copy_pages );
+	for (i=0; i<nr_copy_pages; i++) {
+		if (!(i%100))
+			PRINTK( "." );
+		if (!(entry = get_swap_page()).val)
+			panic("\nNot enough swapspace when writing data" );
+		
+		if(swapfile_used[SWP_TYPE(entry)] != SWAPFILE_SUSPEND)
+			panic("\nPage %d: not enough swapspace on suspend device", i );
+	    
+		address = (pagedir_nosave+i)->address;
+		lock_page(virt_to_page(address));
+		{
+			long dummy1, dummy2;
+			get_swaphandle_info(entry, &dummy1, &suspend_device);
+		}
+		rw_swap_page_nolock(WRITE, entry, (char *) address);
+		(pagedir_nosave+i)->swap_address = entry;
+	}
+	PRINTK(" done\n");
+	PRINTS( "Writing pagedir (%d pages): ", nr_pgdir_pages);
+	for (i=0; i<nr_pgdir_pages; i++) {
+		cur = (union diskpage *)((char *) pagedir_nosave)+i;
+		if ((char *) cur != (((char *) pagedir_nosave) + i*PAGE_SIZE))
+			panic("Something is of wrong size");
+		PRINTK( "." );
+		if (!(entry = get_swap_page()).val) {
+			printk(KERN_CRIT "Not enough swapspace when writing pgdir\n" );
+			panic("Don't know how to recover");
+			free_page((unsigned long) buffer);
+			return -ENOSPC;
+		}
+
+		if(swapfile_used[SWP_TYPE(entry)] != SWAPFILE_SUSPEND)
+		  panic("\nNot enough swapspace for pagedir on suspend device" );
+
+		if (sizeof(swp_entry_t) != sizeof(long))
+			panic("I need swp_entry_t to be sizeof long, otherwise next assignment could damage pagedir");
+		if (PAGE_SIZE % sizeof(struct pbe))
+			panic("I need PAGE_SIZE to be integer multiple of struct pbe, otherwise next assignment could damage pagedir");
+		cur->link.next = prev;				
+		lock_page(virt_to_page((unsigned long)cur));
+		rw_swap_page_nolock(WRITE, entry, (char *) cur);
+		prev = entry;
+	}
+	PRINTK(", header");
+	if (sizeof(struct suspend_header) > PAGE_SIZE-sizeof(swp_entry_t))
+		panic("sizeof(struct suspend_header) too big: %d",
+				sizeof(struct suspend_header));
+	if (sizeof(union diskpage) != PAGE_SIZE)
+		panic("union diskpage has bad size");
+	if (!(entry = get_swap_page()).val)
+		panic( "\nNot enough swapspace when writing header" );
+	if(swapfile_used[SWP_TYPE(entry)] != SWAPFILE_SUSPEND)
+	  panic("\nNot enough swapspace for header on suspend device" );
+
+	cur = (void *) buffer;
+	if(fill_suspend_header(&cur->sh))
+		panic("\nOut of memory while writing header");
+		
+	cur->link.next = prev;
+
+	lock_page(virt_to_page((unsigned long)cur));
+	rw_swap_page_nolock(WRITE, entry, (char *) cur);
+	prev = entry;
+
+	PRINTK( ", signature" );
+#if 0
+	if (SWP_TYPE(entry) != 0)
+		panic("Need just one swapfile");
+#endif
+	mark_swapfiles(prev, MARK_SWAP_SUSPEND);
+	PRINTK( ", done\n" );
+
+	MDELAY(1000);
+	free_page((unsigned long) buffer);
+	return 0;
+}
+
+/* if pagedir_p != NULL it also copies the counted pages */
+static int count_and_copy_data_pages(struct pbe *pagedir_p)
+{
+	int chunk_size;
+	int nr_copy_pages = 0;
+	int loop;
+	
+	if (max_mapnr != num_physpages)
+		panic("mapnr is not expected");
+	for(loop = 0; loop < max_mapnr; loop++) {
+		if(PageHighMem(mem_map+loop))
+			panic("No highmem for me, sorry.");
+		if(!PageReserved(mem_map+loop)) {
+			if(PageNosave(mem_map+loop))
+				continue;
+
+			if((chunk_size=is_head_of_free_region(mem_map+loop))!=0) {
+				loop += chunk_size - 1;
+				continue;
+			}
+		} else if(PageReserved(mem_map+loop)) {
+			if(PageNosave(mem_map+loop))
+				panic("What?");
+
+			/*
+			 * Just copy whole code segment. Hopefully it is not that big.
+			 */
+			if (ADDRESS(loop) >= (unsigned long)
+				&__nosave_begin && ADDRESS(loop) < 
+				(unsigned long)&__nosave_end) {
+				printk("[nosave]");
+				continue;
+			}
+			/* Hmm, perhaps copying all reserved pages is not too healthy as they may contain 
+			   critical bios data? */
+		} else panic("No third thing should be possible");
+
+		nr_copy_pages++;
+		if(pagedir_p) {
+			pagedir_p->orig_address = ADDRESS(loop);
+			copy_page(pagedir_p->address, pagedir_p->orig_address);
+			pagedir_p++;
+		}
+	}
+	return nr_copy_pages;
+}
+
+static void free_suspend_pagedir(unsigned long this_pagedir)
+{
+	struct page *page = mem_map;
+	int i;
+	unsigned long this_pagedir_end = this_pagedir +
+		(PAGE_SIZE << pagedir_order);
+
+	for(i=0; i < num_physpages; i++, page++) {
+		if(!TestClearPageNosave(page))
+			continue;
+
+		if(ADDRESS(i) >= this_pagedir && ADDRESS(i) < this_pagedir_end)
+			continue; /* old pagedir gets freed in one */
+		
+		free_page(ADDRESS(i));
+	}
+	free_pages(this_pagedir, pagedir_order);
+}
+
+static suspend_pagedir_t *create_suspend_pagedir(int nr_copy_pages)
+{
+	int i;
+	suspend_pagedir_t *pagedir;
+	struct pbe *p;
+	struct page *page;
+
+	pagedir_order = get_bitmask_order(SUSPEND_PD_PAGES(nr_copy_pages));
+
+	p = pagedir = (suspend_pagedir_t *)__get_free_pages(GFP_ATOMIC, pagedir_order);
+	if(!pagedir)
+		return NULL;
+
+	page = virt_to_page(pagedir);
+	for(i=0; i < 1<<pagedir_order; i++)
+		SetPageNosave(page++);
+		
+	while(nr_copy_pages--) {
+		p->address = get_free_page(GFP_ATOMIC);
+		if(!p->address) {
+			panic("oom");
+			free_suspend_pagedir((unsigned long) pagedir);
+			return NULL;
+		}
+		SetPageNosave(virt_to_page(p->address));
+		p->orig_address = 0;
+		p++;
+	}
+	return pagedir;
+}
+
+static int prepare_suspend_console(void)
+{
+	orig_loglevel = console_loglevel;
+	console_loglevel = new_loglevel;
+
+#ifdef CONFIG_VT
+	orig_fgconsole = fg_console;
+#ifdef SUSPEND_CONSOLE
+	if(vc_allocate(SUSPEND_CONSOLE))
+	  /* we can't have a free VC for now. Too bad,
+	   * we don't want to mess the screen for now. */
+		return 1;
+
+	set_console (SUSPEND_CONSOLE);
+	if(vt_waitactive(SUSPEND_CONSOLE)) {
+		PRINTS("Bummer. Can't switch VCs.");
+		return 1;
+	}
+#endif
+#endif
+	return 0;
+}
+
+static void restore_console(void)
+{
+	console_loglevel = orig_loglevel;
+#ifdef SUSPEND_CONSOLE
+	set_console (orig_fgconsole);
+#endif
+	return;
+}
+
+static int prepare_suspend_processes(void)
+{
+	PRINTS( "Stopping processes\n" );
+	MDELAY(1000);
+	if (freeze_processes()) {
+		PRINTS( "Not all processes stopped!\n" );
+		thaw_processes();
+		return 1;
+	}
+	do_suspend_sync();
+	return 0;
+}
+
+/*
+ * Try to free as much memory as possible, but do not OOM-kill anyone
+ *
+ * Notice: all userland should be stopped at this point, or livelock is possible.
+ */
+static void free_some_memory(void)
+{
+	PRINTS("Freeing memory: ");
+	while (try_to_free_pages(&contig_page_data.node_zones[ZONE_HIGHMEM], GFP_KSWAPD, 0))
+		printk(".");
+	printk("\n");
+}
+
+/* Make disk drivers accept operations, again */
+static void drivers_unsuspend(void)
+{
+	device_resume(RESUME_ENABLE);
+	device_resume(RESUME_RESTORE_STATE);
+}
+
+/* Called from process context */
+static int drivers_suspend(void)
+{
+	device_suspend(4, SUSPEND_NOTIFY);
+	device_suspend(4, SUSPEND_SAVE_STATE);
+	device_suspend(4, SUSPEND_DISABLE);
+	if(!pm_suspend_state) {
+		if(pm_send_all(PM_SUSPEND,(void *)3)) {
+			printk(KERN_WARNING "Problem while sending suspend event\n");
+			return(1);
+		}
+		pm_suspend_state=1;
+	} else
+		printk(KERN_WARNING "PM suspend state already raised\n");
+	  
+	return(0);
+}
+
+#define RESUME_PHASE1 1 /* Called from interrupts disabled */
+#define RESUME_PHASE2 2 /* Called with interrupts enabled */
+#define RESUME_ALL_PHASES (RESUME_PHASE1 | RESUME_PHASE2)
+static void drivers_resume(int flags)
+{
+	device_resume(RESUME_ENABLE);
+	device_resume(RESUME_RESTORE_STATE);
+  	if(flags & RESUME_PHASE2) {
+		if(pm_suspend_state) {
+			if(pm_send_all(PM_RESUME,(void *)0))
+				printk(KERN_WARNING "Problem while sending resume event\n");
+			pm_suspend_state=0;
+		} else
+			printk(KERN_WARNING "PM suspend state wasn't raised\n");
+
+#ifdef SUSPEND_CONSOLE
+		update_screen(fg_console);	/* Hmm, is this the problem? */
+#endif
+	}
+}
+
+static int suspend_save_image(void)
+{
+	struct sysinfo i;
+	unsigned int nr_needed_pages = 0;
+
+	pagedir_nosave = NULL;
+	PRINTS( "/critical section: Counting pages to copy" );
+	nr_copy_pages = count_and_copy_data_pages(NULL);
+	nr_needed_pages = nr_copy_pages + PAGES_FOR_IO;
+	
+	PRINTK(" (pages needed: %d+%d=%d free: %d)\n",nr_copy_pages,PAGES_FOR_IO,nr_needed_pages,nr_free_pages());
+	if(nr_free_pages() < nr_needed_pages) {
+		printk(KERN_CRIT "%sCouldn't get enough free pages, on %d pages short\n",
+		       name_suspend, nr_needed_pages-nr_free_pages());
+		spin_unlock_irq(&suspend_pagedir_lock);
+		return 1;
+	}
+	si_swapinfo(&i);	/* FIXME: si_swapinfo(&i) returns all swap devices information.
+				   We should only consider resume_device. */
+	if (i.freeswap < nr_needed_pages)  {
+		printk(KERN_CRIT "%sThere's not enough swap space available, on %ld pages short\n",
+		       name_suspend, nr_needed_pages-i.freeswap);
+		spin_unlock_irq(&suspend_pagedir_lock);
+		return 1;
+	}
+
+	PRINTK( "Alloc pagedir\n" ); 
+	pagedir_save = pagedir_nosave = create_suspend_pagedir(nr_copy_pages);
+	if(!pagedir_nosave) {
+		/* Shouldn't happen */
+		printk(KERN_CRIT "%sCouldn't allocate enough pages\n",name_suspend);
+		panic("Really should not happen");
+		spin_unlock_irq(&suspend_pagedir_lock);
+		return 1;
+	}
+	nr_copy_pages_check = nr_copy_pages;
+	pagedir_order_check = pagedir_order;
+
+	if (nr_copy_pages != count_and_copy_data_pages(pagedir_nosave))	/* copy */
+		panic("Count and copy returned another count than when counting?\n");
+
+	/*
+	 * End of critical section. From now on, we can write to memory,
+	 * but we should not touch disk. This specially means we must _not_
+	 * touch swap space! Except we must write out our image of course.
+	 *
+	 * Following line enforces not writing to disk until we choose.
+	 */
+	drivers_unsuspend();
+	spin_unlock_irq(&suspend_pagedir_lock);
+	PRINTS( "critical section/: done (%d pages copied)\n", nr_copy_pages );
+
+	lock_swapdevices();
+	write_suspend_image();
+	lock_swapdevices();	/* This will unlock ignored swap devices since writing is finished */
+
+	/* Image is saved, call sync & restart machine */
+	PRINTS( "Syncing disks\n" );
+	/* It is important _NOT_ to umount filesystems at this point. We want
+	 * them synced (in case something goes wrong) but we DO not want to mark
+	 * filesystem clean: it is not. (And it does not matter, if we resume
+	 * correctly, we'll mark system clean, anyway.)
+	 */
+	return 0;
+}
+
+void suspend_power_down(void)
+{
+	C_A_D = 0;
+	printk(KERN_EMERG "%sTrying to power down.\n", name_suspend);
+#ifdef CONFIG_VT
+	printk(KERN_EMERG "shift_state: %04x\n", shift_state);
+	mdelay(1000);
+	if (TEST_SWSUSP ^ (!!(shift_state & (1 << KG_CTRL))))
+		machine_restart(NULL);
+	else
+#endif
+		machine_power_off();
+
+	printk(KERN_EMERG "%sProbably not capable for powerdown. System halted.\n", name_suspend);
+	machine_halt();
+	while (1);
+	/* NOTREACHED */
+}
+
+/* forward decl */
+void do_software_suspend(void);
+
+/*
+ * Magic happens here
+ */
+
+static void do_magic_resume_1(void)
+{
+	barrier();
+	mb();
+	spin_lock_irq(&suspend_pagedir_lock);	/* Done to disable interrupts */ 
+
+	printk( "Waiting for DMAs to settle down...\n");
+	mdelay(1000);	/* We do not want some readahead with DMA to corrupt our memory, right?
+			   Do it with disabled interrupts for best effect. That way, if some
+			   driver scheduled DMA, we have good chance for DMA to finish ;-). */
+}
+
+static void do_magic_resume_2(void)
+{
+	if (nr_copy_pages_check != nr_copy_pages)
+		panic("nr_copy_pages changed?!");
+	if (pagedir_order_check != pagedir_order)
+		panic("pagedir_order changed?!");
+
+	PRINTR( "Freeing prev allocated pagedir\n" );
+	free_suspend_pagedir(pagedir_save);
+	__flush_tlb_global();		/* Even mappings of "global" things (vmalloc) need to be fixed */
+	drivers_resume(RESUME_ALL_PHASES);
+	spin_unlock_irq(&suspend_pagedir_lock);
+
+	PRINTK( "Fixing swap signatures... " );
+	mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME);
+	PRINTK( "ok\n" );
+
+#ifdef SUSPEND_CONSOLE
+	update_screen(fg_console);	/* Hmm, is this the problem? */
+#endif
+	suspend_tq.routine = (void *)do_software_suspend;
+}
+
+static void do_magic_suspend_1(void)
+{
+	mb();
+	barrier();
+	spin_lock_irq(&suspend_pagedir_lock);
+}
+
+static void do_magic_suspend_2(void)
+{
+	read_swapfiles();
+	if (!suspend_save_image())
+		suspend_power_down();	/* FIXME: if suspend_power_down is commented out, console is lost after few suspends ?! */
+
+	printk(KERN_WARNING "%sSuspend failed, trying to recover...\n", name_suspend);
+	MDELAY(1000); /* So user can wait and report us messages if armageddon comes :-) */
+
+	barrier();
+	mb();
+	drivers_resume(RESUME_PHASE2);
+	spin_lock_irq(&suspend_pagedir_lock);	/* Done to disable interrupts */ 
+	mdelay(1000);
+
+	free_pages((unsigned long) pagedir_nosave, pagedir_order);
+	drivers_resume(RESUME_PHASE1);
+	spin_unlock_irq(&suspend_pagedir_lock);
+	mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME);
+	suspend_tq.routine = (void *)do_software_suspend;
+	printk(KERN_WARNING "%sLeaving do_magic_suspend_2...\n", name_suspend);	
+}
+
+#define SUSPEND_C
+#include <asm/suspend.h>
+
+/*
+ * This function is triggered using process bdflush. We try to swap out as
+ * much as we can then make a copy of the occupied pages in memory so we can
+ * make a copy of kernel state atomically, the I/O needed by saving won't
+ * bother us anymore.
+ */
+void do_software_suspend(void)
+{
+	arch_prepare_suspend();
+	if (!prepare_suspend_console()) {
+		if (!prepare_suspend_processes()) {
+			free_some_memory();
+
+			/* No need to invalidate any vfsmnt list -- they will be valid after resume, anyway.
+			 *
+			 * We sync here -- so you have consistent filesystem state when things go wrong.
+			 * -- so that noone writes to disk after we do atomic copy of data.
+			 */
+			PRINTS("Syncing disks before copy\n");
+			do_suspend_sync();
+			if(drivers_suspend()==0)
+				do_magic(0);			/* This function returns after machine woken up from resume */
+			PRINTR("Restarting processes...\n");
+			thaw_processes();
+		}
+	}
+	software_suspend_enabled = 1;
+	MDELAY(1000);
+	restore_console ();
+}
+
+struct tq_struct suspend_tq =
+	{ routine: (void *)(void *)do_software_suspend, 
+	  data: 0 };
+
+/*
+ * This is the trigger function, we must queue ourself since we
+ * can be called from interrupt && bdflush context is needed
+ */
+void software_suspend(void)
+{
+	if(!software_suspend_enabled)
+		return;
+
+	software_suspend_enabled = 0;
+	queue_task(&suspend_tq, &tq_bdflush);
+	wakeup_bdflush();
+}
+
+/* More restore stuff */
+
+/* FIXME: Why not memcpy(to, from, 1<<pagedir_order*PAGE_SIZE)? */
+static void copy_pagedir(suspend_pagedir_t *to, suspend_pagedir_t *from)
+{
+	int i;
+	char *topointer=(char *)to, *frompointer=(char *)from;
+
+	for(i=0; i < 1 << pagedir_order; i++) {
+		copy_page(topointer, frompointer);
+		topointer += PAGE_SIZE;
+		frompointer += PAGE_SIZE;
+	}
+}
+
+#define does_collide(addr) does_collide_order(pagedir_nosave, addr, 0)
+
+/*
+ * Returns true if given address/order collides with any orig_address 
+ */
+static int does_collide_order(suspend_pagedir_t *pagedir, unsigned long addr,
+		int order)
+{
+	int i;
+	unsigned long addre = addr + (PAGE_SIZE<<order);
+	
+	for(i=0; i < nr_copy_pages; i++)
+		if((pagedir+i)->orig_address >= addr &&
+			(pagedir+i)->orig_address < addre)
+			return 1;
+
+	return 0;
+}
+
+/*
+ * We check here that pagedir & pages it points to won't collide with pages
+ * where we're going to restore from the loaded pages later
+ */
+static int check_pagedir(void)
+{
+	int i;
+
+	for(i=0; i < nr_copy_pages; i++) {
+		unsigned long addr;
+
+		do {
+			addr = get_free_page(GFP_ATOMIC);
+			if(!addr)
+				return -ENOMEM;
+		} while (does_collide(addr));
+
+		(pagedir_nosave+i)->address = addr;
+	}
+	return 0;
+}
+
+static int relocate_pagedir(void)
+{
+	/*
+	 * We have to avoid recursion (not to overflow kernel stack),
+	 * and that's why code looks pretty cryptic 
+	 */
+	suspend_pagedir_t *new_pagedir, *old_pagedir = pagedir_nosave;
+	void **eaten_memory = NULL;
+	void **c = eaten_memory, *m, *f;
+
+	if(!does_collide_order(old_pagedir, (unsigned long)old_pagedir, pagedir_order)) {
+		printk("not neccessary\n");
+		return 0;
+	}
+
+	while ((m = (void *) __get_free_pages(GFP_ATOMIC, pagedir_order))) {
+		memset(m, 0, PAGE_SIZE);
+		if (!does_collide_order(old_pagedir, (unsigned long)m, pagedir_order))
+			break;
+		eaten_memory = m;
+		printk( "." ); 
+		*eaten_memory = c;
+		c = eaten_memory;
+	}
+
+	if (!m)
+		return -ENOMEM;
+
+	pagedir_nosave = new_pagedir = m;
+	copy_pagedir(new_pagedir, old_pagedir);
+
+	c = eaten_memory;
+	while(c) {
+		printk(":");
+		f = *c;
+		c = *c;
+		if (f)
+			free_pages((unsigned long)f, pagedir_order);
+	}
+	printk("okay\n");
+	return 0;
+}
+
+/*
+ * Sanity check if this image makes sense with this kernel/swap context
+ * I really don't think that it's foolproof but more than nothing..
+ */
+
+static int sanity_check_failed(char *reason)
+{
+	printk(KERN_ERR "%s%s\n",name_resume,reason);
+	return -EPERM;
+}
+
+static int sanity_check(struct suspend_header *sh)
+{
+	if(sh->version_code != LINUX_VERSION_CODE)
+		return sanity_check_failed("Incorrect kernel version");
+	if(sh->num_physpages != num_physpages)
+		return sanity_check_failed("Incorrect memory size");
+	if(strncmp(sh->machine, system_utsname.machine, 8))
+		return sanity_check_failed("Incorrect machine type");
+	if(strncmp(sh->version, system_utsname.version, 20))
+		return sanity_check_failed("Incorrect version");
+	if(sh->num_cpus != smp_num_cpus)
+		return sanity_check_failed("Incorrect number of cpus");
+	if(sh->page_size != PAGE_SIZE)
+		return sanity_check_failed("Incorrect PAGE_SIZE");
+	return 0;
+}
+
+static int bdev_read_page(kdev_t dev, long pos, void *buf)
+{
+	struct buffer_head *bh;
+	struct block_device *bdev;
+
+	if (pos%PAGE_SIZE) panic("Sorry, dave, I can't let you do that!\n");
+	bdev = bdget(kdev_t_to_nr(dev));
+	blkdev_get(bdev, FMODE_READ, O_RDONLY, BDEV_RAW);
+	if (!bdev) {
+		printk("No block device for %s\n", __bdevname(dev));
+		BUG();
+	}
+	set_blocksize(bdev, PAGE_SIZE);
+	bh = __bread(bdev, pos/PAGE_SIZE, PAGE_SIZE);
+	if (!bh || (!bh->b_data)) {
+		return -1;
+	}
+	memcpy(buf, bh->b_data, PAGE_SIZE);	/* FIXME: may need kmap() */
+	BUG_ON(!buffer_uptodate(bh));
+	brelse(bh);
+	blkdev_put(bdev, BDEV_RAW);
+	return 0;
+} 
+
+extern kdev_t __init name_to_kdev_t(char *line);
+
+static int resume_try_to_read(const char * specialfile, int noresume)
+{
+	union diskpage *cur;
+	swp_entry_t next;
+	int i, nr_pgdir_pages, error;
+	int blksize = 0;
+
+	resume_device = name_to_kdev_t(specialfile);
+	cur = (void *) get_free_page(GFP_ATOMIC);
+	if (!cur) {
+		printk( "%sNot enough memory?\n", name_resume );
+		error = -ENOMEM;
+		goto resume_read_error;
+	}
+
+	printk("Resuming from device %x\n", resume_device);
+
+#define READTO(pos, ptr) \
+	if (bdev_read_page(resume_device, pos, ptr)) { error = -EIO; goto resume_read_error; }
+#define PREPARENEXT \
+	{	next = cur->link.next; \
+		next.val = SWP_OFFSET(next) * PAGE_SIZE; \
+        }
+
+	error = -EIO;
+	READTO(0, cur);
+
+	if ((!memcmp("SWAP-SPACE",cur->swh.magic.magic,10)) ||
+	    (!memcmp("SWAPSPACE2",cur->swh.magic.magic,10))) {
+		printk(KERN_ERR "%sThis is normal swap space\n", name_resume );
+		error = -EINVAL;
+		goto resume_read_error;
+	}
+
+	PREPARENEXT; /* We have to read next position before we overwrite it */
+
+	if (!memcmp("SUSP1R",cur->swh.magic.magic,6))
+		memcpy(cur->swh.magic.magic,"SWAP-SPACE",10);
+	else if (!memcmp("SUSP2R",cur->swh.magic.magic,6))
+		memcpy(cur->swh.magic.magic,"SWAPSPACE2",10);
+	else {
+		panic("%sUnable to find suspended-data signature (%.10s - misspelled?\n", 
+			name_resume, cur->swh.magic.magic);
+	}
+	printk( "%sSignature found, resuming\n", name_resume );
+	MDELAY(1000);
+
+	READTO(next.val, cur);
+
+	error = -EPERM;
+	if (sanity_check(&cur->sh))
+		goto resume_read_error;
+
+	/* Probably this is the same machine */	
+
+	PREPARENEXT;
+
+	pagedir_save = cur->sh.suspend_pagedir;
+	nr_copy_pages = cur->sh.num_pbes;
+	nr_pgdir_pages = SUSPEND_PD_PAGES(nr_copy_pages);
+	pagedir_order = get_bitmask_order(nr_pgdir_pages);
+
+	error = -ENOMEM;
+	pagedir_nosave = (suspend_pagedir_t *)__get_free_pages(GFP_ATOMIC, pagedir_order);
+	if(!pagedir_nosave)
+		goto resume_read_error;
+
+	PRINTR( "%sReading pagedir, ", name_resume );
+
+	/* We get pages in reverse order of saving! */
+	error=-EIO;
+	for (i=nr_pgdir_pages-1; i>=0; i--) {
+		if (!next.val)
+			panic( "Preliminary end of suspended data?" );
+		cur = (union diskpage *)((char *) pagedir_nosave)+i;
+		READTO(next.val, cur);
+		PREPARENEXT;
+	}
+	if (next.val)
+		panic( "Suspended data too long?" );
+
+	printk("Relocating pagedir");
+	if((error=relocate_pagedir())!=0)
+		goto resume_read_error;
+	if((error=check_pagedir())!=0)
+		goto resume_read_error;
+
+	PRINTK( "image data (%d pages): ", nr_copy_pages );
+	error = -EIO;
+	for(i=0; i < nr_copy_pages; i++) {
+		swp_entry_t swap_address = (pagedir_nosave+i)->swap_address;
+		if (!(i%100))
+			PRINTK( "." );
+		next.val = SWP_OFFSET (swap_address) * PAGE_SIZE;
+		/* You do not need to check for overlaps...
+		   ... check_pagedir already did this work */
+		READTO(next.val, (char *)((pagedir_nosave+i)->address));
+	}
+	PRINTK( " done\n" );
+	error = 0;
+
+resume_read_error:
+	switch (error) {
+		case 0:
+			PRINTR("Reading resume file was successful\n");
+			break;
+		case -EINVAL:
+			break;
+		case -EIO:
+			printk( "%sI/O error\n", name_resume);
+			panic("Wanted to resume but it did not work\n");
+			break;
+		case -ENOENT:
+			printk( "%s%s: No such file or directory\n", name_resume, specialfile);
+			panic("Wanted to resume but it did not work\n");
+			break;
+		default:
+			printk( "%sError %d resuming\n", name_resume, error );
+			panic("Wanted to resume but it did not work\n");
+	}
+	MDELAY(1000);
+	return error;
+}
+
+/*
+ * Called from init kernel_thread.
+ * We check if we have an image and if so we try to resume
+ */
+
+void software_resume(void)
+{
+#ifdef CONFIG_SMP
+	printk(KERN_WARNING "Software Suspend has a malfunctioning SMP support. Disabled :(\n");
+#else
+	/* We enable the possibility of machine suspend */
+	software_suspend_enabled = 1;
+#endif
+	if(!resume_status)
+		return;
+
+	printk( "%s", name_resume );
+	if(resume_status == NORESUME) {
+		/* FIXME: Signature should be restored here */
+		printk( "disabled\n" );
+		return;
+	}
+	MDELAY(1000);
+
+	orig_loglevel = console_loglevel;
+	console_loglevel = new_loglevel;
+
+	if(!resume_file[0] && resume_status == RESUME_SPECIFIED) {
+		printk( "nowhere to resume from\n" );
+		return;
+	}
+
+	printk( "resuming from %s\n", resume_file);
+	if(resume_try_to_read(resume_file, 0))
+		goto read_failure;
+	do_magic(1);
+	panic("This never returns");
+
+read_failure:
+	console_loglevel = orig_loglevel;
+	return;
+}
+
+static int __init resume_setup(char *str)
+{
+	if(resume_status)
+		return 1;
+
+	strncpy( resume_file, str, 255 );
+	resume_status = RESUME_SPECIFIED;
+
+	return 1;
+}
+
+static int __init software_noresume(char *str)
+{
+	if(!resume_status)
+		printk(KERN_WARNING "noresume option lacks a resume= option\n");
+	resume_status = NORESUME;
+	
+	return 1;
+}
+
+__setup("noresume", software_noresume);
+__setup("resume=", resume_setup);
+
+EXPORT_SYMBOL(software_suspend);
+EXPORT_SYMBOL(software_suspend_enabled);
+EXPORT_SYMBOL(refrigerator);
diff -Nru a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c	Fri May 24 18:55:33 2002
+++ b/kernel/sys.c	Fri May 24 18:55:33 2002
@@ -4,6 +4,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/utsname.h>
@@ -346,6 +347,16 @@
 		printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer);
 		machine_restart(buffer);
 		break;
+
+#ifdef CONFIG_SOFTWARE_SUSPEND
+	case LINUX_REBOOT_CMD_SW_SUSPEND:
+		if(!software_suspend_enabled)
+			return -EAGAIN;
+		
+		software_suspend();
+		do_exit(0);
+		break;
+#endif
 
 	default:
 		unlock_kernel();
diff -Nru a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile	Fri May 24 18:55:33 2002
+++ b/lib/Makefile	Fri May 24 18:55:33 2002
@@ -23,11 +23,8 @@
 
 obj-$(CONFIG_CRC32)	+= crc32.o
 
-subdir-$(CONFIG_ZLIB_INFLATE) += zlib_inflate
-subdir-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate
-
-# Include the subdirs, if necessary.
-obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
+obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
 
 include $(TOPDIR)/drivers/net/Makefile.lib
 include $(TOPDIR)/drivers/usb/class/Makefile.lib
diff -Nru a/lib/zlib_deflate/Makefile b/lib/zlib_deflate/Makefile
--- a/lib/zlib_deflate/Makefile	Fri May 24 18:55:36 2002
+++ b/lib/zlib_deflate/Makefile	Fri May 24 18:55:36 2002
@@ -6,13 +6,10 @@
 # decompression code.
 #
 
-O_TARGET    := zlib_deflate.o
-
 export-objs := deflate_syms.o
 
-obj-y := deflate.o deftree.o deflate_syms.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate.o
 
-EXTRA_CFLAGS += -I $(TOPDIR)/lib/zlib_deflate
+zlib_deflate-objs := deflate.o deftree.o deflate_syms.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/lib/zlib_inflate/Makefile b/lib/zlib_inflate/Makefile
--- a/lib/zlib_inflate/Makefile	Fri May 24 18:55:36 2002
+++ b/lib/zlib_inflate/Makefile	Fri May 24 18:55:36 2002
@@ -13,14 +13,11 @@
 # uncompression can be done without blocking on allocation).
 #
 
-O_TARGET    := zlib_inflate.o
-
 export-objs := inflate_syms.o
 
-obj-y := infblock.o infcodes.o inffast.o inflate.o \
-	 inftrees.o infutil.o inflate_syms.o
-obj-m := $(O_TARGET)
+obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate.o
 
-EXTRA_CFLAGS += -I $(TOPDIR)/lib/zlib_inflate
+zlib_inflate-objs := infblock.o infcodes.o inffast.o inflate.o \
+		     inftrees.o infutil.o inflate_syms.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/mm/filemap.c b/mm/filemap.c
--- a/mm/filemap.c	Fri May 24 18:55:35 2002
+++ b/mm/filemap.c	Fri May 24 18:55:35 2002
@@ -20,6 +20,16 @@
 #include <linux/iobuf.h>
 #include <linux/hash.h>
 #include <linux/writeback.h>
+/*
+ * This is needed for the following functions:
+ *  - try_to_release_page
+ *  - block_flushpage
+ *  - page_has_buffers
+ *  - generic_osync_inode
+ *
+ * FIXME: remove all knowledge of the buffer layer from this file
+ */
+#include <linux/buffer_head.h>
 
 #include <asm/uaccess.h>
 #include <asm/mman.h>
diff -Nru a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c	Fri May 24 18:55:35 2002
+++ b/mm/memory.c	Fri May 24 18:55:35 2002
@@ -127,9 +127,6 @@
 		free_one_pgd(tlb, page_dir);
 		page_dir++;
 	} while (--nr);
-
-	/* keep the page table cache within bounds */
-	check_pgt_cache();
 }
 
 pte_t * pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
@@ -346,8 +343,7 @@
 		if (pte_present(pte)) {
 			unsigned long pfn = pte_pfn(pte);
 
-			pte_clear(ptep);
-			pfn = pte_pfn(pte);
+			pte = ptep_get_and_clear(ptep);
 			tlb_remove_tlb_entry(tlb, pte, address+offset);
 			if (pfn_valid(pfn)) {
 				struct page *page = pfn_to_page(pfn);
diff -Nru a/mm/mempool.c b/mm/mempool.c
--- a/mm/mempool.c	Fri May 24 18:55:33 2002
+++ b/mm/mempool.c	Fri May 24 18:55:33 2002
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mempool.h>
+#include <linux/buffer_head.h>		/* for wakeup_bdflush() */
 
 static void add_element(mempool_t *pool, void *element)
 {
diff -Nru a/mm/page-writeback.c b/mm/page-writeback.c
--- a/mm/page-writeback.c	Fri May 24 18:55:33 2002
+++ b/mm/page-writeback.c	Fri May 24 18:55:33 2002
@@ -117,15 +117,14 @@
 	} ____cacheline_aligned ratelimits[NR_CPUS];
 	int cpu;
 
-	preempt_disable();
-	cpu = smp_processor_id();
+	cpu = get_cpu();
 	if (ratelimits[cpu].count++ >= 1000) {
 		ratelimits[cpu].count = 0;
-		preempt_enable();
+		put_cpu();
 		balance_dirty_pages(mapping);
 		return;
 	}
-	preempt_enable();
+	put_cpu();
 }
 
 /*
@@ -479,7 +478,10 @@
  *
  * For now, we treat swapper_space specially.  It doesn't use the normal
  * block a_ops.
+ *
+ * FIXME: this should move over to fs/buffer.c - buffer_heads have no business in mm/
  */
+#include <linux/buffer_head.h>
 int __set_page_dirty_buffers(struct page *page)
 {
 	struct address_space * const mapping = page->mapping;
diff -Nru a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c	Fri May 24 18:55:33 2002
+++ b/mm/page_alloc.c	Fri May 24 18:55:33 2002
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/compiler.h>
 #include <linux/module.h>
+#include <linux/suspend.h>
 
 unsigned long totalram_pages;
 unsigned long totalhigh_pages;
@@ -247,6 +248,46 @@
 	return NULL;
 }
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+int is_head_of_free_region(struct page *p)
+{
+	pg_data_t *pgdat = pgdat_list;
+	unsigned type;
+	unsigned long flags;
+
+	for (type=0;type < MAX_NR_ZONES; type++) {
+		zone_t *zone = pgdat->node_zones + type;
+		int order = MAX_ORDER - 1;
+		free_area_t *area;
+		struct list_head *head, *curr;
+		spin_lock_irqsave(&zone->lock, flags);	/* Should not matter as we need quiescent system for suspend anyway, but... */
+
+		do {
+			area = zone->free_area + order;
+			head = &area->free_list;
+			curr = head;
+
+			for(;;) {
+				if(!curr) {
+//					printk("FIXME: this should not happen but it does!!!");
+					break;
+				}
+				if(p != memlist_entry(curr, struct page, list)) {
+					curr = memlist_next(curr);
+					if (curr == head)
+						break;
+					continue;
+				}
+				return 1 << order;
+			}
+		} while(order--);
+		spin_unlock_irqrestore(&zone->lock, flags);
+
+	}
+	return 0;
+}
+#endif /* CONFIG_SOFTWARE_SUSPEND */
+
 #ifndef CONFIG_DISCONTIGMEM
 struct page *_alloc_pages(unsigned int gfp_mask, unsigned int order)
 {
@@ -569,11 +610,6 @@
 }
 #endif
 
-unsigned long nr_buffermem_pages(void)
-{
-	return atomic_read(&buffermem_pages);
-}
-
 /*
  * Accumulate the page_state information across all CPUs.
  * The result is unavoidably approximate - it can change
@@ -613,7 +649,7 @@
 	val->totalram = totalram_pages;
 	val->sharedram = 0;
 	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
+	val->bufferram = get_page_cache_size();
 #ifdef CONFIG_HIGHMEM
 	val->totalhigh = totalhigh_pages;
 	val->freehigh = nr_free_highpages();
diff -Nru a/mm/page_io.c b/mm/page_io.c
--- a/mm/page_io.c	Fri May 24 18:55:33 2002
+++ b/mm/page_io.c	Fri May 24 18:55:33 2002
@@ -15,6 +15,7 @@
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/swapctl.h>
+#include <linux/buffer_head.h>		/* for brw_page() */
 
 #include <asm/pgtable.h>
 
diff -Nru a/mm/pdflush.c b/mm/pdflush.c
--- a/mm/pdflush.c	Fri May 24 18:55:36 2002
+++ b/mm/pdflush.c	Fri May 24 18:55:36 2002
@@ -14,6 +14,7 @@
 #include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/suspend.h>
 
 
 /*
@@ -78,12 +79,6 @@
 	unsigned long when_i_went_to_sleep;
 };
 
-/*
- * preemption is disabled in pdflush.  There was a bug in preempt
- * which was causing pdflush to get flipped into state TASK_RUNNING
- * when it performed a spin_unlock.  That bug is probably fixed,
- * but play it safe.  The preempt-off paths are very short.
- */
 static int __pdflush(struct pdflush_work *my_work)
 {
 	daemonize();
@@ -96,11 +91,10 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sigmask_lock);
 
-	current->flags |= PF_FLUSHER;
+	current->flags |= PF_FLUSHER | PF_KERNTHREAD;
 	my_work->fn = NULL;
 	my_work->who = current;
 
-	preempt_disable();
 	spin_lock_irq(&pdflush_lock);
 	nr_pdflush_threads++;
 //	printk("pdflush %d [%d] starts\n", nr_pdflush_threads, current->pid);
@@ -112,11 +106,15 @@
 		set_current_state(TASK_INTERRUPTIBLE);
 		spin_unlock_irq(&pdflush_lock);
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+		run_task_queue(&tq_bdflush);
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_IOTHREAD);
+#endif
 		schedule();
 
-		preempt_enable();
-		(*my_work->fn)(my_work->arg0);
-		preempt_disable();
+		if (my_work->fn)
+			(*my_work->fn)(my_work->arg0);
 
 		/*
 		 * Thread creation: For how long have there been zero
@@ -146,11 +144,11 @@
 			pdf->when_i_went_to_sleep = jiffies;	/* Limit exit rate */
 			break;					/* exeunt */
 		}
+		my_work->fn = NULL;
 	}
 	nr_pdflush_threads--;
 //	printk("pdflush %d [%d] ends\n", nr_pdflush_threads, current->pid);
 	spin_unlock_irq(&pdflush_lock);
-	preempt_enable();
 	return 0;
 }
 
diff -Nru a/mm/swap_state.c b/mm/swap_state.c
--- a/mm/swap_state.c	Fri May 24 18:55:35 2002
+++ b/mm/swap_state.c	Fri May 24 18:55:35 2002
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/buffer_head.h>	/* for block_sync_page()/block_flushpage() */
 
 #include <asm/pgtable.h>
 
diff -Nru a/mm/swapfile.c b/mm/swapfile.c
--- a/mm/swapfile.c	Fri May 24 18:55:34 2002
+++ b/mm/swapfile.c	Fri May 24 18:55:34 2002
@@ -13,9 +13,10 @@
 #include <linux/swapctl.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
+#include <linux/namei.h>
 #include <linux/shm.h>
 #include <linux/blkdev.h>
-#include <linux/compiler.h>
+#include <linux/buffer_head.h>		/* for block_flushpage() */
 
 #include <asm/pgtable.h>
 
diff -Nru a/mm/vmscan.c b/mm/vmscan.c
--- a/mm/vmscan.c	Fri May 24 18:55:33 2002
+++ b/mm/vmscan.c	Fri May 24 18:55:33 2002
@@ -22,7 +22,8 @@
 #include <linux/highmem.h>
 #include <linux/file.h>
 #include <linux/writeback.h>
-#include <linux/compiler.h>
+#include <linux/suspend.h>
+#include <linux/buffer_head.h>		/* for try_to_release_page() */
 
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
@@ -781,18 +782,22 @@
 	 * us from recursively trying to free more memory as we're
 	 * trying to free the first piece of memory in the first place).
 	 */
-	tsk->flags |= PF_MEMALLOC;
+	tsk->flags |= PF_MEMALLOC | PF_KERNTHREAD;
 
 	/*
 	 * Kswapd main loop.
 	 */
 	for (;;) {
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_IOTHREAD);
 		__set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&kswapd_wait, &wait);
 
 		mb();
-		if (kswapd_can_sleep())
+		if (kswapd_can_sleep()) {
 			schedule();
+		}
+		
 
 		__set_current_state(TASK_RUNNING);
 		remove_wait_queue(&kswapd_wait, &wait);
diff -Nru a/net/802/Makefile b/net/802/Makefile
--- a/net/802/Makefile	Fri May 24 18:55:35 2002
+++ b/net/802/Makefile	Fri May 24 18:55:35 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the Linux 802.x protocol layers.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := 802.o
 
 export-objs = llc_macinit.o p8022.o psnap.o
 
diff -Nru a/net/802/tr.c b/net/802/tr.c
--- a/net/802/tr.c	Fri May 24 18:55:33 2002
+++ b/net/802/tr.c	Fri May 24 18:55:33 2002
@@ -20,7 +20,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
diff -Nru a/net/8021q/Makefile b/net/8021q/Makefile
--- a/net/8021q/Makefile	Fri May 24 18:55:35 2002
+++ b/net/8021q/Makefile	Fri May 24 18:55:35 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the Linux VLAN layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := 8021q.o
+obj-$(CONFIG_VLAN_8021Q) += 8021q.o
 
-obj-y := vlan.o vlanproc.o vlan_dev.o
-obj-m := $(O_TARGET)
+8021q-objs := vlan.o vlanproc.o vlan_dev.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/Makefile b/net/Makefile
--- a/net/Makefile	Fri May 24 18:55:35 2002
+++ b/net/Makefile	Fri May 24 18:55:35 2002
@@ -7,47 +7,43 @@
 
 O_TARGET :=	network.o
 
-mod-subdirs :=	ipv4/netfilter ipv6/netfilter ipx irda bluetooth atm netlink sched
+mod-subdirs :=	ipv4 ipv4/netfilter ipv6/netfilter ipx irda bluetooth atm netlink sched
 export-objs :=	netsyms.o
 
-subdir-y :=	core ethernet
-subdir-m :=	ipv4 # hum?
+obj-y	:= socket.o core/
 
-
-subdir-$(CONFIG_NET)		+= 802 sched netlink
-subdir-$(CONFIG_INET)		+= ipv4
-subdir-$(CONFIG_NETFILTER)	+= ipv4/netfilter
-subdir-$(CONFIG_UNIX)		+= unix
-subdir-$(CONFIG_IPV6)		+= ipv6
+obj-$(CONFIG_NET)		+= ethernet/ 802/ sched/ netlink/
+obj-$(CONFIG_INET)		+= ipv4/
+obj-$(CONFIG_NETFILTER)		+= ipv4/netfilter/
+obj-$(CONFIG_UNIX)		+= unix/
+obj-$(CONFIG_IPV6)		+= ipv6/
 
 ifneq ($(CONFIG_IPV6),n)
 ifneq ($(CONFIG_IPV6),)
-subdir-$(CONFIG_NETFILTER)	+= ipv6/netfilter
+obj-$(CONFIG_NETFILTER)		+= ipv6/netfilter/
 endif
 endif
 
-subdir-$(CONFIG_KHTTPD)		+= khttpd
-subdir-$(CONFIG_PACKET)		+= packet
-subdir-$(CONFIG_NET_SCHED)	+= sched
-subdir-$(CONFIG_BRIDGE)		+= bridge
-subdir-$(CONFIG_IPX)		+= ipx
-subdir-$(CONFIG_ATALK)		+= appletalk
-subdir-$(CONFIG_WAN_ROUTER)	+= wanrouter
-subdir-$(CONFIG_X25)		+= x25
-subdir-$(CONFIG_LAPB)		+= lapb
-subdir-$(CONFIG_NETROM)		+= netrom
-subdir-$(CONFIG_ROSE)		+= rose
-subdir-$(CONFIG_AX25)		+= ax25
-subdir-$(CONFIG_IRDA)		+= irda
-subdir-$(CONFIG_BLUEZ)		+= bluetooth
-subdir-$(CONFIG_SUNRPC)		+= sunrpc
-subdir-$(CONFIG_ATM)		+= atm
-subdir-$(CONFIG_DECNET)		+= decnet
-subdir-$(CONFIG_ECONET)		+= econet
-subdir-$(CONFIG_VLAN_8021Q)           += 8021q
-
+obj-$(CONFIG_KHTTPD)		+= khttpd/
+obj-$(CONFIG_PACKET)		+= packet/
+obj-$(CONFIG_NET_SCHED)		+= sched/
+obj-$(CONFIG_BRIDGE)		+= bridge/
+obj-$(CONFIG_IPX)		+= ipx/
+obj-$(CONFIG_ATALK)		+= appletalk/
+obj-$(CONFIG_WAN_ROUTER)	+= wanrouter/
+obj-$(CONFIG_X25)		+= x25/
+obj-$(CONFIG_LAPB)		+= lapb/
+obj-$(CONFIG_NETROM)		+= netrom/
+obj-$(CONFIG_ROSE)		+= rose/
+obj-$(CONFIG_AX25)		+= ax25/
+obj-$(CONFIG_IRDA)		+= irda/
+obj-$(CONFIG_BLUEZ)		+= bluetooth/
+obj-$(CONFIG_SUNRPC)		+= sunrpc/
+obj-$(CONFIG_ATM)		+= atm/
+obj-$(CONFIG_DECNET)		+= decnet/
+obj-$(CONFIG_ECONET)		+= econet/
+obj-$(CONFIG_VLAN_8021Q)	+= 8021q/
 
-obj-y	:= socket.o $(join $(subdir-y), $(patsubst %,/%.o,$(notdir $(subdir-y))))
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_MODULES)		+= netsyms.o
 obj-$(CONFIG_SYSCTL)		+= sysctl_net.o
diff -Nru a/net/appletalk/Makefile b/net/appletalk/Makefile
--- a/net/appletalk/Makefile	Fri May 24 18:55:36 2002
+++ b/net/appletalk/Makefile	Fri May 24 18:55:36 2002
@@ -1,20 +1,14 @@
 #
 # Makefile for the Linux AppleTalk layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := appletalk.o
 
 export-objs = ddp.o
 
-obj-y	 := aarp.o ddp.o
-obj-m	 := $(O_TARGET)
+obj-$(CONFIG_ATALK) += appletalk.o
 
-obj-$(CONFIG_SYSCTL) += sysctl_net_atalk.o
+appletalk-y			:= aarp.o ddp.o
+appletalk-$(CONFIG_SYSCTL)	+= sysctl_net_atalk.o
+appletalk-objs			:= $(appletalk-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/atm/Makefile b/net/atm/Makefile
--- a/net/atm/Makefile	Fri May 24 18:55:33 2002
+++ b/net/atm/Makefile	Fri May 24 18:55:33 2002
@@ -2,28 +2,15 @@
 # Makefile for the ATM Protocol Families.
 #
 
-O_TARGET	:= atm.o
-
 export-objs 	:= common.o atm_misc.o raw.o resources.o ipcommon.o proc.o
 
 mpoa-objs	:= mpc.o mpoa_caches.o mpoa_proc.o
 
 obj-$(CONFIG_ATM) := addr.o pvc.o signaling.o svc.o common.o atm_misc.o raw.o resources.o
 
-ifeq ($(CONFIG_ATM_CLIP),y)
-obj-y += clip.o
-NEED_IPCOM = ipcommon.o
-endif
-
-ifeq ($(CONFIG_NET_SCH_ATM),y)
-NEED_IPCOM = ipcommon.o
-endif
-
-obj-y += $(NEED_IPCOM)
-
-ifeq ($(CONFIG_PROC_FS),y)
-obj-y += proc.o
-endif
+obj-$(CONFIG_ATM_CLIP) += clip.o ipcommon.o
+obj-$(CONFIG_NET_SCH_ATM) += ipcommon.o
+obj-$(CONFIG_PROC_FS) += proc.o
 
 obj-$(CONFIG_ATM_LANE) += lec.o
 obj-$(CONFIG_ATM_MPOA) += mpoa.o
diff -Nru a/net/ax25/Makefile b/net/ax25/Makefile
--- a/net/ax25/Makefile	Fri May 24 18:55:33 2002
+++ b/net/ax25/Makefile	Fri May 24 18:55:33 2002
@@ -1,25 +1,17 @@
 #
 # Makefile for the Linux AX.25 layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-
-O_TARGET := ax25.o
 
 export-objs := af_ax25.o
 
-obj-y	 := ax25_addr.o ax25_dev.o ax25_iface.o ax25_in.o ax25_ip.o ax25_out.o \
+obj-$(CONFIG_AX25) += ax25.o
+
+ax25-y	 := ax25_addr.o ax25_dev.o ax25_iface.o ax25_in.o ax25_ip.o ax25_out.o \
 	    ax25_route.o ax25_std_in.o ax25_std_subr.o ax25_std_timer.o \
 	    ax25_subr.o ax25_timer.o ax25_uid.o af_ax25.o
-
-obj-m    := $(O_TARGET)
-
-obj-$(CONFIG_AX25_DAMA_SLAVE) += ax25_ds_in.o ax25_ds_subr.o ax25_ds_timer.o
-obj-$(CONFIG_SYSCTL) += sysctl_net_ax25.o
+ax25-$(CONFIG_AX25_DAMA_SLAVE) += ax25_ds_in.o ax25_ds_subr.o ax25_ds_timer.o
+ax25-$(CONFIG_SYSCTL) += sysctl_net_ax25.o
+ax25-objs := $(ax25-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
--- a/net/ax25/ax25_ds_timer.c	Fri May 24 18:55:36 2002
+++ b/net/ax25/ax25_ds_timer.c	Fri May 24 18:55:36 2002
@@ -20,7 +20,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c
--- a/net/ax25/ax25_timer.c	Fri May 24 18:55:33 2002
+++ b/net/ax25/ax25_timer.c	Fri May 24 18:55:33 2002
@@ -31,7 +31,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/bluetooth/Makefile b/net/bluetooth/Makefile
--- a/net/bluetooth/Makefile	Fri May 24 18:55:34 2002
+++ b/net/bluetooth/Makefile	Fri May 24 18:55:34 2002
@@ -1,17 +1,13 @@
 #
 # Makefile for the Bluetooth subsystem
 #
-O_TARGET	:= bluetooth.o
 
-list-multi	:= bluez.o
 export-objs	:= syms.o
-bluez-objs	:= af_bluetooth.o hci_core.o hci_conn.o hci_event.o hci_sock.o lib.o syms.o
 
 obj-$(CONFIG_BLUEZ) += bluez.o
 obj-$(CONFIG_BLUEZ_L2CAP) += l2cap.o
 obj-$(CONFIG_BLUEZ_SCO) += sco.o
 
-include $(TOPDIR)/Rules.make
+bluez-objs	:= af_bluetooth.o hci_core.o hci_conn.o hci_event.o hci_sock.o lib.o syms.o
 
-bluez.o: $(bluez-objs)
-	$(LD) -r -o $@ $(bluez-objs)
+include $(TOPDIR)/Rules.make
diff -Nru a/net/bridge/Makefile b/net/bridge/Makefile
--- a/net/bridge/Makefile	Fri May 24 18:55:36 2002
+++ b/net/bridge/Makefile	Fri May 24 18:55:36 2002
@@ -1,16 +1,11 @@
 #
 # Makefile for the IEEE 802.1d ethernet bridging layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET	:= bridge.o
-obj-y		:= br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \
+obj-$(CONFIG_BRIDGE) += bridge.o
+
+bridge-objs	:= br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \
 			br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \
 			br_stp_if.o br_stp_timer.o
-obj-m		:= $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/bridge/br.c b/net/bridge/br.c
--- a/net/bridge/br.c	Fri May 24 18:55:34 2002
+++ b/net/bridge/br.c	Fri May 24 18:55:34 2002
@@ -74,8 +74,6 @@
 #endif
 }
 
-EXPORT_NO_SYMBOLS;
-
 module_init(br_init)
 module_exit(br_deinit)
 MODULE_LICENSE("GPL");
diff -Nru a/net/core/Makefile b/net/core/Makefile
--- a/net/core/Makefile	Fri May 24 18:55:35 2002
+++ b/net/core/Makefile	Fri May 24 18:55:35 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the Linux networking core.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := core.o
 
 export-objs := netfilter.o profile.o
 
diff -Nru a/net/core/profile.c b/net/core/profile.c
--- a/net/core/profile.c	Fri May 24 18:55:36 2002
+++ b/net/core/profile.c	Fri May 24 18:55:36 2002
@@ -1,7 +1,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
diff -Nru a/net/core/sock.c b/net/core/sock.c
--- a/net/core/sock.c	Fri May 24 18:55:36 2002
+++ b/net/core/sock.c	Fri May 24 18:55:36 2002
@@ -641,7 +641,7 @@
 		sysctl_wmem_max = 32767;
 		sysctl_rmem_max = 32767;
 		sysctl_wmem_default = 32767;
-		sysctl_wmem_default = 32767;
+		sysctl_rmem_default = 32767;
 	} else if (num_physpages >= 131072) {
 		sysctl_wmem_max = 131071;
 		sysctl_rmem_max = 131071;
diff -Nru a/net/core/utils.c b/net/core/utils.c
--- a/net/core/utils.c	Fri May 24 18:55:33 2002
+++ b/net/core/utils.c	Fri May 24 18:55:33 2002
@@ -17,7 +17,7 @@
 #include <asm/system.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 
diff -Nru a/net/decnet/Makefile b/net/decnet/Makefile
--- a/net/decnet/Makefile	Fri May 24 18:55:34 2002
+++ b/net/decnet/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,11 @@
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := decnet.o
-obj-y    := af_decnet.o dn_nsp_in.o dn_nsp_out.o dn_route.o dn_dev.o dn_neigh.o dn_timer.o
-obj-m	 := $(O_TARGET)
+obj-$(CONFIG_DECNET) += decnet.o
 
-obj-$(CONFIG_DECNET_ROUTER) += dn_fib.o dn_rules.o dn_table.o
-obj-$(CONFIG_DECNET_FW) += dn_fw.o
-
-obj-y += sysctl_net_decnet.o
+decnet-y := af_decnet.o dn_nsp_in.o dn_nsp_out.o dn_route.o dn_dev.o dn_neigh.o dn_timer.o
+decnet-$(CONFIG_DECNET_ROUTER) += dn_fib.o dn_rules.o dn_table.o
+decnet-$(CONFIG_DECNET_FW) += dn_fw.o
+decnet-y += sysctl_net_decnet.o
+decnet-objs := $(decnet-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
--- a/net/decnet/af_decnet.c	Fri May 24 18:55:33 2002
+++ b/net/decnet/af_decnet.c	Fri May 24 18:55:33 2002
@@ -2228,7 +2228,6 @@
 
 
 #ifdef MODULE
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION("The Linux DECnet Network Protocol");
 MODULE_AUTHOR("Linux DECnet Project Team");
 MODULE_LICENSE("GPL");
diff -Nru a/net/econet/Makefile b/net/econet/Makefile
--- a/net/econet/Makefile	Fri May 24 18:55:35 2002
+++ b/net/econet/Makefile	Fri May 24 18:55:35 2002
@@ -1,16 +1,10 @@
 #
 # Makefile for Econet support code.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := econet.o
+obj-$(CONFIG_ECONET) += econet.o
 
-obj-y := af_econet.o
-obj-m := $(O_TARGET)
+econet-objs := af_econet.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/ethernet/Makefile b/net/ethernet/Makefile
--- a/net/ethernet/Makefile	Fri May 24 18:55:33 2002
+++ b/net/ethernet/Makefile	Fri May 24 18:55:33 2002
@@ -1,28 +1,10 @@
 #
 # Makefile for the Linux Ethernet layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := ethernet.o
-
-OBJS	:= eth.o
-
-ifeq ($(CONFIG_SYSCTL),y)
-OBJS += sysctl_net_ether.o
-endif
-
-ifdef CONFIG_IPX
-OBJ2	:= pe2.o
-endif
-
-ifdef CONFIG_ATALK
-OBJ2	:= pe2.o
-endif
-
-obj-$(CONFIG_NET)	:= $(OBJS) $(OBJ2)
+obj-y					+= eth.o
+obj-$(CONFIG_SYSCTL)			+= sysctl_net_ether.o
+obj-$(subst m,y,$(CONFIG_IPX))		+= pe2.o
+obj-$(subst m,y,$(CONFIG_ATALK))	+= pe2.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/ipv4/Makefile b/net/ipv4/Makefile
--- a/net/ipv4/Makefile	Fri May 24 18:55:34 2002
+++ b/net/ipv4/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the Linux TCP/IP (INET) layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := ipv4.o
 
 export-objs = ipip.o ip_gre.o
 
diff -Nru a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
--- a/net/ipv4/fib_semantics.c	Fri May 24 18:55:34 2002
+++ b/net/ipv4/fib_semantics.c	Fri May 24 18:55:34 2002
@@ -21,7 +21,7 @@
 #include <asm/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/socket.h>
diff -Nru a/net/ipv4/icmp.c b/net/ipv4/icmp.c
--- a/net/ipv4/icmp.c	Fri May 24 18:55:35 2002
+++ b/net/ipv4/icmp.c	Fri May 24 18:55:35 2002
@@ -65,7 +65,7 @@
 
 #include <linux/config.h>
 #include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/fcntl.h>
 #include <linux/socket.h>
diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
--- a/net/ipv4/igmp.c	Fri May 24 18:55:36 2002
+++ b/net/ipv4/igmp.c	Fri May 24 18:55:36 2002
@@ -76,7 +76,7 @@
 #include <asm/system.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
diff -Nru a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
--- a/net/ipv4/ip_fragment.c	Fri May 24 18:55:34 2002
+++ b/net/ipv4/ip_fragment.c	Fri May 24 18:55:34 2002
@@ -24,7 +24,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/mm.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
 #include <linux/icmp.h>
diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
--- a/net/ipv4/ip_output.c	Fri May 24 18:55:36 2002
+++ b/net/ipv4/ip_output.c	Fri May 24 18:55:36 2002
@@ -322,7 +322,8 @@
 		/* Reject packet ONLY if TCP might fragment
 		 * it itself, if were careful enough.
 		 */
-		NETDEBUG(printk(KERN_DEBUG "sending pkt_too_big to self\n"));
+		NETDEBUG(printk(KERN_DEBUG "sending pkt_too_big (len[%u] pmtu[%u]) to self\n",
+				skb->len, rt->u.dst.pmtu));
 
 		icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
 			  htonl(rt->u.dst.pmtu));
diff -Nru a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
--- a/net/ipv4/ipconfig.c	Fri May 24 18:55:33 2002
+++ b/net/ipv4/ipconfig.c	Fri May 24 18:55:33 2002
@@ -32,7 +32,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/utsname.h>
diff -Nru a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
--- a/net/ipv4/netfilter/Makefile	Fri May 24 18:55:34 2002
+++ b/net/ipv4/netfilter/Makefile	Fri May 24 18:55:34 2002
@@ -2,9 +2,9 @@
 # Makefile for the netfilter modules on top of IPv4.
 #
 
-O_TARGET := netfilter.o
-
-export-objs = ip_conntrack_standalone.o ip_fw_compat.o ip_nat_standalone.o ip_tables.o arp_tables.o
+export-objs  := ip_conntrack_standalone.o ip_fw_compat.o ip_nat_standalone.o \
+		ip_tables.o arp_tables.o ip_conntrack_ftp.o \
+		ip_conntrack_irc.o
 
 # objects for the conntrack and NAT core (used by standalone and backw. compat)
 ip_nf_conntrack-objs	:= ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
@@ -25,14 +25,7 @@
 
 # connection tracking helpers
 obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o
-ifdef CONFIG_IP_NF_NAT_FTP
-	export-objs += ip_conntrack_ftp.o
-endif
-
 obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o
-ifdef CONFIG_IP_NF_NAT_IRC
-	export-objs += ip_conntrack_irc.o
-endif
 
 # NAT helpers 
 obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o
diff -Nru a/net/ipv4/netfilter/ip_fw_compat.c b/net/ipv4/netfilter/ip_fw_compat.c
--- a/net/ipv4/netfilter/ip_fw_compat.c	Fri May 24 18:55:35 2002
+++ b/net/ipv4/netfilter/ip_fw_compat.c	Fri May 24 18:55:35 2002
@@ -18,7 +18,6 @@
 
 /* Theoretically, we could one day use 2.4 helpers, but for now it
    just confuses depmod --RR */
-EXPORT_NO_SYMBOLS;
 
 static struct firewall_ops *fwops;
 
diff -Nru a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
--- a/net/ipv4/netfilter/ipt_ah.c	Fri May 24 18:55:36 2002
+++ b/net/ipv4/netfilter/ipt_ah.c	Fri May 24 18:55:36 2002
@@ -5,7 +5,6 @@
 #include <linux/netfilter_ipv4/ipt_ah.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
 
 #ifdef DEBUG_CONNTRACK
diff -Nru a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c
--- a/net/ipv4/netfilter/ipt_esp.c	Fri May 24 18:55:36 2002
+++ b/net/ipv4/netfilter/ipt_esp.c	Fri May 24 18:55:36 2002
@@ -5,7 +5,6 @@
 #include <linux/netfilter_ipv4/ipt_esp.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_LICENSE("GPL");
 
 #ifdef DEBUG_CONNTRACK
diff -Nru a/net/ipv4/tcp.c b/net/ipv4/tcp.c
--- a/net/ipv4/tcp.c	Fri May 24 18:55:34 2002
+++ b/net/ipv4/tcp.c	Fri May 24 18:55:34 2002
@@ -1674,6 +1674,12 @@
 				}
 			}
 		}
+		if ((flags & MSG_PEEK) && peek_seq != tp->copied_seq) {
+			if (net_ratelimit())
+				printk(KERN_DEBUG "TCP(%s:%d): Application bug, race in MSG_PEEK.\n",
+				       current->comm, current->pid);
+			peek_seq = tp->copied_seq;
+		}
 		continue;
 
 	found_ok_skb:
diff -Nru a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
--- a/net/ipv4/tcp_input.c	Fri May 24 18:55:34 2002
+++ b/net/ipv4/tcp_input.c	Fri May 24 18:55:34 2002
@@ -466,7 +466,7 @@
 	} else {
 		/* no previous measure. */
 		tp->srtt = m<<3;	/* take the measured time to be rtt */
-		tp->mdev = m<<2;	/* make sure rto = 3*rtt */
+		tp->mdev = m<<1;	/* make sure rto = 3*rtt */
 		tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN);
 		tp->rtt_seq = tp->snd_nxt;
 	}
diff -Nru a/net/ipv6/Makefile b/net/ipv6/Makefile
--- a/net/ipv6/Makefile	Fri May 24 18:55:36 2002
+++ b/net/ipv6/Makefile	Fri May 24 18:55:36 2002
@@ -1,23 +1,16 @@
 #
 # Makefile for the Linux TCP/IP (INET6) layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-
-
-O_TARGET := ipv6.o
 
 export-objs :=  ipv6_syms.o
 
-obj-y :=	af_inet6.o ip6_output.o ip6_input.o addrconf.o sit.o \
+obj-$(CONFIG_IPV6) += ipv6.o
+
+ipv6-objs :=	af_inet6.o ip6_output.o ip6_input.o addrconf.o sit.o \
 		route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \
 		protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
 		exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \
 		ip6_flowlabel.o ipv6_syms.o
-
-obj-m  := $(O_TARGET)
 
 #obj-$(CONFIG_IPV6_FIREWALL) += ip6_fw.o
 
diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
--- a/net/ipv6/mcast.c	Fri May 24 18:55:34 2002
+++ b/net/ipv6/mcast.c	Fri May 24 18:55:34 2002
@@ -28,7 +28,7 @@
 #include <linux/string.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/net.h>
 #include <linux/in6.h>
 #include <linux/netdevice.h>
diff -Nru a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile
--- a/net/ipv6/netfilter/Makefile	Fri May 24 18:55:33 2002
+++ b/net/ipv6/netfilter/Makefile	Fri May 24 18:55:33 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the netfilter modules on top of IPv6.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := netfilter.o
 
 export-objs := ip6_tables.o
 
diff -Nru a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
--- a/net/ipv6/reassembly.c	Fri May 24 18:55:34 2002
+++ b/net/ipv6/reassembly.c	Fri May 24 18:55:34 2002
@@ -29,7 +29,7 @@
 #include <linux/string.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/net.h>
 #include <linux/netdevice.h>
 #include <linux/in6.h>
diff -Nru a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
--- a/net/ipv6/tcp_ipv6.c	Fri May 24 18:55:36 2002
+++ b/net/ipv6/tcp_ipv6.c	Fri May 24 18:55:36 2002
@@ -29,7 +29,7 @@
 #include <linux/socket.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/netdevice.h>
diff -Nru a/net/ipx/Makefile b/net/ipx/Makefile
--- a/net/ipx/Makefile	Fri May 24 18:55:34 2002
+++ b/net/ipx/Makefile	Fri May 24 18:55:34 2002
@@ -1,25 +1,14 @@
 #
 # Makefile for the Linux IPX layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-# We only get in/to here if CONFIG_IPX = 'y' or 'm'
-
-O_TARGET := ipx.o
 
 export-objs = af_ipx.o af_spx.o
 
-obj-y	:= af_ipx.o
-
-ifeq ($(CONFIG_IPX),m)
-  obj-m += $(O_TARGET)
-endif
+obj-$(CONFIG_IPX) += ipx.o
 
-obj-$(CONFIG_SYSCTL) += sysctl_net_ipx.o
-obj-$(CONFIG_SPX) += af_spx.o
+ipx-y			:= af_ipx.o
+ipx-$(CONFIG_SYSCTL)	+= sysctl_net_ipx.o
+ipx-$(CONFIG_SPX)	+= af_spx.o
+ipx-objs		:= $(ipx-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/irda/Makefile b/net/irda/Makefile
--- a/net/irda/Makefile	Fri May 24 18:55:36 2002
+++ b/net/irda/Makefile	Fri May 24 18:55:36 2002
@@ -1,42 +1,20 @@
 #
 # Makefile for the Linux IrDA protocol layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := irda.o
 
 export-objs := irsyms.o
 
-obj-y	 := iriap.o iriap_event.o irlmp.o irlmp_event.o irlmp_frame.o \
-            irlap.o irlap_event.o irlap_frame.o timer.o qos.o irqueue.o \
-            irttp.o irda_device.o irias_object.o crc.o wrapper.o af_irda.o \
-	    discovery.o parameters.o irsyms.o
-
-ifeq ($(CONFIG_IRDA),m)
-obj-m   := $(O_TARGET)
-endif
-
-obj-$(CONFIG_PROC_FS) += irproc.o
-obj-$(CONFIG_SYSCTL) += irsysctl.o
-
-subdir-$(CONFIG_IRLAN) += irlan
-subdir-$(CONFIG_IRNET) += irnet
-subdir-$(CONFIG_IRCOMM) += ircomm
-
-ifeq ($(CONFIG_IRLAN),y)
-obj-y += irlan/irlan.o
-endif
-
-ifeq ($(CONFIG_IRNET),y)
-obj-y += irnet/irnet.o
-endif
-
-ifeq ($(CONFIG_IRCOMM),y)
-obj-y += ircomm/ircomm_and_tty.o
-endif
+obj-$(CONFIG_IRDA) += irda.o
+obj-$(CONFIG_IRLAN) += irlan/
+obj-$(CONFIG_IRNET) += irnet/
+obj-$(CONFIG_IRCOMM) += ircomm/
+
+irda-y := iriap.o iriap_event.o irlmp.o irlmp_event.o irlmp_frame.o \
+          irlap.o irlap_event.o irlap_frame.o timer.o qos.o irqueue.o \
+          irttp.o irda_device.o irias_object.o crc.o wrapper.o af_irda.o \
+	  discovery.o parameters.o irsyms.o
+irda-$(CONFIG_PROC_FS) += irproc.o
+irda-$(CONFIG_SYSCTL) += irsysctl.o
+irda-objs := $(irda-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/irda/ircomm/Makefile b/net/irda/ircomm/Makefile
--- a/net/irda/ircomm/Makefile	Fri May 24 18:55:33 2002
+++ b/net/irda/ircomm/Makefile	Fri May 24 18:55:33 2002
@@ -2,14 +2,12 @@
 # Makefile for the Linux IrDA IrCOMM protocol layer.
 #
 
-O_TARGET := ircomm_and_tty.o
-
 export-objs := ircomm_core.o
 
+obj-$(CONFIG_IRCOMM) += ircomm.o ircomm-tty.o
+
 ircomm-objs := ircomm_core.o ircomm_event.o ircomm_lmp.o ircomm_ttp.o
 ircomm-tty-objs := ircomm_tty.o ircomm_tty_attach.o ircomm_tty_ioctl.o ircomm_param.o
-
-obj-$(CONFIG_IRCOMM) += ircomm.o ircomm-tty.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/irda/irlan/Makefile b/net/irda/irlan/Makefile
--- a/net/irda/irlan/Makefile	Fri May 24 18:55:34 2002
+++ b/net/irda/irlan/Makefile	Fri May 24 18:55:34 2002
@@ -1,15 +1,9 @@
 #
 # Makefile for the Linux IrDA IrLAN protocol layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := irlan.o
+obj-$(CONFIG_IRLAN) += irlan.o
 
-obj-y	:= irlan_common.o irlan_eth.o irlan_event.o irlan_client.o irlan_provider.o irlan_filter.o irlan_provider_event.o irlan_client_event.o
-obj-m	:= $(O_TARGET)
+irlan-objs := irlan_common.o irlan_eth.o irlan_event.o irlan_client.o irlan_provider.o irlan_filter.o irlan_provider_event.o irlan_client_event.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/irda/irnet/Makefile b/net/irda/irnet/Makefile
--- a/net/irda/irnet/Makefile	Fri May 24 18:55:36 2002
+++ b/net/irda/irnet/Makefile	Fri May 24 18:55:36 2002
@@ -1,16 +1,9 @@
 #
 # Makefile for the Linux IrDA IrNET protocol layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-MOD_LIST_NAME := IRDA_MODULES
-O_TARGET := irnet.o
+obj-$(CONFIG_IRNET) += irnet.o
 
-obj-y	:= irnet_ppp.o irnet_irda.o
-obj-m	:= $(O_TARGET)
+irnet-objs := irnet_ppp.o irnet_irda.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/khttpd/Makefile b/net/khttpd/Makefile
--- a/net/khttpd/Makefile	Fri May 24 18:55:36 2002
+++ b/net/khttpd/Makefile	Fri May 24 18:55:36 2002
@@ -1,18 +1,12 @@
 #
 # Makefile for kHTTPd
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := khttpd.o
-
-obj-m := 	$(O_TARGET)
-obj-y := 	main.o accept.o datasending.o logging.o misc.o rfc.o rfc_time.o security.o \
-		sockets.o sysctl.o userspace.o waitheaders.o
+obj-$(CONFIG_KHTTPD) += khttpd.o
 
+khttpd-objs := 	main.o accept.o datasending.o logging.o misc.o rfc.o \
+		rfc_time.o security.o sockets.o sysctl.o userspace.o \
+		waitheaders.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/lapb/Makefile b/net/lapb/Makefile
--- a/net/lapb/Makefile	Fri May 24 18:55:33 2002
+++ b/net/lapb/Makefile	Fri May 24 18:55:33 2002
@@ -1,19 +1,12 @@
 #
 # Makefile for the Linux LAPB layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-
-O_TARGET := lapb.o
 
 export-objs := lapb_iface.o
 
-obj-y	 := lapb_in.o lapb_out.o lapb_subr.o lapb_timer.o lapb_iface.o
-obj-m    := $(O_TARGET)
+obj-$(CONFIG_LAPB) += lapb.o
+
+lapb-objs := lapb_in.o lapb_out.o lapb_subr.o lapb_timer.o lapb_iface.o
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
--- a/net/lapb/lapb_iface.c	Fri May 24 18:55:35 2002
+++ b/net/lapb/lapb_iface.c	Fri May 24 18:55:35 2002
@@ -21,7 +21,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/lapb/lapb_timer.c b/net/lapb/lapb_timer.c
--- a/net/lapb/lapb_timer.c	Fri May 24 18:55:34 2002
+++ b/net/lapb/lapb_timer.c	Fri May 24 18:55:34 2002
@@ -19,7 +19,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/netlink/Makefile b/net/netlink/Makefile
--- a/net/netlink/Makefile	Fri May 24 18:55:35 2002
+++ b/net/netlink/Makefile	Fri May 24 18:55:35 2002
@@ -1,20 +1,10 @@
 #
 # Makefile for the netlink driver.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := netlink.o
 
 export-objs := af_netlink.o
 
-obj-y  := af_netlink.o
-
-obj-m  :=
-
-obj-$(CONFIG_NETLINK_DEV) += netlink_dev.o
+obj-y  				:= af_netlink.o
+obj-$(CONFIG_NETLINK_DEV)	+= netlink_dev.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/netrom/Makefile b/net/netrom/Makefile
--- a/net/netrom/Makefile	Fri May 24 18:55:36 2002
+++ b/net/netrom/Makefile	Fri May 24 18:55:36 2002
@@ -1,19 +1,13 @@
 #
 # Makefile for the Linux NET/ROM layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := netrom.o
+obj-$(CONFIG_NETROM) += netrom.o
 
-obj-y	 := af_netrom.o nr_dev.o nr_in.o nr_loopback.o nr_out.o nr_route.o \
-	    nr_subr.o nr_timer.o
-obj-m    := $(O_TARGET)
-
-obj-$(CONFIG_SYSCTL) += sysctl_net_netrom.o
+netrom-y		:= af_netrom.o nr_dev.o nr_in.o nr_loopback.o \
+			   nr_out.o nr_route.o nr_subr.o nr_timer.o
+netrom-$(CONFIG_SYSCTL)	+= sysctl_net_netrom.o
+netrom-objs		:= $(netrom-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
--- a/net/netrom/af_netrom.c	Fri May 24 18:55:35 2002
+++ b/net/netrom/af_netrom.c	Fri May 24 18:55:35 2002
@@ -1331,8 +1331,6 @@
 module_init(nr_proto_init);
 
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_PARM(nr_ndevs, "i");
 MODULE_PARM_DESC(nr_ndevs, "number of NET/ROM devices");
 
diff -Nru a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c
--- a/net/netrom/nr_timer.c	Fri May 24 18:55:34 2002
+++ b/net/netrom/nr_timer.c	Fri May 24 18:55:34 2002
@@ -20,7 +20,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/packet/Makefile b/net/packet/Makefile
--- a/net/packet/Makefile	Fri May 24 18:55:34 2002
+++ b/net/packet/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the packet AF.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := packet.o
 
 obj-$(CONFIG_PACKET) += af_packet.o
 
diff -Nru a/net/rose/Makefile b/net/rose/Makefile
--- a/net/rose/Makefile	Fri May 24 18:55:36 2002
+++ b/net/rose/Makefile	Fri May 24 18:55:36 2002
@@ -1,19 +1,13 @@
 #
 # Makefile for the Linux Rose (X.25 PLP) layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := rose.o
+obj-$(CONFIG_ROSE) += rose.o
 
-obj-y	 := af_rose.o rose_dev.o rose_in.o rose_link.o rose_loopback.o \
-	    rose_out.o rose_route.o rose_subr.o rose_timer.o
-obj-m    := $(O_TARGET)
-
-obj-$(CONFIG_SYSCTL) += sysctl_net_rose.o
+rose-y	  := af_rose.o rose_dev.o rose_in.o rose_link.o rose_loopback.o \
+	     rose_out.o rose_route.o rose_subr.o rose_timer.o
+rose-$(CONFIG_SYSCTL) += sysctl_net_rose.o
+rose-objs := $(rose-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c
--- a/net/rose/af_rose.c	Fri May 24 18:55:35 2002
+++ b/net/rose/af_rose.c	Fri May 24 18:55:35 2002
@@ -1512,8 +1512,6 @@
 }
 module_init(rose_proto_init);
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_PARM(rose_ndevs, "i");
 MODULE_PARM_DESC(rose_ndevs, "number of ROSE devices");
 
diff -Nru a/net/rose/rose_link.c b/net/rose/rose_link.c
--- a/net/rose/rose_link.c	Fri May 24 18:55:33 2002
+++ b/net/rose/rose_link.c	Fri May 24 18:55:33 2002
@@ -19,7 +19,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/rose/rose_timer.c b/net/rose/rose_timer.c
--- a/net/rose/rose_timer.c	Fri May 24 18:55:36 2002
+++ b/net/rose/rose_timer.c	Fri May 24 18:55:36 2002
@@ -20,7 +20,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/sched/Makefile b/net/sched/Makefile
--- a/net/sched/Makefile	Fri May 24 18:55:35 2002
+++ b/net/sched/Makefile	Fri May 24 18:55:35 2002
@@ -2,10 +2,7 @@
 # Makefile for the Linux Traffic Control Unit.
 #
 
-O_TARGET := sched.o
-
 obj-y	:= sch_generic.o
-
 
 obj-$(CONFIG_NET_SCHED)		+= sch_api.o sch_fifo.o
 obj-$(CONFIG_NET_ESTIMATOR)	+= estimator.o
diff -Nru a/net/sched/estimator.c b/net/sched/estimator.c
--- a/net/sched/estimator.c	Fri May 24 18:55:33 2002
+++ b/net/sched/estimator.c	Fri May 24 18:55:33 2002
@@ -14,7 +14,7 @@
 #include <asm/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
diff -Nru a/net/sched/sch_csz.c b/net/sched/sch_csz.c
--- a/net/sched/sch_csz.c	Fri May 24 18:55:36 2002
+++ b/net/sched/sch_csz.c	Fri May 24 18:55:36 2002
@@ -17,7 +17,7 @@
 #include <asm/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
diff -Nru a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
--- a/net/sched/sch_sfq.c	Fri May 24 18:55:35 2002
+++ b/net/sched/sch_sfq.c	Fri May 24 18:55:35 2002
@@ -16,7 +16,7 @@
 #include <asm/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
diff -Nru a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
--- a/net/sched/sch_tbf.c	Fri May 24 18:55:33 2002
+++ b/net/sched/sch_tbf.c	Fri May 24 18:55:33 2002
@@ -17,7 +17,7 @@
 #include <asm/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
diff -Nru a/net/sunrpc/Makefile b/net/sunrpc/Makefile
--- a/net/sunrpc/Makefile	Fri May 24 18:55:33 2002
+++ b/net/sunrpc/Makefile	Fri May 24 18:55:33 2002
@@ -1,24 +1,17 @@
 #
 # Makefile for Linux kernel SUN RPC
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := sunrpc.o
+obj-$(CONFIG_SUNRPC) += sunrpc.o
 
 export-objs := sunrpc_syms.o
 
-obj-y    := clnt.o xprt.o sched.o \
+sunrpc-y := clnt.o xprt.o sched.o \
 	    auth.o auth_null.o auth_unix.o \
 	    svc.o svcsock.o svcauth.o \
 	    pmap_clnt.o xdr.o sunrpc_syms.o
-
-obj-$(CONFIG_PROC_FS) += stats.o
-obj-$(CONFIG_SYSCTL) += sysctl.o
-
-obj-m  := $(O_TARGET)
+sunrpc-$(CONFIG_PROC_FS) += stats.o
+sunrpc-$(CONFIG_SYSCTL) += sysctl.o
+sunrpc-objs := $(sunrpc-y)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/unix/Makefile b/net/unix/Makefile
--- a/net/unix/Makefile	Fri May 24 18:55:34 2002
+++ b/net/unix/Makefile	Fri May 24 18:55:34 2002
@@ -1,18 +1,12 @@
 #
 # Makefile for the Linux unix domain socket layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := unix.o
+obj-$(CONFIG_UNIX)	+= unix.o
 
-obj-y	 := af_unix.o garbage.o
-obj-m    := $(O_TARGET)
-
-obj-$(CONFIG_SYSCTL) += sysctl_net_unix.o
+unix-y			:= af_unix.o garbage.o
+unix-$(CONFIG_SYSCTL)	+= sysctl_net_unix.o
+unix-objs		:= $(unix-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
--- a/net/unix/af_unix.c	Fri May 24 18:55:36 2002
+++ b/net/unix/af_unix.c	Fri May 24 18:55:36 2002
@@ -88,6 +88,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/stat.h>
+#include <linux/namei.h>
 #include <linux/socket.h>
 #include <linux/un.h>
 #include <linux/fcntl.h>
diff -Nru a/net/wanrouter/Makefile b/net/wanrouter/Makefile
--- a/net/wanrouter/Makefile	Fri May 24 18:55:33 2002
+++ b/net/wanrouter/Makefile	Fri May 24 18:55:33 2002
@@ -1,20 +1,11 @@
 #
 # Makefile for the Linux WAN router layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
-
-O_TARGET := wanrouter.o
 
 export-objs := wanmain.o
 
-obj-y :=  wanproc.o wanmain.o
-obj-m := $(O_TARGET)
-ifneq ($(CONFIG_VENDOR_SANGOMA),n)
-	obj-m += $(O_TARGET)
-endif
+obj-$(CONFIG_WAN_ROUTER) += wanrouter.o
+
+wanrouter-objs :=  wanproc.o wanmain.o
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c
--- a/net/wanrouter/wanproc.c	Fri May 24 18:55:35 2002
+++ b/net/wanrouter/wanproc.c	Fri May 24 18:55:35 2002
@@ -233,18 +233,6 @@
 	release:	seq_release,
 };
 
-static void *single_start(struct seq_file *p, loff_t *pos)
-{
-	return *pos == 0 ? p->private : NULL;
-}
-static void *single_next(struct seq_file *p, void *v, loff_t *pos)
-{
-	++*pos;
-	return NULL;
-}
-static void single_stop(struct seq_file *p, void *v)
-{
-}
 static int wandev_show(struct seq_file *m, void *v)
 {
 	wan_device_t *wandev = v;
@@ -306,20 +294,10 @@
 		"aborted frames transmitted", wandev->stats.tx_aborted_errors);
 	return 0;
 }
-static struct seq_operations wandev_op = {
-	start:	single_start,
-	next:	single_next,
-	stop:	single_stop,
-	show:	wandev_show,
-};
+
 static int wandev_open(struct inode *inode, struct file *file)
 {
-	int ret = seq_open(file, &wandev_op);
-	if (!ret) {
-		struct seq_file *m = file->private_data;
-		m->private = PDE(inode)->data;
-	}
-	return ret;
+	return single_open(file, wandev_show, PDE(inode)->data);
 }
 
 static struct file_operations wandev_fops =
@@ -327,7 +305,7 @@
 	open:		wandev_open,
 	read:		seq_read,
 	llseek:		seq_lseek,
-	release:	seq_release,
+	release:	single_release,
 	ioctl:		wanrouter_ioctl,
 };
 
diff -Nru a/net/x25/Makefile b/net/x25/Makefile
--- a/net/x25/Makefile	Fri May 24 18:55:34 2002
+++ b/net/x25/Makefile	Fri May 24 18:55:34 2002
@@ -1,19 +1,14 @@
 #
 # Makefile for the Linux X.25 Packet layer.
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definition is now in the main makefile...
 
-O_TARGET := x25.o
+obj-$(CONFIG_X25) += x25.o
 
-obj-y	 := af_x25.o x25_dev.o x25_facilities.o x25_in.o x25_link.o x25_out.o \
-	    x25_route.o x25_subr.o x25_timer.o
-obj-m    := $(O_TARGET)
-
-obj-$(CONFIG_SYSCTL) += sysctl_net_x25.o
+x25-y			:= af_x25.o x25_dev.o x25_facilities.o x25_in.o \
+			   x25_link.o x25_out.o x25_route.o x25_subr.o \
+			   x25_timer.o
+x25-$(CONFIG_SYSCTL)	+= sysctl_net_x25.o
+x25-objs		:= $(x25-y)
 
 include $(TOPDIR)/Rules.make
 
diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
--- a/net/x25/af_x25.c	Fri May 24 18:55:35 2002
+++ b/net/x25/af_x25.c	Fri May 24 18:55:35 2002
@@ -1367,8 +1367,6 @@
 
 
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>");
 MODULE_DESCRIPTION("The X.25 Packet Layer network layer protocol");
 MODULE_LICENSE("GPL");
diff -Nru a/net/x25/x25_link.c b/net/x25/x25_link.c
--- a/net/x25/x25_link.c	Fri May 24 18:55:33 2002
+++ b/net/x25/x25_link.c	Fri May 24 18:55:33 2002
@@ -25,7 +25,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/net/x25/x25_timer.c b/net/x25/x25_timer.c
--- a/net/x25/x25_timer.c	Fri May 24 18:55:33 2002
+++ b/net/x25/x25_timer.c	Fri May 24 18:55:33 2002
@@ -23,7 +23,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
diff -Nru a/scripts/mkcompile_h b/scripts/mkcompile_h
--- a/scripts/mkcompile_h	Fri May 24 18:55:35 2002
+++ b/scripts/mkcompile_h	Fri May 24 18:55:35 2002
@@ -3,13 +3,20 @@
 SMP=$3
 CC=$4
 
+if [ -r ../.version ]; then
+  VERSION=`cat ../.version`
+else
+  VERSION=0
+  echo 0 > ../.version
+fi
+
 # Generate a temporary compile.h
 
-( echo /\* This file is auto generated, version `cat ../.version` \*/
+( echo /\* This file is auto generated, version $VERSION \*/
 
   echo \#define UTS_MACHINE \"$ARCH\"
 
-  echo -n \#define UTS_VERSION \"\#`cat ../.version`
+  echo -n \#define UTS_VERSION \"\#$VERSION
   if [ -n "$SMP" ] ; then echo -n " SMP"; fi
   echo ' '`date`'"'
 
diff -Nru a/scripts/mkversion_h b/scripts/mkversion_h
--- a/scripts/mkversion_h	Fri May 24 18:55:35 2002
+++ b/scripts/mkversion_h	Fri May 24 18:55:35 2002
@@ -11,4 +11,14 @@
   echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'
 ) > .tmpversion
 
-mv -f .tmpversion $TARGET
\ No newline at end of file
+# Only replace the real version.h if the new one is different
+# in order to preserve the timestamp and avoid unnecessary
+# recompilations.
+
+if [ -r $TARGET ] && \
+      cmp -s $TARGET .tmpversion; then
+   echo $TARGET is unchanged;
+   rm -f .tmpversion
+else
+   mv -f .tmpversion $TARGET
+fi
diff -Nru a/sound/Makefile b/sound/Makefile
--- a/sound/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/Makefile	Fri May 24 18:55:34 2002
@@ -8,25 +8,13 @@
 mod-subdirs	:= oss core i2c drivers isa pci ppc synth
 
 obj-$(CONFIG_SOUND) += soundcore.o
+obj-$(CONFIG_SOUND_PRIME) += oss/
+obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/
 
-subdir-$(CONFIG_SOUND_PRIME) += oss
-ifeq ($(CONFIG_SOUND_PRIME),y)
-  obj-y += oss/_oss.o
-endif
-
-subdir-$(CONFIG_SND) += core i2c drivers isa pci ppc arm synth
 ifeq ($(CONFIG_SND),y)
-  obj-y += core/_core.o i2c/_i2c.o
-  obj-y += drivers/_drivers.o
-  obj-y += isa/_isa.o
-  obj-y += pci/_pci.o
-  obj-y += arm/_arm.o
-  obj-y += ppc/_ppc.o
-  obj-y += synth/_synth.o
   obj-y += last.o
 endif
 
 soundcore-objs  := sound_core.o sound_firmware.o
-
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/arm/Makefile b/sound/arm/Makefile
--- a/sound/arm/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/arm/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 # Makefile for ALSA
 #
 
-O_TARGET    := _arm.o
-
 snd-sa11xx-uda1341-objs := sa11xx-uda1341.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
--- a/sound/arm/sa11xx-uda1341.c	Fri May 24 18:55:33 2002
+++ b/sound/arm/sa11xx-uda1341.c	Fri May 24 18:55:33 2002
@@ -40,8 +40,6 @@
 
 /* {{{ Type definitions */
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Tomas Kasparek <tomas.kasparek@seznam.cz>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SA1100/SA1111 + UDA1341TS driver for ALSA");
diff -Nru a/sound/core/Makefile b/sound/core/Makefile
--- a/sound/core/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/core/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _core.o
-
 export-objs  := sound.o pcm.o pcm_lib.o rawmidi.o timer.o rtctimer.o hwdep.o
 
 mod-subdirs  := oss seq
@@ -29,26 +27,10 @@
   obj-$(CONFIG_SND_RTCTIMER) += snd-rtctimer.o
 endif
 obj-$(CONFIG_SND_HWDEP) += snd-hwdep.o
-
-subdir-$(CONFIG_SND_MIXER_OSS) += oss
-subdir-$(CONFIG_SND_PCM_OSS) += oss
-ifeq ($(filter $(subdir-y),oss),oss)
-  obj-y += oss/_oss.o
-endif
-
-obj-$(CONFIG_SND_PCM_OSS) += snd-pcm.o snd-timer.o
-
-subdir-$(CONFIG_SND_SEQUENCER) += seq
-ifeq ($(CONFIG_SND_SEQUENCER),y)
-  obj-y += seq/_seq.o
-endif
-
-obj-$(CONFIG_SND_SEQUENCER) += snd-timer.o
-
-subdir-$(CONFIG_SND_BIT32_EMUL) += ioctl32
-ifeq ($(CONFIG_SND_BIT32_EMUL),y)
-  obj-y += ioctl32/_ioctl32.o
-endif
+obj-$(CONFIG_SND_MIXER_OSS) += oss/
+obj-$(CONFIG_SND_PCM_OSS) += snd-pcm.o snd-timer.o oss/
+obj-$(CONFIG_SND_SEQUENCER) += snd-timer.o seq/
+obj-$(CONFIG_SND_BIT32_EMUL) += ioctl32/
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_DUMMY) += snd-pcm.o snd-timer.o snd.o
@@ -111,7 +93,5 @@
   obj-$(CONFIG_SND_SB16) += snd-hwdep.o
   obj-$(CONFIG_SND_SBAWE) += snd-hwdep.o
 endif
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/core/ioctl32/Makefile b/sound/core/ioctl32/Makefile
--- a/sound/core/ioctl32/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/core/ioctl32/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ioctl32.o
-
 snd-ioctl32-objs := ioctl32.o pcm32.o rawmidi32.o timer32.o hwdep32.o
 ifeq ($(CONFIG_SND_SEQUENCER),y)
   snd-ioctl32-objs += seq32.o
diff -Nru a/sound/core/oss/Makefile b/sound/core/oss/Makefile
--- a/sound/core/oss/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/core/oss/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _oss.o
-
 export-objs  := mixer_oss.o
 
 snd-mixer-oss-objs := mixer_oss.o
diff -Nru a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
--- a/sound/core/oss/pcm_oss.c	Fri May 24 18:55:34 2002
+++ b/sound/core/oss/pcm_oss.c	Fri May 24 18:55:34 2002
@@ -59,8 +59,6 @@
 static int snd_pcm_oss_get_channels(snd_pcm_oss_file_t *pcm_oss_file);
 static int snd_pcm_oss_get_format(snd_pcm_oss_file_t *pcm_oss_file);
 
-EXPORT_NO_SYMBOLS;
-
 static inline mm_segment_t snd_enter_user(void)
 {
 	mm_segment_t fs = get_fs();
diff -Nru a/sound/core/rtctimer.c b/sound/core/rtctimer.c
--- a/sound/core/rtctimer.c	Fri May 24 18:55:34 2002
+++ b/sound/core/rtctimer.c	Fri May 24 18:55:34 2002
@@ -216,6 +216,4 @@
 
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 #endif /* CONFIG_RTC || CONFIG_RTC_MODULE */
diff -Nru a/sound/core/seq/Makefile b/sound/core/seq/Makefile
--- a/sound/core/seq/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/core/seq/Makefile	Fri May 24 18:55:36 2002
@@ -3,19 +3,10 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _seq.o
-
 mod-subdirs  := instr
 
-subdir-$(CONFIG_SND) += instr
-ifeq ($(CONFIG_SND),y)
-  obj-y        += instr/_instr.o
-endif
-
-subdir-$(CONFIG_SND_SEQUENCER_OSS) += oss
-ifeq ($(CONFIG_SND_SEQUENCER_OSS),y)
-  obj-y	     += oss/_oss.o
-endif
+obj-$(CONFIG_SND) += instr/
+obj-$(CONFIG_SND_SEQUENCER_OSS) += oss/
 
 export-objs  := seq_device.o seq.o seq_ports.o seq_instr.o seq_midi_emul.o \
 		seq_midi_event.o seq_virmidi.o
@@ -80,7 +71,5 @@
 obj-$(CONFIG_SND_EMU10K1) += snd-seq-midi.o snd-seq.o snd-seq-device.o snd-seq-midi-event.o snd-seq-midi-emul.o snd-seq-virmidi.o
 obj-$(CONFIG_SND_TRIDENT) += snd-seq-midi.o snd-seq.o snd-seq-device.o snd-seq-midi-event.o snd-seq-midi-emul.o snd-seq-instr.o
 obj-$(CONFIG_SND_YMFPCI) += snd-seq-midi.o snd-seq.o snd-seq-device.o snd-seq-midi-event.o snd-seq-midi-emul.o snd-seq-instr.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/core/seq/instr/Makefile b/sound/core/seq/instr/Makefile
--- a/sound/core/seq/instr/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/core/seq/instr/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _instr.o
-
 export-objs  := ainstr_fm.o ainstr_simple.o ainstr_gf1.o ainstr_iw.o
 
 snd-ainstr-fm-objs := ainstr_fm.o
@@ -42,7 +40,5 @@
 obj-$(CONFIG_SND_SONICVIBES) += snd-ainstr-fm.o
 obj-$(CONFIG_SND_TRIDENT) += snd-ainstr-simple.o
 obj-$(CONFIG_SND_YMFPCI) += snd-ainstr-fm.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/core/seq/oss/Makefile b/sound/core/seq/oss/Makefile
--- a/sound/core/seq/oss/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/core/seq/oss/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _oss.o
-
 snd-seq-oss-objs  := seq_oss.o seq_oss_init.o seq_oss_timer.o seq_oss_ioctl.o \
 		     seq_oss_event.o seq_oss_rw.o seq_oss_synth.o \
 		     seq_oss_midi.o seq_oss_readq.o seq_oss_writeq.o
diff -Nru a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
--- a/sound/core/seq/oss/seq_oss.c	Fri May 24 18:55:36 2002
+++ b/sound/core/seq/oss/seq_oss.c	Fri May 24 18:55:36 2002
@@ -31,8 +31,6 @@
 /*
  * module option
  */
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("OSS-compatible sequencer module");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
--- a/sound/core/seq/seq_dummy.c	Fri May 24 18:55:36 2002
+++ b/sound/core/seq/seq_dummy.c	Fri May 24 18:55:36 2002
@@ -59,7 +59,6 @@
  */
 
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ALSA sequencer MIDI-through client");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
--- a/sound/core/seq/seq_midi.c	Fri May 24 18:55:34 2002
+++ b/sound/core/seq/seq_midi.c	Fri May 24 18:55:34 2002
@@ -38,7 +38,6 @@
 #include <sound/seq_midi_event.h>
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Frank van de Pol <fvdpol@home.nl>, Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth.");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/drivers/Makefile b/sound/drivers/Makefile
--- a/sound/drivers/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/drivers/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _drivers.o
-
 mod-subdirs  := opl3 mpu401
 
 snd-dummy-objs := dummy.o
@@ -18,9 +16,6 @@
 obj-$(CONFIG_SND_SERIAL_U16550) += snd-serial-u16550.o
 obj-$(CONFIG_SND_MTPAV) += snd-mtpav.o
 
-subdir-$(CONFIG_SND) += opl3 mpu401
-ifeq ($(CONFIG_SND),y)
-  obj-y += mpu401/_mpu401.o opl3/_opl3.o
-endif
+obj-$(CONFIG_SND) += opl3/ mpu401/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/drivers/dummy.c b/sound/drivers/dummy.c
--- a/sound/drivers/dummy.c	Fri May 24 18:55:35 2002
+++ b/sound/drivers/dummy.c	Fri May 24 18:55:35 2002
@@ -20,7 +20,7 @@
 
 #include <sound/driver.h>
 #include <linux/init.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/wait.h>
@@ -30,8 +30,6 @@
 #include <sound/rawmidi.h>
 #define SNDRV_GET_ID
 #include <sound/initval.h>
-
-EXPORT_NO_SYMBOLS;
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
diff -Nru a/sound/drivers/mpu401/Makefile b/sound/drivers/mpu401/Makefile
--- a/sound/drivers/mpu401/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/drivers/mpu401/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _mpu401.o
-
 export-objs  := mpu401_uart.o
 
 snd-mpu401-objs := mpu401.o
@@ -41,7 +39,5 @@
 obj-$(CONFIG_SND_ALI5451) += snd-mpu401-uart.o
 obj-$(CONFIG_SND_TRIDENT) += snd-mpu401-uart.o
 obj-$(CONFIG_SND_YMFPCI) += snd-mpu401-uart.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
--- a/sound/drivers/mpu401/mpu401.c	Fri May 24 18:55:36 2002
+++ b/sound/drivers/mpu401/mpu401.c	Fri May 24 18:55:36 2002
@@ -30,8 +30,6 @@
 #include <sound/initval.h>
 #include <linux/delay.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("MPU-401 UART");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
--- a/sound/drivers/mtpav.c	Fri May 24 18:55:34 2002
+++ b/sound/drivers/mtpav.c	Fri May 24 18:55:34 2002
@@ -64,8 +64,6 @@
 /*
  *      globals
  */
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Michael T. Mayers");
 MODULE_DESCRIPTION("MOTU MidiTimePiece AV multiport MIDI");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/drivers/opl3/Makefile b/sound/drivers/opl3/Makefile
--- a/sound/drivers/opl3/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/drivers/opl3/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _opl3.o
-
 export-objs  := opl3_lib.o
 
 snd-opl3-lib-objs := opl3_lib.o opl3_synth.o
@@ -64,7 +62,5 @@
   obj-$(CONFIG_SND_SONICVIBES) += snd-opl3-synth.o
   obj-$(CONFIG_SND_YMFPCI) += snd-opl3-synth.o
 endif
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
--- a/sound/drivers/opl3/opl3_seq.c	Fri May 24 18:55:33 2002
+++ b/sound/drivers/opl3/opl3_seq.c	Fri May 24 18:55:33 2002
@@ -26,8 +26,6 @@
 #include <linux/init.h>
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("ALSA driver for OPL3 FM synth");
diff -Nru a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
--- a/sound/drivers/serial-u16550.c	Fri May 24 18:55:33 2002
+++ b/sound/drivers/serial-u16550.c	Fri May 24 18:55:33 2002
@@ -42,7 +42,6 @@
 
 #include <linux/serial_reg.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION("MIDI serial u16550");
 MODULE_LICENSE("GPL");
 MODULE_CLASSES("{sound}");
diff -Nru a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
--- a/sound/drivers/virmidi.c	Fri May 24 18:55:34 2002
+++ b/sound/drivers/virmidi.c	Fri May 24 18:55:34 2002
@@ -51,8 +51,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("Dummy soundcard for virtual rawmidi devices");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/i2c/Makefile b/sound/i2c/Makefile
--- a/sound/i2c/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/i2c/Makefile	Fri May 24 18:55:36 2002
@@ -3,7 +3,7 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _i2c.o
+mod-subdirs := l3
 
 export-objs  := i2c.o cs8427.o tea6330t.o
 
@@ -11,13 +11,7 @@
 snd-cs8427-objs := cs8427.o
 snd-tea6330t-objs := tea6330t.o
 
-ifeq ($(subst m,y,$(CONFIG_L3)),y)
-  subdir-$(CONFIG_L3) += l3
-endif
-ifeq ($(filter $(subdir-y),l3),l3)
-  subdir-m := l3
-  obj-y += l3/l3.o
-endif
+obj-$(CONFIG_SND) += l3/
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_INTERWAVE_STB) += snd-tea6330t.o snd-i2c.o
diff -Nru a/sound/i2c/l3/Makefile b/sound/i2c/l3/Makefile
--- a/sound/i2c/l3/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/i2c/l3/Makefile	Fri May 24 18:55:33 2002
@@ -2,8 +2,6 @@
 # Makefile for ALSA
 #
 
-O_TARGET = l3.o
-
 export-objs += uda1341.o
 
 snd-uda1341-objs := uda1341.o
diff -Nru a/sound/isa/Makefile b/sound/isa/Makefile
--- a/sound/isa/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/isa/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _isa.o
-
 mod-subdirs  := ad1816a ad1848 cs423x es1688 gus opti9xx sb wavefront
 
 snd-als100-objs := als100.o
@@ -24,16 +22,7 @@
 obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o
 obj-$(CONFIG_SND_SGALAXY) += snd-sgalaxy.o
 
-subdir-$(CONFIG_SND) += ad1816a ad1848 cs423x es1688 gus opti9xx sb wavefront
-ifeq ($(CONFIG_SND),y)
-  obj-y += ad1816a/_ad1816a.o \
-	   ad1848/_ad1848.o \
-	   cs423x/_cs423x.o \
-	   es1688/_es1688.o \
-	   gus/_gus.o \
-	   opti9xx/_opti9xx.o \
-	   sb/_sb.o \
-	   wavefront/_wavefront.o
-endif
+obj-$(CONFIG_SND) += ad1816a/ ad1848/ cs423x/ es1688/ gus/ opti9xx/ \
+		     sb/ wavefront/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/isa/ad1816a/Makefile b/sound/isa/ad1816a/Makefile
--- a/sound/isa/ad1816a/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/isa/ad1816a/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ad1816a.o
-
 export-objs  := ad1816a_lib.o
 
 snd-ad1816a-lib-objs := ad1816a_lib.o
diff -Nru a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
--- a/sound/isa/ad1816a/ad1816a.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/ad1816a/ad1816a.c	Fri May 24 18:55:34 2002
@@ -38,7 +38,6 @@
 
 #define PFX "ad1816a: "
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("AD1816A, AD1815");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/ad1848/Makefile b/sound/isa/ad1848/Makefile
--- a/sound/isa/ad1848/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/isa/ad1848/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ad1848.o
-
 export-objs  := ad1848_lib.o
 
 snd-ad1848-lib-objs := ad1848_lib.o
@@ -15,7 +13,5 @@
 obj-$(CONFIG_SND_SGALAXY) += snd-ad1848-lib.o
 obj-$(CONFIG_SND_AD1848) += snd-ad1848.o snd-ad1848-lib.o
 obj-$(CONFIG_SND_OPTI92X_AD1848) += snd-ad1848-lib.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
--- a/sound/isa/ad1848/ad1848.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/ad1848/ad1848.c	Fri May 24 18:55:36 2002
@@ -32,7 +32,6 @@
 
 #define chip_t ad1848_t
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("AD1848/AD1847/CS4248");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/als100.c b/sound/isa/als100.c
--- a/sound/isa/als100.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/als100.c	Fri May 24 18:55:33 2002
@@ -41,8 +41,6 @@
 
 #define PFX "als100: "
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("Avance Logic ALS1X0");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/azt2320.c b/sound/isa/azt2320.c
--- a/sound/isa/azt2320.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/azt2320.c	Fri May 24 18:55:36 2002
@@ -52,8 +52,6 @@
 
 #define PFX "azt2320: "
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("Aztech Systems AZT2320");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
--- a/sound/isa/cmi8330.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/cmi8330.c	Fri May 24 18:55:33 2002
@@ -52,8 +52,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>");
 MODULE_DESCRIPTION("C-Media CMI8330");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/cs423x/Makefile b/sound/isa/cs423x/Makefile
--- a/sound/isa/cs423x/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/isa/cs423x/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _cs423x.o
-
 export-objs  := cs4231_lib.o cs4236_lib.o
 
 snd-cs4231-lib-objs := cs4231_lib.o
@@ -24,7 +22,5 @@
 obj-$(CONFIG_SND_INTERWAVE_STB) += snd-cs4231-lib.o
 obj-$(CONFIG_SND_OPTI92X_CS4231) += snd-cs4231-lib.o
 obj-$(CONFIG_SND_WAVEFRONT) += snd-cs4231-lib.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
--- a/sound/isa/cs423x/cs4231.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/cs423x/cs4231.c	Fri May 24 18:55:33 2002
@@ -32,8 +32,6 @@
 
 #define chip_t cs4231_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Generic CS4231");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
--- a/sound/isa/cs423x/cs4236.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/cs423x/cs4236.c	Fri May 24 18:55:33 2002
@@ -36,7 +36,6 @@
 
 #define chip_t cs4231_t
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_LICENSE("GPL");
 MODULE_CLASSES("{sound}");
diff -Nru a/sound/isa/dt0197h.c b/sound/isa/dt0197h.c
--- a/sound/isa/dt0197h.c	Fri May 24 18:55:35 2002
+++ b/sound/isa/dt0197h.c	Fri May 24 18:55:35 2002
@@ -38,8 +38,6 @@
 
 #define PFX "dt0197h: "
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("Diamond Technologies DT-0197H");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/es1688/Makefile b/sound/isa/es1688/Makefile
--- a/sound/isa/es1688/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/isa/es1688/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _es1688.o
-
 export-objs  := es1688_lib.o
 
 snd-es1688-lib-objs := es1688_lib.o
diff -Nru a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
--- a/sound/isa/es1688/es1688.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/es1688/es1688.c	Fri May 24 18:55:34 2002
@@ -36,8 +36,6 @@
 
 #define chip_t es1688_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("ESS ESx688 AudioDrive");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/es18xx.c b/sound/isa/es18xx.c
--- a/sound/isa/es18xx.c	Fri May 24 18:55:35 2002
+++ b/sound/isa/es18xx.c	Fri May 24 18:55:35 2002
@@ -1883,8 +1883,6 @@
 
 /* Card level */
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>, Abramo Bagnara <abramo@alsa-project.org>");  
 MODULE_DESCRIPTION("ESS ES18xx AudioDrive");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/gus/Makefile b/sound/isa/gus/Makefile
--- a/sound/isa/gus/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/isa/gus/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _gus.o
-
 export-objs  := gus_main.o gus_volume.o
 
 snd-gus-lib-objs := gus_main.o \
@@ -34,7 +32,5 @@
   obj-$(CONFIG_SND_INTERWAVE) += snd-gus-synth.o
   obj-$(CONFIG_SND_INTERWAVE_STB) += snd-gus-synth.o
 endif
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c
--- a/sound/isa/gus/gus_synth.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/gus/gus_synth.c	Fri May 24 18:55:36 2002
@@ -30,8 +30,6 @@
 MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards - Synthesizer");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
 /*
  *
  */
diff -Nru a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
--- a/sound/isa/gus/gusclassic.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/gus/gusclassic.c	Fri May 24 18:55:36 2002
@@ -32,8 +32,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Gravis UltraSound Classic");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
--- a/sound/isa/gus/gusextreme.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/gus/gusextreme.c	Fri May 24 18:55:36 2002
@@ -35,8 +35,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Gravis UltraSound Extreme");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
--- a/sound/isa/gus/gusmax.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/gus/gusmax.c	Fri May 24 18:55:33 2002
@@ -33,8 +33,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Gravis UltraSound MAX");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
--- a/sound/isa/gus/interwave.c	Fri May 24 18:55:33 2002
+++ b/sound/isa/gus/interwave.c	Fri May 24 18:55:33 2002
@@ -44,8 +44,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_CLASSES("{sound}");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
--- a/sound/isa/opl3sa2.c	Fri May 24 18:55:35 2002
+++ b/sound/isa/opl3sa2.c	Fri May 24 18:55:35 2002
@@ -36,8 +36,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Yamaha OPL3SA2+");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/opti9xx/Makefile b/sound/isa/opti9xx/Makefile
--- a/sound/isa/opti9xx/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/isa/opti9xx/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _opti9xx.o
-
 snd-opti92x-ad1848-objs := opti92x-ad1848.o
 snd-opti92x-cs4231-objs := opti92x-cs4231.o
 snd-opti93x-objs := opti93x.o
diff -Nru a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
--- a/sound/isa/opti9xx/opti92x-ad1848.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/opti9xx/opti92x-ad1848.c	Fri May 24 18:55:34 2002
@@ -53,7 +53,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_CLASSES("{sound}");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile
--- a/sound/isa/sb/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/isa/sb/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _sb.o
-
 export-objs  := emu8000.o emu8000_synth.o sb_common.o sb8_main.o sb16_main.o sb16_csp.o
 
 snd-sb-common-objs := sb_common.o sb_mixer.o
@@ -33,7 +31,5 @@
 ifeq ($(subst m,y,$(CONFIG_SND_SEQUENCER)),y)
   obj-$(CONFIG_SND_SBAWE) += snd-emu8000-synth.o
 endif
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
--- a/sound/isa/sb/emu8000_synth.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/sb/emu8000_synth.c	Fri May 24 18:55:34 2002
@@ -24,8 +24,6 @@
 #include <linux/init.h>
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Takashi Iwai, Steve Ratcliffe");
 MODULE_DESCRIPTION("Emu8000 synth plug-in routine");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c
--- a/sound/isa/sb/es968.c	Fri May 24 18:55:35 2002
+++ b/sound/isa/sb/es968.c	Fri May 24 18:55:35 2002
@@ -35,8 +35,6 @@
 
 #define chip_t sb_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("ESS AudioDrive ES968");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
--- a/sound/isa/sb/sb16.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/sb/sb16.c	Fri May 24 18:55:34 2002
@@ -49,10 +49,6 @@
 #define PFX "sb16: "
 #endif
 
-#ifndef SNDRV_SBAWE
-EXPORT_NO_SYMBOLS;
-#endif
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_LICENSE("GPL");
 MODULE_CLASSES("{sound}");
diff -Nru a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
--- a/sound/isa/sb/sb8.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/sb/sb8.c	Fri May 24 18:55:36 2002
@@ -32,8 +32,6 @@
 
 #define chip_t sb_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Sound Blaster 1.0/2.0/Pro");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
--- a/sound/isa/sgalaxy.c	Fri May 24 18:55:36 2002
+++ b/sound/isa/sgalaxy.c	Fri May 24 18:55:36 2002
@@ -34,8 +34,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Christopher Butler <chrisb@sandy.force9.co.uk>");
 MODULE_DESCRIPTION("Aztech Sound Galaxy");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/isa/wavefront/Makefile b/sound/isa/wavefront/Makefile
--- a/sound/isa/wavefront/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/isa/wavefront/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _wavefront.o
-
 snd-wavefront-objs := wavefront.o wavefront_fx.o wavefront_synth.o wavefront_midi.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
--- a/sound/isa/wavefront/wavefront.c	Fri May 24 18:55:34 2002
+++ b/sound/isa/wavefront/wavefront.c	Fri May 24 18:55:34 2002
@@ -35,7 +35,6 @@
 
 #define chip_t cs4231_t
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
 MODULE_DESCRIPTION("Turtle Beach Wavefront");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/oss/Makefile b/sound/oss/Makefile
--- a/sound/oss/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/oss/Makefile	Fri May 24 18:55:34 2002
@@ -3,8 +3,6 @@
 # 18 Apr 1998, Michael Elizabeth Chastain, <mailto:mec@shout.net>
 # Rewritten to use lists instead of if-statements.
 
-O_TARGET	:= _oss.o
-
 # All of the (potential) objects that export symbols.
 # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
 
@@ -78,23 +76,9 @@
   obj-$(CONFIG_SOUND_EMU10K1)	+= sound.o
 endif
 
-subdir-$(CONFIG_SOUND_EMU10K1) += emu10k1
-subdir-$(CONFIG_SOUND_CS4281) += cs4281
-
-ifeq ($(CONFIG_SOUND_EMU10K1),y)
-  obj-y += emu10k1/_emu10k1.o
-endif
-
-ifeq ($(CONFIG_SOUND_CS4281),y)
-  obj-y += cs4281/_cs4281.o
-endif
-
-subdir-$(CONFIG_DMASOUND) += dmasound
-
-ifeq ($(CONFIG_DMASOUND),y)
-  obj-y += dmasound/_dmasound.o
-endif
-
+obj-$(CONFIG_SOUND_EMU10K1)	+= emu10k1/
+obj-$(CONFIG_SOUND_CS4281)	+= cs4281/
+obj-$(CONFIG_DMASOUND)		+= dmasound/
 
 # Declare multi-part drivers.
 
diff -Nru a/sound/oss/awe_wave.c b/sound/oss/awe_wave.c
--- a/sound/oss/awe_wave.c	Fri May 24 18:55:35 2002
+++ b/sound/oss/awe_wave.c	Fri May 24 18:55:35 2002
@@ -219,7 +219,6 @@
 MODULE_PARM_DESC(memsize, "onboard DRAM size in Kbytes");
 MODULE_PARM(isapnp, "i");
 MODULE_PARM_DESC(isapnp, "use ISAPnP detection");
-EXPORT_NO_SYMBOLS;
 
 /* DRAM start offset */
 static int awe_mem_start = AWE_DRAM_OFFSET;
diff -Nru a/sound/oss/cs4281/Makefile b/sound/oss/cs4281/Makefile
--- a/sound/oss/cs4281/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/oss/cs4281/Makefile	Fri May 24 18:55:33 2002
@@ -1,8 +1,6 @@
 # Makefile for Cirrus Logic-Crystal CS4281 
 #
 
-O_TARGET := _cs4281.o
-
 obj-$(CONFIG_SOUND_CS4281) += cs4281.o
 
 cs4281-objs += cs4281m.o
diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
--- a/sound/oss/cs4281/cs4281m.c	Fri May 24 18:55:36 2002
+++ b/sound/oss/cs4281/cs4281m.c	Fri May 24 18:55:36 2002
@@ -83,7 +83,6 @@
 #include "cs4281pm.h"
 
 struct cs4281_state;
-EXPORT_NO_SYMBOLS;
 
 static void stop_dac(struct cs4281_state *s);
 static void stop_adc(struct cs4281_state *s);
diff -Nru a/sound/oss/dmasound/Makefile b/sound/oss/dmasound/Makefile
--- a/sound/oss/dmasound/Makefile	Fri May 24 18:55:34 2002
+++ b/sound/oss/dmasound/Makefile	Fri May 24 18:55:34 2002
@@ -1,13 +1,6 @@
 #
 # Makefile for the DMA sound driver
 #
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile...
-
-O_TARGET = _dmasound.o
 
 export-objs := dmasound_core.o
 
diff -Nru a/sound/oss/emu10k1/Makefile b/sound/oss/emu10k1/Makefile
--- a/sound/oss/emu10k1/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/oss/emu10k1/Makefile	Fri May 24 18:55:36 2002
@@ -2,8 +2,6 @@
 #
 # 12 Apr 2000 Rui Sousa
 
-O_TARGET := _emu10k1.o
-
 obj-$(CONFIG_SOUND_EMU10K1) += emu10k1.o
 
 emu10k1-objs := audio.o cardmi.o cardmo.o cardwi.o cardwo.o ecard.o \
diff -Nru a/sound/oss/emu10k1/cardmi.c b/sound/oss/emu10k1/cardmi.c
--- a/sound/oss/emu10k1/cardmi.c	Fri May 24 18:55:36 2002
+++ b/sound/oss/emu10k1/cardmi.c	Fri May 24 18:55:36 2002
@@ -31,7 +31,7 @@
  */
 
 #include <linux/slab.h>
-#include <linux/sched.h>
+#include <linux/jiffies.h>
 
 #include "hwaccess.h"
 #include "8010.h"
diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
--- a/sound/oss/via82cxxx_audio.c	Fri May 24 18:55:34 2002
+++ b/sound/oss/via82cxxx_audio.c	Fri May 24 18:55:34 2002
@@ -3356,9 +3356,6 @@
 MODULE_DESCRIPTION("DSP audio and mixer driver for Via 82Cxxx audio devices");
 MODULE_LICENSE("GPL");
 
-EXPORT_NO_SYMBOLS;
-
-
 
 #ifdef VIA_PROC_FS
 
diff -Nru a/sound/oss/vidc.c b/sound/oss/vidc.c
--- a/sound/oss/vidc.c	Fri May 24 18:55:33 2002
+++ b/sound/oss/vidc.c	Fri May 24 18:55:33 2002
@@ -546,4 +546,3 @@
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("VIDC20 audio driver");
 MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -Nru a/sound/pci/Makefile b/sound/pci/Makefile
--- a/sound/pci/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/pci/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _pci.o
-
 mod-subdirs  := ac97 ali5451 cs46xx emu10k1 korg1212 nm256 rme9652 trident ymfpci
 
 snd-als4000-objs := als4000.o
@@ -42,17 +40,6 @@
 obj-$(CONFIG_SND_VIA686) += snd-via686.o
 obj-$(CONFIG_SND_VIA8233) += snd-via8233.o
 
-subdir-$(CONFIG_SND) += ac97 ali5451 cs46xx emu10k1 korg1212 nm256 rme9652 trident ymfpci
-ifeq ($(CONFIG_SND),y)
-  obj-y += ac97/_ac97.o \
-	   ali5451/_ali5451.o \
-	   cs46xx/_cs46xx.o \
-	   emu10k1/_emu10k1.o \
-	   korg1212/_korg1212.o \
-	   nm256/_nm256.o \
-	   rme9652/_rme9652.o \
-	   trident/_trident.o \
-	   ymfpci/_ymfpci.o
-endif
+obj-$(CONFIG_SND) += ac97/ ali5451/ cs46xx/ emu10k1/ korg1212/ nm256/ rme9652/ trident/ ymfpci/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
--- a/sound/pci/ac97/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/pci/ac97/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ac97.o
-
 export-objs  := ac97_codec.o ak4531_codec.o
 
 snd-ac97-codec-objs := ac97_codec.o
@@ -27,7 +25,5 @@
 obj-$(CONFIG_SND_NM256) += snd-ac97-codec.o
 obj-$(CONFIG_SND_TRIDENT) += snd-ac97-codec.o
 obj-$(CONFIG_SND_YMFPCI) += snd-ac97-codec.o
-
-obj-m := $(sort $(obj-m))
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/pci/ali5451/Makefile b/sound/pci/ali5451/Makefile
--- a/sound/pci/ali5451/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/pci/ali5451/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ali5451.o
-
 snd-ali5451-objs := ali5451.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
--- a/sound/pci/ali5451/ali5451.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/ali5451/ali5451.c	Fri May 24 18:55:36 2002
@@ -42,7 +42,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Matt Wu <Matt_Wu@acersoftech.com.cn>");
 MODULE_DESCRIPTION("ALI M5451");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/als4000.c b/sound/pci/als4000.c
--- a/sound/pci/als4000.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/als4000.c	Fri May 24 18:55:36 2002
@@ -58,8 +58,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Bart Hartgers <bart@etpmod.phys.tue.nl>");
 MODULE_DESCRIPTION("Avance Logic ALS4000");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/cmipci.c b/sound/pci/cmipci.c
--- a/sound/pci/cmipci.c	Fri May 24 18:55:33 2002
+++ b/sound/pci/cmipci.c	Fri May 24 18:55:33 2002
@@ -35,8 +35,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("C-Media CMI8x38 PCI");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/cs4281.c b/sound/pci/cs4281.c
--- a/sound/pci/cs4281.c	Fri May 24 18:55:35 2002
+++ b/sound/pci/cs4281.c	Fri May 24 18:55:35 2002
@@ -39,8 +39,6 @@
 #include <linux/gameport.h>
 #endif
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Cirrus Logic CS4281");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/cs46xx/Makefile b/sound/pci/cs46xx/Makefile
--- a/sound/pci/cs46xx/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/pci/cs46xx/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _cs46xx.o
-
 snd-cs46xx-objs := cs46xx.o cs46xx_lib.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
--- a/sound/pci/cs46xx/cs46xx.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/cs46xx/cs46xx.c	Fri May 24 18:55:36 2002
@@ -33,8 +33,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Cirrus Logic Sound Fusion CS46XX");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/emu10k1/Makefile b/sound/pci/emu10k1/Makefile
--- a/sound/pci/emu10k1/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/pci/emu10k1/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _emu10k1.o
-
 export-objs  := emu10k1_main.o
 
 snd-emu10k1-objs := emu10k1.o emu10k1_main.o \
diff -Nru a/sound/pci/emu10k1/emu10k1_synth.c b/sound/pci/emu10k1/emu10k1_synth.c
--- a/sound/pci/emu10k1/emu10k1_synth.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/emu10k1/emu10k1_synth.c	Fri May 24 18:55:34 2002
@@ -96,9 +96,6 @@
 }
 
 
-EXPORT_NO_SYMBOLS;
-
-
 /*
  *  INIT part
  */
diff -Nru a/sound/pci/ens1370.c b/sound/pci/ens1370.c
--- a/sound/pci/ens1370.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/ens1370.c	Fri May 24 18:55:34 2002
@@ -42,8 +42,6 @@
 #define CHIP1370
 #endif
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Thomas Sailer <sailer@ife.ee.ethz.ch>");
 MODULE_LICENSE("GPL");
 MODULE_CLASSES("{sound}");
diff -Nru a/sound/pci/es1938.c b/sound/pci/es1938.c
--- a/sound/pci/es1938.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/es1938.c	Fri May 24 18:55:36 2002
@@ -65,8 +65,6 @@
 
 #define chip_t es1938_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaromir Koutek <miri@punknet.cz>");
 MODULE_DESCRIPTION("ESS Solo-1");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/es1968.c b/sound/pci/es1968.c
--- a/sound/pci/es1968.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/es1968.c	Fri May 24 18:55:36 2002
@@ -114,7 +114,6 @@
 #define CARD_NAME "ESS Maestro1/2"
 #define DRIVER_NAME "ES1968"
 
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION("ESS Maestro");
 MODULE_CLASSES("{sound}");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/fm801.c b/sound/pci/fm801.c
--- a/sound/pci/fm801.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/fm801.c	Fri May 24 18:55:36 2002
@@ -35,8 +35,6 @@
 
 #define chip_t fm801_t
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("ForteMedia FM801");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/ice1712.c b/sound/pci/ice1712.c
--- a/sound/pci/ice1712.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/ice1712.c	Fri May 24 18:55:36 2002
@@ -49,8 +49,6 @@
 #define SND_CS8404
 #include <sound/cs8403.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("ICEnsemble ICE1712 (Envy24)");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c	Fri May 24 18:55:33 2002
+++ b/sound/pci/intel8x0.c	Fri May 24 18:55:33 2002
@@ -40,8 +40,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,MX440; SiS 7012");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/korg1212/Makefile b/sound/pci/korg1212/Makefile
--- a/sound/pci/korg1212/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/pci/korg1212/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _korg1212.o
-
 snd-korg1212-objs := korg1212.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
--- a/sound/pci/korg1212/korg1212.c	Fri May 24 18:55:33 2002
+++ b/sound/pci/korg1212/korg1212.c	Fri May 24 18:55:33 2002
@@ -373,7 +373,6 @@
         u16 rightADCInSens;          // ADC right channel input sensitivity
 };
 
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION("korg1212");
 MODULE_LICENSE("GPL");
 MODULE_CLASSES("{sound}");
diff -Nru a/sound/pci/maestro3.c b/sound/pci/maestro3.c
--- a/sound/pci/maestro3.c	Fri May 24 18:55:33 2002
+++ b/sound/pci/maestro3.c	Fri May 24 18:55:33 2002
@@ -47,8 +47,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ESS Maestro3 PCI");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/nm256/Makefile b/sound/pci/nm256/Makefile
--- a/sound/pci/nm256/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/pci/nm256/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _nm256.o
-
 snd-nm256-objs := nm256.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
--- a/sound/pci/nm256/nm256.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/nm256/nm256.c	Fri May 24 18:55:34 2002
@@ -42,8 +42,6 @@
 #define CARD_NAME "NeoMagic 256AV/ZX"
 #define DRIVER_NAME "NM256"
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("NeoMagic NM256AV/ZX");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/rme32.c b/sound/pci/rme32.c
--- a/sound/pci/rme32.c	Fri May 24 18:55:36 2002
+++ b/sound/pci/rme32.c	Fri May 24 18:55:36 2002
@@ -49,7 +49,6 @@
 static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 
-EXPORT_NO_SYMBOLS;
 MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(snd_index, "Index value for RME Digi32 soundcard.");
 MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);
diff -Nru a/sound/pci/rme96.c b/sound/pci/rme96.c
--- a/sound/pci/rme96.c	Fri May 24 18:55:35 2002
+++ b/sound/pci/rme96.c	Fri May 24 18:55:35 2002
@@ -37,9 +37,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-/* note, two last pcis should be equal, it is not a bug */
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Anders Torger <torger@ludd.luth.se>");
 MODULE_DESCRIPTION("RME Digi96, Digi96/8, Digi96/8 PRO, Digi96/8 PST, "
 		   "Digi96/8 PAD");
diff -Nru a/sound/pci/rme9652/Makefile b/sound/pci/rme9652/Makefile
--- a/sound/pci/rme9652/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/pci/rme9652/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _rme9652.o
-
 export-objs  := rme9652_mem.o
 
 snd-rme9652-mem-objs := rme9652_mem.o
diff -Nru a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
--- a/sound/pci/rme9652/rme9652.c	Fri May 24 18:55:35 2002
+++ b/sound/pci/rme9652/rme9652.c	Fri May 24 18:55:35 2002
@@ -39,7 +39,6 @@
 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int snd_precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
 
-EXPORT_NO_SYMBOLS;
 MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(snd_index, "Index value for RME Digi9652 (Hammerfall) soundcard.");
 MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);
diff -Nru a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
--- a/sound/pci/sonicvibes.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/sonicvibes.c	Fri May 24 18:55:34 2002
@@ -40,8 +40,6 @@
 #include <linux/gameport.h>
 #endif
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("S3 SonicVibes PCI");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/trident/Makefile b/sound/pci/trident/Makefile
--- a/sound/pci/trident/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/pci/trident/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _trident.o
-
 export-objs  := trident_main.o
 
 snd-trident-objs := trident.o trident_main.o trident_memory.o
diff -Nru a/sound/pci/trident/trident_synth.c b/sound/pci/trident/trident_synth.c
--- a/sound/pci/trident/trident_synth.c	Fri May 24 18:55:35 2002
+++ b/sound/pci/trident/trident_synth.c	Fri May 24 18:55:35 2002
@@ -27,8 +27,6 @@
 #include <sound/trident.h>
 #include <sound/seq_device.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Scott McNab <jedi@tartarus.uwa.edu.au>");
 MODULE_DESCRIPTION("Routines for Trident 4DWave NX/DX soundcards - Synthesizer");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/via686.c b/sound/pci/via686.c
--- a/sound/pci/via686.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/via686.c	Fri May 24 18:55:34 2002
@@ -34,8 +34,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("VIA VT82C686A");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/via8233.c b/sound/pci/via8233.c
--- a/sound/pci/via8233.c	Fri May 24 18:55:34 2002
+++ b/sound/pci/via8233.c	Fri May 24 18:55:34 2002
@@ -35,8 +35,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Tjeerd.Mulder@fujitsu-siemens.com");
 MODULE_DESCRIPTION("VIA VT8233");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/pci/ymfpci/Makefile b/sound/pci/ymfpci/Makefile
--- a/sound/pci/ymfpci/Makefile	Fri May 24 18:55:36 2002
+++ b/sound/pci/ymfpci/Makefile	Fri May 24 18:55:36 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ymfpci.o
-
 snd-ymfpci-objs := ymfpci.o ymfpci_main.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
--- a/sound/pci/ymfpci/ymfpci.c	Fri May 24 18:55:35 2002
+++ b/sound/pci/ymfpci/ymfpci.c	Fri May 24 18:55:35 2002
@@ -30,8 +30,6 @@
 #define SNDRV_GET_ID
 #include <sound/initval.h>
 
-EXPORT_NO_SYMBOLS;
-
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Yamaha DS-XG PCI");
 MODULE_LICENSE("GPL");
diff -Nru a/sound/ppc/Makefile b/sound/ppc/Makefile
--- a/sound/ppc/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/ppc/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _ppc.o
-
 snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o keywest.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/ppc/powermac.c b/sound/ppc/powermac.c
--- a/sound/ppc/powermac.c	Fri May 24 18:55:35 2002
+++ b/sound/ppc/powermac.c	Fri May 24 18:55:35 2002
@@ -29,7 +29,6 @@
 
 #define CHIP_NAME "PMac"
 
-EXPORT_NO_SYMBOLS;
 MODULE_DESCRIPTION("PowerMac");
 MODULE_CLASSES("{sound}");
 MODULE_DEVICES("{{Apple,PowerMac}}");
diff -Nru a/sound/synth/Makefile b/sound/synth/Makefile
--- a/sound/synth/Makefile	Fri May 24 18:55:33 2002
+++ b/sound/synth/Makefile	Fri May 24 18:55:33 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _synth.o
-
 mod-subdirs  := emux
 
 export-objs  := util_mem.o
@@ -18,9 +16,6 @@
   obj-$(CONFIG_SND_SBAWE) += snd-util-mem.o
 endif
 
-subdir-$(CONFIG_SND) += emux
-ifeq ($(CONFIG_SND),y)
-  obj-y += emux/_emux.o
-endif
+obj-$(CONFIG_SND) += emux/
 
 include $(TOPDIR)/Rules.make
diff -Nru a/sound/synth/emux/Makefile b/sound/synth/emux/Makefile
--- a/sound/synth/emux/Makefile	Fri May 24 18:55:35 2002
+++ b/sound/synth/emux/Makefile	Fri May 24 18:55:35 2002
@@ -3,8 +3,6 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-O_TARGET     := _emux.o
-
 export-objs  := emux.o
 
 snd-emux-synth-objs := emux.o emux_synth.o emux_seq.o emux_nrpn.o \
